Example #1
0
function wpv_shortcode_icon($atts, $content = null)
{
    extract(shortcode_atts(array('name' => '', 'style' => '', 'color' => '', 'size' => '', 'lheight' => 1), $atts));
    $size_int = array('small' => 16, 'medium' => 24, 'large' => 32);
    $icon_char = wpv_get_icon($name);
    $theme = '';
    if (strpos($name, 'theme-') === 0) {
        $theme = 'theme';
    } elseif (strpos($name, 'custom-') === 0) {
        $theme = 'custom';
    }
    $color = wpv_sanitize_accent($color);
    if (isset($size_int[$size])) {
        $size = $size_int[$size];
    }
    $style_slug = $style;
    if (!empty($color)) {
        $style = "color:{$color};";
        if ($style_slug == 'inverted-colors' || $style_slug == 'box') {
            $l = new WpvLessc();
            $l->importDir = '.';
            $l->setFormatter("compressed");
            $style = $l->compile("\n\t\t\t\t.readable-color(@bgcolor:#FFF, @treshold:70, @diff:50%) when (iscolor(@bgcolor)) and ( lightness(@bgcolor) >= @treshold ) {\n\t\t\t\t\tcolor: darken(@bgcolor, @diff);\n\t\t\t\t}\n\t\t\t\t.readable-color(@bgcolor:#FFF, @treshold:70, @diff:50%) when (iscolor(@bgcolor)) and ( lightness(@bgcolor) < @treshold ) {\n\t\t\t\t\tcolor: lighten(@bgcolor, @diff);\n\t\t\t\t}\n\n\n\t\t\t\t\t.readable-color({$color});\n\t\t\t\t\tbackground: {$color};\n\t\t\t");
        }
    }
    $lheight = (int) $lheight != 1 && (int) $lheight != (int) $size ? "line-height:{$lheight};" : '';
    if (!empty($size)) {
        $size = "font-size:{$size}px !important;";
    }
    return "<span class='icon shortcode {$theme} {$style_slug}' style='{$lheight}{$size}{$style}'>{$icon_char}</span>";
}
Example #2
0
function theme_background_styles()
{
    global $post;
    $post_id = wpv_get_the_ID();
    if (is_null($post_id)) {
        return;
    }
    $bgcolor = wpv_sanitize_accent(wpv_post_meta($post_id, 'background-color', true));
    $bgimage = wpv_post_meta($post_id, 'background-image', true);
    $bgrepeat = wpv_post_meta($post_id, 'background-repeat', true);
    $bgsize = wpv_post_meta($post_id, 'background-size', true);
    $bgattachment = wpv_post_meta($post_id, 'background-attachment', true);
    $bgposition = wpv_post_meta($post_id, 'background-position', true);
    $page_style = '';
    if (!empty($bgcolor)) {
        $page_style .= "background-color:{$bgcolor};";
    }
    if (!empty($bgimage)) {
        $page_style .= "background-image:url('{$bgimage}');";
        if (!empty($bgrepeat)) {
            $page_style .= "background-repeat:{$bgrepeat};";
        }
        if (!empty($bgattachment)) {
            $page_style .= "background-attachment:{$bgattachment};";
        }
        if (!empty($bgsize)) {
            $page_style .= "background-size:{$bgsize};";
        }
    }
    if (!empty($page_style) && (is_single() || is_page())) {
        echo "<style>html{ {$page_style} }</style>";
    }
}
Example #3
0
    public static function shortcode($atts, $content = null, $code = 'accordion')
    {
        extract(shortcode_atts(array('closed_bg' => 'accent1', 'title_color' => 'accent8', 'collapsible' => 'true'), $atts));
        if (!wpv_sub_shortcode('pane', $content, $params, $sub_contents)) {
            return do_shortcode($content);
        }
        wp_enqueue_script('jquery-ui-accordion');
        $title_tag = apply_filters('wpv_accordion_title_tag', 'h4');
        $closed_bg = wpv_sanitize_accent($closed_bg);
        $title_color = wpv_sanitize_accent($title_color);
        global $wpv_accordions_shown;
        if (!isset($wpv_accordions_shown)) {
            $wpv_accordions_shown = 0;
        }
        $wpv_accordions_shown++;
        $output = '';
        foreach ($sub_contents as $i => $sc) {
            $tab_class = '';
            $bgimage = '';
            if (isset($params[$i]['background_image']) && !empty($params[$i]['background_image'])) {
                $bgimage = 'background-image: url("' . $params[$i]['background_image'] . '");';
                $tab_class .= ' has-bg';
            }
            $output .= '<li class="pane-wrapper" style="' . esc_attr($bgimage) . '">
					<' . $title_tag . ' class="tab' . $tab_class . '"><div class="inner">' . $params[$i]['title'] . '</div></' . $title_tag . '>
					<div class="pane"><div class="inner">' . do_shortcode(trim($sc)) . '</div></div>
					</li>';
        }
        $style = '<style>.wpv-accordion-' . $wpv_accordions_shown . ' .tab .inner { background-color: ' . $closed_bg . '; color: ' . $title_color . '; }</style>';
        return '<div class="wpv-accordion-wrapper wpv-accordion-' . $wpv_accordions_shown . '"><ul class="wpv-accordion" data-collapsible="' . esc_attr($collapsible) . '">' . $output . '</ul>' . $style . '</div>';
    }
 public static function shortcode($atts, $content = null, $code)
 {
     extract(shortcode_atts(array('type' => 'percentage', 'value' => 0, 'percentage' => 0, 'bar_color' => 'accent1', 'track_color' => 'accent7', 'value_color' => 'accent2'), $atts));
     if ($type == 'percentage') {
         return '<div class="wpv-progress pie" data-percent="' . $percentage . '" data-bar-color="' . wpv_sanitize_accent($bar_color) . '" data-track-color="' . wpv_sanitize_accent($track_color) . '" style="color:' . wpv_sanitize_accent($value_color) . '"><span>0</span>%</div>';
     } elseif ($type == 'number') {
         return '<div class="wpv-progress number" data-number="' . $value . '" style="color:' . wpv_sanitize_accent($value_color) . '"><span>0</span></div>';
     }
     return '';
 }
Example #5
0
 public static function shortcode($atts, $content = null, $code)
 {
     extract(shortcode_atts(array('layout' => 'horizontal', 'left_color' => 'accent8', 'right_color' => 'accent1', 'nav_color' => 'accent2'), $atts));
     if (!wpv_sub_shortcode('tab', $content, $params, $sub_contents)) {
         return 'error parsing slider shortcode';
     }
     wp_enqueue_script('jquery-ui-tabs');
     wp_enqueue_script('front-jquery.ui.tabs.rotate');
     global $wpv_tabs_shown;
     if (!isset($wpv_tabs_shown)) {
         $wpv_tabs_shown = 0;
     }
     $wpv_tabs_shown++;
     $id = 'tabs-' . $wpv_tabs_shown;
     $output = '<ul class="ui-tabs-nav">';
     if (isset($GLOBALS['wpv_last_column_title']) && !empty($GLOBALS['wpv_last_column_title']) && $layout == 'vertical') {
         $output .= '<li class="inactive-block-title"><h2>' . $GLOBALS['wpv_last_column_title'] . '</h2></li>';
     }
     foreach ($params as $i => $p) {
         $p = shortcode_atts(array('title' => '', 'class' => '', 'icon' => ''), $p);
         if (!empty($p['icon'])) {
             $p['icon'] = wpv_shortcode_icon(array('name' => $p['icon']));
             $p['class'] .= ' has-icon';
         }
         $class = empty($p['class']) ? '' : " class='{$p['class']}'";
         $output .= '<li' . $class . '><a href="#tab-' . $wpv_tabs_shown . '-' . $i . '-' . self::sanitize_id($params[$i]['title']) . '">' . $p['icon'] . ' <span class="title-text">' . $p['title'] . '</span></a></li>';
     }
     $output .= '</ul>';
     foreach ($sub_contents as $i => $c) {
         $class = isset($params[$i]['class']) ? ' tab-' . $params[$i]['class'] : '';
         $output .= '<div class="pane' . $class . '" id="tab-' . $wpv_tabs_shown . '-' . $i . '-' . self::sanitize_id($params[$i]['title']) . '">' . do_shortcode(trim($c)) . '</div>';
     }
     $l = new WpvLessc();
     $l->importDir = '.';
     $l->setFormatter("compressed");
     $left_color = wpv_sanitize_accent($left_color);
     $right_color = wpv_sanitize_accent($right_color);
     $nav_color = wpv_sanitize_accent($nav_color);
     $inner_style = '';
     if (!empty($left_color) && !empty($right_color)) {
         $readable = WpvTemplates::readable_color_mixin();
         $vertical_styles = $layout !== 'vertical' ? '' : "\n\t\t\t\t#{$id}.vertical {\n\t\t\t\t\t&,\n\t\t\t\t\t&:before {\n\t\t\t\t\t\tbackground: {$right_color};\n\t\t\t\t\t}\n\n\t\t\t\t\t.ui-tabs-nav {\n\t\t\t\t\t\t&:before {\n\t\t\t\t\t\t\tbackground: {$left_color};\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t.pane:before {\n\t\t\t\t\t\tbackground: {$left_color};\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t";
         $inner_style = $l->compile($readable . $vertical_styles . "\n\t\t\t\t#{$id} {\n\t\t\t\t\t.ui-tabs-nav {\n\t\t\t\t\t\t&,\n\t\t\t\t\t\tli {\n\t\t\t\t\t\t\tbackground: {$left_color};\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tli {\n\t\t\t\t\t\t\t&, a, a .icon {\n\t\t\t\t\t\t\t\tcolor: {$nav_color};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t.ui-state-active,\n\t\t\t\t\t\t.ui-state-selected,\n\t\t\t\t\t\t.ui-state-hover {\n\t\t\t\t\t\t\tbackground: {$right_color};\n\n\t\t\t\t\t\t\t&, a, a .icon {\n\t\t\t\t\t\t\t\t.readable-color({$right_color});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t.inactive-block-title {\n\t\t\t\t\t\t\th1, h2, h3, h4, h5, h6 {\n\t\t\t\t\t\t\t\tcolor: {$nav_color};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t&.horizontal {\n\t\t\t\t\t\t.pane {\n\t\t\t\t\t\t\tbackground: {$right_color};\n\n\t\t\t\t\t\t\t&,\n\t\t\t\t\t\t\tp,\n\t\t\t\t\t\t\ta,\n\t\t\t\t\t\t\t.column-title,\n\t\t\t\t\t\t\t.sep-text h2.regular-title-wrapper,\n\t\t\t\t\t\t\t.text-divider-double,\n\t\t\t\t\t\t\t.sep-text .sep-text-line,\n\t\t\t\t\t\t\t.sep,\n\t\t\t\t\t\t\t.sep-2,\n\t\t\t\t\t\t\t.sep-3,\n\t\t\t\t\t\t\ttd,\n\t\t\t\t\t\t\tth,\n\t\t\t\t\t\t\tcaption {\n\t\t\t\t\t\t\t\t.readable-color({$right_color});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t");
     }
     $style = '<style>' . $inner_style . '</style>';
     return '<div class="wpv-tabs ' . $layout . '" id="' . $id . '">' . $output . '</div>' . $style;
 }
