WordPress.org

Forums

[resolved] Help with disabling part of a plugin without editing code (2 posts)

  1. Doodlebee
    Member
    Posted 4 years ago #

    hey all - I'm a bit stuck and i was hoping someone might be able to help me out here.
    I'm working on a theme, and with the theme I'm writing a custom plugin. The theme in question will also be using the Yet Another Photo Blog plugin. Unfortunately, the YAPB plugin doesn't utilize register_script and wp_enqueue_script, and also (unfortunately) it applies it's stuff to regular posts. I want it to only be on a new post type I've created - not on the regular post stuff.

    So in this new plugin I'm writing for the theme I'm creating, I'm trying to remove filters and actions that the YAPB plugin inserts, so the field in the admin area only show where I want them to. The problem is, none of these removal techniques are working. I've also tried adding a style to the header to simply hide the div in question - but it won't hide it.

    I can only assume that the reason none of my attempts are working is because *my* plugin is being loaded before the YAPB plugin. That's the only viable reason I can come up with.

    The YAPB stuff is added via jQuery.

    So, what I'm wondering is, is there some piece of removal code I'm missing to effectively "deactivate" the plugin only on certain admin pages? or perhaps some piece of jQuery code I can use to turn off the YAPB jQuery function that inserts the code?

    I hav no problem getting the page I want this to be activated on. I'm just confused as to why remove_action() and remove_filter() won't work. Either it's because my plugin is loaded after the YAPB, or I'm doin' it wrong.

    My current code looks like so:

    $address = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER["REQUEST_URI"]; 		// get the full URL of current page
    
    // begin by testing what page we're on and see if it's a photo custom post type
      $addy_parts = explode('/', $address);
      $where = end($addy_parts);
      if(!strpos($where, 'post_type=photos')) { // we've determined we are not on the "photos" custom post type
    	remove_filter('edit_form_advanced', '_filter_edit_form_advanced');
    	remove_filter('edit_page_form', '_filter_edit_form_advanced');
    	remove_action('edit_post', '_on_edit_publish_save_post');
    	remove_action('publish_post', '_on_edit_publish_save_post');
    	remove_action('publish_post', '_on_publish_post');
    	remove_action('save_post', '_on_edit_publish_save_post');
    	remove_action('delete_post', '_on_delete_post');
    	remove_filter('manage_posts_columns', '_filter_manage_posts_columns');
    	remove_action('manage_posts_custom_column', '_filter_manage_posts_custom_column');
    	remove_filter('manage_pages_columns', '_filter_manage_pages_columns');
    	remove_action('manage_pages_custom_column', '_filter_manage_pages_custom_column');
    	remove_action('admin_head', '_on_admin_head');
    	remove_action('admin_menu', '_on_admin_menu');
      }

    For the record, I've checked each of those actions/filters one-by-one, and individually or all together, they do nothing. As as example, the code is added like so:

    add_action('admin_head', array(&$this, '_on_admin_head'));

    but

    remove_action('admin_menu', '_on_admin_menu');

    seems to have no effect.

    Anyone have any idea as to why? Thanks so much :)

  2. Doodlebee
    Member
    Posted 4 years ago #

    heh. I found it. I, for some unknown reason, had put "add_action('admin_header'...);" instead of "admin_head". Whoops. Thanks anyway!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.