/** * This function to display featured page slider * * @param $options: catchresponsive_theme_options from customizer * * @since Catch Responsive 1.0 */ function catchresponsive_page_slider($options) { $quantity = $options['featured_slide_number']; $more_link_text = $options['excerpt_more_text']; global $post; $catchresponsive_page_slider = ''; $number_of_page = 0; // for number of pages $page_list = array(); // list of valid page ids //Get number of valid pages for ($i = 1; $i <= $quantity; $i++) { if (isset($options['featured_slider_page_' . $i]) && $options['featured_slider_page_' . $i] > 0) { $number_of_page++; $page_list = array_merge($page_list, array($options['featured_slider_page_' . $i])); } } if (!empty($page_list) && $number_of_page > 0) { $get_featured_posts = new WP_Query(array('posts_per_page' => $quantity, 'post_type' => 'page', 'post__in' => $page_list, 'orderby' => 'post__in')); $i = 0; while ($get_featured_posts->have_posts()) { $get_featured_posts->the_post(); $i++; $title_attribute = the_title_attribute(array('before' => __('Permalink to: ', 'catch-responsive'), 'echo' => false)); $excerpt = get_the_excerpt(); if ($i == 1) { $classes = 'page pageid-' . $post->ID . ' hentry slides displayblock'; } else { $classes = 'page pageid-' . $post->ID . ' hentry slides displaynone'; } $catchresponsive_page_slider .= ' <article class="' . $classes . '"> <figure class="slider-image">'; if (has_post_thumbnail()) { $catchresponsive_page_slider .= '<a title="Permalink to ' . the_title('', '', false) . '" href="' . get_permalink() . '"> ' . get_the_post_thumbnail($post->ID, 'catchresponsive-slider', array('title' => esc_attr($title_attribute), 'alt' => esc_attr($title_attribute), 'class' => 'attached-page-image')) . ' </a>'; } else { //Default value if there is no first image $catchresponsive_image = '<img class="pngfix wp-post-image" src="' . get_template_directory_uri() . '/images/gallery/no-featured-image-1200x514.jpg" >'; //Get the first image in page, returns false if there is no image $catchresponsive_first_image = catchresponsive_get_first_image($post->ID, 'catchresponsive-slider', array('title' => esc_attr($title_attribute), 'alt' => esc_attr($title_attribute), 'class' => 'attached-page-image')); //Set value of image as first image if there is an image present in the page if ('' != $catchresponsive_first_image) { $catchresponsive_image = $catchresponsive_first_image; } $catchresponsive_page_slider .= '<a title="Permalink to ' . the_title('', '', false) . '" href="' . get_permalink() . '"> ' . $catchresponsive_image . ' </a>'; } $catchresponsive_page_slider .= ' </figure><!-- .slider-image --> <div class="entry-container"> <header class="entry-header"> <h1 class="entry-title"> <a title="Permalink to ' . the_title('', '', false) . '" href="' . get_permalink() . '">' . the_title('<span>', '</span>', false) . '</a> </h1> <div class="assistive-text">' . catchresponsive_page_post_meta() . '</div> </header>'; if ($excerpt != '') { $catchresponsive_page_slider .= '<div class="entry-content"><p>' . $excerpt . '</p></div>'; } $catchresponsive_page_slider .= ' </div><!-- .entry-container --> </article><!-- .slides -->'; } wp_reset_query(); } return $catchresponsive_page_slider; }
/** * This function to display featured page content * * @param $options: catchresponsive_theme_options from customizer * * @since Catch Responsive 1.0 */ function catchresponsive_page_content($options) { global $post; $quantity = $options['featured_content_number']; $more_link_text = $options['excerpt_more_text']; $show_content = isset($options['featured_content_show']) ? $options['featured_content_show'] : 'excerpt'; $catchresponsive_page_content = ''; $number_of_page = 0; // for number of pages $page_list = array(); // list of valid pages ids //Get valid pages for ($i = 1; $i <= $quantity; $i++) { if (isset($options['featured_content_page_' . $i]) && $options['featured_content_page_' . $i] > 0) { $number_of_page++; $page_list = array_merge($page_list, array($options['featured_content_page_' . $i])); } } if (!empty($page_list) && $number_of_page > 0) { $get_featured_posts = new WP_Query(array('posts_per_page' => $number_of_page, 'post__in' => $page_list, 'orderby' => 'post__in', 'post_type' => 'page')); $i = 0; while ($get_featured_posts->have_posts()) { $get_featured_posts->the_post(); $i++; $title_attribute = the_title_attribute(array('before' => __('Permalink to: ', 'catch-responsive'), 'echo' => false)); $excerpt = get_the_excerpt(); $catchresponsive_page_content .= ' <article id="featured-post-' . $i . '" class="post hentry featured-page-content">'; if (has_post_thumbnail()) { $catchresponsive_page_content .= ' <figure class="featured-homepage-image"> <a href="' . get_permalink() . '" title="' . the_title('', '', false) . '"> ' . get_the_post_thumbnail($post->ID, 'catchresponsive-featured-content', array('title' => esc_attr($title_attribute), 'alt' => esc_attr($title_attribute), 'class' => 'pngfix')) . ' </a> </figure>'; } else { $catchresponsive_first_image = catchresponsive_get_first_image($post->ID, 'catchresponsive-featured-content', array('title' => esc_attr($title_attribute), 'alt' => esc_attr($title_attribute), 'class' => 'pngfix')); if ('' != $catchresponsive_first_image) { $catchresponsive_page_content .= ' <figure class="featured-homepage-image"> <a href="' . get_permalink() . '" title="' . the_title('', '', false) . '"> ' . $catchresponsive_first_image . ' </a> </figure>'; } } $catchresponsive_page_content .= ' <div class="entry-container"> <header class="entry-header"> <h1 class="entry-title"> <a href="' . get_permalink() . '" rel="bookmark">' . the_title('', '', false) . '</a> </h1> </header>'; if ('excerpt' == $show_content) { $catchresponsive_page_content .= '<div class="entry-excerpt"><p>' . $excerpt . '</p></div><!-- .entry-excerpt -->'; } elseif ('full-content' == $show_content) { $content = apply_filters('the_content', get_the_content()); $content = str_replace(']]>', ']]>', $content); $catchresponsive_page_content .= '<div class="entry-content">' . $content . '</div><!-- .entry-content -->'; } $catchresponsive_page_content .= ' </div><!-- .entry-container --> </article><!-- .featured-post-' . $i . ' -->'; } wp_reset_query(); } return $catchresponsive_page_content; }