Example #6
0
        }
        ?>
				</div>
				<?php 
        if ($has_icon) {
            ?>
					<div class="sep-2"></div>
				<?php 
        }
        ?>
			<?php 
    } else {
        ?>
				<div class="shrinking-outer clearfix">
					<div class="shrinking" style="background:<?php 
        echo wpv_sanitize_accent($background);
        ?>
 no-repeat 50% 50%;<?php 
        if ($has_image) {
            echo esc_attr("background-image:url('{$image}')");
        }
        ?>
">
						<?php 
        if ($has_button) {
            ?>
							<a href="<?php 
            echo $button_link;
            ?>
" title="<?php 
            echo esc_attr($button_text);
">
	<div class="closed services-inside">
		<div class="services-content-wrapper clearfix">
			<?php 
if (!empty($image)) {
    ?>
				<div class="image-wrapper">
					<?php 
    wpv_lazy_load($image, '', array('class' => 'aligncenter'));
    ?>
				</div>
			<?php 
} elseif (!empty($icon)) {
    ?>
				<div class="image-wrapper"><?php 
    echo wpv_shortcode_icon(array('name' => $icon, 'size' => $icon_size, 'color' => wpv_sanitize_accent($icon_color)));
    ?>
</div>
			<?php 
}
?>

			<?php 
echo do_shortcode($before);
?>

		</div>
	</div>
	<div class="open services-inside">
		<div class="services-content-wrapper">
			<div class="row">
Example #8
0
 /**
  * Outputs the page title styles
  */
 public static function get_title_style()
 {
     $post_id = wpv_get_the_ID();
     if (!current_theme_supports('wpv-page-title-style') || is_null($post_id)) {
         return;
     }
     $bgcolor = wpv_sanitize_accent(wpv_post_meta($post_id, 'local-title-background-color', true));
     $bgimage = wpv_post_meta($post_id, 'local-title-background-image', true);
     $bgrepeat = wpv_post_meta($post_id, 'local-title-background-repeat', true);
     $bgsize = wpv_post_meta($post_id, 'local-title-background-size', true);
     $bgattachment = wpv_post_meta($post_id, 'local-title-background-attachment', true);
     $bgposition = wpv_post_meta($post_id, 'local-title-background-position', true);
     $style = '';
     if (!empty($bgcolor)) {
         $style .= "background-color:{$bgcolor};";
     }
     if (!empty($bgimage)) {
         $style .= "background-image:url('{$bgimage}' );";
         if (!empty($bgrepeat)) {
             $style .= "background-repeat:{$bgrepeat};";
         }
         if (!empty($bgsize)) {
             $style .= "background-size:{$bgsize};";
         }
     }
     return $style;
 }
    /**
     * Column shortcode callback
     *
     * @param  array  $atts    shortcode attributes
     * @param  string $content shortcode content
     * @param  string $code    shortcode name
     * @return string          output html
     */
    public static function dispatch($atts, $content, $code)
    {
        extract(shortcode_atts(array('animation' => 'none', 'background_attachment' => 'scroll', 'background_color' => '', 'background_image' => '', 'background_position' => '', 'background_repeat' => '', 'background_size' => '', 'background_video' => '', 'class' => '', 'extended' => 'false', 'extended_padding' => 'true', 'last' => 'false', 'more_link' => '', 'more_text' => '', 'parallax_bg' => 'disabled', 'parallax_bg_inertia' => '1', 'title' => '', 'title_type' => 'single', 'vertical_padding_bottom' => '0', 'vertical_padding_top' => '0', 'width' => '1/1', 'div_atts' => '', 'left_border' => 'transparent', 'id' => ''), $atts));
        if (!preg_match('/column_\\d+/', $code)) {
            $class .= ' wpv-first-level';
        }
        $GLOBALS['wpv_column_stack'][] = $width;
        $GLOBALS['wpv_last_column_title'] = $title;
        if ($parallax_bg !== 'disabled') {
            $class .= ' parallax-bg';
            $div_atts .= ' data-parallax-method="' . esc_attr($parallax_bg) . '" data-parallax-inertia="' . esc_attr($parallax_bg_inertia) . '"';
            $background_position = 'center top';
            $background_attachment = 'fixed';
        }
        $has_price = strpos($content, '[price') !== false;
        $has_vertical_tabs = preg_match('/\\[tabs.+layout="vertical"/s', $content);
        $width = str_replace('/', '-', $width);
        $title = !empty($title) && !$has_vertical_tabs ? apply_filters('wpv_column_title', $title, $title_type) : '';
        $extended = wpv_sanitize_bool($extended);
        $last = wpv_sanitize_bool($last);
        $first = !$last;
        $id = empty($id) ? 'wpv-column-' . md5(uniqid()) : $id;
        if ($width === '1-1') {
            $first = true;
            $last = true;
        }
        if ($width !== '1-1' || WpvTemplates::get_layout() !== 'full') {
            $extended = false;
        }
        $result = '';
        $result_before = $result_after = $content_before = $content_after = '';
        if (self::$in_row > self::$last_row) {
            $rowclass = $has_price ? 'has-price' : '';
            $class .= ' first';
            $result .= '<div class="row ' . $rowclass . '">';
            self::$last_row = self::$in_row;
        }
        if (!empty($background_image)) {
            $background_image = "\n\t\t\t\tbackground: url('{$background_image}') {$background_repeat} {$background_position};\n\t\t\t\tbackground-size: {$background_size};\n\t\t\t\tbackground-attachment: {$background_attachment};\n\t\t\t";
        }
        $inner_style = '';
        $l = new WpvLessc();
        $l->importDir = '.';
        $l->setFormatter("compressed");
        if (!empty($background_color) && $background_color !== 'transparent') {
            $color = wpv_sanitize_accent($background_color);
            $inner_style .= $l->compile("\n\t\t\t\t.readable-color(@bgcolor:#FFF, @treshold:70, @diff:50%) when (iscolor(@bgcolor)) and ( lightness(@bgcolor) >= @treshold ) {\n\t\t\t\t\tcolor: darken(@bgcolor, @diff);\n\t\t\t\t}\n\t\t\t\t.readable-color(@bgcolor:#FFF, @treshold:70, @diff:50%) when (iscolor(@bgcolor)) and ( lightness(@bgcolor) < @treshold ) {\n\t\t\t\t\tcolor: lighten(@bgcolor, @diff);\n\t\t\t\t}\n\t\t\t\t.safe-bg(@bgcolor) when (iscolor(@bgcolor)) {\n\t\t\t\t\tbackground-color: @bgcolor;\n\t\t\t\t}\n\t\t\t\t.safe-bg(@bgcolor) {}\n\n\t\t\t\t#{$id} {\n\t\t\t\t\tp,\n\t\t\t\t\tem,\n\t\t\t\t\t.column-title,\n\t\t\t\t\t.sep-text h2.regular-title-wrapper,\n\t\t\t\t\t.text-divider-double,\n\t\t\t\t\t.sep-text .sep-text-line,\n\t\t\t\t\t.sep,\n\t\t\t\t\t.sep-2,\n\t\t\t\t\t.sep-3 {\n\t\t\t\t\t\t.readable-color({$color});\n\t\t\t\t\t}\n\n\t\t\t\t\t&:before {\n\t\t\t\t\t\t.safe-bg({$left_border});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t");
            $background_color = "background-color:" . wpv_sanitize_accent($background_color) . ";";
        } else {
            $background_color = '';
        }
        if (!empty($left_border) && $left_border !== 'transparent') {
            $inner_style .= $l->compile("\n\t\t\t\t.safe-bg(@bgcolor) when (iscolor(@bgcolor)) {\n\t\t\t\t\tbackground-color: @bgcolor;\n\t\t\t\t}\n\t\t\t\t.safe-bg(@bgcolor) {}\n\n\t\t\t\t#{$id} {\n\t\t\t\t\t&:before {\n\t\t\t\t\t\t.safe-bg({$left_border});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t");
        }
        if (!empty($inner_style)) {
            $content_before .= '<style>' . $inner_style . '</style>';
        }
        if (!empty($more_link) && !empty($more_text) && !$extended) {
            $class .= ' has-more-button';
            $more_link = esc_attr($more_link);
            $content_after .= "<a href='{$more_link}' title='" . esc_attr($more_text) . "' class='column-read-more-btn'>{$more_text}</a>";
        }
        if (!empty($background_video) && !WpvMobileDetect::getInstance()->isMobile()) {
            $type = wp_check_filetype($background_video, wp_get_mime_types());
            $content_before .= '<div class="wpv-video-bg">
				<video autoplay loop preload="metadata" width="100%" class="wpv-background-video" style="width:100%">
					<source type="' . $type['type'] . '" src="' . $background_video . '"></source>
				</video>
			</div><div class="wpv-video-bg-content">';
            $content_after .= '</div>';
            $class .= ' has-video-bg';
            wp_enqueue_style('wp-mediaelement');
            wp_enqueue_script('wp-mediaelement');
        }
        if (!empty($background_image) || !empty($background_color) && $background_color !== 'transparent') {
            $class .= ' has-background';
        }
        if ((int) $vertical_padding_top < 0) {
            $div_atts .= ' data-padding-top="' . (int) $vertical_padding_top . '"';
        }
        if ((int) $vertical_padding_bottom < 0) {
            $div_atts .= ' data-padding-bottom="' . (int) $vertical_padding_bottom . '"';
        }
        $vertical_padding_top = max(0, (int) $vertical_padding_top) . 'px';
        $vertical_padding_bottom = max(0, (int) $vertical_padding_bottom) . 'px';
        $style = 'style="' . $background_image . $background_color . 'padding-top:' . $vertical_padding_top . ';padding-bottom:' . $vertical_padding_bottom . '"';
        $class .= $extended ? ' extended' : ' unextended';
        if ($left_border != 'transparent') {
            $class .= ' left-border';
        }
        if ($animation !== 'none' && $parallax_bg == 'disabled') {
            $class .= ' animation-' . $animation . ' animated-active';
        }
        if ($extended_padding === 'false') {
            $class .= ' no-extended-padding';
        }
        if ($extended) {
            $content_before = '<div class="extended-column-inner">' . $content_before;
            $content_after .= '</div>';
        }
        $result .= '<div class="wpv-grid grid-' . $width . ' ' . $class . '" ' . $style . ' id="' . $id . '" ' . $div_atts . '>' . $content_before . $title . self::content($content) . $content_after . '</div>';
        if ($last) {
            self::$last_row--;
            $result .= '</div>';
        }
        array_pop($GLOBALS['wpv_column_stack']);
        return $result_before . $result . $result_after;
    }
Example #10
0
    public static function shortcode($atts, $content = null, $code = 'gmap')
    {
        extract(shortcode_atts(array("width" => false, "height" => '400', "address" => '', "latitude" => 0, "longitude" => 0, "zoom" => 14, "html" => '', "popup" => 'false', "controls" => '[]', "scrollwheel" => 'true', "maptype" => 'ROADMAP', "marker" => 'true', 'align' => false, 'hue' => '', 'invert_lightness' => 'false'), $atts));
        $width = $width && is_numeric($width) ? 'width:' . $width . 'px;' : '';
        $height = $height && is_numeric($height) ? 'height:' . $height . 'px;' : '';
        $align = $align ? ' align' . $align : '';
        $id = rand(100, 1000);
        $inline_html = $html;
        if (empty($controls)) {
            $controls = '[]';
        }
        if (empty($latitude)) {
            $latitude = 0;
        }
        if (empty($longitude)) {
            $longitude = 0;
        }
        if (!empty($hue)) {
            $hue = ',' . json_encode(array('hue' => wpv_sanitize_accent($hue)));
        }
        ob_start();
        ?>

	<div class="frame"><div id="google_map_<?php 
        echo $id;
        ?>
" class="google_map<?php 
        echo $align;
        ?>
" style="<?php 
        echo $width;
        echo $height;
        ?>
"></div></div>
	<script type="text/javascript">
	jQuery(document).ready(function($) {
		jQuery("#google_map_<?php 
        echo $id;
        ?>
").gMap({
		    zoom: <?php 
        echo $zoom;
        ?>
,


		<?php 
        if ($marker != 'false') {
            ?>
		    markers:[{
		    	address: "<?php 
            echo $address;
            ?>
",
				latitude: <?php 
            echo $latitude;
            ?>
,
		    	longitude: <?php 
            echo $longitude;
            ?>
,
		    	html: '<?php 
            echo str_replace("'", "\\'", $inline_html);
            ?>
',
		    	popup: <?php 
            echo $popup != 'true' ? 'false' : 'true';
            ?>
			}],
		<?php 
        } else {
            ?>
		    latitude: <?php 
            echo $latitude;
            ?>
,
		    longitude: <?php 
            echo $longitude;
            ?>
,
		    address: "<?php 
            echo $address;
            ?>
",
		<?php 
        }
        ?>

			controls: <?php 
        echo $controls;
        ?>
,
			maptype: '<?php 
        echo $maptype;
        ?>
',
		    scrollwheel:<?php 
        echo $scrollwheel != 'true' ? 'false' : 'true';
        ?>
,
		    custom: {
			    styles: [
			  		{
						stylers: [
				 			{ inverse_lightness: <?php 
        echo $invert_lightness;
        ?>
 }
				 			<?php 
        echo $hue;
        ?>
						]
			  		}
				]
			}
		});
	});
	</script>

<?php 
        return ob_get_clean();
    }
Example #11
0
 /**
  * Sanitizes a variable
  *
  * @param  string  $name           option name
  * @param  string  $value          option value from db
  * @param  boolean $returnOriginal whether to return the db value if no good sanitization is found
  * @return int|string|null         sanitized value
  */
 private static function prepare($name, $value, $returnOriginal = false)
 {
     $good = true;
     $name = preg_replace('/^wpv_/', '', $name);
     $originalValue = $value;
     // duck typing values
     if (preg_match('/(^share|^has-|^show|-last$)/i', $name)) {
         $good = false;
     } elseif (is_numeric($value)) {
         // most likely dimensions, must differentiate between percentages and pixels
         if (in_array($name, self::$percentages)) {
             $value .= '%';
         } elseif (preg_match('/(size|width|height)$/', $name)) {
             // treat as px
             $value .= 'px';
         }
     } elseif (preg_match('/^#([0-9a-f]{3}|[0-9a-f]{6})$/i', $value)) {
         // colors
         // as is
     } elseif (preg_match('/^http|^url/i', $value) || preg_match('/(face|weight)$/', $name)) {
         // urls and other strings
         $value = '"' . addslashes($value) . '"';
     } elseif (preg_match('/^accent(?:-color-)?\\d$/', $value)) {
         // accents
         $value = wpv_sanitize_accent($value);
     } else {
         if (!preg_match('/\\bface\\b|\\burl\\b/i', $name)) {
             // check keywords
             $keywords = explode(' ', 'top right bottom left fixed static scroll cover contain auto repeat repeat-x repeat-y no-repeat center normal italic bold 300 800 transparent');
             $sub_values = explode(' ', $value);
             foreach ($sub_values as $s) {
                 if (!in_array($s, $keywords)) {
                     $good = false;
                     break;
                 }
             }
         }
     }
     return $good ? $value : ($returnOriginal ? $originalValue : null);
 }