Advertisement
Guest User

themeum-slider

a guest
May 17th, 2018
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 10.36 KB | None | 0 0
  1. <?php
  2. if(!class_exists('ThemeumSliderShortcode'))
  3. {
  4.     class ThemeumSliderShortcode
  5.     {
  6.        
  7.         function __construct()
  8.         {  
  9.             $active_counter = 0;
  10.             add_action('init', array($this, 'add_themeum_slider'));        
  11.             add_shortcode( 'themeum_slider_wrap', array($this, 'themeum_slider_wrap' ) );
  12.             add_shortcode( 'themeum_slider_item', array($this, 'themeum_slider_item' ) );
  13.         }
  14.  
  15.         function themeum_slider_wrap($atts, $content = null)
  16.         {
  17.             $class              = '';
  18.             $time               = '';
  19.             $disable_slider     = '';
  20.             extract(shortcode_atts(array(
  21.                 'class'             => '',
  22.                 'time'              => '',
  23.                 'disable_slider'    => '',
  24.             ), $atts));
  25.             if($disable_slider == 'enable'){
  26.                 $time = 'false';
  27.             }
  28.             $randId = rand(10,100);
  29.             $output  = '<div id="home-one-crousel'.$randId.'" class="home-one-crousel carousel slide ' . esc_attr($class) . '">';
  30.                 $output .= '<div class="carousel-inner">';
  31.                             $output .= do_shortcode($content);
  32.                             $output  .= '<div class="slider-overlay"></div>';
  33.                 $output .= '</div>';//carousel-inner
  34.                 // Controls
  35.                 $output .= '<a class="left carousel-control" href="#home-one-crousel'.$randId.'" role="button" data-slide="prev">';
  36.                     $output .= '<i class="fa fa-angle-left"></i>';
  37.                 $output .= '</a>';
  38.                 $output .= '<a class="right carousel-control" href="#home-one-crousel'.$randId.'" role="button" data-slide="next">';
  39.                     $output .= '<i class="fa fa-angle-right"></i>';
  40.                 $output .= '</a>';
  41.             $output .= '</div>';//#home-one-crousel
  42.  
  43.             // JS time
  44.             $output .= "<script type='text/javascript'>jQuery(document).ready(function() { jQuery('#home-one-crousel".$randId."').carousel({ interval: ".$time." }) });</script>";
  45.             return $output;
  46.         }
  47.  
  48.         function themeum_slider_item($atts,$content = null)
  49.         {
  50.             $slider_type = '';
  51.             $title = '';
  52.             $subtitle = '';
  53.             $image = '';
  54.             $btn_url = '';
  55.             $btn_text = '';
  56.             extract(shortcode_atts(array(
  57.                 'slider_type'   => 'text_slide',
  58.                 'title'         => '',
  59.                 'subtitle'      => '',
  60.                 'btn_url'       => '',
  61.                 'btn_text'      => '',
  62.                 'image'         => '',
  63.             ), $atts));
  64.            
  65.             $style = '';
  66.             $output = '';
  67.             $src_image   = wp_get_attachment_image_src($image, 'full');
  68.             if ($slider_type == 'image_slide') {
  69.                 $style = 'style="background: #333 url('.esc_url($src_image[0]).'); background-size: cover; background-repeat: no-repeat;"';
  70.             } else {
  71.                 $style = 'style="overflow: hidden;backface-visibility: hidden;"';
  72.             }  
  73.            
  74.             //foreach ($title as $value) {
  75.                 global $active_counter;
  76.                 if( $active_counter == 0 ){
  77.                 $output   .= '<div class="item active" '.$style.'>';
  78.                 $active_counter = 2;
  79.                 }else{
  80.                 $output   .= '<div class="item" '.$style.'>';
  81.                 }
  82.                     $output  .= '<div class="container">';
  83.                         $output  .= '<div class="slider-content text-left">';
  84.                                 if ($title) {
  85.                                     $output  .= '<h2 class="first-animation">'. esc_attr($title) .'</h2>';
  86.                                 }
  87.                                 if ($subtitle) {
  88.                                     $output  .= '<h3 class="second-animation">'. $subtitle .'</h3>';
  89.                                 }
  90.                                 if ($btn_url) {
  91.                                     $output  .= '<a class="bordered-button fourth-animation" href="'.esc_url($btn_url).'" target="_blank">'.esc_attr($btn_text).'<i class="fa fa-long-arrow-right"></i></a>';
  92.                                 }
  93.                         $output  .= '</div>';//slider-content
  94.                         if ($slider_type == 'image_slide') {
  95.                             $output  .= '<div class="slider-overlay"></div>';
  96.                         }
  97.                     $output  .= '</div>';//container
  98.                 $output  .= '</div>';//item
  99.                
  100.             return $output;
  101.         }
  102.        
  103.         // Shortcode Functions for frontend editor
  104.         function front_themeum_slider_wrap($atts, $content = null)
  105.         {
  106.             // Do nothing
  107.             $class              = '';
  108.             $time               = '';
  109.             $disable_slider     = '';
  110.             extract(shortcode_atts(array(
  111.                 'class'             => '',
  112.                 'time'              => '',
  113.                 'disable_slider'    => '',
  114.             ), $atts));
  115.  
  116.                 if($disable_slider == 'enable'){
  117.                     $time = 'false';
  118.                 }  
  119.                 $output  = '<div id="home-two-crousel" class="carousel carousel-fade slide ' . esc_attr($class) . '">';
  120.                     $output .= '<div class="carousel-inner">';
  121.                                 $output .= do_shortcode($content);
  122.                     $output .= '</div>';//carousel-inner
  123.  
  124.                     // Controls
  125.                     $output .= '<a class="left carousel-control" href="#home-two-crousel" role="button" data-slide="prev">';
  126.                         $output .= '<i class="fa fa-angle-left"></i>';
  127.                     $output .= '</a>';
  128.                     $output .= '<a class="right carousel-control" href="#home-two-crousel" role="button" data-slide="next">';
  129.                         $output .= '<i class="fa fa-angle-right"></i>';
  130.                     $output .= '</a>';
  131.                 $output .= '</div>';//#home-two-crousel
  132.  
  133.                 // JS time
  134.                 $output .= "<script type='text/javascript'>jQuery(document).ready(function() { jQuery('#home-one-crousel".$randId."').carousel({ interval: ".$time." }) });</script>";
  135.  
  136.             return $output;
  137.         }
  138.         function front_themeum_slider_item($atts,$content = null)
  139.         {
  140.             // Do nothing
  141.             $title = '';
  142.             $subtitle = '';
  143.             $image = '';
  144.             $btn_url = '';
  145.             $btn_text = '';
  146.             extract(shortcode_atts(array(
  147.                 'title'     => '',
  148.                 'subtitle'  => '',
  149.                 'btn_url'   => '',
  150.                 'btn_text'  => '',
  151.                 'image'     => '',
  152.             ), $atts));
  153.            
  154.             $style = '';
  155.             $src_image   = wp_get_attachment_image_src($image, 'full');
  156.             $style = 'style="background: #333 url('.esc_url($src_image[0]).') no-repeat center center cover; overflow: hidden;backface-visibility: hidden;padding: 154px 0 145px;"';
  157.  
  158.             $output = '<li class="icon_list_item">';
  159.             $output   = '<div class="item" '.$style.'>';
  160.                 $output  .= '<div class="slider-content">';
  161.                         if ($title) {
  162.                             $output  .= '<h2  data-animation="animated zoomInLeft">'. esc_attr($title) .'</h2>';
  163.                         }
  164.                         if ($subtitle) {
  165.                             $output  .= '<h3 data-animation="animated zoomInRight">'. esc_attr($subtitle) .'</h3>';
  166.                         }
  167.                         if ($btn_url) {
  168.                             $output  .= '<a href="'.esc_url($btn_url).'" class="bordered-button" data-animation="animated zoomInUp">'.esc_attr($btn_text).'<i class="fa fa-long-arrow-right"></i></a>';
  169.                         }
  170.                 $output  .= '</div>';//slider-content
  171.                 $output .= wpb_js_remove_wpautop($content, true);
  172.             $output  .= '</div>';//item
  173.  
  174.             return $output;
  175.         }
  176.         function add_themeum_slider()
  177.         {
  178.             if(function_exists('vc_map'))
  179.             {
  180.                 vc_map(
  181.                 array(
  182.                    "name" => __("Themeum Slider","themeum-core"),
  183.                    "base" => "themeum_slider_wrap",
  184.                    "class" => "",
  185.                    "icon" => "icon-slider-wrap",
  186.                    "category" => "Politist",
  187.                    "as_parent" => array('only' => 'themeum_slider_item'),
  188.                    "description" => __("Text blocks connected together in one list.","themeum-core"),
  189.                    "content_element" => true,
  190.                    "show_settings_on_create" => true,
  191.                    "params" => array(
  192.                         array(
  193.                             "type" => "textfield",
  194.                             "class" => "",
  195.                             "heading" => __("Add Custom Class","themeum-core"),
  196.                             "param_name" => "class",
  197.                             "description" => __("Add Custom Class","themeum-core")
  198.                         ), 
  199.  
  200.                         array(
  201.                             "type" => "checkbox",
  202.                             "class" => "",
  203.                             "heading" => esc_html__("Disable Auto Slide: ","themeum-core"),
  204.                             "param_name" => "disable_slider",
  205.                             "value" => array ( esc_html__('Disable','themeum-core') => 'enable'),
  206.                             "description" => esc_html__("If you want disable slide check this.","themeum-core"),
  207.                         ),
  208.  
  209.                         array(
  210.                             "type" => "textfield",
  211.                             "heading" => esc_html__("Sliding Time(Milliseconds Ex: 4000)", "themeum-core"),
  212.                             "param_name" => "time",
  213.                             "value" => "3000",
  214.                             ),
  215.  
  216.                     ),
  217.                     "js_view" => 'VcColumnView'
  218.                 ));
  219.                 // Add slider Item
  220.                 vc_map(
  221.                     array(
  222.                        "name" => __("Themeum Slider Item","themeum-core"),
  223.                        "base" => "themeum_slider_item",
  224.                        "class" => "",
  225.                        "icon" => "icon-slider-list",
  226.                        "category" => "Politist",
  227.                        "content_element" => true,
  228.                        "as_child" => array('only' => 'themeum_slider_wrap'),
  229.                        "is_container"    => false,
  230.                        "params" => array(
  231.                             array(
  232.                                 "type" => "dropdown",
  233.                                 "heading" => esc_html__("Slider Type", 'themeum-core'),
  234.                                 "param_name" => "slider_type",
  235.                                 "value" => array('Select'=>'','Only Text Slide'=>'text_slide','Slide With Image '=>'image_slide'),
  236.                             ), 
  237.                             array(
  238.                                 "type" => "textfield",
  239.                                 "class" => "",
  240.                                 "heading" => __("Title","themeum-core"),
  241.                                 "param_name" => "title",
  242.                                 "description" => __("Title","themeum-core")
  243.                             ),
  244.                             array(
  245.                                 "type" => "textarea",
  246.                                 "class" => "",
  247.                                 "heading" => __("Sub Title","themeum-core"),
  248.                                 "param_name" => "subtitle",
  249.                                 "description" => __("Sub Title","themeum-core")
  250.                             ), 
  251.                             array(
  252.                                 "type" => "textfield",
  253.                                 "class" => "",
  254.                                 "heading" => __("Add Button URL","themeum-core"),
  255.                                 "param_name" => "btn_url",
  256.                                 "description" => __("Add URL","themeum-core")
  257.                             ),                         
  258.                             array(
  259.                                 "type" => "textfield",
  260.                                 "class" => "",
  261.                                 "heading" => __("Add Button Text","themeum-core"),
  262.                                 "param_name" => "btn_text",
  263.                             ),                                                     
  264.                             array(
  265.                                 "type" => "attach_image",
  266.                                 "heading" => esc_html__("Upload Slider Image", 'themeum-core'),
  267.                                 "param_name" => "image",
  268.                                 "value" => "",
  269.                             ), 
  270.                        )
  271.                     )
  272.                 );
  273.             }//endif
  274.         }
  275.     }
  276. }
  277. global $ThemeumSliderShortcode;
  278. if(class_exists('WPBakeryShortCodesContainer'))
  279. {
  280.     class WPBakeryShortCode_themeum_slider_wrap extends WPBakeryShortCodesContainer {
  281.         function content( $atts, $content = null ) {
  282.             global $ThemeumSliderShortcode;
  283.             return $ThemeumSliderShortcode->front_themeum_slider_wrap($atts, $content);
  284.         }
  285.     }
  286.     class WPBakeryShortCode_themeum_slider_item extends WPBakeryShortCode {
  287.         function content($atts, $content = null ) {
  288.             global $ThemeumSliderShortcode;
  289.             return $ThemeumSliderShortcode->front_themeum_slider_item($atts, $content);
  290.         }
  291.     }
  292. }
  293. if(class_exists('ThemeumSliderShortcode'))
  294. {
  295.     $ThemeumSliderShortcode = new ThemeumSliderShortcode;
  296. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement