]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/general-template.php
Wordpress 3.7
[autoinstalls/wordpress.git] / wp-includes / general-template.php
index b586762473e4b85a9860f2181d924b4e76658ba0..90e19d4b7267d08a9d92096b8e205ba0b7b1c236 100644 (file)
@@ -172,7 +172,7 @@ function get_search_form( $echo = true ) {
                        $form = '<form role="search" method="get" class="search-form" action="' . esc_url( home_url( '/' ) ) . '">
                                <label>
                                        <span class="screen-reader-text">' . _x( 'Search for:', 'label' ) . '</span>
-                                       <input type="search" class="search-field" placeholder="' . esc_attr_x( 'Search &hellip;', 'placeholder' ) . '" value="' . get_search_query() . '" name="s" title="' . _x( 'Search for:', 'label' ) . '" />
+                                       <input type="search" class="search-field" placeholder="' . esc_attr_x( 'Search &hellip;', 'placeholder' ) . '" value="' . get_search_query() . '" name="s" title="' . esc_attr_x( 'Search for:', 'label' ) . '" />
                                </label>
                                <input type="submit" class="search-submit" value="'. esc_attr_x( 'Search', 'submit button' ) .'" />
                        </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 = '&raquo;', $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 = '&raquo;', $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<link rel='archives' title='$title_text' href='$url' />\n";
+               $link_html = "\t<link rel='archives' title='" . esc_attr( $text ) . "' href='$url' />\n";
        elseif ('option' == $format)
                $link_html = "\t<option value='$url'>$before $text $after</option>\n";
        elseif ('html' == $format)
-               $link_html = "\t<li>$before<a href='$url' title='$title_text'>$text</a>$after</li>\n";
+               $link_html = "\t<li>$before<a href='$url'>$text</a>$after</li>\n";
        else // custom
-               $link_html = "\t$before<a href='$url' title='$title_text'>$text</a>$after\n";
+               $link_html = "\t$before<a href='$url'>$text</a>$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 '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr(sprintf( $args['feedtitle'], get_bloginfo('name'), $args['separator'] )) . '" href="' . get_feed_link() . "\" />\n";
-       echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr(sprintf( $args['comstitle'], get_bloginfo('name'), $args['separator'] )) . '" href="' . get_feed_link( 'comments_' . get_default_feed() ) . "\" />\n";
+       echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( sprintf( $args['feedtitle'], get_bloginfo('name'), $args['separator'] ) ) . '" href="' . esc_url( get_feed_link() ) . "\" />\n";
+       echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( sprintf( $args['comstitle'], get_bloginfo('name'), $args['separator'] ) ) . '" href="' . esc_url( get_feed_link( 'comments_' . get_default_feed() ) ) . "\" />\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) )