WordPress with Composer and different plugins for dev/live.

I’m using a Bedrock-like setup where I handle WordPress core & plugins with Composer. I have my usual plugins in my composer.json within the “require” block, and some dev related plugins in “require-dev”. On dev/staging I do composer install and on the live site I do composer install –no-dev. Thats fine and all, but when … Read more

Where to put my global functions?

I currently have a global function in my functions.php file ein_error_log($message) { //push out $message to file… } But I want to start using it in my MU-Plugin directory and it doesn’t know it exists. So I assume it’s because MU-Plugins folder is read before the theme folder in WordPress’s hierarchy, which makes sense. But … Read more

Identifying the priority of style.css so I can make a small CSS file load last

I have a small bit of hourly-changing css and I want to keep it in a second file (apart from style.css) and load it after my theme’s style.css file. I believe I can make it load before style.css by setting its priority to the style.css minus one (e.g. if the main style.css has a priority … Read more

Conditionally dequeue dependency of scripts

Please note that, I’m not telling about conditionally enqueue/dequeue scripts, I’m referring to conditionally dequeue certain dependencies from an existing enqueued scripts in front end. And please note the question is not plugin-specific. I want to be enlightened about the general rules. I used Elementor (page builder) for front end. But it’s not used in … Read more

How to modify/extend/override a core method?

This is my first post. In advance, thank you for welcoming me… Context When you enqueue style, you can output your css link into conditional comments. global $wp_styles; wp_enqueue_style(“my_styles_ie”); $wp_styles->add_data(“my_styles_ie”, “conditional”, “(lt IE 9) & (!IEMobile)”); It will produce the following code : <!–[if (lt IE 9) & (!IEMobile)]> <link rel=”stylesheet” href=”#” /> <![endif]–> This … Read more

Add a script as a dependency to a registered script

wp_register_script() (see codex) allows you to specify dependencies: scripts that must be loaded before the one being registered is loaded (if it is loaded). But suppose the script is a third-party one (WordPress or another plug-in) so that you are not the one calling wp_register_script(). How can you inject a script as a dependency for … Read more

Concatenate and minify dependencies for enqueued JavaScript files

I’m loading a JavaScript file using wp_enqueue_script into my theme. However, along with it, I’m loading several jQuery files as well, as dependencies for the enqueued script (which has already been concatenated and minified by Grunt). Here is my code: add_action(‘wp_enqueue_scripts’, function() { wp_enqueue_script( ‘customscripts’, get_template_directory_uri() . ‘/assets/js/main.min.js’, array(‘jquery’, ‘jquery-form’, ‘json2’, ‘jquery-ui-autocomplete’), NULL, true ); … Read more