Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * Shortcodes for RT Content Slider
- *
- */
- if( ! function_exists("rt_slider") ){
- /**
- * RT Slider Holder
- * returns html ouput of the content slider
- *
- * @param [array] $atts
- * @param [string] $content
- * @return [string] $output
- */
- function rt_slider( $atts, $content = null ) {
- global $rt_slider_min_height;
- //defaults
- extract(shortcode_atts(array(
- "id" => 'content-slider-'.rand(100000, 1000000),
- "min_height" => 300,
- "mobile_min_height" => 300,
- "autoplay" => true,
- "timeout" => 5000,
- "parallax" => false,
- "dots" => "true",
- "nav" => "true"
- ), $atts));
- //id
- $id = !empty( $id ) ? sanitize_html_class( $id ) : 'slider-dynamicID-'.rand(100000, 1000000);
- //min height
- $rt_slider_min_height = (double) $min_height;
- //parallax
- $parallax = $parallax === "true" ? "true" : "false";
- //autoplay
- $autoplay = $autoplay === "true" ? "true" : "false";
- //get slides
- ob_start();
- echo (do_shortcode($content));
- $get_slides = ob_get_contents();
- ob_end_clean();
- //dots holder
- $dots_holder = ( $dots == "true" ) ? sprintf('
- <div id="%1$s-dots" class="dots-holder">
- </div>
- ', $id) : "";
- //create the slider holder
- $output = '<div id="'.$id.'" class="rt-carousel main-carousel carousel-holder clearfix" data-item-width="1" data-mobile-height="'.intval($mobile_min_height).'" data-nav="'.$nav.'" data-dots="'.$dots.'" data-parallax="'.$parallax.'" data-timeout="'.$timeout.'" data-autoplay="'.$autoplay.'">'."\n";
- $output .= '<div class="owl-carousel">'."\n";
- $output .= $get_slides;
- $output .= '</div>'."\n";
- $output .= $dots_holder."\n";
- $output .= '</div>'."\n";
- return $output;
- }
- }
- add_shortcode('rt_slider', 'rt_slider');
- if( ! function_exists("rt_slide") ){
- /**
- * RT Slide
- * returns html ouput of a slide
- *
- * @param [array] $atts
- * @param [string] $content
- * @return [string] $output
- */
- function rt_slide( $atts, $content = null ) {
- global $rt_slider_min_height;
- //defaults
- extract(shortcode_atts(array(
- "class" => '',
- "content_width" => 40,
- "content_bg_color" => "",
- "content_wrapper_width" => "default",
- "content_color_schema" => "",
- "content_align" => "right",
- "text_align" => "left",
- 'bg_color' => '',
- 'bg_image' => '',
- 'bg_image_repeat' => '',
- 'bg_position' => '',
- 'bg_size' => '',
- 'top_margin' => '',
- 'mobile_top_margin' => '',
- 'link'=> '',
- 'link_target'=> '_self',
- 'link_title'=> '',
- "button_text" => '',
- "button_icon" => '',
- "button_link" => '',
- "button_link_target" => '',
- "button_size" => 'small',
- "button_style" => 'color',
- "button_href_title" => "",
- "button2_text" => '',
- "button2_icon" => '',
- "button2_link" => '',
- "button2_link_target" => '',
- "button2_size" => 'small',
- "button2_style" => 'color',
- "button2_href_title" => "",
- "heading" => '',
- "heading_font_size" => '',
- "heading_line_height" => '',
- "mobile_heading_font_size" => '',
- "mobile_heading_line_height" => '',
- "sub_heading" => '',
- "sub_heading_font_size" => '',
- "sub_heading_line_height" => '',
- "mobile_sub_heading_font_size" => '',
- "mobile_sub_heading_line_height" => '',
- ), $atts));
- $style_output = $content_style_output = $content_class = $content_wrapper_style = $background_output = "";
- //get slide content
- ob_start();
- echo do_shortcode(rt_visual_composer_content_fix($content));
- $get_slide_content = ob_get_contents();
- $get_slide_content = ! empty( $get_slide_content ) ? '<div class="slide-text">'.$get_slide_content.'</div>' : "";
- ob_end_clean();
- //heading output
- $heading_style = ! empty( $heading_font_size ) ? ' font-size:'.intval($heading_font_size).'px;' : "";
- $heading_style .= ! empty( $heading_line_height ) ? ' line-height:'.$heading_line_height.'' : "";
- $heading_style = ! empty( $heading_style ) ? 'style="'.trim($heading_style).'"' : "";
- $mobile_heading_font_size = ! empty( $mobile_heading_font_size ) ? 'data-mobile-value="'.intval($mobile_heading_font_size).'"' : 'data-mobile-value="28"';
- $mobile_heading_line_height = ! empty( $mobile_heading_line_height ) ? 'data-mobile-line-height="'.intval($mobile_heading_line_height).'%"' : 'data-mobile-line-height="1.5"';
- $heading_output = ! empty( $heading ) ? '<h2 class="slide_heading" '. $heading_style .' '.$mobile_heading_font_size.' '.$mobile_heading_line_height.'>'.$heading.'</h2>' : "";
- //sub heading output
- $sub_heading_style = ! empty( $sub_heading_font_size ) ? ' font-size:'.intval($sub_heading_font_size).'px;' : "";
- $sub_heading_style .= ! empty( $sub_heading_line_height ) ? ' line-height:'.$sub_heading_line_height.'' : "";
- $sub_heading_style = ! empty( $sub_heading_style ) ? 'style="'.trim($sub_heading_style).'"' : "";
- $mobile_sub_heading_font_size = ! empty( $mobile_sub_heading_font_size ) ? 'data-mobile-value="'.intval($mobile_sub_heading_font_size).'"' : 'data-mobile-value="22"';
- $mobile_sub_heading_line_height = ! empty( $mobile_sub_heading_line_height ) ? 'data-mobile-line-height="'.intval($mobile_sub_heading_line_height).'%"' : 'data-mobile-line-height="1"';
- $sub_heading_output = ! empty( $sub_heading ) ? '<span class="slide_sub_heading secondary-font" '. $sub_heading_style .' '.$mobile_sub_heading_font_size.' '.$mobile_sub_heading_line_height.'>'.$sub_heading.'</span>' : "";
- //button 1
- $button_format = '
- [button
- button_size = "'.$button_size.'"
- button_text = "'.$button_text.'"
- button_link = "'.$button_link.'"
- button_icon = "'.$button_icon.'"
- button_style = "'.$button_style.'"
- href_title = "'.$button_text.'"
- link_open = "'.$link_target.'"
- wrapper_class="button-1"
- ]
- ';
- $button_output = ! empty( $button_text ) ? do_shortcode($button_format) : "";
- //button 2
- $button2_format = '
- [button
- button_size = "'.$button2_size.'"
- button_text = "'.$button2_text.'"
- button_link = "'.$button2_link.'"
- button_icon = "'.$button2_icon.'"
- button_style = "'.$button2_style.'"
- href_title = "'.$button2_text.'"
- link_open = "'.$link_target.'"
- wrapper_class="button-2"
- ]
- ';
- $button2_output = ! empty( $button2_text ) ? do_shortcode($button2_format) : "";
- //css class
- $class = ! empty( $class ) ? sanitize_html_class( $class ) : "";
- //color schema
- $class .= ! empty( $content_color_schema ) ? " ".sanitize_html_class( $content_color_schema ) : "";
- //bg values
- if( ! empty( $bg_image ) ){
- $bg_image = rtframework_get_attachment_image_src($bg_image);
- //background image
- $background_output .= 'background-image: url('.$bg_image.');';
- //background repeat
- $background_output .= ! empty( $bg_image_repeat ) ? 'background-repeat: '.$bg_image_repeat.';': "";
- //background size
- $background_output .= ! empty( $bg_size ) ? 'background-size: '.$bg_size.';': "";
- //background attachment
- //$style_output .= ! empty( $bg_attachment ) ? 'background-attachment: '.$bg_attachment.';': "";
- //background position
- $background_output .= ! empty( $bg_position ) ? 'background-position: '.$bg_position.';': "";
- }
- //background color
- $background_output .= ! empty( $bg_color ) ? 'background-color: '.$bg_color.';': "";
- //height
- $style_output .= ! empty( $rt_slider_min_height ) ? 'min-height: '.intval($rt_slider_min_height).'px;': "";
- //wrapper height
- $content_wrapper_style .= ! empty( $rt_slider_min_height ) ? 'min-height: '.intval($rt_slider_min_height).'px;': "";
- //content width
- $content_style_output .= ! empty( $content_width ) ? 'width: '.$content_width.'%;': "";
- //background color
- $content_style_output .= ! empty( $content_bg_color ) ? 'background-color: '.$content_bg_color.';': "";
- //content align
- $content_class .= ! empty( $content_align ) ? " {$content_align}":"";
- //content top margin
- $content_style_output .= $content_align == "center" ? 'left: '.((100-$content_width)/2).'%;': "";
- //text align
- $content_class .= ! empty( $text_align ) ? " text-{$text_align}":"";
- //content top margin
- $content_style_output .= ! empty( $top_margin ) ? 'margin-top: '.intval($top_margin).'px;': "";
- //content top margin mobile
- $content_data = ! empty( $mobile_top_margin ) ? ' data-mobile-top-margin= "'.intval($mobile_top_margin).'"': "";
- //style outputs
- $style_output = ! empty( $style_output ) ? 'style="'.$style_output.'"' : "";
- $content_style_output = ! empty( $content_style_output ) ? 'style="'.$content_style_output.'"' : "";
- $content_wrapper_style_output = ! empty( $content_wrapper_style ) ? 'style="'.$content_wrapper_style.'"' : "asads";
- $link_output = ! empty( $link ) ? '<a href="'.esc_url($link).'" target="'.$link_target.'" title="'.sanitize_text_field( $link_title ).'"></a>' : "";
- if (empty($heading_output)&&empty($sub_heading_output)&&empty($get_slide_content)) {
- return sprintf('
- <div class="item has-bg-image %1$s" %2$s>
- %3$s
- <div class="slide-background" style="%4$s"></div>
- </div>',
- $class,
- $style_output,
- $link_output,
- $background_output
- );
- }
- else {
- return sprintf('
- <div class="item has-bg-image %1$s" %2$s>
- %3$s
- <div class="slide-content-wrapper %4$s clearfix" %13$s>
- <div class="slide-content %5$s" %6$s%12$s>
- %7$s
- %8$s
- %9$s
- %10$s
- %11$s
- </div>
- </div>
- <div class="slide-background" style="%14$s"></div>
- </div>',
- $class,
- $style_output,
- $link_output,
- $content_wrapper_width,
- $content_class,
- $content_style_output,
- $heading_output,//7
- $sub_heading_output,
- $get_slide_content,//9
- $button_output,
- $button2_output,
- $content_data,//12
- $content_wrapper_style_output,
- $background_output
- );
- }
- }
- }
- add_shortcode('rt_slide', 'rt_slide');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement