Example #1
0
 /**
  * Returns a simple slider markup
  *
  * @param string $id The id attribute
  * @param integer $width Slider width
  * @param integer $height Slider height
  * @param array $config Slider configuration
  * @param array $slides
  * @return string
  */
 public function capture($slides, $config, $args)
 {
     static $counter = 0;
     $counter++;
     $out = '';
     if (!count($slides)) {
         return '';
     }
     // clean arguments
     $args['id'] = !empty($args['id']) ? $args['id'] : 'g1-slider-counter-' . $counter;
     $args['class'] = !empty($args['class']) ? $args['class'] : '';
     $args['width'] = absint($args['width']);
     $args['height'] = absint($args['height']);
     // clean options
     $config['layout'] = $this->sanitize_string_var($config['layout']);
     $config['width'] = $this->sanitize_string_var($config['width']);
     $config['height'] = 320;
     if (is_numeric($config['height'])) {
         $config['height'] = absint($config['height']);
     }
     $config['animation'] = $this->sanitize_string_var($config['animation']);
     $config['animation'] = str_replace('-', '_', $config['animation']);
     $config['animationDuration'] = absint($config['animationDuration']);
     $config['slideshowSpeed'] = absint($config['slideshowSpeed']);
     $config['autoplay'] = $this->sanitize_string_var($config['autoplay']);
     $config['fullscreen'] = $this->sanitize_string_var($config['fullscreen']);
     $config['coinNavigation'] = $this->sanitize_string_var($config['coinNavigation']);
     $config['directionNavigation'] = $this->sanitize_string_var($config['directionNavigation']);
     $config['progressBar'] = $this->sanitize_string_var($config['progressBar']);
     $config['width_in_px'] = G1_Simple_Sliders_Module::get_slider_width_in_pixels($config['width']);
     switch ($config['width']) {
         case '':
             break;
     }
     // set defaults if needed
     $config_defaults = $this->get_default_config();
     foreach ($config as $key => $value) {
         if (empty($value)) {
             $config[$key] = $config_defaults[$key];
         }
     }
     $final_class = array('g1-simple-slider', 'g1-slider-not-ready', 'g1-simple-slider-' . $config['layout']);
     $final_class = array_merge($final_class, explode(' ', $args['class']));
     // Remove empty strings
     $final_class = array_filter($final_class);
     $final_class[] = 'g1-width-' . str_replace('g1_simple_slider_', '', $config['width']);
     $final_class[] = 'g1-nav-direction-' . $config['directionNavigation'];
     $final_class[] = 'g1-nav-coin-' . $config['coinNavigation'];
     $final_class[] = 'g1-fullscreen-' . $config['fullscreen'];
     $final_class[] = 'g1-progress-' . $config['progressBar'];
     // Install Simple Slider. Not every page needs to load additional javascrips
     add_action('wp_footer', 'g1_simple_slider_wp_footer');
     $out .= '<div id="' . esc_attr($args['id']) . '" class="' . sanitize_html_classes($final_class) . '" data-config="' . g1_data_capture($config) . '">';
     $out .= '<div class="g1-inner">';
     $out .= '<ol class="g1-slides">' . "\n";
     foreach ($slides as $i => $slide) {
         // Default slide configuration
         $x = array('layout' => 'default', 'width' => $args['width'], 'height' => $args['height']);
         // Cascade configuration
         $x = array_merge($x, $slide);
         // Check for an empty link
         $x['linking'] = strlen($x['link']) ? $x['linking'] : 'none';
         $media = '<img src="' . esc_url($x['src']) . '" ' . 'width="' . absint($x['width']) . '" ' . 'height="' . absint($x['height']) . '" ' . 'alt="' . esc_url($x['src']) . '" ' . '/>';
         switch ($x['linking']) {
             case 'none':
                 break;
             case 'new_window':
             case 'new-window':
                 $media = '<a href="' . esc_url($x['link']) . '" class="g1-new-window">' . do_shortcode('[indicator type="new-window"]') . $media . '</a>';
                 break;
             case 'lightbox':
                 $media = '<a href="' . esc_url($x['link']) . '">' . do_shortcode('[indicator type="zoom"]') . $media . '</a>';
                 break;
             default:
                 $media = '<a href="' . esc_url($x['link']) . '">' . do_shortcode('[indicator type="document"]') . $media . '</a>';
                 break;
         }
         $media = '<div>' . $media . '</div>';
         $desc = '';
         if (strlen($x['title'] || strlen($x['content']))) {
             $desc .= '<figcaption>' . "\n" . '<div class="g1-slide__title">' . '<div class="g1-h1">' . $x['title'] . '</div>' . '<div class="g1-background"></div>' . '</div>' . '<div class="g1-slide__description">' . '<div class="g1-h3">' . do_shortcode($x['content']) . '</div>' . '<div class="g1-background"></div>' . '</div>' . '</figcaption>' . "\n";
         }
         $final_class = array('g1-slide');
         if (0 == $i) {
             $final_class[] = 'g1-selected';
         }
         $out .= '<li class="' . sanitize_html_classes($final_class) . '" data-g1-linking="' . esc_attr($x['linking']) . '">' . "\n" . '<figure>' . "\n" . $media . $desc . '</figure>' . "\n" . '</li>' . "\n";
     }
     $out .= '</ol>' . "\n";
     if ('none' !== $config['coinNavigation']) {
         // thumbnails
         $out .= '<ol class="g1-nav-coin">' . "\n";
         foreach ($slides as $slide) {
             $thumb = wp_get_attachment_image_src($slide['id'], 'g1_one_twelfth');
             if ($thumb) {
                 $src = $thumb[0];
                 $width = $thumb[1];
                 $height = $thumb[2];
                 $out .= '<li>' . "\n";
                 $out .= '<a>' . "\n";
                 $out .= '<img src="' . esc_url($src) . '" width="' . absint($width) . '" height="' . absint($height) . '" />' . "\n";
                 $out .= '</a>' . "\n";
                 $out .= '</li>' . "\n";
             }
         }
         $out .= '</ol>' . "\n";
     }
     $out .= '</div>' . "\n";
     $out .= '</div><!-- END .g1-slider -->';
     return $out;
 }
