コード例 #1
0
    /**
     * Displays the controls to setup the font.
     *
     * @param object $values
     */
    function render_fonts($values)
    {
        // Font family
        $font_family = '';
        if (isset($values->family)) {
            $font_family = !empty($values->family->name) ? $values->family->name : '';
        }
        // Font styles and decoration
        $font_weight = !empty($values->bold) ? $values->bold : '';
        $font_italic = !empty($values->italic) ? $values->italic : '';
        $font_underline = !empty($values->underline) ? $values->underline : '';
        $font_linethrough = !empty($values->linethrough) ? $values->linethrough : '';
        $font_nostyle = !empty($values->nostyle) ? $values->nostyle : '';
        // Text transform
        $text_transform = !empty($values->texttransform) ? $values->texttransform : '';
        // Text align
        $font_align = !empty($values->align) ? $values->align : '';
        $font_noalign = !empty($values->noalign) ? $values->noalign : '';
        // Font size
        $font_size_num = isset($values->sizenum) ? $values->sizenum : '';
        $font_size_unit = isset($values->sizeunit) ? $values->sizeunit : 'px';
        // Line height
        $font_line_num = isset($values->linenum) ? $values->linenum : '';
        $font_line_unit = isset($values->lineunit) ? $values->lineunit : 'px';
        $units = array('px', '%', 'em');
        ?>

		<!-- FONT SIZE -->
		<div class="themify-customizer-brick">
			<input type="text" class="font_size_num" value="<?php 
        echo empty($font_size_num) ? '' : $font_size_num;
        ?>
" />
			<div class="custom-select">
				<select class="font_size_unit">
					<?php 
        foreach ($units as $unit) {
            ?>
						<option value="<?php 
            echo $unit;
            ?>
" <?php 
            selected($unit, $font_size_unit);
            ?>
><?php 
            echo $unit;
            ?>
</option>
					<?php 
        }
        ?>
				</select>
			</div>

			<!-- FONT FAMILY -->
			<div class="custom-select font-family-select">
				<select class="themify_font_family">
					<option value=""></option>
					<optgroup label="<?php 
        _e('Web Safe Fonts', 'themify');
        ?>
">
						<?php 
        $fonts = themify_base_get_web_safe_font_list();
        unset($fonts[0]);
        unset($fonts[1]);
        foreach ($fonts as $font) {
            $value = "'" . json_encode(array('name' => esc_attr($font['value']), 'fonttype' => 'websafe')) . "'";
            echo '<option value=' . $value . ' ' . selected($font_family, $font['value'], false) . '>' . $font['name'] . '</option>';
        }
        ?>
					</optgroup>
					<optgroup label="<?php 
        _e('Google Fonts', 'themify');
        ?>
">
						<?php 
        if (!isset($GLOBALS['themify_customizer_gfonts']) || '' == $GLOBALS['themify_customizer_gfonts']) {
            $fonts = themify_base_get_google_font_lists();
            foreach ($fonts as $font) {
                $value = "'" . json_encode(array('name' => isset($font['family']) ? esc_attr($font['family']) : '', 'subsets' => isset($font['subsets']) ? $font['subsets'] : '', 'fonttype' => 'google')) . "'";
                $GLOBALS['themify_customizer_gfonts'] .= '<option class="google_font" value=' . $value . ' ' . selected($font_family, $font['family'], false) . '>' . $font['family'] . '</option>';
            }
        }
        echo $GLOBALS['themify_customizer_gfonts'];
        ?>
					</optgroup>
				</select>
			</div>
		</div>

		<div class="themify-customizer-brick">
			<!-- LINE HEIGHT -->
			<input type="text" class="font_line_num" value="<?php 
        echo empty($font_line_num) ? '' : $font_size_num;
        ?>
" />
			<div class="custom-select">
				<select class="font_line_unit">
					<?php 
        foreach ($units as $unit) {
            ?>
						<option value="<?php 
            echo $unit;
            ?>
" <?php 
            selected($unit, $font_line_unit);
            ?>
><?php 
            echo $unit;
            ?>
</option>
					<?php 
        }
        ?>
				</select>
			</div>
			<label><?php 
        _e('Line Height', 'themify');
        ?>
</label>
		</div>

		<!-- TEXT STYLE & DECORATION -->
		<div class="themify_font_style themify-customizer-brick">
			<button type="button" class="button <?php 
        echo $this->style_is($font_italic, 'italic');
        ?>
" data-style="italic"><?php 
        _e('i', 'themify');
        ?>
</button>
			<button type="button" class="button <?php 
        echo $this->style_is($font_weight, 'bold');
        ?>
" data-style="bold"><?php 
        _e('B', 'themify');
        ?>
</button>
			<button type="button" class="button <?php 
        echo $this->style_is($font_underline, 'underline');
        ?>
" data-style="underline"><?php 
        _e('U', 'themify');
        ?>
</button>
			<button type="button" class="button <?php 
        echo $this->style_is($font_linethrough, 'linethrough');
        ?>
" data-style="linethrough"><?php 
        _e('S', 'themify');
        ?>
</button>
			<button type="button" class="button <?php 
        echo $this->style_is($font_nostyle, 'nostyle');
        ?>
" data-style="nostyle"><?php 
        _e('&times;', 'themify');
        ?>
</button>
		</div>

		<!-- TEXT TRANSFORM -->
		<div class="themify_text_transform themify-customizer-brick">
			<button type="button" class="button <?php 
        echo $this->style_is($text_transform, 'uppercase');
        ?>
" data-texttransform="uppercase"><?php 
        _e('AA', 'themify');
        ?>
</button>
			<button type="button" class="button <?php 
        echo $this->style_is($text_transform, 'lowercase');
        ?>
" data-texttransform="lowercase"><?php 
        _e('ab', 'themify');
        ?>
</button>
			<button type="button" class="button <?php 
        echo $this->style_is($text_transform, 'capitalize');
        ?>
" data-texttransform="capitalize"><?php 
        _e('Ab', 'themify');
        ?>
</button>
			<button type="button" class="button <?php 
        echo $this->style_is($text_transform, 'notexttransform');
        ?>
" data-texttransform="notexttransform"><?php 
        _e('&times;', 'themify');
        ?>
</button>
		</div>

		<!-- TEXT ALIGN -->
		<div class="themify_font_align themify-customizer-brick">
			<button type="button" class="button <?php 
        echo $this->style_is($font_align, 'left');
        ?>
" data-align="left"><span class="ti-align-left"></span></button>
			<button type="button" class="button <?php 
        echo $this->style_is($font_align, 'center');
        ?>
" data-align="center"><span class="ti-align-center"></span></button>
			<button type="button" class="button <?php 
        echo $this->style_is($font_align, 'right');
        ?>
" data-align="right"><span class="ti-align-right"></span></button>
			<button type="button" class="button <?php 
        echo $this->style_is($font_align, 'justify');
        ?>
" data-align="justify"><span class="ti-align-justify"></span></button>
			<button type="button" class="button <?php 
        echo $this->style_is($font_noalign, 'noalign');
        ?>
" data-align="noalign"><?php 
        _e('&times;', 'themify');
        ?>
</button>
		</div>
	<?php 
    }
コード例 #2
0
 /**
  * Returns a list of Google Web Fonts
  * @return array
  * @since 1.5.6
  */
 function themify_base_get_google_web_fonts_list()
 {
     $google_fonts_list = array(array('value' => '', 'name' => ''), array('value' => '', 'name' => '--- ' . __('Google Fonts', 'themify') . ' ---'));
     foreach (wp_list_pluck(themify_base_get_google_font_lists(), 'family') as $font) {
         $google_fonts_list[] = array('value' => $font, 'name' => $font);
     }
     return apply_filters('themify_base_get_google_web_fonts_list', $google_fonts_list);
 }