Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Themeum Post Slider
- */
- add_shortcode( 'themeum_post_slider', function( $atts, $content = null ) {
- extract(shortcode_atts(array(
- 'category' => '',
- 'number' => '4',
- 'class' => '',
- 'order_by' => 'date',
- 'order' => 'DESC',
- 'time' => '',
- 'disable_slider' => '',
- 'slidenav' => 'true',
- 'autoplay' => 'true',
- 'slidecolumn' => '4',
- ), $atts));
- global $post;
- $posts= 0;
- if (isset($category) && $category!='') {
- $idObj = get_category_by_slug( $category );
- if (isset($idObj) && $idObj!='') {
- $idObj = get_category_by_slug( $category );
- $cat_id = $idObj->term_id;
- $args = array(
- 'category' => $cat_id,
- 'orderby' => $order_by,
- 'order' => $order,
- 'posts_per_page' => $number,
- );
- $posts = get_posts($args);
- }
- }else{
- $args = array(
- 'orderby' => $order_by,
- 'order' => $order,
- 'posts_per_page' => $number,
- );
- $posts = get_posts($args);
- }
- $output = '';
- if($disable_slider == 'enable'){
- $time = 'false';
- }
- // $output .= '<div class="row">';
- $output .= '<div data-number="'.esc_attr($slidecolumn).'" data-aplay="'.esc_attr($rautoplay).'" data-testnav="'.esc_attr($rslidenav).'" class="slider-style1 owl-carousel owl-theme">';
- $j=0;
- foreach ($posts as $post){
- setup_postdata( $post );
- if ( has_post_thumbnail() ) {
- $image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
- if( $j == 0 ){
- $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;">';
- }else{
- $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;">';
- }
- $output .= '<div class="container">';
- $output .= '<div class="row">';
- $output .= '<div class="post-slider-wrap col-md-6 col-sm-6 col-xs-12">';
- $output .= '<div class="post-slider-in clearfix">';
- $output .= '<div class="post-slider-innner">';
- $output .= '<span class="entry-category">';
- $output .= get_the_category_list(', ');
- $output .= '</span>';
- $output .= '<h2 class="slider-title"><a href="'.get_permalink().'">'.get_the_title().'</a></h2>';
- $output .= '<p class="slider-excerpt">'.calcio_excerpt_max_charlength(100).'</p>';
- $output .= '</div>'; //handpick-slider-innner
- $output .= '</div>'; //handpick-slider-in
- $output .= '</div>'; //col-sm-7
- $output .= '</div>'; //row
- $output .= '</div>'; //container
- $output .= '</div>'; //item
- $j++;
- }
- }
- wp_reset_postdata();
- $output .= '</div>';
- // $output .= '</div>';
- # JS time
- $output .= "<script type='text/javascript'>jQuery(document).ready(function() { jQuery('.nano').nanoScroller(); jQuery('#themeum-post-slider').carousel({ interval: ".$time." }) });</script>";
- return $output;
- });
- function themeum_post_cat_list(){
- $cat_lists = get_categories();
- $all_cat_list = array('All Category'=>'');
- foreach($cat_lists as $cat_list){
- $all_cat_list[$cat_list->cat_name] = $cat_list->cat_name;
- }
- return $all_cat_list;
- }
- # Visual Composer
- if (class_exists('WPBakeryVisualComposerAbstract')) {
- vc_map(array(
- "name" => esc_html__("Themeum Post Slider", 'themeum-core'),
- "base" => "themeum_post_slider",
- 'icon' => 'icon-thm-slide',
- "class" => "",
- "description" => esc_html__("Widget Title Heading", 'themeum-core'),
- "category" => __('Calcio', "themeum-core"),
- "params" => array(
- array(
- "type" => "dropdown",
- "heading" => esc_html__("Category Name", 'themeum-core'),
- "param_name" => "category",
- "value" => themeum_post_cat_list(),
- ),
- array(
- "type" => "textfield",
- "heading" => esc_html__("Number of items", 'themeum-core'),
- "param_name" => "number",
- "value" => "",
- ),
- array(
- "type" => "dropdown",
- "heading" => esc_html__("OderBy", 'themeum-core'),
- "param_name" => "order_by",
- "value" => array('Date'=>'date','Title'=>'title','Modified'=>'modified','Author'=>'author','Random'=>'rand'),
- ),
- array(
- "type" => "dropdown",
- "heading" => esc_html__("Order", 'themeum-core'),
- "param_name" => "order",
- "value" => array('DESC'=>'DESC','ASC'=>'ASC'),
- ),
- array(
- "type" => "textfield",
- "heading" => esc_html__("Custom Class", 'themeum-core'),
- "param_name" => "class",
- "value" => "",
- ),
- array(
- "type" => "checkbox",
- "class" => "",
- "heading" => esc_html__("Disable Slider: ","themeum-core"),
- "param_name" => "disable_slider",
- "value" => array ( esc_html__('Disable','themeum-core') => 'enable'),
- "description" => esc_html__("If you want disable slide check this.","themeum-core"),
- "group" => "Slide"
- ),
- array(
- "type" => "dropdown",
- "class" => "",
- "heading" => esc_html__("Select Column Number",'themeum-core'),
- "param_name" => "slidecolumn",
- "value" => array(
- esc_html__("Select",'themeum-core') =>'',
- esc_html__("Column 1",'themeum-core') => '1',
- esc_html__("Column 2",'themeum-core') => '2',
- esc_html__("Column 3",'themeum-core') => '3',
- esc_html__("Column 4",'themeum-core') => '4',
- esc_html__("Column 5",'themeum-core') => '5',
- ),
- ),
- array(
- "type" => "dropdown",
- "class" => "",
- "heading" => __("Auto Play",'themeum-core'),
- "param_name" => "autoplay",
- "value" => array('None'=>'','True'=>'true','False'=>'false'),
- ),
- array(
- "type" => "dropdown",
- "class" => "",
- "heading" => __("Show Navigation",'themeum-core'),
- "param_name" => "slidenav",
- "value" => array('None'=>'','True'=>'true','False'=>'false'),
- ),
- array(
- "type" => "textfield",
- "heading" => esc_html__("Sliding Time(Milliseconds Ex: 4000)", "themeum-core"),
- "param_name" => "time",
- "value" => "3000",
- "group" => "Slide"
- ),
- )
- ));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement