diff --git a/projects/packages/publicize/changelog/fix-publicize-activation-crash-in-the-editor b/projects/packages/publicize/changelog/fix-publicize-activation-crash-in-the-editor new file mode 100644 index 0000000000000..18cb7b183c157 --- /dev/null +++ b/projects/packages/publicize/changelog/fix-publicize-activation-crash-in-the-editor @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Social | Fixed publicize crashing when activated in the editor diff --git a/projects/packages/publicize/src/class-publicize-script-data.php b/projects/packages/publicize/src/class-publicize-script-data.php index 1b285f1d09801..70ce959194f12 100644 --- a/projects/packages/publicize/src/class-publicize-script-data.php +++ b/projects/packages/publicize/src/class-publicize-script-data.php @@ -84,14 +84,14 @@ public static function get_admin_script_data() { // the Jetpack settings page, or the block editor. $should_set_script_data = Utils::is_jetpack_settings_page() || Utils::is_social_settings_page() - || Utils::should_block_editor_have_social(); + || Utils::should_block_editor_have_social( false ); if ( ! $should_set_script_data ) { return array(); } $basic_data = array( - 'api_paths' => array(), + 'api_paths' => self::get_api_paths(), 'is_publicize_enabled' => Utils::is_publicize_active(), 'feature_flags' => self::get_feature_flags(), 'supported_services' => array(), @@ -114,7 +114,6 @@ public static function get_admin_script_data() { return array_merge( $basic_data, array( - 'api_paths' => self::get_api_paths(), 'supported_services' => self::get_supported_services(), 'shares_data' => self::get_shares_data(), 'urls' => self::get_urls(), diff --git a/projects/packages/publicize/src/class-publicize-utils.php b/projects/packages/publicize/src/class-publicize-utils.php index 77f5272f0ba93..96048880cd8e2 100644 --- a/projects/packages/publicize/src/class-publicize-utils.php +++ b/projects/packages/publicize/src/class-publicize-utils.php @@ -37,9 +37,11 @@ public static function is_jetpack_settings_page() { /** * Whether the block editor should have the social features. * + * @param bool $should_publicize_be_active Whether the Publicize module should be active. + * * @return bool */ - public static function should_block_editor_have_social() { + public static function should_block_editor_have_social( $should_publicize_be_active = true ) { if ( ! is_admin() ) { return false; } @@ -56,7 +58,7 @@ public static function should_block_editor_have_social() { return false; } - if ( ! self::is_publicize_active() ) { + if ( $should_publicize_be_active && ! self::is_publicize_active() ) { return false; } diff --git a/projects/plugins/jetpack/changelog/fix-publicize-activation-crash-in-the-editor b/projects/plugins/jetpack/changelog/fix-publicize-activation-crash-in-the-editor new file mode 100644 index 0000000000000..0af9f98a252a8 --- /dev/null +++ b/projects/plugins/jetpack/changelog/fix-publicize-activation-crash-in-the-editor @@ -0,0 +1,4 @@ +Significance: patch +Type: bugfix + +Social | Fixed publicize crashing when activated in the editor diff --git a/projects/plugins/social/changelog/fix-publicize-activation-crash-in-the-editor b/projects/plugins/social/changelog/fix-publicize-activation-crash-in-the-editor new file mode 100644 index 0000000000000..cdb89762a5ffe --- /dev/null +++ b/projects/plugins/social/changelog/fix-publicize-activation-crash-in-the-editor @@ -0,0 +1,4 @@ +Significance: patch +Type: fixed + +Fixed publicize crashing when activated in the editor diff --git a/projects/plugins/social/src/class-jetpack-social.php b/projects/plugins/social/src/class-jetpack-social.php index 2d8b351f6ac08..a9a96b55fea7d 100644 --- a/projects/plugins/social/src/class-jetpack-social.php +++ b/projects/plugins/social/src/class-jetpack-social.php @@ -18,6 +18,7 @@ use Automattic\Jetpack\Modules; use Automattic\Jetpack\My_Jetpack\Initializer as My_Jetpack_Initializer; use Automattic\Jetpack\Publicize\Jetpack_Social_Settings\Dismissed_Notices; +use Automattic\Jetpack\Publicize\Publicize_Utils; use Automattic\Jetpack\Status; use Automattic\Jetpack\Terms_Of_Service; use Automattic\Jetpack\Tracking; @@ -224,6 +225,10 @@ public function get_shares_info() { * @return array */ public function set_social_admin_script_data( $data ) { + // We need this data only on the social settings page. + if ( ! Publicize_Utils::is_social_settings_page() ) { + return $data; + } $data['plugin_info']['social'] = array( 'version' => $this->get_plugin_version(),