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

Version 0.6 get_support_errors() filter? #867

Closed
ktmn opened this issue Jan 16, 2018 · 7 comments
Closed

Version 0.6 get_support_errors() filter? #867

ktmn opened this issue Jan 16, 2018 · 7 comments
Assignees
Milestone

Comments

@ktmn
Copy link

ktmn commented Jan 16, 2018

I have previously provided support in a theme for having a chosen page as AMP front page by manually changing the global WP_Query, setting proper template and calling amp_prepare_render() when applicable.

0.6 introduced a problem when trying to render an AMP front page that is also the main front page due to this code here:

// Homepage and page for posts are not supported yet.
if ( 'page' === get_post_type( $post ) && 'page' === get_option( 'show_on_front' ) ) {
	if ( (int) get_option( 'page_for_posts' ) === (int) $post->ID ) {
		$errors[] = 'page-for-posts';
	} elseif ( (int) get_option( 'page_on_front' ) === (int) $post->ID ) {
		$errors[] = 'page-on-front';
	}
}

It forces the AMP to be disabled in the metabox and redirects to canonical when visiting it.

I think if the AMP_Post_Type_Support::get_support_errors() return array had a filter I could just unset the 'page-for-posts' and 'page-on-front' error values and would be able to keep the support for front pages.

@westonruter
Copy link
Member

@ktmn I have written up a proposal for what I think would be a better solution than adding a new filter: #837 (comment)

Please review.

@ktmn
Copy link
Author

ktmn commented Jan 17, 2018

Looks good

@westonruter
Copy link
Member

@ktmn would you test #872?

@ktmn
Copy link
Author

ktmn commented Jan 18, 2018

Works well, thank you

@westonruter
Copy link
Member

@ktmn can you share your code that mutates WP_Query? That code would seem to be needed by the plugin in order for the front page to render as AMP when the query var is present.

@westonruter
Copy link
Member

@ktmn actually, take a look at c9acad7

@ktmn
Copy link
Author

ktmn commented Jan 18, 2018

Yeah that works, replaces my custom implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants