placeholder = isset( $args['placeholder'] ) ? $args['placeholder'] : ''; $this->extras = isset( $args['extras'] ) ? $args['extras'] : array(); } public function to_json() { parent::to_json(); $this->json['placeholder'] = $this->placeholder; $this->json['extras'] = $this->extras; } public function enqueue() { $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; wp_enqueue_style( 'select2', esc_url( get_theme_file_uri( "/assets/css/select2{$suffix}.css" ) ), array(), beetan_assets_version( get_theme_file_uri( "/assets/css/select2{$suffix}.css" ) ) ); wp_enqueue_script( 'select2', esc_url( get_theme_file_uri( "/assets/js/select2{$suffix}.js" ) ), array( 'jquery' ), beetan_assets_version( get_theme_file_uri( "/assets/js/select2{$suffix}.js" ) ), true ); wp_enqueue_style( 'customize-typography-control', esc_url( get_theme_file_uri( "/assets/css/customize-typography-control{$suffix}.css" ) ), array(), beetan_assets_version( get_theme_file_uri( "/assets/css/customize-typography-control{$suffix}.css" ) ) ); wp_enqueue_script( 'customize-typography-control', esc_url( get_theme_file_uri( "/assets/js/customize-typography-control{$suffix}.js" ) ), array( 'jquery', 'select2' ), beetan_assets_version( get_theme_file_uri( "/assets/js/customize-typography-control{$suffix}.js" ) ), true ); wp_localize_script( 'customize-typography-control', 'CustomizeTypographyObject', array( 'standardFonts' => beetan_standard_fonts(), 'standardFontWidth' => beetan_standard_font_width(), 'standardFontSubset' => beetan_standard_font_subset(), 'googleFonts' => beetan_all_google_fonts() ) ); } protected function render_content() { if ( empty( $this->choices ) ) { return; } ?> add_settings( $wp_customize, $id, $args ); $this->add_controls( $wp_customize, $id, $args ); } private function add_settings( $wp_customize, $id, $args = array() ) { $wp_customize->add_setting( sprintf( '%s[family]', $id ), array( 'default' => isset( $args['default']['family'] ) ? $args['default']['family'] : false, 'sanitize_callback' => 'sanitize_key', ) ); $wp_customize->add_setting( sprintf( '%s[style]', $id ), array( 'default' => isset( $args['default']['style'] ) ? $args['default']['style'] : false, 'sanitize_callback' => 'beetan_sanitize_multiselect', ) ); // $wp_customize->add_setting( sprintf( '%s[subset]', $id ), array( // 'default' => isset( $args['default']['subset'] ) ? $args['default']['subset'] : false, //// 'sanitize_callback' => 'beetan_sanitize_select', // ) ); } private function add_controls( $wp_customize, $id, $args ) { $wp_customize->add_control( new Beetan_Customize_Typography_Control( $wp_customize, sprintf( '%s[family]', $id ), array( 'label' => sprintf( esc_html__( '%s Family', 'beetan' ), $args['label'] ), // phpcs:ignore WordPress.WP.I18n.MissingTranslatorsComment 'description' => wp_kses_post( isset( $args['description'] ) ? $args['description'] : '' ), 'placeholder' => esc_html__( 'Font Family', 'beetan' ), 'section' => $args['section'], 'choices' => beetan_google_fonts(), 'extras' => array( 'id' => $id ) ) ) ); $wp_customize->add_control( new Beetan_Customize_Typography_Control( $wp_customize, sprintf( '%s[style]', $id ), array( 'label' => sprintf( esc_html__( '%s Style', 'beetan' ), $args['label'] ), // phpcs:ignore WordPress.WP.I18n.MissingTranslatorsComment 'description' => wp_kses_post( isset( $args['description'] ) ? $args['description'] : '' ), 'placeholder' => esc_html__( 'Font Style', 'beetan' ), 'section' => $args['section'], 'choices' => beetan_standard_font_width(), 'extras' => array( 'id' => $id ) ) ) ); // $wp_customize->add_control( // new Beetan_Customize_Typography_Control( $wp_customize, // sprintf( '%s[subset]', $id ), // array( // 'label' => sprintf( esc_html__( '%s Subset', 'beetan' ), $args['label'] ), // // phpcs:ignore WordPress.WP.I18n.MissingTranslatorsComment // 'description' => wp_kses_post( isset( $args['description'] ) ? $args['description'] : '' ), // 'placeholder' => esc_html__( 'Font Subset', 'beetan' ), // 'section' => $args['section'], // 'choices' => beetan_standard_font_subset(), // 'extras' => array( // 'id' => $id // ) // ) // ) // ); } } }