/** * Load Google Fonts stylesheets * * @return void * @since 1.0.0 */ public function load_options_font() { $theme_options_fonts = yit_get_option_by( 'type', 'typography' ); $google_fonts = yit_get_google_fonts(); $google_fonts = array_map( 'stripslashes', ( array ) $google_fonts->items ); foreach( $theme_options_fonts as $option ) { $option_value = yit_get_option( $option['id'] ); if ( ! array_key_exists( 'family', $option_value ) ) { continue; } if( $option_value['family'] != $option['std']['family'] ) { $family = $option_value['family']; } else { $family = $option['std']['family']; } if( in_array( $family, $google_fonts ) ) { //yit_enqueue_style( 600, 'font-' . sanitize_title( preg_replace( '/:(.*)?/', '', $option['std']['family'] ) ), yit_ssl_url( '//fonts.googleapis.com/css?family=' . $option['std']['family'] ) ); yit_add_google_font( $family ); } } }
<?php if (strpos($style['properties'], 'font-family') !== false) { ?> <!-- Family --> <div class="select_wrapper font-family"> <select name="<?php echo $name; ?> [family]" id="<?php echo $id; ?> -family"> <?php $web_fonts = yit_get_web_fonts(); $google_fonts = yit_get_google_fonts(); if (!empty($web_fonts)) { echo '<optgroup label="' . __('Web fonts', 'yit') . '">'; foreach ($web_fonts as $font_name => $rule) { ?> <option value='<?php echo esc_attr($rule); ?> ' <?php selected(stripslashes($value['family']), $rule); ?> ><?php echo $font_name; ?> </option> <?php
/** * Load and print the correspondent field type. * * @param @field * @return string */ public static function display($value, $dep) { $std = yit_get_option($value['id']); ob_start(); ?> <div id="<?php echo $value['id_container']; ?> " <?php if ($dep) { ?> data-field="<?php echo $dep['field']; ?> " data-dep="<?php echo $dep['dep']; ?> " data-value="<?php echo $dep['value']; ?> " <?php } ?> class="typography_container yit_options rm_typography rm_option rm_input rm_number rm_text"> <div class="option"> <label for="<?php echo $value['id']; ?> "><?php echo $value['name']; ?> <small><?php echo $value['desc']; ?> <?php printf(__('(Default: %s)', 'yit'), $value['std']['size'] . $value['std']['unit'] . ', ' . $value['std']['family'] . ', ' . ucfirst(str_replace('-', ' ', $value['std']['style'])) . ', ' . $value['std']['color']); ?> </small></label> <!-- Size --> <div class="spinner_container"> <input class="typography_size number" type="text" name="<?php yit_field_name($value['id']); ?> [size]" id="<?php echo $value['id']; ?> -size" value="<?php echo $std['size']; ?> " data-min="<?php if (isset($value['min'])) { echo $value['min']; } ?> " data-max="<?php if (isset($value['max'])) { echo $value['max']; } ?> " /> </div> <!-- Unit --> <div class="select_wrapper font-unit"> <select class="typography_unit" name="<?php yit_field_name($value['id']); ?> [unit]" id="<?php echo $value['id']; ?> -unit"> <option value="px" <?php selected($std['unit'], 'px'); ?> ><?php _e('px', 'yit'); ?> </option> <option value="em" <?php selected($std['unit'], 'em'); ?> ><?php _e('em', 'yit'); ?> </option> <option value="pt" <?php selected($std['unit'], 'pt'); ?> ><?php _e('pt', 'yit'); ?> </option> <option value="rem" <?php selected($std['unit'], 'rem'); ?> ><?php _e('rem', 'yit'); ?> </option> </select> </div> <!-- Family --> <div class="select_wrapper font-family"> <select class="typography_family" name="<?php yit_field_name($value['id']); ?> [family]" id="<?php echo $value['id']; ?> -family"> <?php $web_fonts = yit_get_web_fonts(); $google_fonts = yit_get_google_fonts(); if (!empty($web_fonts)) { echo '<optgroup label="' . __('Web fonts', 'yit') . '">'; foreach ($web_fonts as $name => $rule) { ?> <option value='<?php echo $rule; ?> ' <?php selected(stripslashes($std['family']), $rule); ?> ><?php echo $name; ?> </option> <?php } echo '</optgroup>'; } if (!empty($google_fonts)) { echo '<optgroup label="' . __('Google fonts', 'yit') . '">'; foreach ($google_fonts->items as $font) { // $font_human = trim( stripslashes( end( array_slice( explode( ',', $font ), 0, 1 ) ) ), "'" ); // $std_human = trim( stripslashes( end( array_slice( explode( ',', $std['family'] ), 0, 1 ) ) ), "'" ); //if( isset($font->family) ): //Only me and god know what happen on this line... ?> <option value="<?php echo $font; ?> " <?php selected($std['family'], $font); ?> ><?php echo $font; ?> </option> <?php //endif; } echo '</optgroup>'; } ?> </select> </div> <!-- Style --> <div class="select_wrapper font-style"> <select class="typography_style" name="<?php yit_field_name($value['id']); ?> [style]" id="<?php echo $value['id']; ?> -style"> <option value="regular" <?php selected($std['style'], 'regular'); ?> ><?php _e('Regular', 'yit'); ?> </option> <option value="bold" <?php selected($std['style'], 'bold'); ?> ><?php _e('Bold', 'yit'); ?> </option> <option value="extra-bold" <?php selected($std['style'], 'extra-bold'); ?> ><?php _e('Extra bold', 'yit'); ?> </option> <option value="italic" <?php selected($std['style'], 'italic'); ?> ><?php _e('Italic', 'yit'); ?> </option> <option value="bold-italic" <?php selected($std['style'], 'bold-italic'); ?> ><?php _e('Italic bold', 'yit'); ?> </option> </select> </div> <!-- Color --> <div id="<?php echo $value['id']; ?> _container" class="typography_color colorpicker_container" data-color="<?php echo $std['color']; ?> "><div style="background-color: <?php echo $std['color']; ?> "></div></div> <input type="text" name="<?php yit_field_name($value['id']); ?> [color]" id="<?php echo $value['id']; ?> -color" style="width:150px" value="<?php echo $std['color']; ?> " /> </div> <div class="clear"></div> <div class="font-preview"> <p>The quick brown fox jumps over the lazy dog</p> <!-- Refresh --> <div class="refresh_container"><button class="refresh"><img src="<?php echo YIT_CORE_ASSETS_URL; ?> /images/search.png" title="<?php _e('Click to preview', 'yit'); ?> " alt="" /><?php _e('Click to preview', 'yit'); ?> </button></div> </div> </div> <?php return ob_get_clean(); }
/** * Load Google Fonts stylesheets for the tab typography * * @return void * @since 1.0.0 */ public function load_options_font() { $google_fonts = yit_get_google_fonts(); $google_fonts = array_map('stripslashes', (array) $google_fonts->items); foreach ($this->_post_types as $post_type => $args) { foreach ($args['typography_options'] as $option) { $posts = $this->get_posts_types($post_type); foreach ($posts as $post) { $family = $this->get_setting($option['id'], $post->ID); if (isset($family['family']) && in_array($family['family'], $google_fonts)) { //yit_enqueue_style( 800, 'font-' . sanitize_title( preg_replace( '/:(.*)?/', '', $family['family'] ) ), yit_ssl_url( 'http://fonts.googleapis.com/css?family=' . $family['family'] ) ); yit_add_google_font($family['family']); } } } } }