Advertisement
Guest User

themeum-spotlight

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