Move page titles into separate file
This commit is contained in:
@@ -8,6 +8,7 @@ require_once locate_template('/lib/wrapper.php'); // Theme wrapper class
|
|||||||
require_once locate_template('/lib/sidebar.php'); // Sidebar class
|
require_once locate_template('/lib/sidebar.php'); // Sidebar class
|
||||||
require_once locate_template('/lib/config.php'); // Configuration
|
require_once locate_template('/lib/config.php'); // Configuration
|
||||||
require_once locate_template('/lib/activation.php'); // Theme activation
|
require_once locate_template('/lib/activation.php'); // Theme activation
|
||||||
|
require_once locate_template('/lib/titles.php'); // Page titles
|
||||||
require_once locate_template('/lib/cleanup.php'); // Cleanup
|
require_once locate_template('/lib/cleanup.php'); // Cleanup
|
||||||
require_once locate_template('/lib/nav.php'); // Custom nav modifications
|
require_once locate_template('/lib/nav.php'); // Custom nav modifications
|
||||||
require_once locate_template('/lib/gallery.php'); // Custom [gallery] modifications
|
require_once locate_template('/lib/gallery.php'); // Custom [gallery] modifications
|
||||||
|
|||||||
37
lib/titles.php
Normal file
37
lib/titles.php
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Page titles
|
||||||
|
*/
|
||||||
|
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()) {
|
||||||
|
$author = get_queried_object();
|
||||||
|
printf(__('Author Archives: %s', 'roots'), $author->display_name);
|
||||||
|
} else {
|
||||||
|
single_cat_title();
|
||||||
|
}
|
||||||
|
} elseif (is_search()) {
|
||||||
|
printf(__('Search Results for %s', 'roots'), get_search_query());
|
||||||
|
} elseif (is_404()) {
|
||||||
|
_e('Not Found', 'roots');
|
||||||
|
} else {
|
||||||
|
the_title();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,41 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Page titles
|
* Utility functions
|
||||||
*/
|
*/
|
||||||
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()) {
|
|
||||||
$author = get_queried_object();
|
|
||||||
printf(__('Author Archives: %s', 'roots'), $author->display_name);
|
|
||||||
} else {
|
|
||||||
single_cat_title();
|
|
||||||
}
|
|
||||||
} elseif (is_search()) {
|
|
||||||
printf(__('Search Results for %s', 'roots'), get_search_query());
|
|
||||||
} elseif (is_404()) {
|
|
||||||
_e('Not Found', 'roots');
|
|
||||||
} else {
|
|
||||||
the_title();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function add_filters($tags, $function) {
|
function add_filters($tags, $function) {
|
||||||
foreach($tags as $tag) {
|
foreach($tags as $tag) {
|
||||||
add_filter($tag, $function);
|
add_filter($tag, $function);
|
||||||
|
|||||||
Reference in New Issue
Block a user