+ ';
+
+ echo apply_filters('get_search_form', $form);
+}
+
+/**
+ * Display the Log In/Out link.
+ *
+ * Displays a link, which allows the user to navigate to the Log In page to log in
+ * or log out depending on whether or not they are currently logged in.
+ *
+ * @since 1.5.0
+ * @uses apply_filters() Calls 'loginout' hook on HTML link content.
+ *
+ * @param string $redirect Optional path to redirect to on login/logout.
+ */
+function wp_loginout($redirect = '') {
if ( ! is_user_logged_in() )
- $link = '' . __('Login') . '';
+ $link = '' . __('Log in') . '';
else
- $link = '' . __('Logout') . '';
+ $link = '' . __('Log out') . '';
echo apply_filters('loginout', $link);
}
+/**
+ * Returns the Log Out URL.
+ *
+ * Returns the URL that allows the user to log out of the site
+ *
+ * @since 2.7
+ * @uses wp_nonce_url() To protect against CSRF
+ * @uses site_url() To generate the log in URL
+ * @uses apply_filters() calls 'logout_url' hook on final logout url
+ *
+ * @param string $redirect Path to redirect to on logout.
+ */
+function wp_logout_url($redirect = '') {
+ $args = array( 'action' => 'logout' );
+ if ( !empty($redirect) ) {
+ $args['redirect_to'] = $redirect;
+ }
+
+ $logout_url = add_query_arg($args, site_url('wp-login.php', 'login'));
+ $logout_url = wp_nonce_url( $logout_url, 'log-out' );
+ return apply_filters('logout_url', $logout_url, $redirect);
+}
+
+/**
+ * Returns the Log In URL.
+ *
+ * Returns the URL that allows the user to log in to the site
+ *
+ * @since 2.7
+ * @uses site_url() To generate the log in URL
+ * @uses apply_filters() calls 'login_url' hook on final login url
+ *
+ * @param string $redirect Path to redirect to on login.
+ */
+function wp_login_url($redirect = '') {
+ $login_url = site_url('wp-login.php', 'login');
+
+ if ( !empty($redirect) ) {
+ $login_url = add_query_arg('redirect_to', urlencode($redirect), $login_url);
+ }
+
+ return apply_filters('login_url', $login_url, $redirect);
+}
+
+/**
+ * Returns the Lost Password URL.
+ *
+ * Returns the URL that allows the user to retrieve the lost password
+ *
+ * @since 2.8.0
+ * @uses site_url() To generate the lost password URL
+ * @uses apply_filters() calls 'lostpassword_url' hook on the lostpassword url
+ *
+ * @param string $redirect Path to redirect to on login.
+ */
+function wp_lostpassword_url($redirect = '') {
+ $args = array( 'action' => 'lostpassword' );
+ if ( !empty($redirect) ) {
+ $args['redirect_to'] = $redirect;
+ }
+
+ $lostpassword_url = add_query_arg($args, site_url('wp-login.php', 'login'));
+ return apply_filters('lostpassword_url', $lostpassword_url, $redirect);
+}
+
+/**
+ * Display the Registration or Admin link.
+ *
+ * Display a link which allows the user to navigate to the registration page if
+ * not logged in and registration is enabled or to the dashboard if logged in.
+ *
+ * @since 1.5.0
+ * @uses apply_filters() Calls 'register' hook on register / admin link content.
+ *
+ * @param string $before Text to output before the link (defaults to
).
+ * @param string $after Text to output after the link (defaults to
).
+ */
function wp_register( $before = '
', $after = '
' ) {
if ( ! is_user_logged_in() ) {
if ( get_option('users_can_register') )
- $link = $before . '' . __('Register') . '' . $after;
+ $link = $before . '' . __('Register') . '' . $after;
else
$link = '';
} else {
- $link = $before . '' . __('Site Admin') . '' . $after;
+ $link = $before . '' . __('Site Admin') . '' . $after;
}
echo apply_filters('register', $link);
}
-
+/**
+ * Theme container function for the 'wp_meta' action.
+ *
+ * The 'wp_meta' action can have several purposes, depending on how you use it,
+ * but one purpose might have been to allow for theme switching.
+ *
+ * @since 1.5.0
+ * @link http://trac.wordpress.org/ticket/1458 Explanation of 'wp_meta' action.
+ * @uses do_action() Calls 'wp_meta' hook.
+ */
function wp_meta() {
do_action('wp_meta');
}
-
+/**
+ * Display information about the blog.
+ *
+ * @see get_bloginfo() For possible values for the parameter.
+ * @since 0.71
+ *
+ * @param string $show What to display.
+ */
function bloginfo($show='') {
echo get_bloginfo($show, 'display');
}
/**
- * Note: some of these values are DEPRECATED. Meaning they could be
- * taken out at any time and shouldn't be relied upon. Options
- * without "// DEPRECATED" are the preferred and recommended ways
- * to get the information.
+ * Retrieve information about the blog.
+ *
+ * Some show parameter values are deprecated and will be removed in future
+ * versions. Care should be taken to check the function contents and know what
+ * the deprecated blog info options are. Options without "// DEPRECATED" are
+ * the preferred and recommended ways to get the information.
+ *
+ * The possible values for the 'show' parameter are listed below.
+ *
+ *
url - Blog URI to homepage.
+ *
wpurl - Blog URI path to WordPress.
+ *
description - Secondary title
+ *
+ *
+ * The feed URL options can be retrieved from 'rdf_url' (RSS 0.91),
+ * 'rss_url' (RSS 1.0), 'rss2_url' (RSS 2.0), or 'atom_url' (Atom feed). The
+ * comment feeds can be retrieved from the 'comments_atom_url' (Atom comment
+ * feed) or 'comments_rss2_url' (RSS 2.0 comment feed).
+ *
+ * There are many other options and you should check the function contents:
+ * {@source 32 37}
+ *
+ * @since 0.71
+ *
+ * @param string $show Blog info to retrieve.
+ * @param string $filter How to filter what is retrieved.
+ * @return string Mostly string values, might be empty.
*/
function get_bloginfo($show = '', $filter = 'raw') {
@@ -158,14 +387,33 @@ function get_bloginfo($show = '', $filter = 'raw') {
return $output;
}
-
-function wp_title($sep = '»', $display = true) {
+/**
+ * Display or retrieve page title for all areas of blog.
+ *
+ * By default, the page title will display the separator before the page title,
+ * so that the blog title will be before the page title. This is not good for
+ * title display, since the blog title shows up on most tabs and not what is
+ * important, which is the page that the user is looking at.
+ *
+ * There are also SEO benefits to having the blog title after or to the 'right'
+ * or the page title. However, it is mostly common sense to have the blog title
+ * to the right with most browsers supporting tabs. You can achieve this by
+ * using the seplocation parameter and setting the value to 'right'. This change
+ * was introduced around 2.5.0, in case backwards compatibility of themes is
+ * important.
+ *
+ * @since 1.0.0
+ *
+ * @param string $sep Optional, default is '»'. How to separate the various items within the page title.
+ * @param bool $display Optional, default is true. Whether to display or retrieve title.
+ * @param string $seplocation Optional. Direction to display title, 'right'.
+ * @return string|null String on retrieve, null when displaying.
+ */
+function wp_title($sep = '»', $display = true, $seplocation = '') {
global $wpdb, $wp_locale, $wp_query;
$cat = get_query_var('cat');
$tag = get_query_var('tag_id');
- $p = get_query_var('p');
- $name = get_query_var('name');
$category_name = get_query_var('category_name');
$author = get_query_var('author');
$author_name = get_query_var('author_name');
@@ -173,8 +421,11 @@ function wp_title($sep = '»', $display = true) {
$year = get_query_var('year');
$monthnum = get_query_var('monthnum');
$day = get_query_var('day');
+ $search = get_query_var('s');
$title = '';
+ $t_sep = '%WP_TITILE_SEP%'; // Temporary separator, for accurate flipping, if necessary
+
// If there's a category
if ( !empty($cat) ) {
// category exclusion
@@ -195,7 +446,7 @@ function wp_title($sep = '»', $display = true) {
if ( !empty($tag) ) {
$tag = get_term($tag, 'post_tag', OBJECT, 'display');
- if ( is_wp_error( $tag ) )
+ if ( is_wp_error( $tag ) )
return $tag;
if ( ! empty($tag->name) )
$title = apply_filters('single_tag_title', $tag->name);
@@ -208,7 +459,7 @@ function wp_title($sep = '»', $display = true) {
}
if ( !empty($author_name) ) {
// We do a direct query here because we don't cache by nicename.
- $title = $wpdb->get_var("SELECT display_name FROM $wpdb->users WHERE user_nicename = '$author_name'");
+ $title = $wpdb->get_var($wpdb->prepare("SELECT display_name FROM $wpdb->users WHERE user_nicename = %s", $author_name));
}
// If there's a month
@@ -216,38 +467,85 @@ function wp_title($sep = '»', $display = true) {
$my_year = substr($m, 0, 4);
$my_month = $wp_locale->get_month(substr($m, 4, 2));
$my_day = intval(substr($m, 6, 2));
- $title = "$my_year" . ($my_month ? "$sep $my_month" : "") . ($my_day ? "$sep $my_day" : "");
+ $title = "$my_year" . ($my_month ? "$t_sep$my_month" : "") . ($my_day ? "$t_sep$my_day" : "");
}
if ( !empty($year) ) {
$title = $year;
if ( !empty($monthnum) )
- $title .= " $sep " . $wp_locale->get_month($monthnum);
+ $title .= "$t_sep" . $wp_locale->get_month($monthnum);
if ( !empty($day) )
- $title .= " $sep " . zeroise($day, 2);
+ $title .= "$t_sep" . zeroise($day, 2);
}
// If there is a post
- if ( is_single() || is_page() ) {
+ if ( is_single() || ( is_home() && !is_front_page() ) || ( is_page() && !is_front_page() ) ) {
$post = $wp_query->get_queried_object();
$title = strip_tags( apply_filters( 'single_post_title', $post->post_title ) );
}
+ // If there's a taxonomy
+ if ( is_tax() ) {
+ $taxonomy = get_query_var( 'taxonomy' );
+ $tax = get_taxonomy( $taxonomy );
+ $tax = $tax->label;
+ $term = $wp_query->get_queried_object();
+ $term = $term->name;
+ $title = "$tax$t_sep$term";
+ }
+
+ //If it's a search
+ if ( is_search() ) {
+ /* translators: 1: separator, 2: search phrase */
+ $title = sprintf(__('Search Results %1$s %2$s'), $t_sep, strip_tags($search));
+ }
+
+ if ( is_404() ) {
+ $title = __('Page not found');
+ }
+
$prefix = '';
if ( !empty($title) )
$prefix = " $sep ";
- $title = $prefix . $title;
- $title = apply_filters('wp_title', $title, $sep);
+ // Determines position of the separator and direction of the breadcrumb
+ if ( 'right' == $seplocation ) { // sep on right, so reverse the order
+ $title_array = explode( $t_sep, $title );
+ $title_array = array_reverse( $title_array );
+ $title = implode( " $sep ", $title_array ) . $prefix;
+ } else {
+ $title_array = explode( $t_sep, $title );
+ $title = $prefix . implode( " $sep ", $title_array );
+ }
+
+ $title = apply_filters('wp_title', $title, $sep, $seplocation);
// Send it out
if ( $display )
echo $title;
else
return $title;
-}
+}
+/**
+ * Display or retrieve page title for post.
+ *
+ * This is optimized for single.php template file for displaying the post title.
+ * Only useful for posts, does not support pages for example.
+ *
+ * It does not support placing the separator after the title, but by leaving the
+ * prefix parameter empty, you can set the title separator manually. The prefix
+ * does not automatically place a space between the prefix, so if there should
+ * be a space, the parameter value will need to have it at the end.
+ *
+ * @since 0.71
+ * @uses $wpdb
+ *
+ * @param string $prefix Optional. What to display before the title.
+ * @param bool $display Optional, default is true. Whether to display or retrieve title.
+ * @return string|null Title when retrieving, null when displaying or failure.
+ */
function single_post_title($prefix = '', $display = true) {
global $wpdb;
$p = get_query_var('p');
@@ -255,7 +553,7 @@ function single_post_title($prefix = '', $display = true) {
if ( intval($p) || '' != $name ) {
if ( !$p )
- $p = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_name = '$name'");
+ $p = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_name = %s", $name));
$post = & get_post($p);
$title = $post->post_title;
$title = apply_filters('single_post_title', $title);
@@ -266,7 +564,23 @@ function single_post_title($prefix = '', $display = true) {
}
}
-
+/**
+ * Display or retrieve page title for category archive.
+ *
+ * This is useful for category template file or files, because it is optimized
+ * for category page title and with less overhead than {@link wp_title()}.
+ *
+ * It does not support placing the separator after the title, but by leaving the
+ * prefix parameter empty, you can set the title separator manually. The prefix
+ * does not automatically place a space between the prefix, so if there should
+ * be a space, the parameter value will need to have it at the end.
+ *
+ * @since 0.71
+ *
+ * @param string $prefix Optional. What to display before the title.
+ * @param bool $display Optional, default is true. Whether to display or retrieve title.
+ * @return string|null Title when retrieving, null when displaying or failure.
+ */
function single_cat_title($prefix = '', $display = true ) {
$cat = intval( get_query_var('cat') );
if ( !empty($cat) && !(strtoupper($cat) == 'ALL') ) {
@@ -282,7 +596,23 @@ function single_cat_title($prefix = '', $display = true ) {
}
}
-
+/**
+ * Display or retrieve page title for tag post archive.
+ *
+ * Useful for tag template files for displaying the tag page title. It has less
+ * overhead than {@link wp_title()}, because of its limited implementation.
+ *
+ * It does not support placing the separator after the title, but by leaving the
+ * prefix parameter empty, you can set the title separator manually. The prefix
+ * does not automatically place a space between the prefix, so if there should
+ * be a space, the parameter value will need to have it at the end.
+ *
+ * @since 2.3.0
+ *
+ * @param string $prefix Optional. What to display before the title.
+ * @param bool $display Optional, default is true. Whether to display or retrieve title.
+ * @return string|null Title when retrieving, null when displaying or failure.
+ */
function single_tag_title($prefix = '', $display = true ) {
if ( !is_tag() )
return;
@@ -291,7 +621,7 @@ function single_tag_title($prefix = '', $display = true ) {
if ( !empty($tag_id) ) {
$my_tag = &get_term($tag_id, 'post_tag', OBJECT, 'display');
- if ( is_wp_error( $my_tag ) )
+ if ( is_wp_error( $my_tag ) )
return false;
$my_tag_name = apply_filters('single_tag_title', $my_tag->name);
if ( !empty($my_tag_name) ) {
@@ -303,7 +633,24 @@ function single_tag_title($prefix = '', $display = true ) {
}
}
-
+/**
+ * Display or retrieve page title for post archive based on date.
+ *
+ * Useful for when the template only needs to display the month and year, if
+ * either are available. Optimized for just this purpose, so if it is all that
+ * is needed, should be better than {@link wp_title()}.
+ *
+ * It does not support placing the separator after the title, but by leaving the
+ * prefix parameter empty, you can set the title separator manually. The prefix
+ * does not automatically place a space between the prefix, so if there should
+ * be a space, the parameter value will need to have it at the end.
+ *
+ * @since 0.71
+ *
+ * @param string $prefix Optional. What to display before the title.
+ * @param bool $display Optional, default is true. Whether to display or retrieve title.
+ * @return string|null Title when retrieving, null when displaying or failure.
+ */
function single_month_title($prefix = '', $display = true ) {
global $wp_locale;
@@ -329,31 +676,94 @@ function single_month_title($prefix = '', $display = true ) {
echo $result;
}
-
-/* link navigation hack by Orien http://icecode.com/ */
+/**
+ * Retrieve archive link content based on predefined or custom code.
+ *
+ * The format can be one of four styles. The 'link' for head element, 'option'
+ * for use in the select element, 'html' for use in list (either ol or ul HTML
+ * elements). Custom content is also supported using the before and after
+ * parameters.
+ *
+ * The 'link' format uses the link HTML element with the archives
+ * relationship. The before and after parameters are not used. The text
+ * parameter is used to describe the link.
+ *
+ * The 'option' format uses the option HTML element for use in select element.
+ * The value is the url parameter and the before and after parameters are used
+ * between the text description.
+ *
+ * The 'html' format, which is the default, uses the li HTML element for use in
+ * the list HTML elements. The before parameter is before the link and the after
+ * parameter is after the closing link.
+ *
+ * The custom format uses the before parameter before the link ('a' HTML
+ * element) and the after parameter after the closing link tag. If the above
+ * three values for the format are not used, then custom format is assumed.
+ *
+ * @since 1.0.0
+ * @author Orien
+ * @link http://icecode.com/ link navigation hack by Orien
+ *
+ * @param string $url URL to archive.
+ * @param string $text Archive text description.
+ * @param string $format Optional, default is 'html'. Can be 'link', 'option', 'html', or custom.
+ * @param string $before Optional.
+ * @param string $after Optional.
+ * @return string HTML link content for archive.
+ */
function get_archives_link($url, $text, $format = 'html', $before = '', $after = '') {
$text = wptexturize($text);
- $title_text = attribute_escape($text);
- $url = clean_url($url);
+ $title_text = esc_attr($text);
+ $url = esc_url($url);
if ('link' == $format)
- return "\t\n";
+ $link_html = "\t\n";
elseif ('option' == $format)
- return "\t\n";
+ $link_html = "\t\n";
elseif ('html' == $format)
- return "\t