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

AMP meta box is active on post types that are not public #957

Closed
renatonascalves opened this Issue Feb 14, 2018 · 3 comments

Comments

Projects
None yet
3 participants
@renatonascalves
Contributor

renatonascalves commented Feb 14, 2018

The AMP plugin adds the meta box in the back-end for post types that are not public. A good example I stumbled upon now while in the BuddyPress email area.

BuddyPress uses post types to manager its emails. The post types are not public. Still, in the admin area, one can see the notice that AMP is not active because of post type support.

post-type-support

Clicking on the link sends the user to the AMP settings page where the email post type, correctly, by the way, is not available for activation.

The verification made on AMP_Post_Meta_Box::render_status() that uses post_supports_amp() is not enough. There is a filter available that plugins can use, but I believe this should be fixed in the AMP plugin.

Theoretically, non-public post types will not be used in the front-end and so, will have no AMP support. So the meta box in the back-end is unnecessary.

What do you guys think? :)

@renatonascalves

This comment has been minimized.

Contributor

renatonascalves commented Feb 14, 2018

By the way, something like that should work fine. I'm happy to send a PR.

/**
 * Render AMP status.
 *
 * @since 0.6
 * @param WP_Post $post Post.
 */
public function render_status( $post ) {
	$p = get_post_type_object( $post->post_type );

	$verify = (
		isset( $post->ID )
		&&
		$p->public // Only public post types, please.
		&&
		current_user_can( 'edit_post', $post->ID )
	);

	if ( true !== $verify ) {
		return;
	}

	... 
@westonruter

This comment has been minimized.

Member

westonruter commented Feb 14, 2018

@renatonascalves good catch. Yes, please do open a PR! You may want to use is_post_type_viewable( $post->post_type ).

@postphotos

This comment has been minimized.

Contributor

postphotos commented Apr 10, 2018

Hey @renatonascalves, this was a good suggestion, thanks for contributing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment