Advertisement
rejuancse

themeum-sportlight

Dec 28th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 18.28 KB | None | 0 0
  1. <?php
  2. add_shortcode( 'themeum_spotlight', function($atts, $content = null) {
  3.  
  4.     extract(shortcode_atts(array(
  5.         'latest_section'    => 'on',
  6.         'coming_soon'       => 'on',
  7.         'top_rated'         => 'on',
  8.         'recently_released' => 'on',
  9.         'number'            => '20',
  10.         ), $atts));
  11.  
  12.     $output = '';
  13.  
  14.     $output .= '<div class="spotlight-post tabpanel">';
  15.         $output .= '<ul class="list-unstyled list-inline text-left">';
  16.             if( $coming_soon == 'on' ) { $output .= '<li class="active"><a href="#coming-soon" data-toggle="tab">'.__('Coming Soon','themeum-core').'</a></li>'; }
  17.             if( $top_rated == 'on' ) { $output .= '<li><a href="#top-rated" data-toggle="tab">'.__('Top Rated','themeum-core').'</a></li>'; }
  18.             if( $recently_released == 'on' ) { $output .= '<li><a href="#recently-released" data-toggle="tab">'.__('Recently Released','themeum-core').'</a></li>'; }
  19.         $output .= '</ul>';
  20.         $output .= '<div class="tab-content">';
  21.            
  22.  
  23.             // coming soon open
  24.             if( $coming_soon == 'on' ) {
  25.                 $output .= '<div class="spotlight moview-common-layout tab-pane active fade in" id="coming-soon">';
  26.                     $arr = array(
  27.                         'post_type'     => 'movie',
  28.                         'meta_query'    => array(
  29.                                             array(
  30.                                                 'key'       => 'themeum_release_date',
  31.                                                 'value'     => date("Y-m-d", strtotime( date("Y-m-d") )),
  32.                                                 'compare'   =>'>',
  33.                                                 'type'      =>'date',
  34.                                             )),
  35.                         'post_status'       => 'publish',
  36.                         'orderby'           => 'meta_value',
  37.                         'order'             => 'ASC',
  38.                         'meta_value'        => '1',
  39.                         'posts_per_page'    => $number
  40.                     );
  41.                     query_posts( $arr ); while (have_posts()) : the_post();
  42.                     $movie_type      = esc_attr(get_post_meta(get_the_ID(),'themeum_movie_type',true));
  43.                     $movie_trailer_info     = get_post_meta(get_the_ID(),'themeum_movie_trailer_info',true);
  44.                     $release_year    = get_post_meta(get_the_ID(),'themeum_movie_release_year',true);
  45.                        $output .= '<div class="item">';
  46.                             $output .= '<div class="movie-poster">';
  47.                                 $output .= get_the_post_thumbnail(get_the_ID(),'moview-profile', array('class' => 'img-responsive'));
  48.                                 if( is_array(($movie_trailer_info)) ) {
  49.                                     if(!empty($movie_trailer_info)) {
  50.                                         foreach( $movie_trailer_info as $key=>$value ){
  51.                                             if ($key==0) {
  52.                                                 if ($value["themeum_video_link"]) {
  53.                                                     $output .= '<a class="play-icon play-video" href="'.$value["themeum_video_link"].'" data-type="'.esc_attr($value["themeum_video_source"]).'">
  54.                                                    <i class="themeum-moviewplay"></i>
  55.                                                    </a>';
  56.                                                     $output .= '<div class="content-wrap">';
  57.                                                         $output .= '<div class="video-container">';
  58.                                                             $output .= '<span class="video-close">x</span>';
  59.                                                         $output .= '</div>';
  60.                                                     $output .= '</div>'; //content-wrap
  61.                                                 }
  62.                                                  else {
  63.                                                     $output .= '<a class="play-icon" href="'.get_permalink().'">
  64.                                                    <i class="themeum-moviewenter"></i>
  65.                                                    </a>';
  66.                                                 }
  67.                                             }
  68.                                         }
  69.                                     }
  70.                                 }
  71.                             $output .= '</div>';//movie-poster
  72.                             $output .= '<div class="movie-details">';
  73.                                 $output .= '<div class="movie-rating-wrapper">';
  74.                                 if (function_exists('themeum_wp_rating')) {
  75.                                     $output .= '<div class="movie-rating">';
  76.                                         $output .= '<span class="themeum-moviewstar active"></span>';
  77.                                     $output .= '</div>';
  78.                                     $output .= '<span class="rating-summary"><span>'.themeum_wp_rating(get_the_ID(),'single').'</span>/10</span>';
  79.                                 }
  80.                                 $output .= '</div>';//movie-rating-wrapper
  81.                                 $year ='';
  82.                                 if ($release_year) {
  83.                                     $year =  '('.esc_attr($release_year).')';
  84.                                 }
  85.                                 $output .= '<div class="movie-name">';
  86.                                     $output .= '<h4 class="movie-title"><a href="'.get_the_permalink().'">'.get_the_title().$year.'</a></h4>';
  87.                                     if ($movie_type) {
  88.                                         $output .= '<span class="tag">'.esc_attr($movie_type).'</span>';
  89.                                     }
  90.                                 $output .= '</div>';//movie-name
  91.                             $output .= '</div>';//movie-details
  92.                         $output .= '</div> '; //item
  93.                     endwhile;
  94.                     wp_reset_query();
  95.                 $output .= '</div>';//moview-common-layout
  96.             }
  97.             // coming soon close
  98.  
  99.  
  100.  
  101.  
  102.             // Top Rated close
  103.             if( $top_rated == 'on' ) {
  104.                 $output .= '<div class="spotlight moview-common-layout tab-pane fade in" id="top-rated">';
  105.                     $arr = array(
  106.                                     'post_type'         => 'movie',
  107.                                     'post_status'       => 'publish',
  108.                                     'orderby'           => 'meta_value_num',
  109.                                     // 'meta_value'        => '1',
  110.                                     'order'             => 'DESC',
  111.                                     'meta_key'          => 'rating',
  112.                                     'posts_per_page'    => $number
  113.                                 );
  114.                     query_posts( $arr ); while (have_posts()) : the_post();
  115.                     $movie_type      = esc_attr(get_post_meta(get_the_ID(),'themeum_movie_type',true));
  116.                     $movie_trailer_info     = get_post_meta(get_the_ID(),'themeum_movie_trailer_info',true);
  117.                     $release_year     = get_post_meta(get_the_ID(),'themeum_movie_release_year',true);
  118.                        $output .= '<div class="item">';
  119.                             $output .= '<div class="movie-poster">';
  120.                                 $output .= get_the_post_thumbnail(get_the_ID(),'moview-profile', array('class' => 'img-responsive'));
  121.                                 if( is_array(($movie_trailer_info)) ) {
  122.                                     if(!empty($movie_trailer_info)) {
  123.                                         foreach( $movie_trailer_info as $key=>$value ){
  124.                                             if ($key==0) {
  125.                                                 if ($value["themeum_video_link"]) {
  126.                                                     $output .= '<a class="play-icon play-video" href="'.$value["themeum_video_link"].'" data-type="'.esc_attr($value["themeum_video_source"]).'">
  127.                                                    <i class="themeum-moviewplay"></i>
  128.                                                    </a>';
  129.                                                     $output .= '<div class="content-wrap">';
  130.                                                         $output .= '<div class="video-container">';
  131.                                                             $output .= '<span class="video-close">x</span>';
  132.                                                         $output .= '</div>';
  133.                                                     $output .= '</div>'; //content-wrap
  134.                                                 }
  135.                                                  else {
  136.                                                     $output .= '<a class="play-icon" href="'.get_permalink().'">
  137.                                                    <i class="themeum-moviewenter"></i>
  138.                                                    </a>';
  139.                                                 }
  140.                                             }
  141.                                         }
  142.                                     }
  143.                                 }
  144.                             $output .= '</div>';//movie-poster
  145.                             $output .= '<div class="movie-details">';
  146.                                 $output .= '<div class="movie-rating-wrapper">';
  147.                                 if (function_exists('themeum_wp_rating')) {
  148.                                     $output .= '<div class="movie-rating">';
  149.                                         $output .= '<span class="themeum-moviewstar active"></span>';
  150.                                     $output .= '</div>';
  151.                                     $output .= '<span class="rating-summary"><span>'.themeum_wp_rating(get_the_ID(),'single').'</span>/10</span>';
  152.                                 }
  153.                                 $output .= '</div>';//movie-rating-wrapper
  154.                                 $year ='';
  155.                                 if ($release_year) {
  156.                                     $year =  '('.esc_attr($release_year).')';
  157.                                 }
  158.                                 $output .= '<div class="movie-name">';
  159.                                     $output .= '<h4 class="movie-title"><a href="'.get_the_permalink().'">'.get_the_title().$year.'</a></h4>';
  160.                                     if ($movie_type) {
  161.                                         $output .= '<span class="tag">'.esc_attr($movie_type).'</span>';
  162.                                     }
  163.                                 $output .= '</div>';//movie-name
  164.                             $output .= '</div>';//movie-details
  165.                         $output .= '</div> ';//item
  166.                     endwhile;
  167.                     wp_reset_query();
  168.                 $output .= '</div>';//moview-common-layout
  169.             }
  170.             // Top Rated close
  171.            
  172.  
  173.             // coming soon open
  174.             if( $recently_released == 'on' ) {
  175.                 $output .= '<div class="spotlight moview-common-layout tab-pane fade in" id="recently-released">';
  176.                     $arr = array(
  177.                                     'post_type'     => 'movie',
  178.                                     /*'meta_query'    => array(
  179.                                                         array(
  180.                                                         'key'       => 'themeum_release_date',
  181.                                                         'value'     => date("Y-m-d", strtotime( date("Y-m-d") )),
  182.                                                         'compare'   =>'<',
  183.                                                         'type'      =>'date',
  184.                                                     )),*/
  185.                                     'meta_key'       => 'themeum_release_date',
  186.                                     'meta_value'     => date("Y-m-d", strtotime( date("Y-m-d") )),
  187.                                     'meta_type'      => 'DATE',
  188.                                     'meta_compare'   => '<',
  189.                                     'orderby'        => 'meta_value',
  190.                                     'order'          => 'DESC',
  191.  
  192.                                     'post_status'       => 'publish',
  193.                                     // 'orderby'           => 'meta_value_date',
  194.                                     // 'order'             => 'ASC',
  195.                                     // 'meta_key'          => 'themeum_release_date',
  196.                                     // 'meta_value'        => date("Y-m-d", strtotime( date("Y-m-d") )),
  197.                                     // 'meta_type'         => 'DATE',
  198.                                     'posts_per_page'    => $number
  199.                                 );
  200.                     query_posts( $arr ); while (have_posts()) : the_post();
  201.                     $movie_type      = esc_attr(get_post_meta(get_the_ID(),'themeum_movie_type',true));
  202.                     $movie_trailer_info     = get_post_meta(get_the_ID(),'themeum_movie_trailer_info',true);
  203.                     $release_year    = get_post_meta(get_the_ID(),'themeum_movie_release_year',true);
  204.                        $output .= '<div class="item">';
  205.                             $output .= '<div class="movie-poster">';
  206.                                 $output .= get_the_post_thumbnail(get_the_ID(),'moview-profile', array('class' => 'img-responsive'));
  207.                                 if( is_array(($movie_trailer_info)) ) {
  208.                                     if(!empty($movie_trailer_info)) {
  209.                                         foreach( $movie_trailer_info as $key=>$value ){
  210.                                             if ($key==0) {
  211.                                                 if ($value["themeum_video_link"]) {
  212.                                                     $output .= '<a class="play-icon play-video" href="'.$value["themeum_video_link"].'" data-type="'.esc_attr($value["themeum_video_source"]).'">
  213.                                                    <i class="themeum-moviewplay"></i>
  214.                                                    </a>';
  215.                                                     $output .= '<div class="content-wrap">';
  216.                                                         $output .= '<div class="video-container">';
  217.                                                             $output .= '<span class="video-close">x</span>';
  218.                                                         $output .= '</div>';
  219.                                                     $output .= '</div>'; //content-wrap
  220.                                                 }
  221.                                                  else {
  222.                                                     $output .= '<a class="play-icon" href="'.get_permalink().'">
  223.                                                    <i class="themeum-moviewenter"></i>
  224.                                                    </a>';
  225.                                                 }
  226.                                             }
  227.                                         }
  228.                                     }
  229.                                 }
  230.                             $output .= '</div>';//movie-poster
  231.                             $output .= '<div class="movie-details">';
  232.                                 $output .= '<div class="movie-rating-wrapper">';
  233.                                 if (function_exists('themeum_wp_rating')) {
  234.                                     $output .= '<div class="movie-rating">';
  235.                                         $output .= '<span class="themeum-moviewstar active"></span>';
  236.                                     $output .= '</div>';
  237.                                     $output .= '<span class="rating-summary"><span>'.themeum_wp_rating(get_the_ID(),'single').'</span>/10</span>';
  238.                                 }
  239.                                 $output .= '</div>';//movie-rating-wrapper
  240.                                 $year ='';
  241.                                 if ($release_year) {
  242.                                     $year =  '('.esc_attr($release_year).')';
  243.                                 }
  244.                                 $output .= '<div class="movie-name">';
  245.                                     $output .= '<h4 class="movie-title"><a href="'.get_the_permalink().'">'.get_the_title().$year.'</a></h4>';
  246.                                     if ($movie_type) {
  247.                                         $output .= '<span class="tag">'.esc_attr($movie_type).'</span>';
  248.                                     }
  249.                                 $output .= '</div>';//movie-name
  250.                             $output .= '</div>';//movie-details
  251.                         $output .= '</div> '; //item
  252.                     endwhile;
  253.                     wp_reset_query();
  254.                 $output .= '</div>';//moview-common-layout
  255.             }
  256.             // coming soon close
  257.  
  258.         $output .= '</div>'; //tab-content
  259.     $output .= '</div>';//spotlight-post
  260.  
  261.  
  262.  
  263.     return $output;
  264.  
  265. });
  266.  
  267.  
  268. //Visual Composer
  269. if (class_exists('WPBakeryVisualComposerAbstract')) {
  270. vc_map(array(
  271.     "name" => __("Spotlight", "themeum-core"),
  272.     "base" => "themeum_spotlight",
  273.     'icon' => 'icon-thm-title',
  274.     "class" => "",
  275.     "description" => __("Widget Title Heading", "themeum-core"),
  276.     "category" => __('Moview', "themeum-core"),
  277.     "params" => array(
  278.  
  279.     array(
  280.         "type" => "textfield",
  281.         "heading" => esc_html__("Number of items", 'themeum-core'),
  282.         "param_name" => "number",
  283.         "value" => "20",
  284.         ),  
  285.  
  286.     array(
  287.         "type" => "dropdown",
  288.         "heading" => __("Latest Section:", "themeum-core"),
  289.         "param_name" => "latest_section",
  290.         "value" => array('On'=>'on','OFF'=>'off'),
  291.         ),
  292.     array(
  293.         "type" => "dropdown",
  294.         "heading" => __("Coming Soon:", "themeum-core"),
  295.         "param_name" => "coming_soon",
  296.         "value" => array('On'=>'on','OFF'=>'off'),
  297.         ),
  298.     array(
  299.         "type" => "dropdown",
  300.         "heading" => __("Top Rated:", "themeum-core"),
  301.         "param_name" => "top_rated",
  302.         "value" => array('On'=>'on','OFF'=>'off'),
  303.         ),
  304.  
  305.  
  306.         )
  307.     ));
  308. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement