Skip to content

Introduce amp_skip filter for disabling AMP on non-singular templates #2817

@westonruter

Description

@westonruter

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/c3d4d73418b310f12d3cba7245fccebc

add_action( 'init', __NAMESPACE__ . '\remove_theme_support_on_geo_mashup_requests' );

/**
 * On standard mode sites, prevent the page in the Geo Mashup iframe from being served as AMP, since it requires JavaScript.
 */
function remove_theme_support_on_geo_mashup_requests() {
	if ( isset( $_GET['geo_mashup_content'] ) ) {
		remove_theme_support( 'amp' );
	}
}

There needs to be an amp_skip filter for theme support to avoid having to hackily remove theme support.

Relates to #1778.

Metadata

Metadata

Assignees

Labels

EnhancementNew feature or improvement of an existing oneGroomedP1Medium priorityWS:CoreWork stream for Plugin core

Type

No type

Projects

Status

To Do

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions