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_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_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" ) ) ); } 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' => 'sanitize_key', ) ); $wp_customize->add_setting( sprintf( '%s[subset]', $id ), array( 'default' => isset( $args['default']['subset'] ) ? $args['default']['subset'] : false, 'sanitize_callback' => 'sanitize_key', ) ); $wp_customize->add_setting( sprintf( '%s[size]', $id ), array( 'default' => isset( $args['default']['size'] ) ? $args['default']['size'] : '0px', 'sanitize_callback' => 'esc_attr', ) ); } 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' => array( array( 'label' => esc_html__( 'Standard Fonts', 'beetan' ), 'options' => beetan_standard_fonts() ), array( 'label' => esc_html__( 'Google Fonts', 'beetan' ), 'options' => 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_styles(), '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_styles(), 'extras' => array( 'id' => $id ) ) ) ); $wp_customize->add_control( new Beetan_Customize_Unit_Control( $wp_customize, sprintf( '%s[size]', $id ), array( 'label' => sprintf( esc_html__( '%s Size', 'beetan' ), $args['label'] ), // phpcs:ignore WordPress.WP.I18n.MissingTranslatorsComment 'description' => wp_kses_post( isset( $args['description'] ) ? $args['description'] : '' ), 'placeholder' => esc_html__( 'Font Size', 'beetan' ), 'section' => $args['section'], 'required' => array( sprintf( '%s[family]', $id ) ) ) ) ); } } endif;