/** * Displays the option in admin panels and meta boxes * * @return void * @since 1.4 */ public function display() { $this->echoOptionHeader( true ); // Get the current value and merge with defaults $value = $this->getValue(); if ( is_serialized( $value ) ) { $value = unserialize( $value ); } if ( ! is_array( $value ) ) { $value = array(); } $value = array_merge( self::$defaultStyling, $value ); /* * Create all the fields */ $visibilityAttrs = ''; if ( ! $this->settings['show_font_family'] ) { $visibilityAttrs = "data-visible='false' style='display: none'"; } ?> <div> <label <?php echo $visibilityAttrs ?>> Font Family <select class='tf-font-sel-family'> <optgroup label="Web Safe Fonts" class='safe'> <?php $options = array( 'Arial, Helvetica, sans-serif' => 'Arial', '"Arial Black", Gadget, sans-serif' => 'Arial Black', '"Comic Sans MS", cursive, sans-serif' => 'Comic Sans', '"Courier New", Courier, monospace' => 'Courier New', 'Georgia, serif' => 'Geogia', 'Impact, Charcoal, sans-serif' => 'Impact', '"Lucida Console", Monaco, monospace' => 'Lucida Console', '"Lucida Sans Unicode", "Lucida Grande", sans-serif' => 'Lucida Sans', '"Palatino Linotype", "Book Antiqua", Palatino, serif' => 'Palatino', 'Tahoma, Geneva, sans-serif' => 'Tahoma', '"Times New Roman", Times, serif' => 'Times New Roman', '"Trebuchet MS", Helvetica, sans-serif' => 'Trebuchet', 'Verdana, Geneva, sans-serif' => 'Verdana', ); foreach ( $options as $family => $label ) { printf( "<option value='%s'%s>%s</option>", $family, selected( $value['font-family'], $family, false ), $label ); } ?> </optgroup> <optgroup label="Google WebFonts" class='google'> <?php $allFonts = titan_get_googlefonts(); foreach ( $allFonts as $key => $fontStuff ) { printf( "<option value='%s'%s>%s</option>", esc_attr( $fontStuff['name'] ), selected( $value['font-family'], $fontStuff['name'], false ), $fontStuff['name'] ); } ?> </optgroup> </select> </label> <?php $visibilityAttrs = ''; if ( ! $this->settings['show_color'] ) { $visibilityAttrs = "data-visible='false' style='display: none'"; } ?> <label <?php echo $visibilityAttrs ?>> Color <input class='tf-font-sel-color' type="text" value="<?php echo esc_attr( $value['color'] ) ?>" data-default-color="<?php echo esc_attr( $value['color'] ) ?>"/> </label> <?php $visibilityAttrs = ''; if ( ! $this->settings['show_font_size'] ) { $visibilityAttrs = "data-visible='false' style='display: none'"; } ?> <label <?php echo $visibilityAttrs ?>> Font Size <select class='tf-font-sel-size'> <?php for ( $i = 1; $i <= 150; $i++ ) { printf( "<option value='%s'%s>%s</option>", esc_attr( $i . 'px' ), selected( $value['font-size'], $i . 'px', false ), $i . 'px' ); } ?> </select> </label> <?php $visibilityAttrs = ''; if ( ! $this->settings['show_font_weight'] ) { $visibilityAttrs = "data-visible='false' style='display: none'"; } ?> <label <?php echo $visibilityAttrs ?>> Font Weight <select class='tf-font-sel-weight'> <?php $options = array( 'normal', 'bold', 'bolder', 'lighter', '100', '200', '300', '400', '500', '600', '700', '800', '900' ); foreach ( $options as $option ) { printf( "<option value='%s'%s>%s</option>", esc_attr( $option ), selected( $value['font-weight'], $option, false ), $option ); } ?> </select> </label> <?php $visibilityAttrs = ''; if ( ! $this->settings['show_font_style'] ) { $visibilityAttrs = "data-visible='false' style='display: none'"; } ?> <label <?php echo $visibilityAttrs ?>> Font Style <select class='tf-font-sel-style'> <?php $options = array( 'normal', 'italic' ); foreach ( $options as $option ) { printf( "<option value='%s'%s>%s</option>", esc_attr( $option ), selected( $value['font-style'], $option, false ), $option ); } ?> </select> </label> <?php $visibilityAttrs = ''; if ( ! $this->settings['show_line_height'] ) { $visibilityAttrs = "data-visible='false' style='display: none'"; } ?> <label <?php echo $visibilityAttrs ?>> Line Height <select class='tf-font-sel-height'> <?php for ( $i = .5; $i <= 3; $i += 0.1 ) { printf( "<option value='%s'%s>%s</option>", esc_attr( $i . 'em' ), selected( $value['line-height'], $i . 'em', false ), $i . 'em' ); } ?> </select> </label> <?php $visibilityAttrs = ''; if ( ! $this->settings['show_letter_spacing'] ) { $visibilityAttrs = "data-visible='false' style='display: none'"; } ?> <label <?php echo $visibilityAttrs ?>> Letter Spacing <select class='tf-font-sel-spacing'> <option value='normal'>normal</option> <?php for ( $i = -20; $i <= 20; $i++ ) { printf( "<option value='%s'%s>%s</option>", esc_attr( $i . 'px' ), selected( $value['letter-spacing'], $i . 'px', false ), $i . 'px' ); } ?> </select> </label> <?php $visibilityAttrs = ''; if ( ! $this->settings['show_text_transform'] ) { $visibilityAttrs = "data-visible='false' style='display: none'"; } ?> <label <?php echo $visibilityAttrs ?>> Text Transform <select class='tf-font-sel-transform'> <?php $options = array( 'none', 'capitalize', 'uppercase', 'lowercase' ); foreach ( $options as $option ) { printf( "<option value='%s'%s>%s</option>", esc_attr( $option ), selected( $value['text-transform'], $option, false ), $option ); } ?> </select> </label> <?php $visibilityAttrs = ''; if ( ! $this->settings['show_font_variant'] ) { $visibilityAttrs = "data-visible='false' style='display: none'"; } ?> <label <?php echo $visibilityAttrs ?>> Font Variant <select class='tf-font-sel-variant'> <?php $options = array( 'normal', 'small-caps' ); foreach ( $options as $option ) { printf( "<option value='%s'%s>%s</option>", esc_attr( $option ), selected( $value['font-variant'], $option, false ), $option ); } ?> </select> </label> <?php $visibilityAttrs = ''; if ( ! $this->settings['show_text_shadow'] ) { $visibilityAttrs = "data-visible='false' style='display: none'"; } ?> <label <?php echo $visibilityAttrs ?>> Shadow Location <select class='tf-font-sel-location'> <?php $options = array( 'none', 'top', 'bottom', 'left', 'right', 'top-left', 'top-right', 'bottom-left', 'bottom-right' ); foreach ( $options as $option ) { printf( "<option value='%s'%s>%s</option>", esc_attr( $option ), selected( $value['text-shadow-location'], $option, false ), $option ); } ?> </select> </label> <label style='display: none'> Shadow Distance <select class='tf-font-sel-distance'> <?php for ( $i = 0; $i <= 10; $i++ ) { printf( "<option value='%s'%s>%s</option>", esc_attr( $i . 'px' ), selected( $value['text-shadow-distance'], $i . 'px', false ), $i . 'px' ); } ?> </select> </label> <label style='display: none'> Shadow Blur <select class='tf-font-sel-blur'> <?php $options = array( '0px', '1px', '2px', '3px', '4px', '5px', '10px', '20px' ); foreach ( $options as $option ) { printf( "<option value='%s'%s>%s</option>", esc_attr( $option ), selected( $value['text-shadow-blur'], $option, false ), $option ); } ?> </select> </label> <label style='display: none'> Shadow Color <input class="tf-font-sel-shadow-color" type="text" value="<?php echo esc_attr( $value['text-shadow-color'] ) ?>" data-default-color="<?php echo esc_attr( $value['text-shadow-color'] ) ?>"/> </label> <label style='display: none'> Shadow Opacity <select class='tf-font-sel-opacity'> <?php $options = array( '1', '0.9', '0.8', '0.7', '0.6', '0.5', '0.4', '0.3', '0.2', '0.1', '0' ); foreach ( $options as $option ) { printf( "<option value='%s'%s>%s</option>", esc_attr( $option ), selected( $value['text-shadow-opacity'], $option, false ), $option ); } ?> </select> </label> </div> <?php $visibilityAttrs = ''; if ( ! $this->settings['show_preview'] ) { $visibilityAttrs = "data-visible='false' style='display: none'"; } ?> <div <?php echo $visibilityAttrs ?>> <iframe data-preview-text='<?php echo esc_attr( $this->settings['preview_text'] ) ?>'></iframe> <i class='fa fa-adjust btn-dark'></i> <input type='hidden' class='tf-font-sel-dark' value='<?php echo esc_attr( $value['dark'] ? 'dark' : '' ) ?>'/> </div> <?php if ( ! is_serialized( $value ) ) { $value = serialize( $value ); } printf("<input type='hidden' class='tf-for-saving' name='%s' id='%s' value='%s' />", $this->getID(), $this->getID(), esc_attr( $value ) ); $this->echoOptionFooter( false ); }
/** * Displays the option in admin panels and meta boxes * * @return void * @since 1.4 */ public function display() { $this->echoOptionHeader(true); // Get the current value and merge with defaults $value = $this->getValue(); if (is_serialized($value)) { $value = unserialize($value); } if (!is_array($value)) { $value = array(); } $value = array_merge(self::$defaultStyling, $value); /* * Create all the fields */ $visibilityAttrs = ''; if (!$this->settings['show_font_family']) { $visibilityAttrs = "data-visible='false' style='display: none'"; } ?> <div> <label <?php echo $visibilityAttrs; ?> > Font Family <select class='tf-font-sel-family'> <?php if ($this->settings['show_websafe_fonts']) { ?> <optgroup label="Web Safe Fonts" class='safe'> <?php foreach (self::$webSafeFonts as $family => $label) { printf("<option value='%s'%s>%s</option>", $family, selected($value['font-family'], $family, false), $label); } ?> </optgroup> <?php } if ($this->settings['show_google_fonts']) { ?> <optgroup label="Google WebFonts" class='google'> <?php $allFonts = titan_get_googlefonts(); foreach ($allFonts as $key => $fontStuff) { // Show only the include_fonts (font names) if provided, uses regex if (!empty($this->settings['include_fonts'])) { if (is_array($this->settings['include_fonts'])) { $fontNameMatch = false; foreach ($this->settings['include_fonts'] as $fontNamePattern) { if (!is_string($fontNamePattern)) { continue; } $fontNamePattern = '/' . trim($fontNamePattern, '/') . '/'; if (preg_match($fontNamePattern . 'i', $fontStuff['name'])) { $fontNameMatch = true; break; } } if (!$fontNameMatch) { continue; } } else { if (is_string($this->settings['include_fonts'])) { $fontNamePattern = '/' . trim($this->settings['include_fonts'], '/') . '/'; if (!preg_match($fontNamePattern . 'i', $fontStuff['name'])) { continue; } } } } printf("<option value='%s'%s>%s</option>", esc_attr($fontStuff['name']), selected($value['font-family'], $fontStuff['name'], false), $fontStuff['name']); } ?> </optgroup> <?php } ?> </select> </label> <?php $visibilityAttrs = ''; if (!$this->settings['show_color']) { $visibilityAttrs = "data-visible='false' style='display: none'"; } ?> <label <?php echo $visibilityAttrs; ?> > Color <input class='tf-font-sel-color' type="text" value="<?php echo esc_attr($value['color']); ?> " data-default-color="<?php echo esc_attr($value['color']); ?> "/> </label> <?php $visibilityAttrs = ''; if (!$this->settings['show_font_size']) { $visibilityAttrs = "data-visible='false' style='display: none'"; } ?> <label <?php echo $visibilityAttrs; ?> > Font Size <select class='tf-font-sel-size'> <?php for ($i = 1; $i <= 150; $i++) { printf("<option value='%s'%s>%s</option>", esc_attr($i . 'px'), selected($value['font-size'], $i . 'px', false), $i . 'px'); } ?> </select> </label> <?php $visibilityAttrs = ''; if (!$this->settings['show_font_weight']) { $visibilityAttrs = "data-visible='false' style='display: none'"; } ?> <label <?php echo $visibilityAttrs; ?> > Font Weight <select class='tf-font-sel-weight'> <?php $options = array('normal', 'bold', 'bolder', 'lighter', '100', '200', '300', '400', '500', '600', '700', '800', '900'); foreach ($options as $option) { printf("<option value='%s'%s>%s</option>", esc_attr($option), selected($value['font-weight'], $option, false), $option); } ?> </select> </label> <?php $visibilityAttrs = ''; if (!$this->settings['show_font_style']) { $visibilityAttrs = "data-visible='false' style='display: none'"; } ?> <label <?php echo $visibilityAttrs; ?> > Font Style <select class='tf-font-sel-style'> <?php $options = array('normal', 'italic'); foreach ($options as $option) { printf("<option value='%s'%s>%s</option>", esc_attr($option), selected($value['font-style'], $option, false), $option); } ?> </select> </label> <?php $visibilityAttrs = ''; if (!$this->settings['show_line_height']) { $visibilityAttrs = "data-visible='false' style='display: none'"; } ?> <label <?php echo $visibilityAttrs; ?> > Line Height <select class='tf-font-sel-height'> <?php for ($i = 0.5; $i <= 3; $i += 0.1) { printf("<option value='%s'%s>%s</option>", esc_attr($i . 'em'), selected($value['line-height'], $i . 'em', false), $i . 'em'); } ?> </select> </label> <?php $visibilityAttrs = ''; if (!$this->settings['show_letter_spacing']) { $visibilityAttrs = "data-visible='false' style='display: none'"; } ?> <label <?php echo $visibilityAttrs; ?> > Letter Spacing <select class='tf-font-sel-spacing'> <option value='normal'>normal</option> <?php for ($i = -20; $i <= 20; $i++) { printf("<option value='%s'%s>%s</option>", esc_attr($i . 'px'), selected($value['letter-spacing'], $i . 'px', false), $i . 'px'); } ?> </select> </label> <?php $visibilityAttrs = ''; if (!$this->settings['show_text_transform']) { $visibilityAttrs = "data-visible='false' style='display: none'"; } ?> <label <?php echo $visibilityAttrs; ?> > Text Transform <select class='tf-font-sel-transform'> <?php $options = array('none', 'capitalize', 'uppercase', 'lowercase'); foreach ($options as $option) { printf("<option value='%s'%s>%s</option>", esc_attr($option), selected($value['text-transform'], $option, false), $option); } ?> </select> </label> <?php $visibilityAttrs = ''; if (!$this->settings['show_font_variant']) { $visibilityAttrs = "data-visible='false' style='display: none'"; } ?> <label <?php echo $visibilityAttrs; ?> > Font Variant <select class='tf-font-sel-variant'> <?php $options = array('normal', 'small-caps'); foreach ($options as $option) { printf("<option value='%s'%s>%s</option>", esc_attr($option), selected($value['font-variant'], $option, false), $option); } ?> </select> </label> <?php $visibilityAttrs = ''; if (!$this->settings['show_text_shadow']) { $visibilityAttrs = "data-visible='false' style='display: none'"; } ?> <label <?php echo $visibilityAttrs; ?> > Shadow Location <select class='tf-font-sel-location'> <?php $options = array('none', 'top', 'bottom', 'left', 'right', 'top-left', 'top-right', 'bottom-left', 'bottom-right'); foreach ($options as $option) { printf("<option value='%s'%s>%s</option>", esc_attr($option), selected($value['text-shadow-location'], $option, false), $option); } ?> </select> </label> <label style='display: none'> Shadow Distance <select class='tf-font-sel-distance'> <?php for ($i = 0; $i <= 10; $i++) { printf("<option value='%s'%s>%s</option>", esc_attr($i . 'px'), selected($value['text-shadow-distance'], $i . 'px', false), $i . 'px'); } ?> </select> </label> <label style='display: none'> Shadow Blur <select class='tf-font-sel-blur'> <?php $options = array('0px', '1px', '2px', '3px', '4px', '5px', '10px', '20px'); foreach ($options as $option) { printf("<option value='%s'%s>%s</option>", esc_attr($option), selected($value['text-shadow-blur'], $option, false), $option); } ?> </select> </label> <label style='display: none'> Shadow Color <input class="tf-font-sel-shadow-color" type="text" value="<?php echo esc_attr($value['text-shadow-color']); ?> " data-default-color="<?php echo esc_attr($value['text-shadow-color']); ?> "/> </label> <label style='display: none'> Shadow Opacity <select class='tf-font-sel-opacity'> <?php $options = array('1', '0.9', '0.8', '0.7', '0.6', '0.5', '0.4', '0.3', '0.2', '0.1', '0'); foreach ($options as $option) { printf("<option value='%s'%s>%s</option>", esc_attr($option), selected($value['text-shadow-opacity'], $option, false), $option); } ?> </select> </label> </div> <?php $visibilityAttrs = ''; if (!$this->settings['show_preview']) { $visibilityAttrs = "data-visible='false' style='display: none'"; } ?> <div <?php echo $visibilityAttrs; ?> > <iframe data-preview-text='<?php echo esc_attr($this->settings['preview_text']); ?> '></iframe> <i class='dashicons dashicons-admin-appearance btn-dark'></i> <input type='hidden' class='tf-font-sel-dark' value='<?php echo esc_attr($value['dark'] ? 'dark' : ''); ?> '/> </div> <?php if (!is_serialized($value)) { $value = serialize($value); } printf("<input type='hidden' class='tf-for-saving' name='%s' id='%s' value='%s' />", $this->getID(), $this->getID(), esc_attr($value)); $this->echoOptionFooter(false); }
public function display() { $this->echoOptionHeader(true); // set a default value $value = $this->getValue(); if (is_serialized($value)) { $value = unserialize($value); } if ($value == array() || empty($value['name']) || empty($value['variants']) || empty($value['subsets'])) { $value = array('name' => 'Open Sans', 'variants' => array('400'), 'subsets' => array('latin')); } if (self::$firstLoad) { self::$firstLoad = false; self::createScript(); } $allFonts = titan_get_googlefonts(); ?> <select class='tf-select-googlefont'><?php foreach ($allFonts as $key => $fontStuff) { printf("<option value='%s' data-subset='%s' data-variants='%s'>%s</option>", esc_attr($key), esc_attr(json_encode($fontStuff['subsets'])), esc_attr(json_encode($fontStuff['variants'])), $fontStuff['name']); } ?> </select><?php // preview printf("<iframe src='%s'></iframe>", TitanFramework::getURL('iframe-googlefont-preview.php?f=' . $value['name'], __FILE__)); // select variants echo "<p class='description tf-variants'>Choose the styles to include:</p>"; echo "<fieldset>"; $allVariants = array('100', '100italic', '200', '200italic', '300', '300italic', '400', 'italic', '500', '500italic', '600', '600italic', '700', '700italic', '800', '800italic', '900', '900italic'); foreach ($allVariants as $key => $variant) { printf("<label style='display: none'><input type='checkbox' class='variant' data-variant='%s'/> %s</label>", esc_attr($variant), self::getVariantName($variant)); } echo "</fieldset>"; // select charsets echo "<p class='description tf-subsets'>Choose the subsets to include:</p>"; echo "<fieldset>"; $allSubsets = array("latin", "latin-ext", "greek", "vietnamese", "cyrillic", "cyrillic-ext", "khmer", "greek-ext"); foreach ($allSubsets as $key => $subset) { printf("<label style='display: none'><input type='checkbox' class='subset' data-subset='%s'/> %s</label>", esc_attr($subset), $subset); } echo "</fieldset>"; if (!is_serialized($value)) { $value = serialize($value); } printf("<input type='hidden' value='%s' name='%s' class='large-text'/>", esc_attr($value), esc_attr($this->getID())); $this->echoOptionFooter(false); }