-
Notifications
You must be signed in to change notification settings - Fork 359
Blockbase: Only display font customizer options if not enabled in site editor #5976
Changes from all commits
0e5448c
1d641fe
004718f
9b9b688
443bf63
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -209,13 +209,66 @@ 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' ) ); | ||
| add_action( 'customize_save_after', array( $this, 'handle_customize_save_after' ) ); | ||
| 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' ); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note: Jetpack::is_module_active always returns true for dotcom simple regardless of what value is passed to it. Unsure why at the moment
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jeyip yup that is by design. From a code comment on
|
||
| } | ||
|
|
||
| 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' => '<div class="notice notice-info"> | ||
| <p>' . __( 'Updating fonts for this theme is now even easier! Use the site editor to select and preview different font families.', 'blockbase' ) . '</p> | ||
| </div>', | ||
| 'settings' => array(), | ||
| 'section' => $this->section_key, | ||
| ) | ||
| ); | ||
|
|
||
| $wp_customize->add_control( | ||
| $this->section_key . '-site-editor-button', | ||
| array( | ||
| 'type' => 'hidden', | ||
| 'description' => sprintf( '<a class="button button-primary" href=%s style="font-style: normal;" >Use Site Editor</a>', 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 ); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO:
Remove unnecessary reference to
wpcom. We control all versioning for Jetpack, Gutenberg, and jetpack modules for simple sites.