From 328bba5af15e28ff14636ca707a722993e57ee4b Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Mon, 2 Jul 2018 12:32:53 -0700 Subject: [PATCH] Fix initialization of paried mode and Customizer, and fix support options on admin screen --- amp.php | 10 ++++++++++ includes/options/class-amp-options-menu.php | 14 ++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/amp.php b/amp.php index 09fa1402bd7..f47001ff8bc 100644 --- a/amp.php +++ b/amp.php @@ -312,6 +312,16 @@ function amp_is_canonical() { $support = get_theme_support( 'amp' ); if ( is_array( $support ) ) { $args = array_shift( $support ); + + if ( ! empty( $args['optional'] ) ) { + $support = AMP_Options_Manager::get_option( 'theme_support' ); + if ( 'disabled' === $support ) { + return false; + } elseif ( ! isset( $args['mode'] ) ) { + return 'native' === $support; + } + } + if ( isset( $args['mode'] ) ) { $mode = $args['mode']; } elseif ( ! empty( $args['template_dir'] ) ) { diff --git a/includes/options/class-amp-options-menu.php b/includes/options/class-amp-options-menu.php index 82672bc1df6..4ce89cf0958 100644 --- a/includes/options/class-amp-options-menu.php +++ b/includes/options/class-amp-options-menu.php @@ -129,21 +129,15 @@ public function render_theme_support() { $support_args = AMP_Theme_Support::get_theme_support_args( array( 'initial' => true ) ); $theme_support_mutable = ( - empty( $support_args ) - || ! empty( $support_args['optional'] ) || AMP_Theme_Support::is_support_added_via_option() ); - $mode_mutable = ! ( is_array( $support_args ) && isset( $support_args['mode'] ) ); + $mode_mutable = ! isset( $support_args['mode'] ); if ( ! $theme_support_mutable || ( ! $mode_mutable && 'disabled' !== $theme_support ) ) { - if ( amp_is_canonical() ) { - $theme_support = 'native'; - } else { - $theme_support = 'paired'; - } + $theme_support = isset( $support_args['mode'] ) ? $support_args['mode'] : 'native'; } $should_have_theme_support = in_array( get_template(), array( 'twentyfifteen', 'twentysixteen', 'twentyseventeen' ), true ); @@ -168,7 +162,7 @@ public function render_theme_support() {
- +
>
>