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 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="' . 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' => site_url( $_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="' . site_url( 'wp-login.php', 'login' ) . '" 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_attr( $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, 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 $arc_title = $arcresult->post_title;
1036 $text = strip_tags(apply_filters('the_title', $arc_title));
1038 $text = $arcresult->ID;
1039 $output .= get_archives_link($url, $text, $format, $before, $after);
1051 * Get number of days since the start of the week.
1054 * @usedby get_calendar()
1056 * @param int $num Number of day.
1057 * @return int Days since the start of the week.
1059 function calendar_week_mod($num) {
1061 return ($num - $base*floor($num/$base));
1065 * Display calendar with days that have posts as links.
1067 * The calendar is cached, which will be retrieved, if it exists. If there are
1068 * no posts for the month, then it will not be displayed.
1072 * @param bool $initial Optional, default is true. Use initial calendar names.
1073 * @param bool $echo Optional, default is true. Set to false for return.
1075 function get_calendar($initial = true, $echo = true) {
1076 global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
1079 $key = md5( $m . $monthnum . $year );
1080 if ( $cache = wp_cache_get( 'get_calendar', 'calendar' ) ) {
1081 if ( is_array($cache) && isset( $cache[ $key ] ) ) {
1083 echo apply_filters( 'get_calendar', $cache[$key] );
1086 return apply_filters( 'get_calendar', $cache[$key] );
1091 if ( !is_array($cache) )
1094 // Quick check. If we have no posts at all, abort!
1096 $gotsome = $wpdb->get_var("SELECT 1 as test FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1");
1098 $cache[ $key ] = '';
1099 wp_cache_set( 'get_calendar', $cache, 'calendar' );
1104 if ( isset($_GET['w']) )
1105 $w = ''.intval($_GET['w']);
1107 // week_begins = 0 stands for Sunday
1108 $week_begins = intval(get_option('start_of_week'));
1110 // Let's figure out when we are
1111 if ( !empty($monthnum) && !empty($year) ) {
1112 $thismonth = ''.zeroise(intval($monthnum), 2);
1113 $thisyear = ''.intval($year);
1114 } elseif ( !empty($w) ) {
1115 // We need to get the month from MySQL
1116 $thisyear = ''.intval(substr($m, 0, 4));
1117 $d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's
1118 $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')");
1119 } elseif ( !empty($m) ) {
1120 $thisyear = ''.intval(substr($m, 0, 4));
1121 if ( strlen($m) < 6 )
1124 $thismonth = ''.zeroise(intval(substr($m, 4, 2)), 2);
1126 $thisyear = gmdate('Y', current_time('timestamp'));
1127 $thismonth = gmdate('m', current_time('timestamp'));
1130 $unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear);
1131 $last_day = date('t', $unixmonth);
1133 // Get the next and previous month and year with at least one post
1134 $previous = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
1136 WHERE post_date < '$thisyear-$thismonth-01'
1137 AND post_type = 'post' AND post_status = 'publish'
1138 ORDER BY post_date DESC
1140 $next = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
1142 WHERE post_date > '$thisyear-$thismonth-{$last_day} 23:59:59'
1143 AND post_type = 'post' AND post_status = 'publish'
1144 ORDER BY post_date ASC
1147 /* translators: Calendar caption: 1: month name, 2: 4-digit year */
1148 $calendar_caption = _x('%1$s %2$s', 'calendar caption');
1149 $calendar_output = '<table id="wp-calendar">
1150 <caption>' . sprintf($calendar_caption, $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '</caption>
1156 for ( $wdcount=0; $wdcount<=6; $wdcount++ ) {
1157 $myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7);
1160 foreach ( $myweek as $wd ) {
1161 $day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
1162 $wd = esc_attr($wd);
1163 $calendar_output .= "\n\t\t<th scope=\"col\" title=\"$wd\">$day_name</th>";
1166 $calendar_output .= '
1174 $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>';
1176 $calendar_output .= "\n\t\t".'<td colspan="3" id="prev" class="pad"> </td>';
1179 $calendar_output .= "\n\t\t".'<td class="pad"> </td>';
1182 $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>';
1184 $calendar_output .= "\n\t\t".'<td colspan="3" id="next" class="pad"> </td>';
1187 $calendar_output .= '
1194 // Get days with posts
1195 $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
1196 FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00'
1197 AND post_type = 'post' AND post_status = 'publish'
1198 AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'", ARRAY_N);
1199 if ( $dayswithposts ) {
1200 foreach ( (array) $dayswithposts as $daywith ) {
1201 $daywithpost[] = $daywith[0];
1204 $daywithpost = array();
1207 if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'camino') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false)
1208 $ak_title_separator = "\n";
1210 $ak_title_separator = ', ';
1212 $ak_titles_for_day = array();
1213 $ak_post_titles = $wpdb->get_results("SELECT ID, post_title, DAYOFMONTH(post_date) as dom "
1214 ."FROM $wpdb->posts "
1215 ."WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' "
1216 ."AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59' "
1217 ."AND post_type = 'post' AND post_status = 'publish'"
1219 if ( $ak_post_titles ) {
1220 foreach ( (array) $ak_post_titles as $ak_post_title ) {
1222 $post_title = esc_attr( apply_filters( 'the_title', $ak_post_title->post_title, $ak_post_title->ID ) );
1224 if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) )
1225 $ak_titles_for_day['day_'.$ak_post_title->dom] = '';
1226 if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one
1227 $ak_titles_for_day["$ak_post_title->dom"] = $post_title;
1229 $ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . $post_title;
1234 // See how much we should pad in the beginning
1235 $pad = calendar_week_mod(date('w', $unixmonth)-$week_begins);
1237 $calendar_output .= "\n\t\t".'<td colspan="'. esc_attr($pad) .'" class="pad"> </td>';
1239 $daysinmonth = intval(date('t', $unixmonth));
1240 for ( $day = 1; $day <= $daysinmonth; ++$day ) {
1241 if ( isset($newrow) && $newrow )
1242 $calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
1245 if ( $day == gmdate('j', current_time('timestamp')) && $thismonth == gmdate('m', current_time('timestamp')) && $thisyear == gmdate('Y', current_time('timestamp')) )
1246 $calendar_output .= '<td id="today">';
1248 $calendar_output .= '<td>';
1250 if ( in_array($day, $daywithpost) ) // any posts today?
1251 $calendar_output .= '<a href="' . get_day_link( $thisyear, $thismonth, $day ) . '" title="' . esc_attr( $ak_titles_for_day[ $day ] ) . "\">$day</a>";
1253 $calendar_output .= $day;
1254 $calendar_output .= '</td>';
1256 if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) )
1260 $pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins);
1261 if ( $pad != 0 && $pad != 7 )
1262 $calendar_output .= "\n\t\t".'<td class="pad" colspan="'. esc_attr($pad) .'"> </td>';
1264 $calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>";
1266 $cache[ $key ] = $calendar_output;
1267 wp_cache_set( 'get_calendar', $cache, 'calendar' );
1270 echo apply_filters( 'get_calendar', $calendar_output );
1272 return apply_filters( 'get_calendar', $calendar_output );
1277 * Purge the cached results of get_calendar.
1282 function delete_get_calendar_cache() {
1283 wp_cache_delete( 'get_calendar', 'calendar' );
1285 add_action( 'save_post', 'delete_get_calendar_cache' );
1286 add_action( 'delete_post', 'delete_get_calendar_cache' );
1287 add_action( 'update_option_start_of_week', 'delete_get_calendar_cache' );
1288 add_action( 'update_option_gmt_offset', 'delete_get_calendar_cache' );
1291 * Display all of the allowed tags in HTML format with attributes.
1293 * This is useful for displaying in the comment area, which elements and
1294 * attributes are supported. As well as any plugins which want to display it.
1297 * @uses $allowedtags
1299 * @return string HTML allowed tags entity encoded.
1301 function allowed_tags() {
1302 global $allowedtags;
1304 foreach ( (array) $allowedtags as $tag => $attributes ) {
1305 $allowed .= '<'.$tag;
1306 if ( 0 < count($attributes) ) {
1307 foreach ( $attributes as $attribute => $limits ) {
1308 $allowed .= ' '.$attribute.'=""';
1313 return htmlentities($allowed);
1316 /***** Date/Time tags *****/
1319 * Outputs the date in iso8601 format for xml files.
1323 function the_date_xml() {
1325 echo mysql2date('Y-m-d', $post->post_date, false);
1329 * Display or Retrieve the date the current $post was written (once per date)
1331 * Will only output the date if the current post's date is different from the
1332 * previous one output.
1334 * i.e. Only one date listing will show per day worth of posts shown in the loop, even if the
1335 * function is called several times for each post.
1337 * HTML output can be filtered with 'the_date'.
1338 * Date string output can be filtered with 'get_the_date'.
1341 * @uses get_the_date()
1342 * @param string $d Optional. PHP date format defaults to the date_format option if not specified.
1343 * @param string $before Optional. Output before the date.
1344 * @param string $after Optional. Output after the date.
1345 * @param bool $echo Optional, default is display. Whether to echo the date or return it.
1346 * @return string|null Null if displaying, string if retrieving.
1348 function the_date( $d = '', $before = '', $after = '', $echo = true ) {
1349 global $currentday, $previousday;
1351 if ( $currentday != $previousday ) {
1352 $the_date .= $before;
1353 $the_date .= get_the_date( $d );
1354 $the_date .= $after;
1355 $previousday = $currentday;
1357 $the_date = apply_filters('the_date', $the_date, $d, $before, $after);
1369 * Retrieve the date the current $post was written.
1371 * Unlike the_date() this function will always return the date.
1372 * Modify output with 'get_the_date' filter.
1376 * @param string $d Optional. PHP date format defaults to the date_format option if not specified.
1377 * @return string|null Null if displaying, string if retrieving.
1379 function get_the_date( $d = '' ) {
1384 $the_date .= mysql2date(get_option('date_format'), $post->post_date);
1386 $the_date .= mysql2date($d, $post->post_date);
1388 return apply_filters('get_the_date', $the_date, $d);
1392 * Display the date on which the post was last modified.
1396 * @param string $d Optional. PHP date format defaults to the date_format option if not specified.
1397 * @param string $before Optional. Output before the date.
1398 * @param string $after Optional. Output after the date.
1399 * @param bool $echo Optional, default is display. Whether to echo the date or return it.
1400 * @return string|null Null if displaying, string if retrieving.
1402 function the_modified_date($d = '', $before='', $after='', $echo = true) {
1404 $the_modified_date = $before . get_the_modified_date($d) . $after;
1405 $the_modified_date = apply_filters('the_modified_date', $the_modified_date, $d, $before, $after);
1408 echo $the_modified_date;
1410 return $the_modified_date;
1415 * Retrieve the date on which the post was last modified.
1419 * @param string $d Optional. PHP date format. Defaults to the "date_format" option
1422 function get_the_modified_date($d = '') {
1424 $the_time = get_post_modified_time(get_option('date_format'), null, null, true);
1426 $the_time = get_post_modified_time($d, null, null, true);
1427 return apply_filters('get_the_modified_date', $the_time, $d);
1431 * Display the time at which the post was written.
1435 * @param string $d Either 'G', 'U', or php date format.
1437 function the_time( $d = '' ) {
1438 echo apply_filters('the_time', get_the_time( $d ), $d);
1442 * Retrieve the time at which the post was written.
1446 * @param string $d Optional Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
1447 * @param int|object $post Optional post ID or object. Default is global $post object.
1450 function get_the_time( $d = '', $post = null ) {
1451 $post = get_post($post);
1454 $the_time = get_post_time(get_option('time_format'), false, $post, true);
1456 $the_time = get_post_time($d, false, $post, true);
1457 return apply_filters('get_the_time', $the_time, $d, $post);
1461 * Retrieve the time at which the post was written.
1465 * @param string $d Optional Either 'G', 'U', or php date format.
1466 * @param bool $gmt Optional, default is false. Whether to return the gmt time.
1467 * @param int|object $post Optional post ID or object. Default is global $post object.
1468 * @param bool $translate Whether to translate the time string
1471 function get_post_time( $d = 'U', $gmt = false, $post = null, $translate = false ) { // returns timestamp
1472 $post = get_post($post);
1475 $time = $post->post_date_gmt;
1477 $time = $post->post_date;
1479 $time = mysql2date($d, $time, $translate);
1480 return apply_filters('get_post_time', $time, $d, $gmt);
1484 * Display the time at which the post was last modified.
1488 * @param string $d Optional Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
1490 function the_modified_time($d = '') {
1491 echo apply_filters('the_modified_time', get_the_modified_time($d), $d);
1495 * Retrieve the time at which the post was last modified.
1499 * @param string $d Optional Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
1502 function get_the_modified_time($d = '') {
1504 $the_time = get_post_modified_time(get_option('time_format'), null, null, true);
1506 $the_time = get_post_modified_time($d, null, null, true);
1507 return apply_filters('get_the_modified_time', $the_time, $d);
1511 * Retrieve the time at which the post was last modified.
1515 * @param string $d Optional, default is 'U'. Either 'G', 'U', or php date format.
1516 * @param bool $gmt Optional, default is false. Whether to return the gmt time.
1517 * @param int|object $post Optional, default is global post object. A post_id or post object
1518 * @param bool $translate Optional, default is false. Whether to translate the result
1519 * @return string Returns timestamp
1521 function get_post_modified_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
1522 $post = get_post($post);
1525 $time = $post->post_modified_gmt;
1527 $time = $post->post_modified;
1528 $time = mysql2date($d, $time, $translate);
1530 return apply_filters('get_post_modified_time', $time, $d, $gmt);
1534 * Display the weekday on which the post was written.
1540 function the_weekday() {
1541 global $wp_locale, $post;
1542 $the_weekday = $wp_locale->get_weekday(mysql2date('w', $post->post_date, false));
1543 $the_weekday = apply_filters('the_weekday', $the_weekday);
1548 * Display the weekday on which the post was written.
1550 * Will only output the weekday if the current post's weekday is different from
1551 * the previous one output.
1555 * @param string $before Optional Output before the date.
1556 * @param string $after Optional Output after the date.
1558 function the_weekday_date($before='',$after='') {
1559 global $wp_locale, $post, $day, $previousweekday;
1560 $the_weekday_date = '';
1561 if ( $currentday != $previousweekday ) {
1562 $the_weekday_date .= $before;
1563 $the_weekday_date .= $wp_locale->get_weekday(mysql2date('w', $post->post_date, false));
1564 $the_weekday_date .= $after;
1565 $previousweekday = $currentday;
1567 $the_weekday_date = apply_filters('the_weekday_date', $the_weekday_date, $before, $after);
1568 echo $the_weekday_date;
1572 * Fire the wp_head action
1575 * @uses do_action() Calls 'wp_head' hook.
1577 function wp_head() {
1578 do_action('wp_head');
1582 * Fire the wp_footer action
1585 * @uses do_action() Calls 'wp_footer' hook.
1587 function wp_footer() {
1588 do_action('wp_footer');
1592 * Display the links to the general feeds.
1596 * @param array $args Optional arguments.
1598 function feed_links( $args = array() ) {
1599 if ( !current_theme_supports('automatic-feed-links') )
1603 /* translators: Separator between blog name and feed type in feed links */
1604 'separator' => _x('»', 'feed link'),
1605 /* translators: 1: blog title, 2: separator (raquo) */
1606 'feedtitle' => __('%1$s %2$s Feed'),
1607 /* translators: %s: blog title, 2: separator (raquo) */
1608 'comstitle' => __('%1$s %2$s Comments Feed'),
1611 $args = wp_parse_args( $args, $defaults );
1613 echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr(sprintf( $args['feedtitle'], get_bloginfo('name'), $args['separator'] )) . '" href="' . get_feed_link() . "\" />\n";
1614 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";
1618 * Display the links to the extra feeds such as category feeds.
1622 * @param array $args Optional arguments.
1624 function feed_links_extra( $args = array() ) {
1626 /* translators: Separator between blog name and feed type in feed links */
1627 'separator' => _x('»', 'feed link'),
1628 /* translators: 1: blog name, 2: separator(raquo), 3: post title */
1629 'singletitle' => __('%1$s %2$s %3$s Comments Feed'),
1630 /* translators: 1: blog name, 2: separator(raquo), 3: category name */
1631 'cattitle' => __('%1$s %2$s %3$s Category Feed'),
1632 /* translators: 1: blog name, 2: separator(raquo), 3: tag name */
1633 'tagtitle' => __('%1$s %2$s %3$s Tag Feed'),
1634 /* translators: 1: blog name, 2: separator(raquo), 3: author name */
1635 'authortitle' => __('%1$s %2$s Posts by %3$s Feed'),
1636 /* translators: 1: blog name, 2: separator(raquo), 3: search phrase */
1637 'searchtitle' => __('%1$s %2$s Search Results for “%3$s” Feed'),
1640 $args = wp_parse_args( $args, $defaults );
1642 if ( is_single() || is_page() ) {
1643 $post = &get_post( $id = 0 );
1645 if ( comments_open() || pings_open() || $post->comment_count > 0 ) {
1646 $title = esc_attr(sprintf( $args['singletitle'], get_bloginfo('name'), $args['separator'], esc_html( get_the_title() ) ));
1647 $href = get_post_comments_feed_link( $post->ID );
1649 } elseif ( is_category() ) {
1650 $term = get_queried_object();
1652 $title = esc_attr(sprintf( $args['cattitle'], get_bloginfo('name'), $args['separator'], $term->name ));
1653 $href = get_category_feed_link( $term->term_id );
1654 } elseif ( is_tag() ) {
1655 $term = get_queried_object();
1657 $title = esc_attr(sprintf( $args['tagtitle'], get_bloginfo('name'), $args['separator'], $term->name ));
1658 $href = get_tag_feed_link( $term->term_id );
1659 } elseif ( is_author() ) {
1660 $author_id = intval( get_query_var('author') );
1662 $title = esc_attr(sprintf( $args['authortitle'], get_bloginfo('name'), $args['separator'], get_the_author_meta( 'display_name', $author_id ) ));
1663 $href = get_author_feed_link( $author_id );
1664 } elseif ( is_search() ) {
1665 $title = esc_attr(sprintf( $args['searchtitle'], get_bloginfo('name'), $args['separator'], get_search_query( false ) ));
1666 $href = get_search_feed_link();
1669 if ( isset($title) && isset($href) )
1670 echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . $title . '" href="' . $href . '" />' . "\n";
1674 * Display the link to the Really Simple Discovery service endpoint.
1676 * @link http://archipelago.phrasewise.com/rsd
1679 function rsd_link() {
1680 echo '<link rel="EditURI" type="application/rsd+xml" title="RSD" href="' . get_bloginfo('wpurl') . "/xmlrpc.php?rsd\" />\n";
1684 * Display the link to the Windows Live Writer manifest file.
1686 * @link http://msdn.microsoft.com/en-us/library/bb463265.aspx
1689 function wlwmanifest_link() {
1690 echo '<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="'
1691 . get_bloginfo('wpurl') . '/wp-includes/wlwmanifest.xml" /> ' . "\n";
1695 * Display a noindex meta tag if required by the blog configuration.
1697 * If a blog is marked as not being public then the noindex meta tag will be
1698 * output to tell web robots not to index the page content.
1702 function noindex() {
1703 // If the blog is not public, tell robots to go away.
1704 if ( '0' == get_option('blog_public') )
1705 echo "<meta name='robots' content='noindex,nofollow' />\n";
1709 * Determine if TinyMCE is available.
1711 * Checks to see if the user has deleted the tinymce files to slim down there WordPress install.
1715 * @return bool Whether TinyMCE exists.
1717 function rich_edit_exists() {
1718 global $wp_rich_edit_exists;
1719 if ( !isset($wp_rich_edit_exists) )
1720 $wp_rich_edit_exists = file_exists(ABSPATH . WPINC . '/js/tinymce/tiny_mce.js');
1721 return $wp_rich_edit_exists;
1725 * Whether the user should have a WYSIWIG editor.
1727 * Checks that the user requires a WYSIWIG editor and that the editor is
1728 * supported in the users browser.
1734 function user_can_richedit() {
1735 global $wp_rich_edit, $pagenow, $is_iphone;
1737 if ( !isset( $wp_rich_edit) ) {
1738 if ( get_user_option( 'rich_editing' ) == 'true' &&
1739 !$is_iphone && // this includes all Safari mobile browsers
1740 ( ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval($match[1]) >= 420 ) ||
1741 !preg_match( '!opera[ /][2-8]|konqueror|safari!i', $_SERVER['HTTP_USER_AGENT'] ) )
1742 && 'comment.php' != $pagenow ) {
1743 $wp_rich_edit = true;
1745 $wp_rich_edit = false;
1749 return apply_filters('user_can_richedit', $wp_rich_edit);
1753 * Find out which editor should be displayed by default.
1755 * Works out which of the two editors to display as the current editor for a
1760 * @return string Either 'tinymce', or 'html', or 'test'
1762 function wp_default_editor() {
1763 $r = user_can_richedit() ? 'tinymce' : 'html'; // defaults
1764 if ( $user = wp_get_current_user() ) { // look for cookie
1765 $ed = get_user_setting('editor', 'tinymce');
1766 $r = ( in_array($ed, array('tinymce', 'html', 'test') ) ) ? $ed : $r;
1768 return apply_filters( 'wp_default_editor', $r ); // filter
1772 * Display visual editor forms: TinyMCE, or HTML, or both.
1774 * The amount of rows the text area will have for the content has to be between
1775 * 3 and 100 or will default at 12. There is only one option used for all users,
1776 * named 'default_post_edit_rows'.
1778 * If the user can not use the rich editor (TinyMCE), then the switch button
1779 * will not be displayed.
1783 * @param string $content Textarea content.
1784 * @param string $id Optional, default is 'content'. HTML ID attribute value.
1785 * @param string $prev_id Optional, default is 'title'. HTML ID name for switching back and forth between visual editors.
1786 * @param bool $media_buttons Optional, default is true. Whether to display media buttons.
1787 * @param int $tab_index Optional, default is 2. Tabindex for textarea element.
1789 function the_editor($content, $id = 'content', $prev_id = 'title', $media_buttons = true, $tab_index = 2, $extended = true) {
1790 $rows = get_option('default_post_edit_rows');
1791 if (($rows < 3) || ($rows > 100))
1794 if ( !current_user_can( 'upload_files' ) )
1795 $media_buttons = false;
1797 $richedit = user_can_richedit();
1800 if ( $richedit || $media_buttons ) { ?>
1801 <div id="editor-toolbar">
1804 $wp_default_editor = wp_default_editor(); ?>
1805 <div class="zerosize"><input accesskey="e" type="button" onclick="switchEditors.go('<?php echo $id; ?>')" /></div>
1806 <?php if ( 'html' == $wp_default_editor ) {
1807 add_filter('the_editor_content', 'wp_htmledit_pre'); ?>
1808 <a id="edButtonHTML" class="active hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'html');"><?php _e('HTML'); ?></a>
1809 <a id="edButtonPreview" class="hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'tinymce');"><?php _e('Visual'); ?></a>
1811 $class = " class='theEditor'";
1812 add_filter('the_editor_content', 'wp_richedit_pre'); ?>
1813 <a id="edButtonHTML" class="hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'html');"><?php _e('HTML'); ?></a>
1814 <a id="edButtonPreview" class="active hide-if-no-js" onclick="switchEditors.go('<?php echo $id; ?>', 'tinymce');"><?php _e('Visual'); ?></a>
1818 if ( $media_buttons ) { ?>
1819 <div id="media-buttons" class="hide-if-no-js">
1820 <?php do_action( 'media_buttons' ); ?>
1828 <div id="quicktags"><?php
1829 wp_print_scripts( 'quicktags' ); ?>
1830 <script type="text/javascript">edToolbar()</script>
1834 $the_editor = apply_filters('the_editor', "<div id='editorcontainer'><textarea rows='$rows'$class cols='40' name='$id' tabindex='$tab_index' id='$id'>%s</textarea></div>\n");
1835 $the_editor_content = apply_filters('the_editor_content', $content);
1837 printf($the_editor, $the_editor_content);
1840 <script type="text/javascript">
1841 edCanvas = document.getElementById('<?php echo $id; ?>');
1842 <?php if ( ! $extended ) { ?> jQuery('#ed_fullscreen, #ed_more').hide();<?php } ?>
1847 add_action( 'admin_print_footer_scripts', 'wp_tiny_mce', 25 );
1848 elseif ( $extended )
1849 add_action( 'admin_print_footer_scripts', 'wp_quicktags', 25 );
1854 * Retrieve the contents of the search WordPress query variable.
1856 * The search query string is passed through {@link esc_attr()}
1857 * to ensure that it is safe for placing in an html attribute.
1862 * @param bool $escaped Whether the result is escaped. Default true.
1863 * Only use when you are later escaping it. Do not use unescaped.
1866 function get_search_query( $escaped = true ) {
1867 $query = apply_filters( 'get_search_query', get_query_var( 's' ) );
1869 $query = esc_attr( $query );
1874 * Display the contents of the search query variable.
1876 * The search query string is passed through {@link esc_attr()}
1877 * to ensure that it is safe for placing in an html attribute.
1882 function the_search_query() {
1883 echo esc_attr( apply_filters( 'the_search_query', get_search_query( false ) ) );
1887 * Display the language attributes for the html tag.
1889 * Builds up a set of html attributes containing the text direction and language
1890 * information for the page.
1894 * @param string $doctype The type of html document (xhtml|html).
1896 function language_attributes($doctype = 'html') {
1897 $attributes = array();
1900 if ( function_exists( 'is_rtl' ) )
1901 $attributes[] = 'dir="' . ( is_rtl() ? 'rtl' : 'ltr' ) . '"';
1903 if ( $lang = get_bloginfo('language') ) {
1904 if ( get_option('html_type') == 'text/html' || $doctype == 'html' )
1905 $attributes[] = "lang=\"$lang\"";
1907 if ( get_option('html_type') != 'text/html' || $doctype == 'xhtml' )
1908 $attributes[] = "xml:lang=\"$lang\"";
1911 $output = implode(' ', $attributes);
1912 $output = apply_filters('language_attributes', $output);
1917 * Retrieve paginated link for archive post pages.
1919 * Technically, the function can be used to create paginated link list for any
1920 * area. The 'base' argument is used to reference the url, which will be used to
1921 * create the paginated links. The 'format' argument is then used for replacing
1922 * the page number. It is however, most likely and by default, to be used on the
1923 * archive post pages.
1925 * The 'type' argument controls format of the returned value. The default is
1926 * 'plain', which is just a string with the links separated by a newline
1927 * character. The other possible values are either 'array' or 'list'. The
1928 * 'array' value will return an array of the paginated link list to offer full
1929 * control of display. The 'list' value will place all of the paginated links in
1930 * an unordered HTML list.
1932 * The 'total' argument is the total amount of pages and is an integer. The
1933 * 'current' argument is the current page number and is also an integer.
1935 * An example of the 'base' argument is "http://example.com/all_posts.php%_%"
1936 * and the '%_%' is required. The '%_%' will be replaced by the contents of in
1937 * the 'format' argument. An example for the 'format' argument is "?page=%#%"
1938 * and the '%#%' is also required. The '%#%' will be replaced with the page
1941 * You can include the previous and next links in the list by setting the
1942 * 'prev_next' argument to true, which it is by default. You can set the
1943 * previous text, by using the 'prev_text' argument. You can set the next text
1944 * by setting the 'next_text' argument.
1946 * If the 'show_all' argument is set to true, then it will show all of the pages
1947 * instead of a short list of the pages near the current page. By default, the
1948 * 'show_all' is set to false and controlled by the 'end_size' and 'mid_size'
1949 * arguments. The 'end_size' argument is how many numbers on either the start
1950 * and the end list edges, by default is 1. The 'mid_size' argument is how many
1951 * numbers to either side of current page, but not including current page.
1953 * It is possible to add query vars to the link by using the 'add_args' argument
1954 * and see {@link add_query_arg()} for more information.
1958 * @param string|array $args Optional. Override defaults.
1959 * @return array|string String of page links or array of page links.
1961 function paginate_links( $args = '' ) {
1963 'base' => '%_%', // http://example.com/all_posts.php%_% : %_% is replaced by format (below)
1964 'format' => '?page=%#%', // ?page=%#% : %#% is replaced by the page number
1967 'show_all' => false,
1968 'prev_next' => true,
1969 'prev_text' => __('« Previous'),
1970 'next_text' => __('Next »'),
1974 'add_args' => false, // array of query args to add
1975 'add_fragment' => ''
1978 $args = wp_parse_args( $args, $defaults );
1979 extract($args, EXTR_SKIP);
1981 // Who knows what else people pass in $args
1982 $total = (int) $total;
1985 $current = (int) $current;
1986 $end_size = 0 < (int) $end_size ? (int) $end_size : 1; // Out of bounds? Make it the default.
1987 $mid_size = 0 <= (int) $mid_size ? (int) $mid_size : 2;
1988 $add_args = is_array($add_args) ? $add_args : false;
1990 $page_links = array();
1994 if ( $prev_next && $current && 1 < $current ) :
1995 $link = str_replace('%_%', 2 == $current ? '' : $format, $base);
1996 $link = str_replace('%#%', $current - 1, $link);
1998 $link = add_query_arg( $add_args, $link );
1999 $link .= $add_fragment;
2000 $page_links[] = '<a class="prev page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $prev_text . '</a>';
2002 for ( $n = 1; $n <= $total; $n++ ) :
2003 $n_display = number_format_i18n($n);
2004 if ( $n == $current ) :
2005 $page_links[] = "<span class='page-numbers current'>$n_display</span>";
2008 if ( $show_all || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) :
2009 $link = str_replace('%_%', 1 == $n ? '' : $format, $base);
2010 $link = str_replace('%#%', $n, $link);
2012 $link = add_query_arg( $add_args, $link );
2013 $link .= $add_fragment;
2014 $page_links[] = "<a class='page-numbers' href='" . esc_url( apply_filters( 'paginate_links', $link ) ) . "'>$n_display</a>";
2016 elseif ( $dots && !$show_all ) :
2017 $page_links[] = '<span class="page-numbers dots">...</span>';
2022 if ( $prev_next && $current && ( $current < $total || -1 == $total ) ) :
2023 $link = str_replace('%_%', $format, $base);
2024 $link = str_replace('%#%', $current + 1, $link);
2026 $link = add_query_arg( $add_args, $link );
2027 $link .= $add_fragment;
2028 $page_links[] = '<a class="next page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $next_text . '</a>';
2035 $r .= "<ul class='page-numbers'>\n\t<li>";
2036 $r .= join("</li>\n\t<li>", $page_links);
2037 $r .= "</li>\n</ul>\n";
2040 $r = join("\n", $page_links);
2047 * Registers an admin colour scheme css file.
2049 * Allows a plugin to register a new admin colour scheme. For example:
2051 * wp_admin_css_color('classic', __('Classic'), admin_url("css/colors-classic.css"),
2052 * array('#07273E', '#14568A', '#D54E21', '#2683AE'));
2057 * @param string $key The unique key for this theme.
2058 * @param string $name The name of the theme.
2059 * @param string $url The url of the css file containing the colour scheme.
2060 * @param array $colors Optional An array of CSS color definitions which are used to give the user a feel for the theme.
2062 function wp_admin_css_color($key, $name, $url, $colors = array()) {
2063 global $_wp_admin_css_colors;
2065 if ( !isset($_wp_admin_css_colors) )
2066 $_wp_admin_css_colors = array();
2068 $_wp_admin_css_colors[$key] = (object) array('name' => $name, 'url' => $url, 'colors' => $colors);
2072 * Registers the default Admin color schemes
2076 function register_admin_color_schemes() {
2077 wp_admin_css_color( 'classic', __( 'Blue' ), admin_url( 'css/colors-classic.css' ),
2078 array( '#5589aa', '#cfdfe9', '#d1e5ee', '#eff8ff' ) );
2079 wp_admin_css_color( 'fresh', __( 'Gray' ), admin_url( 'css/colors-fresh.css' ),
2080 array( '#7c7976', '#c6c6c6', '#e0e0e0', '#f1f1f1' ) );
2084 * Display the URL of a WordPress admin CSS file.
2086 * @see WP_Styles::_css_href and its style_loader_src filter.
2090 * @param string $file file relative to wp-admin/ without its ".css" extension.
2092 function wp_admin_css_uri( $file = 'wp-admin' ) {
2093 if ( defined('WP_INSTALLING') ) {
2094 $_file = "./$file.css";
2096 $_file = admin_url("$file.css");
2098 $_file = add_query_arg( 'version', get_bloginfo( 'version' ), $_file );
2100 return apply_filters( 'wp_admin_css_uri', $_file, $file );
2104 * Enqueues or directly prints a stylesheet link to the specified CSS file.
2106 * "Intelligently" decides to enqueue or to print the CSS file. If the
2107 * 'wp_print_styles' action has *not* yet been called, the CSS file will be
2108 * enqueued. If the wp_print_styles action *has* been called, the CSS link will
2109 * be printed. Printing may be forced by passing TRUE as the $force_echo
2110 * (second) parameter.
2112 * For backward compatibility with WordPress 2.3 calling method: If the $file
2113 * (first) parameter does not correspond to a registered CSS file, we assume
2114 * $file is a file relative to wp-admin/ without its ".css" extension. A
2115 * stylesheet link to that generated URL is printed.
2117 * @package WordPress
2119 * @uses $wp_styles WordPress Styles Object
2121 * @param string $file Optional. Style handle name or file name (without ".css" extension) relative
2122 * to wp-admin/. Defaults to 'wp-admin'.
2123 * @param bool $force_echo Optional. Force the stylesheet link to be printed rather than enqueued.
2125 function wp_admin_css( $file = 'wp-admin', $force_echo = false ) {
2127 if ( !is_a($wp_styles, 'WP_Styles') )
2128 $wp_styles = new WP_Styles();
2130 // For backward compatibility
2131 $handle = 0 === strpos( $file, 'css/' ) ? substr( $file, 4 ) : $file;
2133 if ( $wp_styles->query( $handle ) ) {
2134 if ( $force_echo || did_action( 'wp_print_styles' ) ) // we already printed the style queue. Print this one immediately
2135 wp_print_styles( $handle );
2136 else // Add to style queue
2137 wp_enqueue_style( $handle );
2141 echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . esc_url( wp_admin_css_uri( $file ) ) . "' type='text/css' />\n", $file );
2143 echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . esc_url( wp_admin_css_uri( "$file-rtl" ) ) . "' type='text/css' />\n", "$file-rtl" );
2147 * Enqueues the default ThickBox js and css.
2149 * If any of the settings need to be changed, this can be done with another js
2150 * file similar to media-upload.js and theme-preview.js. That file should
2151 * require array('thickbox') to ensure it is loaded after.
2155 function add_thickbox() {
2156 wp_enqueue_script( 'thickbox' );
2157 wp_enqueue_style( 'thickbox' );
2159 if ( is_network_admin() )
2160 add_action( 'admin_head', '_thickbox_path_admin_subfolder' );
2164 * Display the XHTML generator that is generated on the wp_head hook.
2168 function wp_generator() {
2169 the_generator( apply_filters( 'wp_generator_type', 'xhtml' ) );
2173 * Display the generator XML or Comment for RSS, ATOM, etc.
2175 * Returns the correct generator type for the requested output format. Allows
2176 * for a plugin to filter generators overall the the_generator filter.
2179 * @uses apply_filters() Calls 'the_generator' hook.
2181 * @param string $type The type of generator to output - (html|xhtml|atom|rss2|rdf|comment|export).
2183 function the_generator( $type ) {
2184 echo apply_filters('the_generator', get_the_generator($type), $type) . "\n";
2188 * Creates the generator XML or Comment for RSS, ATOM, etc.
2190 * Returns the correct generator type for the requested output format. Allows
2191 * for a plugin to filter generators on an individual basis using the
2192 * 'get_the_generator_{$type}' filter.
2195 * @uses apply_filters() Calls 'get_the_generator_$type' hook.
2197 * @param string $type The type of generator to return - (html|xhtml|atom|rss2|rdf|comment|export).
2198 * @return string The HTML content for the generator.
2200 function get_the_generator( $type = '' ) {
2201 if ( empty( $type ) ) {
2203 $current_filter = current_filter();
2204 if ( empty( $current_filter ) )
2207 switch ( $current_filter ) {
2209 case 'commentsrss2_head' :
2220 case 'comments_atom_head' :
2229 $gen = '<meta name="generator" content="WordPress ' . get_bloginfo( 'version' ) . '">';
2232 $gen = '<meta name="generator" content="WordPress ' . get_bloginfo( 'version' ) . '" />';
2235 $gen = '<generator uri="http://wordpress.org/" version="' . get_bloginfo_rss( 'version' ) . '">WordPress</generator>';
2238 $gen = '<generator>http://wordpress.org/?v=' . get_bloginfo_rss( 'version' ) . '</generator>';
2241 $gen = '<admin:generatorAgent rdf:resource="http://wordpress.org/?v=' . get_bloginfo_rss( 'version' ) . '" />';
2244 $gen = '<!-- generator="WordPress/' . get_bloginfo( 'version' ) . '" -->';
2247 $gen = '<!-- generator="WordPress/' . get_bloginfo_rss('version') . '" created="'. date('Y-m-d H:i') . '" -->';
2250 return apply_filters( "get_the_generator_{$type}", $gen, $type );
2254 * Outputs the html checked attribute.
2256 * Compares the first two arguments and if identical marks as checked
2260 * @param mixed $checked One of the values to compare
2261 * @param mixed $current (true) The other value to compare if not just true
2262 * @param bool $echo Whether to echo or just return the string
2263 * @return string html attribute or empty string
2265 function checked( $checked, $current = true, $echo = true ) {
2266 return __checked_selected_helper( $checked, $current, $echo, 'checked' );
2270 * Outputs the html selected attribute.
2272 * Compares the first two arguments and if identical marks as selected
2276 * @param mixed $selected One of the values to compare
2277 * @param mixed $current (true) The other value to compare if not just true
2278 * @param bool $echo Whether to echo or just return the string
2279 * @return string html attribute or empty string
2281 function selected( $selected, $current = true, $echo = true ) {
2282 return __checked_selected_helper( $selected, $current, $echo, 'selected' );
2286 * Outputs the html disabled attribute.
2288 * Compares the first two arguments and if identical marks as disabled
2292 * @param mixed $disabled One of the values to compare
2293 * @param mixed $current (true) The other value to compare if not just true
2294 * @param bool $echo Whether to echo or just return the string
2295 * @return string html attribute or empty string
2297 function disabled( $disabled, $current = true, $echo = true ) {
2298 return __checked_selected_helper( $disabled, $current, $echo, 'disabled' );
2302 * Private helper function for checked, selected, and disabled.
2304 * Compares the first two arguments and if identical marks as $type
2309 * @param any $helper One of the values to compare
2310 * @param any $current (true) The other value to compare if not just true
2311 * @param bool $echo Whether to echo or just return the string
2312 * @param string $type The type of checked|selected|disabled we are doing
2313 * @return string html attribute or empty string
2315 function __checked_selected_helper( $helper, $current, $echo, $type ) {
2316 if ( (string) $helper === (string) $current )
2317 $result = " $type='$type'";