示例#1
0
 /**
  * Generator button
  */
 public static function button($args = array())
 {
     // Check access.
     if (!self::access_check()) {
         return;
     }
     // Prepare button target.
     $target = is_string($args) ? $args : 'content';
     // Prepare args.
     $args = wp_parse_args($args, array('target' => $target, 'text' => __('Insert shortcode', 'cherry-shortcodes'), 'class' => 'button', 'icon' => '<span class="dashicons dashicons-editor-code" style="width:18px; height:18px; vertical-align:text-top; margin: 0 2px; color: #82878c;"></span>', 'echo' => true, 'shortcode' => false));
     // Print button.
     $button = '<a href="javascript:void(0);" class="cherry-generator-button ' . $args['class'] . '" title="' . $args['text'] . '" data-target="' . $args['target'] . '" data-mfp-src="#cherry-generator" data-shortcode="' . (string) $args['shortcode'] . '">' . $args['icon'] . '&nbsp;' . $args['text'] . '</a>';
     // Show generator popup.
     add_action('wp_footer', array(__CLASS__, 'popup'));
     add_action('admin_footer', array(__CLASS__, 'popup'));
     // Request assets.
     wp_enqueue_media();
     $admin_styles = apply_filters('cherry_shortcodes_admin_styles', array('simple-slider', 'farbtastic', 'magnific-popup', 'font-awesome', 'cherry-shortcodes-all', 'cherry-shortcodes-generator'));
     cherry_query_asset('css', $admin_styles);
     cherry_query_asset('js', array('jquery', 'jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-mouse', 'simple-slider', 'farbtastic', 'magnific-popup', 'cherry-shortcodes-generator'));
     // Print/return result
     if ($args['echo']) {
         echo $button;
     }
     return $button;
 }
示例#2
0
 public static function get_icon($args)
 {
     $args = wp_parse_args($args, array('icon' => '', 'size' => '', 'color' => '', 'style' => ''));
     // Check for icon param
     if (!$args['icon']) {
         return;
     }
     // Add trailing ; to the style param
     if ($args['style']) {
         $args['style'] = rtrim($args['style'], ';') . ';';
     }
     // Font Awesome icon
     if (strpos($args['icon'], 'icon:') !== false) {
         // Add size
         if ($args['size']) {
             $args['style'] .= 'font-size:' . $args['size'] . 'px;';
         }
         // Add color
         if ($args['color']) {
             $args['style'] .= 'color:' . $args['color'] . ';';
         }
         // Query font-awesome stylesheet
         cherry_query_asset('css', 'font-awesome');
         // Return icon
         return '<i class="fa fa-' . trim(str_replace('icon:', '', $args['icon'])) . '" style="' . $args['style'] . '"></i>';
     } elseif (strpos($args['icon'], '/') !== false) {
         // Add size
         if ($args['size']) {
             $args['style'] .= 'width:' . $args['size'] . 'px;height:' . $args['size'] . 'px;';
         }
         // Return icon
         return '<img src="' . $args['icon'] . '" alt="" style="' . $args['style'] . '" />';
     }
     // Icon is not detected
     return false;
 }
 public static function video_preview($atts = null, $content)
 {
     $atts = shortcode_atts(array('poster' => '', 'source' => '', 'control' => 'show', 'show_content_on_hover' => 'no', 'muted' => 'no', 'loop' => 'no', 'preload' => 'no', 'width' => '', 'height' => '', 'custom_class' => ''), $atts, 'video_preview');
     $video_preview_class = apply_filters('cherry_video_preview_class', array('class_1' => 'fa-play', 'class_2' => 'fa-pause', 'class_3' => 'fa-volume-off', 'class_4' => 'fa-volume-up'));
     $video_preview_text = apply_filters('cherry_video_preview_texts', array('text_1' => '', 'text_2' => '', 'text_3' => '', 'text_4' => ''));
     extract($atts);
     $type = strtolower(preg_replace('/(^(http(s)?:)?(\\/\\/)(www.)?)|(([.]\\D{2,5})?\\/[\\S]+)/', '', $source));
     $is_mobile = wp_is_mobile() ? 'true' : 'false';
     if ($type === 'youtube') {
         cherry_query_asset('js', 'video-youtube');
         global $video_preview_count;
         $video_preview_count += 1;
         $video_id = preg_replace('/[\\S.]+\\/[\\S.]+[=]|[\\S.]+\\//', '', $source);
         if ($poster) {
             $poster = '<div style="background-image: url(\'' . $poster . '\')" class="cherry-video-poster"></div>';
         }
         $video_tag = '<div id="cherry-youtube-' . $video_preview_count . '" class="youtube-player" data-video="' . $video_id . '"></div>' . $poster . '<div class="youtube-player-cap"></div>';
     } else {
         if ($type === 'vimeo') {
             $video_id = preg_replace('/([\\S.]+\\/)/', '', $source);
             $response = Cherry_Shortcodes_Tools::remote_query('https://player.vimeo.com/video/' . $video_id . '/config');
             if ($response) {
                 $file_codes = $response->request->files->codecs[0];
                 if (strpos($custom_class, 'full-width') !== false && $is_mobile === 'false') {
                     $poster_size = '1280';
                     $source = $response->request->files->{$file_codes}->hd->url;
                 } else {
                     $poster_size = '640';
                     $source = $response->request->files->{$file_codes}->sd->url;
                 }
                 if (!$poster) {
                     $poster = $response->video->thumbs->{$poster_size};
                 }
             }
         }
         $poster = $poster ? '<div style="background-image: url(\'' . $poster . '\')" class="cherry-video-poster"></div>' : '';
         $muted_attr = $muted !== 'no' ? 'muted ' : '';
         $loop_attr = $loop !== 'no' ? 'loop ' : '';
         $preload_attr = $preload !== 'no' ? 'preload="auto" ' : '';
         $autoplay_attr = $control === 'autoplay' ? 'autoplay ' : '';
         $video_tag = $poster;
         $video_tag .= '<video ' . $autoplay_attr . $muted_attr . $loop_attr . $preload_attr . ' width="100%" height="auto" >';
         $video_tag .= '<source src="' . $source . '" type="video/mp4">';
         $video_tag .= '</video>';
     }
     $control_tag = '';
     if ($control !== 'hide' && $control !== 'play-on-hover' && $control !== 'autoplay') {
         $control_class = $control === 'show-on-hover' ? 'hidden-element' : '';
         $control_tag .= '<div class="video-preview-controls ' . $control_class . '">';
         $control_tag .= '<button class="play-pause fa ' . $video_preview_class['class_1'] . '" data-class="' . $video_preview_class['class_1'] . '" data-sub-class="' . $video_preview_class['class_2'] . '" data-text="' . __($video_preview_text['text_1'], 'cherry-shortcodes') . '" data-sub-text="' . __($video_preview_text['text_2'], 'cherry-shortcodes') . '" type="button">' . __($video_preview_text['text_1'], 'cherry-shortcodes') . '</button>';
         $control_tag .= '<button class="mute fa ' . $video_preview_class['class_3'] . '" data-class="' . $video_preview_class['class_3'] . '" data-sub-class="' . $video_preview_class['class_4'] . '" data-text="' . __($video_preview_text['text_3'], 'cherry-shortcodes') . '" data-sub-text="' . __($video_preview_text['text_4'], 'cherry-shortcodes') . '" type="button">' . __($video_preview_text['text_3'], 'cherry-shortcodes') . '</button>';
         $control_tag .= '</div>';
     }
     $content_tag = '';
     if ($content) {
         $content_class = $show_content_on_hover !== 'no' ? 'class="hidden-element"' : '';
         $content_tag .= '<figcaption ' . $content_class . ' >' . do_shortcode($content) . '</figcaption>';
     }
     $output = apply_filters('cherry_video_preview_before', '');
     $output .= '<figure class="video-preview ' . $custom_class . '" data-settings=\'{"control":"' . $control . '", "muted":"' . $muted . '", "loop":"' . $loop . '", "preload":"' . $preload . '", "type":"' . $type . '", "is_mobile":"' . $is_mobile . '"}\' >';
     $output .= '<div class="video-holder">';
     $output .= '<div class="video-inner-holder">';
     $output .= $video_tag;
     $output .= $control_tag;
     $output .= '</div>';
     $output .= '</div>';
     $output .= $content_tag;
     $output .= '</figure>';
     $output .= apply_filters('cherry_video_preview_after', '');
     if ($type === 'youtube') {
         cherry_query_asset('js', 'video-youtube');
     }
     cherry_query_asset('js', 'video-preview');
     return apply_filters('cherry_shortcodes_output', $output, $atts, 'video_preview');
 }
 public function mpce_cherry4_scripts()
 {
     wp_register_script('mpce-cherry-controller', plugins_url('controller.js', __FILE__), array('jquery'), '1.0', true);
     wp_localize_script('mpce-cherry-controller', 'mpce_cherry4_prefix', $this->prefix);
     wp_enqueue_script('mpce-cherry-controller');
     //assets
     cherry_query_asset('js', 'cherry-shortcodes-init');
     cherry_query_asset('js', array('swiper', 'cherry-shortcodes-init'));
     cherry_query_asset('js', 'cherry-shortcodes');
     cherry_query_asset('js', array('cherry-google-map', 'cherry-shortcodes-init'));
     cherry_query_asset('js', 'cherry-parallax');
     cherry_query_asset('js', array('jquery-counterup', 'cherry-shortcodes-init'));
     cherry_query_asset('js', 'cherry-lazy-load-effect');
     cherry_query_asset('css', 'font-awesome');
 }
