function ts_essentials_output_social_icon($arg, $preset = '', $override = false) { $orig_arg = $arg; $social_icon_style = ts_essentials_option_vs_default('social_icon_style', 'fontawesome'); $arg = 'social_url_' . $arg; $val = $override !== false ? $override : ts_essentials_option_vs_default($arg, $preset); if (trim($val)) { $url = $val; if ($orig_arg == 'rss' && ($preset == '[rss_url]' || $url == '[rss_url]')) { $override = '[rss_url]'; $url = ts_essentials_get_feed_url($override); } $orig_arg = $orig_arg == 'google_plus' ? 'google-plus' : $orig_arg; $orig_arg = $orig_arg == 'vimeo' ? 'vimeo-square' : $orig_arg; return '<a href="' . esc_url($url) . '" class="icon-style" target="_blank"><i class="fa fa-' . esc_attr($orig_arg) . '"></i></a>'; } else { return ''; } }
function ts_title_shortcode($atts, $content = null) { $atts = shortcode_atts(array('size' => '3', 'align' => '', 'bold' => '', 'line_style' => '', 'style' => '', 'padding_top' => '0', 'padding_bottom' => '0', 'margin_top' => '0', 'margin_bottom' => '0', 'color' => '', 'border_color' => ''), $atts); $hex = $class = $style = $h_atts = $span_class_style = ''; $size = $font_size = preg_replace("/[^0-9]*/", "", $atts['size']); $size = ts_essentials_number_within_range($size, 1, 6) ? $size : 3; if ($font_size > 6) { $style .= 'font-size:' . $font_size . 'px;'; $size = 1; } $default_align = ts_essentials_option_vs_default('rtl', 0) == 1 ? 'right' : 'left'; $align_options = array('center', 'centered', 'middle', 'right', 'left'); $align = in_array($atts['align'], $align_options) ? in_array($atts['align'], array('centered', 'middle')) ? 'text-center' : 'text-' . $atts['align'] : 'text-' . $default_align; $line_style_options = array('none', 'line', 'single', 'single-line', 'dashed', 'dotted', 'double-line', 'double-dashed', 'double-dotted', 'underline-full', 'underline-text'); $line_style = $atts['line_style'] ? $atts['line_style'] : $atts['style']; $line_style = in_array($line_style, $line_style_options) ? $line_style : 'none'; $line_style = in_array($line_style, array('single', 'single-line')) ? 'line' : $line_style; $padding_top = max(preg_replace("/[^0-9]*/", "", $atts['margin_top']), preg_replace("/[^0-9]*/", "", $atts['padding_top'])); $padding_top = preg_replace("/[^0-9]*/", "", $padding_top); $padding_bottom = max(preg_replace("/[^0-9]*/", "", $atts['margin_bottom']), preg_replace("/[^0-9]*/", "", $atts['padding_bottom'])); $padding_bottom = preg_replace("/[^0-9]*/", "", $padding_bottom); $color = $atts['color'] ? $atts['color'] : ''; if ($color && $color[0] == '#') { $style .= 'color:' . $color . ';'; $color = ''; } else { $class .= $color ? 'color-shortcode ' . $color : ''; } $no_line_thru = in_array($line_style, array('none', 'underline-text', 'underline-full')) ? true : false; $no_table = $no_line_thru ? 'no-table' : ''; $class .= ts_essentials_attr_is_true($atts['bold']) ? ' bold' : ''; $class .= ' ' . $align; $border_color = $atts['border_color'] ? $atts['border_color'] : ''; $title_sep_class_style = 'class="title-sep"'; if (substr($border_color, 0, 1) == '#') { $title_sep_class_style = 'class="title-sep" style="border-color:' . esc_attr($border_color) . ' !important;"'; $span_class_style = 'style="border-color:' . esc_attr($border_color) . ' !important;"'; $border_color = ''; } $title_sep_class_style = $border_color ? 'class="title-sep border-' . esc_attr($border_color) . '"' : $title_sep_class_style; $span_class_style = $border_color ? 'class="border-' . esc_attr($border_color) . '"' : $span_class_style; $h_atts .= ' style="' . esc_attr($style) . '"'; $h_atts .= ' class="title-shortcode-htag ' . esc_attr($class) . '"'; $html = '<div class="title-shortcode ' . esc_attr($no_table) . ' ' . esc_attr($align) . ' ' . esc_attr($line_style) . '" style="padding-top:' . intval($padding_top) . 'px;padding-bottom:' . intval($padding_bottom) . 'px;">'; if ($align == 'text-center') { $html .= $no_line_thru ? '' : '<div class="title-sep-container"><div ' . $title_sep_class_style . '> </div></div>'; $html .= '<h' . absint($size) . ' ' . $h_atts . '><span ' . $span_class_style . '>' . do_shortcode($content) . '</span></h' . absint($size) . '>'; $html .= $no_line_thru ? '' : '<div class="title-sep-container"><div ' . $title_sep_class_style . '> </div></div>'; } elseif ($align == 'text-right') { $rtl = ts_essentials_option_vs_default('rtl', 0) == 1 ? true : false; $html .= $no_line_thru ? '' : ($rtl ? '' : '<div class="title-sep-container"><div ' . $title_sep_class_style . '></div></div>'); $html .= '<h' . absint($size) . ' ' . $h_atts . '><span ' . $span_class_style . '>' . do_shortcode($content) . '</span></h' . absint($size) . '>'; $html .= $no_line_thru ? '' : ($rtl ? '<div class="title-sep-container"><div ' . $title_sep_class_style . '></div></div>' : ''); } else { $rtl = ts_essentials_option_vs_default('rtl', 0) == 1 ? true : false; $html .= $no_line_thru ? '' : ($rtl ? '<div class="title-sep-container"><div ' . $title_sep_class_style . '></div></div>' : ''); $html .= '<h' . absint($size) . ' ' . $h_atts . '><span ' . $span_class_style . '>' . do_shortcode($content) . '</span></h' . absint($size) . '>'; $html .= $no_line_thru ? '' : ($rtl ? '' : '<div class="title-sep-container"><div ' . $title_sep_class_style . '></div></div>'); } $html .= '</div>'; return $html; }
function form($instance) { global $smof_data; wp_enqueue_style('wp-color-picker'); wp_enqueue_script('wp-color-picker'); $icon_bg_color = ts_essentials_option_vs_default('primary_color', '#000000'); $defaults = array('label' => '', 'icon' => '', 'title' => '', 'description' => '', 'url' => '', 'icon_color' => $icon_bg_color); $instance = wp_parse_args((array) $instance, $defaults); ?> <script type="text/javascript"> jQuery(document).ready(function($){ $('.color-picker-field').not('.wp-color-picker').wpColorPicker(); }); </script> <p> <label for="<?php echo esc_attr($this->get_field_id('icon')); ?> "><?php _e('Icon (optional):', 'ThemeStockyard'); ?> </label> <input type="text" name="<?php echo esc_attr($this->get_field_name('icon')); ?> " value="<?php echo esc_attr($instance['icon']); ?> " class="widefat" id="<?php echo esc_attr($this->get_field_id('icon')); ?> " /> <span style="font-size:11px;color:#808080;">Use a Font Awesome icon code if you wish. <a href="http://fortawesome.github.io/Font-Awesome/" target="_blank">Refer here</a> (scroll down) for a list of available options.</span> </p> <p> <label for="<?php echo esc_attr($this->get_field_id('icon_color')); ?> "><?php _e('Icon Background Color (optional):', 'ThemeStockyard'); ?> </label> <input type="text" name="<?php echo esc_attr($this->get_field_name('icon_color')); ?> " value="<?php echo esc_attr($instance['icon_color']); ?> " class="ts-color-picker-field color-picker-field" id="<?php echo esc_attr($this->get_field_id('icon_color')); ?> " /> <span style="font-size:11px;color:#808080;display:block;"><strong>Note:</strong> The foreground color is always white</span> </p> <p> <label for="<?php echo esc_attr($this->get_field_id('label')); ?> "><?php _e('Label (optional):', 'ThemeStockyard'); ?> </label> <input type="text" name="<?php echo esc_attr($this->get_field_name('label')); ?> " value="<?php echo esc_attr($instance['label']); ?> " class="widefat" id="<?php echo esc_attr($this->get_field_id('label')); ?> " /> </p> <p> <label for="<?php echo esc_attr($this->get_field_id('title')); ?> "><?php _e('Title (optional):', 'ThemeStockyard'); ?> </label> <input type="text" name="<?php echo esc_attr($this->get_field_name('title')); ?> " value="<?php echo esc_attr($instance['title']); ?> " class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?> " /> </p> <p> <label for="<?php echo esc_attr($this->get_field_id('description')); ?> "><?php _e('Description:', 'ThemeStockyard'); ?> </label> <textarea name="<?php echo esc_attr($this->get_field_name('description')); ?> " class="widefat" id="<?php echo esc_attr($this->get_field_id('description')); ?> "><?php echo esc_attr($instance['description']); ?> </textarea> </p> <p> <label for="<?php echo esc_attr($this->get_field_id('url')); ?> "><?php _e('Link URL (optional):', 'ThemeStockyard'); ?> </label> <input type="text" name="<?php echo esc_attr($this->get_field_name('url')); ?> " value="<?php echo esc_url($instance['url']); ?> " class="widefat" id="<?php echo esc_attr($this->get_field_id('url')); ?> " /> </p> <?php }