Example #2
0
 /**
  * Shortcode callback function.
  *
  * @return string
  */
 protected function do_shortcode()
 {
     extract($this->extract());
     // Compose final HTML id attribute
     $final_id = strlen($id) ? $id : 'g1-gmap-counter-' . $this->get_counter();
     // Compose final HTML class attribute
     $final_class = array('g1-gmap');
     add_action('wp_footer', array($this, 'enqueue_scripts'));
     if (!$width) {
         $width = '100%';
     }
     if (!$height) {
         return '';
     }
     $inline_style = ' style="width: ' . esc_attr($width) . '; height: ' . esc_attr($height) . ';"';
     $config = array('map_type' => !empty($map_type) ? $map_type : 'roadmap', 'invert_lightness' => $invert_lightness, 'latitude' => $latitude, 'longitude' => $longitude, 'zoom' => !empty($zoom) ? $zoom : 15, 'marker' => !empty($marker) ? $marker : 'none', 'marker_icon' => !empty($marker_icon) ? $marker_icon : '', 'type' => $type);
     if (!empty($color)) {
         $colorObj = new G1_Color($color);
         $colorConfig = array('color' => $color, 'color_hue' => '#' . $colorObj->get_hex(), 'color_saturation' => ($colorObj->get_saturation() - 50) * 2, 'color_lightness' => ($colorObj->get_lightness() - 50) * 2);
         $config = array_merge($config, $colorConfig);
     }
     $data_attr = ' data-g1-gmap-config="' . g1_data_capture($config) . '"';
     // Compose output
     $out = '<div class="g1-gmap-wrapper">' . "\n";
     $out .= '<div id="' . esc_attr($final_id) . '" class="' . sanitize_html_classes($final_class) . '"' . $data_attr . $inline_style . '>' . "\n";
     $out .= '<div class="g1-gmap-content" style="display: none;">';
     $out .= $content;
     $out .= '</div>';
     $out .= '</div>';
     $out .= '</div>' . "\n";
     return $out;
 }
Example #3
0
function g1_data_render($data)
{
    echo g1_data_capture($data);
}
Example #4
0
 /**
  * Shortcode callback function.
  *
  * @return string
  */
 protected function do_shortcode()
 {
     extract($this->extract());
     $value = absint($value);
     if ($value < 0) {
         $value = 0;
     }
     if ($value > 100) {
         $value = 100;
     }
     $final_id = strlen($id) ? $id : 'g1-progress-circle-' . $this->get_counter();
     $final_class = array('g1-progress-circle', 'g1-progress-circle--' . $style);
     $final_class = array_merge($final_class, explode(' ', $class));
     $config = array();
     add_action('wp_footer', array($this, 'enqueue_scripts'));
     $css = '';
     switch ($style) {
         case 'simple':
             if (strlen($text_color)) {
                 $color = new G1_Color($text_color);
                 $css .= '#' . esc_attr($final_id) . '.g1-progress-circle {' . "\n" . 'color: #' . $color->get_hex() . ';' . "\n" . '}' . "\n";
             }
             if (strlen($bg_color)) {
                 $color = new G1_Color($bg_color);
                 $config['barColor'] = '#' . $color->get_hex();
             }
             break;
         case 'solid':
             if (strlen($text_color)) {
                 $color = new G1_Color($text_color);
                 $css .= '#' . esc_attr($final_id) . '.g1-progress-circle {' . "\n" . 'color: #' . $color->get_hex() . ';' . "\n" . '}' . "\n";
                 $config['barColor'] = '#' . $color->get_hex();
             }
             if (strlen($bg_color)) {
                 $color = new G1_Color($bg_color);
                 $config['bgColor'] = '#' . $color->get_hex();
             }
             break;
     }
     $icon = strlen($icon) ? '<i class="icon-' . sanitize_html_class($icon) . ' g1-progress-circle__icon"></i>' : '%';
     $out = '%css%<div id="%id%" class="%class%" data-config="%data_config%" data-percent="%percent%">%content%</div>';
     $out = str_replace(array('%css%', '%id%', '%class%', '%data_config%', '%percent%', '%content%'), array(strlen($css) ? "\n" . '<style type="text/css" scoped="scoped">' . $css . '</style>' . "\n" : '', esc_attr($final_id), sanitize_html_classes($final_class), g1_data_capture($config), esc_attr($value), '<span class="g1-progress-circle__value">' . esc_html($value) . '</span>' . $icon . '<div class="g1-color-scheme"></div>'), $out);
     return $out;
 }