-
Notifications
You must be signed in to change notification settings - Fork 383
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
Introduce amp_skip filter for disabling AMP on non-singular templates #2817
Comments
We'll need to make sure we provide feedback to the user in the editor when the post gets AMP disabled due to this filter. |
This may make more sense as a |
I just realized that the code snippet in the description will no longer work as of #5010 since the database option now controls the mode. So this means we do need this filter for v2.0. The filter should be able to force AMP to be disabled for a given URL, ensuring that an arbitrary URL can serve non-AMP content even when Standard mode is enabled. There's also a need for sites in Transitional/Reader mode to serve certain URLs as exclusively AMP (i.e. Standard mode). This is specifically the case for plugins like Web Stories. |
Actually, I just realized that my original code snippet in the description (involving add_filter( 'amp_is_enabled', function ( $is_enabled ) {
if ( isset( $_GET['geo_mashup_content'] ) ) {
$is_enabled = false;
}
return $is_enabled;
} ); Nevertheless, I see this is not currently working as expected. In particular, the services are getting initialized before the amp-wp/includes/amp-helper-functions.php Lines 219 to 234 in b8661f3
This means filtering |
See #5153 for the fix to allow |
Use case for this filter. The Events Calendar plugin (https://github.com/moderntribe/the-events-calendar) is not AMP compatible, and I'm interested in programmatically disabling AMP on the main calendar listings page, which by default has the URL |
Got it. That makes sense. A challenge we need to figure out here is how we can best communicate to the user when programmatically disabling AMP for a given URL. We currently have the Prior to 2.0 there may have actually been a way to do this via the Nevertheless, the need can go beyond a plugin needing to disable AMP for a specific template. In reality, AMP may need to be disabled for a given template which also satisfies some other condition. For example, if I've attached some term meta to a category which designates that the post list should be animated with some bit Flash embed (😱). In that way, simply filtering So, all that to say, perhaps using So maybe in the end what is needed is a way to filter the return value of In the same way that In other words, currently the function will return /**
* Filters whether AMP is available for a request that would otherwise be served as an AMP page.
*
* This filter has least precedence over other signals for whether AMP is enabled. For example, if a post type has
* AMP disabled then this filter will not be called. Likewise, if a user has disabled AMP for a given post or if
* a plugin has filtered `amp_skip_post` to be false, then this filter will not be involved. This filter only
* applies to give plugins a final say for whether an AMP page should be served.
*
* @since 2.x
* @see amp_skip_post()
* @see AMP_Post_Type_Support::get_support_errors()
* @see AMP_Theme_Support::get_template_availability()
*
* @param bool $available Available. True by default.
*/
return apply_filters( 'amp_is_available', true ); If we do this, then it's true that a plugin may disable AMP for a given post and there would be no way of being able to indicate that from the edit post screen. As such, perhaps this filter could be passed the amp-wp/includes/admin/class-amp-post-meta-box.php Lines 313 to 342 in c6aed8f
This is used to get the value of the amp-wp/includes/admin/class-amp-post-meta-box.php Lines 433 to 476 in c6aed8f
This is actually already being used in amp-wp/includes/admin/class-amp-post-meta-box.php Lines 178 to 193 in c6aed8f
But passing a |
We can probably address this with the filter added for controlling off-cache AMP. See #5378. |
There is currently an
amp_skip_post
which can be used to programmatically disable AMP for a given post. This is also needed for non-singular posts as well, as illustrated in this support topic: https://wordpress.org/support/topic/shortcodes-for-geo-mashup-not-working/In the topic, a plugin is generating a template which is used to render inside of an
amp-iframe
. The iframed window is not an AMP page, as it needs to run JS. The hacky workaround can be see in this shim plugin I made: https://gist.github.com/westonruter/c3d4d73418b310f12d3cba7245fccebcThere needs to be an
amp_skip
filter for theme support to avoid having to hackily remove theme support.Relates to #1778.
The text was updated successfully, but these errors were encountered: