$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 …', 'placeholder' ) . '" value="' . get_search_query() . '" name="s" title="' . _x( 'Search for:', 'label' ) . '" />
+ <input type="search" class="search-field" placeholder="' . esc_attr_x( 'Search …', '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>';
$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();
$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 );
// 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
if ( $display )
echo $prefix . $title;
else
- return $title;
+ return $prefix . $title;
}
/**
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;
}
/**
if ( $display )
echo $prefix . $term_name;
else
- return $term_name;
+ return $prefix . $term_name;
}
/**
*/
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 );
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);
}
}
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]) )
$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";
}
/**
$args = wp_parse_args( $args, $defaults );
- if ( is_single() || is_page() ) {
+ if ( is_singular() ) {
$id = 0;
$post = get_post( $id );
$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') );
$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) )