Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to disable a few plugins when my mobile theme is loaded. I read somewhere about using this particular function in my mobile theme functions.php file to remove scripts and css.

//Disable plugins
add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 );

function my_deregister_javascript() {
    wp_deregister_script( 'smp_common','smp_cookie','smp_colorbox','smp_meerkat','jquery','query-ui-sortable' );
}
//Deregister styles
add_action( 'wp_print_styles', 'my_deregister_styles', 100 );

Going by the above, i've been able to remove a few scripts, but unable to remove the 'share post' plugin as wp_enqueue is not mentioned in the script. Is there an alternative to disable this plugin?

share|improve this question
add comment

2 Answers

No, you have to fix the plugin code. Also, send a bug report to the plugin author. I'm sure she wants to improve the plugin.

share|improve this answer
    
This is not correct. IF the plugin is setup with proper script / style enqueues, they can absolutely be removed. @Chris_O below is correct. –  Pippin May 3 '12 at 15:55
1  
@Pippin Re-read the question: as wp_enqueue is not mentioned in the script. The missing proper setup is the whole point of my answer … –  toscho May 3 '12 at 16:15
    
bah, my bad. I missed that. –  Pippin May 3 '12 at 19:45
add comment

wp_deregister_script only takes a single script handle as the argument. Also it should be hooked into wp_enqueue_scripts not wp_print_scripts.

Also if the plugin is not using wp_enqueue it must be hooking into wp_head with add_action to print the inline script calls. You can remove the add_action function in the plugin with remove_action.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.