Plugin Version: 1.2.5
Apologies if I've missed something obvious, I haven't delved through this plugin code before.
1) I don't want the Yoast SEO to do anything for a particular custom post type. My use case is that it is not public.
2) I do want it on everything else.
3) I do want to leave in the analysis functionality for normal pages/pages and other custom post types (that means I do not want to completely disable it using the wpseo_use_page_analysis filter )
What I have done:
I can't find a filter to block Yoast SEO from being enabled for a particular custom post type, but setting up the custom post type up as public=>false does disable most but not all of the Yoast WP SEO functionality. This is fine for my use case as the custom post type is not publicly viewable on its own pages. (Note if the post type is publicly viewable then most of the admin output can be disabled using the Post Types WordPress SEO Meta Box hide option aka hideeditbox-post_type).
That's great but there's still some functionality I don't want to happen which is generated by this code in the metabox class:
add_filter( 'request', array( $this, 'column_sort_orderby' ) ); add_action( 'restrict_manage_posts', array( $this, 'posts_filter_dropdown' ) ); add_action( 'post_submitbox_misc_actions', array( $this, 'publish_box' ) );
As they are nicely set up using actions and filters we should be able to remove them quite easily. I have put this on the admin_init hook to fire after the Yoast SEO functionality
remove_filter( 'request', array( $wpseo_metabox, 'column_sort_orderby' ) ); remove_action( 'restrict_manage_posts', array( $wpseo_metabox, 'posts_filter_dropdown' ) ); remove_action( 'post_submitbox_misc_actions', array( $wpseo_metabox, 'publish_box' ) );
However that can only work if $wpseo_metabox has global scope which it doesn't. Adding
global $wpseo_metabox just before it is defined means I can now disable it for my custom post type, but obviously it's not a long term solution.
Any chance of an update to make $wpseo_metabox global so themes and other plugins can play nicely with this excellent SEO plugin?
A better general solution would be the ability to completely exclude some custom post types from WordPress SEO.
Any other ideas - am I missing something obvious? Or should I be using an earlier hook to disable WordPress SEO from loading at all (for example using the WP $typenow global)?