3 * General template tags that can go anywhere in a template.
10 * Load header template.
12 * Includes the header template for a theme or if a name is specified then a
13 * specialised header will be included.
15 * For the parameter, if the file is called "header-special.php" then specify
18 * @uses locate_template()
20 * @uses do_action() Calls 'get_header' action.
22 * @param string $name The name of the specialised header.
24 function get_header( $name = null ) {
25 do_action( 'get_header', $name );
29 $templates[] = "header-{$name}.php";
31 $templates[] = 'header.php';
33 // Backward compat code will be removed in a future release
34 if ('' == locate_template($templates, true))
35 load_template( ABSPATH . WPINC . '/theme-compat/header.php');
39 * Load footer template.
41 * Includes the footer template for a theme or if a name is specified then a
42 * specialised footer will be included.
44 * For the parameter, if the file is called "footer-special.php" then specify
47 * @uses locate_template()
49 * @uses do_action() Calls 'get_footer' action.
51 * @param string $name The name of the specialised footer.
53 function get_footer( $name = null ) {
54 do_action( 'get_footer', $name );
58 $templates[] = "footer-{$name}.php";
60 $templates[] = 'footer.php';
62 // Backward compat code will be removed in a future release
63 if ('' == locate_template($templates, true))
64 load_template( ABSPATH . WPINC . '/theme-compat/footer.php');
68 * Load sidebar template.
70 * Includes the sidebar template for a theme or if a name is specified then a
71 * specialised sidebar will be included.
73 * For the parameter, if the file is called "sidebar-special.php" then specify
76 * @uses locate_template()
78 * @uses do_action() Calls 'get_sidebar' action.
80 * @param string $name The name of the specialised sidebar.
82 function get_sidebar( $name = null ) {
83 do_action( 'get_sidebar', $name );
87 $templates[] = "sidebar-{$name}.php";
89 $templates[] = 'sidebar.php';
91 // Backward compat code will be removed in a future release
92 if ('' == locate_template($templates, true))
93 load_template( ABSPATH . WPINC . '/theme-compat/sidebar.php');
97 * Load a template part into a template
99 * Makes it easy for a theme to reuse sections of code in a easy to overload way
102 * Includes the named template part for a theme or if a name is specified then a
103 * specialised part will be included. If the theme contains no {slug}.php file
104 * then no template will be included.
106 * The template is included using require, not require_once, so you may include the
107 * same template part multiple times.
109 * For the $name parameter, if the file is called "{slug}-special.php" then specify
112 * @uses locate_template()
114 * @uses do_action() Calls 'get_template_part_{$slug}' action.
116 * @param string $slug The slug name for the generic template.
117 * @param string $name The name of the specialised template.
119 function get_template_part( $slug, $name = null ) {
120 do_action( "get_template_part_{$slug}", $slug, $name );
122 $templates = array();
124 $templates[] = "{$slug}-{$name}.php";
126 $templates[] = "{$slug}.php";
128 locate_template($templates, true, false);
132 * Display search form.
134 * Will first attempt to locate the searchform.php file in either the child or
135 * the parent, then load it. If it doesn't exist, then the default search form
136 * will be displayed. The default search form is HTML, which will be displayed.
137 * There is a filter applied to the search form HTML in order to edit or replace
138 * it. The filter is 'get_search_form'.
140 * This function is primarily used by themes which want to hardcode the search
141 * form into the sidebar and also by the search widget in WordPress.
143 * There is also an action that is called whenever the function is run called,
144 * 'get_search_form'. This can be useful for outputting JavaScript that the
145 * search relies on or various formatting that applies to the beginning of the
146 * search. To give a few examples of what it can be used for.
149 * @param boolean $echo Default to echo and not return the form.
151 function get_search_form($echo = true) {
152 do_action( 'get_search_form' );
154 $search_form_template = locate_template('searchform.php');
155 if ( '' != $search_form_template ) {
156 require($search_form_template);
160 $form = '<form role="search" method="get" id="searchform" action="' . esc_url( home_url( '/' ) ) . '" >
161 <div><label class="screen-reader-text" for="s">' . __('Search for:') . '</label>
162 <input type="text" value="' . get_search_query() . '" name="s" id="s" />
163 <input type="submit" id="searchsubmit" value="'. esc_attr__('Search') .'" />
168 echo apply_filters('get_search_form', $form);
170 return apply_filters('get_search_form', $form);
174 * Display the Log In/Out link.
176 * Displays a link, which allows users to navigate to the Log In page to log in
177 * or log out depending on whether they are currently logged in.
180 * @uses apply_filters() Calls 'loginout' hook on HTML link content.
182 * @param string $redirect Optional path to redirect to on login/logout.
183 * @param boolean $echo Default to echo and not return the link.
185 function wp_loginout($redirect = '', $echo = true) {
186 if ( ! is_user_logged_in() )
187 $link = '<a href="' . esc_url( wp_login_url($redirect) ) . '">' . __('Log in') . '</a>';
189 $link = '<a href="' . esc_url( wp_logout_url($redirect) ) . '">' . __('Log out') . '</a>';
192 echo apply_filters('loginout', $link);
194 return apply_filters('loginout', $link);
198 * Returns the Log Out URL.
200 * Returns the URL that allows the user to log out of the site
203 * @uses wp_nonce_url() To protect against CSRF
204 * @uses site_url() To generate the log in URL
205 * @uses apply_filters() calls 'logout_url' hook on final logout url
207 * @param string $redirect Path to redirect to on logout.
209 function wp_logout_url($redirect = '') {
210 $args = array( 'action' => 'logout' );
211 if ( !empty($redirect) ) {
212 $args['redirect_to'] = urlencode( $redirect );
215 $logout_url = add_query_arg($args, site_url('wp-login.php', 'login'));
216 $logout_url = wp_nonce_url( $logout_url, 'log-out' );
218 return apply_filters('logout_url', $logout_url, $redirect);
222 * Returns the Log In URL.
224 * Returns the URL that allows the user to log in to the site
227 * @uses site_url() To generate the log in URL
228 * @uses apply_filters() calls 'login_url' hook on final login url
230 * @param string $redirect Path to redirect to on login.
231 * @param bool $force_reauth Whether to force reauthorization, even if a cookie is present. Default is false.
232 * @return string A log in url
234 function wp_login_url($redirect = '', $force_reauth = false) {
235 $login_url = site_url('wp-login.php', 'login');
237 if ( !empty($redirect) )
238 $login_url = add_query_arg('redirect_to', urlencode($redirect), $login_url);
241 $login_url = add_query_arg('reauth', '1', $login_url);
243 return apply_filters('login_url', $login_url, $redirect);
247 * Provides a simple login form for use anywhere within WordPress. By default, it echoes
248 * the HTML immediately. Pass array('echo'=>false) to return the string instead.
251 * @param array $args Configuration options to modify the form output
252 * @return Void, or string containing the form
254 function wp_login_form( $args = array() ) {
255 $defaults = array( 'echo' => true,
256 'redirect' => ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], // Default redirect is back to the current page
257 'form_id' => 'loginform',
258 'label_username' => __( 'Username' ),
259 'label_password' => __( 'Password' ),
260 'label_remember' => __( 'Remember Me' ),
261 'label_log_in' => __( 'Log In' ),
262 'id_username' => 'user_login',
263 'id_password' => 'user_pass',
264 'id_remember' => 'rememberme',
265 'id_submit' => 'wp-submit',
267 'value_username' => '',
268 'value_remember' => false, // Set this to true to default the "Remember me" checkbox to checked
270 $args = wp_parse_args( $args, apply_filters( 'login_form_defaults', $defaults ) );
273 <form name="' . $args['form_id'] . '" id="' . $args['form_id'] . '" action="' . esc_url( site_url( 'wp-login.php', 'login_post' ) ) . '" method="post">
274 ' . apply_filters( 'login_form_top', '', $args ) . '
275 <p class="login-username">
276 <label for="' . esc_attr( $args['id_username'] ) . '">' . esc_html( $args['label_username'] ) . '</label>
277 <input type="text" name="log" id="' . esc_attr( $args['id_username'] ) . '" class="input" value="' . esc_attr( $args['value_username'] ) . '" size="20" tabindex="10" />
279 <p class="login-password">
280 <label for="' . esc_attr( $args['id_password'] ) . '">' . esc_html( $args['label_password'] ) . '</label>
281 <input type="password" name="pwd" id="' . esc_attr( $args['id_password'] ) . '" class="input" value="" size="20" tabindex="20" />
283 ' . apply_filters( 'login_form_middle', '', $args ) . '
284 ' . ( $args['remember'] ? '<p class="login-remember"><label><input name="rememberme" type="checkbox" id="' . esc_attr( $args['id_remember'] ) . '" value="forever" tabindex="90"' . ( $args['value_remember'] ? ' checked="checked"' : '' ) . ' /> ' . esc_html( $args['label_remember'] ) . '</label></p>' : '' ) . '
285 <p class="login-submit">
286 <input type="submit" name="wp-submit" id="' . esc_attr( $args['id_submit'] ) . '" class="button-primary" value="' . esc_attr( $args['label_log_in'] ) . '" tabindex="100" />
287 <input type="hidden" name="redirect_to" value="' . esc_url( $args['redirect'] ) . '" />
289 ' . apply_filters( 'login_form_bottom', '', $args ) . '
299 * Returns the Lost Password URL.
301 * Returns the URL that allows the user to retrieve the lost password
304 * @uses site_url() To generate the lost password URL
305 * @uses apply_filters() calls 'lostpassword_url' hook on the lostpassword url
307 * @param string $redirect Path to redirect to on login.
309 function wp_lostpassword_url( $redirect = '' ) {
310 $args = array( 'action' => 'lostpassword' );
311 if ( !empty($redirect) ) {
312 $args['redirect_to'] = $redirect;
315 $lostpassword_url = add_query_arg( $args, network_site_url('wp-login.php', 'login') );
316 return apply_filters( 'lostpassword_url', $lostpassword_url, $redirect );
320 * Display the Registration or Admin link.
322 * Display a link which allows the user to navigate to the registration page if
323 * not logged in and registration is enabled or to the dashboard if logged in.
326 * @uses apply_filters() Calls 'register' hook on register / admin link content.
328 * @param string $before Text to output before the link (defaults to <li>).
329 * @param string $after Text to output after the link (defaults to </li>).
330 * @param boolean $echo Default to echo and not return the link.
332 function wp_register( $before = '<li>', $after = '</li>', $echo = true ) {
334 if ( ! is_user_logged_in() ) {
335 if ( get_option('users_can_register') )
336 $link = $before . '<a href="' . site_url('wp-login.php?action=register', 'login') . '">' . __('Register') . '</a>' . $after;
340 $link = $before . '<a href="' . admin_url() . '">' . __('Site Admin') . '</a>' . $after;
344 echo apply_filters('register', $link);
346 return apply_filters('register', $link);
350 * Theme container function for the 'wp_meta' action.
352 * The 'wp_meta' action can have several purposes, depending on how you use it,
353 * but one purpose might have been to allow for theme switching.
356 * @link http://trac.wordpress.org/ticket/1458 Explanation of 'wp_meta' action.
357 * @uses do_action() Calls 'wp_meta' hook.
360 do_action('wp_meta');
364 * Display information about the blog.
366 * @see get_bloginfo() For possible values for the parameter.
369 * @param string $show What to display.
371 function bloginfo( $show='' ) {
372 echo get_bloginfo( $show, 'display' );
376 * Retrieve information about the blog.
378 * Some show parameter values are deprecated and will be removed in future
379 * versions. These options will trigger the _deprecated_argument() function.
380 * The deprecated blog info options are listed in the function contents.
382 * The possible values for the 'show' parameter are listed below.
384 * <li><strong>url</strong> - Blog URI to homepage.</li>
385 * <li><strong>wpurl</strong> - Blog URI path to WordPress.</li>
386 * <li><strong>description</strong> - Secondary title</li>
389 * The feed URL options can be retrieved from 'rdf_url' (RSS 0.91),
390 * 'rss_url' (RSS 1.0), 'rss2_url' (RSS 2.0), or 'atom_url' (Atom feed). The
391 * comment feeds can be retrieved from the 'comments_atom_url' (Atom comment
392 * feed) or 'comments_rss2_url' (RSS 2.0 comment feed).
396 * @param string $show Blog info to retrieve.
397 * @param string $filter How to filter what is retrieved.
398 * @return string Mostly string values, might be empty.
400 function get_bloginfo( $show = '', $filter = 'raw' ) {
403 case 'home' : // DEPRECATED
404 case 'siteurl' : // DEPRECATED
405 _deprecated_argument( __FUNCTION__, '2.2', sprintf( __('The <code>%s</code> option is deprecated for the family of <code>bloginfo()</code> functions.' ), $show ) . ' ' . sprintf( __( 'Use the <code>%s</code> option instead.' ), 'url' ) );
407 $output = home_url();
410 $output = site_url();
413 $output = get_option('blogdescription');
416 $output = get_feed_link('rdf');
419 $output = get_feed_link('rss');
422 $output = get_feed_link('rss2');
425 $output = get_feed_link('atom');
427 case 'comments_atom_url':
428 $output = get_feed_link('comments_atom');
430 case 'comments_rss2_url':
431 $output = get_feed_link('comments_rss2');
434 $output = get_option('siteurl') .'/xmlrpc.php';
436 case 'stylesheet_url':
437 $output = get_stylesheet_uri();
439 case 'stylesheet_directory':
440 $output = get_stylesheet_directory_uri();
442 case 'template_directory':
444 $output = get_template_directory_uri();
447 $output = get_option('admin_email');
450 $output = get_option('blog_charset');
451 if ('' == $output) $output = 'UTF-8';
454 $output = get_option('html_type');
458 $output = $wp_version;
461 $output = get_locale();
462 $output = str_replace('_', '-', $output);
464 case 'text_direction':
465 //_deprecated_argument( __FUNCTION__, '2.2', sprintf( __('The <code>%s</code> option is deprecated for the family of <code>bloginfo()</code> functions.' ), $show ) . ' ' . sprintf( __( 'Use the <code>%s</code> function instead.' ), 'is_rtl()' ) );
466 if ( function_exists( 'is_rtl' ) ) {
467 $output = is_rtl() ? 'rtl' : 'ltr';
474 $output = get_option('blogname');
479 if (strpos($show, 'url') === false &&
480 strpos($show, 'directory') === false &&
481 strpos($show, 'home') === false)
484 if ( 'display' == $filter ) {
486 $output = apply_filters('bloginfo_url', $output, $show);
488 $output = apply_filters('bloginfo', $output, $show);
495 * Retrieve the current blog id
499 * @return int Blog id
501 function get_current_blog_id() {
503 return absint($blog_id);
507 * Display or retrieve page title for all areas of blog.
509 * By default, the page title will display the separator before the page title,
510 * so that the blog title will be before the page title. This is not good for
511 * title display, since the blog title shows up on most tabs and not what is
512 * important, which is the page that the user is looking at.
514 * There are also SEO benefits to having the blog title after or to the 'right'
515 * or the page title. However, it is mostly common sense to have the blog title
516 * to the right with most browsers supporting tabs. You can achieve this by
517 * using the seplocation parameter and setting the value to 'right'. This change
518 * was introduced around 2.5.0, in case backwards compatibility of themes is
523 * @param string $sep Optional, default is '»'. How to separate the various items within the page title.
524 * @param bool $display Optional, default is true. Whether to display or retrieve title.
525 * @param string $seplocation Optional. Direction to display title, 'right'.
526 * @return string|null String on retrieve, null when displaying.
528 function wp_title($sep = '»', $display = true, $seplocation = '') {
529 global $wpdb, $wp_locale;
531 $m = get_query_var('m');
532 $year = get_query_var('year');
533 $monthnum = get_query_var('monthnum');
534 $day = get_query_var('day');
535 $search = get_query_var('s');
538 $t_sep = '%WP_TITILE_SEP%'; // Temporary separator, for accurate flipping, if necessary
540 // If there is a post
541 if ( is_single() || ( is_home() && !is_front_page() ) || ( is_page() && !is_front_page() ) ) {
542 $title = single_post_title( '', false );
545 // If there's a category or tag
546 if ( is_category() || is_tag() ) {
547 $title = single_term_title( '', false );
550 // If there's a taxonomy
552 $term = get_queried_object();
553 $tax = get_taxonomy( $term->taxonomy );
554 $title = single_term_title( $tax->labels->name . $t_sep, false );
557 // If there's an author
559 $author = get_queried_object();
560 $title = $author->display_name;
563 // If there's a post type archive
564 if ( is_post_type_archive() )
565 $title = post_type_archive_title( '', false );
567 // If there's a month
568 if ( is_archive() && !empty($m) ) {
569 $my_year = substr($m, 0, 4);
570 $my_month = $wp_locale->get_month(substr($m, 4, 2));
571 $my_day = intval(substr($m, 6, 2));
572 $title = $my_year . ( $my_month ? $t_sep . $my_month : '' ) . ( $my_day ? $t_sep . $my_day : '' );
576 if ( is_archive() && !empty($year) ) {
578 if ( !empty($monthnum) )
579 $title .= $t_sep . $wp_locale->get_month($monthnum);
581 $title .= $t_sep . zeroise($day, 2);
586 /* translators: 1: separator, 2: search phrase */
587 $title = sprintf(__('Search Results %1$s %2$s'), $t_sep, strip_tags($search));
590 // If it's a 404 page
592 $title = __('Page not found');
596 if ( !empty($title) )
599 // Determines position of the separator and direction of the breadcrumb
600 if ( 'right' == $seplocation ) { // sep on right, so reverse the order
601 $title_array = explode( $t_sep, $title );
602 $title_array = array_reverse( $title_array );
603 $title = implode( " $sep ", $title_array ) . $prefix;
605 $title_array = explode( $t_sep, $title );
606 $title = $prefix . implode( " $sep ", $title_array );
609 $title = apply_filters('wp_title', $title, $sep, $seplocation);
620 * Display or retrieve page title for post.
622 * This is optimized for single.php template file for displaying the post title.
624 * It does not support placing the separator after the title, but by leaving the
625 * prefix parameter empty, you can set the title separator manually. The prefix
626 * does not automatically place a space between the prefix, so if there should
627 * be a space, the parameter value will need to have it at the end.
631 * @param string $prefix Optional. What to display before the title.
632 * @param bool $display Optional, default is true. Whether to display or retrieve title.
633 * @return string|null Title when retrieving, null when displaying or failure.
635 function single_post_title($prefix = '', $display = true) {
636 $_post = get_queried_object();
638 if ( !isset($_post->post_title) )
641 $title = apply_filters('single_post_title', $_post->post_title, $_post);
643 echo $prefix . $title;
649 * Display or retrieve title for a post type archive.
651 * This is optimized for archive.php and archive-{$post_type}.php template files
652 * for displaying the title of the post type.
656 * @param string $prefix Optional. What to display before the title.
657 * @param bool $display Optional, default is true. Whether to display or retrieve title.
658 * @return string|null Title when retrieving, null when displaying or failure.
660 function post_type_archive_title( $prefix = '', $display = true ) {
661 if ( ! is_post_type_archive() )
664 $post_type_obj = get_queried_object();
665 $title = apply_filters('post_type_archive_title', $post_type_obj->labels->name );
668 echo $prefix . $title;
674 * Display or retrieve page title for category archive.
676 * This is useful for category template file or files, because it is optimized
677 * for category page title and with less overhead than {@link wp_title()}.
679 * It does not support placing the separator after the title, but by leaving the
680 * prefix parameter empty, you can set the title separator manually. The prefix
681 * does not automatically place a space between the prefix, so if there should
682 * be a space, the parameter value will need to have it at the end.
686 * @param string $prefix Optional. What to display before the title.
687 * @param bool $display Optional, default is true. Whether to display or retrieve title.
688 * @return string|null Title when retrieving, null when displaying or failure.
690 function single_cat_title( $prefix = '', $display = true ) {
691 return single_term_title( $prefix, $display );
695 * Display or retrieve page title for tag post archive.
697 * Useful for tag template files for displaying the tag page title. It has less
698 * overhead than {@link wp_title()}, because of its limited implementation.
700 * It does not support placing the separator after the title, but by leaving the
701 * prefix parameter empty, you can set the title separator manually. The prefix
702 * does not automatically place a space between the prefix, so if there should
703 * be a space, the parameter value will need to have it at the end.
707 * @param string $prefix Optional. What to display before the title.
708 * @param bool $display Optional, default is true. Whether to display or retrieve title.
709 * @return string|null Title when retrieving, null when displaying or failure.
711 function single_tag_title( $prefix = '', $display = true ) {
712 return single_term_title( $prefix, $display );
716 * Display or retrieve page title for taxonomy term archive.
718 * Useful for taxonomy term template files for displaying the taxonomy term page title.
719 * It has less overhead than {@link wp_title()}, because of its limited implementation.
721 * It does not support placing the separator after the title, but by leaving the
722 * prefix parameter empty, you can set the title separator manually. The prefix
723 * does not automatically place a space between the prefix, so if there should
724 * be a space, the parameter value will need to have it at the end.
728 * @param string $prefix Optional. What to display before the title.
729 * @param bool $display Optional, default is true. Whether to display or retrieve title.
730 * @return string|null Title when retrieving, null when displaying or failure.
732 function single_term_title( $prefix = '', $display = true ) {
733 $term = get_queried_object();
739 $term_name = apply_filters( 'single_cat_title', $term->name );
741 $term_name = apply_filters( 'single_tag_title', $term->name );
743 $term_name = apply_filters( 'single_term_title', $term->name );
747 if ( empty( $term_name ) )
751 echo $prefix . $term_name;
757 * Display or retrieve page title for post archive based on date.
759 * Useful for when the template only needs to display the month and year, if
760 * either are available. Optimized for just this purpose, so if it is all that
761 * is needed, should be better than {@link wp_title()}.
763 * It does not support placing the separator after the title, but by leaving the
764 * prefix parameter empty, you can set the title separator manually. The prefix
765 * does not automatically place a space between the prefix, so if there should
766 * be a space, the parameter value will need to have it at the end.
770 * @param string $prefix Optional. What to display before the title.
771 * @param bool $display Optional, default is true. Whether to display or retrieve title.
772 * @return string|null Title when retrieving, null when displaying or failure.
774 function single_month_title($prefix = '', $display = true ) {
777 $m = get_query_var('m');
778 $year = get_query_var('year');
779 $monthnum = get_query_var('monthnum');
781 if ( !empty($monthnum) && !empty($year) ) {
783 $my_month = $wp_locale->get_month($monthnum);
784 } elseif ( !empty($m) ) {
785 $my_year = substr($m, 0, 4);
786 $my_month = $wp_locale->get_month(substr($m, 4, 2));
789 if ( empty($my_month) )
792 $result = $prefix . $my_month . $prefix . $my_year;
800 * Retrieve archive link content based on predefined or custom code.
802 * The format can be one of four styles. The 'link' for head element, 'option'
803 * for use in the select element, 'html' for use in list (either ol or ul HTML
804 * elements). Custom content is also supported using the before and after
807 * The 'link' format uses the link HTML element with the <em>archives</em>
808 * relationship. The before and after parameters are not used. The text
809 * parameter is used to describe the link.
811 * The 'option' format uses the option HTML element for use in select element.
812 * The value is the url parameter and the before and after parameters are used
813 * between the text description.
815 * The 'html' format, which is the default, uses the li HTML element for use in
816 * the list HTML elements. The before parameter is before the link and the after
817 * parameter is after the closing link.
819 * The custom format uses the before parameter before the link ('a' HTML
820 * element) and the after parameter after the closing link tag. If the above
821 * three values for the format are not used, then custom format is assumed.
825 * @param string $url URL to archive.
826 * @param string $text Archive text description.
827 * @param string $format Optional, default is 'html'. Can be 'link', 'option', 'html', or custom.
828 * @param string $before Optional.
829 * @param string $after Optional.
830 * @return string HTML link content for archive.
832 function get_archives_link($url, $text, $format = 'html', $before = '', $after = '') {
833 $text = wptexturize($text);
834 $title_text = esc_attr($text);
835 $url = esc_url($url);
837 if ('link' == $format)
838 $link_html = "\t<link rel='archives' title='$title_text' href='$url' />\n";
839 elseif ('option' == $format)
840 $link_html = "\t<option value='$url'>$before $text $after</option>\n";
841 elseif ('html' == $format)
842 $link_html = "\t<li>$before<a href='$url' title='$title_text'>$text</a>$after</li>\n";
844 $link_html = "\t$before<a href='$url' title='$title_text'>$text</a>$after\n";
846 $link_html = apply_filters( 'get_archives_link', $link_html );
852 * Display archive links based on type and format.
854 * The 'type' argument offers a few choices and by default will display monthly
855 * archive links. The other options for values are 'daily', 'weekly', 'monthly',
856 * 'yearly', 'postbypost' or 'alpha'. Both 'postbypost' and 'alpha' display the
857 * same archive link list, the difference between the two is that 'alpha'
858 * will order by post title and 'postbypost' will order by post date.
860 * The date archives will logically display dates with links to the archive post
861 * page. The 'postbypost' and 'alpha' values for 'type' argument will display
864 * The 'limit' argument will only display a limited amount of links, specified
865 * by the 'limit' integer value. By default, there is no limit. The
866 * 'show_post_count' argument will show how many posts are within the archive.
867 * By default, the 'show_post_count' argument is set to false.
869 * For the 'format', 'before', and 'after' arguments, see {@link
870 * get_archives_link()}. The values of these arguments have to do with that
875 * @param string|array $args Optional. Override defaults.
877 function wp_get_archives($args = '') {
878 global $wpdb, $wp_locale;
881 'type' => 'monthly', 'limit' => '',
882 'format' => 'html', 'before' => '',
883 'after' => '', 'show_post_count' => false,
887 $r = wp_parse_args( $args, $defaults );
888 extract( $r, EXTR_SKIP );
893 if ( '' != $limit ) {
894 $limit = absint($limit);
895 $limit = ' LIMIT '.$limit;
898 // this is what will separate dates on weekly archive links
899 $archive_week_separator = '–';
901 // over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride
902 $archive_date_format_over_ride = 0;
904 // options for daily archive (only if you over-ride the general date format)
905 $archive_day_date_format = 'Y/m/d';
907 // options for weekly archive (only if you over-ride the general date format)
908 $archive_week_start_date_format = 'Y/m/d';
909 $archive_week_end_date_format = 'Y/m/d';
911 if ( !$archive_date_format_over_ride ) {
912 $archive_day_date_format = get_option('date_format');
913 $archive_week_start_date_format = get_option('date_format');
914 $archive_week_end_date_format = get_option('date_format');
918 $where = apply_filters( 'getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r );
919 $join = apply_filters( 'getarchives_join', '', $r );
923 if ( 'monthly' == $type ) {
924 $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC $limit";
926 $cache = wp_cache_get( 'wp_get_archives' , 'general');
927 if ( !isset( $cache[ $key ] ) ) {
928 $arcresults = $wpdb->get_results($query);
929 $cache[ $key ] = $arcresults;
930 wp_cache_set( 'wp_get_archives', $cache, 'general' );
932 $arcresults = $cache[ $key ];
935 $afterafter = $after;
936 foreach ( (array) $arcresults as $arcresult ) {
937 $url = get_month_link( $arcresult->year, $arcresult->month );
938 /* translators: 1: month name, 2: 4-digit year */
939 $text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($arcresult->month), $arcresult->year);
940 if ( $show_post_count )
941 $after = ' ('.$arcresult->posts.')' . $afterafter;
942 $output .= get_archives_link($url, $text, $format, $before, $after);
945 } elseif ('yearly' == $type) {
946 $query = "SELECT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date) ORDER BY post_date DESC $limit";
948 $cache = wp_cache_get( 'wp_get_archives' , 'general');
949 if ( !isset( $cache[ $key ] ) ) {
950 $arcresults = $wpdb->get_results($query);
951 $cache[ $key ] = $arcresults;
952 wp_cache_set( 'wp_get_archives', $cache, 'general' );
954 $arcresults = $cache[ $key ];
957 $afterafter = $after;
958 foreach ( (array) $arcresults as $arcresult) {
959 $url = get_year_link($arcresult->year);
960 $text = sprintf('%d', $arcresult->year);
961 if ($show_post_count)
962 $after = ' ('.$arcresult->posts.')' . $afterafter;
963 $output .= get_archives_link($url, $text, $format, $before, $after);
966 } elseif ( 'daily' == $type ) {
967 $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date DESC $limit";
969 $cache = wp_cache_get( 'wp_get_archives' , 'general');
970 if ( !isset( $cache[ $key ] ) ) {
971 $arcresults = $wpdb->get_results($query);
972 $cache[ $key ] = $arcresults;
973 wp_cache_set( 'wp_get_archives', $cache, 'general' );
975 $arcresults = $cache[ $key ];
978 $afterafter = $after;
979 foreach ( (array) $arcresults as $arcresult ) {
980 $url = get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth);
981 $date = sprintf('%1$d-%2$02d-%3$02d 00:00:00', $arcresult->year, $arcresult->month, $arcresult->dayofmonth);
982 $text = mysql2date($archive_day_date_format, $date);
983 if ($show_post_count)
984 $after = ' ('.$arcresult->posts.')'.$afterafter;
985 $output .= get_archives_link($url, $text, $format, $before, $after);
988 } elseif ( 'weekly' == $type ) {
989 $week = _wp_mysql_week( '`post_date`' );
990 $query = "SELECT DISTINCT $week AS `week`, YEAR( `post_date` ) AS `yr`, DATE_FORMAT( `post_date`, '%Y-%m-%d' ) AS `yyyymmdd`, count( `ID` ) AS `posts` FROM `$wpdb->posts` $join $where GROUP BY $week, YEAR( `post_date` ) ORDER BY `post_date` DESC $limit";
992 $cache = wp_cache_get( 'wp_get_archives' , 'general');
993 if ( !isset( $cache[ $key ] ) ) {
994 $arcresults = $wpdb->get_results($query);
995 $cache[ $key ] = $arcresults;
996 wp_cache_set( 'wp_get_archives', $cache, 'general' );
998 $arcresults = $cache[ $key ];
1001 $afterafter = $after;
1002 if ( $arcresults ) {
1003 foreach ( (array) $arcresults as $arcresult ) {
1004 if ( $arcresult->week != $arc_w_last ) {
1005 $arc_year = $arcresult->yr;
1006 $arc_w_last = $arcresult->week;
1007 $arc_week = get_weekstartend($arcresult->yyyymmdd, get_option('start_of_week'));
1008 $arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']);
1009 $arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']);
1010 $url = sprintf('%1$s/%2$s%3$sm%4$s%5$s%6$sw%7$s%8$d', home_url(), '', '?', '=', $arc_year, '&', '=', $arcresult->week);
1011 $text = $arc_week_start . $archive_week_separator . $arc_week_end;
1012 if ($show_post_count)
1013 $after = ' ('.$arcresult->posts.')'.$afterafter;
1014 $output .= get_archives_link($url, $text, $format, $before, $after);
1018 } elseif ( ( 'postbypost' == $type ) || ('alpha' == $type) ) {
1019 $orderby = ('alpha' == $type) ? 'post_title ASC ' : 'post_date DESC ';
1020 $query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit";
1022 $cache = wp_cache_get( 'wp_get_archives' , 'general');
1023 if ( !isset( $cache[ $key ] ) ) {
1024 $arcresults = $wpdb->get_results($query);
1025 $cache[ $key ] = $arcresults;
1026 wp_cache_set( 'wp_get_archives', $cache, 'general' );
1028 $arcresults = $cache[ $key ];
1030 if ( $arcresults ) {
1031 foreach ( (array) $arcresults as $arcresult ) {
1032 if ( $arcresult->post_date != '0000-00-00 00:00:00' ) {
1033 $url = get_permalink( $arcresult );
1034 if ( $arcresult->post_title )
1035 $text = strip_tags( apply_filters( 'the_title', $arcresult->post_title, $arcresult->ID ) );
1037 $text = $arcresult->ID;
1038 $output .= get_archives_link($url, $text, $format, $before, $after);
1050 * Get number of days since the start of the week.
1053 * @usedby get_calendar()
1055 * @param int $num Number of day.
1056 * @return int Days since the start of the week.
1058 function calendar_week_mod($num) {
1060 return ($num - $base*floor($num/$base));
1064 * Display calendar with days that have posts as links.
1066 * The calendar is cached, which will be retrieved, if it exists. If there are
1067 * no posts for the month, then it will not be displayed.
1071 * @param bool $initial Optional, default is true. Use initial calendar names.
1072 * @param bool $echo Optional, default is true. Set to false for return.
1074 function get_calendar($initial = true, $echo = true) {
1075 global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
1078 $key = md5( $m . $monthnum . $year );
1079 if ( $cache = wp_cache_get( 'get_calendar', 'calendar' ) ) {
1080 if ( is_array($cache) && isset( $cache[ $key ] ) ) {
1082 echo apply_filters( 'get_calendar', $cache[$key] );
1085 return apply_filters( 'get_calendar', $cache[$key] );
1090 if ( !is_array($cache) )
1093 // Quick check. If we have no posts at all, abort!
1095 $gotsome = $wpdb->get_var("SELECT 1 as test FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1");
1097 $cache[ $key ] = '';
1098 wp_cache_set( 'get_calendar', $cache, 'calendar' );
1103 if ( isset($_GET['w']) )
1104 $w = ''.intval($_GET['w']);
1106 // week_begins = 0 stands for Sunday
1107 $week_begins = intval(get_option('start_of_week'));
1109 // Let's figure out when we are
1110 if ( !empty($monthnum) && !empty($year) ) {
1111 $thismonth = ''.zeroise(intval($monthnum), 2);
1112 $thisyear = ''.intval($year);
1113 } elseif ( !empty($w) ) {
1114 // We need to get the month from MySQL
1115 $thisyear = ''.intval(substr($m, 0, 4));
1116 $d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's
1117 $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')");
1118 } elseif ( !empty($m) ) {
1119 $thisyear = ''.intval(substr($m, 0, 4));
1120 if ( strlen($m) < 6 )
1123 $thismonth = ''.zeroise(intval(substr($m, 4, 2)), 2);
1125 $thisyear = gmdate('Y', current_time('timestamp'));
1126 $thismonth = gmdate('m', current_time('timestamp'));
1129 $unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear);
1130 $last_day = date('t', $unixmonth);
1132 // Get the next and previous month and year with at least one post
1133 $previous = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
1135 WHERE post_date < '$thisyear-$thismonth-01'
1136 AND post_type = 'post' AND post_status = 'publish'
1137 ORDER BY post_date DESC
1139 $next = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
1141 WHERE post_date > '$thisyear-$thismonth-{$last_day} 23:59:59'
1142 AND post_type = 'post' AND post_status = 'publish'
1143 ORDER BY post_date ASC
1146 /* translators: Calendar caption: 1: month name, 2: 4-digit year */
1147 $calendar_caption = _x('%1$s %2$s', 'calendar caption');
1148 $calendar_output = '<table id="wp-calendar">
1149 <caption>' . sprintf($calendar_caption, $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '</caption>
1155 for ( $wdcount=0; $wdcount<=6; $wdcount++ ) {
1156 $myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7);
1159 foreach ( $myweek as $wd ) {
1160 $day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
1161 $wd = esc_attr($wd);
1162 $calendar_output .= "\n\t\t<th scope=\"col\" title=\"$wd\">$day_name</th>";
1165 $calendar_output .= '
1173 $calendar_output .= "\n\t\t".'<td colspan="3" id="prev"><a href="' . get_month_link($previous->year, $previous->month) . '" title="' . esc_attr( sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($previous->month), date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year)))) . '">« ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . '</a></td>';
1175 $calendar_output .= "\n\t\t".'<td colspan="3" id="prev" class="pad"> </td>';
1178 $calendar_output .= "\n\t\t".'<td class="pad"> </td>';
1181 $calendar_output .= "\n\t\t".'<td colspan="3" id="next"><a href="' . get_month_link($next->year, $next->month) . '" title="' . esc_attr( sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($next->month), date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year))) ) . '">' . $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)) . ' »</a></td>';
1183 $calendar_output .= "\n\t\t".'<td colspan="3" id="next" class="pad"> </td>';
1186 $calendar_output .= '
1193 // Get days with posts
1194 $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
1195 FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00'
1196 AND post_type = 'post' AND post_status = 'publish'
1197 AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'", ARRAY_N);
1198 if ( $dayswithposts ) {
1199 foreach ( (array) $dayswithposts as $daywith ) {
1200 $daywithpost[] = $daywith[0];
1203 $daywithpost = array();
1206 if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'camino') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false)
1207 $ak_title_separator = "\n";
1209 $ak_title_separator = ', ';
1211 $ak_titles_for_day = array();
1212 $ak_post_titles = $wpdb->get_results("SELECT ID, post_title, DAYOFMONTH(post_date) as dom "
1213 ."FROM $wpdb->posts "
1214 ."WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' "
1215 ."AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59' "
1216 ."AND post_type = 'post' AND post_status = 'publish'"
1218 if ( $ak_post_titles ) {
1219 foreach ( (array) $ak_post_titles as $ak_post_title ) {
1221 $post_title = esc_attr( apply_filters( 'the_title', $ak_post_title->post_title, $ak_post_title->ID ) );
1223 if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) )
1224 $ak_titles_for_day['day_'.$ak_post_title->dom] = '';
1225 if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one
1226 $ak_titles_for_day["$ak_post_title->dom"] = $post_title;
1228 $ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . $post_title;
1232 // See how much we should pad in the beginning
1233 $pad = calendar_week_mod(date('w', $unixmonth)-$week_begins);
1235 $calendar_output .= "\n\t\t".'<td colspan="'. esc_attr($pad) .'" class="pad"> </td>';
1237 $daysinmonth = intval(date('t', $unixmonth));
1238 for ( $day = 1; $day <= $daysinmonth; ++$day ) {
1239 if ( isset($newrow) && $newrow )
1240 $calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
1243 if ( $day == gmdate('j', current_time('timestamp')) && $thismonth == gmdate('m', current_time('timestamp')) && $thisyear == gmdate('Y', current_time('timestamp')) )
1244 $calendar_output .= '<td id="today">';
1246 $calendar_output .= '<td>';
1248 if ( in_array($day, $daywithpost) ) // any posts today?
1249 $calendar_output .= '<a href="' . get_day_link( $thisyear, $thismonth, $day ) . '" title="' . esc_attr( $ak_titles_for_day[ $day ] ) . "\">$day</a>";
1251 $calendar_output .= $day;
1252 $calendar_output .= '</td>';
1254 if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) )
1258 $pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins);
1259 if ( $pad != 0 && $pad != 7 )
1260 $calendar_output .= "\n\t\t".'<td class="pad" colspan="'. esc_attr($pad) .'"> </td>';
1262 $calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>";
1264 $cache[ $key ] = $calendar_output;
1265 wp_cache_set( 'get_calendar', $cache, 'calendar' );
1268 echo apply_filters( 'get_calendar', $calendar_output );
1270 return apply_filters( 'get_calendar', $calendar_output );
1275 * Purge the cached results of get_calendar.
1280 function delete_get_calendar_cache() {
1281 wp_cache_delete( 'get_calendar', 'calendar' );
1283 add_action( 'save_post', 'delete_get_calendar_cache' );
1284 add_action( 'delete_post', 'delete_get_calendar_cache' );
1285 add_action( 'update_option_start_of_week', 'delete_get_calendar_cache' );
1286 add_action( 'update_option_gmt_offset', 'delete_get_calendar_cache' );
1289 * Display all of the allowed tags in HTML format with attributes.
1291 * This is useful for displaying in the comment area, which elements and
1292 * attributes are supported. As well as any plugins which want to display it.
1295 * @uses $allowedtags
1297 * @return string HTML allowed tags entity encoded.
1299 function allowed_tags() {
1300 global $allowedtags;
1302 foreach ( (array) $allowedtags as $tag => $attributes ) {
1303 $allowed .= '<'.$tag;
1304 if ( 0 < count($attributes) ) {
1305 foreach ( $attributes as $attribute => $limits ) {
1306 $allowed .= ' '.$attribute.'=""';
1311 return htmlentities($allowed);
1314 /***** Date/Time tags *****/
1317 * Outputs the date in iso8601 format for xml files.
1321 function the_date_xml() {
1323 echo mysql2date('Y-m-d', $post->post_date, false);
1327 * Display or Retrieve the date the current $post was written (once per date)
1329 * Will only output the date if the current post's date is different from the
1330 * previous one output.
1332 * i.e. Only one date listing will show per day worth of posts shown in the loop, even if the
1333 * function is called several times for each post.
1335 * HTML output can be filtered with 'the_date'.
1336 * Date string output can be filtered with 'get_the_date'.
1339 * @uses get_the_date()
1340 * @param string $d Optional. PHP date format defaults to the date_format option if not specified.
1341 * @param string $before Optional. Output before the date.
1342 * @param string $after Optional. Output after the date.
1343 * @param bool $echo Optional, default is display. Whether to echo the date or return it.
1344 * @return string|null Null if displaying, string if retrieving.
1346 function the_date( $d = '', $before = '', $after = '', $echo = true ) {
1347 global $currentday, $previousday;
1349 if ( $currentday != $previousday ) {
1350 $the_date .= $before;
1351 $the_date .= get_the_date( $d );
1352 $the_date .= $after;
1353 $previousday = $currentday;
1355 $the_date = apply_filters('the_date', $the_date, $d, $before, $after);
1367 * Retrieve the date the current $post was written.
1369 * Unlike the_date() this function will always return the date.
1370 * Modify output with 'get_the_date' filter.
1374 * @param string $d Optional. PHP date format defaults to the date_format option if not specified.
1375 * @return string|null Null if displaying, string if retrieving.
1377 function get_the_date( $d = '' ) {
1382 $the_date .= mysql2date(get_option('date_format'), $post->post_date);
1384 $the_date .= mysql2date($d, $post->post_date);
1386 return apply_filters('get_the_date', $the_date, $d);
1390 * Display the date on which the post was last modified.
1394 * @param string $d Optional. PHP date format defaults to the date_format option if not specified.
1395 * @param string $before Optional. Output before the date.
1396 * @param string $after Optional. Output after the date.
1397 * @param bool $echo Optional, default is display. Whether to echo the date or return it.
1398 * @return string|null Null if displaying, string if retrieving.
1400 function the_modified_date($d = '', $before='', $after='', $echo = true) {
1402 $the_modified_date = $before . get_the_modified_date($d) . $after;
1403 $the_modified_date = apply_filters('the_modified_date', $the_modified_date, $d, $before, $after);
1406 echo $the_modified_date;
1408 return $the_modified_date;
1413 * Retrieve the date on which the post was last modified.
1417 * @param string $d Optional. PHP date format. Defaults to the "date_format" option
1420 function get_the_modified_date($d = '') {
1422 $the_time = get_post_modified_time(get_option('date_format'), null, null, true);
1424 $the_time = get_post_modified_time($d, null, null, true);
1425 return apply_filters('get_the_modified_date', $the_time, $d);
1429 * Display the time at which the post was written.
1433 * @param string $d Either 'G', 'U', or php date format.
1435 function the_time( $d = '' ) {
1436 echo apply_filters('the_time', get_the_time( $d ), $d);
1440 * Retrieve the time at which the post was written.
1444 * @param string $d Optional Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
1445 * @param int|object $post Optional post ID or object. Default is global $post object.
1448 function get_the_time( $d = '', $post = null ) {
1449 $post = get_post($post);
1452 $the_time = get_post_time(get_option('time_format'), false, $post, true);
1454 $the_time = get_post_time($d, false, $post, true);
1455 return apply_filters('get_the_time', $the_time, $d, $post);
1459 * Retrieve the time at which the post was written.
1463 * @param string $d Optional Either 'G', 'U', or php date format.
1464 * @param bool $gmt Optional, default is false. Whether to return the gmt time.
1465 * @param int|object $post Optional post ID or object. Default is global $post object.
1466 * @param bool $translate Whether to translate the time string
1469 function get_post_time( $d = 'U', $gmt = false, $post = null, $translate = false ) { // returns timestamp
1470 $post = get_post($post);
1473 $time = $post->post_date_gmt;
1475 $time = $post->post_date;
1477 $time = mysql2date($d, $time, $translate);
1478 return apply_filters('get_post_time', $time, $d, $gmt);
1482 * Display the time at which the post was last modified.
1486 * @param string $d Optional Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
1488 function the_modified_time($d = '') {
1489 echo apply_filters('the_modified_time', get_the_modified_time($d), $d);
1493 * Retrieve the time at which the post was last modified.
1497 * @param string $d Optional Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
1500 function get_the_modified_time($d = '') {
1502 $the_time = get_post_modified_time(get_option('time_format'), null, null, true);
1504 $the_time = get_post_modified_time($d, null, null, true);
1505 return apply_filters('get_the_modified_time', $the_time, $d);
1509 * Retrieve the time at which the post was last modified.
1513 * @param string $d Optional, default is 'U'. Either 'G', 'U', or php date format.
1514 * @param bool $gmt Optional, default is false. Whether to return the gmt time.
1515 * @param int|object $post Optional, default is global post object. A post_id or post object
1516 * @param bool $translate Optional, default is false. Whether to translate the result
1517 * @return string Returns timestamp
1519 function get_post_modified_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
1520 $post = get_post($post);
1523 $time = $post->post_modified_gmt;
1525 $time = $post->post_modified;
1526 $time = mysql2date($d, $time, $translate);
1528 return apply_filters('get_post_modified_time', $time, $d, $gmt);
1532 * Display the weekday on which the post was written.
1538 function the_weekday() {
1539 global $wp_locale, $post;
1540 $the_weekday = $wp_locale->get_weekday(mysql2date('w', $post->post_date, false));
1541 $the_weekday = apply_filters('the_weekday', $the_weekday);
1546 * Display the weekday on which the post was written.
1548 * Will only output the weekday if the current post's weekday is different from
1549 * the previous one output.
1553 * @param string $before Optional Output before the date.
1554 * @param string $after Optional Output after the date.
1556 function the_weekday_date($before='',$after='') {
1557 global $wp_locale, $post, $day, $previousweekday;
1558 $the_weekday_date = '';
1559 if ( $currentday != $previousweekday ) {
1560 $the_weekday_date .= $before;
1561 $the_weekday_date .= $wp_locale->get_weekday(mysql2date('w', $post->post_date, false));
1562 $the_weekday_date .= $after;
1563 $previousweekday = $currentday;
1565 $the_weekday_date = apply_filters('the_weekday_date', $the_weekday_date, $before, $after);
1566 echo $the_weekday_date;
1570 * Fire the wp_head action
1573 * @uses do_action() Calls 'wp_head' hook.
1575 function wp_head() {
1576 do_action('wp_head');
1580 * Fire the wp_footer action
1583 * @uses do_action() Calls 'wp_footer' hook.
1585 function wp_footer() {
1586 do_action('wp_footer');
1590 * Display the links to the general feeds.
1594 * @param array $args Optional arguments.
1596 function feed_links( $args = array() ) {
1597 if ( !current_theme_supports('automatic-feed-links') )
1601 /* translators: Separator between blog name and feed type in feed links */
1602 'separator' => _x('»', 'feed link'),
1603 /* translators: 1: blog title, 2: separator (raquo) */
1604 'feedtitle' => __('%1$s %2$s Feed'),
1605 /* translators: %s: blog title, 2: separator (raquo) */
1606 'comstitle' => __('%1$s %2$s Comments Feed'),
1609 $args = wp_parse_args( $args, $defaults );
1611 echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr(sprintf( $args['feedtitle'], get_bloginfo('name'), $args['separator'] )) . '" href="' . get_feed_link() . "\" />\n";
1612 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";
1616 * Display the links to the extra feeds such as category feeds.
1620 * @param array $args Optional arguments.
1622 function feed_links_extra( $args = array() ) {
1624 /* translators: Separator between blog name and feed type in feed links */
1625 'separator' => _x('»', 'feed link'),
1626 /* translators: 1: blog name, 2: separator(raquo), 3: post title */
1627 'singletitle' => __('%1$s %2$s %3$s Comments Feed'),
1628 /* translators: 1: blog name, 2: separator(raquo), 3: category name */
1629 'cattitle' => __('%1$s %2$s %3$s Category Feed'),
1630 /* translators: 1: blog name, 2: separator(raquo), 3: tag name */
1631 'tagtitle' => __('%1$s %2$s %3$s Tag Feed'),
1632 /* translators: 1: blog name, 2: separator(raquo), 3: author name */
1633 'authortitle' => __('%1$s %2$s Posts by %3$s Feed'),
1634 /* translators: 1: blog name, 2: separator(raquo), 3: search phrase */
1635 'searchtitle' => __('%1$s %2$s Search Results for “%3$s” Feed'),
1638 $args = wp_parse_args( $args, $defaults );
1640 if ( is_single() || is_page() ) {
1642 $post = &get_post( $id );
1644 if ( comments_open() || pings_open() || $post->comment_count > 0 ) {
1645 $title = sprintf( $args['singletitle'], get_bloginfo('name'), $args['separator'], esc_html( get_the_title() ) );
1646 $href = get_post_comments_feed_link( $post->ID );
1648 } elseif ( is_category() ) {
1649 $term = get_queried_object();
1651 $title = sprintf( $args['cattitle'], get_bloginfo('name'), $args['separator'], $term->name );
1652 $href = get_category_feed_link( $term->term_id );
1653 } elseif ( is_tag() ) {
1654 $term = get_queried_object();
1656 $title = sprintf( $args['tagtitle'], get_bloginfo('name'), $args['separator'], $term->name );
1657 $href = get_tag_feed_link( $term->term_id );
1658 } elseif ( is_author() ) {
1659 $author_id = intval( get_query_var('author') );
1661 $title = sprintf( $args['authortitle'], get_bloginfo('name'), $args['separator'], get_the_author_meta( 'display_name', $author_id ) );
1662 $href = get_author_feed_link( $author_id );
1663 } elseif ( is_search() ) {
1664 $title = sprintf( $args['searchtitle'], get_bloginfo('name'), $args['separator'], get_search_query( false ) );
1665 $href = get_search_feed_link();
1668 if ( isset($title) && isset($href) )
1669 echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( $title ) . '" href="' . esc_url( $href ) . '" />' . "\n";
1673 * Display the link to the Really Simple Discovery service endpoint.
1675 * @link http://archipelago.phrasewise.com/rsd
1678 function rsd_link() {
1679 echo '<link rel="EditURI" type="application/rsd+xml" title="RSD" href="' . get_bloginfo('wpurl') . "/xmlrpc.php?rsd\" />\n";
1683 * Display the link to the Windows Live Writer manifest file.
1685 * @link http://msdn.microsoft.com/en-us/library/bb463265.aspx
1688 function wlwmanifest_link() {
1689 echo '<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="'
1690 . get_bloginfo('wpurl') . '/wp-includes/wlwmanifest.xml" /> ' . "\n";
1694 * Display a noindex meta tag if required by the blog configuration.
1696 * If a blog is marked as not being public then the noindex meta tag will be
1697 * output to tell web robots not to index the page content. Add this to the wp_head action.
1698 * Typical usage is as a wp_head callback. add_action( 'wp_head', 'noindex' );
1704 function noindex() {
1705 // If the blog is not public, tell robots to go away.
1706 if ( '0' == get_option('blog_public') )
1711 * Display a noindex meta tag.
1713 * Outputs a noindex meta tag that tells web robots not to index the page content.
1714 * Typical usage is as a wp_head callback. add_action( 'wp_head', 'wp_no_robots' );
1718 function wp_no_robots() {
1719 echo "<meta name='robots' content='noindex,nofollow' />\n";
1723 * Determine if TinyMCE is available.
1725 * Checks to see if the user has deleted the tinymce files to slim down there WordPress install.
1729 * @return bool Whether TinyMCE exists.
1731 function rich_edit_exists() {
1732 global $wp_rich_edit_exists;
1733 if ( !isset($wp_rich_edit_exists) )
1734 $wp_rich_edit_exists = file_exists(ABSPATH . WPINC . '/js/tinymce/tiny_mce.js');
1735 return $wp_rich_edit_exists;
1739 * Whether the user should have a WYSIWIG editor.
1741 * Checks that the user requires a WYSIWIG editor and that the editor is
1742 * supported in the users browser.
1748 function user_can_richedit() {
1749 global $wp_rich_edit, $is_gecko, $is_opera, $is_safari, $is_chrome, $is_IE;
1751 if ( !isset($wp_rich_edit) ) {
1752 $wp_rich_edit = false;
1754 if ( get_user_option( 'rich_editing' ) == 'true' || ! is_user_logged_in() ) { // default to 'true' for logged out users
1756 $wp_rich_edit = ! wp_is_mobile() || ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval( $match[1] ) >= 534 );
1757 } elseif ( $is_gecko || $is_opera || $is_chrome || $is_IE ) {
1758 $wp_rich_edit = true;
1763 return apply_filters('user_can_richedit', $wp_rich_edit);
1767 * Find out which editor should be displayed by default.
1769 * Works out which of the two editors to display as the current editor for a
1774 * @return string Either 'tinymce', or 'html', or 'test'
1776 function wp_default_editor() {
1777 $r = user_can_richedit() ? 'tinymce' : 'html'; // defaults
1778 if ( $user = wp_get_current_user() ) { // look for cookie
1779 $ed = get_user_setting('editor', 'tinymce');
1780 $r = ( in_array($ed, array('tinymce', 'html', 'test') ) ) ? $ed : $r;
1782 return apply_filters( 'wp_default_editor', $r ); // filter
1786 * Renders an editor.
1788 * Using this function is the proper way to output all needed components for both TinyMCE and Quicktags.
1789 * _WP_Editors should not be used directly. See http://core.trac.wordpress.org/ticket/17144.
1791 * NOTE: Once initialized the TinyMCE editor cannot be safely moved in the DOM. For that reason
1792 * running wp_editor() inside of a metabox is not a good idea unless only Quicktags is used.
1793 * On the post edit screen several actions can be used to include additional editors
1794 * containing TinyMCE: 'edit_page_form', 'edit_form_advanced' and 'dbx_post_sidebar'.
1795 * See http://core.trac.wordpress.org/ticket/19173 for more information.
1797 * @see wp-includes/class-wp-editor.php
1800 * @param string $content Initial content for the editor.
1801 * @param string $editor_id HTML ID attribute value for the textarea and TinyMCE. Can only be /[a-z]+/.
1802 * @param array $settings See _WP_Editors::editor().
1804 function wp_editor( $content, $editor_id, $settings = array() ) {
1805 if ( ! class_exists( '_WP_Editors' ) )
1806 require( ABSPATH . WPINC . '/class-wp-editor.php' );
1808 _WP_Editors::editor($content, $editor_id, $settings);
1812 * Retrieve the contents of the search WordPress query variable.
1814 * The search query string is passed through {@link esc_attr()}
1815 * to ensure that it is safe for placing in an html attribute.
1820 * @param bool $escaped Whether the result is escaped. Default true.
1821 * Only use when you are later escaping it. Do not use unescaped.
1824 function get_search_query( $escaped = true ) {
1825 $query = apply_filters( 'get_search_query', get_query_var( 's' ) );
1827 $query = esc_attr( $query );
1832 * Display the contents of the search query variable.
1834 * The search query string is passed through {@link esc_attr()}
1835 * to ensure that it is safe for placing in an html attribute.
1840 function the_search_query() {
1841 echo esc_attr( apply_filters( 'the_search_query', get_search_query( false ) ) );
1845 * Display the language attributes for the html tag.
1847 * Builds up a set of html attributes containing the text direction and language
1848 * information for the page.
1852 * @param string $doctype The type of html document (xhtml|html).
1854 function language_attributes($doctype = 'html') {
1855 $attributes = array();
1858 if ( function_exists( 'is_rtl' ) )
1859 $attributes[] = 'dir="' . ( is_rtl() ? 'rtl' : 'ltr' ) . '"';
1861 if ( $lang = get_bloginfo('language') ) {
1862 if ( get_option('html_type') == 'text/html' || $doctype == 'html' )
1863 $attributes[] = "lang=\"$lang\"";
1865 if ( get_option('html_type') != 'text/html' || $doctype == 'xhtml' )
1866 $attributes[] = "xml:lang=\"$lang\"";
1869 $output = implode(' ', $attributes);
1870 $output = apply_filters('language_attributes', $output);
1875 * Retrieve paginated link for archive post pages.
1877 * Technically, the function can be used to create paginated link list for any
1878 * area. The 'base' argument is used to reference the url, which will be used to
1879 * create the paginated links. The 'format' argument is then used for replacing
1880 * the page number. It is however, most likely and by default, to be used on the
1881 * archive post pages.
1883 * The 'type' argument controls format of the returned value. The default is
1884 * 'plain', which is just a string with the links separated by a newline
1885 * character. The other possible values are either 'array' or 'list'. The
1886 * 'array' value will return an array of the paginated link list to offer full
1887 * control of display. The 'list' value will place all of the paginated links in
1888 * an unordered HTML list.
1890 * The 'total' argument is the total amount of pages and is an integer. The
1891 * 'current' argument is the current page number and is also an integer.
1893 * An example of the 'base' argument is "http://example.com/all_posts.php%_%"
1894 * and the '%_%' is required. The '%_%' will be replaced by the contents of in
1895 * the 'format' argument. An example for the 'format' argument is "?page=%#%"
1896 * and the '%#%' is also required. The '%#%' will be replaced with the page
1899 * You can include the previous and next links in the list by setting the
1900 * 'prev_next' argument to true, which it is by default. You can set the
1901 * previous text, by using the 'prev_text' argument. You can set the next text
1902 * by setting the 'next_text' argument.
1904 * If the 'show_all' argument is set to true, then it will show all of the pages
1905 * instead of a short list of the pages near the current page. By default, the
1906 * 'show_all' is set to false and controlled by the 'end_size' and 'mid_size'
1907 * arguments. The 'end_size' argument is how many numbers on either the start
1908 * and the end list edges, by default is 1. The 'mid_size' argument is how many
1909 * numbers to either side of current page, but not including current page.
1911 * It is possible to add query vars to the link by using the 'add_args' argument
1912 * and see {@link add_query_arg()} for more information.
1916 * @param string|array $args Optional. Override defaults.
1917 * @return array|string String of page links or array of page links.
1919 function paginate_links( $args = '' ) {
1921 'base' => '%_%', // http://example.com/all_posts.php%_% : %_% is replaced by format (below)
1922 'format' => '?page=%#%', // ?page=%#% : %#% is replaced by the page number
1925 'show_all' => false,
1926 'prev_next' => true,
1927 'prev_text' => __('« Previous'),
1928 'next_text' => __('Next »'),
1932 'add_args' => false, // array of query args to add
1933 'add_fragment' => ''
1936 $args = wp_parse_args( $args, $defaults );
1937 extract($args, EXTR_SKIP);
1939 // Who knows what else people pass in $args
1940 $total = (int) $total;
1943 $current = (int) $current;
1944 $end_size = 0 < (int) $end_size ? (int) $end_size : 1; // Out of bounds? Make it the default.
1945 $mid_size = 0 <= (int) $mid_size ? (int) $mid_size : 2;
1946 $add_args = is_array($add_args) ? $add_args : false;
1948 $page_links = array();
1952 if ( $prev_next && $current && 1 < $current ) :
1953 $link = str_replace('%_%', 2 == $current ? '' : $format, $base);
1954 $link = str_replace('%#%', $current - 1, $link);
1956 $link = add_query_arg( $add_args, $link );
1957 $link .= $add_fragment;
1958 $page_links[] = '<a class="prev page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $prev_text . '</a>';
1960 for ( $n = 1; $n <= $total; $n++ ) :
1961 $n_display = number_format_i18n($n);
1962 if ( $n == $current ) :
1963 $page_links[] = "<span class='page-numbers current'>$n_display</span>";
1966 if ( $show_all || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) :
1967 $link = str_replace('%_%', 1 == $n ? '' : $format, $base);
1968 $link = str_replace('%#%', $n, $link);
1970 $link = add_query_arg( $add_args, $link );
1971 $link .= $add_fragment;
1972 $page_links[] = "<a class='page-numbers' href='" . esc_url( apply_filters( 'paginate_links', $link ) ) . "'>$n_display</a>";
1974 elseif ( $dots && !$show_all ) :
1975 $page_links[] = '<span class="page-numbers dots">' . __( '…' ) . '</span>';
1980 if ( $prev_next && $current && ( $current < $total || -1 == $total ) ) :
1981 $link = str_replace('%_%', $format, $base);
1982 $link = str_replace('%#%', $current + 1, $link);
1984 $link = add_query_arg( $add_args, $link );
1985 $link .= $add_fragment;
1986 $page_links[] = '<a class="next page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $next_text . '</a>';
1993 $r .= "<ul class='page-numbers'>\n\t<li>";
1994 $r .= join("</li>\n\t<li>", $page_links);
1995 $r .= "</li>\n</ul>\n";
1998 $r = join("\n", $page_links);
2005 * Registers an admin colour scheme css file.
2007 * Allows a plugin to register a new admin colour scheme. For example:
2009 * wp_admin_css_color('classic', __('Classic'), admin_url("css/colors-classic.css"),
2010 * array('#07273E', '#14568A', '#D54E21', '#2683AE'));
2015 * @param string $key The unique key for this theme.
2016 * @param string $name The name of the theme.
2017 * @param string $url The url of the css file containing the colour scheme.
2018 * @param array $colors Optional An array of CSS color definitions which are used to give the user a feel for the theme.
2020 function wp_admin_css_color($key, $name, $url, $colors = array()) {
2021 global $_wp_admin_css_colors;
2023 if ( !isset($_wp_admin_css_colors) )
2024 $_wp_admin_css_colors = array();
2026 $_wp_admin_css_colors[$key] = (object) array('name' => $name, 'url' => $url, 'colors' => $colors);
2030 * Registers the default Admin color schemes
2034 function register_admin_color_schemes() {
2035 wp_admin_css_color( 'classic', _x( 'Blue', 'admin color scheme' ), admin_url( 'css/colors-classic.css' ),
2036 array( '#5589aa', '#cfdfe9', '#d1e5ee', '#eff8ff' ) );
2037 wp_admin_css_color( 'fresh', _x( 'Gray', 'admin color scheme' ), admin_url( 'css/colors-fresh.css' ),
2038 array( '#555', '#a0a0a0', '#ccc', '#f1f1f1' ) );
2042 * Display the URL of a WordPress admin CSS file.
2044 * @see WP_Styles::_css_href and its style_loader_src filter.
2048 * @param string $file file relative to wp-admin/ without its ".css" extension.
2050 function wp_admin_css_uri( $file = 'wp-admin' ) {
2051 if ( defined('WP_INSTALLING') ) {
2052 $_file = "./$file.css";
2054 $_file = admin_url("$file.css");
2056 $_file = add_query_arg( 'version', get_bloginfo( 'version' ), $_file );
2058 return apply_filters( 'wp_admin_css_uri', $_file, $file );
2062 * Enqueues or directly prints a stylesheet link to the specified CSS file.
2064 * "Intelligently" decides to enqueue or to print the CSS file. If the
2065 * 'wp_print_styles' action has *not* yet been called, the CSS file will be
2066 * enqueued. If the wp_print_styles action *has* been called, the CSS link will
2067 * be printed. Printing may be forced by passing true as the $force_echo
2068 * (second) parameter.
2070 * For backward compatibility with WordPress 2.3 calling method: If the $file
2071 * (first) parameter does not correspond to a registered CSS file, we assume
2072 * $file is a file relative to wp-admin/ without its ".css" extension. A
2073 * stylesheet link to that generated URL is printed.
2075 * @package WordPress
2077 * @uses $wp_styles WordPress Styles Object
2079 * @param string $file Optional. Style handle name or file name (without ".css" extension) relative
2080 * to wp-admin/. Defaults to 'wp-admin'.
2081 * @param bool $force_echo Optional. Force the stylesheet link to be printed rather than enqueued.
2083 function wp_admin_css( $file = 'wp-admin', $force_echo = false ) {
2085 if ( !is_a($wp_styles, 'WP_Styles') )
2086 $wp_styles = new WP_Styles();
2088 // For backward compatibility
2089 $handle = 0 === strpos( $file, 'css/' ) ? substr( $file, 4 ) : $file;
2091 if ( $wp_styles->query( $handle ) ) {
2092 if ( $force_echo || did_action( 'wp_print_styles' ) ) // we already printed the style queue. Print this one immediately
2093 wp_print_styles( $handle );
2094 else // Add to style queue
2095 wp_enqueue_style( $handle );
2099 echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . esc_url( wp_admin_css_uri( $file ) ) . "' type='text/css' />\n", $file );
2100 if ( function_exists( 'is_rtl' ) && is_rtl() )
2101 echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . esc_url( wp_admin_css_uri( "$file-rtl" ) ) . "' type='text/css' />\n", "$file-rtl" );
2105 * Enqueues the default ThickBox js and css.
2107 * If any of the settings need to be changed, this can be done with another js
2108 * file similar to media-upload.js. That file should
2109 * require array('thickbox') to ensure it is loaded after.
2113 function add_thickbox() {
2114 wp_enqueue_script( 'thickbox' );
2115 wp_enqueue_style( 'thickbox' );
2117 if ( is_network_admin() )
2118 add_action( 'admin_head', '_thickbox_path_admin_subfolder' );
2122 * Display the XHTML generator that is generated on the wp_head hook.
2126 function wp_generator() {
2127 the_generator( apply_filters( 'wp_generator_type', 'xhtml' ) );
2131 * Display the generator XML or Comment for RSS, ATOM, etc.
2133 * Returns the correct generator type for the requested output format. Allows
2134 * for a plugin to filter generators overall the the_generator filter.
2137 * @uses apply_filters() Calls 'the_generator' hook.
2139 * @param string $type The type of generator to output - (html|xhtml|atom|rss2|rdf|comment|export).
2141 function the_generator( $type ) {
2142 echo apply_filters('the_generator', get_the_generator($type), $type) . "\n";
2146 * Creates the generator XML or Comment for RSS, ATOM, etc.
2148 * Returns the correct generator type for the requested output format. Allows
2149 * for a plugin to filter generators on an individual basis using the
2150 * 'get_the_generator_{$type}' filter.
2153 * @uses apply_filters() Calls 'get_the_generator_$type' hook.
2155 * @param string $type The type of generator to return - (html|xhtml|atom|rss2|rdf|comment|export).
2156 * @return string The HTML content for the generator.
2158 function get_the_generator( $type = '' ) {
2159 if ( empty( $type ) ) {
2161 $current_filter = current_filter();
2162 if ( empty( $current_filter ) )
2165 switch ( $current_filter ) {
2167 case 'commentsrss2_head' :
2178 case 'comments_atom_head' :
2187 $gen = '<meta name="generator" content="WordPress ' . get_bloginfo( 'version' ) . '">';
2190 $gen = '<meta name="generator" content="WordPress ' . get_bloginfo( 'version' ) . '" />';
2193 $gen = '<generator uri="http://wordpress.org/" version="' . get_bloginfo_rss( 'version' ) . '">WordPress</generator>';
2196 $gen = '<generator>http://wordpress.org/?v=' . get_bloginfo_rss( 'version' ) . '</generator>';
2199 $gen = '<admin:generatorAgent rdf:resource="http://wordpress.org/?v=' . get_bloginfo_rss( 'version' ) . '" />';
2202 $gen = '<!-- generator="WordPress/' . get_bloginfo( 'version' ) . '" -->';
2205 $gen = '<!-- generator="WordPress/' . get_bloginfo_rss('version') . '" created="'. date('Y-m-d H:i') . '" -->';
2208 return apply_filters( "get_the_generator_{$type}", $gen, $type );
2212 * Outputs the html checked attribute.
2214 * Compares the first two arguments and if identical marks as checked
2218 * @param mixed $checked One of the values to compare
2219 * @param mixed $current (true) The other value to compare if not just true
2220 * @param bool $echo Whether to echo or just return the string
2221 * @return string html attribute or empty string
2223 function checked( $checked, $current = true, $echo = true ) {
2224 return __checked_selected_helper( $checked, $current, $echo, 'checked' );
2228 * Outputs the html selected attribute.
2230 * Compares the first two arguments and if identical marks as selected
2234 * @param mixed $selected One of the values to compare
2235 * @param mixed $current (true) The other value to compare if not just true
2236 * @param bool $echo Whether to echo or just return the string
2237 * @return string html attribute or empty string
2239 function selected( $selected, $current = true, $echo = true ) {
2240 return __checked_selected_helper( $selected, $current, $echo, 'selected' );
2244 * Outputs the html disabled attribute.
2246 * Compares the first two arguments and if identical marks as disabled
2250 * @param mixed $disabled One of the values to compare
2251 * @param mixed $current (true) The other value to compare if not just true
2252 * @param bool $echo Whether to echo or just return the string
2253 * @return string html attribute or empty string
2255 function disabled( $disabled, $current = true, $echo = true ) {
2256 return __checked_selected_helper( $disabled, $current, $echo, 'disabled' );
2260 * Private helper function for checked, selected, and disabled.
2262 * Compares the first two arguments and if identical marks as $type
2267 * @param any $helper One of the values to compare
2268 * @param any $current (true) The other value to compare if not just true
2269 * @param bool $echo Whether to echo or just return the string
2270 * @param string $type The type of checked|selected|disabled we are doing
2271 * @return string html attribute or empty string
2273 function __checked_selected_helper( $helper, $current, $echo, $type ) {
2274 if ( (string) $helper === (string) $current )
2275 $result = " $type='$type'";