function hoot_page_header_attop() { $full = array_map('trim', explode(',', hoot_get_mod('page_header_full'))); /* Override For Full Width Pages (including 404 page) */ if (in_array('no-sidebar', $full)) { $sidebar_size = hoot_main_layout('primary-sidebar'); if (empty($sidebar_size) || hoot_is_404()) { return apply_filters('hoot_page_header_attop', true, 'no-sidebar'); } } /* For Posts */ if (is_singular('post')) { if (in_array('posts', $full)) { return apply_filters('hoot_page_header_attop', true, 'posts'); } else { return apply_filters('hoot_page_header_attop', false, 'posts'); } } /* For Pages */ if (is_page()) { if (in_array('pages', $full)) { return apply_filters('hoot_page_header_attop', true, 'pages'); } else { return apply_filters('hoot_page_header_attop', false, 'pages'); } } /* Default */ if (in_array('default', $full)) { return apply_filters('hoot_page_header_attop', true, 'default'); } else { return apply_filters('hoot_page_header_attop', false, 'default'); } }
/** * Filters the `wp_title` output early. * * @since 1.0.0 * @access public * @param string $title * @param string $separator * @param string $seplocation * @return string */ function hoot_wp_title($doctitle, $separator, $seplocation) { if (is_front_page()) { $doctitle = get_bloginfo('name') . $separator . ' ' . get_bloginfo('description'); } elseif (is_home() || is_singular()) { $doctitle = single_post_title('', false); } elseif (is_category()) { $doctitle = single_cat_title('', false); } elseif (is_tag()) { $doctitle = single_tag_title('', false); } elseif (is_tax()) { $doctitle = single_term_title('', false); } elseif (is_post_type_archive()) { $doctitle = post_type_archive_title('', false); } elseif (is_author()) { $doctitle = hoot_single_author_title('', false); } elseif (get_query_var('minute') && get_query_var('hour')) { $doctitle = hoot_single_minute_hour_title('', false); } elseif (get_query_var('minute')) { $doctitle = hoot_single_minute_title('', false); } elseif (get_query_var('hour')) { $doctitle = hoot_single_hour_title('', false); } elseif (is_day()) { $doctitle = hoot_single_day_title('', false); } elseif (get_query_var('w')) { $doctitle = hoot_single_week_title('', false); } elseif (is_month()) { $doctitle = single_month_title(' ', false); } elseif (is_year()) { $doctitle = hoot_single_year_title('', false); } elseif (is_archive()) { $doctitle = hoot_single_archive_title('', false); } elseif (is_search()) { $doctitle = hoot_search_title('', false); } elseif (hoot_is_404()) { $doctitle = hoot_404_title('', false); } /* If the current page is a paged page. */ if ((($page = get_query_var('paged')) || ($page = get_query_var('page'))) && $page > 1) { /* Translators: 1 is the page title. 2 is the page number. */ $doctitle = sprintf(__('%1$s Page %2$s', 'dispatch'), $doctitle . $separator, number_format_i18n(absint($page))); } /* Trim separator + space from beginning and end. */ $doctitle = trim(strip_tags($doctitle), "{$separator} "); return $doctitle; }
// End paged check. ?> </div><!-- .loop-meta --> </div> </div> </div> <?php // Let child themes add content if they want to hoot_display_loop_title_content('post'); /** * If viewing a single post/page, and the page is not set as frontpage */ } elseif (!is_front_page() && is_singular() && !hoot_is_404()) { if (have_posts()) { // Begins the loop through found posts, and load the post data. while (have_posts()) { the_post(); $display_title = ''; $display_title = apply_filters('display_loop_meta', $display_title); $pre_title_content = ''; $pre_title_content_stretch = ''; $pre_title_content_post = ''; hoot_display_loop_title_content('pre', array($pre_title_content, $pre_title_content_stretch, $pre_title_content_post)); if ($display_title !== 'hide') { ?> <div id="loop-meta"> <div class="grid">
?> ><?php single_post_title(); ?> </h1> </header><!-- .entry-header --> <?php if (hoot_get_mod('post_featured_image') && !hoot_is_404()) { $img_size = apply_filters('hoot_post_image_page', ''); hoot_post_thumbnail('entry-content-featured-img', $img_size); } ?> <?php $entry_content_class = hoot_is_404() ? 'no-shadow' : ''; ?> <div <?php hoot_attr('entry-content', '', $entry_content_class); ?> > <div class="entry-the-content"> <?php the_content(); ?> </div> <?php wp_link_pages(); ?>
<h1 <?php hoot_attr('entry-title'); ?> ><?php single_post_title(); ?> </h1> </header><!-- .entry-header --> <div <?php hoot_attr('entry-content'); ?> > <?php if (hoot_get_mod('post_featured_image') && !hoot_is_404()) { $img_size = apply_filters('hoot_post_image_page', ''); hoot_post_thumbnail('entry-content-featured-img', $img_size); } ?> <div class="entry-the-content"> <?php the_content(); ?> </div> <?php wp_link_pages(); ?> </div><!-- .entry-content -->
/** * Main content container of the page attributes. * * @since 1.0.0 * @access public * @param array $attr * @return array */ function hoot_attr_content($attr) { $attr['id'] = 'content'; $attr['class'] = 'content'; $attr['role'] = 'main'; if (is_page_template()) { $template_slug = basename(get_page_template(), '.php'); $attr['class'] .= ' ' . sanitize_html_class('content-' . $template_slug); } if (hoot_is_404()) { $attr['class'] .= ' custom-404-content'; } return $attr; }
/** * Framework's main contextual function. This allows code to be used more than once without running * hundreds of conditional checks within the theme. It returns an array of contexts based on what * page a visitor is currently viewing on the site. This function is useful for making dynamic/contextual * classes, action and filter hooks, and handling the templating system. * * Note that time and date can be tricky because any of the conditionals may be true on time-/date- * based archives depending on several factors. For example, one could load an archive for a specific * second during a specific minute within a specific hour on a specific day and so on. * * @since 1.0.0 * @access public * @global object $hoot * @return array */ function hoot_get_context() { global $hoot; /* If $hoot->context has been set, don't run through the conditionals again. Just return the variable. */ if (isset($hoot->context)) { return apply_filters('hoot_context', $hoot->context); } /* Set some variables for use within the function. */ $hoot->context = array(); $object = get_queried_object(); $object_id = get_queried_object_id(); /* Front page of the site. */ if (is_front_page()) { $hoot->context[] = 'home'; } /* Blog page. */ if (is_home()) { $hoot->context[] = 'blog'; } elseif (is_singular()) { $hoot->context[] = 'singular'; $hoot->context[] = "singular-{$object->post_type}"; $hoot->context[] = "singular-{$object->post_type}-{$object_id}"; } elseif (is_archive()) { $hoot->context[] = 'archive'; /* Post type archives. */ if (is_post_type_archive()) { $post_type = get_post_type_object(get_query_var('post_type')); $hoot->context[] = "archive-{$post_type->name}"; } /* Taxonomy archives. */ if (is_tax() || is_category() || is_tag()) { $hoot->context[] = 'taxonomy'; $hoot->context[] = "taxonomy-{$object->taxonomy}"; $slug = 'post_format' == $object->taxonomy ? str_replace('post-format-', '', $object->slug) : $object->slug; $hoot->context[] = "taxonomy-{$object->taxonomy}-" . sanitize_html_class($slug, $object->term_id); } /* User/author archives. */ if (is_author()) { $user_id = get_query_var('author'); $hoot->context[] = 'user'; $hoot->context[] = 'user-' . sanitize_html_class(get_the_author_meta('user_nicename', $user_id), $user_id); } /* Date archives. */ if (is_date()) { $hoot->context[] = 'date'; if (is_year()) { $hoot->context[] = 'year'; } if (is_month()) { $hoot->context[] = 'month'; } if (get_query_var('w')) { $hoot->context[] = 'week'; } if (is_day()) { $hoot->context[] = 'day'; } } /* Time archives. */ if (is_time()) { $hoot->context[] = 'time'; if (get_query_var('hour')) { $hoot->context[] = 'hour'; } if (get_query_var('minute')) { $hoot->context[] = 'minute'; } } } elseif (is_search()) { $hoot->context[] = 'search'; } elseif (hoot_is_404()) { $hoot->context[] = 'error-404'; } return array_map('esc_attr', apply_filters('hoot_context', array_unique($hoot->context))); }
// Loads the template-parts/loop-meta.php template to display Title Area with Meta Info (of the loop) } // Begins the loop through found posts, and load the post data. while (have_posts()) { the_post(); // Loads the template-parts/content-{$post_type}.php template. hoot_get_content_template(); // End found posts loop. } ?> </div><!-- #content-wrap --> <?php // Loads the comments.php template if this page is not being displayed as frontpage or a custom 404 page or if this is attachment page of media attached (uploaded) to a page. if (!is_front_page() && !hoot_is_404() && !is_attachment()) { comments_template('', true); } // If no posts were found. } else { // Loads the template-parts/error.php template. get_template_part('template-parts/error'); // End check for posts. } ?> </main><!-- #content --> <?php hoot_get_sidebar('primary'); // Loads the template-parts/sidebar-primary.php template.
><?php single_post_title(); ?> </h1> </header><!-- .entry-header --> <?php $entry_content_class = hoot_is_404() ? 'no-shadow' : ''; ?> <div <?php hoot_attr('entry-content', '', $entry_content_class); ?> > <?php if (hoot_get_option('post_featured_image') && !hoot_is_404()) { hoot_post_thumbnail('entry-content-featured-img'); } ?> <div class="entry-the-content"> <?php the_content(); ?> </div> <?php wp_link_pages(); ?> </div><!-- .entry-content --> <?php
/** * Utility function to determine the location of page header * * @since 1.0 * @access public */ function hoot_page_header_attop() { $full = wp_parse_args(hoot_get_option('page_header_full'), array('default' => '1', 'posts' => 0, 'pages' => '1', 'no-sidebar' => '1')); /* Override For Full Width Pages (including 404 page) */ if ($full['no-sidebar']) { $sidebar_size = hoot_main_layout('primary-sidebar'); if (empty($sidebar_size) || hoot_is_404()) { return apply_filters('hoot_page_header_attop', true); } } /* For Posts */ if (is_singular('post')) { if ($full['posts']) { return apply_filters('hoot_page_header_attop', true); } else { return apply_filters('hoot_page_header_attop', false); } } /* For Pages */ if (is_page()) { if ($full['pages']) { return apply_filters('hoot_page_header_attop', true); } else { return apply_filters('hoot_page_header_attop', false); } } /* Default */ if ($full['default']) { return apply_filters('hoot_page_header_attop', true); } else { return apply_filters('hoot_page_header_attop', false); } }
/** * Main content container of the page attributes. * * @since 1.0.0 * @access public * @param array $attr * @return array */ function hoot_attr_content($attr) { $attr['id'] = 'content'; $attr['class'] = 'content'; $attr['role'] = 'main'; $attr['itemprop'] = 'mainContentOfPage'; if (is_page_template()) { $template_slug = basename(get_page_template(), '.php'); $attr['class'] .= ' ' . sanitize_html_class('content-' . $template_slug); } if (hoot_is_404()) { $attr['class'] .= ' custom-404-content'; } elseif (is_singular('post') || is_home() || is_archive()) { $attr['itemscope'] = ''; $attr['itemtype'] = 'http://schema.org/Blog'; } elseif (is_search()) { $attr['itemscope'] = 'itemscope'; $attr['itemtype'] = 'http://schema.org/SearchResultsPage'; } return $attr; }
/** * Utility function to calculate and set main (content+aside) layout according to the sidebar layout * set by user for the current view. * Can only be used after 'posts_selection' action hook i.e. in 'wp' hook or later. * * @since 1.0 * @access public */ function hoot_set_main_layout() { // Apply Sidebar Layout for Posts if (is_singular('post')) { $sidebar = hoot_get_option('sidebar_posts'); } elseif (is_attachment()) { $sidebar = 'none'; } elseif (is_page()) { if (hoot_is_404()) { // Apply 'Full Width' if this page is being displayed as a custom 404 page $sidebar = 'none'; } else { // Apply Sidebar Layout for Pages $sidebar = hoot_get_option('sidebar_pages'); } } else { $sidebar = hoot_get_option('sidebar'); } /* Allow for custom manipulation of the layout by child themes */ $sidebar = apply_filters('hoot_main_layout', $sidebar); $spans = apply_filters('hoot_main_layout_spans', array('none' => array('content' => 9, 'sidebar' => 0), 'narrow-right' => array('content' => 9, 'sidebar' => 3), 'wide-right' => array('content' => 8, 'sidebar' => 4), 'default' => array('content' => 8, 'sidebar' => 4))); /* Finally, set the layout for current view */ global $hoot_theme; if (isset($spans[$sidebar])) { $hoot_theme->currentlayout['content'] = $spans[$sidebar]['content']; $hoot_theme->currentlayout['sidebar'] = $spans[$sidebar]['sidebar']; } else { $hoot_theme->currentlayout['content'] = $spans['default']['content']; $hoot_theme->currentlayout['sidebar'] = $spans['default']['sidebar']; } }
function hoot_set_main_layout() { // Apply Sidebar Layout for Posts if (is_singular('post')) { $sidebar = hoot_get_mod('sidebar_posts'); } elseif (is_attachment()) { $sidebar = 'none'; } elseif (is_page()) { if (hoot_is_404()) { // Apply 'Full Width' if this page is being displayed as a custom 404 page $sidebar = 'none'; } else { // Apply Sidebar Layout for Pages $sidebar = hoot_get_mod('sidebar_pages'); } } else { $sidebar = hoot_get_mod('sidebar'); } // Allow for custom manipulation of the layout by child themes $sidebar = apply_filters('hoot_main_layout', $sidebar); // Save the layout for current view hoot_set_current_layout($sidebar); }