Advertisement
rejuancse

themeum-slider-2

Dec 25th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 11.91 KB | None | 0 0
  1. <?php
  2. add_shortcode( 'themeum_slider_2', function($atts, $content = null) {
  3.  
  4.     extract(shortcode_atts(array(
  5.         'number_of_slide'   => '3',
  6.         'order_by'          => 'date',
  7.         'order'             => 'DESC',
  8.         'time'              => '3000',
  9.         'disable_slider'    => '',
  10.         ), $atts));
  11.  
  12.  
  13.  
  14.     global $post;
  15.  
  16.     $args = array(
  17.         'post_type'         => 'slider',
  18.         'post_status'       => 'publish',
  19.         'posts_per_page'    => $number_of_slide,
  20.         'orderby'           => $order_by,
  21.         'order'             => $order,
  22.     );
  23.  
  24.     $posts = get_posts($args);
  25.     $output = '';
  26.  
  27.  
  28.    
  29.     if($disable_slider == 'enable'){
  30.         $time = 'false';
  31.     }
  32.  
  33.     $output .= '<div class="bs-example" data-example-id="simple-carousel">';
  34.     $output .= '<div id="themeum-slider2-carousel" class="carousel slide themeum-slider2-carousel" data-ride="carousel">';
  35.  
  36.  
  37.      
  38.     $output .= '<div class="slider2-carousel-indicators" >';
  39.    
  40.     $output .= '<div class="container clearfix">';  
  41.     $output .= '<div class="nano">';
  42.     $output .= '<ul class="slider2-carousel-indicators-inner carousel-indicators nano-content">';
  43.     $i=0;
  44.     foreach ($posts as $post){
  45.         setup_postdata( $post );
  46.         $slider_type      = get_post_meta(get_the_ID(),'slider_type',true);
  47.  
  48.         if( $slider_type != '' ){
  49.             $slider_type = '<span class="slide2-type">'.esc_attr( $slider_type ).'</span>';
  50.         }
  51.  
  52.         if( $i == 0 ){
  53.             $output .= '<li data-target="#themeum-slider2-carousel" data-slide-to="'.$i.'" class="text-right active">'.balanceTags( $slider_type ).'<span class="indicators-title">'.get_the_title().'</span></li>';
  54.         }else{
  55.             $output .= '<li data-target="#themeum-slider2-carousel" data-slide-to="'.$i.'" class="text-right">'.balanceTags( $slider_type ).'<span class="indicators-title">'.get_the_title().'</span></li>';
  56.         }
  57.         $i++;
  58.     }
  59.     wp_reset_postdata();
  60.     $output .= '</ul>';
  61.     $output .= '</div>';//slider2-carousel-indicators
  62.     $output .= '</div>';
  63.     $output .= '</div>';//container
  64.  
  65.    
  66.  
  67.  
  68.     $output .= '<div class="carousel-inner" role="listbox">';
  69.     $j=0;
  70.     foreach ($posts as $post){
  71.  
  72.             setup_postdata( $post );
  73.             $reasult_group    = get_post_meta(get_the_ID(),'reasult_group',true);
  74.             $select_type      = get_post_meta(get_the_ID(),'select_type',true);
  75.             $classic_content  = get_post_meta(get_the_ID(),'classic_group',true);
  76.             if ( isset($reasult_group["themeum_goal"]) ) {
  77.                $match_result    = $reasult_group["themeum_goal"];
  78.                $match_result = explode(':', $match_result);
  79.             }
  80.            
  81.             # Date translate.
  82.            if ( isset($reasult_group["themeum_datetime"]) ) {
  83.                 $sportsdate = esc_attr($reasult_group["themeum_datetime"]);
  84.             }
  85.             $sports_date = date_i18n("d M Y h:i a", strtotime($sportsdate));
  86.             # End Date.
  87.  
  88.             $image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
  89.  
  90.             if( $j == 0 ){
  91.                 $output .= '<div class="item active" style="padding:250px 0 200px 0;background-image: url('.esc_url($image_url[0]).');background-repeat:no-repeat;background-size:cover;">';
  92.             }else{
  93.                 $output .= '<div class="item" style="padding:250px 0 200px 0;background-image: url('.esc_url($image_url[0]).');background-repeat:no-repeat;background-size:cover;">';
  94.             }
  95.            
  96.  
  97.             $output .= '<div class="container">';
  98.                 $output .= '<div class="row">';
  99.                     $output .= '<div class="col-md-6 col-sm-8 col-xs-12">';
  100.  
  101.                     if( $select_type == 'value2' ){
  102.                         //Match Result
  103.                         $output .= '<div class="slider2-title"><span>'.get_the_title().'</span></div>';
  104.                         $output .= '<div class="slider2-box slider2-box-result">';
  105.                         $output .= '<div class="row">';
  106.                             $output .= '<div class="col-xs-4">';
  107.                             $output .= '<div class="text-left  slider2-logo media">';
  108.                             if ( isset($reasult_group["themeum_team_name1"]) ) {
  109.                                 $output .= '<img class="pull-left" width="50" src="'.esc_url(themeum_logo_url_by_id($reasult_group["themeum_team_name1"])).'" alt="'.esc_attr( themeum_get_title_by_id($reasult_group["themeum_team_name1"]) ).'">';
  110.                                 $output .= '<div class="media-body"><h3>'.esc_attr( themeum_get_title_by_id($reasult_group["themeum_team_name1"]) ).'</h3></div>';
  111.                             }
  112.                             $output .= '</div>';
  113.                             $output .= '</div>'; //col-xs-4
  114.  
  115.                             $output .= '<div class="text-center col-xs-4">';
  116.                             if ( isset($reasult_group["themeum_goal"]) ) {
  117.                                 $output .= '<div class="slider2-score"><span class="goal">'.esc_attr( $match_result[0] ).'</span> - <span class="goal">'.esc_attr( $match_result[1] ).'</span></div>';
  118.                             }
  119.                             if ( isset($reasult_group["themeum_datetime"]) ) {
  120.                                 $output .= '<div class="slider2-time">'.$sports_date.'</div>';
  121.                             }
  122.                             $output .= '</div>';//col-xs-4
  123.  
  124.                             $output .= '<div class="col-xs-4">';
  125.                             $output .= '<div class="text-right slider2-logo media">';
  126.                             if ( isset($reasult_group["themeum_team_name2"]) ) {
  127.                                 $output .= '<img class="pull-right" width="50" src="'.esc_url( themeum_logo_url_by_id($reasult_group["themeum_team_name2"]) ).'" alt="'.esc_attr( themeum_get_title_by_id($reasult_group["themeum_team_name2"]) ).'">';
  128.                                 $output .= '<div class="media-body"><h3>'.esc_attr( themeum_get_title_by_id($reasult_group["themeum_team_name2"]) ).'</h3></div>';
  129.                             }
  130.                             $output .= '</div>';    
  131.                              $output .= '</div>'; //col-xs-4
  132.                         $output .= '</div>';//row
  133.                         $output .= '</div>';//slider2-box
  134.                     }
  135.                     elseif( $select_type == 'value3' ){
  136.                         // Upcoming Match
  137.                         $output .= '<div class="slider2-title"><span>'.get_the_title().'</span></div>';
  138.                         $output .= '<div class="slider2-box slider2-box-upcoming">';
  139.                         $output .= '<div class="row">';
  140.                             $output .= '<div class="col-xs-4">';
  141.                             $output .= '<div class="text-left  slider2-logo media">';
  142.                             if ( isset($reasult_group["themeum_team_name1"]) ) {
  143.                                 $output .= '<img class="pull-left" width="50" src="'.esc_url( themeum_logo_url_by_id($reasult_group["themeum_team_name1"]) ).'" alt="'.esc_attr( themeum_get_title_by_id($reasult_group["themeum_team_name1"]) ).'">';
  144.                                 $output .= '<div class="media-body"><h3>'.esc_attr( themeum_get_title_by_id($reasult_group["themeum_team_name1"]) ).'</h3></div>';
  145.                             }
  146.                             $output .= '</div>';
  147.                             $output .= '</div>'; //col-xs-4
  148.  
  149.                             $output .= '<div class="text-center col-xs-4">';
  150.                             if ( isset($reasult_group["themeum_datetime"]) ) {
  151.                                 $output .= '<div class="slider2-time"><span class="goal">'.$sports_date.'</span></div>';
  152.                             }
  153.                             $output .= '</div>';//col-xs-4
  154.  
  155.                             $output .= '<div class="col-xs-4">';
  156.                             $output .= '<div class="text-right slider2-logo media">';
  157.  
  158.                             if ( isset($reasult_group["themeum_team_name2"]) ) {
  159.                                 $output .= '<img class="pull-right" width="50" src="'.esc_url( themeum_logo_url_by_id($reasult_group["themeum_team_name2"]) ).'" alt="'.esc_attr( themeum_get_title_by_id($reasult_group["themeum_team_name2"]) ).'">';
  160.                                 $output .= '<div class="media-body"><h3>'.esc_attr( themeum_get_title_by_id($reasult_group["themeum_team_name2"]) ).'</h3></div>';
  161.                             }
  162.                             $output .= '</div>';    
  163.                             $output .= '</div>'; //col-xs-4
  164.  
  165.                         $output .= '</div>';//row
  166.                         $output .= '</div>';//slider2-box
  167.                     }else{
  168.                         $output .= '<div class="slider2-title"><span>'.get_the_title().'</span></div>';
  169.                         $output .= '<div class="slider2-box">';
  170.                             $output .= '<div class="slider2-content">'.esc_html( $classic_content["themeum_short_description"] ).'</div>';
  171.                         $output .= '</div>';
  172.                     }
  173.                     $output .= '</div>';
  174.                 $output .= '</div>';
  175.             $output .= '</div>';
  176.  
  177.         $output .= '</div>';
  178.  
  179.         $j++;    
  180.         }
  181.     wp_reset_postdata();    
  182.     $output .= '</div>';
  183.  
  184.     $output .= '</div>';
  185.     $output .= '</div>';    
  186.  
  187.     // JS time
  188.     $output .= "<script type='text/javascript'>jQuery(document).ready(function() { jQuery('.nano').nanoScroller(); jQuery('#themeum-slider2-carousel').carousel({ interval: ".$time." }) });</script>";
  189.  
  190.  
  191.     return $output;
  192.  
  193. });
  194.  
  195.  
  196. //Visual Composer
  197. if (class_exists('WPBakeryVisualComposerAbstract')) {
  198. vc_map(array(
  199.     "name"                 => __("Slider 2", "themeum-soccer"),
  200.     "base"                 => "themeum_slider_2",
  201.     'icon'                 => 'icon-thm-title',
  202.     "class"                => "",
  203.     "description"          => __("Widget Title Heading", "themeum-soccer"),
  204.     "category"             => __('Themeum', "themeum-soccer"),
  205.     "params"               => array(            
  206.  
  207.             array(
  208.                 "type"               => "textfield",
  209.                 "heading"            => __("Number of Slide", "themeum-soccer"),
  210.                 "param_name"         => "number_of_slide",
  211.                 "value"              => "",
  212.             ),
  213.  
  214.             array(
  215.                 "type"              => "dropdown",
  216.                 "heading"           => esc_html__("OderBy", 'themeum'),
  217.                 "param_name"        => "order_by",
  218.                 "value"             => array('Date'=>'date','Title'=>'title','Modified'=>'modified','Author'=>'author','Random'=>'rand'),
  219.             ),
  220.  
  221.             array(
  222.                 "type"              => "dropdown",
  223.                 "heading"           => __("Order By", "themeum-soccer"),
  224.                 "param_name"        => "order",
  225.                 "value"             => array('Select'=>'','ASC'=>'ASC','DESC'=>'DESC'),
  226.             ),
  227.  
  228.             array(
  229.                 "type"              => "checkbox",
  230.                 "class"             => "",
  231.                 "heading"           => __("Disable Slider: ","themeum-soccer"),
  232.                 "param_name"        => "disable_slider",
  233.                 "value"             => array ( __('Disable','themeum') => 'enable'),
  234.                 "description"       => __("If you want disable slide check this.","themeum-soccer"),
  235.                 "group"             => "Slide"
  236.             ),
  237.  
  238.             array(
  239.                 "type"              => "textfield",
  240.                 "heading"           => __("Sliding Time(Milliseconds Ex: 4000)", "themeum-soccer"),
  241.                 "param_name"        => "time",
  242.                 "value"             => "",
  243.                 "group"             => "Slide"
  244.             ),
  245.  
  246.  
  247.  
  248.         )
  249.     ));
  250. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement