• Resolved adfisch

    (@adfisch)


    Dear SmartCrawl team,

    thank you again for your awesome SEO plug-in. Previously, I had to ask you how to disable SmartCrawl for certain (custom) post types and you sent me some code. This time I was wondering if there’s a way to disable SmartCrawl’s meta box for certain taxonomies?

    In the long-term I guess it would be awesome if the SmartCrawl meta box could be enabled/disabled for certain post types. I mean the basic set-up is pretty much there (SmartCrawl > Title & Meta > Post Types/Taxonomies). It would be awesome if there was a switch (like there is in the SmartCrawl > Title & Meta > Archives section) with which the meta boxes could be enabled or disabled.

    Thank you in advance,
    Adrian

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Kasia – WPMU DEV Support

    (@wpmudev-support2)

    Hello @adfisch ,

    This time I was wondering if there’s a way to disable SmartCrawl’s meta box for certain taxonomies?

    Just to be on the same page, you mean this meta box:

    kind regards,
    Kasia

    Thread Starter adfisch

    (@adfisch)

    Yes, exactly. 🙂

    Plugin Support Adam – WPMU DEV Support

    (@wpmudev-support8)

    Hi @adfisch

    Thank you for confirmation!

    This should be possible, I believe, so I asked our developers for assistance. We’ll update you here again once we got the solution for you but please note that our developers are dealing with a lot of complex tasks on daily basis so it might take them a bit longer to respond than it takes us.

    We’ll update you here as soon as we get feedback from them.

    Best regards,
    Adam

    Plugin Support Adam – WPMU DEV Support

    (@wpmudev-support8)

    Hi @adfisch

    I just got response from our developers so here’s the code for you:

    add_action( 'init', function(){
    
    	if ( ! function_exists( 'smartcrawl_get_array_value' ) ) {
    		return;
    	}
    
    	$taxonomy = smartcrawl_get_array_value( $_GET, 'taxonomy' ); 
    	if ( is_admin() && ! empty( $taxonomy ) ) {
    
    		global $wp_filter;
    		$tag 			= sanitize_key( $taxonomy ) . '_edit_form';
    		$hook_method	= 'term_additions_form';
    		$hook_class 	= 'Smartcrawl_Taxonomy';
    
    		if ( ! isset( $wp_filter[$tag] ) ) {
    			return;
    		}
    
    		foreach ( $wp_filter[$tag]->callbacks as $key => $callback_array ) {
    
    			foreach ( $callback_array as $c_key => $callback ) {
    
    				if ( substr_compare( $c_key, $hook_method, strlen( $c_key )-strlen( $hook_method ), strlen( $hook_method ) ) === 0 ) {
    					if ( $callback['function'][0] instanceof $hook_class ){
    						unset( $wp_filter[$tag]->callbacks[$key][$c_key] );
    					}
    				}
    			}
    		}
    	}
    
    }, 11 );

    If you have any follow-up questions, let me know, please.

    Best regards,
    Adam

    Thread Starter adfisch

    (@adfisch)

    If that was a long response time, I want to know what your short one is… 😀 Thank you very much, it worked like a charme.

    For other readers it might be noteworthy that the above code will disable the SmartCrawl meta box for all taxonomies. If you only wish to disable it for certain taxonomies you can use this code:

    ...
    
    $taxonomy = smartcrawl_get_array_value( $_GET, 'taxonomy' ); 
    
    $disabled_taxonomies = array(
    	'taxonomy_slug1',
    
    	'taxonomy_slug2'
    );
    
    if ( ! in_array( $taxonomy, $disabled_taxonomies ) ) {
    	return;
    
    }
    
    if ( is_admin() && ! empty( $taxonomy ) ) {
    ...
    • This reply was modified 2 years, 12 months ago by adfisch.
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Disable SmartCrawl for certain taxonomies’ is closed to new replies.