From b01b14a4673ec7f917db309aa454ef3e83c6331a Mon Sep 17 00:00:00 2001 From: Konstantin Kovshenin Date: Fri, 14 Sep 2012 20:43:20 +0400 Subject: [PATCH 1/2] Renaming inc/tweaks.php to inc/extras.php and including by default in functions.php --- functions.php | 2 +- inc/{tweaks.php => extras.php} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename inc/{tweaks.php => extras.php} (100%) diff --git a/functions.php b/functions.php index 5067672a..4649ce4b 100644 --- a/functions.php +++ b/functions.php @@ -34,7 +34,7 @@ function _s_setup() { /** * Custom functions that act independently of the theme templates */ - //require( get_template_directory() . '/inc/tweaks.php' ); + require( get_template_directory() . '/inc/extras.php' ); /** * Custom Theme Options diff --git a/inc/tweaks.php b/inc/extras.php similarity index 100% rename from inc/tweaks.php rename to inc/extras.php From 3517c7a36b94c412170ecda210ac86b4e6d97f01 Mon Sep 17 00:00:00 2001 From: Konstantin Kovshenin Date: Fri, 14 Sep 2012 20:49:06 +0400 Subject: [PATCH 2/2] Use a filter for wp_title instead of hard-coding things in header.php --- header.php | 24 ++---------------------- inc/extras.php | 29 ++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 23 deletions(-) diff --git a/header.php b/header.php index 55bd1631..aef91adf 100644 --- a/header.php +++ b/header.php @@ -12,27 +12,7 @@ -<?php - /* - * Print the <title> tag based on what is being viewed. - */ - global $page, $paged; - - wp_title( '|', true, 'right' ); - - // Add the blog name. - bloginfo( 'name' ); - - // Add the blog description for the home/front page. - $site_description = get_bloginfo( 'description', 'display' ); - if ( $site_description && ( is_home() || is_front_page() ) ) - echo " | $site_description"; - - // Add a page number if necessary: - if ( $paged >= 2 || $page >= 2 ) - echo ' | ' . sprintf( __( 'Page %s', '_s' ), max( $paged, $page ) ); - - ?> +<?php wp_title( '|', true, 'right' ); ?> -
\ No newline at end of file +
diff --git a/inc/extras.php b/inc/extras.php index 03e8de91..72fb96c8 100644 --- a/inc/extras.php +++ b/inc/extras.php @@ -49,4 +49,31 @@ function _s_enhanced_image_navigation( $url, $id ) { return $url; } -add_filter( 'attachment_link', '_s_enhanced_image_navigation', 10, 2 ); \ No newline at end of file +add_filter( 'attachment_link', '_s_enhanced_image_navigation', 10, 2 ); + +/** + * Filters wp_title to print a neat tag based on what is being viewed. + * + * @since _s 1.1 + */ +function _s_wp_title( $title, $sep ) { + global $page, $paged; + + if ( is_feed() ) + return $title; + + // Add the blog name + $title .= get_bloginfo( 'name' ); + + // Add the blog description for the home/front page. + $site_description = get_bloginfo( 'description', 'display' ); + if ( $site_description && ( is_home() || is_front_page() ) ) + $title .= " $sep $site_description"; + + // Add a page number if necessary: + if ( $paged >= 2 || $page >= 2 ) + $title .= " $sep " . sprintf( __( 'Page %s', '_s' ), max( $paged, $page ) ); + + return $title; +} +add_filter( 'wp_title', '_s_wp_title', 10, 2 ); \ No newline at end of file