diff --git a/blockbase/inc/customizer/wp-customize-fonts.php b/blockbase/inc/customizer/wp-customize-fonts.php index c2457292f2..e4313dfc38 100644 --- a/blockbase/inc/customizer/wp-customize-fonts.php +++ b/blockbase/inc/customizer/wp-customize-fonts.php @@ -209,6 +209,11 @@ class GlobalStylesFontsCustomizer { ); function __construct() { + if ( $this->site_editor_is_implementing_google_fonts() ) { + add_action( 'customize_register', array( $this, 'init_deprecation_notice' ) ); + return; + } + add_action( 'customize_register', array( $this, 'initialize' ) ); add_action( 'customize_preview_init', array( $this, 'handle_customize_preview_init' ) ); add_action( 'customize_register', array( $this, 'enqueue_google_fonts' ) ); @@ -216,6 +221,54 @@ function __construct() { add_action( 'customize_controls_enqueue_scripts', array( $this, 'customize_control_js' ) ); } + function site_editor_is_implementing_google_fonts() { + $jetpack_has_google_fonts_module = false; + $gutenberg_webfonts_api_supports_enqueueing = false; + + if ( defined( 'JETPACK__VERSION' ) ) { + $jetpack_has_google_fonts_module = JETPACK__VERSION === 'wpcom' || version_compare( JETPACK__VERSION, '10.8', '>' ); + } + + if ( defined( 'GUTENBERG_VERSION' ) ) { + $gutenberg_webfonts_api_supports_enqueueing = version_compare( GUTENBERG_VERSION, '13.0', '>=' ); + } + + return $jetpack_has_google_fonts_module && $gutenberg_webfonts_api_supports_enqueueing && Jetpack::is_module_active( 'google-fonts' ); + } + + function init_deprecation_notice( $wp_customize ) { + $wp_customize->add_section( + $this->section_key, + array( + 'capability' => 'edit_theme_options', + 'title' => __( 'Fonts', 'blockbase' ), + ) + ); + + $wp_customize->add_control( + $this->section_key . '-v1-blockbase-font-deprecation-notice', + array( + 'type' => 'hidden', + 'description' => '
+

' . __( 'Updating fonts for this theme is now even easier! Use the site editor to select and preview different font families.', 'blockbase' ) . '

+
', + 'settings' => array(), + 'section' => $this->section_key, + ) + ); + + $wp_customize->add_control( + $this->section_key . '-site-editor-button', + array( + 'type' => 'hidden', + 'description' => sprintf( 'Use Site Editor', esc_url( admin_url( 'site-editor.php' ) ) ), + 'settings' => array(), + 'section' => $this->section_key, + ) + ); + } + + function handle_customize_preview_init( $wp_customize ) { $this->update_font_settings( $wp_customize ); $this->customize_preview_js( $wp_customize );