• Hi, I would like to use your Custom CSS and JS plugin in my environment but I have the incompatibility with humanmade/S3-Uploads plugin.

    Using directly file_put_contents / file_get_contents that push direct to a specific folder it is impossible for me to make it works with automatic S3 sync.

    Do you plan to improve this plugin using the standard WordPress functions and/or allow extensions via WP hooks? Maybe just wrapping save/get with a function and an hook will be enough.

    Thanks in advance.

    Claudio

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author SilkyPress

    (@diana_burduja)

    Hello Claudio,

    can you send me a patch with your suggestion for changes so that it would work with automatic S3 sync?

    Thread Starter cbsk10

    (@cbsk10)

    Hi @diana_burduja, I found the issue!

    Inside the custom-css-js.php file, into the __construct function, the function $this->set_constants(); is not called inside the WordPress lifecycle and this is why is not working with other plugins (in this case the S3 upload).

    The function wp_upload_dir called inside the set_constants function has inside some WordPress hooks that are not available for other plugins because these plugins are loaded after this initialisation.

    I tried to wrap most of the __construct cost inside the init hook and everything seems working well.

    Image attached of the small refactoring.

    Waiting for your feedback.

    Thanks!

    Plugin Author SilkyPress

    (@diana_burduja)

    Hello Claudio,

    the S3-uploads plugin seems to load after the Simple Custom CSS & JS plugin and its “upload_dir” filter runs after the CCJ_UPLOAD_DIR / CCJ_UPLOAD_URL constants are defined.

    There are two other methods to solve your issue:

    1. upload the S3-uploads plugin in the “mu-plugins” directory. See the documentation for Must Use Plugins, which are always loaded much earlier than the other plugins, or
    2. define the CCJ_UPLOAD_DIR and the CCJ_UPLOAD_URL constants in your wp-config.php file, under the other S3_UPLOADS constants, as follows:
      • define( 'CCJ_UPLOAD_DIR', 's3://' . S3_UPLOADS_BUCKET . '/custom-css-js' );
      • define( 'CCJ_UPLOAD_URL', 'https://' . S3_UPLOADS_BUCKET . '.s3.amazonaws.com/custom-css-js' );

    Your solution to delay the Simple Custom CSS & JS plugin’s initialization seems also reasonable, though, as far as I know, it is not a requirement for a plugin to run after the “init” hook, nor is it a best or recommended practice.

    Let me know if any of the two proposed solutions work for you.

    Thread Starter cbsk10

    (@cbsk10)

    Hi @diana_burduja, thanks for the reply.

    I’m working with a multisite WordPress installation, but I cannot move the plugins to mu-plugins due some restrictions that I have on hosting site

    And hardcoding variables is not a feasible solution because the path has to be dynamic like

    S3_UPLOADS_BUCKET/uploads/sites/BLOG_ID/custom-css-js'

    so I don’t think it fits with my needs.

    Maybe plugins_loaded hook is better then the init? ??

    Because the S3 plugins starts with this hook. https://github.com/humanmade/S3-Uploads/blob/master/s3-uploads.php

    What do you think?

    Plugin Author SilkyPress

    (@diana_burduja)

    Hello @cbsk10,

    the Simple Custom CSS & JS plugin is currently actively installed on 600,000+ websites. Changing the point at which a plugin initializes is not a trivial matter; it can cause a row of issues related to incompatibilities with other plugins/themes.

    At this point it is easier to declare the plugin incompatible with Humanmade/S3-Uploads, then to possibly break thousands of websites overnight. I’m sure you also expect your website to keep on working after a plugin update, and not break because “the update fixes an incompatibility with another plugin”.

    Here is another solution for you: in the “plugins” folder add a file called “a-custom-css-js-s3-uploads.php” with this content, then open the “WP Admin -> Plugins” page and enable the newly created “Compat Simple Custom CSS and JS and Humanmad/S3-Uploads” plugin.

    This small plugin will be executed before the Simple Custom CSS and JS plugin because the plugins are loaded alphabetically and “a-custom-css-js-s3-uploads” will show up before “custom-css-js”.

    The small plugin will delay the initialization of the Simple Custom CSS and JS plugin to the “plugins_loaded” hook. Let me know if that works.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘humanmade/S3-Uploads compatibility’ is closed to new replies.