@@ -433,26 +433,26 @@ public function render_validation_handling() {
assertFalse( is_amp_endpoint() );
remove_theme_support( AMP_Theme_Support::SLUG );
- // Native theme support.
+ // Standard theme support.
add_theme_support( AMP_Theme_Support::SLUG );
$this->assertTrue( is_amp_endpoint() );
diff --git a/tests/test-class-amp-cli.php b/tests/test-class-amp-cli.php
index bc2d67f473a..da8d629389c 100644
--- a/tests/test-class-amp-cli.php
+++ b/tests/test-class-amp-cli.php
@@ -120,7 +120,7 @@ public function test_get_posts_that_support_amp() {
$this->assertEquals( $ids, AMP_CLI::get_posts_that_support_amp( $ids ) );
AMP_CLI::$force_crawl_urls = false;
- // In Native AMP, the IDs should include all of the newly-created posts.
+ // In AMP first, the IDs should include all of the newly-created posts.
add_theme_support( AMP_Theme_Support::SLUG );
$this->assertEquals( $ids, AMP_CLI::get_posts_that_support_amp( $ids ) );
diff --git a/tests/test-class-amp-gallery-block-sanitizer.php b/tests/test-class-amp-gallery-block-sanitizer.php
index 4597f23df20..24cd2ea08ea 100644
--- a/tests/test-class-amp-gallery-block-sanitizer.php
+++ b/tests/test-class-amp-gallery-block-sanitizer.php
@@ -58,7 +58,7 @@ public function get_data() {
* Test sanitizer.
*
* This only tests when theme support is present.
- * Like if Native or Transitional is selected in AMP Settings > Template Mode,
+ * Like if Standard or Transitional is selected in AMP Settings > Template Mode,
* or if this is added with add_theme_support( 'amp' ).
* If there is no theme support, the sanitizer will have the argument array( 'carousel_required' => true ).
*
diff --git a/tests/test-class-amp-meta-box.php b/tests/test-class-amp-meta-box.php
index e5867efc8c8..7552e53e64e 100644
--- a/tests/test-class-amp-meta-box.php
+++ b/tests/test-class-amp-meta-box.php
@@ -183,7 +183,7 @@ public function test_render_status() {
$this->assertContains( $amp_status_markup, $output );
$this->assertContains( $checkbox_enabled, $output );
- // This is in AMP native mode with a template that can be rendered.
+ // This is in AMP first mode with a template that can be rendered.
add_theme_support( AMP_Theme_Support::SLUG );
ob_start();
$this->instance->render_status( $post );
@@ -242,7 +242,7 @@ public function test_get_status_and_errors() {
$this->instance->get_status_and_errors( $post )
);
- // In Native AMP, there also shouldn't be errors.
+ // In AMP first, there also shouldn't be errors.
add_theme_support( AMP_Theme_Support::SLUG );
$this->assertEquals(
$expected_status_and_errors,
diff --git a/tests/test-class-amp-options-manager.php b/tests/test-class-amp-options-manager.php
index 896028052f3..09886b5f4ed 100644
--- a/tests/test-class-amp-options-manager.php
+++ b/tests/test-class-amp-options-manager.php
@@ -484,12 +484,12 @@ public function test_handle_updated_theme_support_option_disabled() {
}
/**
- * Test handle_updated_theme_support_option for native when there is one auto-accepted issue.
+ * Test handle_updated_theme_support_option for standard when there is one auto-accepted issue.
*
* @covers AMP_Options_Manager::handle_updated_theme_support_option()
* @covers \amp_admin_get_preview_permalink()
*/
- public function test_handle_updated_theme_support_option_native_success_but_error() {
+ public function test_handle_updated_theme_support_option_standard_success_but_error() {
wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) );
$post_id = $this->factory()->post->create( array( 'post_type' => 'post' ) );
@@ -517,7 +517,7 @@ public function test_handle_updated_theme_support_option_native_success_but_erro
remove_filter( 'pre_http_request', $filter );
$amp_settings_errors = get_settings_errors( AMP_Options_Manager::OPTION_NAME );
$new_error = end( $amp_settings_errors );
- $this->assertStringStartsWith( 'Native mode activated!', $new_error['message'] );
+ $this->assertStringStartsWith( 'Standard mode activated!', $new_error['message'] );
$this->assertContains( esc_url( amp_get_permalink( $post_id ) ), $new_error['message'], 'Expect amp_admin_get_preview_permalink() to return a post since it is the only post type supported.' );
$invalid_url_posts = get_posts(
array(
@@ -532,12 +532,12 @@ public function test_handle_updated_theme_support_option_native_success_but_erro
}
/**
- * Test handle_updated_theme_support_option for native when there is one auto-accepted issue.
+ * Test handle_updated_theme_support_option for standard when there is one auto-accepted issue.
*
* @covers AMP_Options_Manager::handle_updated_theme_support_option()
* @covers \amp_admin_get_preview_permalink()
*/
- public function test_handle_updated_theme_support_option_native_validate_error() {
+ public function test_handle_updated_theme_support_option_standard_validate_error() {
wp_set_current_user( $this->factory()->user->create( array( 'role' => 'administrator' ) ) );
$this->factory()->post->create( array( 'post_type' => 'post' ) );
@@ -555,7 +555,7 @@ public function test_handle_updated_theme_support_option_native_validate_error()
$amp_settings_errors = get_settings_errors( AMP_Options_Manager::OPTION_NAME );
$new_error = end( $amp_settings_errors );
- $this->assertStringStartsWith( 'Native mode activated!', $new_error['message'] );
+ $this->assertStringStartsWith( 'Standard mode activated!', $new_error['message'] );
$invalid_url_posts = get_posts(
array(
'post_type' => AMP_Validated_URL_Post_Type::POST_TYPE_SLUG,
diff --git a/tests/test-class-amp-theme-support.php b/tests/test-class-amp-theme-support.php
index 29144920eff..c3c182a7cf6 100644
--- a/tests/test-class-amp-theme-support.php
+++ b/tests/test-class-amp-theme-support.php
@@ -128,14 +128,14 @@ public function test_read_theme_support_bad_available_callback() {
*/
public function test_read_theme_support_and_support_args() {
- // Test that native via option trumps transitional in theme.
+ // Test that standard via option trumps transitional in theme.
$args = array(
'templates_supported' => 'all',
'paired' => true,
'comments_live_list' => true,
);
add_theme_support( AMP_Theme_Support::SLUG, $args );
- AMP_Options_Manager::update_option( 'theme_support', AMP_Theme_Support::NATIVE_MODE_SLUG ); // Will override the theme support flag.
+ AMP_Options_Manager::update_option( 'theme_support', AMP_Theme_Support::STANDARD_MODE_SLUG ); // Will override the theme support flag.
AMP_Theme_Support::read_theme_support();
$this->assertEquals(
array_merge(
@@ -146,27 +146,27 @@ public function test_read_theme_support_and_support_args() {
),
AMP_Theme_Support::get_theme_support_args()
);
- $this->assertSame( AMP_Theme_Support::NATIVE_MODE_SLUG, AMP_Theme_Support::get_support_mode_added_via_option() );
+ $this->assertSame( AMP_Theme_Support::STANDARD_MODE_SLUG, AMP_Theme_Support::get_support_mode_added_via_option() );
$this->assertSame( AMP_Theme_Support::TRANSITIONAL_MODE_SLUG, AMP_Theme_Support::get_support_mode_added_via_theme() );
- $this->assertSame( AMP_Theme_Support::NATIVE_MODE_SLUG, AMP_Theme_Support::get_support_mode() );
+ $this->assertSame( AMP_Theme_Support::STANDARD_MODE_SLUG, AMP_Theme_Support::get_support_mode() );
$this->assertTrue( current_theme_supports( AMP_Theme_Support::SLUG ) );
- // Test that native via theme always trumps transitional via option.
+ // Test that standard via theme always trumps transitional via option.
add_theme_support( AMP_Theme_Support::SLUG );
- AMP_Options_Manager::update_option( 'theme_support', AMP_Theme_Support::TRANSITIONAL_MODE_SLUG ); // Will be ignored since native in theme overrides transitional option.
+ AMP_Options_Manager::update_option( 'theme_support', AMP_Theme_Support::TRANSITIONAL_MODE_SLUG ); // Will be ignored since standard in theme overrides transitional option.
AMP_Theme_Support::read_theme_support();
$this->assertTrue( current_theme_supports( AMP_Theme_Support::SLUG ) );
$this->assertNull( AMP_Theme_Support::get_support_mode_added_via_option() );
- $this->assertSame( AMP_Theme_Support::NATIVE_MODE_SLUG, AMP_Theme_Support::get_support_mode_added_via_theme() );
- $this->assertSame( AMP_Theme_Support::NATIVE_MODE_SLUG, AMP_Theme_Support::get_support_mode() );
+ $this->assertSame( AMP_Theme_Support::STANDARD_MODE_SLUG, AMP_Theme_Support::get_support_mode_added_via_theme() );
+ $this->assertSame( AMP_Theme_Support::STANDARD_MODE_SLUG, AMP_Theme_Support::get_support_mode() );
$this->assertEquals( array( 'paired' => false ), AMP_Theme_Support::get_theme_support_args() );
// Test that no support via theme can be overridden with option.
remove_theme_support( AMP_Theme_Support::SLUG );
- AMP_Options_Manager::update_option( 'theme_support', AMP_Theme_Support::NATIVE_MODE_SLUG );
+ AMP_Options_Manager::update_option( 'theme_support', AMP_Theme_Support::STANDARD_MODE_SLUG );
AMP_Theme_Support::read_theme_support();
$this->assertNull( AMP_Theme_Support::get_support_mode_added_via_theme() );
- $this->assertSame( AMP_Theme_Support::NATIVE_MODE_SLUG, AMP_Theme_Support::get_support_mode_added_via_option() );
+ $this->assertSame( AMP_Theme_Support::STANDARD_MODE_SLUG, AMP_Theme_Support::get_support_mode_added_via_option() );
$this->assertTrue( current_theme_supports( AMP_Theme_Support::SLUG ) );
// Test that no support via theme can be overridden with option.
@@ -182,7 +182,7 @@ public function test_read_theme_support_and_support_args() {
delete_option( AMP_Options_Manager::OPTION_NAME );
$_GET[ AMP_Validation_Manager::VALIDATE_QUERY_VAR ] = AMP_Validation_Manager::get_amp_validate_nonce();
AMP_Theme_Support::read_theme_support();
- $this->assertSame( AMP_Theme_Support::NATIVE_MODE_SLUG, AMP_Theme_Support::get_support_mode_added_via_option() );
+ $this->assertSame( AMP_Theme_Support::STANDARD_MODE_SLUG, AMP_Theme_Support::get_support_mode_added_via_option() );
$this->assertNull( AMP_Theme_Support::get_support_mode_added_via_theme() );
$this->assertTrue( get_theme_support( AMP_Theme_Support::SLUG ) );
}
@@ -947,7 +947,7 @@ public function test_amend_comment_form() {
$this->go_to( get_permalink( $post_id ) );
$this->assertTrue( is_singular() );
- // Test native AMP.
+ // Test AMP first.
add_theme_support( AMP_Theme_Support::SLUG );
$this->assertTrue( amp_is_canonical() );
ob_start();
@@ -1521,11 +1521,11 @@ function ( $url ) {
}
/**
- * Test prepare_response for native mode when some validation errors aren't auto-sanitized.
+ * Test prepare_response for standard mode when some validation errors aren't auto-sanitized.
*
* @covers AMP_Theme_Support::prepare_response()
*/
- public function test_prepare_response_native_mode_non_amp() {
+ public function test_prepare_response_standard_mode_non_amp() {
wp();
$original_html = $this->get_original_html();
add_filter( 'amp_validation_error_sanitized', '__return_false' ); // For testing purpose only. This should not normally be done.
diff --git a/tests/validation/test-class-amp-validation-manager.php b/tests/validation/test-class-amp-validation-manager.php
index db9ca426713..46a42a63223 100644
--- a/tests/validation/test-class-amp-validation-manager.php
+++ b/tests/validation/test-class-amp-validation-manager.php
@@ -273,7 +273,7 @@ public function test_add_admin_bar_menu_items() {
remove_filter( 'amp_supportable_templates', '__return_empty_array' );
AMP_Options_Manager::update_option( 'all_templates_supported', true );
- // Admin bar item available in native mode.
+ // Admin bar item available in AMP first mode.
add_theme_support( AMP_Theme_Support::SLUG, array( 'paired' => false ) );
$admin_bar = new WP_Admin_Bar();
AMP_Validation_Manager::add_admin_bar_menu_items( $admin_bar );
@@ -417,7 +417,7 @@ public function test_add_rest_api_fields() {
);
$this->assert_rest_api_field_present( $post_types_non_canonical );
- // Test in a Native AMP (canonical) context.
+ // Test in a AMP first (canonical) context.
add_theme_support( AMP_Theme_Support::SLUG );
AMP_Theme_Support::read_theme_support();
AMP_Validation_Manager::add_rest_api_fields();
@@ -675,7 +675,7 @@ public function test_print_edit_form_validation_status() {
$this->assertContains( 'script
', $output );
$this->assertContains( $expected_notice_non_accepted_errors, $output );
- // In 'Native' mode, if there are unaccepted validation errors, there should be a notice because this will block serving an AMP document.
+ // In 'Standard' mode, if there are unaccepted validation errors, there should be a notice because this will block serving an AMP document.
add_theme_support( AMP_Theme_Support::SLUG );
ob_start();
AMP_Validation_Manager::print_edit_form_validation_status( $post );
@@ -775,7 +775,7 @@ public function test_source_comments() {
* @return array
*/
public function get_block_data() {
- if ( ! class_exists( 'WP_Block_Type_Registry' ) || 1 ) {
+ if ( ! class_exists( 'WP_Block_Type_Registry' ) ) {
$this->markTestSkipped( 'Gutenberg not active.' );
}
$latest_posts_block = WP_Block_Type_Registry::get_instance()->get_registered( 'core/latest-posts' );
From ea75efcc2fc1f8bbf9fa8fca07dd2aebfe967409 Mon Sep 17 00:00:00 2001
From: Weston Ruter
Date: Mon, 10 Jun 2019 13:02:10 -0700
Subject: [PATCH 09/21] Hide validation screens when website experience
disabled
---
includes/validation/class-amp-validated-url-post-type.php | 2 +-
includes/validation/class-amp-validation-error-taxonomy.php | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/includes/validation/class-amp-validated-url-post-type.php b/includes/validation/class-amp-validated-url-post-type.php
index 045963e660f..de7461e4555 100644
--- a/includes/validation/class-amp-validated-url-post-type.php
+++ b/includes/validation/class-amp-validated-url-post-type.php
@@ -160,7 +160,7 @@ public static function handle_plugin_update( $old_version ) {
*/
public static function should_show_in_menu() {
global $pagenow;
- if ( current_theme_supports( AMP_Theme_Support::SLUG ) ) {
+ if ( AMP_Options_Manager::is_website_experience_enabled() && current_theme_supports( AMP_Theme_Support::SLUG ) ) {
return true;
}
return ( 'edit.php' === $pagenow && ( isset( $_GET['post_type'] ) && self::POST_TYPE_SLUG === $_GET['post_type'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
diff --git a/includes/validation/class-amp-validation-error-taxonomy.php b/includes/validation/class-amp-validation-error-taxonomy.php
index 596032e484f..a705c5321bc 100644
--- a/includes/validation/class-amp-validation-error-taxonomy.php
+++ b/includes/validation/class-amp-validation-error-taxonomy.php
@@ -283,7 +283,7 @@ public static function register() {
*/
public static function should_show_in_menu() {
global $pagenow;
- if ( current_theme_supports( AMP_Theme_Support::SLUG ) ) {
+ if ( AMP_Options_Manager::is_website_experience_enabled() && current_theme_supports( AMP_Theme_Support::SLUG ) ) {
return true;
}
return ( 'edit-tags.php' === $pagenow && ( isset( $_GET['taxonomy'] ) && self::TAXONOMY_SLUG === $_GET['taxonomy'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
From f18045816dee033229528d5ef7b00fd06f130f3b Mon Sep 17 00:00:00 2001
From: Weston Ruter
Date: Mon, 10 Jun 2019 13:36:35 -0700
Subject: [PATCH 10/21] Fix typo in validation message
---
includes/options/class-amp-options-menu.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/includes/options/class-amp-options-menu.php b/includes/options/class-amp-options-menu.php
index 9ba456a0230..a0fee2e6e68 100644
--- a/includes/options/class-amp-options-menu.php
+++ b/includes/options/class-amp-options-menu.php
@@ -250,7 +250,7 @@ public function render_experiences() {
})(
jQuery,
,
-
+
);
From 55f1f1f3857d2126b264ecc7316568757e45a712 Mon Sep 17 00:00:00 2001
From: Weston Ruter
Date: Mon, 10 Jun 2019 13:54:47 -0700
Subject: [PATCH 11/21] Add experiences to generator meta tag; use new mode
identifiers
---
includes/amp-helper-functions.php | 14 +++++++++---
includes/class-amp-theme-support.php | 6 +++---
tests/test-amp-helper-functions.php | 32 +++++++++++++++++++---------
3 files changed, 36 insertions(+), 16 deletions(-)
diff --git a/includes/amp-helper-functions.php b/includes/amp-helper-functions.php
index 39bc4b56770..87ef7db23d3 100644
--- a/includes/amp-helper-functions.php
+++ b/includes/amp-helper-functions.php
@@ -374,14 +374,22 @@ function amp_get_boilerplate_code() {
* @since 1.0 Add template mode.
*/
function amp_add_generator_metadata() {
- if ( amp_is_canonical() ) {
- $mode = 'native'; // aka 'standard'.
+ $content = sprintf( 'AMP Plugin v%s', AMP__VERSION );
+
+ if ( ! AMP_Options_Manager::is_website_experience_enabled() ) {
+ $mode = 'none';
+ } elseif ( amp_is_canonical() ) {
+ $mode = 'standard';
} elseif ( current_theme_supports( AMP_Theme_Support::SLUG ) ) {
$mode = 'transitional';
} else {
$mode = 'reader';
}
- printf( '', esc_attr( sprintf( 'AMP Plugin v%s; mode=%s', AMP__VERSION, $mode ) ) );
+ $content .= sprintf( '; mode=%s', $mode );
+
+ $content .= sprintf( '; experiences=%s', implode( ',', AMP_Options_Manager::get_option( 'experiences' ) ) );
+
+ printf( '', esc_attr( $content ) );
}
/**
diff --git a/includes/class-amp-theme-support.php b/includes/class-amp-theme-support.php
index 57e955d8d9a..7258806e4de 100644
--- a/includes/class-amp-theme-support.php
+++ b/includes/class-amp-theme-support.php
@@ -200,7 +200,7 @@ public static function is_support_added_via_option() {
* Get the theme support mode added via admin option.
*
* @return null|string Support added via option, with null meaning Reader, and otherwise being 'native' or 'paired'.
- *@see AMP_Theme_Support::read_theme_support()
+ * @see AMP_Theme_Support::read_theme_support()
* @see AMP_Theme_Support::TRANSITIONAL_MODE_SLUG
* @see AMP_Theme_Support::STANDARD_MODE_SLUG
*
@@ -214,7 +214,7 @@ public static function get_support_mode_added_via_option() {
* Get the theme support mode added via admin option.
*
* @return null|string Support added via option, with null meaning Reader, and otherwise being 'native' or 'paired'.
- *@see AMP_Theme_Support::read_theme_support()
+ * @see AMP_Theme_Support::read_theme_support()
* @see AMP_Theme_Support::TRANSITIONAL_MODE_SLUG
* @see AMP_Theme_Support::STANDARD_MODE_SLUG
*
@@ -228,7 +228,7 @@ public static function get_support_mode_added_via_theme() {
* Get theme support mode.
*
* @return string Theme support mode.
- *@see AMP_Theme_Support::read_theme_support()
+ * @see AMP_Theme_Support::read_theme_support()
* @see AMP_Theme_Support::TRANSITIONAL_MODE_SLUG
* @see AMP_Theme_Support::STANDARD_MODE_SLUG
*
diff --git a/tests/test-amp-helper-functions.php b/tests/test-amp-helper-functions.php
index 3ad551b6977..62ddbe1f547 100644
--- a/tests/test-amp-helper-functions.php
+++ b/tests/test-amp-helper-functions.php
@@ -478,25 +478,37 @@ public function capture_filter_call( $value ) {
*/
public function test_amp_add_generator_metadata() {
remove_theme_support( AMP_Theme_Support::SLUG );
- ob_start();
- amp_add_generator_metadata();
- $output = ob_get_clean();
+
+ $get_generator_tag = function() {
+ ob_start();
+ amp_add_generator_metadata();
+ return ob_get_clean();
+ };
+
+ $output = $get_generator_tag();
$this->assertContains( 'mode=reader', $output );
$this->assertContains( 'v' . AMP__VERSION, $output );
+ $this->assertContains( 'experiences=website', $output );
add_theme_support( AMP_Theme_Support::SLUG, array( 'paired' => true ) );
- ob_start();
- amp_add_generator_metadata();
- $output = ob_get_clean();
+ $output = $get_generator_tag();
$this->assertContains( 'mode=transitional', $output );
$this->assertContains( 'v' . AMP__VERSION, $output );
add_theme_support( AMP_Theme_Support::SLUG, array( 'paired' => false ) );
- ob_start();
- amp_add_generator_metadata();
- $output = ob_get_clean();
- $this->assertContains( 'mode=native', $output );
+ $output = $get_generator_tag();
+ $this->assertContains( 'mode=standard', $output );
$this->assertContains( 'v' . AMP__VERSION, $output );
+
+ AMP_Options_Manager::update_option( 'experiences', array( AMP_Options_Manager::STORIES_EXPERIENCE ) );
+ $output = $get_generator_tag();
+ $this->assertContains( 'mode=none', $output );
+ $this->assertContains( 'experiences=stories', $output );
+
+ AMP_Options_Manager::update_option( 'experiences', array( AMP_Options_Manager::WEBSITE_EXPERIENCE, AMP_Options_Manager::STORIES_EXPERIENCE ) );
+ $output = $get_generator_tag();
+ $this->assertContains( 'mode=standard', $output );
+ $this->assertContains( 'experiences=website,stories', $output );
}
/**
From 4d7920f64c5d5d94dbce111ca8a6ef35719c9516 Mon Sep 17 00:00:00 2001
From: Weston Ruter
Date: Mon, 10 Jun 2019 14:32:16 -0700
Subject: [PATCH 12/21] Upate constants for modes, use instead of strings
---
amp.php | 4 +--
includes/amp-helper-functions.php | 2 +-
includes/class-amp-theme-support.php | 32 ++++++++++++-------
.../options/class-amp-options-manager.php | 19 +++++++----
includes/options/class-amp-options-menu.php | 10 +++---
.../class-amp-validated-url-post-type.php | 10 +++---
tests/test-amp-helper-functions.php | 6 ++--
tests/test-amp.php | 6 ++--
tests/test-class-amp-cli.php | 2 +-
tests/test-class-amp-options-manager.php | 10 +++---
tests/test-class-amp-theme-support.php | 26 +++++++--------
...test-class-amp-validated-url-post-type.php | 14 ++++----
...st-class-amp-validation-error-taxonomy.php | 2 +-
.../test-class-amp-validation-manager.php | 18 +++++------
14 files changed, 88 insertions(+), 73 deletions(-)
diff --git a/amp.php b/amp.php
index b9045b2d681..bbedbc01104 100644
--- a/amp.php
+++ b/amp.php
@@ -561,8 +561,8 @@ function amp_is_canonical() {
}
$args = AMP_Theme_Support::get_theme_support_args();
- if ( isset( $args['paired'] ) ) {
- return empty( $args['paired'] );
+ if ( isset( $args[ AMP_Theme_Support::PAIRED_FLAG ] ) ) {
+ return empty( $args[ AMP_Theme_Support::PAIRED_FLAG ] );
}
// If there is a template_dir, then transitional mode is implied.
diff --git a/includes/amp-helper-functions.php b/includes/amp-helper-functions.php
index 87ef7db23d3..cd2f24f7963 100644
--- a/includes/amp-helper-functions.php
+++ b/includes/amp-helper-functions.php
@@ -243,7 +243,7 @@ function post_supports_amp( $post ) {
* to determine the queried object is able to be served as AMP. If 'amp' theme support is not
* present, this function returns true just if the query var is present. If theme support is
* present, then it returns true in transitional mode if an AMP template is available and the query
- * var is present, or else in native mode if just the template is available.
+ * var is present, or else in standard mode if just the template is available.
*
* @return bool Whether it is the AMP endpoint.
* @global string $pagenow
diff --git a/includes/class-amp-theme-support.php b/includes/class-amp-theme-support.php
index 7258806e4de..17fcb5d7742 100644
--- a/includes/class-amp-theme-support.php
+++ b/includes/class-amp-theme-support.php
@@ -60,7 +60,7 @@ class AMP_Theme_Support {
* @since 1.2
* @var string
*/
- const STANDARD_MODE_SLUG = 'native'; // aka 'standard'.
+ const STANDARD_MODE_SLUG = 'standard';
/**
* Slug identifying transitional website mode.
@@ -68,7 +68,15 @@ class AMP_Theme_Support {
* @since 1.2
* @var string
*/
- const TRANSITIONAL_MODE_SLUG = 'paired';
+ const TRANSITIONAL_MODE_SLUG = 'transitional';
+
+ /**
+ * Flag used in args passed to add_theme_support('amp') to indicate transitional mode supported.
+ *
+ * @since 1.2
+ * @var string
+ */
+ const PAIRED_FLAG = 'paired';
/**
* Sanitizer classes.
@@ -128,7 +136,7 @@ class AMP_Theme_Support {
/**
* Theme support mode that was added via option.
*
- * This should be either null (reader), 'native', or 'transitional'.
+ * This should be either null (reader), 'standard', or 'transitional'.
*
* @since 1.0
* @var null|string
@@ -138,7 +146,7 @@ class AMP_Theme_Support {
/**
* Theme support mode which was added via the theme.
*
- * This should be either null (reader), 'native', or 'transitional'.
+ * This should be either null (reader), 'standard', or 'transitional'.
*
* @var null|string
*/
@@ -199,7 +207,7 @@ public static function is_support_added_via_option() {
/**
* Get the theme support mode added via admin option.
*
- * @return null|string Support added via option, with null meaning Reader, and otherwise being 'native' or 'paired'.
+ * @return null|string Support added via option, with null meaning Reader, and otherwise being 'standard' or 'transitional'.
* @see AMP_Theme_Support::read_theme_support()
* @see AMP_Theme_Support::TRANSITIONAL_MODE_SLUG
* @see AMP_Theme_Support::STANDARD_MODE_SLUG
@@ -213,7 +221,7 @@ public static function get_support_mode_added_via_option() {
/**
* Get the theme support mode added via admin option.
*
- * @return null|string Support added via option, with null meaning Reader, and otherwise being 'native' or 'paired'.
+ * @return null|string Support added via option, with null meaning Reader, and otherwise being 'standard' or 'transitional'.
* @see AMP_Theme_Support::read_theme_support()
* @see AMP_Theme_Support::TRANSITIONAL_MODE_SLUG
* @see AMP_Theme_Support::STANDARD_MODE_SLUG
@@ -263,7 +271,7 @@ public static function read_theme_support() {
$args = self::get_theme_support_args();
// Validate theme support usage.
- $keys = array( 'template_dir', 'comments_live_list', 'paired', 'templates_supported', 'available_callback', 'service_worker', 'nav_menu_toggle', 'nav_menu_dropdown' );
+ $keys = array( 'template_dir', 'comments_live_list', self::PAIRED_FLAG, 'templates_supported', 'available_callback', 'service_worker', 'nav_menu_toggle', 'nav_menu_dropdown' );
if ( count( array_diff( array_keys( $args ), $keys ) ) !== 0 ) {
_doing_it_wrong(
@@ -293,7 +301,7 @@ public static function read_theme_support() {
);
}
- $is_paired = ! empty( $args['paired'] );
+ $is_paired = ! empty( $args[ self::PAIRED_FLAG ] );
self::$support_added_via_theme = $is_paired ? self::TRANSITIONAL_MODE_SLUG : self::STANDARD_MODE_SLUG;
@@ -305,15 +313,15 @@ public static function read_theme_support() {
*/
self::$support_added_via_option = ( $is_paired && self::STANDARD_MODE_SLUG === $theme_support_option ) ? self::STANDARD_MODE_SLUG : null;
if ( self::STANDARD_MODE_SLUG === self::$support_added_via_option ) {
- $args['paired'] = false;
+ $args[ self::PAIRED_FLAG ] = false;
add_theme_support( 'amp', $args );
}
} elseif ( 'disabled' !== $theme_support_option ) {
- $is_paired = ( 'paired' === $theme_support_option );
+ $is_paired = ( self::TRANSITIONAL_MODE_SLUG === $theme_support_option );
add_theme_support(
self::SLUG,
array(
- 'paired' => $is_paired,
+ self::PAIRED_FLAG => $is_paired,
)
);
self::$support_added_via_option = $is_paired ? self::TRANSITIONAL_MODE_SLUG : self::STANDARD_MODE_SLUG;
@@ -339,7 +347,7 @@ public static function get_theme_support_args() {
$support = get_theme_support( self::SLUG );
if ( true === $support ) {
return array(
- 'paired' => false,
+ self::PAIRED_FLAG => false,
);
}
if ( ! isset( $support[0] ) || ! is_array( $support[0] ) ) {
diff --git a/includes/options/class-amp-options-manager.php b/includes/options/class-amp-options-manager.php
index a22c6d23afc..aba46d863ff 100644
--- a/includes/options/class-amp-options-manager.php
+++ b/includes/options/class-amp-options-manager.php
@@ -114,6 +114,13 @@ public static function get_options() {
unset( $options['enable_amp_stories'] );
}
+ // Migrate theme support slugs.
+ if ( 'native' === $options['theme_support'] ) {
+ $options['theme_support'] = AMP_Theme_Support::STANDARD_MODE_SLUG;
+ } elseif ( 'paired' === $options['theme_support'] ) {
+ $options['theme_support'] = AMP_Theme_Support::TRANSITIONAL_MODE_SLUG;
+ }
+
return $options;
}
@@ -195,8 +202,8 @@ public static function validate_options( $new_options ) {
// Theme support.
$recognized_theme_supports = array(
'disabled',
- 'paired',
- 'native', // aka 'standard'.
+ AMP_Theme_Support::TRANSITIONAL_MODE_SLUG,
+ AMP_Theme_Support::STANDARD_MODE_SLUG,
);
if ( isset( $new_options['theme_support'] ) && in_array( $new_options['theme_support'], $recognized_theme_supports, true ) ) {
$options['theme_support'] = $new_options['theme_support'];
@@ -593,13 +600,13 @@ public static function handle_updated_theme_support_option() {
AMP_Post_Type_Support::add_post_type_support();
// Ensure theme support flags are set properly according to the new mode so that proper AMP URL can be generated.
- $has_theme_support = ( 'native' === $template_mode || 'paired' === $template_mode );
+ $has_theme_support = ( AMP_Theme_Support::STANDARD_MODE_SLUG === $template_mode || AMP_Theme_Support::TRANSITIONAL_MODE_SLUG === $template_mode );
if ( $has_theme_support ) {
$theme_support = current_theme_supports( AMP_Theme_Support::SLUG );
if ( ! is_array( $theme_support ) ) {
$theme_support = array();
}
- $theme_support['paired'] = 'paired' === $template_mode;
+ $theme_support['paired'] = AMP_Theme_Support::TRANSITIONAL_MODE_SLUG === $template_mode;
add_theme_support( AMP_Theme_Support::SLUG, $theme_support );
} else {
remove_theme_support( AMP_Theme_Support::SLUG ); // So that the amp_get_permalink() will work for reader mode URL.
@@ -713,13 +720,13 @@ public static function handle_updated_theme_support_option() {
}
switch ( $template_mode ) {
- case 'native': // aka 'standard'.
+ case AMP_Theme_Support::STANDARD_MODE_SLUG:
$message = esc_html__( 'Standard mode activated!', 'amp' );
if ( $review_messages ) {
$message .= ' ' . join( ' ', $review_messages );
}
break;
- case 'paired':
+ case AMP_Theme_Support::TRANSITIONAL_MODE_SLUG:
$message = esc_html__( 'Transitional mode activated!', 'amp' );
if ( $review_messages ) {
$message .= ' ' . join( ' ', $review_messages );
diff --git a/includes/options/class-amp-options-menu.php b/includes/options/class-amp-options-menu.php
index a0fee2e6e68..9f078a795af 100644
--- a/includes/options/class-amp-options-menu.php
+++ b/includes/options/class-amp-options-menu.php
@@ -266,7 +266,7 @@ public function render_theme_support() {
$theme_support = AMP_Theme_Support::get_support_mode();
/* translators: %s: URL to the documentation. */
- $native_description = sprintf( __( 'The active theme integrates AMP as the framework for your site by using its templates and styles to render webpages. This means your site is AMP-first and your canonical URLs are AMP! Depending on your theme/plugins, a varying level of development work may be required.', 'amp' ), esc_url( 'https://amp-wp.org/documentation/developing-wordpress-amp-sites/' ) );
+ $standard_description = sprintf( __( 'The active theme integrates AMP as the framework for your site by using its templates and styles to render webpages. This means your site is AMP-first and your canonical URLs are AMP! Depending on your theme/plugins, a varying level of development work may be required.', 'amp' ), esc_url( 'https://amp-wp.org/documentation/developing-wordpress-amp-sites/' ) );
/* translators: %s: URL to the documentation. */
$transitional_description = sprintf( __( 'The active theme’s templates are used to generate non-AMP and AMP versions of your content, allowing for each canonical URL to have a corresponding (paired) AMP URL. This mode is useful to progressively transition towards a fully AMP-first site. Depending on your theme/plugins, a varying level of development work may be required.', 'amp' ), esc_url( 'https://amp-wp.org/documentation/developing-wordpress-amp-sites/' ) );
$reader_description = __( 'Formerly called the classic mode, this mode generates paired AMP content using simplified templates which may not match the look-and-feel of your site. Only posts/pages can be served as AMP in Reader mode. No redirection is performed for mobile visitors; AMP pages are served by AMP consumption platforms.', 'amp' );
@@ -280,7 +280,7 @@ public function render_theme_support() {
@@ -300,13 +300,13 @@ public function render_theme_support() {