-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Hide “Advanced” tab #67
Comments
The proper way to hide this we need to modify the function |
Another way would be: /**
* Hide Advanced tab from Yoast metabox.
* Only affect post editor screen.
*/
add_action( 'current_screen', function() {
if ( get_current_screen()->id == 'post' ) {
add_filter( 'user_has_cap', function( $allcaps, $cap, $args ) {
$allcaps['wpseo_manage_options'] = false;
return $allcaps;
}, 10, 3 );
}
}); |
@Dibbyo456 thanks for this Feature Request. That function indeed does the trick. I never felt the urge to remove the entire Advanced "tab", as it is closed by default anyways
Hang on, on the Page editor the advanced "tab" also shows and most likely on custom post types too, so how about those then? Should either be all or skip it all together and live with the closed tab, what do you think? |
I think most users will prefer the "close advanced tab". I just wanted to get rid of it because I almost never uses it. |
But for Pages and other CPTs you're fine that it is there? That is my issue with it. I can remove it from the post editor, but then what about the page editor and any other editor screens? |
I like to have it enabled on pages because sometimes pages needs to be "noindex" or change "canonical" etc where "posts" does not need these options, because almost no user write a post and have it "noindex". Not sure about custom post type, because I rarely use it. |
Okay, fair enough
Happy to merge it if you can send me a PR or a snippet I can use :) |
/**
* Hide Advanced tab from Yoast metabox.
* Works on Post, Page as well as CPT.
*/
add_action( 'current_screen', function() {
// create array of default post types.
// not sure about pages, perhaps make it optional?
$default_post_types = array( 'post', 'page' );
// get the custom post types if available.
$custom_post_types = get_post_types( array( '_builtin' => false ) );
// merge them. no errors if no cpt found.
$all_post_types = array_merge( $default_post_types, $custom_post_types );
// if current edit screen belong to post types, then change capability.
if ( in_array( get_current_screen()->id, $all_post_types ) ) {
add_filter( 'user_has_cap', function( $allcaps, $cap, $args ) {
$allcaps['wpseo_manage_options'] = false;
return $allcaps;
}, 10, 3 );
}
}); |
Great thank you Harry! Yes, I think it would be a good idea to make it optional for pages, as you said yourself:
|
@Dibbyo456 |
Frankly leave the |
* release date August 29, 2019 * remove notice on permalinks page that warns the user of the implications of changing them, fixes [issue #58](#58) * recode hiding of the admin columns into actually removing them, fixes [issue #65](#65) * recode hiding of the seo score/readability score filters into actually removing them, fixes [issue #65](#65) * remove advanced accordion menu at bottom of SEO metabox for post- and custom post types, fixes [issue #67](#67)
Originally reported by @Dibbyo456 as issue #64
Is there any way to hide “Advanced” tab? – https://s.put.re/jPZh688X.png
The text was updated successfully, but these errors were encountered: