function output_dynamic_style() { $store_type = PixCustomifyPlugin::get_plugin_option('values_store_mod', 'option'); if ($store_type === 'option') { $output = get_option('live_css_edit'); } elseif ($store_type === 'theme_mod') { $output = get_theme_mod('live_css_edit'); } if (empty($output)) { return; } ?> <style id="customify_css_editor_output"> <?php echo $output; ?> </style> <?php }
/** * Render the control's content. * * @since 3.4.0 */ public function render_content() { $current_value = $this->value(); if (empty($current_value) || is_array($current_value) && !isset($current_value['font_family'])) { $current_value = $this->get_default_values(); } // if this value was an array, well it was wrong if (is_array($current_value)) { if (isset($current_value['font-family'])) { $current_value['font_family'] = $current_value['font-family']; unset($current_value['font-family']); } $current_value = json_encode($current_value); } $values = json_decode($current_value); $font_family = ''; if (isset($values->font_family)) { $font_family = $values->font_family; } if (isset($values->load_all_weights)) { $this->load_all_weights = $values->font_load_all_weights; } ?> <label class="customify_typography"> <?php if (!empty($this->label)) { ?> <span class="customize-control-title"><?php echo esc_html($this->label); ?> </span> <?php } $this_id = str_replace('[', '_', $this->id); $this_id = str_replace(']', '_', $this_id); $select_data = ''; if ($this->load_all_weights) { $select_data .= ' data-load_all_weights="true"'; } /** * This input will hold the values of this typography field */ ?> <input class="customify_typography_values" id="<?php echo $this_id; ?> " type="hidden" <?php $this->link(); ?> value='<?php echo $current_value; ?> ' data-default='<?php echo $current_value; ?> '/> <select class="customify_typography_font_family"<?php echo $select_data; ?> > <?php if (!empty($this->typekit_fonts)) { echo '<optgroup label="' . __('Typekit', 'customify_txtd') . '">'; foreach ($this->typekit_fonts as $key => $font) { self::output_font_option($font['css_names'][0], $font_family, $font, 'typekit'); } echo "</optgroup>"; } if (!empty($this->recommended)) { echo '<optgroup label="' . __('Recommended', 'customify_txtd') . '">'; foreach ($this->recommended as $key => $font) { $font_type = 'std'; if (isset(self::$google_fonts[$key])) { $font = self::$google_fonts[$key]; $font_type = 'google'; } elseif (isset($this->typekit_fonts[$key])) { $font_type = 'typekit'; $font = $key; } else { $font = $key; } self::output_font_option($key, $font_family, $font, $font_type); } echo "</optgroup>"; } if (PixCustomifyPlugin::get_plugin_option('typography_standard_fonts')) { echo '<optgroup label="' . __('Standard fonts', 'customify_txtd') . '">'; foreach (self::$std_fonts as $key => $font) { self::output_font_option($key, $font_family, $font, 'std'); } echo "</optgroup>"; } if (PixCustomifyPlugin::get_plugin_option('typography_google_fonts')) { if (PixCustomifyPlugin::get_plugin_option('typography_group_google_fonts')) { $grouped_google_fonts = array(); foreach (self::$google_fonts as $key => $font) { if (isset($font['category'])) { $grouped_google_fonts[$font['category']][] = $font; } } foreach ($grouped_google_fonts as $group_name => $group) { echo '<optgroup label="' . __('Google fonts', 'customify_txtd') . ' ' . $group_name . '">'; foreach ($group as $key => $font) { self::output_font_option($key, $font_family, $font); } echo "</optgroup>"; } } else { echo '<optgroup label="' . __('Google fonts', 'customify_txtd') . '">'; foreach (self::$google_fonts as $key => $font) { self::output_font_option($key, $font_family, $font); } echo "</optgroup>"; } } ?> </select> </label> <ul class="options"> <?php $display = 'none'; if (!$this->load_all_weights && $this->font_weight) { $display = 'inline-block'; } ?> <li class="customify_weights_wrapper" style="display: <?php echo $display; ?> "> <select class="customify_typography_font_weight"> <?php $selected = array(); if (isset($values->selected_variants)) { $selected = $values->selected_variants; } if (isset($values->variants) && !empty($values->variants)) { foreach ($values->variants as $weight) { $attrs = ''; if (in_array($weight, (array) $selected)) { $attrs = ' selected="selected"'; } echo '<option value="' . $weight . '" ' . $attrs . '> ' . $weight . '</option>'; } } ?> </select> </li> <?php $display = 'none'; if ($this->subsets && !empty($values->subsets)) { $display = 'inline-block'; } ?> <li class="customify_subsets_wrapper" style="display: <?php echo $display; ?> "> <select multiple class="customify_typography_font_subsets"> <?php $selected = array(); if (isset($values->selected_subsets)) { $selected = $values->selected_subsets; } if (isset($values->subsets) && !empty($values->subsets)) { foreach ($values->subsets as $key => $subset) { $attrs = ''; if (in_array($subset, (array) $selected)) { $attrs .= ' selected="selected"'; } echo '<option value="' . $subset . '"' . $attrs . '> ' . $subset . '</option>'; } } ?> </select> </li> <?php ?> </ul> <?php if (!empty($this->description)) { ?> <span class="description customize-control-description"><?php echo $this->description; ?> </span> <?php } ?> <?php }