Ejemplo n.º 1
0
/**
 * 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;
}
/**
 * Gets the loop description.  This function should only be used on archive-type pages, such as archive, blog, and 
 * search results pages.  It outputs the description of the page.
 *
 * @link   http://core.trac.wordpress.org/ticket/21995
 * @since 1.0.0
 * @access public
 * @return string
 */
function hoot_get_loop_description()
{
    $loop_desc = '';
    if (is_home() && !is_front_page()) {
        $loop_desc = get_post_field('post_content', get_queried_object_id(), 'raw');
    } elseif (is_category()) {
        $loop_desc = get_term_field('description', get_queried_object_id(), 'category', 'raw');
    } elseif (is_tag()) {
        $loop_desc = get_term_field('description', get_queried_object_id(), 'post_tag', 'raw');
    } elseif (is_tax()) {
        $loop_desc = get_term_field('description', get_queried_object_id(), get_query_var('taxonomy'), 'raw');
    } elseif (is_author()) {
        $loop_desc = get_the_author_meta('description', get_query_var('author'));
    } elseif (is_search()) {
        $loop_desc = sprintf(__('You are browsing the search results for “%s”', 'hoot'), get_search_query());
    } elseif (is_post_type_archive()) {
        $loop_desc = get_post_type_object(get_query_var('post_type'))->description;
    } elseif (is_time()) {
        $loop_desc = __('You are browsing the site archives by time.', 'hoot');
    } elseif (is_day()) {
        $loop_desc = sprintf(__('You are browsing the site archives for %s.', 'hoot'), hoot_single_day_title('', false));
    } elseif (is_month()) {
        $loop_desc = sprintf(__('You are browsing the site archives for %s.', 'hoot'), single_month_title(' ', false));
    } elseif (is_year()) {
        $loop_desc = sprintf(__('You are browsing the site archives for %s.', 'hoot'), hoot_single_year_title('', false));
    } elseif (is_archive()) {
        $loop_desc = __('You are browsing the site archives.', 'hoot');
    }
    return apply_filters('hoot_loop_description', $loop_desc);
}