Advertisement
rejuancse

topheadline

Jan 10th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.20 KB | None | 0 0
  1. <?php
  2. if ( ! defined( 'ABSPATH' ) ) {
  3.     exit; # Exit if accessed directly
  4. }
  5.  
  6. # Upcoming posts
  7. add_shortcode( 'themeum_topheadline', function($atts, $content = null){
  8.  
  9.     extract(shortcode_atts(array(
  10.         'post_category'         => '',
  11.         'slidecolumn'       => '',
  12.         'title'         => '',
  13.         'introtext'     => '',
  14.         'count'         => '3',
  15.         'order'         => 'DESC',
  16.         'order_by'      => 'date',
  17.         'class'         => '',
  18.         'slidenav'      => 'true',
  19.         'autoplay'      => 'true',
  20.     ), $atts));
  21.  
  22.     global $post;
  23.  
  24.     $output     = '';
  25.     $posts= 0;
  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'           => 'meta_value_num',
  36.                 'meta_key'          => 'themeum_headline',
  37.                 'order'             => $order,
  38.                 'posts_per_page'    => $number,
  39.             );
  40.             $posts = get_posts($args);
  41.         }
  42.     }else{
  43.         $args = array(
  44.             'orderby'           => 'meta_value_num',
  45.             'meta_key'          => 'themeum_headline',
  46.             'order'             => $order,
  47.             'posts_per_page'    => $number,
  48.         );
  49.         $posts = get_posts($args);
  50.     }
  51.  
  52.     $output .= '<div class="topheadline '.esc_attr($class).'">';
  53.         $output  .= '<div data-number="'.esc_attr($slidecolumn).'" class="jihad owl-carousel owl-theme '.esc_attr($layout).'">';       
  54.             if( count($posts) > 0 ){
  55.                 foreach ($posts as $key=>$post) {
  56.                     setup_postdata( $post );   
  57.                     $output .= '<div class="themeum-course-in item">';
  58.                         if ( has_post_thumbnail()) {
  59.                             $output .= '<a class="review-item-image"  href="'.get_permalink().'">'.get_the_post_thumbnail($post->ID, 'wpeducon-small', array('class' => 'img-responsive')).'</a>';
  60.                         }
  61.                         $output .= '<h3><a href="' . get_permalink() . '">' . get_the_title() . '</a></h3>';
  62.                     $output .= '</div>';//themeum-feature-course
  63.                 }
  64.                 wp_reset_postdata();
  65.             }
  66.         $output .= '</div>';//themeum-feature-course
  67.     $output .= '</div>';//adons-themeum-feature-carosuel
  68.  
  69.     return $output;
  70.  
  71. });
  72.  
  73.  
  74. function themeum_category_list(){
  75.     $cat_lists = get_categories();
  76.     $all_cat_list = array('All Category'=>'');
  77.     foreach($cat_lists as $cat_list){
  78.         $all_cat_list[$cat_list->cat_name] = $cat_list->cat_name;
  79.     }
  80.     return $all_cat_list;
  81. }
  82.  
  83. # Visual Composer
  84. if (class_exists('WPBakeryVisualComposerAbstract')) {
  85. vc_map(array(
  86.     "name"              => esc_html__("Top Headline", 'themeum-core'),
  87.     "base"              => "themeum_topheadline",
  88.     'icon'              => 'icon-thm-title',
  89.     "class"             => "",
  90.     "description"       => esc_html__("Widget Title Heading", 'themeum-core'),
  91.     "category"          => esc_html__('Educon', 'themeum-core'),
  92.     "params"            => array(
  93.  
  94.             array(
  95.                 "type"              => "dropdown",
  96.                 "heading"           => __("Category Filter", "themeum-core"),
  97.                 "param_name"        => "post_category",
  98.                 "value"             => themeum_category_list(),
  99.             ),
  100.             array(
  101.                 "type"              => "textfield",
  102.                 "heading"           => __("Title", "themeum-core"),
  103.                 "param_name"        => "title",
  104.                 "value"             => "",
  105.                 "admin_label"       =>true,
  106.             ),
  107.             array(
  108.                 "type"              => "textarea",
  109.                 "heading"           => __("Intro Text", "themeum-core"),
  110.                 "param_name"        => "introtext",
  111.                 "value"             => "",
  112.             ),
  113.             array(
  114.                 "type"              => "dropdown",
  115.                 "class"             => "",
  116.                 "heading"           => esc_html__("Select Column Number",'themeum-core'),
  117.                 "param_name"        => "slidecolumn",
  118.                 "value"             => array(
  119.                     esc_html__("Select",'themeum-core')     =>'',
  120.                     esc_html__("Column 1",'themeum-core')   => '1',
  121.                     esc_html__("Column 2",'themeum-core')   => '2',
  122.                     esc_html__("Column 3",'themeum-core')   => '3',
  123.                     esc_html__("Column 4",'themeum-core')   => '4',
  124.                     esc_html__("Column 5",'themeum-core')   => '5',
  125.                 ),
  126.             ),
  127.             array(
  128.                 "type"              => "textfield",
  129.                 "heading"           => __("Number of posts", "themeum-core"),
  130.                 "param_name"        => "count",
  131.                 "value"             => "",
  132.             ), 
  133.             array(
  134.                 "type"              => "dropdown",
  135.                 "class"             => "",
  136.                 "heading"           => __("Auto Play",'themeum-core'),
  137.                 "param_name"        => "autoplay",
  138.                 "value"             => array('None'=>'','True'=>'true','False'=>'false'),
  139.                 "dependency"        => Array("element" => "layout", "value" => array("carosuel")),
  140.             ),
  141.             array(
  142.                 "type"              => "dropdown",
  143.                 "class"             => "",
  144.                 "heading"           => __("Show Navigation",'themeum-core'),
  145.                 "param_name"        => "slidenav",
  146.                 "value"             => array('None'=>'','True'=>'true','False'=>'false'),
  147.                 "dependency"        => Array("element" => "layout", "value" => array("carosuel")),
  148.             ),                 
  149.             array(
  150.                 "type"              => "dropdown",
  151.                 "heading"           => esc_html__("Order", 'themeum-core'),
  152.                 "param_name"        => "order",
  153.                 "value"             => array('None'=>'','DESC'=>'DESC','ASC'=>'ASC'),
  154.             ),
  155.             array(
  156.                 "type"              => "dropdown",
  157.                 "heading"           => esc_html__("OderBy", 'themeum-core'),
  158.                 "param_name"        => "order_by",
  159.                 "value"             => array('None'=>'','Date'=>'date','Title'=>'title','Modified'=>'modified','Author'=>'author','Random'=>'rand'),
  160.             ),             
  161.             array(
  162.                 "type"              => "textfield",
  163.                 "heading"           => esc_html__("Extra CSS Class", "themeum-core"),
  164.                 "param_name"        => "class",
  165.                 "value"             => "",
  166.             ),
  167.         )
  168.     ));
  169. }
  170. ?>
  171.  
  172.  
  173. <script type="text/javascript">
  174.     var $headline = $('.jihad');
  175.     var $testicount  = $headline.data('number');
  176.     var $testiautoplay  = $headline.data('aplay');
  177.     var $testnav  = $headline.data('testnav');
  178.     $headline.owlCarousel({
  179.        loop:true,
  180.        dots:false,
  181.        nav:true,
  182.        margin:30,
  183.        rtl:rtl,
  184.        autoplay:$testiautoplay,
  185.        autoplayTimeout:3000,
  186.        autoplayHoverPause:true,
  187.        autoHeight: false,
  188.        smartSpeed:400,
  189.        nav:$testnav,
  190.        navText: ['<i class="fa fa-angle-left">','<i class="fa fa-angle-right">'],
  191.        lazyLoad:false,
  192.        responsive:{
  193.            0:{
  194.                items:1
  195.            },
  196.            600:{
  197.                items:1
  198.            },
  199.            1000:{
  200.                items: $testicount,
  201.            }
  202.        },
  203.        onInitialized: function() {
  204.            $('.owl-item.active').first().addClass('last-owl-active-item');
  205.        }
  206.     });
  207. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement