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've run into a problem using two different twitter plugins. One is for login and one is for displaying a twitter stream. The issue is they both use Oauth so I get a re-declare error when trying to login on my custom login template. Since I only use the twitter stream plugin on profiles I'd like to limit it's functions use purely to the profile but without actually changing the plugins core code. Possible?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

I would approach as follows:

  1. Identify all the action/filter hooks in the plugin
  2. Identify all scripts/styles being enqueued.
  3. Create a function that removes the actions/filters based on the page using remove_action, remove_filter, wp_deregister_style, wp_deregister_script

You could use something like the following:

function foo_disable_plugin(){
    if(is_page('PAGE_TITLE OR ID')){
        remove_filter('the_content', 'PLUGIN_FILTER_NAME');
        remove_action('wp_head', 'PLUGIN_ACTION_NAME');
        wp_deregister_script('PLUGIN_SCRIPT_NAME');
    }
}
add_action('template_redirect', 'foo_disable_plugin', 999999999);

If this doesn't work, you're probably going to have to make one of the plugin's classes pluggable.

if(!class_exists('CLASS_NAME')){
    //Class goes here
}
share|improve this answer
    
How do I reverse this line because I think it might be the problem require_once('twitteroauth/twitteroauth.php'); –  Pollux Khafra Sep 4 '12 at 14:20
    
@PolluxKhafra change it to include_once as it won't throw a fatal error. If it's already included it will be skipped. –  Brian Fegter Sep 4 '12 at 14:21
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.