Advertisement
Guest User

Klikabilna slika na klizaču

a guest
Nov 16th, 2018
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.08 KB | None | 0 0
  1. /*********************** magbook Category SLIDERS ***********************************/
  2. function magbook_category_sliders() {
  3.     global $post;
  4.     $magbook_settings = magbook_get_theme_options();
  5.     global $excerpt_length;
  6.     $magbook_tag_text = $magbook_settings['magbook_tag_text'];
  7.     $magbook_slider_design_layout = $magbook_settings['magbook_slider_design_layout'];
  8.     $entry_format_meta_blog = $magbook_settings['magbook_entry_meta_blog'];
  9.     $category = $magbook_settings['magbook_default_category_slider'];
  10.     $magbook_small_slider_post_category = $magbook_settings['magbook_small_slider_post_category'];
  11.     $query = new WP_Query(array(
  12.                 'posts_per_page' =>  intval($magbook_settings['magbook_slider_number']),
  13.                 'post_type' => array(
  14.                     'post'
  15.                 ) ,
  16.                 'category_name' => esc_attr($category),
  17.             ));
  18.  
  19.     $small_query = new WP_Query(array(
  20.                 'posts_per_page' =>  4,
  21.                 'post_type' => array(
  22.                     'post'
  23.                 ) ,
  24.                 'category_name' => esc_attr($magbook_small_slider_post_category),
  25.             ));
  26.    
  27.     if(($query->have_posts() ) ||  ($small_query->have_posts() && !empty($magbook_small_slider_post_category) ) ){ ?>
  28.  
  29.         <div class="main-slider clearfix">
  30.         <?php
  31.         if ($magbook_slider_design_layout=='no-slider'){
  32.             echo  '<div class="no-slider">';
  33.         } elseif ($magbook_slider_design_layout=='layer-slider'){
  34.             echo  '<div class="layer-slider">';
  35.         } elseif ($magbook_slider_design_layout=='small-slider'){
  36.         echo '<div class="small-slider">';
  37.         } else {
  38.             echo  '<div class="multi-slider">';
  39.         }
  40.         echo  '<ul class="slides">';
  41.         while ($query->have_posts()):$query->the_post();
  42.             $attachment_id = get_post_thumbnail_id();
  43.             $image_attributes = wp_get_attachment_image_src($attachment_id,'magbook_slider_image');
  44.             $title_attribute = apply_filters('the_title', get_the_title(get_queried_object_id()));
  45.             $excerpt = get_the_excerpt();
  46.                 echo '<li>';
  47.                 if ($image_attributes) {
  48.                     echo  '<div class="image-slider" title="'.the_title_attribute('echo=0').'"' .' style="background-image:url(' ."'" .esc_url($image_attributes[0])."'" .')">';
  49.                 }else{
  50.                     echo  '<div class="image-slider">';
  51.                 }
  52.                 echo  '<article class="slider-content">';
  53.                 if ($title_attribute != '' || $excerpt != '') {
  54.                     echo  '<div class="slider-text-content">';
  55.  
  56.                     if($entry_format_meta_blog != 'hide-meta' ){
  57.                         echo  '<div class="entry-meta">';
  58.                             do_action('magbook_post_categories_list_id');
  59.                         echo '</div> <!-- end .entry-meta -->';
  60.                     }
  61.                    
  62.                     $remove_link = $magbook_settings['magbook_slider_link'];
  63.                         if($remove_link == 0){
  64.                             if ($title_attribute != '') {
  65.                                 echo '<h2 class="slider-title"><a href="'.esc_url(get_permalink()).'" title="'.the_title_attribute('echo=0').'" rel="bookmark">'.get_the_title().'</a></h2><!-- .slider-title -->';
  66.                             }
  67.                         }else{
  68.                             echo '<h2 class="slider-title">'.get_the_title().'</h2><!-- .slider-title -->';
  69.                         }
  70.  
  71.                         if ($excerpt != '') {
  72.                             echo '<p class="slider-text">'.wp_strip_all_tags( get_the_excerpt(), true ).'</p><!-- end .slider-text -->';
  73.                         }
  74.                     if($entry_format_meta_blog != 'hide-meta' ){
  75.                         echo  '<div class="entry-meta">';
  76.                         echo '<span class="author vcard"><a href="'.get_author_posts_url( get_the_author_meta( 'ID' ) ).'" title="'.the_title_attribute('echo=0').'"><i class="fa fa-user-o"></i> ' .esc_attr(get_the_author()).'</a></span>';
  77.                         printf( '<span class="posted-on"><a href="%1$s" title="%2$s"><i class="fa fa-calendar-o"></i> %3$s</a></span>',
  78.                                             esc_url(get_the_permalink()),
  79.                                             esc_attr( get_the_time(get_option( 'date_format' )) ),
  80.                                             esc_attr( get_the_time(get_option( 'date_format' )) )
  81.                                         );
  82.  
  83.                         if ( comments_open()) { ?>
  84.                                 <span class="comments">
  85.                                 <?php comments_popup_link( __( '<i class="fa fa-comment-o"></i> No Comments', 'magbook' ), __( '<i class="fa fa-comment-o"></i> 1 Comment', 'magbook' ), __( '<i class="fa fa-comment-o"></i> % Comments', 'magbook' ), '', __( 'Comments Off', 'magbook' ) ); ?> </span>
  86.                         <?php }
  87.                         echo  '</div> <!-- end .entry-meta -->';
  88.                     }
  89.                     echo  '</div><!-- end .slider-text-content -->';
  90.                 }
  91.                 if( $magbook_settings['magbook_slider_button'] == 0 && $magbook_tag_text !='' ){
  92.                     echo '<div class="slider-buttons">';
  93.                     echo  '<a title='.'"'.the_title_attribute('echo=0'). '"'. ' '.'href="'.esc_url(get_permalink()).'"'.' class="btn-default">'.esc_attr($magbook_tag_text).'</a>';
  94.                    
  95.                     echo  '</div><!-- end .slider-buttons -->';
  96.                 }
  97.                 echo '</article><!-- end .slider-content --> ';
  98.                 echo '</div><!-- end .image-slider -->
  99.                 </li>';
  100.             endwhile;
  101.             wp_reset_postdata(); ?>
  102.             </ul><!-- end .slides -->
  103.         </div> <!-- end .layer-slider -->
  104.         <?php if ($magbook_settings['magbook_slider_design_layout']=='small-slider'){ ?>
  105.         <div class="small-sld-cat">
  106.             <?php
  107.             while ($small_query->have_posts()):$small_query->the_post(); ?>
  108.                     <article id="post-<?php the_ID(); ?>" <?php post_class();?>>
  109.                     <div class="sld-cat-wrap">
  110.                         <?php if( has_post_thumbnail() ){ ?>
  111.                             <div class="sld-cat-image">
  112.                                 <figure class="post-featured-image">
  113.                                     <a href="<?php the_permalink();?>" title="<?php echo the_title_attribute('echo=0'); ?>">
  114.                                         <?php the_post_thumbnail('magbook-featured-image'); ?>
  115.                                     </a>
  116.                                 </figure>
  117.                                 <!-- end .post-featured-image -->
  118.                             </div>
  119.                             <!-- end .sld-cat-image -->
  120.                             <?php } ?>
  121.                             <div class="sld-cat-text">
  122.                                 <header class="entry-header">      
  123.                                     <h2 class="entry-title">
  124.                                          <a href="<?php the_permalink(); ?>" title="<?php echo the_title_attribute('echo=0'); ?>"> <?php the_title();?> </a>
  125.                                     </h2>
  126.                                     <!-- end.entry-title -->
  127.                                     <?php if($entry_format_meta_blog != 'hide-meta' ){
  128.                                         echo  '<div class="entry-meta">';
  129.                                         echo '<span class="author vcard"><a href="'.get_author_posts_url( get_the_author_meta( 'ID' ) ).'" title="'.the_title_attribute('echo=0').'"><i class="fa fa-user-o"></i> ' .esc_attr(get_the_author()).'</a></span>';
  130.                                         printf( '<span class="posted-on"><a href="%1$s" title="%2$s"><i class="fa fa-calendar-o"></i> %3$s</a></span>',
  131.                                                             esc_url(get_the_permalink()),
  132.                                                             esc_attr( get_the_time(get_option( 'date_format' )) ),
  133.                                                             esc_attr( get_the_time(get_option( 'date_format' )) )
  134.                                                         ); ?>
  135.  
  136.                                         <?php if ( comments_open()) { ?>
  137.                                                 <span class="comments">
  138.                                                 <?php comments_popup_link( __( '<i class="fa fa-comment-o"></i> No Comments', 'magbook' ), __( '<i class="fa fa-comment-o"></i> 1 Comment', 'magbook' ), __( '<i class="fa fa-comment-o"></i> % Comments', 'magbook' ), '', __( 'Comments Off', 'magbook' ) ); ?> </span>
  139.                                         <?php }
  140.                                         echo  '</div> <!-- end .entry-meta -->';
  141.                                     } ?>
  142.                                 </header>
  143.                                 <!-- end .entry-header -->
  144.                             </div>
  145.                             <!-- end .sld-cat-text -->
  146.                         </div>
  147.                         <!-- end .sld-cat-wrap -->
  148.                     </article>
  149.                     <!-- end .post -->
  150.             <?php  endwhile;
  151.             wp_reset_postdata(); ?>
  152.         </div> <!-- end .small-sld-cat-->
  153.         <?php } ?>
  154.     </div> <!-- end .main-slider -->
  155. <?php }
  156. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement