Skip to content
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

Closed
senlin opened this issue Aug 17, 2019 · 11 comments
Closed

[Feature Request] Hide “Advanced” tab #67

senlin opened this issue Aug 17, 2019 · 11 comments

Comments

@senlin
Copy link
Owner

senlin commented Aug 17, 2019

Originally reported by @Dibbyo456 as issue #64

Is there any way to hide “Advanced” tab? – https://s.put.re/jPZh688X.png

@harryqt
Copy link

harryqt commented Aug 17, 2019

The proper way to hide this we need to modify the function get_seo_meta_section() on \wordpress-seo\admin\metabox\class-metabox.php Line 330.

@harryqt
Copy link

harryqt commented Aug 17, 2019

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 );
	}
});

@senlin senlin changed the title Hide “Advanced” tab [Feature Request] Hide “Advanced” tab Aug 17, 2019
@senlin
Copy link
Owner Author

senlin commented Aug 17, 2019

@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 but I can imagine that some people would like to remove as much as they can, and then this might be a useful option.

So I will add it to the plugin, but I will leave it visible by default, if only not to surprise people that actually are using the Advanced section of the metabox.

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?

@harryqt
Copy link

harryqt commented Aug 17, 2019

I think most users will prefer the "close advanced tab". I just wanted to get rid of it because I almost never uses it.

@senlin
Copy link
Owner Author

senlin commented Aug 17, 2019

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?

@harryqt
Copy link

harryqt commented Aug 17, 2019

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.
Perhaps we can create an array of CPT and loop through them and remove it?

@senlin
Copy link
Owner Author

senlin commented Aug 17, 2019

sometimes pages needs to be "noindex" or change "canonical" etc where "posts" does not need these options

Okay, fair enough

Perhaps we can create an array of CPT and loop through them and remove it?

Happy to merge it if you can send me a PR or a snippet I can use :)

@harryqt
Copy link

harryqt commented Aug 17, 2019

/**
 * 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 );
	}
});

@senlin
Copy link
Owner Author

senlin commented Aug 17, 2019

Great thank you Harry! Yes, I think it would be a good idea to make it optional for pages, as you said yourself:

I like to have it enabled on pages because sometimes pages needs to be "noindex" or change "canonical" etc

@senlin
Copy link
Owner Author

senlin commented Aug 27, 2019

@Dibbyo456
Harry, so do I just leave the page post-type out when $default_post_types is defined or do you have a better idea?

@harryqt
Copy link

harryqt commented Aug 28, 2019

Harry, so do I just leave the page post-type out when $default_post_types is defined or do you have a better idea?

Frankly leave the page out of it for now. Later if lot of users asks for it the we can make it optional by pushing a simple update.

@senlin senlin closed this as completed in 57fb99e Aug 29, 2019
senlin added a commit that referenced this issue Aug 29, 2019
* 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)
senlin added a commit that referenced this issue Dec 18, 2020
* release date December 18, 2020
* hides ad for premium version on post type analysis dropdown
* delete function added in 3.13.0 that removes advanced accordion menu at bottom of SEO metabox for post- and custom post types, since it no longer functions properly ([issue #67](#67))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants