CSSID = $this->get_CSS_ID(); $this->add_hooks(); // Since 4.7 all the customizer data is saved in a post type named changeset. // This is how we get it. if ( method_exists( $wp_customize, 'changeset_data' ) ) { $changeset_data = $wp_customize->changeset_data(); if ( isset( $changeset_data[$this->setting->id] ) ) { $this->current_value = $this->standardizeSettingValue( $changeset_data[$this->setting->id]['value'] ); return; } } $this->current_value = $this->standardizeSettingValue( $this->value() ); } protected function add_hooks() { if ( ! empty( $this->recommended ) ) { add_action( 'customify_font_family_select_options', array( $this, 'output_recommended_options_group' ), 10, 3 ); } // Standardize the setting value at a low level so it is consistent everywhere (including in JS). add_filter( "customize_sanitize_js_{$this->setting->id}", array( $this, 'standardizeSettingValue'), 100, 1 ); } /** * Given a font value, standardize it (unencoded). * * @param mixed $value * @param WP_Customize_Setting $setting * * @return array */ public function standardizeSettingValue( $value ) { $value = Customify_Fonts_Global::maybeDecodeValue( $value ); $value = Customify_Fonts_Global::standardizeFontValue( $value ); return $value; } public function output_recommended_options_group( $active_font_family, $current_value, $field_id ) { // We only want each instance to output it's recommended options group. if ( $this->id !== $field_id ) { return; } $this->display_recommended_options_group( $active_font_family, $current_value ); } protected function display_recommended_options_group( $active_font_family, $current_value ) { // Allow others to add options here do_action( 'customify_font_family_before_recommended_fonts_options', $active_font_family, $current_value ); if ( ! empty( $this->recommended ) ) { echo ''; foreach ( $this->recommended as $font_family ) { self::output_font_family_option( $font_family, $active_font_family ); } echo ""; } // Allow others to add options here do_action( 'customify_font_family_after_recommended_fonts_options', $active_font_family, $current_value ); } /** * Render the control's content. */ public function render_content() { // The self::value() will consider the defined default value and return that if that is the case. $current_value = $this->current_value; if ( empty( $current_value ) ) { $current_value = $this->get_default_values(); } // Make sure it is an object from here going forward. $current_value = (object) $current_value; $current_font_family = ''; if ( isset( $current_value->font_family ) ) { $current_font_family = $current_value->font_family; } $current_font_details = array(); if ( ! empty( $current_font_family ) ) { $current_font_details = Customify_Fonts_Global::instance()->getFontDetails( $current_font_family ); } $select_data = 'data-active_font_family="' . esc_attr( $current_font_family ) . '"'; ?>
display_value_holder( $current_value ); $this->display_field_title( $current_font_family, $current_font_details ); ?>
description ) ) : ?> description; ?> link(); ?> value="" /> fields['font-weight'] ) ) { return; } // Display is for the initial state. Depending on the selected fonts, the JS logic will show or hide it. $display = 'none'; if ( ! empty( $current_font_details['variants'] ) && $current_font_details['variants'] !== ['regular'] ) { $display = 'inline-block'; } $selected = false; if ( isset( $current_value->font_variant ) ) { $selected = $current_value->font_variant; } ?>
  • fields[ $field ] ) ) { return; } $value = empty( $currentFontValue->$valueEntry ) ? 0 : $currentFontValue->$valueEntry; // Standardize the value. $value = Customify_Fonts_Global::standardizeNumericalValue( $value, $field, array( 'fields' => $this->fields ) ); // We will remember the unit of the value, in case some other system pushed down a value (with an unit) // that is different from the field config unit. This way we can retain the unit of the value until // the user interacts with the control. ?>
  • range_field_attributes( $this->fields[ $field ] ) ?> value="" data-value_unit="">
  • $value ) { echo $attr . '="' . esc_attr( $value ) . '" '; } } protected function display_select_field( $field, $currentFontValue, $valueEntry, $label ) { // If the field entry is falsy, this means we don't want to use the field. if ( empty( $this->fields[ $field ] ) ) { return; } $valid_values = Customify_Fonts_Global::instance()->get_valid_subfield_values( $valueEntry, false ); $value = isset( $currentFontValue->$valueEntry ) && ( empty( $valid_values ) || in_array( $currentFontValue->$valueEntry, $valid_values ) ) ? $currentFontValue->$valueEntry : reset( $valid_values ); ?>
  • tag from the given params * * @param string|array $font_family * @param string|false $active_font_family Optional. The active font family to add the selected attribute to the appropriate opt. * False to not mark any opt as selected. */ public static function output_font_family_option( $font_family, $active_font_family = false ) { echo self::get_font_family_option_markup( $font_family, $active_font_family ); } /** * This method returns an '; return apply_filters( 'customify_filter_font_option_markup', $html, $font_family, $active_font_family, $font_type ); } /** ==== Helpers ==== */ protected function get_default_values() { $defaults = array(); if ( isset( $this->default ) && is_array( $this->default ) ) { // Handle special logic for when the $value array is not an associative array. if ( ! $this->isAssocArray( $this->default ) ) { // The first entry is the font-family. if ( isset( $this->default[0] ) ) { $defaults['font_family'] = $this->default[0]; } // The second entry is the variant. if ( isset( $this->default[1] ) ) { $defaults['font_variant'] = $this->default[1]; } } else { $defaults = $this->default; } } return Customify_Fonts_Global::standardizeFontValue( $defaults ); } protected function get_CSS_ID() { return str_replace( array( '[', ']' ), '_', $this->id ); } protected function isAssocArray( $array ) { return ( $array !== array_values( $array ) ); } /** ==== LEGACY ==== */ /** * Legacy: This method displays an