Make better use of $wp_query->get_queried_object() instead of duplicating its functionality. See [13143]
git-svn-id: http://svn.automattic.com/wordpress/trunk@13219 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c402ed54bb
commit
0cf65f18a6
|
@ -673,18 +673,15 @@ function single_post_title($prefix = '', $display = true) {
|
||||||
*/
|
*/
|
||||||
function single_cat_title($prefix = '', $display = true ) {
|
function single_cat_title($prefix = '', $display = true ) {
|
||||||
global $wp_query;
|
global $wp_query;
|
||||||
$cat = $wp_query->queried_object;
|
|
||||||
|
|
||||||
if ( is_tag() ) {
|
if ( is_tag() )
|
||||||
return single_tag_title($prefix, $display);
|
return single_tag_title($prefix, $display);
|
||||||
} elseif ( !empty($cat->name) ) {
|
|
||||||
$cat = $cat->name;
|
if ( !is_category() )
|
||||||
} else {
|
return;
|
||||||
$cat = intval( get_query_var('cat') );
|
|
||||||
if ( !empty($cat) )
|
$cat = $wp_query->get_queried_object();
|
||||||
$cat = get_the_category_by_ID($cat);
|
$my_cat_name = apply_filters('single_cat_title', $cat->name);
|
||||||
}
|
|
||||||
$my_cat_name = apply_filters('single_cat_title', $cat);
|
|
||||||
if ( !empty($my_cat_name) ) {
|
if ( !empty($my_cat_name) ) {
|
||||||
if ( $display )
|
if ( $display )
|
||||||
echo $prefix . strip_tags($my_cat_name);
|
echo $prefix . strip_tags($my_cat_name);
|
||||||
|
@ -711,22 +708,14 @@ function single_cat_title($prefix = '', $display = true ) {
|
||||||
* @return string|null Title when retrieving, null when displaying or failure.
|
* @return string|null Title when retrieving, null when displaying or failure.
|
||||||
*/
|
*/
|
||||||
function single_tag_title($prefix = '', $display = true ) {
|
function single_tag_title($prefix = '', $display = true ) {
|
||||||
|
global $wp_query;
|
||||||
if ( !is_tag() )
|
if ( !is_tag() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
global $wp_query;
|
$tag = $wp_query->get_queried_object();;
|
||||||
$tag = $wp_query->queried_object;
|
|
||||||
|
|
||||||
if ( !empty($tag->name) ) {
|
if ( ! $tag )
|
||||||
$tag = sanitize_term($tag, 'post_tag', 'display');
|
return;
|
||||||
} else {
|
|
||||||
$tag_id = intval( get_query_var('tag_id') );
|
|
||||||
if ( !empty($tag_id) ) {
|
|
||||||
$tag = &get_term($tag_id, 'post_tag', OBJECT, 'display');
|
|
||||||
if ( is_wp_error( $tag ) )
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$my_tag_name = apply_filters('single_tag_title', $tag->name);
|
$my_tag_name = apply_filters('single_tag_title', $tag->name);
|
||||||
if ( !empty($my_tag_name) ) {
|
if ( !empty($my_tag_name) ) {
|
||||||
|
|
Loading…
Reference in New Issue