Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * The template for displaying the Slider
- *
- * @package Catch_Fullscreen
- */
- if ( ! function_exists( 'catch_fullscreen_featured_slider' ) ) :
- /**
- * Add slider.
- *
- * @uses action hook catch_fullscreen_before_content.
- *
- * @since Catch Fullscreen Pro 1.0
- */
- function catch_fullscreen_featured_slider() {
- $enable_slider = get_theme_mod( 'catch_fullscreen_slider_option', 'disabled' );
- if ( catch_fullscreen_check_section( $enable_slider ) ) {
- $type = get_theme_mod( 'catch_fullscreen_slider_type', 'category' );
- $transition_effect = get_theme_mod( 'catch_fullscreen_slider_transition_effect', 'fade' );
- $transition_length = get_theme_mod( 'catch_fullscreen_slider_transition_length', 1 );
- $transition_delay = get_theme_mod( 'catch_fullscreen_slider_transition_delay', 4 );
- $image_loader = get_theme_mod( 'catch_fullscreen_slider_image_loader', false );
- $pause_on_hover = get_theme_mod( 'catch_fullscreen_pause_on_hover', 1 );
- if( $pause_on_hover ) {
- $value = 'true';
- } else {
- $value = 'false';
- }
- $anchor = get_theme_mod( 'catch_fullscreen_slider_anchor', 'featured-slider-section' );
- $output = '
- <div id="feature-slider-section" data-anchor="' . esc_attr( $anchor ) . '" class="section">
- <div class="wrapper">
- <div class="cycle-slideshow"
- data-cycle-log="false"
- data-cycle-pause-on-hover="' . esc_attr( $value ) . '"
- data-cycle-swipe="true"
- data-cycle-auto-height=container
- data-cycle-fx="' . esc_attr( $transition_effect ) . '"
- data-cycle-speed="' . esc_attr( $transition_length * 1000 ) . '"
- data-cycle-timeout="' . esc_attr( $transition_delay * 1000 ) . '"
- data-cycle-loader="' . esc_attr( $image_loader ) . '"
- data-cycle-slides="> article"
- >
- <!-- prev/next links -->
- <button class="cycle-prev" aria-label="Previous"><span class="screen-reader-text">' . esc_html__( 'Previous Slide', 'catch-fullscreen-pro' ) . '</span>' . catch_fullscreen_get_svg( array( 'icon' => 'angle-down' ) ) . '</button>
- <button class="cycle-next" aria-label="Next"><span class="screen-reader-text">' . esc_html__( 'Next Slide', 'catch-fullscreen-pro' ) . '</span>' . catch_fullscreen_get_svg( array( 'icon' => 'angle-down' ) ) . '</button>
- <!-- empty element for pager links -->
- <div class="cycle-pager"></div>';
- // Select Slider
- if ( 'post' === $type || 'page' === $type || 'category' === $type ) {
- $output .= catch_fullscreen_post_page_category_slider();
- } elseif ( 'image' === $type ) {
- $output .= catch_fullscreen_image_slider();
- }
- $output .= '
- </div><!-- .cycle-slideshow -->
- </div><!-- .wrapper -->
- </div><!-- #feature-slider -->';
- echo $output;
- } // End if().
- }
- endif;
- add_action( 'catch_fullscreen_slider', 'catch_fullscreen_featured_slider', 10 );
- if ( ! function_exists( 'catch_fullscreen_post_page_category_slider' ) ) :
- /**
- * This function to display featured posts/page/category slider
- *
- * @param $options: catch_fullscreen_theme_options from customizer
- *
- * @since Catch Fullscreen Pro 1.0
- */
- function catch_fullscreen_post_page_category_slider() {
- $quantity = get_theme_mod( 'catch_fullscreen_slider_number', 4 );
- $no_of_post = 0; // for number of posts
- $post_list = array();// list of valid post/page ids
- $type = get_theme_mod( 'catch_fullscreen_slider_type', 'category' );
- $show_content = get_theme_mod( 'catch_fullscreen_slider_content_show', 'hide-content' );
- $show_meta = get_theme_mod( 'catch_fullscreen_slider_meta_show', 'show-meta' );
- $output = '';
- $args = array(
- 'ignore_sticky_posts' => 1, // ignore sticky posts
- 'orderby' => 'rand',
- );
- //Get valid number of posts
- if ( 'post' === $type || 'page' === $type ) {
- for ( $i = 1; $i <= $quantity; $i++ ) {
- $post_id = '';
- if ( 'post' === $type ) {
- $post_id = get_theme_mod( 'catch_fullscreen_slider_post_' . $i );
- } elseif ( 'page' === $type ) {
- $post_id = get_theme_mod( 'catch_fullscreen_slider_page_' . $i );
- $args['post_type'] = 'page';
- }
- if ( $post_id && '' !== $post_id ) {
- $post_list = array_merge( $post_list, array( $post_id ) );
- $no_of_post++;
- }
- }
- $args['post__in'] = $post_list;
- $args['orderby'] = 'post__in';
- } elseif ( 'category' === $type ) {
- $no_of_post = $quantity;
- $args['category__in'] = get_theme_mod( 'catch_fullscreen_slider_select_category' );
- $args['post_type'] = 'post';
- }
- if ( ! $no_of_post ) {
- return;
- }
- $args['posts_per_page'] = $no_of_post;
- $loop = new WP_Query( $args );
- while ( $loop->have_posts() ) :
- $loop->the_post();
- $title_attribute = the_title_attribute( 'echo=0' );
- $content_alignment = get_theme_mod( 'catch_fullscreen_content_align_' . ( $loop->current_post + 1 ), 'content-align-center' );
- if ( 0 === $loop->current_post ) {
- $classes = 'post post-' . get_the_ID() . ' hentry slides displayblock ' . $content_alignment;
- } else {
- $classes = 'post post-' . get_the_ID() . ' hentry slides displaynone ' . $content_alignment;
- }
- // Default value if there is no featurd image or first image.
- $image_url = trailingslashit( esc_url ( get_template_directory_uri() ) ) . 'assets/images/no-thumb-1920x1080.jpg';
- if ( has_post_thumbnail() ) {
- $image_url = get_the_post_thumbnail_url( get_the_ID(), 'catch-fullscreen-slider' );
- } else {
- // Get the first image in page, returns false if there is no image.
- $first_image_url = catch_fullscreen_get_first_image( get_the_ID(), 'catch-fullscreen-slider', '', true );
- // Set value of image as first image if there is an image present in the page.
- if ( $first_image_url ) {
- $image_url = $first_image_url;
- }
- }
- $style ='';
- if ( $image_url ) {
- $style = ' style="background-image: url(' . esc_url( $image_url ) . ')"';
- }
- $output .= '
- <article class="content-background ' . esc_attr( $classes ) . '"' . $style . '><div class="post-wrapper">';
- $output .= '
- <div class="slider-image-wrapper">
- <a href="' . esc_url( get_permalink() ) . '" title="' . $title_attribute . '">
- <img src="' . esc_url( $image_url ) . '" class="wp-post-image" alt="' . $title_attribute . '">
- </a>
- </div><!-- .slider-image-wrapper -->
- <div class="slider-content-wrapper entry-content-wrapper">
- <div class="entry-container">
- <header class="entry-header">';
- $output .= '<h2 class="entry-title">
- <a title="' . $title_attribute . '" href="' . esc_url( get_permalink() ) . '">' . the_title( '<span>','</span>', false ) . '</a>
- </h2>';
- if ( 'show-meta' === $show_meta && ( 'post' === $type || 'category' === $type ) ) {
- $output .= catch_fullscreen_entry_category_date();
- }
- $output .= '
- </header>
- ';
- if ( 'excerpt' === $show_content ) {
- $excerpt = get_the_excerpt();
- $output .= '<div class="entry-summary"><p>' . $excerpt . '</p></div><!-- .entry-summary -->';
- } elseif ( 'full-content' === $show_content ) {
- $content = apply_filters( 'the_content', get_the_content() );
- $content = str_replace( ']]>', ']]>', $content );
- $output .= '<div class="entry-content">' . wp_kses_post( $content ) . '</div><!-- .entry-content -->';
- }
- $output .= '
- </div><!-- .entry-container -->
- </div><!-- .slider-content-wrapper -->
- </div></article><!-- .slides -->';
- endwhile;
- wp_reset_postdata();
- return $output;
- }
- endif; // catch_fullscreen_post_page_category_slider.
- if ( ! function_exists( 'catch_fullscreen_image_slider' ) ) :
- /**
- * This function to display featured posts slider
- *
- * @get the data value from theme options
- * @displays on the index
- *
- * @usage Featured Image, Title and Excerpt of Post
- *
- */
- function catch_fullscreen_image_slider() {
- $quantity = get_theme_mod( 'catch_fullscreen_slider_number', 4 );
- $output = '';
- for ( $i = 1; $i <= $quantity; $i++ ) {
- $image = get_theme_mod( 'catch_fullscreen_slider_image_' . $i );
- $content_alignment = get_theme_mod( 'catch_fullscreen_content_align_' . $i, 'content-align-center' );
- // Check Image Not Empty to add in the slides.
- if ( $image ) {
- $imagetitle = get_theme_mod( 'catch_fullscreen_featured_title_' . $i ) ? get_theme_mod( 'catch_fullscreen_featured_title_' . $i ) : 'Featured Image-' . $i;
- $title = '';
- $link = get_theme_mod( 'catch_fullscreen_featured_link_' . $i );
- $target = get_theme_mod( 'catch_fullscreen_featured_target_' . $i ) ? '_blank' : '_self';
- $title = '<header class="entry-header"><h2 class="entry-title"><span>' . esc_html( $imagetitle ) . '</span></h2></header>';
- if ( $link ) {
- $title = '<header class="entry-header"><h2 class="entry-title"><a title="' . esc_attr( $imagetitle ) . '" href="' . esc_url( $link ) . '" target="' . $target . '"><span>' . esc_html( $imagetitle ) . '</span></a></h2></header>';
- }
- $content = get_theme_mod( 'catch_fullscreen_featured_content_' . $i ) ? '<div class="entry-summary"><p>' . get_theme_mod( 'catch_fullscreen_featured_content_' . $i ) . '</p></div><!-- .entry-summary -->' : '';
- $contentopening = '';
- $contentclosing = '';
- // Content Opening and Closing.
- if ( ! empty( $title ) || ! empty( $content ) ) {
- $contentopening = '<div class="slider-content-wrapper"><div class="entry-container">';
- $contentclosing = '</div><!-- .entry-container --></div><!-- .slider-content-wrapper -->';
- }
- // Adding in Classes for Display block and none.
- if ( 1 === $i ) {
- $classes = 'displayblock';
- } else {
- $classes = 'displaynone';
- }
- $classes .= 'image-slides hentry slider-image images-' . $i . ' slides ' . $content_alignment;
- $output .= '
- <article class="' . esc_attr( $classes ) . '" style="background-image: url(' . esc_url( $image ) . ')">
- <div class="slider-image-wrapper">
- <a href="' . esc_url( $link ) . '" title="' . esc_attr( $imagetitle ) . '">
- <img src="' . esc_url( $image ) . '" class="wp-post-image" alt="' . esc_attr( $imagetitle ) . '">
- </a>
- </div>
- ' . $contentopening . $title . $content . $contentclosing . '
- </article><!-- .slides --> ';
- } // End if().
- } // End for().
- return $output;
- }
- endif; // catch_fullscreen_image_slider.
Add Comment
Please, Sign In to add comment