Advertisement
rejuancse

themeum-slider3

Jan 28th, 2018
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 15.75 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. *  Themeum Post Slider
  5. */
  6.  
  7. add_shortcode( 'themeum_post_slider', function( $atts, $content = null ) {
  8.  
  9.     extract(shortcode_atts(array(
  10.         'style'             => 'style1',
  11.         'category'          => '',
  12.         'number'            => '4',
  13.         'class'             => '',
  14.         'order_by'          => 'date',          
  15.         'order'             => 'DESC',  
  16.         'time'              => '',
  17.         'disable_slider'    => '',
  18.         'slidenav'          => 'true',
  19.         'autoplay'          => 'true',
  20.     ), $atts));
  21.  
  22.     global $post;
  23.  
  24.     $posts= 0;
  25.  
  26.     if (isset($category) && $category!='') {
  27.         $idObj  = get_category_by_slug( $category );
  28.        
  29.         if (isset($idObj) && $idObj!='') {
  30.             $idObj  = get_category_by_slug( $category );
  31.             $cat_id = $idObj->term_id;
  32.  
  33.             $args = array(
  34.                 'category'          => $cat_id,
  35.                 'orderby'           => $order_by,
  36.                 'order'             => $order,
  37.                 'posts_per_page'    => -1,
  38.             );
  39.             $posts = get_posts($args);
  40.         }
  41.     }else{
  42.         $args = array(
  43.             'orderby'           => $order_by,
  44.             'order'             => $order,
  45.             'posts_per_page'    => -1,
  46.         );
  47.         $posts = get_posts($args);
  48.     }
  49.  
  50.     $output = '';
  51.  
  52.     if($disable_slider == 'enable'){
  53.         $time = 'false';
  54.     }
  55.  
  56.  
  57. if ($style == 'style1') {
  58.     $output .= '<div class="row">';  
  59.     $output  .= '<div data-number="1" data-aplay="'.esc_attr($rautoplay).'" data-testnav="'.esc_attr($rslidenav).'" class="slider-style1 owl-carousel owl-theme">';
  60.     $j=0;
  61.     foreach ($posts as $post){
  62.         setup_postdata( $post );
  63.              if ( has_post_thumbnail() ) {
  64.  
  65.                 $image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
  66.  
  67.                 if( $j == 0 ){
  68.                     $output .= '<div class="item active" style="min-height:570px; background-image: url('.esc_url($image_url[0]).');background-repeat:no-repeat;background-position:center;background-size:cover;">';
  69.                 }else{
  70.                     $output .= '<div class="item" style="min-height:570px; background-image: url('.esc_url($image_url[0]).');background-repeat:no-repeat;background-size:cover;background-position:center;">';
  71.                 }
  72.  
  73.                 $output .= '<div class="container">';
  74.                     $output .= '<div class="row">';
  75.                         $output .= '<div class="post-slider-wrap col-md-6 col-sm-6 col-xs-12">';
  76.                             $output .= '<div class="post-slider-in clearfix">';
  77.                                 $output .= '<div class="post-slider-innner">';
  78.                                 $output .= '<span class="entry-category">';
  79.                                 $output .= get_the_category_list(', ');
  80.                                 $output .= '</span>';
  81.                                 $output .= '<h2 class="slider-title"><a href="'.get_permalink().'">'.get_the_title().'</a></h2>';
  82.                                 $output .= '<p class="slider-excerpt">'.calcio_excerpt_max_charlength(100).'</p>';
  83.                                 $output .= '</div>'; # handpick-slider-innner
  84.                            $output .= '</div>'; # handpick-slider-in
  85.                        $output .= '</div>'; # col-sm-6
  86.                    $output .= '</div>'; # row
  87.                $output .= '</div>'; # container
  88.            $output .= '</div>'; # item
  89.            
  90.             $j++;
  91.         }  
  92.     }
  93.     wp_reset_postdata();    
  94.     $output .= '</div>';
  95.     $output .= '</div>';
  96. }elseif ($style == 'style2') {
  97.     $output .= '<div class="row">';  
  98.         $output  .= '<div data-number="1" data-aplay="'.esc_attr($rautoplay).'" data-testnav="'.esc_attr($rslidenav).'" class="slider-style1 style-two owl-carousel owl-theme">';
  99.         $j=0;
  100.         foreach ($posts as $post){
  101.             setup_postdata( $post );
  102.                  if ( has_post_thumbnail() ) {
  103.  
  104.                     $image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
  105.  
  106.                     if( $j == 0 ){
  107.                         $output .= '<div class="item active" style="min-height:570px; background-image: url('.esc_url($image_url[0]).');background-repeat:no-repeat;background-position:center;background-size:cover;">';
  108.                     }else{
  109.                         $output .= '<div class="item" style="min-height:570px; background-image: url('.esc_url($image_url[0]).');background-repeat:no-repeat;background-size:cover;background-position:center;">';
  110.                     }
  111.  
  112.                     $output .= '<div class="container">';
  113.                         $output .= '<div class="row">';
  114.                             $output .= '<div class="post-slider-wrap style2 col-md-6 col-sm-6 col-xs-12">';
  115.                                 $output .= '<div class="post-slider-in clearfix">';
  116.                                     $output .= '<div class="post-slider-innner">';
  117.                                     $output .= '<span class="entry-category">';
  118.                                     $output .= get_the_category_list(', ');
  119.                                     $output .= '</span>';
  120.                                     $output .= '<h2 class="slider-title"><a href="'.get_permalink().'">'.get_the_title().'</a></h2>';
  121.                                     $output .= '<p class="slider-excerpt">'.calcio_excerpt_max_charlength(100).'</p>';
  122.                                     $output .= '</div>'; # handpick-slider-innner
  123.                                $output .= '</div>'; # handpick-slider-in
  124.                            $output .= '</div>'; # col-sm-6
  125.                        $output .= '</div>'; # row
  126.                    $output .= '</div>'; # container
  127.                $output .= '</div>'; # item
  128.                
  129.                 $j++;
  130.             }  
  131.         }
  132.         wp_reset_postdata();    
  133.         $output .= '</div>';
  134.     $output .= '</div>';
  135. }else {
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145. $output .= '<div class="row">';  
  146.     $output .= '<div class="padding-zero col-sm-8">';  
  147.         $output  .= '<div data-number="1" data-aplay="'.esc_attr($rautoplay).'" data-testnav="'.esc_attr($rslidenav).'" class="slider-style3 owl-carousel owl-theme">';
  148.         $j=0;
  149.         foreach ($posts as $post){
  150.             if($j==3){
  151.                 break;
  152.             }
  153.             setup_postdata( $post );
  154.                  if ( has_post_thumbnail() ) {
  155.  
  156.                     $image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
  157.  
  158.                     if( $j == 0 ){
  159.                         $output .= '<div class="item active" style="min-height:492px; background-image: url('.esc_url($image_url[0]).');background-repeat:no-repeat;background-position:center;background-size:cover;">';
  160.                     }else{
  161.                         $output .= '<div class="item" style="min-height:480px; background-image: url('.esc_url($image_url[0]).');background-repeat:no-repeat;background-size:cover;background-position:center;">';
  162.                     }
  163.  
  164.                     $output .= '<div class="post-slider-wrap col-md-10 col-sm-6 col-xs-12">';
  165.                         $output .= '<div class="post-slider-in clearfix">';
  166.                             $output .= '<div class="post-slider-innner">';
  167.                             $output .= '<span class="entry-category">';
  168.                             $output .= get_the_category_list(', ');
  169.                             $output .= '</span>';
  170.                             $output .= '<h2 class="slider-title"><a href="'.get_permalink().'">'.get_the_title().'</a></h2>';
  171.                             $output .= '<p class="slider-excerpt">'.calcio_excerpt_max_charlength(100).'</p>';
  172.                             $output .= '</div>'; # handpick-slider-innner
  173.                        $output .= '</div>'; # handpick-slider-in
  174.                    $output .= '</div>'; # col-sm-6
  175.                        
  176.                 $output .= '</div>'; # item
  177.                
  178.                 $j++;
  179.             }  
  180.         }
  181.         wp_reset_postdata();    
  182.         $output .= '</div>';
  183.     $output .= '</div>';
  184.  
  185.     $output .= '<div class="padding-zero col-sm-4">';
  186.         $tt = 0;
  187.         foreach ($posts as $post){
  188.             if( $tt == 3 || $tt == 4 ){
  189.                
  190.                 setup_postdata( $post );
  191.                 if ( has_post_thumbnail() ) {
  192.                     $image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
  193.                     $output .= '<div class="item" style="min-height:246px; background-image: url('.esc_url($image_url[0]).');background-repeat:no-repeat;background-size:cover;background-position:center;">';
  194.                        
  195.                         $output .= '<div class="post-slider-wrap style3">';
  196.                             $output .= '<div class="post-slider-in clearfix">';
  197.                                 $output .= '<div class="post-slider-innner">';
  198.                                 $output .= '<span class="entry-category">';
  199.                                 $output .= get_the_category_list(', ');
  200.                                 $output .= '</span>';
  201.                                 $output .= '<h3 class="slider-title"><a href="'.get_permalink().'">'.get_the_title().'</a></h3>';
  202.                                 // $output .= '<p class="slider-excerpt">'.calcio_excerpt_max_charlength(100).'</p>';
  203.                                 $output .= '</div>'; # handpick-slider-innner
  204.                            $output .= '</div>'; # handpick-slider-in
  205.                        $output .= '</div>'; # col-sm-6
  206.                          
  207.                     $output .= '</div>'; # item
  208.                }      
  209.             }
  210.             $tt++;
  211.         }
  212.     $output .= '</div>';
  213. $output .= '</div>';
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230. }
  231.  
  232.     # JS time
  233.    $output .= "<script type='text/javascript'>jQuery(document).ready(function() { jQuery('.nano').nanoScroller(); jQuery('#themeum-post-slider').carousel({ interval: ".$time." }) });</script>";
  234.  
  235.     return $output;
  236.  
  237. });
  238.  
  239.  
  240. function themeum_post_cat_list(){
  241.     $cat_lists = get_categories();
  242.     $all_cat_list = array('All Category'=>'');
  243.     foreach($cat_lists as $cat_list){
  244.         $all_cat_list[$cat_list->cat_name] = $cat_list->cat_name;
  245.     }
  246.     return $all_cat_list;
  247. }
  248.  
  249. # Visual Composer
  250. if (class_exists('WPBakeryVisualComposerAbstract')) {
  251.     vc_map(array(
  252.         "name"          => esc_html__("Themeum Post Slider", 'themeum-core'),
  253.         "base"          => "themeum_post_slider",
  254.         'icon'          => 'icon-thm-slide',
  255.         "class"         => "",
  256.         "description"   => esc_html__("Widget Title Heading", 'themeum-core'),
  257.         "category"      => __('Calcio', "themeum-core"),
  258.         "params"        => array(  
  259.  
  260.             array(
  261.                 "type"          => "dropdown",
  262.                 "heading"       => __("Style", "themeum"),
  263.                 "param_name"    => "style",
  264.                 "value"         => array('Select'=>'','Style1'=>'style1','Style2'=>'style2', 'Style3' => 'style3'),
  265.             ),          
  266.  
  267.             array(
  268.                 "type"          => "dropdown",
  269.                 "heading"       => esc_html__("Category Name", 'themeum-core'),
  270.                 "param_name"    => "category",
  271.                 "value"         => themeum_post_cat_list(),
  272.             ),                      
  273.             array(
  274.                 "type"          => "textfield",
  275.                 "heading"       => esc_html__("Number of items", 'themeum-core'),
  276.                 "param_name"    => "number",
  277.                 "value"         => "",
  278.             ),          
  279.             array(
  280.                 "type"          => "dropdown",
  281.                 "heading"       => esc_html__("OderBy", 'themeum-core'),
  282.                 "param_name"    => "order_by",
  283.                 "value"         => array('Date'=>'date','Title'=>'title','Modified'=>'modified','Author'=>'author','Random'=>'rand'),
  284.             ),              
  285.             array(
  286.                 "type"          => "dropdown",
  287.                 "heading"       => esc_html__("Order", 'themeum-core'),
  288.                 "param_name"    => "order",
  289.                 "value"         => array('DESC'=>'DESC','ASC'=>'ASC'),
  290.             ),                          
  291.             array(
  292.                 "type"          => "textfield",
  293.                 "heading"       => esc_html__("Custom Class", 'themeum-core'),
  294.                 "param_name"    => "class",
  295.                 "value"         => "",
  296.             ),  
  297.             array(
  298.                 "type"          => "checkbox",
  299.                 "class"         => "",
  300.                 "heading"       => esc_html__("Disable Slider: ","themeum-core"),
  301.                 "param_name"    => "disable_slider",
  302.                 "value"         => array ( esc_html__('Disable','themeum-core') => 'enable'),
  303.                 "description"   => esc_html__("If you want disable slide check this.","themeum-core"),
  304.                 "group"         => "Slide"
  305.             ),
  306.             array(
  307.                 "type"              => "dropdown",
  308.                 "class"             => "",
  309.                 "heading"           => __("Auto Play",'themeum-core'),
  310.                 "param_name"        => "autoplay",
  311.                 "value"             => array('None'=>'','True'=>'true','False'=>'false'),
  312.             ),
  313.             array(
  314.                 "type"              => "dropdown",
  315.                 "class"             => "",
  316.                 "heading"           => __("Show Navigation",'themeum-core'),
  317.                 "param_name"        => "slidenav",
  318.                 "value"             => array('None'=>'','True'=>'true','False'=>'false'),
  319.             ),
  320.  
  321.  
  322.  
  323.             array(
  324.                 "type"          => "textfield",
  325.                 "heading"       => esc_html__("Sliding Time(Milliseconds Ex: 4000)", "themeum-core"),
  326.                 "param_name"    => "time",
  327.                 "value"         => "3000",
  328.                 "group"         => "Slide"
  329.             ),
  330.  
  331.         )
  332.  
  333.     ));
  334. }
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349. .slider-style1 .owl-nav {
  350.     display: none;
  351. }
  352. .slider-style1.owl-carousel.owl-loaded {
  353.     display: block;
  354.     width: calc(100% + 80px);
  355.     margin-left: -40px;
  356.     overflow: hidden;
  357. }
  358. .slider-style1 .owl-item.active .item {
  359.     width: calc(1170px + 80px) !important;
  360.     z-index: 9999;
  361.     position: absolute;
  362. }
  363. .slider-style1.owl-carousel .owl-dots {
  364.     position: absolute;
  365.     left: 75px;
  366.     bottom: 12%;
  367. }
  368. .slider-style1.owl-carousel .owl-stage-outer {
  369.     overflow: inherit;
  370. }
  371. .post-slider-innner {
  372.     margin-left: 18px;
  373. }
  374. .post-slider-wrap.style2 {
  375.     transform: translate(-50%,0%);
  376.     left: 49%;
  377.     top: 26%;
  378.     text-align: center;
  379. }
  380. .slider-style1.style-two.owl-carousel .owl-dots {
  381.     bottom: 12%;
  382.     transform: translate(-50%,0%);
  383.     left: 50.1%;
  384.     text-align: center;
  385. }
  386. .slider-style1 .item:after {
  387.     content: "";
  388.     width: 100%;
  389.     height: 100%;
  390.     bottom: 0;
  391.     background: rgba(0, 0, 0, 0.3);
  392.     position: absolute;
  393.     z-index: -1;
  394. }
  395. .padding-zero.col-sm-8, .padding-zero.col-sm-4 {
  396.     padding: 0;
  397. }
  398. .slider-style3.owl-carousel .owl-item.active {
  399.     width: calc(750px + 30px) !important;
  400. }
  401. .slider-style3 .owl-controls .owl-nav{
  402.     display: none !important;
  403. }
  404. .slider-style3 .owl-dots {
  405.     left: 40px !important;
  406.     bottom: 12% !important;
  407. }
  408. .padding-zero .item {
  409.     position: relative;
  410. }
  411. .post-slider-wrap.style3 .post-slider-innner {
  412.     margin-left: 18px;
  413.     margin-top: 62px;
  414. }
  415. .post-slider-wrap.style3 .post-slider-in .slider-title a {
  416.     font-size: 24px;
  417.     font-weight: 700;
  418.     color: #FFFFFF;
  419.    line-height: 30px;
  420. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement