function x_shortcode_creative_cta($atts) { // 1 extract(shortcode_atts(array('id' => '', 'class' => '', 'style' => '', 'padding' => '', 'text' => '', 'font_size' => '', 'icon' => '', 'icon_size' => '', 'image' => '', 'image_width' => '', 'animation' => '', 'link' => '', 'color' => '', 'bg_color' => '', 'bg_color_hover' => ''), $atts, 'x_creative_cta')); $id = $id != '' ? 'id="' . esc_attr($id) . '"' : ''; $class = $class != '' ? 'x-creative-cta ' . esc_attr($class) : 'x-creative-cta'; $style = $style != '' ? ' ' . $style : ''; $padding = $padding != '' ? $padding : '35px'; $text = $text != '' ? wp_specialchars_decode($text, ENT_QUOTES) : 'Place Your<br>Text Here'; $font_size = $font_size != '' ? $font_size : '36px'; $icon = $icon != '' ? $icon : ''; $icon_size = $icon_size != '' ? $icon_size : '36px'; $image = $image != '' ? $image : ''; $image_width = $image_width != '' ? $image_width : ''; $animation = $animation != '' ? ' ' . $animation : ''; $link = $link != '' ? $link : '#'; $color = $color != '' ? $color : '#ffffff'; $bg_color = $bg_color != '' ? $bg_color : '#ff2a13'; $bg_color_hover = $bg_color_hover != '' ? $bg_color_hover : '#d80f0f'; if ($animation != '') { if ($image != '') { $graphic = '<span class="graphic"><img style="margin: 0; width: ' . $image_width . ';" src="' . $image . '"></span>'; } else { if ($icon != '') { $graphic = '<span class="graphic"><i style="margin: 0; font-size: ' . $icon_size . ';" class="x-icon-' . $icon . '" data-x-icon="&#x' . fa_unicode($icon) . ';"></i></span>'; } } } else { $graphic = ''; } $js_params = array('animation' => $animation, 'bg_color' => $bg_color, 'bg_color_hover' => $bg_color_hover); $data = cs_generate_data_attributes('creative_cta', $js_params); $output = "<a {$id} class=\"{$class}{$animation}\" href=\"{$link}\" style=\"padding: {$padding}; color: {$color}; background-color: {$bg_color};{$style}\" {$data}>" . "<span class=\"text\" style=\"font-size: {$font_size};\">{$text}</span>" . $graphic . "</a>"; return $output; }
function x_shortcode_responsive_text($atts) { extract(shortcode_atts(array('selector' => '', 'compression' => '1.2', 'min_size' => '', 'max_size' => ''), $atts, 'x_responsive_text')); $js_params = array('selector' => $selector != '' ? $selector : '', 'compression' => $compression != '' ? $compression : '1.2', 'minFontSize' => $min_size != '' ? $min_size : '', 'maxFontSize' => $max_size != '' ? $max_size : ''); static $count = 0; $count++; $data = cs_generate_data_attributes('responsive_text', $js_params); $output = "<span id=\"x-responsive-text-{$count}\" {$data}></span>"; return $output; }
function x_shortcode_lightbox($atts) { extract(shortcode_atts(array('selector' => '', 'deeplink' => '', 'opacity' => '', 'prev_scale' => '', 'prev_opacity' => '', 'next_scale' => '', 'next_opacity' => '', 'orientation' => '', 'thumbnails' => ''), $atts, 'x_lightbox')); static $count = 0; $count++; wp_enqueue_script('vendor-ilightbox'); $js_params = array('selector' => $selector != '' ? $selector : '.x-img-link', 'deeplink' => $deeplink == 'true', 'opacity' => $opacity != '' ? $opacity : '0.85', 'prevScale' => $prev_scale != '' ? $prev_scale : '0.85', 'prevOpacity' => $prev_opacity != '' ? $prev_opacity : '0.65', 'nextScale' => $next_scale != '' ? $next_scale : '0.85', 'nextOpacity' => $next_opacity != '' ? $next_opacity : '0.65', 'orientation' => $orientation != '' ? $orientation : 'horizontal', 'thumbnails' => $thumbnails == 'true'); $data = cs_generate_data_attributes('lightbox', $js_params); $output = "<span id=\"x-lightbox-{$count}\" {$data}></span>"; return $output; }
function x_shortcode_feature_list($atts, $content = null) { extract(shortcode_atts(array('id' => '', 'class' => '', 'style' => '', 'animation_offset' => '', 'animation_delay_initial' => '', 'animation_delay_between' => ''), $atts, 'x_feature_list')); $id = $id != '' ? 'id="' . esc_attr($id) . '"' : ''; $class = $class != '' ? 'x-feature-list ' . esc_attr($class) : 'x-feature-list'; $style = $style != '' ? 'style="' . $style . '"' : ''; $animation_offset = $animation_offset != '' ? $animation_offset : '50'; $animation_delay_initial = $animation_delay_initial != '' ? $animation_delay_initial : '0'; $animation_delay_between = $animation_delay_between != '' ? $animation_delay_between : '300'; $data = cs_generate_data_attributes('feature_list', array('animationOffset' => $animation_offset, 'animationDelayInitial' => $animation_delay_initial, 'animationDelayBetween' => $animation_delay_between)); $output = "<ul {$id} class=\"{$class}\" {$style} {$data}>" . do_shortcode($content) . '</ul>'; return $output; }
function x_shortcode_slider($atts, $content = null) { extract(shortcode_atts(array('id' => '', 'class' => '', 'style' => '', 'animation' => '', 'slide_time' => '', 'slide_speed' => '', 'slideshow' => '', 'random' => '', 'control_nav' => '', 'prev_next_nav' => '', 'no_container' => '', 'touch' => ''), $atts, 'x_slider')); static $count = 0; $count++; $id = $id != '' ? 'id="' . esc_attr($id) . '"' : ''; $class = $class != '' ? "x-flexslider-shortcode-container " . esc_attr($class) : "x-flexslider-shortcode-container"; $style = $style != '' ? 'style="' . $style . '"' : ''; $no_container = $no_container == 'true' ? '' : ' with-container'; $js_params = array('animation' => $animation == 'fade' ? 'fade' : 'slide', 'slideTime' => $slide_time != '' ? $slide_time : '7000', 'slideSpeed' => $slide_speed != '' ? $slide_speed : '600', 'controlNav' => $control_nav == 'true', 'prevNextNav' => $prev_next_nav == 'true', 'slideshow' => $slideshow == 'true', 'random' => $random == 'true', 'touch' => $touch != 'false'); $data = cs_generate_data_attributes('slider', $js_params); $output = "<div class=\"{$class}{$no_container}\">" . "<div {$id} class=\"x-flexslider x-flexslider-shortcode x-flexslider-shortcode-{$count}\" {$data} {$style}>" . '<ul class="x-slides">' . do_shortcode($content) . '</ul>' . '</div>' . '</div>'; return $output; }
function x_shortcode_text_type($atts) { extract(shortcode_atts(array('id' => '', 'class' => '', 'style' => '', 'prefix' => '', 'strings' => '', 'suffix' => '', 'type_speed' => '', 'start_delay' => '', 'back_speed' => '', 'back_delay' => '', 'loop' => '', 'show_cursor' => '', 'cursor' => '', 'tag' => '', 'looks_like' => ''), $atts, 'x_text_type')); $id = $id != '' ? 'id="' . esc_attr($id) . '"' : ''; $class = $class != '' ? 'x-text-type ' . esc_attr($class) : 'x-text-type'; $style = $style != '' ? 'style="' . $style . '"' : ''; $prefix = $prefix != '' ? '<span class="prefix">' . $prefix . '</span>' : ''; $suffix = $suffix != '' ? '<span class="suffix">' . $suffix . '</span>' : ''; $tag = $tag != '' ? $tag : 'span'; $looks_like = $looks_like != '' ? ' ' . $looks_like : ''; $js_params = array('strings' => $strings != '' ? explode('|', $strings) : '', 'type_speed' => $type_speed != '' ? intval($type_speed) : 50, 'start_delay' => $start_delay != '' ? intval($start_delay) : 0, 'back_speed' => $back_speed != '' ? intval($back_speed) : 50, 'back_delay' => $back_delay != '' ? intval($back_delay) : 1000, 'loop' => $loop == 'true', 'show_cursor' => $show_cursor == 'true', 'cursor' => $cursor != '' ? $cursor : '|'); $data = cs_generate_data_attributes('text_type', $js_params); $output = "<{$tag} {$id} class=\"{$class}{$looks_like}\" {$style} {$data}>" . $prefix . '<span class="text"></span>' . $suffix . "</{$tag}>"; return $output; }
function x_shortcode_google_map_marker($atts) { extract(shortcode_atts(array('lat' => '', 'lng' => '', 'info' => '', 'image' => ''), $atts, 'x_google_map_marker')); $js_params = array('lat' => $lat != '' ? $lat : '40.7056308', 'lng' => $lng != '' ? $lng : '-73.9780035', 'markerInfo' => $info != '' ? $info : ''); if (is_numeric($image)) { $image_info = wp_get_attachment_image_src($image, 'full'); $js_params['image'] = $image_info[0]; } else { if ($image != '') { $js_params['image'] = $image; } } $data = cs_generate_data_attributes('google_map_marker', $js_params); $output = "<div class=\"x-google-map-marker\" style=\"position: absolute; visibility: hidden;\" {$data}></div>"; return $output; }
function x_shortcode_audio_player($atts) { extract(shortcode_atts(array('id' => '', 'class' => '', 'style' => '', 'src' => '', 'advanced_controls' => '', 'preload' => '', 'autoplay' => '', 'loop' => '', 'mp3' => '', 'oga' => ''), $atts, 'x_audio_player')); $id = $id != '' ? 'id="' . esc_attr($id) . '"' : ''; $class = $class != '' ? 'x-audio player ' . esc_attr($class) : 'x-audio player'; $style = $style != '' ? 'style="' . $style . '"' : ''; $src = $src != '' ? explode('|', $src) : array(); $advanced_controls = $advanced_controls == 'true' ? ' advanced-controls' : ''; $preload = $preload != '' ? ' preload="' . $preload . '"' : ' preload="metadata"'; $autoplay = $autoplay == 'true' ? ' autoplay' : ''; $loop = $loop == 'true' ? ' loop' : ''; // // Deprecated parameters. // $mp3 = $mp3 != '' ? '<source src="' . $mp3 . '" type="audio/mpeg">' : ''; $oga = $oga != '' ? '<source src="' . $oga . '" type="audio/ogg">' : ''; // // Variable markup. // $data = cs_generate_data_attributes('x_mejs'); // // Enqueue scripts. // wp_enqueue_script('mediaelement'); // // Build sources. // $sources = array(); foreach ($src as $file) { $mime = wp_check_filetype($file, wp_get_mime_types()); $sources[] = '<source src="' . esc_url($file) . '" type="' . $mime['type'] . '">'; } if ($mp3 != '') { $sources[] = $mp3; } if ($oga != '') { $sources[] = $oga; } // // Markup. // $output = "<div {$id} class=\"{$class}{$autoplay}{$loop}\" {$data} {$style}>" . "<audio class=\"x-mejs{$advanced_controls}\"{$preload}{$autoplay}{$loop}>" . implode('', $sources) . '</audio>' . '</div>'; return $output; }
function x_shortcode_skill_bar($atts) { extract(shortcode_atts(array('id' => '', 'class' => '', 'style' => '', 'heading' => '', 'bar_text' => '', 'bar_bg_color' => '', 'percent' => ''), $atts, 'x_skill_bar')); $id = $id != '' ? 'id="' . esc_attr($id) . '"' : ''; $class = $class != '' ? 'x-skill-bar ' . esc_attr($class) : 'x-skill-bar'; $style = $style != '' ? ' ' . $style : ''; $heading = $heading != '' ? '<h6 class="h-skill-bar">' . $heading . '</h6>' : ''; $bar_text = $bar_text != '' ? $bar_text : ''; $bar_bg_color = $bar_bg_color != '' ? ' background-color: ' . $bar_bg_color . ';' : ''; $js_params = array('percent' => $percent != '' ? $percent : ''); $data = cs_generate_data_attributes('skill_bar', $js_params); if ($bar_text != '') { $bar_text = $bar_text; } else { $bar_text = $percent; } $output = "{$heading}<div {$id} class=\"{$class}\" {$data}><div class=\"bar\" style=\"{$style}{$bar_bg_color}\"><div class=\"percent\">{$bar_text}</div></div></div>"; return $output; }
function x_shortcode_card($atts) { extract(shortcode_atts(array('id' => '', 'class' => '', 'style' => '', 'animation' => '', 'center_vertically' => '', 'front_style' => '', 'front_icon' => '', 'front_icon_size' => '', 'front_icon_color' => '', 'front_image' => '', 'front_image_width' => '', 'front_title' => '', 'front_text' => '', 'back_style' => '', 'back_title' => '', 'back_text' => '', 'back_button_enabled' => 'true', 'back_button_text' => '', 'back_button_link' => '', 'back_button_color' => '', 'back_button_bg_color' => '', 'padding' => ''), $atts, 'x_card')); $id = $id != '' ? 'id="' . esc_attr($id) . '"' : ''; $class = $class != '' ? 'x-card-outer ' . esc_attr($class) : 'x-card-outer'; $style = $style != '' ? 'style="' . $style . '"' : ''; $animation = $animation != '' ? ' ' . $animation : ' flip-from-left'; $center_vertically = $center_vertically == 'true' ? ' center-vertically' : ''; $front_style = $front_style != '' ? $front_style : 'border: 1px solid #ddd; color: #272727; background-color: #fafafa;'; $front_icon = $front_icon != '' ? $front_icon : ''; $front_icon_size = $front_icon_size != '' ? $front_icon_size : '36px'; $front_icon_color = $front_icon_color != '' ? $front_icon_color : '#272727'; $front_image = $front_image != '' ? $front_image : ''; $front_image_width = $front_image_width != '' ? $front_image_width : 'auto'; $front_title = $front_title != '' ? wp_specialchars_decode($front_title, ENT_QUOTES) : 'Front Title'; $front_text = $front_text != '' ? wp_specialchars_decode($front_text, ENT_QUOTES) : 'This is where the text for the front of your card should go. It\'s best to keep it short and sweet.'; $back_style = $back_style != '' ? $back_style : 'border: 1px solid #ddd; color: #272727; background-color: #fafafa;'; $back_title = $back_title != '' ? wp_specialchars_decode($back_title, ENT_QUOTES) : 'Back Title'; $back_text = $back_text != '' ? wp_specialchars_decode($back_text, ENT_QUOTES) : 'This is where the text for the back of your card should go.'; $back_button_text = $back_button_text != '' ? $back_button_text : 'Click Me!'; $back_button_link = $back_button_link != '' ? $back_button_link : '#'; $back_button_color = $back_button_color != '' ? $back_button_color : '#ffffff'; $back_button_bg_color = $back_button_bg_color != '' ? $back_button_bg_color : '#ff2a13'; $padding = $padding != '' ? $padding : '35px'; if ($front_image != '') { $front_graphic = '<div class="x-face-graphic"><img style="margin: 0; width: ' . $front_image_width . ';" src="' . $front_image . '"></div>'; } else { if ($front_icon != '') { $front_graphic = '<div class="x-face-graphic"><i style="margin: 0; font-size: ' . $front_icon_size . '; color: ' . $front_icon_color . ';" class="x-icon-' . $front_icon . '" data-x-icon="&#x' . fa_unicode($front_icon) . ';"></i></div>'; } else { $front_graphic = ''; } } $data = cs_generate_data_attributes('card', array()); $button_markup = ''; if ('true' == $back_button_enabled) { $button_markup = "<a class=\"x-face-button\" style=\"color: {$back_button_color}; background-color: {$back_button_bg_color};\" href=\"{$back_button_link}\">{$back_button_text}</a>"; } $output = "<div {$id} class=\"{$class}{$animation}{$center_vertically}\" {$data}{$style}>" . '<div class="x-card-inner">' . "<div class=\"x-face-outer front\" style=\"{$front_style}\">" . '<div class="x-face-inner">' . "<div class=\"x-face-content\" style=\"padding: {$padding};\">" . $front_graphic . "<h4 class=\"x-face-title\">{$front_title}</h4>" . "<p class=\"x-face-text\">{$front_text}</p>" . '</div>' . '</div>' . '</div>' . "<div class=\"x-face-outer back\" style=\"{$back_style}\">" . '<div class="x-face-inner">' . "<div class=\"x-face-content\" style=\"padding: {$padding};\">" . "<h4 class=\"x-face-title\">{$back_title}</h4>" . "<p class=\"x-face-text\">{$back_text}</p>" . $button_markup . '</div>' . '</div>' . '</div>' . '</div>' . '</div>'; return $output; }
function x_shortcode_recent_posts($atts) { extract(shortcode_atts(array('id' => '', 'class' => '', 'style' => '', 'type' => 'post', 'count' => '', 'category' => '', 'offset' => '', 'orientation' => '', 'no_sticky' => '', 'no_image' => '', 'fade' => ''), $atts, 'x_recent_posts')); $allowed_post_types = apply_filters('cs_recent_posts_post_types', array('post' => 'post')); $type = isset($allowed_post_types[$type]) ? $allowed_post_types[$type] : 'post'; $id = $id != '' ? 'id="' . esc_attr($id) . '"' : ''; $class = $class != '' ? 'x-recent-posts cf ' . esc_attr($class) : 'x-recent-posts cf'; $style = $style != '' ? 'style="' . $style . '"' : ''; $count = $count != '' ? $count : 3; $category = $category != '' ? $category : ''; $category_type = $type == 'post' ? 'category_name' : 'portfolio-category'; $offset = $offset != '' ? $offset : 0; $orientation = $orientation != '' ? ' ' . $orientation : ' horizontal'; $no_sticky = $no_sticky == 'true'; $no_image = $no_image == 'true' ? $no_image : ''; $fade = $fade == 'true' ? $fade : 'false'; $js_params = array('fade' => $fade == 'true'); $data = cs_generate_data_attributes('recent_posts', $js_params); $output = "<div {$id} class=\"{$class}{$orientation}\" {$style} {$data} data-fade=\"{$fade}\" >"; $q = new WP_Query(array('orderby' => 'date', 'post_type' => "{$type}", 'posts_per_page' => "{$count}", 'offset' => "{$offset}", "{$category_type}" => "{$category}", 'ignore_sticky_posts' => $no_sticky)); if ($q->have_posts()) { while ($q->have_posts()) { $q->the_post(); if ($no_image == 'true') { $image_output = ''; $image_output_class = 'no-image'; } else { $image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'entry-cropped'); $bg_image = $image[0] != '' ? ' style="background-image: url(' . $image[0] . ');"' : ''; $image_output = '<div class="x-recent-posts-img"' . $bg_image . '></div>'; $image_output_class = 'with-image'; } $output .= '<a class="x-recent-post' . $count . ' ' . $image_output_class . '" href="' . get_permalink(get_the_ID()) . '" title="' . esc_attr(sprintf(__('Permalink to: "%s"', csl18n()), the_title_attribute('echo=0'))) . '">' . '<article id="post-' . get_the_ID() . '" class="' . implode(' ', get_post_class()) . '">' . '<div class="entry-wrap">' . $image_output . '<div class="x-recent-posts-content">' . '<h3 class="h-recent-posts">' . get_the_title() . '</h3>' . '<span class="x-recent-posts-date">' . get_the_date() . '</span>' . '</div>' . '</div>' . '</article>' . '</a>'; } } wp_reset_postdata(); $output .= '</div>'; return $output; }
function x_shortcode_section($atts, $content = null) { extract(shortcode_atts(array('id' => '', 'class' => '', 'style' => '', 'bg_color' => '', 'bg_pattern' => '', 'bg_image' => '', 'bg_video' => '', 'bg_video_poster' => '', 'parallax' => ''), $atts, 'x_section')); static $count = 0; $count++; $id = $id != '' ? $id : 'x-section-' . $count; $class = $class != '' ? 'x-section ' . esc_attr($class) : 'x-section'; $style = $style != '' ? ' ' . $style : ''; $bg_color = $bg_color != '' ? $bg_color : 'transparent'; $bg_pattern = $bg_pattern != '' ? $bg_pattern : ''; $bg_image = $bg_image != '' ? $bg_image : ''; $bg_video = $bg_video != '' ? $bg_video : ''; $bg_video_poster = $bg_video_poster != '' ? $bg_video_poster : ''; $parallax = $parallax == 'true' ? $parallax : ''; $parallax_class = $parallax == 'true' ? ' parallax' : ''; if ($bg_video != '') { $data = cs_generate_data_attributes('section', array('type' => 'video')); $before = cs_bg_video($bg_video, $bg_video_poster); $bg_style = 'background-color: ' . $bg_color . ';'; $bg_class = ' bg-video'; } elseif ($bg_image != '') { $data = cs_generate_data_attributes('section', array('type' => 'image', 'parallax' => $parallax == 'true')); $before = ''; $bg_style = 'background-image: url(' . $bg_image . '); background-color: ' . $bg_color . ';'; $bg_class = ' bg-image' . $parallax_class; } elseif ($bg_pattern != '') { $data = cs_generate_data_attributes('section', array('type' => 'pattern', 'parallax' => $parallax == 'true')); $before = ''; $bg_style = 'background-image: url(' . $bg_pattern . '); background-color: ' . $bg_color . ';'; $bg_class = ' bg-pattern' . $parallax_class; } else { $data = ''; $before = ''; $bg_style = 'background-color: ' . $bg_color . ';'; $bg_class = ''; } $output = "<div id=\"{$id}\" class=\"{$class}{$bg_class}\" style=\"{$style}{$bg_style}\" {$data}>" . $before . do_shortcode($content) . '</div>'; return $output; }
function x_shortcode_counter($atts) { extract(shortcode_atts(array('id' => '', 'class' => '', 'style' => '', 'num_color' => '', 'num_start' => '', 'num_end' => '', 'num_speed' => '', 'num_prefix' => '', 'num_suffix' => '', 'text_color' => '', 'text_above' => '', 'text_below' => ''), $atts, 'x_counter')); $id = $id != '' ? 'id="' . esc_attr($id) . '"' : ''; $class = $class != '' ? 'x-counter ' . esc_attr($class) : 'x-counter'; $style = $style != '' ? 'style="' . $style . '"' : ''; $num_color = $num_color != '' ? 'style="color: ' . $num_color . ';"' : ''; $num_start = $num_start != '' ? $num_start : 0; $num_end = $num_end != '' ? $num_end : 0; $num_speed = $num_speed != '' ? $num_speed : 1500; $num_prefix = $num_prefix != '' ? '<span class="prefix">' . $num_prefix . '</span>' : ''; $num_suffix = $num_suffix != '' ? '<span class="suffix">' . $num_suffix . '</span>' : ''; $text_color = $text_color != '' ? 'style="color: ' . $text_color . ';"' : ''; $text_above = $text_above != '' ? '<span class="text-above" ' . $text_color . '>' . $text_above . '</span>' : ''; $text_below = $text_below != '' ? '<span class="text-below" ' . $text_color . '>' . $text_below . '</span>' : ''; $js_params = array('numEnd' => floatval($num_end), 'numSpeed' => floatval($num_speed)); if (floatval($num_start) > 0) { $js_params['numStart'] = floatval($num_start); } $data = cs_generate_data_attributes('counter', $js_params); $output = "<div {$id} class=\"{$class}\" {$data} {$style}>" . $text_above . "<div class=\"number-wrap w-h\" {$num_color}>" . $num_prefix . "<span class=\"number\">{$num_start}</span>" . $num_suffix . '</div>' . $text_below . '</div>'; return $output; }
function x_shortcode_video_player($atts) { extract(shortcode_atts(array('id' => '', 'class' => '', 'style' => '', 'type' => '', 'src' => '', 'poster' => '', 'preload' => '', 'advanced_controls' => '', 'hide_controls' => '', 'autoplay' => '', 'loop' => '', 'muted' => '', 'no_container' => '', 'm4v' => '', 'ogv' => ''), $atts, 'x_video_player')); $id = $id != '' ? 'id="' . esc_attr($id) . '"' : ''; $class = $class != '' ? 'x-video player ' . esc_attr($class) : 'x-video player'; $style = $style != '' ? 'style="' . $style . '"' : ''; switch ($type) { case '5:3': $type = ' five-by-three'; break; case '5:4': $type = ' five-by-four'; break; case '4:3': $type = ' four-by-three'; break; case '3:2': $type = ' three-by-two'; break; default: $type = ''; } $src = $src != '' ? explode('|', $src) : array(); $poster = $poster != '' ? $poster : ''; $preload = $preload != '' ? ' preload="' . $preload . '"' : ' preload="metadata"'; $advanced_controls = $advanced_controls == 'true' ? ' advanced-controls' : ''; $hide_controls = $hide_controls == 'true' ? ' hide-controls' : ''; $autoplay = $autoplay == 'true' ? ' autoplay' : ''; $loop = $loop == 'true' ? ' loop' : ''; $muted = $muted == 'true' ? ' muted' : ''; $no_container = $no_container == 'true' ? '' : ' with-container'; // // Deprecated parameters. // $m4v = $m4v != '' ? '<source src="' . $m4v . '" type="video/mp4">' : ''; $ogv = $ogv != '' ? '<source src="' . $ogv . '" type="video/ogg">' : ''; // // Variable markup. // if (is_numeric($poster)) { $poster_info = wp_get_attachment_image_src($poster, 'full'); $poster = $poster_info[0]; } $is_bg = strpos($class, 'bg') !== false ? true : false; $bg_template_start = $is_bg ? '<script type="text/template">' : ''; $bg_template_end = $is_bg ? '</script>' : ''; $poster_attr = $poster != '' ? ' poster="' . $poster . '"' : ''; $data = cs_generate_data_attributes('x_mejs', array('poster' => $poster)); // // Enqueue scripts. // wp_enqueue_script('mediaelement'); // // Build sources. // $sources = array(); $vimeo = ''; $youtube = ''; foreach ($src as $file) { if (preg_match('#webm|mp4|ogv#', $file)) { $is_vimeo = false; $is_youtube = false; } else { $is_vimeo = preg_match('#^https?://(.+\\.)?vimeo\\.com/.*#', $file); $is_youtube = preg_match('#^https?://(?:www\\.)?(?:youtube\\.com/watch|youtu\\.be/)#', $file); } if ($is_vimeo) { $mime = array('type' => 'video/vimeo'); $vimeo = ' vimeo'; wp_enqueue_script('froogaloop'); } else { if ($is_youtube) { $mime = array('type' => 'video/youtube'); $youtube = ' youtube'; } else { $parts = parse_url($file); $scheme = isset($parts['scheme']) ? $parts['scheme'] . '://' : '//'; $host = isset($parts['host']) ? $parts['host'] : ''; $path = isset($parts['path']) ? $parts['path'] : ''; $clean = $scheme . $host . $path; $mime = wp_check_filetype($clean, wp_get_mime_types()); } } $sources[] = '<source src="' . esc_url($file) . '" type="' . $mime['type'] . '">'; } if ($m4v != '') { $sources[] = $m4v; } if ($ogv != '') { $sources[] = $ogv; } // // Markup. // $output = "<div {$id} class=\"{$class}{$hide_controls}{$autoplay}{$loop}{$muted}{$no_container}{$vimeo}{$youtube}\" {$data} {$style}>" . $bg_template_start . "<div class=\"x-video-inner{$type}\">" . "<video class=\"x-mejs{$advanced_controls}\"{$poster_attr}{$preload}{$autoplay}{$loop}{$muted}>" . implode('', $sources) . '</video>' . '</div>' . $bg_template_end . '</div>'; return $output; }
function x_shortcode_content_band($atts, $content = null) { extract(shortcode_atts(array('class' => '', 'style' => '', 'border' => '', 'bg_color' => '', 'bg_pattern' => '', 'bg_image' => '', 'bg_video' => '', 'bg_video_poster' => '', 'no_margin' => '', 'padding_top' => '', 'padding_bottom' => '', 'inner_container' => '', 'parallax' => '', 'marginless_columns' => ''), $atts, 'x_content_band')); $class = $class != '' ? 'x-content-band ' . esc_attr($class) : 'x-content-band'; $style = $style != '' ? ' ' . $style : ''; switch ($border) { case 'top': $border = ' border-top'; break; case 'left': $border = ' border-left'; break; case 'right': $border = ' border-right'; break; case 'bottom': $border = ' border-bottom'; break; case 'vertical': $border = ' border-top border-bottom'; break; case 'horizontal': $border = ' border-left border-right'; break; case 'all': $border = ' border-top border-left border-right border-bottom'; break; default: $border = ''; } $bg_color = $bg_color != '' ? $bg_color : 'transparent'; $bg_pattern = $bg_pattern != '' ? $bg_pattern : ''; $bg_pattern_class = $bg_pattern != '' ? ' bg-pattern' : ''; $bg_image = $bg_image != '' ? $bg_image : ''; $bg_image_class = $bg_image != '' ? ' bg-image' : ''; $bg_video = $bg_video != '' ? $bg_video : ''; $bg_video_poster = $bg_video_poster != '' ? $bg_video_poster : ''; $bg_video_class = $bg_video != '' ? ' bg-video' : ''; $no_margin = $no_margin == 'true' ? ' man' : ''; $padding_top = $padding_top != '' ? ' padding-top: ' . $padding_top . ';' : ''; $padding_bottom = $padding_bottom != '' ? ' padding-bottom: ' . $padding_bottom . ';' : ''; switch ($inner_container) { case 'true': $container_start = '<div class="x-container max width">'; $container_end = '</div>'; break; default: $container_start = '<div class="x-container">'; $container_end = '</div>'; } $parallax = $parallax == 'true' ? $parallax : ''; $parallax_class = $parallax == 'true' ? ' parallax' : ''; $marginless_columns = $marginless_columns == 'true' ? $marginless_columns : ''; $marginless_columns_class = $marginless_columns == 'true' ? ' marginless-columns' : ''; if (is_numeric($bg_video_poster)) { $bg_video_poster_info = wp_get_attachment_image_src($bg_video_poster, 'full'); $bg_video_poster = $bg_video_poster_info[0]; } if (is_numeric($bg_image)) { $bg_image_info = wp_get_attachment_image_src($bg_image, 'full'); $bg_image = $bg_image_info[0]; } if (is_numeric($bg_pattern)) { $bg_pattern_info = wp_get_attachment_image_src($bg_pattern, 'full'); $bg_pattern = $bg_pattern_info[0]; } static $count = 0; $count++; if ($bg_video != '') { $js_params = array('type' => 'video', 'poster' => $bg_video_poster, 'video' => $bg_video); $data = cs_generate_data_attributes('content_band', $js_params); $output = "<div id=\"x-content-band-{$count}\" class=\"{$class}{$bg_video_class}{$marginless_columns_class}{$border}{$no_margin}\" {$data} style=\"{$padding_top}{$padding_bottom}{$style}\">" . $container_start . do_shortcode($content) . $container_end . '</div>'; } elseif ($bg_image != '') { $js_params = array('type' => 'image', 'parallax' => $parallax == 'true'); $data = cs_generate_data_attributes('content_band', $js_params); $output = "<div id=\"x-content-band-{$count}\" class=\"{$class}{$bg_image_class}{$parallax_class}{$marginless_columns_class}{$border}{$no_margin}\" {$data} style=\"background-image: url({$bg_image}); background-color: {$bg_color};{$padding_top}{$padding_bottom}{$style}\">" . $container_start . do_shortcode($content) . $container_end . '</div>'; } elseif ($bg_pattern != '') { $js_params = array('type' => 'pattern', 'parallax' => $parallax == 'true'); $data = cs_generate_data_attributes('content_band', $js_params); $output = "<div id=\"x-content-band-{$count}\" class=\"{$class}{$bg_pattern_class}{$parallax_class}{$marginless_columns_class}{$border}{$no_margin}\" style=\"background-image: url({$bg_pattern}); background-color: {$bg_color};{$padding_top}{$padding_bottom}{$style}\">" . $container_start . do_shortcode($content) . $container_end . '</div>'; } else { $output = "<div id=\"x-content-band-{$count}\" class=\"{$class}{$marginless_columns_class}{$border}{$no_margin}\" style=\"background-color: {$bg_color};{$padding_top}{$padding_bottom}{$style}\">" . $container_start . do_shortcode($content) . $container_end . '</div>'; } return $output; }
$width = ' x-1-4'; break; case '3/4': $width = ' x-3-4'; break; case '1/6': $width = ' x-1-6'; break; case '5/6': $width = ' x-5-6'; break; } if ($fade == 'true') { $fade = 'data-fade="true"'; $js_params = array('fade' => true, 'animation' => $fade_animation); $data = function_exists('cs_generate_data_attributes') ? cs_generate_data_attributes('column', $js_params) : ''; switch ($fade_animation) { case 'in': $fade_animation_offset = ''; break; case 'in-from-top': $fade_animation_offset = ' top: -' . $fade_animation_offset . ';'; break; case 'in-from-left': $fade_animation_offset = ' left: -' . $fade_animation_offset . ';'; break; case 'in-from-right': $fade_animation_offset = ' right: -' . $fade_animation_offset . ';'; break; case 'in-from-bottom': $fade_animation_offset = ' bottom: -' . $fade_animation_offset . ';';
function x_shortcode_column($atts, $content = null) { extract(shortcode_atts(array('id' => '', 'class' => '', 'style' => '', 'type' => '', 'last' => '', 'fade' => '', 'fade_animation' => '', 'fade_animation_offset' => '', 'fade_duration' => '', 'bg_color' => ''), $atts, 'x_column')); $id = $id != '' ? 'id="' . esc_attr($id) . '"' : ''; $class = $class != '' ? 'x-column x-sm ' . esc_attr($class) : 'x-column x-sm'; $style = $style != '' ? $style : ''; $type = $type != '' ? $type : ' x-1-2'; $last = $last == 'true' ? ' last' : ''; $fade_animation = $fade_animation != '' ? $fade_animation : 'in'; $fade_animation_offset = $fade_animation_offset != '' ? $fade_animation_offset : '45px'; $bg_color = $bg_color != '' ? ' background-color:' . $bg_color . ';' : ''; switch ($type) { case '1/1': case 'whole': $type = ' x-1-1'; break; case '1/2': case 'one-half': $type = ' x-1-2'; break; case '1/3': case 'one-third': $type = ' x-1-3'; break; case '2/3': case 'two-thirds': $type = ' x-2-3'; break; case '1/4': case 'one-fourth': $type = ' x-1-4'; break; case '3/4': case 'three-fourths': $type = ' x-3-4'; break; case '1/5': case 'one-fifth': $type = ' x-1-5'; break; case '2/5': case 'two-fifths': $type = ' x-2-5'; break; case '3/5': case 'three-fifths': $type = ' x-3-5'; break; case '4/5': case 'four-fifths': $type = ' x-4-5'; break; case '1/6': case 'one-sixth': $type = ' x-1-6'; break; case '5/6': case 'five-sixths': $type = ' x-5-6'; break; default: $type = ' x-1-1'; break; } if ($fade == 'true') { $fade = 'data-fade="true"'; $js_params = array('fade' => true, 'animation' => $fade_animation); if ($fade_duration != '') { $js_params['duration'] = (int) $fade_duration; } $data = cs_generate_data_attributes('column', $js_params); switch ($fade_animation) { case 'in': $fade_animation_offset = ''; break; case 'in-from-top': $fade_animation_offset = ' top: -' . $fade_animation_offset . ';'; break; case 'in-from-left': $fade_animation_offset = ' left: -' . $fade_animation_offset . ';'; break; case 'in-from-right': $fade_animation_offset = ' right: -' . $fade_animation_offset . ';'; break; case 'in-from-bottom': $fade_animation_offset = ' bottom: -' . $fade_animation_offset . ';'; break; } } else { $data = ''; $fade = ''; $fade_animation_offset = ''; } $output = "<div {$id} class=\"{$class}{$type}{$last}\" style=\"{$style}{$fade_animation_offset}{$bg_color}\" {$data} {$fade}>" . do_shortcode($content) . "</div>"; return $output; }
$marginless_columns = $marginless_columns == 'true' ? $marginless_columns : ''; $marginless_columns_class = $marginless_columns == 'true' ? ' marginless-columns' : ''; if (is_numeric($bg_video_poster)) { $bg_video_poster_info = wp_get_attachment_image_src($bg_video_poster, 'full'); $bg_video_poster = $bg_video_poster_info[0]; } if (is_numeric($bg_image)) { $bg_image_info = wp_get_attachment_image_src($bg_image, 'full'); $bg_image = $bg_image_info[0]; } if (is_numeric($bg_pattern)) { $bg_pattern_info = wp_get_attachment_image_src($bg_pattern, 'full'); $bg_pattern = $bg_pattern_info[0]; } $count = x_visual_composer_templates_id_increment(); if ($bg_video != '') { $js_params = array('type' => 'video', 'poster' => $bg_video_poster, 'video' => $bg_video); $data = function_exists('cs_generate_data_attributes') ? cs_generate_data_attributes('content_band', $js_params) : ''; $output = "<div id=\"x-content-band-{$count}\" class=\"{$class}{$bg_video_class}{$marginless_columns_class}{$border}{$no_margin}\" {$data} style=\"{$padding_top}{$padding_bottom}{$style}\">" . $container_start . do_shortcode($content) . $container_end . '</div>'; } elseif ($bg_image != '') { $js_params = array('type' => 'image', 'parallax' => $parallax == 'true'); $data = function_exists('cs_generate_data_attributes') ? cs_generate_data_attributes('content_band', $js_params) : ''; $output = "<div id=\"x-content-band-{$count}\" class=\"{$class}{$bg_image_class}{$parallax_class}{$marginless_columns_class}{$border}{$no_margin}\" {$data} style=\"background-image: url({$bg_image}); background-color: {$bg_color};{$padding_top}{$padding_bottom}{$style}\">" . $container_start . do_shortcode($content) . $container_end . '</div>'; } elseif ($bg_pattern != '') { $js_params = array('type' => 'pattern', 'parallax' => $parallax == 'true'); $data = function_exists('cs_generate_data_attributes') ? cs_generate_data_attributes('content_band', $js_params) : ''; $output = "<div id=\"x-content-band-{$count}\" class=\"{$class}{$bg_pattern_class}{$parallax_class}{$marginless_columns_class}{$border}{$no_margin}\" style=\"background-image: url({$bg_pattern}); background-color: {$bg_color};{$padding_top}{$padding_bottom}{$style}\">" . $container_start . do_shortcode($content) . $container_end . '</div>'; } else { $output = "<div id=\"x-content-band-{$count}\" class=\"{$class}{$marginless_columns_class}{$border}{$no_margin}\" style=\"background-color: {$bg_color};{$padding_top}{$padding_bottom}{$style}\">" . $container_start . do_shortcode($content) . $container_end . '</div>'; } echo $output;
function x_shortcode_feature_box($atts, $content = '') { extract(shortcode_atts(array('id' => '', 'class' => '', 'style' => '', 'graphic' => '', 'graphic_size' => '', 'graphic_shape' => '', 'graphic_border' => '', 'graphic_color' => '', 'graphic_bg_color' => '', 'graphic_icon' => '', 'graphic_image' => '', 'graphic_animation' => '', 'graphic_animation_offset' => '', 'graphic_animation_delay' => '', 'title' => '', 'title_color' => '', 'text' => '', 'text_color' => '', 'link_text' => '', 'link_color' => '', 'href' => '', 'href_title' => '', 'href_target' => '', 'align_h' => '', 'align_v' => '', 'side_graphic_spacing' => '', 'max_width' => '', 'child' => '', 'connector_width' => '', 'connector_style' => '', 'connector_color' => '', 'connector_animation' => ''), $atts, 'x_feature_box')); // // Allow text attribute to be used instead of content. // if ('' == $content && '' != $text) { $content = wp_specialchars_decode($text, ENT_QUOTES); } $title = wp_specialchars_decode($title, ENT_QUOTES); $id = $id != '' ? 'id="' . esc_attr($id) . '"' : ''; $class = $class != '' ? 'x-feature-box ' . esc_attr($class) : 'x-feature-box'; $style = $style != '' ? $style : ''; $graphic = $graphic != '' ? $graphic : 'icon'; $graphic_size = $graphic_size != '' ? $graphic_size : '60px'; $graphic_shape = $graphic_shape != '' ? $graphic_shape : 'square'; $graphic_border = $graphic_border != '' ? $graphic_border : ''; $graphic_color = $graphic_color != '' ? $graphic_color : '#ffffff'; $graphic_bg_color = $graphic_bg_color != '' ? $graphic_bg_color : 'transparent'; $graphic_icon = $graphic_icon != '' ? $graphic_icon : ''; $graphic_image = $graphic_image != '' ? $graphic_image : ''; $graphic_animation = $graphic_animation != '' ? $graphic_animation : 'none'; $graphic_animation_offset = $graphic_animation_offset != '' ? $graphic_animation_offset : '50'; $graphic_animation_delay = $graphic_animation_delay != '' ? $graphic_animation_delay : '0'; $title_color = $title_color != '' ? $title_color : ''; $text_color = $text_color != '' ? $text_color : ''; $link_text = $link_text != '' ? $link_text : ''; $link_color = $link_color != '' ? ' style="color: ' . $link_color . ';"' : ''; $href = $href != '' ? $href : '#'; $href_title = $href_title != '' ? $href_title : $link_text; $href_target = $href_target == 'blank' ? ' target="_blank"' : ''; $align_h = $align_h != '' ? $align_h : 'center'; $align_v = $align_v != '' ? $align_v : 'top'; $side_graphic_spacing = $side_graphic_spacing != '' ? $side_graphic_spacing : '20px'; $max_width = $max_width != '' ? ' max-width: ' . $max_width . ';' : ' max-width: none;'; $child = $child == 'true' ? $child : ''; $connector_width = $connector_width != '' ? $connector_width : '1px'; $connector_style = $connector_style != '' ? $connector_style : 'dashed'; $connector_color = $connector_color != '' ? $connector_color : '#2ecc71'; $connector_animation = $connector_animation != '' ? $connector_animation : 'none'; // // Graphic - design. // $graphic_font_size = 'font-size: ' . $graphic_size . ';'; if ($graphic_border != '' && $graphic_shape != 'hexagon' && $graphic_shape != 'badge') { $graphic_border = ' ' . $graphic_border; } else { $graphic_border = ''; } if ($graphic != 'image') { $graphic_colors = ' color: ' . $graphic_color . '; background-color: ' . $graphic_bg_color . ';'; } else { $graphic_colors = ''; } if ($graphic_shape == 'hexagon' || $graphic_shape == 'badge') { $graphic_pseudo_element_color = ' border-color: ' . $graphic_bg_color . ';'; } else { $graphic_pseudo_element_color = ''; } // // Graphic - side alignment. // if ($align_h != 'center') { $side_align_style = ' style="display: table-cell; vertical-align: ' . $align_v . ';"'; $side_graphic_spacing = $align_h == 'left' ? ' margin-right: ' . $side_graphic_spacing . ';' : ' margin-left: ' . $side_graphic_spacing . ';'; } else { $side_align_style = ''; $side_graphic_spacing = ''; } // // Graphic - attributes. // $graphic_container_class_style = ' class="x-feature-box-graphic ' . $graphic_shape . '"' . $side_align_style; $graphic_outer_class_style = ' class="x-feature-box-graphic-outer ' . $graphic_shape . cs_animation_base_class($graphic_animation) . '" style="' . $side_graphic_spacing . '"'; $graphic_inner_class_style = ' class="x-feature-box-graphic-inner ' . $graphic_shape . '" style="' . $graphic_font_size . $graphic_pseudo_element_color . '"'; $graphic_style = ' style="margin: 0 auto;' . $graphic_border . $graphic_colors . '"'; // // Graphic. // if ($graphic == 'image') { $graphic = '<div' . $graphic_container_class_style . '>' . '<div' . $graphic_outer_class_style . '>' . '<div' . $graphic_inner_class_style . '>' . '<img class="' . $graphic_shape . '" src="' . $graphic_image . '"' . $graphic_style . '>' . '</div>' . '</div>' . '</div>'; } else { if ($graphic == 'numbers' && $child == 'true') { $graphic = '<div' . $graphic_container_class_style . '>' . '<div' . $graphic_outer_class_style . '>' . '<div' . $graphic_inner_class_style . '>' . '<i class="number w-h ' . $graphic_shape . '"' . $graphic_style . '></i>' . '</div>' . '</div>' . '</div>'; } else { $graphic = '<div' . $graphic_container_class_style . '>' . '<div' . $graphic_outer_class_style . '>' . '<div' . $graphic_inner_class_style . '>' . '<i class="x-icon-' . $graphic_icon . ' ' . $graphic_shape . '" data-x-icon="&#x' . fa_unicode($graphic_icon) . ';"' . $graphic_style . '></i>' . '</div>' . '</div>' . '</div>'; } } // // Connector. // if ($child == 'true') { $left = $align_h == 'left' ? ' left: 0;' : ' left: calc(100% - ' . $graphic_size . ');'; $right = $align_h == 'right' ? ' right: 0;' : ' right: calc(100% - ' . $graphic_size . ');'; $connector_class = cs_animation_base_class($connector_animation); $connector_style = 'style="' . $graphic_font_size . $left . $right . ' border-left: ' . $connector_width . ' ' . $connector_style . ' ' . $connector_color . ';"'; $connector_text = '<span class="visually-hidden">Connector.</span>'; if ($align_v == 'top') { $connector = '<span class="x-feature-box-connector full' . $connector_class . '" ' . $connector_style . '>' . $connector_text . '</span>'; } else { $connector = '<span class="x-feature-box-connector upper' . $connector_class . '" ' . $connector_style . '>' . $connector_text . '</span>' . '<span class="x-feature-box-connector lower' . $connector_class . '" ' . $connector_style . '>' . $connector_text . '</span>'; } } else { $connector = ''; } // // Content. // $title_color = $title_color != '' ? ' style="color: ' . $title_color . ';"' : ''; $text_color = $text_color != '' ? ' style="color: ' . $text_color . ';"' : ''; $link = $link_text != '' ? ' <a href="' . $href . '" title="' . $href_title . '"' . $href_target . $link_color . '>' . $link_text . '</a>' : ''; $output = '<div class="x-feature-box-content"' . $side_align_style . '>' . '<h4 class="x-feature-box-title"' . $title_color . '>' . $title . '</h4>' . '<p class="x-feature-box-text"' . $text_color . '>' . do_shortcode($content) . $link . '</p>' . '</div>'; // // Output. // $js_params = array('child' => $child == 'true', 'graphicAnimation' => $graphic_animation); if ($child == 'true') { $js_params['connectorAnimation'] = $connector_animation; $js_params['alignH'] = $align_h; $js_params['alignV'] = $align_v; } else { $js_params['graphicAnimationOffset'] = $graphic_animation_offset; $js_params['graphicAnimationDelay'] = $graphic_animation_delay; } $data = cs_generate_data_attributes('feature_box', $js_params); $element = $child == 'true' ? 'li' : 'div'; $ordered_content = $align_h == 'right' ? $output . $graphic : $graphic . $output; $align_h = ' ' . $align_h . '-text'; $align_v = ' ' . $align_v . '-text'; $output = "<{$element} {$id} class=\"{$class}{$align_h}{$align_v} cf\" style=\"{$style}{$max_width}\" {$data}>" . $connector . $ordered_content . "</{$element}>"; return $output; }
function cs_generate_data_attributes_extra($type, $trigger, $placement, $title = '', $content = '') { if (!in_array($type, array('tooltip', 'popover'))) { return ''; } $js_params = array('type' => $type == 'tooltip' ? 'tooltip' : 'popover', 'trigger' => $trigger, 'placement' => $placement, 'title' => $title, 'content' => $content); return cs_generate_data_attributes('extra', $js_params); }