WordPress with Composer and different plugins for dev/live.
WordPress with Composer and different plugins for dev/live.
WordPress with Composer and different plugins for dev/live.
Thanks to https://salferrarello.com/functions-plugin-mu-plugin-wordpress/ I was able to confirm when Code Runs All of the code across the different files of WordPress can be thought of as one big list of instructions. The code is run line by line starting at the beginning of this list through to the end of this list. The order is … Read more
All the information you need you can get from the global variable $wp_scripts: Code: function wpse124227_wp_script_styles_debug_basic() { global $wp_scripts, $wp_styles; echo ‘<pre>’; //Scripts print_r( $wp_scripts ); //Styles //print_r( $wp_styles ); echo ‘</pre>’; } add_filter( ‘wp_head’, ‘wpse124227_wp_script_styles_debug_basic’ ); To get a more specific output you have to define what you are looking for, instead of printing … Read more
When you properly enqueue a file, an instance of the wp_styles (more on this) class is created. The priority of actions is ignored. So it doesn’t matter if you write anything like add_action (‘wp_enqueue_scripts’,’function_adding_main_style’,10); add_action (‘wp_enqueue_scripts’,’function_adding_small_style’,11); The reason is exactly the existence of the dependency system. WP first collects all enqueued style files and then … Read more
Solution 1: Here we will dequeue and deregister elementor-dialog and elementor-frontend, then we will re-register elementor-frontend without the elementor-dialog dependency: // This needs to fire after priority 5 which is where Elementor // handles enqueueing scripts. We’re ok since the default is 10. add_action( ‘wp_enqueue_scripts’, ‘wpse_elementor_frontend_scripts’ ); function wpse_elementor_frontend_scripts() { // Optionally add guard clauses … Read more
There’s already a simliar answer by toscho here. Based on this one and from a look at WP_Styles, which extends WP_Dependencies and _WP_Dependency, I can’t see a reason why it should not work: Whatever got added as extra–conditional, gets thrown in: // ~/wp-includes/class.wp-styles.php if ( isset($obj->extra[‘conditional’]) && $obj->extra[‘conditional’] ) { $tag .= “<!–[if {$obj->extra[‘conditional’]}]>\n”; $end_cond … Read more
RequireJS in custom theme. Working Example
I was searching for the same answer this morning for my plugin AnsPress. So I sneak into WordPress plugin wp-admin/includes/plugin.php and got an idea. WordPress check for fatal error while activating plugin, so simplest solution will be trigger a fatal error and this will prevent WordPress to activate the plugin. In my below code I … Read more
Digging through https://github.com/WordPress/WordPress/blob/3.5.1/wp-includes/class.wp-dependencies.php all registered scripts are stored in the global $wp_scripts. You can access them directly through that, but I prefer to use the API when it exists. In this case, $wp_scripts->query() returns a particular registered script (a _WP_Dependency object – see source). A _WP_Dependency object stores the dependencies as an array of handles, … Read more
W3 Total Cache offers JS/CSS minification. I’m not familiar with the process they use, but if you are wanting to avoid using a plugin, you could take a look at their source code how they handle it.