示例#5
0
 /**
  * Builds the Countdown shortcode output.
  *
  * @since  1.0.7
  * @param  array  $atts    Attributes of the countdown shortcode.
  * @param  string $content Shortcode content.
  * @return string          HTML content to display the countdown.
  */
 public static function countdown($atts = null, $content = null)
 {
     $atts = shortcode_atts(array('start_date' => date('d/n/Y'), 'countdown_date' => '25/10/2020', 'countdown_hour' => 0, 'countdown_minutes' => 0, 'countdown_seconds' => 0, 'show_year' => 'yes', 'show_month' => 'yes', 'show_week' => 'yes', 'show_day' => 'yes', 'show_hour' => 'yes', 'show_minute' => 'yes', 'show_second' => 'yes', 'circle_mode' => 'yes', 'item_size' => 100, 'stroke_width' => 3, 'stroke_color' => 3, 'custom_class' => ''), $atts, 'counter');
     $start_date_array = explode('/', $atts['start_date']);
     $final_date_array = explode('/', $atts['countdown_date']);
     $countdown_hour = (string) $atts['countdown_hour'];
     $countdown_minutes = (string) $atts['countdown_minutes'];
     $countdown_seconds = (string) $atts['countdown_seconds'];
     $show_year = (bool) ('yes' === $atts['show_year']) ? true : false;
     $show_month = (bool) ('yes' === $atts['show_month']) ? true : false;
     $show_week = (bool) ('yes' === $atts['show_week']) ? true : false;
     $show_day = (bool) ('yes' === $atts['show_day']) ? true : false;
     $show_hour = (bool) ('yes' === $atts['show_hour']) ? true : false;
     $show_minute = (bool) ('yes' === $atts['show_minute']) ? true : false;
     $show_second = (bool) ('yes' === $atts['show_second']) ? true : false;
     $circle_mode = (bool) ('yes' === $atts['circle_mode']) ? true : false;
     $item_size = (int) $atts['item_size'];
     $stroke_width = (int) $atts['stroke_width'];
     $stroke_color = esc_attr($atts['stroke_color']);
     $countdown_content = do_shortcode($content);
     $custom_class = sanitize_text_field($atts['custom_class']);
     $custom_class = !'' == $custom_class ? ' ' . $custom_class : $custom_class;
     $data_attr_line = 'data-start-date="' . $atts['start_date'] . '"';
     $data_attr_line .= ' data-final-date="' . $atts['countdown_date'] . '"';
     $data_attr_line .= ' data-hour="' . $countdown_hour . '"';
     $data_attr_line .= ' data-minutes="' . $countdown_minutes . '"';
     $data_attr_line .= ' data-seconds="' . $countdown_seconds . '"';
     $data_attr_line .= ' data-size="' . $item_size . '"';
     $data_attr_line .= ' data-stroke-width="' . $stroke_width . '"';
     $data_attr_line .= ' data-stroke-color="' . $stroke_color . '"';
     $utc_time = gmdate("d/n/Y H:i:s");
     $data_attr_line .= ' data-stroke-color="' . $stroke_color . '"';
     $data_attr_line .= ' data-utc-time="' . $utc_time . '"';
     $countdown_settings = array('year' => array('solus_title' => __('Year', 'cherry-shortcodes'), 'plural_title' => __('Years', 'cherry-shortcodes'), 'show' => $show_year), 'month' => array('solus_title' => __('Month', 'cherry-shortcodes'), 'plural_title' => __('Months', 'cherry-shortcodes'), 'show' => $show_month), 'week' => array('solus_title' => __('Week', 'cherry-shortcodes'), 'plural_title' => __('Weeks', 'cherry-shortcodes'), 'show' => $show_week), 'day' => array('solus_title' => __('Day', 'cherry-shortcodes'), 'plural_title' => __('Days', 'cherry-shortcodes'), 'show' => $show_day), 'hour' => array('solus_title' => __('Hour', 'cherry-shortcodes'), 'plural_title' => __('Hours', 'cherry-shortcodes'), 'show' => $show_hour), 'minute' => array('solus_title' => __('Minute', 'cherry-shortcodes'), 'plural_title' => __('Minutes', 'cherry-shortcodes'), 'show' => $show_minute), 'second' => array('solus_title' => __('Second', 'cherry-shortcodes'), 'plural_title' => __('Seconds', 'cherry-shortcodes'), 'show' => $show_second));
     $html = '<div class="countdown-wrapper">';
     $html .= '<div class="countdown-timer" ' . $data_attr_line . '>';
     foreach ($countdown_settings as $item => $item_settings) {
         if ($item_settings['show']) {
             $html .= '<div class="countdown-item ' . $item . '" data-solus="' . $item_settings['solus_title'] . '" data-plural="' . $item_settings['plural_title'] . '">';
             if ($circle_mode) {
                 $html .= '<svg class="circle-progress" width="' . $item_size . '" height="' . $item_size . '" viewPort="0 0 ' . $item_size . ' ' . $item_size . '" version="1.1" xmlns="http://www.w3.org/2000/svg">';
                 $delta_radius = $item_size / 2 - $stroke_width / 2;
                 $html .= '<circle class="border" r="' . $delta_radius . '" cx="' . $item_size / 2 . '" cy="' . $item_size / 2 . '" fill="transparent" ></circle>';
                 $html .= '<circle class="circle" r="' . $delta_radius . '" cx="' . $item_size / 2 . '" cy="' . $item_size / 2 . '" fill="transparent" ></circle>';
                 $html .= '</svg>';
             }
             $html .= '<div class="countdown-info">';
             $html .= '<div class="inner">';
             $html .= '<span class="value"></span>';
             $html .= '<span class="title"></span>';
             $html .= '</div>';
             $html .= '</div>';
             $html .= '</div>';
         }
     }
     $html .= '</div>';
     $html .= '<div class="countdown-content">';
     $html .= $countdown_content;
     $html .= '</div>';
     $html .= '</div>';
     cherry_query_asset('js', array('jquery-countdown', 'cherry-shortcodes-init'));
     return apply_filters('cherry_shortcodes_output', $html, $atts, 'countdown');
 }
 /**
  * Callback-function for [row], [row_inner] shortcode.
  */
 public function row($atts = null, $content = null)
 {
     $original_atts = $atts;
     $atts = shortcode_atts(array('type' => 'full-width', 'bg_type' => 'none', 'anchor' => '', 'class' => '', 'preset' => '', 'bg_color' => '', 'bg_image' => '', 'bg_position' => 'center', 'bg_repeat' => 'no-repeat', 'bg_attachment' => 'scroll', 'bg_size' => 'auto', 'speed' => '1.5', 'invert' => 'no', 'min_height' => '300', 'poster' => '', 'mp4' => '', 'webm' => '', 'ogv' => ''), $atts, 'row');
     $type = sanitize_key($atts['type']);
     $bg_type = sanitize_key($atts['bg_type']);
     $class = 'fixed-width' == $type ? '' : cherry_esc_class_attr($atts);
     $anchor_data = '';
     $row_class = apply_filters('cherry_shortcodes_output_row_class', 'row', $atts);
     $output = false;
     $id = '';
     $anchor_data = '';
     if ($atts['anchor']) {
         $anchor = preg_replace('/[^A-Za-z0-9-_]/', '', $atts['anchor']);
         $anchor = str_replace(' ', '-', $anchor);
         $id = 'data-id="' . $anchor . '" ';
         $anchor_data = 'data-anchor="true"';
         wp_localize_script('page-anchor', 'anchor_scroll_speed', array(apply_filters('cherry_anchor_scroll_speed', 300)));
         cherry_query_asset('js', 'page-anchor');
     }
     $container = 'fixed-width' == $type ? '<div class="container"><div class="%2$s">%1$s</div></div>' : '<div class="container-fluid"><div class="%2$s">%1$s</div></div>';
     $default_bg_type = false;
     switch ($bg_type) {
         case 'image':
             $_atts = $atts;
             if (!empty($_atts['class'])) {
                 $_atts['class'] = '';
             }
             $_content = Cherry_Shortcodes_Handler::box($_atts, sprintf($container, $content, $row_class));
             break;
         case 'parallax_image':
             if (!empty($original_atts['image_src'])) {
                 $atts['bg_image'] = $original_atts['image_src'];
             }
             if (!empty($original_atts['parallax_speed'])) {
                 $atts['speed'] = $original_atts['parallax_speed'];
             }
             if (!empty($original_atts['parallax_invert'])) {
                 $atts['invert'] = $original_atts['parallax_invert'];
             }
             $_content = Cherry_Shortcodes_Handler::paralax_image($atts, sprintf($container, $content, $row_class));
             break;
         case 'parallax_video':
             $_content = Cherry_Shortcodes_Handler::paralax_html_video($atts, sprintf($container, $content, $row_class));
             break;
         default:
             $default_bg_type = true && 'full-width' == $type;
             $container = 'fixed-width' == $type ? '<div class="container"><div class="%2$s">%1$s</div></div>' : '%s';
             $_content = sprintf($container, do_shortcode($content), $row_class);
             break;
     }
     $output = '<div class="' . ($default_bg_type ? $row_class : 'row') . cherry_esc_class_attr($atts) . '" ' . $id . $anchor_data . '>' . $_content . '</div>';
     return apply_filters('cherry_shortcodes_output', $output, $atts, 'row');
 }