Wordpress cannot deactivate a script / style that has a request

Not sure if I phrased it correctly, but basically I wanted to download the CSS / JS plugin only on pages that use actual plugins. I got a lot of things thanks to searching through plugin files for any descriptors used in wp_enqueue_script inside plugins and just wp_dequeue_script them in functions.php

However, there are some style enqueues that include a .php and not a css file, for example .. in the plugin it inserts a file

 wp_enqueue_style("myrp-stuff", MYRP_PLUGIN_URL . "/myrp-hotlink-css.php"); 

so i tried:

 wp_dequeue_style('myrp-stuff'); wp_deregister_style('myrp-stuff'); 

Does not work

However, when the page / message is displayed, it is displayed as

 <link rel='stylesheet' id='myrp-stuff-css' href='http://www.modernlogic.co/wp/wp-content/plugins/MyRP/myrp-hotlink-css.php?ver=3.4.2' type='text/css' media='all' /> 

He adds -css to id and refuses to unregister / unregister and move.

I also tried the following with no luck

 wp_dequeue_style('myrp-stuff-css'); wp_deregister_style('myrp-stuff-css'); 

Any suggestions?

+7
source share
2 answers

Scripts and styles can be installed in any order and at any time before wp_print_* triggered. Which may make it difficult to remove them from the queue before exiting.

To make the decompression process, connect to wp_print_styles or wp_print_scripts with high priority wp_print_scripts , as this will remove scripts and styles immediately before exiting.

For example, in your plugin loader file or in the functions.php template file, you might have a function and an action, for example:

 function remove_assets() { wp_dequeue_style('myrp-stuff'); wp_deregister_style('myrp-stuff'); } add_action('wp_print_styles', 'remove_assets', 99999); 

Setting high priority (the third argument to add_action ) when connecting to an action will help ensure that the remove_assets is called last, just before printing scripts / styles.

Please note: although this method is legal for removing scripts / styles, it should not be used to add assets. For more information, see this Wordpress Core blog .

+13
source

To be sure, you placed your code inside a function called by an action like this ?:

 add_action('wp_enqueue_scripts', 'dequeue_function'); function dequeue_function() { wp_dequeue_style( array('myrp-stuff', 'myrp-stuff-css') ); wp_deregister_style( array('myrp-stuff', 'myrp-stuff-css') ); } 
+8
source

All Articles