From 709dd1d0c669e5d300b1a3896eeed7cf471aefe9 Mon Sep 17 00:00:00 2001 From: Juanma Rodriguez Escriche Date: Fri, 5 Jul 2024 12:09:16 +0200 Subject: [PATCH] Featured Content: Update loading from different environments loading (#38215) * Moved the check for plugins.php to inside init in case setup method is called from outside. * Add setup from jetpack-mu-wpcom * Remove setup from the class so that it's only set when called explicitly * Changelogs * Changelogs * Bug on the check --- .../changelog/update-featured-content-update-loading | 4 ++++ .../classic-theme-helper/src/class-featured-content.php | 7 ++++--- .../changelog/update-featured-content-update-loading | 4 ++++ .../jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php | 1 + .../changelog/update-featured-content-update-loading | 4 ++++ .../jetpack/modules/theme-tools/featured-content.php | 5 ++++- 6 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 projects/packages/classic-theme-helper/changelog/update-featured-content-update-loading create mode 100644 projects/packages/jetpack-mu-wpcom/changelog/update-featured-content-update-loading create mode 100644 projects/plugins/jetpack/changelog/update-featured-content-update-loading diff --git a/projects/packages/classic-theme-helper/changelog/update-featured-content-update-loading b/projects/packages/classic-theme-helper/changelog/update-featured-content-update-loading new file mode 100644 index 0000000000000..eae73a0ed62c4 --- /dev/null +++ b/projects/packages/classic-theme-helper/changelog/update-featured-content-update-loading @@ -0,0 +1,4 @@ +Significance: minor +Type: changed + +Classic Theme Helper - Featured Content: Moved check for plugins page to init since setup is used now externally diff --git a/projects/packages/classic-theme-helper/src/class-featured-content.php b/projects/packages/classic-theme-helper/src/class-featured-content.php index 56447d3de8c8c..520ce31a32c29 100644 --- a/projects/packages/classic-theme-helper/src/class-featured-content.php +++ b/projects/packages/classic-theme-helper/src/class-featured-content.php @@ -10,7 +10,7 @@ use Automattic\Jetpack\Assets; use WP_Customize_Manager; use WP_Query; -if ( ! class_exists( __NAMESPACE__ . '\Featured_Content' ) && isset( $GLOBALS['pagenow'] ) && 'plugins.php' !== $GLOBALS['pagenow'] ) { +if ( ! class_exists( __NAMESPACE__ . '\Featured_Content' ) ) { /** * Featured Content. @@ -88,6 +88,9 @@ public static function setup() { */ public static function init() { + if ( isset( $GLOBALS['pagenow'] ) && 'plugins.php' === $GLOBALS['pagenow'] ) { + return; + } /** * Array variable to store theme support. * @@ -757,6 +760,4 @@ public static function jetpack_update_featured_content_for_split_terms( $old_ter } } } - - Featured_Content::setup(); } diff --git a/projects/packages/jetpack-mu-wpcom/changelog/update-featured-content-update-loading b/projects/packages/jetpack-mu-wpcom/changelog/update-featured-content-update-loading new file mode 100644 index 0000000000000..3550c13abc43b --- /dev/null +++ b/projects/packages/jetpack-mu-wpcom/changelog/update-featured-content-update-loading @@ -0,0 +1,4 @@ +Significance: minor +Type: added + +Jetpack Mu Wpcom: Added call for Featured Content diff --git a/projects/packages/jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php b/projects/packages/jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php index 7956380100485..fefa58c7fcaa2 100644 --- a/projects/packages/jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php +++ b/projects/packages/jetpack-mu-wpcom/src/class-jetpack-mu-wpcom.php @@ -109,6 +109,7 @@ public static function load_features() { // Initializers, if needed. \Marketplace_Products_Updater::init(); + \Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::setup(); // Only load the Calypsoify and Masterbar features on WoA sites. if ( class_exists( '\Automattic\Jetpack\Status\Host' ) && ( new \Automattic\Jetpack\Status\Host() )->is_woa_site() ) { diff --git a/projects/plugins/jetpack/changelog/update-featured-content-update-loading b/projects/plugins/jetpack/changelog/update-featured-content-update-loading new file mode 100644 index 0000000000000..6859bda7cc9c0 --- /dev/null +++ b/projects/plugins/jetpack/changelog/update-featured-content-update-loading @@ -0,0 +1,4 @@ +Significance: minor +Type: other + +Featured Content: Don't call setup for wpcom platform since jetpack-mu-wpcom already takes care of that. diff --git a/projects/plugins/jetpack/modules/theme-tools/featured-content.php b/projects/plugins/jetpack/modules/theme-tools/featured-content.php index eee39e69c3489..afea4d6b7dc7c 100644 --- a/projects/plugins/jetpack/modules/theme-tools/featured-content.php +++ b/projects/plugins/jetpack/modules/theme-tools/featured-content.php @@ -4,6 +4,7 @@ * * @package automattic/jetpack */ +use Automattic\Jetpack\Status\Host; if ( ! class_exists( 'Featured_Content' ) && isset( $GLOBALS['pagenow'] ) && 'plugins.php' !== $GLOBALS['pagenow'] ) { @@ -357,5 +358,7 @@ public static function jetpack_update_featured_content_for_split_terms( $old_ter } } - Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::setup(); + if ( ! ( new Host() )->is_wpcom_platform() ) { + Automattic\Jetpack\Classic_Theme_Helper\Featured_Content::setup(); + } }