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(
- 'style' => 'style1',
- 'category' => '',
- 'number' => '4',
- 'class' => '',
- 'order_by' => 'date',
- 'order' => 'DESC',
- 'time' => '',
- 'disable_slider' => '',
- 'slidenav' => 'true',
- 'autoplay' => 'true',
- ), $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' => -1,
- );
- $posts = get_posts($args);
- }
- }else{
- $args = array(
- 'orderby' => $order_by,
- 'order' => $order,
- 'posts_per_page' => -1,
- );
- $posts = get_posts($args);
- }
- $output = '';
- if($disable_slider == 'enable'){
- $time = 'false';
- }
- if ($style == 'style1') {
- $output .= '<div class="row">';
- $output .= '<div data-number="1" 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-6
- $output .= '</div>'; # row
- $output .= '</div>'; # container
- $output .= '</div>'; # item
- $j++;
- }
- }
- wp_reset_postdata();
- $output .= '</div>';
- $output .= '</div>';
- }elseif ($style == 'style2') {
- $output .= '<div class="row">';
- $output .= '<div data-number="1" data-aplay="'.esc_attr($rautoplay).'" data-testnav="'.esc_attr($rslidenav).'" class="slider-style1 style-two 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 style2 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-6
- $output .= '</div>'; # row
- $output .= '</div>'; # container
- $output .= '</div>'; # item
- $j++;
- }
- }
- wp_reset_postdata();
- $output .= '</div>';
- $output .= '</div>';
- }else {
- $output .= '<div class="row">';
- $output .= '<div class="padding-zero col-sm-8">';
- $output .= '<div data-number="1" data-aplay="'.esc_attr($rautoplay).'" data-testnav="'.esc_attr($rslidenav).'" class="slider-style3 owl-carousel owl-theme">';
- $j=0;
- foreach ($posts as $post){
- if($j==3){
- break;
- }
- 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:492px; 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:480px; background-image: url('.esc_url($image_url[0]).');background-repeat:no-repeat;background-size:cover;background-position:center;">';
- }
- $output .= '<div class="post-slider-wrap col-md-10 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-6
- $output .= '</div>'; # item
- $j++;
- }
- }
- wp_reset_postdata();
- $output .= '</div>';
- $output .= '</div>';
- $output .= '<div class="padding-zero col-sm-4">';
- $tt = 0;
- foreach ($posts as $post){
- if( $tt == 3 || $tt == 4 ){
- setup_postdata( $post );
- if ( has_post_thumbnail() ) {
- $image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' );
- $output .= '<div class="item" style="min-height:246px; background-image: url('.esc_url($image_url[0]).');background-repeat:no-repeat;background-size:cover;background-position:center;">';
- $output .= '<div class="post-slider-wrap style3">';
- $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 .= '<h3 class="slider-title"><a href="'.get_permalink().'">'.get_the_title().'</a></h3>';
- // $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-6
- $output .= '</div>'; # item
- }
- }
- $tt++;
- }
- $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" => __("Style", "themeum"),
- "param_name" => "style",
- "value" => array('Select'=>'','Style1'=>'style1','Style2'=>'style2', 'Style3' => 'style3'),
- ),
- 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" => __("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"
- ),
- )
- ));
- }
- .slider-style1 .owl-nav {
- display: none;
- }
- .slider-style1.owl-carousel.owl-loaded {
- display: block;
- width: calc(100% + 80px);
- margin-left: -40px;
- overflow: hidden;
- }
- .slider-style1 .owl-item.active .item {
- width: calc(1170px + 80px) !important;
- z-index: 9999;
- position: absolute;
- }
- .slider-style1.owl-carousel .owl-dots {
- position: absolute;
- left: 75px;
- bottom: 12%;
- }
- .slider-style1.owl-carousel .owl-stage-outer {
- overflow: inherit;
- }
- .post-slider-innner {
- margin-left: 18px;
- }
- .post-slider-wrap.style2 {
- transform: translate(-50%,0%);
- left: 49%;
- top: 26%;
- text-align: center;
- }
- .slider-style1.style-two.owl-carousel .owl-dots {
- bottom: 12%;
- transform: translate(-50%,0%);
- left: 50.1%;
- text-align: center;
- }
- .slider-style1 .item:after {
- content: "";
- width: 100%;
- height: 100%;
- bottom: 0;
- background: rgba(0, 0, 0, 0.3);
- position: absolute;
- z-index: -1;
- }
- .padding-zero.col-sm-8, .padding-zero.col-sm-4 {
- padding: 0;
- }
- .slider-style3.owl-carousel .owl-item.active {
- width: calc(750px + 30px) !important;
- }
- .slider-style3 .owl-controls .owl-nav{
- display: none !important;
- }
- .slider-style3 .owl-dots {
- left: 40px !important;
- bottom: 12% !important;
- }
- .padding-zero .item {
- position: relative;
- }
- .post-slider-wrap.style3 .post-slider-innner {
- margin-left: 18px;
- margin-top: 62px;
- }
- .post-slider-wrap.style3 .post-slider-in .slider-title a {
- font-size: 24px;
- font-weight: 700;
- color: #FFFFFF;
- line-height: 30px;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement