Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #619 from leoj3n/suggestion.title_function

move template title to function
  • Loading branch information...
commit aa8d428016497eb3df69e2a03c930682c61ea803 2 parents a139878 + 1f1b45b
@swalkinshaw swalkinshaw authored
Showing with 36 additions and 34 deletions.
  1. +35 −0 lib/utils.php
  2. +1 −34 templates/page-header.php
View
35 lib/utils.php
@@ -6,6 +6,41 @@
* @link http://scribu.net/wordpress/theme-wrappers.html
*/
+function roots_title() {
+ if (is_home()) {
+ if (get_option('page_for_posts', true)) {
+ echo get_the_title(get_option('page_for_posts', true));
+ } else {
+ _e('Latest Posts', 'roots');
+ }
+ } elseif (is_archive()) {
+ $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
+ if ($term) {
+ echo $term->name;
+ } elseif (is_post_type_archive()) {
+ echo get_queried_object()->labels->name;
+ } elseif (is_day()) {
+ printf(__('Daily Archives: %s', 'roots'), get_the_date());
+ } elseif (is_month()) {
+ printf(__('Monthly Archives: %s', 'roots'), get_the_date('F Y'));
+ } elseif (is_year()) {
+ printf(__('Yearly Archives: %s', 'roots'), get_the_date('Y'));
+ } elseif (is_author()) {
+ global $post;
+ $author_id = $post->post_author;
+ printf(__('Author Archives: %s', 'roots'), get_the_author_meta('display_name', $author_id));
+ } else {
+ single_cat_title();
+ }
+ } elseif (is_search()) {
+ printf(__('Search Results for %s', 'roots'), get_search_query());
+ } elseif (is_404()) {
+ _e('File Not Found', 'roots');
+ } else {
+ the_title();
+ }
+}
+
function roots_template_path() {
return Roots_Wrapping::$main_template;
}
View
35 templates/page-header.php
@@ -1,38 +1,5 @@
<div class="page-header">
<h1>
- <?php
- if (is_home()) {
- if (get_option('page_for_posts', true)) {
- echo get_the_title(get_option('page_for_posts', true));
- } else {
- _e('Latest Posts', 'roots');
- }
- } elseif (is_archive()) {
- $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
- if ($term) {
- echo $term->name;
- } elseif (is_post_type_archive()) {
- echo get_queried_object()->labels->name;
- } elseif (is_day()) {
- printf(__('Daily Archives: %s', 'roots'), get_the_date());
- } elseif (is_month()) {
- printf(__('Monthly Archives: %s', 'roots'), get_the_date('F Y'));
- } elseif (is_year()) {
- printf(__('Yearly Archives: %s', 'roots'), get_the_date('Y'));
- } elseif (is_author()) {
- global $post;
- $author_id = $post->post_author;
- printf(__('Author Archives: %s', 'roots'), get_the_author_meta('display_name', $author_id));
- } else {
- single_cat_title();
- }
- } elseif (is_search()) {
- printf(__('Search Results for %s', 'roots'), get_search_query());
- } elseif (is_404()) {
- _e('File Not Found', 'roots');
- } else {
- the_title();
- }
- ?>
+ <?php echo roots_title(); ?>
</h1>
</div>
Please sign in to comment.
Something went wrong with that request. Please try again.