X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/a6f44f0edcda2471c5a33e4156c1c9488c7f3210..refs/tags/wordpress-3.7:/wp-includes/general-template.php diff --git a/wp-includes/general-template.php b/wp-includes/general-template.php index b5867624..90e19d4b 100644 --- a/wp-includes/general-template.php +++ b/wp-includes/general-template.php @@ -172,7 +172,7 @@ function get_search_form( $echo = true ) { $form = ''; @@ -478,7 +478,7 @@ function get_bloginfo( $show = '', $filter = 'raw' ) { $output = get_feed_link('comments_rss2'); break; case 'pingback_url': - $output = get_option('siteurl') .'/xmlrpc.php'; + $output = site_url( 'xmlrpc.php' ); break; case 'stylesheet_url': $output = get_stylesheet_uri(); @@ -577,6 +577,16 @@ function wp_title($sep = '»', $display = true, $seplocation = '') { $title = single_post_title( '', false ); } + // If there's a post type archive + if ( is_post_type_archive() ) { + $post_type = get_query_var( 'post_type' ); + if ( is_array( $post_type ) ) + $post_type = reset( $post_type ); + $post_type_object = get_post_type_object( $post_type ); + if ( ! $post_type_object->has_archive ) + $title = post_type_archive_title( '', false ); + } + // If there's a category or tag if ( is_category() || is_tag() ) { $title = single_term_title( '', false ); @@ -585,18 +595,21 @@ function wp_title($sep = '»', $display = true, $seplocation = '') { // If there's a taxonomy if ( is_tax() ) { $term = get_queried_object(); - $tax = get_taxonomy( $term->taxonomy ); - $title = single_term_title( $tax->labels->name . $t_sep, false ); + if ( $term ) { + $tax = get_taxonomy( $term->taxonomy ); + $title = single_term_title( $tax->labels->name . $t_sep, false ); + } } // If there's an author if ( is_author() ) { $author = get_queried_object(); - $title = $author->display_name; + if ( $author ) + $title = $author->display_name; } - // If there's a post type archive - if ( is_post_type_archive() ) + // Post type archives with has_archive should override terms. + if ( is_post_type_archive() && $post_type_object->has_archive ) $title = post_type_archive_title( '', false ); // If there's a month @@ -677,7 +690,7 @@ function single_post_title($prefix = '', $display = true) { if ( $display ) echo $prefix . $title; else - return $title; + return $prefix . $title; } /** @@ -696,13 +709,17 @@ function post_type_archive_title( $prefix = '', $display = true ) { if ( ! is_post_type_archive() ) return; - $post_type_obj = get_queried_object(); + $post_type = get_query_var( 'post_type' ); + if ( is_array( $post_type ) ) + $post_type = reset( $post_type ); + + $post_type_obj = get_post_type_object( $post_type ); $title = apply_filters('post_type_archive_title', $post_type_obj->labels->name ); if ( $display ) echo $prefix . $title; else - return $title; + return $prefix . $title; } /** @@ -785,7 +802,7 @@ function single_term_title( $prefix = '', $display = true ) { if ( $display ) echo $prefix . $term_name; else - return $term_name; + return $prefix . $term_name; } /** @@ -866,17 +883,16 @@ function single_month_title($prefix = '', $display = true ) { */ function get_archives_link($url, $text, $format = 'html', $before = '', $after = '') { $text = wptexturize($text); - $title_text = esc_attr($text); $url = esc_url($url); if ('link' == $format) - $link_html = "\t\n"; + $link_html = "\t\n"; elseif ('option' == $format) $link_html = "\t\n"; elseif ('html' == $format) - $link_html = "\t
  • $before$text$after
  • \n"; + $link_html = "\t
  • $before$text$after
  • \n"; else // custom - $link_html = "\t$before$text$after\n"; + $link_html = "\t$before$text$after\n"; $link_html = apply_filters( 'get_archives_link', $link_html ); @@ -1062,10 +1078,12 @@ function wp_get_archives($args = '') { foreach ( (array) $results as $result ) { if ( $result->post_date != '0000-00-00 00:00:00' ) { $url = get_permalink( $result ); - if ( $result->post_title ) + if ( $result->post_title ) { + /** This filter is documented in wp-includes/post-template.php */ $text = strip_tags( apply_filters( 'the_title', $result->post_title, $result->ID ) ); - else + } else { $text = $result->ID; + } $output .= get_archives_link($url, $text, $format, $before, $after); } } @@ -1250,6 +1268,7 @@ function get_calendar($initial = true, $echo = true) { if ( $ak_post_titles ) { foreach ( (array) $ak_post_titles as $ak_post_title ) { + /** This filter is documented in wp-includes/post-template.php */ $post_title = esc_attr( apply_filters( 'the_title', $ak_post_title->post_title, $ak_post_title->ID ) ); if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) ) @@ -1639,8 +1658,8 @@ function feed_links( $args = array() ) { $args = wp_parse_args( $args, $defaults ); - echo '\n"; - echo '\n"; + echo '\n"; + echo '\n"; } /** @@ -1670,7 +1689,7 @@ function feed_links_extra( $args = array() ) { $args = wp_parse_args( $args, $defaults ); - if ( is_single() || is_page() ) { + if ( is_singular() ) { $id = 0; $post = get_post( $id ); @@ -1678,16 +1697,28 @@ function feed_links_extra( $args = array() ) { $title = sprintf( $args['singletitle'], get_bloginfo('name'), $args['separator'], esc_html( get_the_title() ) ); $href = get_post_comments_feed_link( $post->ID ); } + } elseif ( is_post_type_archive() ) { + $post_type = get_query_var( 'post_type' ); + if ( is_array( $post_type ) ) + $post_type = reset( $post_type ); + + $post_type_obj = get_post_type_object( $post_type ); + $title = sprintf( $args['posttypetitle'], get_bloginfo( 'name' ), $args['separator'], $post_type_obj->labels->name ); + $href = get_post_type_archive_feed_link( $post_type_obj->name ); } elseif ( is_category() ) { $term = get_queried_object(); - $title = sprintf( $args['cattitle'], get_bloginfo('name'), $args['separator'], $term->name ); - $href = get_category_feed_link( $term->term_id ); + if ( $term ) { + $title = sprintf( $args['cattitle'], get_bloginfo('name'), $args['separator'], $term->name ); + $href = get_category_feed_link( $term->term_id ); + } } elseif ( is_tag() ) { $term = get_queried_object(); - $title = sprintf( $args['tagtitle'], get_bloginfo('name'), $args['separator'], $term->name ); - $href = get_tag_feed_link( $term->term_id ); + if ( $term ) { + $title = sprintf( $args['tagtitle'], get_bloginfo('name'), $args['separator'], $term->name ); + $href = get_tag_feed_link( $term->term_id ); + } } elseif ( is_author() ) { $author_id = intval( get_query_var('author') ); @@ -1698,7 +1729,9 @@ function feed_links_extra( $args = array() ) { $href = get_search_feed_link(); } elseif ( is_post_type_archive() ) { $title = sprintf( $args['posttypetitle'], get_bloginfo('name'), $args['separator'], post_type_archive_title( '', false ) ); - $href = get_post_type_archive_feed_link( get_queried_object()->name ); + $post_type_obj = get_queried_object(); + if ( $post_type_obj ) + $href = get_post_type_archive_feed_link( $post_type_obj->name ); } if ( isset($title) && isset($href) )