/** * Get footer column option. * * @since 1.0.0 * @access public * @return void */ function hoot_get_option_footer() { $footers = hoot_get_option('footer'); $columns = $footers ? intval(substr($footers, 0, 1)) : false; $columns = is_numeric($columns) && 0 < $columns ? $columns : false; return $columns; }
/** * Page wrapper attributes. * * @since 1.0 * @access public * @param array $attr * @return array */ function hoot_theme_attr_page_wrapper($attr) { $site_layout = hoot_get_option('site_layout'); $attr['class'] = $site_layout == 'boxed' ? 'grid site-boxed' : 'site-stretch'; $attr['class'] .= ' page-wrapper'; return $attr; }
/** * Custom CSS built from user theme options * For proper sanitization, always use functions from hoot/functions/css-styles.php * * @since 1.0 * @access public */ function hoot_custom_css() { $css = ''; $accent_color = hoot_get_option('accent_color'); $accent_color_dark = hoot_color_decrease($accent_color, 20, 20); $accent_font = hoot_get_option('accent_font'); $cssrules = array(); // Hoot Grid $cssrules['.grid'] = hoot_css_grid_width(); // Base Typography and HTML $cssrules['a'] = hoot_css_rule('color', $accent_color); // Overridden by hoot_premium_custom_cssrules() $cssrules['.invert-typo'] = array(hoot_css_rule('background', $accent_color), hoot_css_rule('color', $accent_font)); $cssrules['.invert-typo a, .invert-typo a:hover, .invert-typo h1, .invert-typo h2, .invert-typo h3, .invert-typo h4, .invert-typo h5, .invert-typo h6, .invert-typo .title'] = hoot_css_rule('color', $accent_font); $cssrules['input[type="submit"], #submit, .button'] = array(hoot_css_rule('background', $accent_color), hoot_css_rule('color', $accent_font)); $cssrules['input[type="submit"]:hover, #submit:hover, .button:hover'] = array(hoot_css_rule('background', $accent_color_dark), hoot_css_rule('color', $accent_font)); // Layout $content_bg = hoot_get_option('background'); $cssrules['body'][] = hoot_css_background($content_bg); if (hoot_get_option('site_layout') == 'boxed') { $content_bg = hoot_get_option('box_background'); $cssrules['#page-wrapper'][] = hoot_css_background($content_bg); } $cssrules['#page-wrapper'][] = hoot_css_rule('border-color', $accent_color); // Header $cssrules['#topbar-right-inner' . ', ' . '#topbar-right-inner input'] = hoot_css_rule('background', $content_bg['color']); // Shortcodes $cssrules['#page-wrapper ul.shortcode-tabset-nav li.current'] = hoot_css_rule('border-bottom-color', $content_bg['color']); // Light Slider $cssrules['.lSSlideOuter .lSPager.lSpg > li:hover a, .lSSlideOuter .lSPager.lSpg > li.active a'] = hoot_css_rule('background-color', $accent_color); // Allow CSS to be modified $cssrules = apply_filters('hoot_dynamic_cssrules', $cssrules); /** Print CSS Rules **/ foreach ($cssrules as $selector => $rules) { if (!empty($selector)) { $css .= $selector . ' {'; if (is_array($rules)) { foreach ($rules as $rule) { $css .= $rule . ' '; } } else { $css .= $rules; } $css .= ' }' . "\n"; } } // @todo add media queries to preceding code // Allow CSS to be modified $cssrules = apply_filters('hoot_dynamic_css', $css); // Print CSS if (!empty($css)) { wp_add_inline_style('style', $css); } }
// 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 template-parts/loop-nav.php template. if (hoot_get_option('post_prev_next_links')) { get_template_part('template-parts/loop-nav'); } // Loads the comments.php template if (!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 -->
/** * Modify the exceprt length. * * @since 1.0 * @access public * @return void */ function custom_excerpt_length($length) { $excerpt_length = intval(hoot_get_option('excerpt_length')); if (!empty($excerpt_length)) { return $excerpt_length; } return 105; }
?> <div class="entry-sticky-tag contrast-typo"><?php _e('Sticky', 'responsive-brix'); ?> </div> <?php } ?> <?php hoot_meta_info_blocks(hoot_get_option('archive_post_meta')); ?> <div <?php hoot_attr('entry-summary'); ?> > <?php if ('full-content' == hoot_get_option('archive_post_content')) { the_content(); } else { the_excerpt(); } ?> </div><!-- .entry-summary --> </div><!-- .entry-grid-content --> </div><!-- .entry-grid --> </article><!-- .entry -->
/** * Custom CSS built from user theme options * For proper sanitization, always use functions from hoot/functions/css-styles.php * * @since 1.0 * @access public */ function hoot_custom_css() { $css = ''; $vars = array(); $accent_color = hoot_get_option('accent_color'); $accent_color_dark = hoot_color_increase($accent_color, 10, 10); $accent_font = hoot_get_option('accent_font'); $cssrules = array(); // Hoot Grid $cssrules['.grid'] = hoot_css_grid_width(); // Base Typography and HTML $cssrules['a'] = hoot_css_rule('color', $accent_color); // Overridden by hoot_premium_custom_cssrules() $cssrules['.invert-typo'] = array(hoot_css_rule('background', $accent_color), hoot_css_rule('color', $accent_font)); $cssrules['.invert-typo a, .invert-typo a:hover, .invert-typo h1, .invert-typo h2, .invert-typo h3, .invert-typo h4, .invert-typo h5, .invert-typo h6, .invert-typo .title'] = hoot_css_rule('color', $accent_font); $cssrules['input[type="submit"], #submit, .button'] = array(hoot_css_rule('background', $accent_color), hoot_css_rule('color', $accent_font)); $cssrules['input[type="submit"]:hover, #submit:hover, .button:hover'] = array(hoot_css_rule('background', $accent_color_dark), hoot_css_rule('color', $accent_font)); // Override @headingsFontFamily if selected in options if ('cursive' != hoot_get_option('headings_fontface')) { $cssrules['h1, h2, h3, h4, h5, h6, .title, .titlefont'] = array(hoot_css_rule('font-family', '"Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif'), hoot_css_rule('font-weight', '300'), hoot_css_rule('color', '#000000')); } // Layout $content_bg = hoot_get_option('background'); $cssrules['body'][] = hoot_css_background($content_bg); if (hoot_get_option('site_layout') == 'boxed') { $content_bg = array('color' => hoot_get_option('box_background_color')); $cssrules['#page-wrapper'][] = hoot_css_background($content_bg); } $vars['content_bg'] = $content_bg; // Header (Topbar, Header, Main Nav Menu) // Topbar $cssrules['.topbar-right-inner input'] = hoot_css_rule('background', $content_bg['color']); // Header Layout if (hoot_get_option('logo_background_type') == 'accent') { $cssrules['#header:before'] = hoot_css_rule('background', $accent_color); } else { $cssrules['#header:before, #site-logo'] = hoot_css_rule('background', 'transparent'); $cssrules['#header, #branding, #header-aside'] = hoot_css_rule('background', 'none'); $cssrules['#site-logo #site-title, #site-logo #site-description'] = hoot_css_rule('color', $accent_color); } // Logo (with icon) $title_icon_size = hoot_get_option('site_title_icon_size', NULL); if (intval($title_icon_size)) { $cssrules['.site-logo-with-icon #site-title i'] = hoot_css_rule('font-size', $title_icon_size); } $title_icon = hoot_get_option('site_title_icon', NULL); if ($title_icon && intval($title_icon_size)) { $cssrules['.site-logo-with-icon #site-title'] = hoot_css_rule('padding-left', $title_icon_size); } // Mixed Logo (with image) $logo_image_width = hoot_get_option('logo_image_width', NULL); $logo_image_width = intval($logo_image_width) ? intval($logo_image_width) : 120; $cssrules['.site-logo-with-image .site-logo-mixed-image, .site-logo-with-image .site-logo-mixed-image img'] = hoot_css_rule('width', intval($logo_image_width) . 'px'); // Important to have logo img width as img does not follow max-width inside non-fixed tables in Firefox // Custom Logo $hoot_logo = hoot_get_option('logo'); if ('custom' == $hoot_logo || 'mixedcustom' == $hoot_logo) { $title_custom = apply_filters('hoot_logo_custom_text', hoot_get_option('logo_custom')); if (is_array($title_custom) && !empty($title_custom)) { $lcount = 1; foreach ($title_custom as $title_line) { if (!empty($title_line['size'])) { $cssrules['#site-logo-custom .site-title-line' . $lcount . ',#site-logo-mixedcustom .site-title-line' . $lcount] = hoot_css_rule('font-size', $title_line['size']); } $lcount++; } } } // Light Slider $cssrules['.lSSlideOuter .lSPager.lSpg > li:hover a, .lSSlideOuter .lSPager.lSpg > li.active a'] = hoot_css_rule('background-color', $accent_color); // Allow CSS to be modified $cssrules = apply_filters('hoot_dynamic_cssrules', $cssrules, $vars); /** Print CSS Rules **/ foreach ($cssrules as $selector => $rules) { if (!empty($selector)) { $css .= $selector . ' {'; if (is_array($rules)) { foreach ($rules as $rule) { $css .= $rule . ' '; } } else { $css .= $rules; } $css .= ' }' . "\n"; } } // @todo add media queries to preceding code // Allow CSS to be modified $cssrules = apply_filters('hoot_dynamic_css', $css, $vars); // Print CSS if (!empty($css)) { wp_add_inline_style('style', $css); } }
</div> <?php wp_link_pages(); ?> </div><!-- .entry-content --> <div class="screen-reader-text" itemprop="datePublished" itemtype="https://schema.org/Date"><?php echo get_the_date('Y-m-d'); ?> </div> <?php $show_entry_footer = apply_filters('hoot_show_entry_footer', true); ?> <?php if ($show_entry_footer && 'bottom' != hoot_get_option('post_meta_location') && !is_attachment()) { ?> <footer class="entry-footer"> <?php hoot_meta_info_blocks(array('author' => false, 'date' => false, 'cats' => true, 'tags' => true, 'comments' => true)); ?> </footer><!-- .entry-footer --> <?php } ?> </article><!-- .entry --> <?php /** * If not viewing a single post i.e. viewing the post in a list index (archive etc.)
// Display HTML Slider $slider_width = hoot_get_option('wt_html_slider_width'); $slider_grid = 'stretch' == $slider_width ? 'grid-stretch' : 'grid'; ?> <div id="widgetized-template-html-slider" class="widgetized-template-area "> <div class="widgetized-template-slider"> <div class="grid-row"> <div class="grid-span-12"> <?php global $hoot_theme; /* Reset any previous slider */ $hoot_theme->slider = array(); $hoot_theme->sliderSettings = array('class' => 'wt-slider', 'min_height' => hoot_get_option('wt_html_slider_min_height')); /* Create slider object */ $slides = hoot_get_option('wt_html_slider'); foreach ($slides as $slide) { if (!empty($slide['image']) || !empty($slide['content']) || !empty($slide['url'])) { $hoot_theme->slider[] = $slide; } } /* Display Slider Template */ get_template_part('template-parts/slider-html'); ?> </div> </div> </div> </div> <?php } ?>
/** * Callback function for Custom Background * * @since 1.1.72 * @access public * @return string */ function hoot_custom_background_cb() { // $background is the saved custom image, or the default image. $background = set_url_scheme(get_background_image()); // $color is the saved custom color. // A default has to be specified in style.css. It will not be printed here. $color = get_background_color(); if ($color === get_theme_support('custom-background', 'default-color')) { $color = false; } if (!$background && !$color) { return; } $style = $color ? "background-color: #{$color};" : ''; $hoot_bg = hoot_get_option('background'); if ($background && isset($hoot_bg['type']) && $hoot_bg['type'] == 'custom') { $image = " background-image: url('{$background}');"; $repeat = get_theme_mod('background_repeat', get_theme_support('custom-background', 'default-repeat')); if (!in_array($repeat, array('no-repeat', 'repeat-x', 'repeat-y', 'repeat'))) { $repeat = 'repeat'; } $repeat = " background-repeat: {$repeat};"; $position = get_theme_mod('background_position_x', get_theme_support('custom-background', 'default-position-x')); if (!in_array($position, array('center', 'right', 'left'))) { $position = 'left'; } $position = " background-position: top {$position};"; $attachment = get_theme_mod('background_attachment', get_theme_support('custom-background', 'default-attachment')); if (!in_array($attachment, array('fixed', 'scroll'))) { $attachment = 'scroll'; } $attachment = " background-attachment: {$attachment};"; $style .= $image . $repeat . $position . $attachment; } ?> <style type="text/css" id="custom-background-css"> body.custom-background { <?php echo trim($style); ?> } </style> <?php }
<?php $hide_meta_info = ''; $hide_meta_info = apply_filters('hoot_hide_meta_info', $hide_meta_info, 'top'); ?> <?php if (!$hide_meta_info && 'top' == hoot_get_option('post_meta_location') && !is_attachment()) { ?> <div <?php hoot_attr('loop-description'); ?> > <?php if (is_page()) { hoot_meta_info_blocks(hoot_get_option('page_meta')); } else { hoot_meta_info_blocks(hoot_get_option('post_meta')); } ?> </div><!-- .loop-description --> <?php } ?> </div><!-- .entry-header --> </div><!-- .loop-meta --> </div> </div> </div> <?php
/** * Build URL for loading Google Fonts * @credit http://themeshaper.com/2014/08/13/how-to-add-google-fonts-to-wordpress-themes/ * * @since 1.0 * @access public * @return void */ function hoot_google_fonts_enqueue_url() { $fonts_url = ''; $query_args = array(); /* Translators: If there are characters in your language that are not * supported by this font, translate this to 'off'. Do not translate * into your own language. */ $playball = 'cursive' == hoot_get_option('headings_fontface') ? _x('on', 'Playball font: on or off', 'responsive-brix') : 'off'; /* Translators: If there are characters in your language that are not * supported by this font, translate this to 'off'. Do not translate * into your own language. */ $open_sans = _x('on', 'Open Sans font: on or off', 'responsive-brix'); if ('off' !== $playball || 'off' !== $open_sans) { $font_families = array(); if ('off' !== $playball) { $font_families[] = 'Playball:400'; } if ('off' !== $open_sans) { $font_families[] = 'Open Sans:400,400italic,700,700italic,800'; } $query_args = array('family' => urlencode(implode('|', $font_families)), 'subset' => urlencode('latin')); } if (!empty($query_args)) { $fonts_url = add_query_arg($query_args, '//fonts.googleapis.com/css'); } return $fonts_url; }
function hoot_woo_custom_loop_columns_css() { $columns = hoot_get_option('wooshop_product_columns', 4); if ($columns == 4) { return; } switch ($columns) { case '2': $css = '.woocommerce ul.products li.product, .woocommerce-page ul.products li.product { width: 48.1%; }'; break; case '3': $css = '.woocommerce ul.products li.product, .woocommerce-page ul.products li.product { width: 30.8%; }'; break; case '5': $css = '.woocommerce ul.products li.product, .woocommerce-page ul.products li.product { width: 16.96%; }'; break; } if (!empty($css)) { wp_add_inline_style('style', $css); } }
echo $highlight_class; ?> "> <div class="widgetized-template-slider <?php echo $slider_grid; ?> "> <div class="grid-row"> <div class="grid-span-12"> <?php global $hoot_theme; /* Reset any previous slider */ $hoot_theme->slider = array(); $hoot_theme->sliderSettings = array('class' => 'wt-slider'); /* Create slider object */ $slides = hoot_get_option('wt_img_slider'); foreach ($slides as $slide) { if (!empty($slide['image'])) { $hoot_theme->slider[] = $slide; } } /* Display Slider Template */ get_template_part('template-parts/slider-image'); ?> </div> </div> </div> </div> <?php break;
/** * 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); } }
/** * Create CSS style from grid width. * * @since 1.0.0 * @access public * @return string */ function hoot_css_grid_width() { $output = ''; $width = intval(hoot_get_option('site_width')); $width = !empty($width) ? $width : 1260; $output .= hoot_css_rule('max-width', $width . 'px'); return $output; }
/** * 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']; } }
/** * Get the image size to use in a span/column of the CSS grid * @todo Can be made more flexible, but for now this will have to do. * Case 1: $grid can be a container span, for when a spanN is in a grid which itself is a spanN/Column * Case 2: Account for responsive spans i.e. set a minimum span size for smaller spans so that mobile viewports * will show bigger width images for available screen space. Example: span1,2,3 will have image sizes * corresponding to span4, so that in mobile view where all spans have 100% width, images are displayed * more nicely! * Case 3: Maybe find a robust (not hard coded) way to account for span padding as well (curently $swidth * does not take padding into account) * * @since 1.0.0 * @access public * @param string $span span size or column size * @param NULL|bool $crop get only cropped if true, only noncropped if false, either for anything else. * @param int $gridadjust Grid's Width Adjustment for various paddings (possible value 80) * @return string */ function hoot_get_image_size_name($span, $crop = NULL, $gridadjust = 0) { $default_grid = 1260; /* Get the Span/Column factor */ if (strpos($span, 'span-') !== false) { $pieces = explode("span-", $span); $factor = $pieces[1]; } elseif (strpos($span, 'column-') !== false) { $pieces = explode("column-", $span); $factors = explode("-", $pieces[1]); $factor = $factors[0] * 12 / $factors[1]; } else { return false; } /* Responsive Grid: Any span below 3 gets an image size fit for atleast span3 to display nicely on smaller screens */ $factor = intval($factor) < 3 ? 3 : intval($factor); /* Get the Grid (int)Width from Hoot Options else Default */ $grid = function_exists('hoot_get_option') ? intval(hoot_get_option('site_width')) : 0; if (empty($grid)) { $grid = $default_grid; } $grid -= $gridadjust; /* Get width array arranged in ascending order */ if ($crop === true) { $iwidths = hoot_get_image_sizes('sort_by_width_crop'); } elseif ($crop === false) { $iwidths = hoot_get_image_sizes('sort_by_width_nocrop'); } else { $iwidths = hoot_get_image_sizes('sort_by_width'); } /* Get Image size corresponding to span width */ $swidth = $factor / 12 * $grid; foreach ($iwidths as $name => $iwidth) { if ((int) $swidth <= (int) $iwidth) { return $name; } } /* If this was a crop/no-crop request and we didn't find any image size, then search all available sizes. */ if ($crop === true || $crop === false) { $iwidths = hoot_get_image_sizes('sort_by_width'); foreach ($iwidths as $name => $iwidth) { if ((int) $swidth <= (int) $iwidth) { return $name; } } } /* Full size image (largest width) */ return 'full'; }
<?php $site_info = hoot_get_option('site_info'); $site_info = str_replace("<!--year-->", date_i18n('Y'), $site_info); if (!empty($site_info)) { ?> <div id="post-footer" class="grid-stretch contrast-typo"> <div class="grid"> <div class="grid-row"> <div class="grid-span-12"> <p class="credit small"> <?php if (trim($site_info) == '<!--default-->') { printf(__('Designed using %1$s. Powered by %2$s.', 'dispatch'), hoot_get_wp_theme_link(apply_filters('hoot_footer_wp_theme_link', 'https://wordpress.org/themes/dispatch/')), hoot_get_wp_link(), hoot_get_site_link()); } else { echo $site_info; } ?> </p><!-- .credit --> </div> </div> </div> </div> <?php }
<?php // Get Left Content $topbar_left = is_active_sidebar('topbar-left'); // Get Right Content $topbar_right = ''; $topbar_icons = hoot_get_option('topbar_icons'); if (is_array($topbar_icons)) { foreach ($topbar_icons as $profile) { if (!empty($profile['icon']) && !empty($profile['url'])) { $topbar_right .= '<a class="social-icons-icon ' . $profile['icon'] . '-block" href="' . esc_url($profile['url']) . '"><i class="fa ' . $profile['icon'] . '"></i></a>'; } } } // Show Search $search = !(bool) hoot_get_option('topbar_hide_search'); // Return if nothing to show if (empty($topbar_left) && empty($topbar_right) && !$search) { return; } // Display Topbar ?> <div id="topbar" class="grid-stretch"> <div class="grid"> <div class="grid-row"> <div class="grid-span-12"> <div class="table"> <?php if ($topbar_left) {
?> "> <h4><?php echo $linktag; the_title(); echo $linktagend; ?> </h4> <div class="content-block-text"><?php if (empty($excerpt)) { the_content(); } else { the_excerpt(); } if ($linktag) { $linktext = !empty($box['link']) ? $box['link'] : hoot_get_option('read_more'); $linktext = empty($linktext) ? sprintf(__('Read More %s', 'dispatch'), '→') : $linktext; echo '<p class="more-link">' . $linktag . $linktext . $linktagend . '</p>'; } ?> </div> </div> </div><?php break; } } wp_reset_postdata(); ?> <?php