/** * Typography Option * * @access public * @since 1.1.8 * * @param array $value * @param array $settings * @param int $int * * @return string */ function option_tree_typography_headlines($value, $settings, $int) { ?> <div class="option option-font" id="<?php echo $value->item_id; ?> _div"> <div class="lambda-opttitle"> <div class="lambda-opttitle-pad"> <?php echo htmlspecialchars_decode($value->item_title); ?> <span class="infoButton right"> <img class="infoImage" src="<?php echo FRAMEWORK_WEB_ROOT; ?> /assets/images/info.png" width="40px" height="20px" alt="Info" style="left: 0px;"> </span> </div> </div> <div class="section clearfix"> <div class="element clearfix"> <div class="select_wrapper typography-family"> <p> <label><?php _e('Font Family', 'delaware-theme'); ?> </label> <select name="<?php echo $value->item_id; ?> [font-family]" class="select"> <?php echo '<option value="">font-family</option>'; foreach (recognized_font_families() as $key => $family) { echo '<option value="' . esc_attr($key) . '" ' . selected($settings[$value->item_id]['font-family'], $key, false) . '>' . esc_html($family) . '</option>'; } ?> </select> </p> </div> <div class="select_wrapper typography-style"> <p> <label><?php _e('Font Style', 'delaware-theme'); ?> </label> <select name="<?php echo $value->item_id; ?> [font-style]" class="select"> <?php echo '<option value="">font-style</option>'; foreach (recognized_font_styles() as $key => $style) { echo '<option value="' . esc_attr($key) . '" ' . selected($settings[$value->item_id]['font-style'], $key, false) . '>' . esc_html($style) . '</option>'; } ?> </select> </p> </div> <div class="select_wrapper typography-weight"> <p> <label><?php _e('Font Weight', 'delaware-theme'); ?> </label> <select name="<?php echo $value->item_id; ?> [font-weight]" class="select"> <?php echo '<option value="">font-weight</option>'; foreach (recognized_font_weights() as $key => $weight) { echo '<option value="' . esc_attr($key) . '" ' . selected($settings[$value->item_id]['font-weight'], $key, false) . '>' . esc_html($weight) . '</option>'; } ?> </select> </p> </div> </div> <?php if ($value->item_desc) { ?> <div class="desc alert-neutral"><?php echo htmlspecialchars_decode($value->item_desc); ?> </div> <div class="clear"></div> <?php } ?> </div> </div> <?php }
/** * Typography Menu Option * * @access public * * @param array $value * @param array $settings * @param int $int * * @return string */ function option_tree_typography_menu($value, $settings, $int) { ?> <div class="option option-font"> <div class="lambda-opttitle"> <div class="lambda-opttitle-pad"> <?php echo htmlspecialchars_decode($value->item_title); ?> <span class="infoButton right"> <img class="infoImage" src="<?php echo FRAMEWORK_WEB_ROOT; ?> /assets/images/info.png" width="40px" height="20px" alt="Info" style="left: 0px;"> </span> </div> </div> <div class="section clearfix"> <div class="element clearfix"> <script type="text/javascript"> jQuery(document).ready(function($) { $('#<?php echo $value->item_id; ?> -picker').ColorPicker({ onSubmit: function(hsb, hex, rgb) { $('#<?php echo $value->item_id; ?> ').val('#'+hex); }, onBeforeShow: function () { $(this).ColorPickerSetColor(this.value); return false; }, onChange: function (hsb, hex, rgb) { $('#cp_<?php echo $value->item_id; ?> div').css({'backgroundColor':'#'+hex}); $('#cp_<?php echo $value->item_id; ?> ').next('input').attr('value', '#'+hex); //theme scheme color changer if("<?php echo $value->item_id; ?> " == "themecolor") { $('#color_scheme_1').val('#'+hex); $('.color_scheme_1').css('background-color', '#'+hex); } } }).bind('keyup', function(){ $(this).ColorPickerSetColor(this.value); }); }); </script> <div class="select_wrapper"> <label><?php _e('Font Color', 'delaware-theme'); ?> </label> <div id="cp_<?php echo $value->item_id; ?> " class="cp_box"> <div style="background-color:<?php echo isset($settings[$value->item_id]['font-color']) ? $settings[$value->item_id]['font-color'] : '#000'; ?> ;"> </div> </div> <input style="width:175px;" type="text" name="<?php echo $value->item_id; ?> [font-color]" id="<?php echo $value->item_id; ?> -picker" value="<?php echo isset($settings[$value->item_id]['font-color']) ? stripslashes($settings[$value->item_id]['font-color']) : ''; ?> " class="cp_input" /> </div> <div class="clear"></div> <div class="select_wrapper typography-family"> <p> <label><?php _e('Font Family', 'delaware-theme'); ?> </label> <select name="<?php echo $value->item_id; ?> [font-family]" class="select"> <?php echo '<option value="">font-family</option>'; foreach (recognized_font_families() as $key => $family) { echo '<option value="' . esc_attr($key) . '" ' . selected($settings[$value->item_id]['font-family'], $key, false) . '>' . esc_html($family) . '</option>'; } ?> </select> </p> </div> <div class="select_wrapper typography-style" style="width:165px;"> <p> <label><?php _e('Font Style', 'delaware-theme'); ?> </label> <select name="<?php echo $value->item_id; ?> [font-style]" class="select"> <?php echo '<option value="">font-style</option>'; foreach (recognized_font_styles() as $key => $style) { echo '<option value="' . esc_attr($key) . '" ' . selected($settings[$value->item_id]['font-style'], $key, false) . '>' . esc_html($style) . '</option>'; } ?> </select> </p> </div> <div class="select_wrapper typography-transform" style="width:165px;"> <p> <label><?php _e('Font Transform', 'delaware-theme'); ?> </label> <select name="<?php echo $value->item_id; ?> [font-transform]" class="select"> <?php echo '<option value="">font-transform</option>'; foreach (recognized_font_transforms() as $key => $variant) { echo '<option value="' . esc_attr($key) . '" ' . selected($settings[$value->item_id]['font-transform'], $key, false) . '>' . esc_html($variant) . '</option>'; } ?> </select> </p> </div> <div class="select_wrapper typography-weight" style="width:165px;"> <p> <label><?php _e('Font Weight', 'delaware-theme'); ?> </label> <select name="<?php echo $value->item_id; ?> [font-weight]" class="select"> <?php echo '<option value="">font-weight</option>'; foreach (recognized_font_weights() as $key => $weight) { echo '<option value="' . esc_attr($key) . '" ' . selected($settings[$value->item_id]['font-weight'], $key, false) . '>' . esc_html($weight) . '</option>'; } ?> </select> </p> </div> <div class="select_wrapper typography-size" style="width:165px;"> <p> <label><?php _e('Font Size', 'delaware-theme'); ?> </label> <select name="<?php echo $value->item_id; ?> [font-size]" class="select"> <?php echo '<option value="">font-size</option>'; for ($i = 8; $i <= 72; $i++) { $size = $i . 'px'; echo '<option value="' . esc_attr($size) . '" ' . selected($settings[$value->item_id]['font-size'], $size, false) . '>' . esc_html($size) . '</option>'; } ?> </select> </p> </div> </div> <?php if ($value->item_desc) { ?> <div class="desc alert-neutral"><?php echo htmlspecialchars_decode($value->item_desc); ?> </div> <div class="clear"></div> <?php } ?> </div> </div> <?php }
/** * Inserts CSS with Markers * * Inserts CSS into a dynamic.css file, placing it between * BEGIN and END markers. Replaces existing marked info. Retains surrounding * data. * * @since 1.1.8 * * @return bool True on write success, false on failure. */ function option_tree_insert_css_with_markers($option = '') { /* No option defined */ if (!$option) { return; } /* path to the dynamic.css file */ $filepath = get_stylesheet_directory() . '/css/dynamic.css'; /* allow filter on path */ $filepath = apply_filters('css_option_file_path', $filepath, $option); /* Insert CSS into file */ if (!file_exists($filepath) || is_writeable($filepath)) { /* Get options & set CSS value */ $options = get_option('option_tree'); $insertion = option_tree_normalize_css(stripslashes($options[$option])); $regex = "/{{([a-zA-Z0-9\\_\\-\\#\\|\\=]+)}}/"; $marker = $option; /* Match custom CSS */ preg_match_all($regex, $insertion, $matches); /* Loop through CSS */ foreach ($matches[0] as $option) { $the_option = str_replace(array('{{', '}}'), '', $option); $option_array = explode("|", $the_option); /* get array by key from key|value explode */ if (is_array($option_array)) { $value = $options[$option_array[0]]; /* get the whole array from $option param */ } else { $value = $options[$option]; } if (is_array($value)) { /* key|value explode didn't return a second value */ if (!isset($option_array[1])) { /* Measurement */ if (isset($value[0]) && isset($value[1])) { $value = $value[0] . $value[1]; /* typography */ } else { if (isset($value['font-color']) || isset($value['font-style']) || isset($value['font-variant']) || isset($value['font-weight']) || isset($value['font-size']) || isset($value['font-family'])) { $font = array(); if (!empty($value['font-color'])) { $font[] = "font-color: " . $value['font-color'] . ";"; } foreach (recognized_font_families() as $key => $v) { if (!empty($value['font-family']) && $key == $value['font-family']) { $font[] = "font-family: " . $v . ";"; } } if (!empty($value['font-size'])) { $font[] = "font-size: " . $value['font-size'] . ";"; } if (!empty($value['font-style'])) { $font[] = "font-style: " . $value['font-style'] . ";"; } if (!empty($value['font-variant'])) { $font[] = "font-variant: " . $value['font-variant'] . ";"; } if (!empty($value['font-weight'])) { $font[] = "font-weight: " . $value['font-weight'] . ";"; } if (!empty($font)) { $value = implode("\n", $font); } /* background */ } else { if (isset($value['background-color']) || isset($value['background-image'])) { $bg = array(); if (!empty($value['background-color'])) { $bg[] = $value['background-color']; } if (!empty($value['background-image'])) { $bg[] = 'url("' . $value['background-image'] . '")'; } if (!empty($value['background-repeat'])) { $bg[] = $value['background-repeat']; } if (!empty($value['background-attachment'])) { $bg[] = $value['background-attachment']; } if (!empty($value['background-position'])) { $bg[] = $value['background-position']; } if (!empty($bg)) { $value = 'background: ' . implode(" ", $bg) . ';'; } } } } /* key|value explode return a second value */ } else { $value = $value[$option_array[1]]; } } $insertion = stripslashes(str_replace($option, $value, $insertion)); } /* file doesn't exist */ if (!file_exists($filepath)) { $markerdata = ''; /* file exist, create array from the lines of code */ } else { $markerdata = explode("\n", implode('', file($filepath))); } /* can't write to the file return false */ if (!($f = @fopen($filepath, 'w'))) { return false; } $foundit = false; /* has array of lines */ if ($markerdata) { $state = true; /* foreach line of code */ foreach ($markerdata as $n => $markerline) { /* found begining of marker, set state to false */ if (strpos($markerline, '/* BEGIN ' . $marker . ' */') !== false) { $state = false; } /* state is true, rebuild css */ if ($state) { if ($n + 1 < count($markerdata)) { fwrite($f, "{$markerline}\n"); } else { fwrite($f, "{$markerline}"); } } /* found end marker write code */ if (strpos($markerline, '/* END ' . $marker . ' */') !== false) { fwrite($f, "/* BEGIN {$marker} */\n"); fwrite($f, "{$insertion}\n"); fwrite($f, "/* END {$marker} */\n"); $state = true; $foundit = true; } } } /* nothing inserted, write code. DO IT, DO IT! */ if (!$foundit) { fwrite($f, "\n\n/* BEGIN {$marker} */\n"); fwrite($f, "{$insertion}\n"); fwrite($f, "/* END {$marker} */\n"); } /* close file */ fclose($f); return true; } else { return false; } }
/** * Typography Option * * @access public * @since 1.1.8 * * @param array $value * @param array $settings * @param int $int * * @return string */ function option_tree_typography($value, $settings, $int) { ?> <div class="option option-font"> <h3><?php echo htmlspecialchars_decode($value->item_title); ?> </h3> <div class="section"> <div class="element"> <script type="text/javascript"> jQuery(document).ready(function($) { $('#<?php echo $value->item_id; ?> -picker').ColorPicker({ onSubmit: function(hsb, hex, rgb) { $('#<?php echo $value->item_id; ?> -picker').val('#'+hex); }, onBeforeShow: function () { $(this).ColorPickerSetColor(this.value); return false; }, onChange: function (hsb, hex, rgb) { $('#cp_<?php echo $value->item_id; ?> div').css({'backgroundColor':'#'+hex, 'backgroundImage': 'none', 'borderColor':'#'+hex}); $('#cp_<?php echo $value->item_id; ?> ').prev('input').attr('value', '#'+hex); } }) .bind('keyup', function(){ $(this).ColorPickerSetColor(this.value); }); }); </script> <input type="text" name="<?php echo $value->item_id; ?> [font-color]" id="<?php echo $value->item_id; ?> -picker" value="<?php echo isset($settings[$value->item_id]['font-color']) ? stripslashes($settings[$value->item_id]['font-color']) : ''; ?> " class="cp_input" /> <div id="cp_<?php echo $value->item_id; ?> " class="cp_box"> <div style="background-color:<?php echo isset($settings[$value->item_id]['font-color']) ? $settings[$value->item_id]['font-color'] : '#ffffff'; ?> ;<?php if (isset($settings[$value->item_id]['font-color'])) { echo 'background-image:none;border-color:' . $settings[$value->item_id]['font-color'] . ';'; } ?> "> </div> </div> <div class="select_wrapper typography-family"> <select name="<?php echo $value->item_id; ?> [font-family]" class="select"> <?php echo '<option value="">font-family</option>'; foreach (recognized_font_families() as $key => $family) { echo '<option value="' . esc_attr($key) . '" ' . selected($settings[$value->item_id]['font-family'], $key, false) . '>' . esc_html($family) . '</option>'; } ?> </select> </div> <div class="select_wrapper typography-style" style="width:165px;"> <select name="<?php echo $value->item_id; ?> [font-style]" class="select"> <?php echo '<option value="">font-style</option>'; foreach (recognized_font_styles() as $key => $style) { echo '<option value="' . esc_attr($key) . '" ' . selected($settings[$value->item_id]['font-style'], $key, false) . '>' . esc_html($style) . '</option>'; } ?> </select> </div> <div class="select_wrapper typography-variant" style="width:166px;margin-left:10px;"> <select name="<?php echo $value->item_id; ?> [font-variant]" class="select"> <?php echo '<option value="">font-variant</option>'; foreach (recognized_font_variants() as $key => $variant) { echo '<option value="' . esc_attr($key) . '" ' . selected($settings[$value->item_id]['font-variant'], $key, false) . '>' . esc_html($variant) . '</option>'; } ?> </select> </div> <div class="select_wrapper typography-weight" style="width:165px;"> <select name="<?php echo $value->item_id; ?> [font-weight]" class="select"> <?php echo '<option value="">font-weight</option>'; foreach (recognized_font_weights() as $key => $weight) { echo '<option value="' . esc_attr($key) . '" ' . selected($settings[$value->item_id]['font-weight'], $key, false) . '>' . esc_html($weight) . '</option>'; } ?> </select> </div> <div class="select_wrapper typography-size" style="width:166px;margin-left:10px;"> <select name="<?php echo $value->item_id; ?> [font-size]" class="select"> <?php echo '<option value="">font-size</option>'; for ($i = 8; $i <= 72; $i++) { $size = $i . 'px'; echo '<option value="' . esc_attr($size) . '" ' . selected($settings[$value->item_id]['font-size'], $size, false) . '>' . esc_html($size) . '</option>'; } ?> </select> </div> </div> <div class="description"> <?php echo htmlspecialchars_decode($value->item_desc); ?> </div> </div> </div> <?php }