From f44c96af53b9395d170a908709d7b1038655ef56 Mon Sep 17 00:00:00 2001 From: Dmytro Kovalov Date: Wed, 6 Jul 2022 09:09:41 +0300 Subject: [PATCH] Apply new control for all font-family fields #328 --- ...class-visualcomposerstarter-customizer.php | 198 +++++++++++------- 1 file changed, 126 insertions(+), 72 deletions(-) diff --git a/inc/customizer/class-visualcomposerstarter-customizer.php b/inc/customizer/class-visualcomposerstarter-customizer.php index 8615672..77968a8 100644 --- a/inc/customizer/class-visualcomposerstarter-customizer.php +++ b/inc/customizer/class-visualcomposerstarter-customizer.php @@ -1454,7 +1454,7 @@ private function vct_woocommerce( $wp_customize ) { /** * H1 fonts and style section * - * @param object $wp_customize Customizer object. + * @param WP_Customize_Manager $wp_customize Customizer object. */ private function fonts_and_style_section_h1( $wp_customize ) { $wp_customize->add_setting( 'vct_fonts_and_style_h1_text_color', array( @@ -1467,8 +1467,9 @@ private function fonts_and_style_section_h1( $wp_customize ) { ) ); $wp_customize->add_setting( 'vct_fonts_and_style_h1_font_family', array( - 'default' => 'Montserrat', + 'default' => 'Montserrat, sans-serif', 'sanitize_callback' => array( $this, 'sanitize_select_google_fonts' ), + 'transport' => 'postMessage', ) ); $wp_customize->add_setting( 'vct_fonts_and_style_h1_subsets', array( @@ -1537,13 +1538,20 @@ private function fonts_and_style_section_h1( $wp_customize ) { ) ) ); - $wp_customize->add_control( 'vct_fonts_and_style_h1_font_family', array( - 'label' => esc_html__( 'Font-family', 'visual-composer-starter' ), - 'section' => 'vct_fonts_and_style_h1', - 'settings' => 'vct_fonts_and_style_h1_font_family', - 'type' => 'select', - 'choices' => VisualComposerStarter_Fonts::vct_theme_font_choices(), - ) ); + + $wp_customize->add_control( + new VisualComposerStarter_Google_Fonts_Control( + $wp_customize, + 'vct_fonts_and_style_h1_font_family', + array( + 'label' => esc_html__( 'Font-family', 'visual-composer-starter' ), + 'section' => 'vct_fonts_and_style_h1', + 'settings' => 'vct_fonts_and_style_h1_font_family', + 'choices' => VisualComposerStarter_Fonts::vct_theme_font_choices(), + ) + ) + ); + $wp_customize->add_control( 'vct_fonts_and_style_h1_subsets', array( 'label' => esc_html__( 'Google Fonts Subsets', 'visual-composer-starter' ), 'section' => 'vct_fonts_and_style_h1', @@ -1622,7 +1630,7 @@ private function fonts_and_style_section_h1( $wp_customize ) { /** * H2 fonts and style section * - * @param object $wp_customize Customizer object. + * @param WP_Customize_Manager $wp_customize Customizer object. */ private function fonts_and_style_section_h2( $wp_customize ) { $wp_customize->add_setting( 'vct_fonts_and_style_h2_text_color', array( @@ -1635,8 +1643,9 @@ private function fonts_and_style_section_h2( $wp_customize ) { ) ); $wp_customize->add_setting( 'vct_fonts_and_style_h2_font_family', array( - 'default' => 'Montserrat', + 'default' => 'Montserrat, sans-serif', 'sanitize_callback' => array( $this, 'sanitize_select_google_fonts' ), + 'transport' => 'postMessage', ) ); $wp_customize->add_setting( 'vct_fonts_and_style_h2_subsets', array( @@ -1702,13 +1711,18 @@ private function fonts_and_style_section_h2( $wp_customize ) { ) ); - $wp_customize->add_control( 'vct_fonts_and_style_h2_font_family', array( - 'label' => esc_html__( 'Font-family', 'visual-composer-starter' ), - 'section' => 'vct_fonts_and_style_h2', - 'settings' => 'vct_fonts_and_style_h2_font_family', - 'type' => 'select', - 'choices' => VisualComposerStarter_Fonts::vct_theme_font_choices(), - ) ); + $wp_customize->add_control( + new VisualComposerStarter_Google_Fonts_Control( + $wp_customize, + 'vct_fonts_and_style_h2_font_family', + array( + 'label' => esc_html__( 'Font-family', 'visual-composer-starter' ), + 'section' => 'vct_fonts_and_style_h2', + 'settings' => 'vct_fonts_and_style_h2_font_family', + 'choices' => VisualComposerStarter_Fonts::vct_theme_font_choices(), + ) + ) + ); $wp_customize->add_control( 'vct_fonts_and_style_h2_subsets', array( 'label' => esc_html__( 'Google Fonts Subsets', 'visual-composer-starter' ), @@ -1793,7 +1807,7 @@ private function fonts_and_style_section_h2( $wp_customize ) { /** * H3 fonts and style section * - * @param object $wp_customize Customizer object. + * @param WP_Customize_Manager $wp_customize Customizer object. */ private function fonts_and_style_section_h3( $wp_customize ) { $wp_customize->add_setting( 'vct_fonts_and_style_h3_text_color', array( @@ -1805,8 +1819,9 @@ private function fonts_and_style_section_h3( $wp_customize ) { 'sanitize_callback' => 'sanitize_hex_color', ) ); $wp_customize->add_setting( 'vct_fonts_and_style_h3_font_family', array( - 'default' => 'Montserrat', + 'default' => 'Montserrat, sans-serif', 'sanitize_callback' => array( $this, 'sanitize_select_google_fonts' ), + 'transport' => 'postMessage', ) ); $wp_customize->add_setting( 'vct_fonts_and_style_h3_subsets', array( 'default' => 'all', @@ -1867,13 +1882,20 @@ private function fonts_and_style_section_h3( $wp_customize ) { ) ) ); - $wp_customize->add_control( 'vct_fonts_and_style_h3_font_family', array( - 'label' => esc_html__( 'Font-family', 'visual-composer-starter' ), - 'section' => 'vct_fonts_and_style_h3', - 'settings' => 'vct_fonts_and_style_h3_font_family', - 'type' => 'select', - 'choices' => VisualComposerStarter_Fonts::vct_theme_font_choices(), - ) ); + + $wp_customize->add_control( + new VisualComposerStarter_Google_Fonts_Control( + $wp_customize, + 'vct_fonts_and_style_h3_font_family', + array( + 'label' => esc_html__( 'Font-family', 'visual-composer-starter' ), + 'section' => 'vct_fonts_and_style_h3', + 'settings' => 'vct_fonts_and_style_h3_font_family', + 'choices' => VisualComposerStarter_Fonts::vct_theme_font_choices(), + ) + ) + ); + $wp_customize->add_control( 'vct_fonts_and_style_h3_subsets', array( 'label' => esc_html__( 'Google Fonts Subsets', 'visual-composer-starter' ), 'section' => 'vct_fonts_and_style_h3', @@ -1955,7 +1977,7 @@ private function fonts_and_style_section_h3( $wp_customize ) { /** * H4 fonts and style section * - * @param object $wp_customize Customizer object. + * @param WP_Customize_Manager $wp_customize Customizer object. */ private function fonts_and_style_section_h4( $wp_customize ) { $wp_customize->add_setting( 'vct_fonts_and_style_h4_text_color', array( @@ -1966,9 +1988,11 @@ private function fonts_and_style_section_h4( $wp_customize ) { 'default' => '#557cbf', 'sanitize_callback' => 'sanitize_hex_color', ) ); + $wp_customize->add_setting( 'vct_fonts_and_style_h4_font_family', array( - 'default' => 'Montserrat', + 'default' => 'Montserrat, sans-serif', 'sanitize_callback' => array( $this, 'sanitize_select_google_fonts' ), + 'transport' => 'postMessage', ) ); $wp_customize->add_setting( 'vct_fonts_and_style_h4_subsets', array( @@ -2034,13 +2058,18 @@ private function fonts_and_style_section_h4( $wp_customize ) { ) ); - $wp_customize->add_control( 'vct_fonts_and_style_h4_font_family', array( - 'label' => esc_html__( 'Font-family', 'visual-composer-starter' ), - 'section' => 'vct_fonts_and_style_h4', - 'settings' => 'vct_fonts_and_style_h4_font_family', - 'type' => 'select', - 'choices' => VisualComposerStarter_Fonts::vct_theme_font_choices(), - ) ); + $wp_customize->add_control( + new VisualComposerStarter_Google_Fonts_Control( + $wp_customize, + 'vct_fonts_and_style_h4_font_family', + array( + 'label' => esc_html__( 'Font-family', 'visual-composer-starter' ), + 'section' => 'vct_fonts_and_style_h4', + 'settings' => 'vct_fonts_and_style_h4_font_family', + 'choices' => VisualComposerStarter_Fonts::vct_theme_font_choices(), + ) + ) + ); $wp_customize->add_control( 'vct_fonts_and_style_h4_subsets', array( 'label' => esc_html__( 'Google Fonts Subsets', 'visual-composer-starter' ), @@ -2124,7 +2153,7 @@ private function fonts_and_style_section_h4( $wp_customize ) { /** * H5 fonts and style section * - * @param object $wp_customize Customizer object. + * @param WP_Customize_Manager $wp_customize Customizer object. */ private function fonts_and_style_section_h5( $wp_customize ) { $wp_customize->add_setting( 'vct_fonts_and_style_h5_text_color', array( @@ -2135,9 +2164,11 @@ private function fonts_and_style_section_h5( $wp_customize ) { 'default' => '#557cbf', 'sanitize_callback' => 'sanitize_hex_color', ) ); + $wp_customize->add_setting( 'vct_fonts_and_style_h5_font_family', array( - 'default' => 'Montserrat', + 'default' => 'Montserrat, sans-serif', 'sanitize_callback' => array( $this, 'sanitize_select_google_fonts' ), + 'transport' => 'postMessage', ) ); $wp_customize->add_setting( 'vct_fonts_and_style_h5_subsets', array( @@ -2202,13 +2233,18 @@ private function fonts_and_style_section_h5( $wp_customize ) { ) ); - $wp_customize->add_control( 'vct_fonts_and_style_h5_font_family', array( - 'label' => esc_html__( 'Font-family', 'visual-composer-starter' ), - 'section' => 'vct_fonts_and_style_h5', - 'settings' => 'vct_fonts_and_style_h5_font_family', - 'type' => 'select', - 'choices' => VisualComposerStarter_Fonts::vct_theme_font_choices(), - ) ); + $wp_customize->add_control( + new VisualComposerStarter_Google_Fonts_Control( + $wp_customize, + 'vct_fonts_and_style_h5_font_family', + array( + 'label' => esc_html__( 'Font-family', 'visual-composer-starter' ), + 'section' => 'vct_fonts_and_style_h5', + 'settings' => 'vct_fonts_and_style_h5_font_family', + 'choices' => VisualComposerStarter_Fonts::vct_theme_font_choices(), + ) + ) + ); $wp_customize->add_control( 'vct_fonts_and_style_h5_subsets', array( 'label' => esc_html__( 'Google Fonts Subsets', 'visual-composer-starter' ), @@ -2292,7 +2328,7 @@ private function fonts_and_style_section_h5( $wp_customize ) { /** * H6 fonts and style section * - * @param object $wp_customize Customizer object. + * @param WP_Customize_Manager $wp_customize Customizer object. */ private function fonts_and_style_section_h6( $wp_customize ) { $wp_customize->add_setting( 'vct_fonts_and_style_h6_text_color', array( @@ -2303,9 +2339,11 @@ private function fonts_and_style_section_h6( $wp_customize ) { 'default' => '#557cbf', 'sanitize_callback' => 'sanitize_hex_color', ) ); + $wp_customize->add_setting( 'vct_fonts_and_style_h6_font_family', array( - 'default' => 'Montserrat', + 'default' => 'Montserrat, sans-serif', 'sanitize_callback' => array( $this, 'sanitize_select_google_fonts' ), + 'transport' => 'postMessage', ) ); $wp_customize->add_setting( 'vct_fonts_and_style_h6_subsets', array( @@ -2370,13 +2408,18 @@ private function fonts_and_style_section_h6( $wp_customize ) { ) ); - $wp_customize->add_control( 'vct_fonts_and_style_h6_font_family', array( - 'label' => esc_html__( 'Font-family', 'visual-composer-starter' ), - 'section' => 'vct_fonts_and_style_h6', - 'settings' => 'vct_fonts_and_style_h6_font_family', - 'type' => 'select', - 'choices' => VisualComposerStarter_Fonts::vct_theme_font_choices(), - ) ); + $wp_customize->add_control( + new VisualComposerStarter_Google_Fonts_Control( + $wp_customize, + 'vct_fonts_and_style_h6_font_family', + array( + 'label' => esc_html__( 'Font-family', 'visual-composer-starter' ), + 'section' => 'vct_fonts_and_style_h6', + 'settings' => 'vct_fonts_and_style_h6_font_family', + 'choices' => VisualComposerStarter_Fonts::vct_theme_font_choices(), + ) + ) + ); $wp_customize->add_control( 'vct_fonts_and_style_h6_subsets', array( 'label' => esc_html__( 'Google Fonts Subsets', 'visual-composer-starter' ), @@ -2464,7 +2507,7 @@ private function fonts_and_style_section_h6( $wp_customize ) { /** * Body fonts and style section * - * @param object $wp_customize Customizer object. + * @param WP_Customize_Manager $wp_customize Customizer object. */ private function fonts_and_style_section_body( $wp_customize ) { $wp_customize->add_setting( 'vct_fonts_and_style_body_primary_color', array( @@ -2482,8 +2525,9 @@ private function fonts_and_style_section_body( $wp_customize ) { ) ); $wp_customize->add_setting( 'vct_fonts_and_style_body_font_family', array( - 'default' => 'Roboto, sans-serif', + 'default' => 'Roboto, sans-serif', 'sanitize_callback' => array( $this, 'sanitize_select_google_fonts' ), + 'transport' => 'postMessage', ) ); $wp_customize->add_setting( 'vct_fonts_and_style_body_subsets', array( @@ -2563,13 +2607,17 @@ private function fonts_and_style_section_body( $wp_customize ) { ) ); - $wp_customize->add_control( 'vct_fonts_and_style_body_font_family', array( - 'label' => esc_html__( 'Font-family', 'visual-composer-starter' ), - 'section' => 'vct_fonts_and_style_body', - 'settings' => 'vct_fonts_and_style_body_font_family', - 'type' => 'select', - 'choices' => VisualComposerStarter_Fonts::vct_theme_font_choices(), - ) ); + $wp_customize->add_control( + new VisualComposerStarter_Google_Fonts_Control( + $wp_customize, + 'vct_fonts_and_style_body_font_family', array( + 'label' => esc_html__( 'Font-family', 'visual-composer-starter' ), + 'section' => 'vct_fonts_and_style_body', + 'settings' => 'vct_fonts_and_style_body_font_family', + 'choices' => VisualComposerStarter_Fonts::vct_theme_font_choices(), + ) + ) + ); $wp_customize->add_control( 'vct_fonts_and_style_body_subsets', array( 'label' => esc_html__( 'Google Fonts Subsets', 'visual-composer-starter' ), @@ -2653,7 +2701,7 @@ private function fonts_and_style_section_body( $wp_customize ) { /** * Buttons fonts and style section * - * @param object $wp_customize Customizer object. + * @param WP_Customize_Manager $wp_customize Customizer object. */ private function fonts_and_style_section_buttons( $wp_customize ) { $wp_customize->add_setting( 'vct_fonts_and_style_buttons_background_color', array( @@ -2674,8 +2722,9 @@ private function fonts_and_style_section_buttons( $wp_customize ) { ) ); $wp_customize->add_setting( 'vct_fonts_and_style_buttons_font_family', array( - 'default' => 'Montserrat', + 'default' => 'Montserrat, sans-serif', 'sanitize_callback' => array( $this, 'sanitize_select_google_fonts' ), + 'transport' => 'postMessage', ) ); $wp_customize->add_setting( 'vct_fonts_and_style_buttons_subsets', array( @@ -2765,13 +2814,18 @@ private function fonts_and_style_section_buttons( $wp_customize ) { ) ); - $wp_customize->add_control( 'vct_fonts_and_style_buttons_font_family', array( - 'label' => esc_html__( 'Font-family', 'visual-composer-starter' ), - 'section' => 'vct_fonts_and_style_buttons', - 'settings' => 'vct_fonts_and_style_buttons_font_family', - 'type' => 'select', - 'choices' => VisualComposerStarter_Fonts::vct_theme_font_choices(), - ) ); + $wp_customize->add_control( + new VisualComposerStarter_Google_Fonts_Control( + $wp_customize, + 'vct_fonts_and_style_buttons_font_family', + array( + 'label' => esc_html__( 'Font-family', 'visual-composer-starter' ), + 'section' => 'vct_fonts_and_style_buttons', + 'settings' => 'vct_fonts_and_style_buttons_font_family', + 'choices' => VisualComposerStarter_Fonts::vct_theme_font_choices(), + ) + ) + ); $wp_customize->add_control( 'vct_fonts_and_style_buttons_subsets', array( 'label' => esc_html__( 'Google Fonts Subsets', 'visual-composer-starter' ),