/** * Displays the slider and enqueues footer script for animation * The HTML code used here should mirror that in single-slider.php * @return null */ public function html() { if (!scoutwp_display_slider()) { return; } // enqueue scripts wp_enqueue_script('unslider'); query_posts(array('post_type' => 'slider', 'posts_per_page' => -1, 'orderby' => 'menu_order', 'order' => 'ASC')); // add filter to ensure images are correct size if ('full-width' == get_theme_mod('page_width', '')) { add_filter('wp_get_attachment_image_attributes', 'scoutwp_full_width_slider', -1, 3); } // open the containers ?> <div class="sp-slider-container <?php echo get_theme_mod('slider_height', 'medium'); ?> <?php echo get_theme_mod('slider_margin', 'bottom'); ?> "> <ul> <?php if (have_posts()) { while (have_posts()) { the_post(); ?> <li><?php get_template_part('content', 'slider'); ?> </li> <?php } } else { // display a default slide $sizes = 'full-width' == get_theme_mod('page_width', '') ? '100vw' : '(max-width: ' . content_width('no-padding', 'no_sidebar') . 'px) 100vw, ' . content_width('no-padding', 'no_sidebar') . 'px'; ?> <li> <img width="1080" height="720" src="<?php echo get_template_directory_uri(); ?> /images/slider/default-1080x720.jpg" class="attachment-slider_image wp-post-image" srcset="<?php echo get_template_directory_uri(); ?> /images/slider/default-400x267.jpg 400w, <?php echo get_template_directory_uri(); ?> /images/slider/default-1032x688.jpg 1032w, <?php echo get_template_directory_uri(); ?> /images/slider/default-640x427.jpg 640w, <?php echo get_template_directory_uri(); ?> /images/slider/default-1080x720.jpg 1080w, <?php echo get_template_directory_uri(); ?> /images/slider/default-2160x1440.jpg 2160w, <?php echo get_template_directory_uri(); ?> /images/slider/default.jpg 3000w" sizes="<?php echo $sizes; ?> "> <article class="slider icon-fleur-de-lis"> <div> <h1><?php _e('Showcase your Scouting', 'scoutwp-theme'); ?> </h1> <p><?php _e('Use these sliders to really make your Scouting stand out', 'scoutwp-theme'); ?> </p> </div> </article> </li> <?php } // close the containers // ?> </ul> </div> <?php // reset filters and query if ('full-width' == get_theme_mod('page_width', '')) { remove_filter('wp_get_attachment_image_attributes', 'scoutwp_full_width_slider', -1); } wp_reset_query(); }
/** * After theme setup hook * Loads the language Domain * Updates all image sizes to match the current layout * Registers the navigation menu, top bar menu and footer menu * @return null */ function scoutwp_setup() { // load languages load_theme_textdomain('scoutwp-theme', get_template_directory() . '/languages'); if (400 != get_option('medium_size_w', 0)) { update_option('medium_size_w', 400); } if (400 != get_option('medium_size_h', 0)) { update_option('medium_size_h', 400); } if (content_width() != get_option('large_size_w', 0)) { update_option('large_size_w', content_width()); } if (content_width() != get_option('large_size_h', 0)) { update_option('large_size_h', content_width()); } add_image_size('large-medium', 640, 640, false); // add image size between medium and large - needed for sliders and IE set_post_thumbnail_size(180, 180, true); add_image_size('thumb-medium', 360, 360, true); add_image_size('thumb-large', 540, 540, true); // add image size for the slider add_image_size('slider_image', content_width('no_padding', 'no_sidebar'), content_width('no_padding', 'no_sidebar'), false); add_image_size('slider_image_retina', content_width('no_padding', 'no_sidebar') * 2, content_width('no_padding', 'no_sidebar') * 2, false); // and set the content width to match global $content_width; if (!isset($content_width)) { $content_width = content_width('padding'); } // register the main navigation menu register_nav_menus(array('main-menu' => __('Main Menu', 'scoutwp-theme'), 'top-bar' => __('Top Bar', 'scoutwp-theme'), 'footer' => __('Footer Links', 'scoutwp-theme'))); }