roots_title() returns a value

Instead of printing the value directly, now the function returns a
value which can printed with echo (like it is in page-header.php) or
stored in a $var when needed.
This commit is contained in:
magox
2013-11-13 16:40:25 +01:00
parent 41107b1b2b
commit aca0793f87

View File

@@ -5,33 +5,33 @@
function roots_title() { function roots_title() {
if (is_home()) { if (is_home()) {
if (get_option('page_for_posts', true)) { if (get_option('page_for_posts', true)) {
echo get_the_title(get_option('page_for_posts', true)); return get_the_title(get_option('page_for_posts', true));
} else { } else {
_e('Latest Posts', 'roots'); return __('Latest Posts', 'roots');
} }
} elseif (is_archive()) { } elseif (is_archive()) {
$term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')); $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
if ($term) { if ($term) {
echo apply_filters('single_term_title', $term->name); return $term->name;
} elseif (is_post_type_archive()) { } elseif (is_post_type_archive()) {
echo apply_filters('the_title', get_queried_object()->labels->name); return get_queried_object()->labels->name;
} elseif (is_day()) { } elseif (is_day()) {
printf(__('Daily Archives: %s', 'roots'), get_the_date()); return sprintf(__('Daily Archives: %s', 'roots'), get_the_date());
} elseif (is_month()) { } elseif (is_month()) {
printf(__('Monthly Archives: %s', 'roots'), get_the_date('F Y')); return sprintf(__('Monthly Archives: %s', 'roots'), get_the_date('F Y'));
} elseif (is_year()) { } elseif (is_year()) {
printf(__('Yearly Archives: %s', 'roots'), get_the_date('Y')); return sprintf(__('Yearly Archives: %s', 'roots'), get_the_date('Y'));
} elseif (is_author()) { } elseif (is_author()) {
$author = get_queried_object(); $author = get_queried_object();
printf(__('Author Archives: %s', 'roots'), $author->display_name); return sprintf(__('Author Archives: %s', 'roots'), $author->display_name);
} else { } else {
single_cat_title(); return single_cat_title('',false);
} }
} elseif (is_search()) { } elseif (is_search()) {
printf(__('Search Results for %s', 'roots'), get_search_query()); return sprintf(__('Search Results for %s', 'roots'), get_search_query());
} elseif (is_404()) { } elseif (is_404()) {
_e('Not Found', 'roots'); return __('Not Found', 'roots');
} else { } else {
the_title(); return get_the_title();
} }
} }