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.
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.
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:
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
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:
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.
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.