/** * Determines if the slider should be shown on the current page. Returns true if the slider should be displayed. * @return bool true if the sider is displayed */ function scoutwp_display_slider() { if (2 == get_theme_mod('slider_all_pages', 1)) { return true; } elseif (1 == get_theme_mod('slider_all_pages', 1) && scoutwp_is_site_index()) { return true; } else { return false; } }
/** * Displays a links bar with sections determined from the Customizer * @return string HTML code for the link bar. */ function scoutwp_section_bar() { if (get_theme_mod('section_bar_pages') == 0 || get_theme_mod('section_bar_pages') == 1 && !scoutwp_is_site_index()) { return; } $sections = array('beavers' => '6 - 8', 'cubs' => '8 - 10½', 'scouts' => '10½ - 14', 'explorers' => '14 - 18', 'network' => '18 - 25', 'sasu' => '18+'); $return = '<ul class="list-sections-container">'; foreach ($sections as $section => $ages) { if (get_theme_mod("section_bar_{$section}", 1)) { $return .= '<li><a href="' . esc_url(home_url($section)) . '">'; $return .= apply_filters('scoutwp_section_logo', $section, 'medium'); if (get_theme_mod('section_bar_age', 1)) { $return .= "<span>{$ages} years</span>"; } $return .= '</a></li>'; } } $return .= '</ul>'; return $return; }
add_filter('scoutwp_image_sizes', 'scoutwp_social_media_sidebar_image_sizes', -1); add_filter('wp_get_attachment_image_attributes', 'scoutwp_wp_media_sidebar_image_sizes', -1, 3); // include the sidebar dynamic_sidebar('main-sidebar'); // remove filters remove_filter('scoutwp_image_sizes', 'scoutwp_social_media_sidebar_image_sizes', -1); remove_filter('wp_get_attachment_image_attributes', 'scoutwp_wp_media_sidebar_image_sizes', -1); ?> </aside> <?php } ?> </div> <?php // display widgets if (get_theme_mod('sm_widgets_all_pages', 0) || scoutwp_is_site_index()) { ?> <?php if (is_active_sidebar('social-media-widgets')) { ?> <aside id="social-media-widgets" class="widget-area after-main"> <?php // add filters for image sizes add_filter('scoutwp_image_sizes', 'scoutwp_filter_social_media_bottom_widget_image_sizes', -1); add_filter('wp_get_attachment_image_attributes', 'scoutwp_filter_wp_media_bottom_widget_image_sizes', -1, 3); // include the sidebar dynamic_sidebar('social-media-widgets'); // remove filters remove_filter('scoutwp_image_sizes', 'scoutwp_filter_social_media_bottom_widget_image_sizes', -1); remove_filter('wp_get_attachment_image_attributes', 'scoutwp_filter_wp_media_bottom_widget_image_sizes', -1); ?>
/** * Displays a page on the site's index page if selected in the Customizer * @return null */ public function front_page_page() { if (scoutwp_is_site_index() && ($welcome_id = get_theme_mod('fp_welcome_page', 0))) { global $wp_query; query_posts(array('post_type' => 'page', 'page_id' => $welcome_id, 'posts_per_page' => 1)); if (have_posts()) { // tells the title function to use a H2 tag global $welcome_section; $welcome_section = true; while (have_posts()) { the_post(); get_template_part('content', 'page'); } // reset $welcome_section = false; } wp_reset_query(); } }
?> <?php } if (is_home() && !is_page()) { ?> <h1 class="blog-title"><?php echo get_theme_mod('fp_title', sprintf(__('%s Blog', 'scoutwp-theme'), get_bloginfo())); ?> </h1><?php } // the loop if (have_posts()) { while (have_posts()) { the_post(); /* start front page hidden box code */ if (scoutwp_is_site_index() && !is_page()) { $i = !isset($i) ? 1 : $i + 1; // theme uses ?blog=1 for non JS users to view all blog posts if (get_theme_mod('fp_posts') + 1 == $i) { ?> <a href="?blog=1" class="icon-angle-circled-down reveal-more"><?php _e('Show more blog posts', 'scoutwp-theme'); ?> </a> <div id="front-page-hidden-blog-posts"> <?php } } /* end front page hidden box code */ // if we have a post, use the post format if (is_page()) {
/** * Pre query modifications * Alters posts_per_page for media archives * Sets single category for home page if option set in Customizer * @param object $query Current query object * @return null */ function scoutwp_pre_get_posts($query) { // if its a post format and a media type if (is_media_post_format_archive($query)) { $query->set('posts_per_page', get_theme_mod('media_per_archive', 15)); } if (scoutwp_is_site_index()) { if ($query->is_main_query() && get_theme_mod('fp_category', 0) != 0) { $query->set('cat', get_theme_mod('fp_category', 0)); } // modify query for single category } }