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
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
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
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.