From aca0793f874b62c4d47b768b49f6575c0d367082 Mon Sep 17 00:00:00 2001 From: magox Date: Wed, 13 Nov 2013 16:40:25 +0100 Subject: [PATCH 1/3] 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. --- lib/titles.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/titles.php b/lib/titles.php index f4671d5..6383fd0 100644 --- a/lib/titles.php +++ b/lib/titles.php @@ -5,33 +5,33 @@ function roots_title() { if (is_home()) { 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 { - _e('Latest Posts', 'roots'); + return __('Latest Posts', 'roots'); } } elseif (is_archive()) { $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')); if ($term) { - echo apply_filters('single_term_title', $term->name); + return $term->name; } elseif (is_post_type_archive()) { - echo apply_filters('the_title', get_queried_object()->labels->name); + return get_queried_object()->labels->name; } elseif (is_day()) { - printf(__('Daily Archives: %s', 'roots'), get_the_date()); + return sprintf(__('Daily Archives: %s', 'roots'), get_the_date()); } 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()) { - printf(__('Yearly Archives: %s', 'roots'), get_the_date('Y')); + return sprintf(__('Yearly Archives: %s', 'roots'), get_the_date('Y')); } elseif (is_author()) { $author = get_queried_object(); - printf(__('Author Archives: %s', 'roots'), $author->display_name); + return sprintf(__('Author Archives: %s', 'roots'), $author->display_name); } else { - single_cat_title(); + return single_cat_title('',false); } } 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()) { - _e('Not Found', 'roots'); + return __('Not Found', 'roots'); } else { - the_title(); + return get_the_title(); } -} +} \ No newline at end of file From 6cbdcd63e2f7574841f2f47e48233452540d101a Mon Sep 17 00:00:00 2001 From: magox Date: Wed, 13 Nov 2013 17:22:57 +0100 Subject: [PATCH 2/3] add a space after the comma L:28 --- lib/titles.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/titles.php b/lib/titles.php index 6383fd0..d4396cf 100644 --- a/lib/titles.php +++ b/lib/titles.php @@ -25,7 +25,7 @@ function roots_title() { $author = get_queried_object(); return sprintf(__('Author Archives: %s', 'roots'), $author->display_name); } else { - return single_cat_title('',false); + return single_cat_title('', false); } } elseif (is_search()) { return sprintf(__('Search Results for %s', 'roots'), get_search_query()); From bfd07ce8ff50f6bad19ab4ff0d420f7023157e91 Mon Sep 17 00:00:00 2001 From: magox Date: Wed, 13 Nov 2013 17:58:00 +0100 Subject: [PATCH 3/3] restore apply_filters and switch echo to return --- lib/titles.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/titles.php b/lib/titles.php index d4396cf..6ef7743 100644 --- a/lib/titles.php +++ b/lib/titles.php @@ -12,9 +12,9 @@ function roots_title() { } elseif (is_archive()) { $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy')); if ($term) { - return $term->name; + return apply_filters('single_term_title', $term->name); } elseif (is_post_type_archive()) { - return get_queried_object()->labels->name; + return apply_filters('the_title', get_queried_object()->labels->name); } elseif (is_day()) { return sprintf(__('Daily Archives: %s', 'roots'), get_the_date()); } elseif (is_month()) {