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
20 * @param string $name The name of the specialised header.
22 function get_header( $name = null ) {
24 * Fires before the header template file is loaded.
26 * The hook allows a specific header template file to be used in place of the
27 * default header template file. If your file is called header-new.php,
28 * you would specify the filename in the hook as get_header( 'new' ).
31 * @since 2.8.0 $name parameter added.
33 * @param string $name Name of the specific header file to use.
35 do_action( 'get_header', $name );
38 $name = (string) $name;
40 $templates[] = "header-{$name}.php";
42 $templates[] = 'header.php';
44 // Backward compat code will be removed in a future release
45 if ('' == locate_template($templates, true))
46 load_template( ABSPATH . WPINC . '/theme-compat/header.php');
50 * Load footer template.
52 * Includes the footer template for a theme or if a name is specified then a
53 * specialised footer will be included.
55 * For the parameter, if the file is called "footer-special.php" then specify
60 * @param string $name The name of the specialised footer.
62 function get_footer( $name = null ) {
64 * Fires before the footer template file is loaded.
66 * The hook allows a specific footer template file to be used in place of the
67 * default footer template file. If your file is called footer-new.php,
68 * you would specify the filename in the hook as get_footer( 'new' ).
71 * @since 2.8.0 $name parameter added.
73 * @param string $name Name of the specific footer file to use.
75 do_action( 'get_footer', $name );
78 $name = (string) $name;
80 $templates[] = "footer-{$name}.php";
82 $templates[] = 'footer.php';
84 // Backward compat code will be removed in a future release
85 if ('' == locate_template($templates, true))
86 load_template( ABSPATH . WPINC . '/theme-compat/footer.php');
90 * Load sidebar template.
92 * Includes the sidebar template for a theme or if a name is specified then a
93 * specialised sidebar will be included.
95 * For the parameter, if the file is called "sidebar-special.php" then specify
100 * @param string $name The name of the specialised sidebar.
102 function get_sidebar( $name = null ) {
104 * Fires before the sidebar template file is loaded.
106 * The hook allows a specific sidebar template file to be used in place of the
107 * default sidebar template file. If your file is called sidebar-new.php,
108 * you would specify the filename in the hook as get_sidebar( 'new' ).
111 * @since 2.8.0 $name parameter added.
113 * @param string $name Name of the specific sidebar file to use.
115 do_action( 'get_sidebar', $name );
117 $templates = array();
118 $name = (string) $name;
120 $templates[] = "sidebar-{$name}.php";
122 $templates[] = 'sidebar.php';
124 // Backward compat code will be removed in a future release
125 if ('' == locate_template($templates, true))
126 load_template( ABSPATH . WPINC . '/theme-compat/sidebar.php');
130 * Load a template part into a template
132 * Makes it easy for a theme to reuse sections of code in a easy to overload way
135 * Includes the named template part for a theme or if a name is specified then a
136 * specialised part will be included. If the theme contains no {slug}.php file
137 * then no template will be included.
139 * The template is included using require, not require_once, so you may include the
140 * same template part multiple times.
142 * For the $name parameter, if the file is called "{slug}-special.php" then specify
147 * @param string $slug The slug name for the generic template.
148 * @param string $name The name of the specialised template.
150 function get_template_part( $slug, $name = null ) {
152 * Fires before the specified template part file is loaded.
154 * The dynamic portion of the hook name, `$slug`, refers to the slug name
155 * for the generic template part.
159 * @param string $slug The slug name for the generic template.
160 * @param string $name The name of the specialized template.
162 do_action( "get_template_part_{$slug}", $slug, $name );
164 $templates = array();
165 $name = (string) $name;
167 $templates[] = "{$slug}-{$name}.php";
169 $templates[] = "{$slug}.php";
171 locate_template($templates, true, false);
175 * Display search form.
177 * Will first attempt to locate the searchform.php file in either the child or
178 * the parent, then load it. If it doesn't exist, then the default search form
179 * will be displayed. The default search form is HTML, which will be displayed.
180 * There is a filter applied to the search form HTML in order to edit or replace
181 * it. The filter is 'get_search_form'.
183 * This function is primarily used by themes which want to hardcode the search
184 * form into the sidebar and also by the search widget in WordPress.
186 * There is also an action that is called whenever the function is run called,
187 * 'pre_get_search_form'. This can be useful for outputting JavaScript that the
188 * search relies on or various formatting that applies to the beginning of the
189 * search. To give a few examples of what it can be used for.
193 * @param boolean $echo Default to echo and not return the form.
194 * @return string|null String when retrieving, null when displaying or if searchform.php exists.
196 function get_search_form( $echo = true ) {
198 * Fires before the search form is retrieved, at the start of get_search_form().
200 * @since 2.7.0 as 'get_search_form' action.
203 * @link https://core.trac.wordpress.org/ticket/19321
205 do_action( 'pre_get_search_form' );
207 $format = current_theme_supports( 'html5', 'search-form' ) ? 'html5' : 'xhtml';
210 * Filter the HTML format of the search form.
214 * @param string $format The type of markup to use in the search form.
215 * Accepts 'html5', 'xhtml'.
217 $format = apply_filters( 'search_form_format', $format );
219 $search_form_template = locate_template( 'searchform.php' );
220 if ( '' != $search_form_template ) {
222 require( $search_form_template );
223 $form = ob_get_clean();
225 if ( 'html5' == $format ) {
226 $form = '<form role="search" method="get" class="search-form" action="' . esc_url( home_url( '/' ) ) . '">
228 <span class="screen-reader-text">' . _x( 'Search for:', 'label' ) . '</span>
229 <input type="search" class="search-field" placeholder="' . esc_attr_x( 'Search …', 'placeholder' ) . '" value="' . get_search_query() . '" name="s" title="' . esc_attr_x( 'Search for:', 'label' ) . '" />
231 <input type="submit" class="search-submit" value="'. esc_attr_x( 'Search', 'submit button' ) .'" />
234 $form = '<form role="search" method="get" id="searchform" class="searchform" action="' . esc_url( home_url( '/' ) ) . '">
236 <label class="screen-reader-text" for="s">' . _x( 'Search for:', 'label' ) . '</label>
237 <input type="text" value="' . get_search_query() . '" name="s" id="s" />
238 <input type="submit" id="searchsubmit" value="'. esc_attr_x( 'Search', 'submit button' ) .'" />
245 * Filter the HTML output of the search form.
249 * @param string $form The search form HTML output.
251 $result = apply_filters( 'get_search_form', $form );
253 if ( null === $result )
263 * Display the Log In/Out link.
265 * Displays a link, which allows users to navigate to the Log In page to log in
266 * or log out depending on whether they are currently logged in.
270 * @param string $redirect Optional path to redirect to on login/logout.
271 * @param boolean $echo Default to echo and not return the link.
272 * @return string|null String when retrieving, null when displaying.
274 function wp_loginout($redirect = '', $echo = true) {
275 if ( ! is_user_logged_in() )
276 $link = '<a href="' . esc_url( wp_login_url($redirect) ) . '">' . __('Log in') . '</a>';
278 $link = '<a href="' . esc_url( wp_logout_url($redirect) ) . '">' . __('Log out') . '</a>';
282 * Filter the HTML output for the Log In/Log Out link.
286 * @param string $link The HTML link content.
288 echo apply_filters( 'loginout', $link );
290 /** This filter is documented in wp-includes/general-template.php */
291 return apply_filters( 'loginout', $link );
296 * Returns the Log Out URL.
298 * Returns the URL that allows the user to log out of the site.
302 * @param string $redirect Path to redirect to on logout.
303 * @return string A log out URL.
305 function wp_logout_url($redirect = '') {
306 $args = array( 'action' => 'logout' );
307 if ( !empty($redirect) ) {
308 $args['redirect_to'] = urlencode( $redirect );
311 $logout_url = add_query_arg($args, site_url('wp-login.php', 'login'));
312 $logout_url = wp_nonce_url( $logout_url, 'log-out' );
315 * Filter the logout URL.
319 * @param string $logout_url The Log Out URL.
320 * @param string $redirect Path to redirect to on logout.
322 return apply_filters( 'logout_url', $logout_url, $redirect );
326 * Returns the Log In URL.
328 * Returns the URL that allows the user to log in to the site.
332 * @param string $redirect Path to redirect to on login.
333 * @param bool $force_reauth Whether to force reauthorization, even if a cookie is present. Default is false.
334 * @return string A log in URL.
336 function wp_login_url($redirect = '', $force_reauth = false) {
337 $login_url = site_url('wp-login.php', 'login');
339 if ( !empty($redirect) )
340 $login_url = add_query_arg('redirect_to', urlencode($redirect), $login_url);
343 $login_url = add_query_arg('reauth', '1', $login_url);
346 * Filter the login URL.
349 * @since 4.2.0 The `$force_reauth` parameter was added.
351 * @param string $login_url The login URL.
352 * @param string $redirect The path to redirect to on login, if supplied.
353 * @param bool $force_reauth Whether to force reauthorization, even if a cookie is present.
355 return apply_filters( 'login_url', $login_url, $redirect, $force_reauth );
359 * Returns the user registration URL.
361 * Returns the URL that allows the user to register on the site.
365 * @return string User registration URL.
367 function wp_registration_url() {
369 * Filter the user registration URL.
373 * @param string $register The user registration URL.
375 return apply_filters( 'register_url', site_url( 'wp-login.php?action=register', 'login' ) );
379 * Provides a simple login form for use anywhere within WordPress. By default, it echoes
380 * the HTML immediately. Pass array('echo'=>false) to return the string instead.
384 * @param array $args Configuration options to modify the form output.
385 * @return string|null String when retrieving, null when displaying.
387 function wp_login_form( $args = array() ) {
390 'redirect' => ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], // Default redirect is back to the current page
391 'form_id' => 'loginform',
392 'label_username' => __( 'Username' ),
393 'label_password' => __( 'Password' ),
394 'label_remember' => __( 'Remember Me' ),
395 'label_log_in' => __( 'Log In' ),
396 'id_username' => 'user_login',
397 'id_password' => 'user_pass',
398 'id_remember' => 'rememberme',
399 'id_submit' => 'wp-submit',
401 'value_username' => '',
402 'value_remember' => false, // Set this to true to default the "Remember me" checkbox to checked
406 * Filter the default login form output arguments.
410 * @see wp_login_form()
412 * @param array $defaults An array of default login form arguments.
414 $args = wp_parse_args( $args, apply_filters( 'login_form_defaults', $defaults ) );
417 * Filter content to display at the top of the login form.
419 * The filter evaluates just following the opening form tag element.
423 * @param string $content Content to display. Default empty.
424 * @param array $args Array of login form arguments.
426 $login_form_top = apply_filters( 'login_form_top', '', $args );
429 * Filter content to display in the middle of the login form.
431 * The filter evaluates just following the location where the 'login-password'
432 * field is displayed.
436 * @param string $content Content to display. Default empty.
437 * @param array $args Array of login form arguments.
439 $login_form_middle = apply_filters( 'login_form_middle', '', $args );
442 * Filter content to display at the bottom of the login form.
444 * The filter evaluates just preceding the closing form tag element.
448 * @param string $content Content to display. Default empty.
449 * @param array $args Array of login form arguments.
451 $login_form_bottom = apply_filters( 'login_form_bottom', '', $args );
454 <form name="' . $args['form_id'] . '" id="' . $args['form_id'] . '" action="' . esc_url( site_url( 'wp-login.php', 'login_post' ) ) . '" method="post">
455 ' . $login_form_top . '
456 <p class="login-username">
457 <label for="' . esc_attr( $args['id_username'] ) . '">' . esc_html( $args['label_username'] ) . '</label>
458 <input type="text" name="log" id="' . esc_attr( $args['id_username'] ) . '" class="input" value="' . esc_attr( $args['value_username'] ) . '" size="20" />
460 <p class="login-password">
461 <label for="' . esc_attr( $args['id_password'] ) . '">' . esc_html( $args['label_password'] ) . '</label>
462 <input type="password" name="pwd" id="' . esc_attr( $args['id_password'] ) . '" class="input" value="" size="20" />
464 ' . $login_form_middle . '
465 ' . ( $args['remember'] ? '<p class="login-remember"><label><input name="rememberme" type="checkbox" id="' . esc_attr( $args['id_remember'] ) . '" value="forever"' . ( $args['value_remember'] ? ' checked="checked"' : '' ) . ' /> ' . esc_html( $args['label_remember'] ) . '</label></p>' : '' ) . '
466 <p class="login-submit">
467 <input type="submit" name="wp-submit" id="' . esc_attr( $args['id_submit'] ) . '" class="button-primary" value="' . esc_attr( $args['label_log_in'] ) . '" />
468 <input type="hidden" name="redirect_to" value="' . esc_url( $args['redirect'] ) . '" />
470 ' . $login_form_bottom . '
480 * Returns the Lost Password URL.
482 * Returns the URL that allows the user to retrieve the lost password
486 * @param string $redirect Path to redirect to on login.
487 * @return string Lost password URL.
489 function wp_lostpassword_url( $redirect = '' ) {
490 $args = array( 'action' => 'lostpassword' );
491 if ( !empty($redirect) ) {
492 $args['redirect_to'] = $redirect;
495 $lostpassword_url = add_query_arg( $args, network_site_url('wp-login.php', 'login') );
498 * Filter the Lost Password URL.
502 * @param string $lostpassword_url The lost password page URL.
503 * @param string $redirect The path to redirect to on login.
505 return apply_filters( 'lostpassword_url', $lostpassword_url, $redirect );
509 * Display the Registration or Admin link.
511 * Display a link which allows the user to navigate to the registration page if
512 * not logged in and registration is enabled or to the dashboard if logged in.
516 * @param string $before Text to output before the link. Default `<li>`.
517 * @param string $after Text to output after the link. Default `</li>`.
518 * @param boolean $echo Default to echo and not return the link.
519 * @return string|null String when retrieving, null when displaying.
521 function wp_register( $before = '<li>', $after = '</li>', $echo = true ) {
523 if ( ! is_user_logged_in() ) {
524 if ( get_option('users_can_register') )
525 $link = $before . '<a href="' . esc_url( wp_registration_url() ) . '">' . __('Register') . '</a>' . $after;
529 $link = $before . '<a href="' . admin_url() . '">' . __('Site Admin') . '</a>' . $after;
533 * Filter the HTML link to the Registration or Admin page.
535 * Users are sent to the admin page if logged-in, or the registration page
536 * if enabled and logged-out.
540 * @param string $link The HTML code for the link to the Registration or Admin page.
542 $link = apply_filters( 'register', $link );
552 * Theme container function for the 'wp_meta' action.
554 * The 'wp_meta' action can have several purposes, depending on how you use it,
555 * but one purpose might have been to allow for theme switching.
559 * @link https://core.trac.wordpress.org/ticket/1458 Explanation of 'wp_meta' action.
563 * Fires before displaying echoed content in the sidebar.
567 do_action( 'wp_meta' );
571 * Display information about the blog.
573 * @see get_bloginfo() For possible values for the parameter.
576 * @param string $show What to display.
578 function bloginfo( $show='' ) {
579 echo get_bloginfo( $show, 'display' );
583 * Retrieve information about the blog.
585 * Some show parameter values are deprecated and will be removed in future
586 * versions. These options will trigger the {@see _deprecated_argument()}
587 * function. The deprecated blog info options are listed in the function
590 * The possible values for the 'show' parameter are listed below.
592 * 1. url - Blog URI to homepage.
593 * 2. wpurl - Blog URI path to WordPress.
594 * 3. description - Secondary title
596 * The feed URL options can be retrieved from 'rdf_url' (RSS 0.91),
597 * 'rss_url' (RSS 1.0), 'rss2_url' (RSS 2.0), or 'atom_url' (Atom feed). The
598 * comment feeds can be retrieved from the 'comments_atom_url' (Atom comment
599 * feed) or 'comments_rss2_url' (RSS 2.0 comment feed).
603 * @param string $show Blog info to retrieve.
604 * @param string $filter How to filter what is retrieved.
605 * @return string Mostly string values, might be empty.
607 function get_bloginfo( $show = '', $filter = 'raw' ) {
610 case 'home' : // DEPRECATED
611 case 'siteurl' : // DEPRECATED
612 _deprecated_argument( __FUNCTION__, '2.2', sprintf(
613 /* translators: 1: 'siteurl'/'home' argument, 2: bloginfo() function name, 3: 'url' argument */
614 __( 'The %1$s option is deprecated for the family of %2$s functions. Use the %3$s option instead.' ),
615 '<code>' . $show . '</code>',
616 '<code>bloginfo()</code>',
620 $output = home_url();
623 $output = site_url();
626 $output = get_option('blogdescription');
629 $output = get_feed_link('rdf');
632 $output = get_feed_link('rss');
635 $output = get_feed_link('rss2');
638 $output = get_feed_link('atom');
640 case 'comments_atom_url':
641 $output = get_feed_link('comments_atom');
643 case 'comments_rss2_url':
644 $output = get_feed_link('comments_rss2');
647 $output = site_url( 'xmlrpc.php' );
649 case 'stylesheet_url':
650 $output = get_stylesheet_uri();
652 case 'stylesheet_directory':
653 $output = get_stylesheet_directory_uri();
655 case 'template_directory':
657 $output = get_template_directory_uri();
660 $output = get_option('admin_email');
663 $output = get_option('blog_charset');
664 if ('' == $output) $output = 'UTF-8';
667 $output = get_option('html_type');
671 $output = $wp_version;
674 $output = get_locale();
675 $output = str_replace('_', '-', $output);
677 case 'text_direction':
678 _deprecated_argument( __FUNCTION__, '2.2', sprintf(
679 /* translators: 1: 'text_direction' argument, 2: bloginfo() function name, 3: is_rtl() function name */
680 __( 'The %1$s option is deprecated for the family of %2$s functions. Use the %3$s function instead.' ),
681 '<code>' . $show . '</code>',
682 '<code>bloginfo()</code>',
683 '<code>is_rtl()</code>'
685 if ( function_exists( 'is_rtl' ) ) {
686 $output = is_rtl() ? 'rtl' : 'ltr';
693 $output = get_option('blogname');
698 if (strpos($show, 'url') === false &&
699 strpos($show, 'directory') === false &&
700 strpos($show, 'home') === false)
703 if ( 'display' == $filter ) {
706 * Filter the URL returned by get_bloginfo().
710 * @param mixed $output The URL returned by bloginfo().
711 * @param mixed $show Type of information requested.
713 $output = apply_filters( 'bloginfo_url', $output, $show );
716 * Filter the site information returned by get_bloginfo().
720 * @param mixed $output The requested non-URL site information.
721 * @param mixed $show Type of information requested.
723 $output = apply_filters( 'bloginfo', $output, $show );
731 * Display title tag with contents.
739 function _wp_render_title_tag() {
740 if ( ! current_theme_supports( 'title-tag' ) ) {
744 // This can only work internally on wp_head.
745 if ( ! did_action( 'wp_head' ) && ! doing_action( 'wp_head' ) ) {
749 echo '<title>' . wp_title( '|', false, 'right' ) . "</title>\n";
753 * Display or retrieve page title for all areas of blog.
755 * By default, the page title will display the separator before the page title,
756 * so that the blog title will be before the page title. This is not good for
757 * title display, since the blog title shows up on most tabs and not what is
758 * important, which is the page that the user is looking at.
760 * There are also SEO benefits to having the blog title after or to the 'right'
761 * or the page title. However, it is mostly common sense to have the blog title
762 * to the right with most browsers supporting tabs. You can achieve this by
763 * using the seplocation parameter and setting the value to 'right'. This change
764 * was introduced around 2.5.0, in case backwards compatibility of themes is
769 * @param string $sep Optional, default is '»'. How to separate the various items within the page title.
770 * @param bool $display Optional, default is true. Whether to display or retrieve title.
771 * @param string $seplocation Optional. Direction to display title, 'right'.
772 * @return string|null String on retrieve, null when displaying.
774 function wp_title($sep = '»', $display = true, $seplocation = '') {
775 global $wp_locale, $page, $paged;
777 $m = get_query_var('m');
778 $year = get_query_var('year');
779 $monthnum = get_query_var('monthnum');
780 $day = get_query_var('day');
781 $search = get_query_var('s');
784 $t_sep = '%WP_TITILE_SEP%'; // Temporary separator, for accurate flipping, if necessary
786 // If there is a post
787 if ( is_single() || ( is_home() && !is_front_page() ) || ( is_page() && !is_front_page() ) ) {
788 $title = single_post_title( '', false );
791 // If there's a post type archive
792 if ( is_post_type_archive() ) {
793 $post_type = get_query_var( 'post_type' );
794 if ( is_array( $post_type ) )
795 $post_type = reset( $post_type );
796 $post_type_object = get_post_type_object( $post_type );
797 if ( ! $post_type_object->has_archive )
798 $title = post_type_archive_title( '', false );
801 // If there's a category or tag
802 if ( is_category() || is_tag() ) {
803 $title = single_term_title( '', false );
806 // If there's a taxonomy
808 $term = get_queried_object();
810 $tax = get_taxonomy( $term->taxonomy );
811 $title = single_term_title( $tax->labels->name . $t_sep, false );
815 // If there's an author
816 if ( is_author() && ! is_post_type_archive() ) {
817 $author = get_queried_object();
819 $title = $author->display_name;
822 // Post type archives with has_archive should override terms.
823 if ( is_post_type_archive() && $post_type_object->has_archive )
824 $title = post_type_archive_title( '', false );
826 // If there's a month
827 if ( is_archive() && !empty($m) ) {
828 $my_year = substr($m, 0, 4);
829 $my_month = $wp_locale->get_month(substr($m, 4, 2));
830 $my_day = intval(substr($m, 6, 2));
831 $title = $my_year . ( $my_month ? $t_sep . $my_month : '' ) . ( $my_day ? $t_sep . $my_day : '' );
835 if ( is_archive() && !empty($year) ) {
837 if ( !empty($monthnum) )
838 $title .= $t_sep . $wp_locale->get_month($monthnum);
840 $title .= $t_sep . zeroise($day, 2);
845 /* translators: 1: separator, 2: search phrase */
846 $title = sprintf(__('Search Results %1$s %2$s'), $t_sep, strip_tags($search));
849 // If it's a 404 page
851 $title = __('Page not found');
855 if ( !empty($title) )
859 * Filter the parts of the page title.
863 * @param array $title_array Parts of the page title.
865 $title_array = apply_filters( 'wp_title_parts', explode( $t_sep, $title ) );
867 // Determines position of the separator and direction of the breadcrumb
868 if ( 'right' == $seplocation ) { // sep on right, so reverse the order
869 $title_array = array_reverse( $title_array );
870 $title = implode( " $sep ", $title_array ) . $prefix;
872 $title = $prefix . implode( " $sep ", $title_array );
875 if ( current_theme_supports( 'title-tag' ) && ! is_feed() ) {
876 $title .= get_bloginfo( 'name', 'display' );
878 $site_description = get_bloginfo( 'description', 'display' );
879 if ( $site_description && ( is_home() || is_front_page() ) ) {
880 $title .= " $sep $site_description";
883 if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) {
884 $title .= " $sep " . sprintf( __( 'Page %s' ), max( $paged, $page ) );
889 * Filter the text of the page title.
893 * @param string $title Page title.
894 * @param string $sep Title separator.
895 * @param string $seplocation Location of the separator (left or right).
897 $title = apply_filters( 'wp_title', $title, $sep, $seplocation );
908 * Display or retrieve page title for post.
910 * This is optimized for single.php template file for displaying the post title.
912 * It does not support placing the separator after the title, but by leaving the
913 * prefix parameter empty, you can set the title separator manually. The prefix
914 * does not automatically place a space between the prefix, so if there should
915 * be a space, the parameter value will need to have it at the end.
919 * @param string $prefix Optional. What to display before the title.
920 * @param bool $display Optional, default is true. Whether to display or retrieve title.
921 * @return string|null Title when retrieving, null when displaying or failure.
923 function single_post_title($prefix = '', $display = true) {
924 $_post = get_queried_object();
926 if ( !isset($_post->post_title) )
930 * Filter the page title for a single post.
934 * @param string $_post_title The single post page title.
935 * @param object $_post The current queried object as returned by get_queried_object().
937 $title = apply_filters( 'single_post_title', $_post->post_title, $_post );
939 echo $prefix . $title;
941 return $prefix . $title;
945 * Display or retrieve title for a post type archive.
947 * This is optimized for archive.php and archive-{$post_type}.php template files
948 * for displaying the title of the post type.
952 * @param string $prefix Optional. What to display before the title.
953 * @param bool $display Optional, default is true. Whether to display or retrieve title.
954 * @return string|null Title when retrieving, null when displaying or failure.
956 function post_type_archive_title( $prefix = '', $display = true ) {
957 if ( ! is_post_type_archive() )
960 $post_type = get_query_var( 'post_type' );
961 if ( is_array( $post_type ) )
962 $post_type = reset( $post_type );
964 $post_type_obj = get_post_type_object( $post_type );
967 * Filter the post type archive title.
971 * @param string $post_type_name Post type 'name' label.
972 * @param string $post_type Post type.
974 $title = apply_filters( 'post_type_archive_title', $post_type_obj->labels->name, $post_type );
977 echo $prefix . $title;
979 return $prefix . $title;
983 * Display or retrieve page title for category archive.
985 * This is useful for category template file or files, because it is optimized
986 * for category page title and with less overhead than {@link wp_title()}.
988 * It does not support placing the separator after the title, but by leaving the
989 * prefix parameter empty, you can set the title separator manually. The prefix
990 * does not automatically place a space between the prefix, so if there should
991 * be a space, the parameter value will need to have it at the end.
995 * @param string $prefix Optional. What to display before the title.
996 * @param bool $display Optional, default is true. Whether to display or retrieve title.
997 * @return string|null Title when retrieving, null when displaying or failure.
999 function single_cat_title( $prefix = '', $display = true ) {
1000 return single_term_title( $prefix, $display );
1004 * Display or retrieve page title for tag post archive.
1006 * Useful for tag template files for displaying the tag page title. It has less
1007 * overhead than {@link wp_title()}, because of its limited implementation.
1009 * It does not support placing the separator after the title, but by leaving the
1010 * prefix parameter empty, you can set the title separator manually. The prefix
1011 * does not automatically place a space between the prefix, so if there should
1012 * be a space, the parameter value will need to have it at the end.
1016 * @param string $prefix Optional. What to display before the title.
1017 * @param bool $display Optional, default is true. Whether to display or retrieve title.
1018 * @return string|null Title when retrieving, null when displaying or failure.
1020 function single_tag_title( $prefix = '', $display = true ) {
1021 return single_term_title( $prefix, $display );
1025 * Display or retrieve page title for taxonomy term archive.
1027 * Useful for taxonomy term template files for displaying the taxonomy term page title.
1028 * It has less overhead than {@link wp_title()}, because of its limited implementation.
1030 * It does not support placing the separator after the title, but by leaving the
1031 * prefix parameter empty, you can set the title separator manually. The prefix
1032 * does not automatically place a space between the prefix, so if there should
1033 * be a space, the parameter value will need to have it at the end.
1037 * @param string $prefix Optional. What to display before the title.
1038 * @param bool $display Optional, default is true. Whether to display or retrieve title.
1039 * @return string|null Title when retrieving, null when displaying or failure.
1041 function single_term_title( $prefix = '', $display = true ) {
1042 $term = get_queried_object();
1047 if ( is_category() ) {
1049 * Filter the category archive page title.
1053 * @param string $term_name Category name for archive being displayed.
1055 $term_name = apply_filters( 'single_cat_title', $term->name );
1056 } elseif ( is_tag() ) {
1058 * Filter the tag archive page title.
1062 * @param string $term_name Tag name for archive being displayed.
1064 $term_name = apply_filters( 'single_tag_title', $term->name );
1065 } elseif ( is_tax() ) {
1067 * Filter the custom taxonomy archive page title.
1071 * @param string $term_name Term name for archive being displayed.
1073 $term_name = apply_filters( 'single_term_title', $term->name );
1078 if ( empty( $term_name ) )
1082 echo $prefix . $term_name;
1084 return $prefix . $term_name;
1088 * Display or retrieve page title for post archive based on date.
1090 * Useful for when the template only needs to display the month and year, if
1091 * either are available. Optimized for just this purpose, so if it is all that
1092 * is needed, should be better than {@link wp_title()}.
1094 * It does not support placing the separator after the title, but by leaving the
1095 * prefix parameter empty, you can set the title separator manually. The prefix
1096 * does not automatically place a space between the prefix, so if there should
1097 * be a space, the parameter value will need to have it at the end.
1101 * @param string $prefix Optional. What to display before the title.
1102 * @param bool $display Optional, default is true. Whether to display or retrieve title.
1103 * @return string|null Title when retrieving, null when displaying or failure.
1105 function single_month_title($prefix = '', $display = true ) {
1108 $m = get_query_var('m');
1109 $year = get_query_var('year');
1110 $monthnum = get_query_var('monthnum');
1112 if ( !empty($monthnum) && !empty($year) ) {
1114 $my_month = $wp_locale->get_month($monthnum);
1115 } elseif ( !empty($m) ) {
1116 $my_year = substr($m, 0, 4);
1117 $my_month = $wp_locale->get_month(substr($m, 4, 2));
1120 if ( empty($my_month) )
1123 $result = $prefix . $my_month . $prefix . $my_year;
1131 * Display the archive title based on the queried object.
1135 * @see get_the_archive_title()
1137 * @param string $before Optional. Content to prepend to the title. Default empty.
1138 * @param string $after Optional. Content to append to the title. Default empty.
1140 function the_archive_title( $before = '', $after = '' ) {
1141 $title = get_the_archive_title();
1143 if ( ! empty( $title ) ) {
1144 echo $before . $title . $after;
1149 * Retrieve the archive title based on the queried object.
1153 * @return string Archive title.
1155 function get_the_archive_title() {
1156 if ( is_category() ) {
1157 $title = sprintf( __( 'Category: %s' ), single_cat_title( '', false ) );
1158 } elseif ( is_tag() ) {
1159 $title = sprintf( __( 'Tag: %s' ), single_tag_title( '', false ) );
1160 } elseif ( is_author() ) {
1161 $title = sprintf( __( 'Author: %s' ), '<span class="vcard">' . get_the_author() . '</span>' );
1162 } elseif ( is_year() ) {
1163 $title = sprintf( __( 'Year: %s' ), get_the_date( _x( 'Y', 'yearly archives date format' ) ) );
1164 } elseif ( is_month() ) {
1165 $title = sprintf( __( 'Month: %s' ), get_the_date( _x( 'F Y', 'monthly archives date format' ) ) );
1166 } elseif ( is_day() ) {
1167 $title = sprintf( __( 'Day: %s' ), get_the_date( _x( 'F j, Y', 'daily archives date format' ) ) );
1168 } elseif ( is_tax( 'post_format' ) ) {
1169 if ( is_tax( 'post_format', 'post-format-aside' ) ) {
1170 $title = _x( 'Asides', 'post format archive title' );
1171 } elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) {
1172 $title = _x( 'Galleries', 'post format archive title' );
1173 } elseif ( is_tax( 'post_format', 'post-format-image' ) ) {
1174 $title = _x( 'Images', 'post format archive title' );
1175 } elseif ( is_tax( 'post_format', 'post-format-video' ) ) {
1176 $title = _x( 'Videos', 'post format archive title' );
1177 } elseif ( is_tax( 'post_format', 'post-format-quote' ) ) {
1178 $title = _x( 'Quotes', 'post format archive title' );
1179 } elseif ( is_tax( 'post_format', 'post-format-link' ) ) {
1180 $title = _x( 'Links', 'post format archive title' );
1181 } elseif ( is_tax( 'post_format', 'post-format-status' ) ) {
1182 $title = _x( 'Statuses', 'post format archive title' );
1183 } elseif ( is_tax( 'post_format', 'post-format-audio' ) ) {
1184 $title = _x( 'Audio', 'post format archive title' );
1185 } elseif ( is_tax( 'post_format', 'post-format-chat' ) ) {
1186 $title = _x( 'Chats', 'post format archive title' );
1188 } elseif ( is_post_type_archive() ) {
1189 $title = sprintf( __( 'Archives: %s' ), post_type_archive_title( '', false ) );
1190 } elseif ( is_tax() ) {
1191 $tax = get_taxonomy( get_queried_object()->taxonomy );
1192 /* translators: 1: Taxonomy singular name, 2: Current taxonomy term */
1193 $title = sprintf( __( '%1$s: %2$s' ), $tax->labels->singular_name, single_term_title( '', false ) );
1195 $title = __( 'Archives' );
1199 * Filter the archive title.
1203 * @param string $title Archive title to be displayed.
1205 return apply_filters( 'get_the_archive_title', $title );
1209 * Display category, tag, or term description.
1213 * @see get_the_archive_description()
1215 * @param string $before Optional. Content to prepend to the description. Default empty.
1216 * @param string $after Optional. Content to append to the description. Default empty.
1218 function the_archive_description( $before = '', $after = '' ) {
1219 $description = get_the_archive_description();
1220 if ( $description ) {
1221 echo $before . $description . $after;
1226 * Retrieve category, tag, or term description.
1230 * @return string Archive description.
1232 function get_the_archive_description() {
1234 * Filter the archive description.
1238 * @see term_description()
1240 * @param string $description Archive description to be displayed.
1242 return apply_filters( 'get_the_archive_description', term_description() );
1246 * Retrieve archive link content based on predefined or custom code.
1248 * The format can be one of four styles. The 'link' for head element, 'option'
1249 * for use in the select element, 'html' for use in list (either ol or ul HTML
1250 * elements). Custom content is also supported using the before and after
1253 * The 'link' format uses the `<link>` HTML element with the **archives**
1254 * relationship. The before and after parameters are not used. The text
1255 * parameter is used to describe the link.
1257 * The 'option' format uses the option HTML element for use in select element.
1258 * The value is the url parameter and the before and after parameters are used
1259 * between the text description.
1261 * The 'html' format, which is the default, uses the li HTML element for use in
1262 * the list HTML elements. The before parameter is before the link and the after
1263 * parameter is after the closing link.
1265 * The custom format uses the before parameter before the link ('a' HTML
1266 * element) and the after parameter after the closing link tag. If the above
1267 * three values for the format are not used, then custom format is assumed.
1271 * @todo Properly document optional arguments as such
1273 * @param string $url URL to archive.
1274 * @param string $text Archive text description.
1275 * @param string $format Optional, default is 'html'. Can be 'link', 'option', 'html', or custom.
1276 * @param string $before Optional.
1277 * @param string $after Optional.
1278 * @return string HTML link content for archive.
1280 function get_archives_link($url, $text, $format = 'html', $before = '', $after = '') {
1281 $text = wptexturize($text);
1282 $url = esc_url($url);
1284 if ('link' == $format)
1285 $link_html = "\t<link rel='archives' title='" . esc_attr( $text ) . "' href='$url' />\n";
1286 elseif ('option' == $format)
1287 $link_html = "\t<option value='$url'>$before $text $after</option>\n";
1288 elseif ('html' == $format)
1289 $link_html = "\t<li>$before<a href='$url'>$text</a>$after</li>\n";
1291 $link_html = "\t$before<a href='$url'>$text</a>$after\n";
1294 * Filter the archive link content.
1298 * @param string $link_html The archive HTML link content.
1300 $link_html = apply_filters( 'get_archives_link', $link_html );
1306 * Display archive links based on type and format.
1310 * @see get_archives_link()
1312 * @param string|array $args {
1313 * Default archive links arguments. Optional.
1315 * @type string $type Type of archive to retrieve. Accepts 'daily', 'weekly', 'monthly',
1316 * 'yearly', 'postbypost', or 'alpha'. Both 'postbypost' and 'alpha'
1317 * display the same archive link list as well as post titles instead
1318 * of displaying dates. The difference between the two is that 'alpha'
1319 * will order by post title and 'postbypost' will order by post date.
1320 * Default 'monthly'.
1321 * @type string|int $limit Number of links to limit the query to. Default empty (no limit).
1322 * @type string $format Format each link should take using the $before and $after args.
1323 * Accepts 'link' (`<link>` tag), 'option' (`<option>` tag), 'html'
1324 * (`<li>` tag), or a custom format, which generates a link anchor
1325 * with $before preceding and $after succeeding. Default 'html'.
1326 * @type string $before Markup to prepend to the beginning of each link. Default empty.
1327 * @type string $after Markup to append to the end of each link. Default empty.
1328 * @type bool $show_post_count Whether to display the post count alongside the link. Default false.
1329 * @type bool|int $echo Whether to echo or return the links list. Default 1|true to echo.
1330 * @type string $order Whether to use ascending or descending order. Accepts 'ASC', or 'DESC'.
1333 * @return string|null String when retrieving, null when displaying.
1335 function wp_get_archives( $args = '' ) {
1336 global $wpdb, $wp_locale;
1339 'type' => 'monthly', 'limit' => '',
1340 'format' => 'html', 'before' => '',
1341 'after' => '', 'show_post_count' => false,
1342 'echo' => 1, 'order' => 'DESC',
1345 $r = wp_parse_args( $args, $defaults );
1347 if ( '' == $r['type'] ) {
1348 $r['type'] = 'monthly';
1351 if ( ! empty( $r['limit'] ) ) {
1352 $r['limit'] = absint( $r['limit'] );
1353 $r['limit'] = ' LIMIT ' . $r['limit'];
1356 $order = strtoupper( $r['order'] );
1357 if ( $order !== 'ASC' ) {
1361 // this is what will separate dates on weekly archive links
1362 $archive_week_separator = '–';
1364 // over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride
1365 $archive_date_format_over_ride = 0;
1367 // options for daily archive (only if you over-ride the general date format)
1368 $archive_day_date_format = 'Y/m/d';
1370 // options for weekly archive (only if you over-ride the general date format)
1371 $archive_week_start_date_format = 'Y/m/d';
1372 $archive_week_end_date_format = 'Y/m/d';
1374 if ( ! $archive_date_format_over_ride ) {
1375 $archive_day_date_format = get_option( 'date_format' );
1376 $archive_week_start_date_format = get_option( 'date_format' );
1377 $archive_week_end_date_format = get_option( 'date_format' );
1381 * Filter the SQL WHERE clause for retrieving archives.
1385 * @param string $sql_where Portion of SQL query containing the WHERE clause.
1386 * @param array $r An array of default arguments.
1388 $where = apply_filters( 'getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r );
1391 * Filter the SQL JOIN clause for retrieving archives.
1395 * @param string $sql_join Portion of SQL query containing JOIN clause.
1396 * @param array $r An array of default arguments.
1398 $join = apply_filters( 'getarchives_join', '', $r );
1402 $last_changed = wp_cache_get( 'last_changed', 'posts' );
1403 if ( ! $last_changed ) {
1404 $last_changed = microtime();
1405 wp_cache_set( 'last_changed', $last_changed, 'posts' );
1408 $limit = $r['limit'];
1410 if ( 'monthly' == $r['type'] ) {
1411 $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 $order $limit";
1412 $key = md5( $query );
1413 $key = "wp_get_archives:$key:$last_changed";
1414 if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
1415 $results = $wpdb->get_results( $query );
1416 wp_cache_set( $key, $results, 'posts' );
1419 $after = $r['after'];
1420 foreach ( (array) $results as $result ) {
1421 $url = get_month_link( $result->year, $result->month );
1422 /* translators: 1: month name, 2: 4-digit year */
1423 $text = sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $result->month ), $result->year );
1424 if ( $r['show_post_count'] ) {
1425 $r['after'] = ' (' . $result->posts . ')' . $after;
1427 $output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
1430 } elseif ( 'yearly' == $r['type'] ) {
1431 $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 $order $limit";
1432 $key = md5( $query );
1433 $key = "wp_get_archives:$key:$last_changed";
1434 if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
1435 $results = $wpdb->get_results( $query );
1436 wp_cache_set( $key, $results, 'posts' );
1439 $after = $r['after'];
1440 foreach ( (array) $results as $result) {
1441 $url = get_year_link( $result->year );
1442 $text = sprintf( '%d', $result->year );
1443 if ( $r['show_post_count'] ) {
1444 $r['after'] = ' (' . $result->posts . ')' . $after;
1446 $output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
1449 } elseif ( 'daily' == $r['type'] ) {
1450 $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 $order $limit";
1451 $key = md5( $query );
1452 $key = "wp_get_archives:$key:$last_changed";
1453 if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
1454 $results = $wpdb->get_results( $query );
1455 wp_cache_set( $key, $results, 'posts' );
1458 $after = $r['after'];
1459 foreach ( (array) $results as $result ) {
1460 $url = get_day_link( $result->year, $result->month, $result->dayofmonth );
1461 $date = sprintf( '%1$d-%2$02d-%3$02d 00:00:00', $result->year, $result->month, $result->dayofmonth );
1462 $text = mysql2date( $archive_day_date_format, $date );
1463 if ( $r['show_post_count'] ) {
1464 $r['after'] = ' (' . $result->posts . ')' . $after;
1466 $output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
1469 } elseif ( 'weekly' == $r['type'] ) {
1470 $week = _wp_mysql_week( '`post_date`' );
1471 $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` $order $limit";
1472 $key = md5( $query );
1473 $key = "wp_get_archives:$key:$last_changed";
1474 if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
1475 $results = $wpdb->get_results( $query );
1476 wp_cache_set( $key, $results, 'posts' );
1480 $after = $r['after'];
1481 foreach ( (array) $results as $result ) {
1482 if ( $result->week != $arc_w_last ) {
1483 $arc_year = $result->yr;
1484 $arc_w_last = $result->week;
1485 $arc_week = get_weekstartend( $result->yyyymmdd, get_option( 'start_of_week' ) );
1486 $arc_week_start = date_i18n( $archive_week_start_date_format, $arc_week['start'] );
1487 $arc_week_end = date_i18n( $archive_week_end_date_format, $arc_week['end'] );
1488 $url = sprintf( '%1$s/%2$s%3$sm%4$s%5$s%6$sw%7$s%8$d', home_url(), '', '?', '=', $arc_year, '&', '=', $result->week );
1489 $text = $arc_week_start . $archive_week_separator . $arc_week_end;
1490 if ( $r['show_post_count'] ) {
1491 $r['after'] = ' (' . $result->posts . ')' . $after;
1493 $output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
1497 } elseif ( ( 'postbypost' == $r['type'] ) || ('alpha' == $r['type'] ) ) {
1498 $orderby = ( 'alpha' == $r['type'] ) ? 'post_title ASC ' : 'post_date DESC, ID DESC ';
1499 $query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit";
1500 $key = md5( $query );
1501 $key = "wp_get_archives:$key:$last_changed";
1502 if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
1503 $results = $wpdb->get_results( $query );
1504 wp_cache_set( $key, $results, 'posts' );
1507 foreach ( (array) $results as $result ) {
1508 if ( $result->post_date != '0000-00-00 00:00:00' ) {
1509 $url = get_permalink( $result );
1510 if ( $result->post_title ) {
1511 /** This filter is documented in wp-includes/post-template.php */
1512 $text = strip_tags( apply_filters( 'the_title', $result->post_title, $result->ID ) );
1514 $text = $result->ID;
1516 $output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
1529 * Get number of days since the start of the week.
1533 * @param int $num Number of day.
1534 * @return int Days since the start of the week.
1536 function calendar_week_mod($num) {
1538 return ($num - $base*floor($num/$base));
1542 * Display calendar with days that have posts as links.
1544 * The calendar is cached, which will be retrieved, if it exists. If there are
1545 * no posts for the month, then it will not be displayed.
1549 * @param bool $initial Optional, default is true. Use initial calendar names.
1550 * @param bool $echo Optional, default is true. Set to false for return.
1551 * @return string|null String when retrieving, null when displaying.
1553 function get_calendar($initial = true, $echo = true) {
1554 global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
1556 $key = md5( $m . $monthnum . $year );
1557 if ( $cache = wp_cache_get( 'get_calendar', 'calendar' ) ) {
1558 if ( is_array($cache) && isset( $cache[ $key ] ) ) {
1560 /** This filter is documented in wp-includes/general-template.php */
1561 echo apply_filters( 'get_calendar', $cache[$key] );
1564 /** This filter is documented in wp-includes/general-template.php */
1565 return apply_filters( 'get_calendar', $cache[$key] );
1570 if ( !is_array($cache) )
1573 // Quick check. If we have no posts at all, abort!
1575 $gotsome = $wpdb->get_var("SELECT 1 as test FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1");
1577 $cache[ $key ] = '';
1578 wp_cache_set( 'get_calendar', $cache, 'calendar' );
1583 if ( isset($_GET['w']) )
1584 $w = ''.intval($_GET['w']);
1586 // week_begins = 0 stands for Sunday
1587 $week_begins = intval(get_option('start_of_week'));
1589 // Let's figure out when we are
1590 if ( !empty($monthnum) && !empty($year) ) {
1591 $thismonth = ''.zeroise(intval($monthnum), 2);
1592 $thisyear = ''.intval($year);
1593 } elseif ( !empty($w) ) {
1594 // We need to get the month from MySQL
1595 $thisyear = ''.intval(substr($m, 0, 4));
1596 $d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's
1597 $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')");
1598 } elseif ( !empty($m) ) {
1599 $thisyear = ''.intval(substr($m, 0, 4));
1600 if ( strlen($m) < 6 )
1603 $thismonth = ''.zeroise(intval(substr($m, 4, 2)), 2);
1605 $thisyear = gmdate('Y', current_time('timestamp'));
1606 $thismonth = gmdate('m', current_time('timestamp'));
1609 $unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear);
1610 $last_day = date('t', $unixmonth);
1612 // Get the next and previous month and year with at least one post
1613 $previous = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
1615 WHERE post_date < '$thisyear-$thismonth-01'
1616 AND post_type = 'post' AND post_status = 'publish'
1617 ORDER BY post_date DESC
1619 $next = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
1621 WHERE post_date > '$thisyear-$thismonth-{$last_day} 23:59:59'
1622 AND post_type = 'post' AND post_status = 'publish'
1623 ORDER BY post_date ASC
1626 /* translators: Calendar caption: 1: month name, 2: 4-digit year */
1627 $calendar_caption = _x('%1$s %2$s', 'calendar caption');
1628 $calendar_output = '<table id="wp-calendar">
1629 <caption>' . sprintf($calendar_caption, $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '</caption>
1635 for ( $wdcount=0; $wdcount<=6; $wdcount++ ) {
1636 $myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7);
1639 foreach ( $myweek as $wd ) {
1640 $day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
1641 $wd = esc_attr($wd);
1642 $calendar_output .= "\n\t\t<th scope=\"col\" title=\"$wd\">$day_name</th>";
1645 $calendar_output .= '
1653 $calendar_output .= "\n\t\t".'<td colspan="3" id="prev"><a href="' . get_month_link($previous->year, $previous->month) . '">« ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . '</a></td>';
1655 $calendar_output .= "\n\t\t".'<td colspan="3" id="prev" class="pad"> </td>';
1658 $calendar_output .= "\n\t\t".'<td class="pad"> </td>';
1661 $calendar_output .= "\n\t\t".'<td colspan="3" id="next"><a href="' . get_month_link($next->year, $next->month) . '">' . $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)) . ' »</a></td>';
1663 $calendar_output .= "\n\t\t".'<td colspan="3" id="next" class="pad"> </td>';
1666 $calendar_output .= '
1673 $daywithpost = array();
1675 // Get days with posts
1676 $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
1677 FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00'
1678 AND post_type = 'post' AND post_status = 'publish'
1679 AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'", ARRAY_N);
1680 if ( $dayswithposts ) {
1681 foreach ( (array) $dayswithposts as $daywith ) {
1682 $daywithpost[] = $daywith[0];
1686 if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'camino') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false)
1687 $ak_title_separator = "\n";
1689 $ak_title_separator = ', ';
1691 $ak_titles_for_day = array();
1692 $ak_post_titles = $wpdb->get_results("SELECT ID, post_title, DAYOFMONTH(post_date) as dom "
1693 ."FROM $wpdb->posts "
1694 ."WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' "
1695 ."AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59' "
1696 ."AND post_type = 'post' AND post_status = 'publish'"
1698 if ( $ak_post_titles ) {
1699 foreach ( (array) $ak_post_titles as $ak_post_title ) {
1701 /** This filter is documented in wp-includes/post-template.php */
1702 $post_title = esc_attr( apply_filters( 'the_title', $ak_post_title->post_title, $ak_post_title->ID ) );
1704 if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) )
1705 $ak_titles_for_day['day_'.$ak_post_title->dom] = '';
1706 if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one
1707 $ak_titles_for_day["$ak_post_title->dom"] = $post_title;
1709 $ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . $post_title;
1713 // See how much we should pad in the beginning
1714 $pad = calendar_week_mod(date('w', $unixmonth)-$week_begins);
1716 $calendar_output .= "\n\t\t".'<td colspan="'. esc_attr($pad) .'" class="pad"> </td>';
1718 $daysinmonth = intval(date('t', $unixmonth));
1719 for ( $day = 1; $day <= $daysinmonth; ++$day ) {
1720 if ( isset($newrow) && $newrow )
1721 $calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
1724 if ( $day == gmdate('j', current_time('timestamp')) && $thismonth == gmdate('m', current_time('timestamp')) && $thisyear == gmdate('Y', current_time('timestamp')) )
1725 $calendar_output .= '<td id="today">';
1727 $calendar_output .= '<td>';
1729 if ( in_array($day, $daywithpost) ) // any posts today?
1730 $calendar_output .= '<a href="' . get_day_link( $thisyear, $thismonth, $day ) . '" title="' . esc_attr( $ak_titles_for_day[ $day ] ) . "\">$day</a>";
1732 $calendar_output .= $day;
1733 $calendar_output .= '</td>';
1735 if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) )
1739 $pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins);
1740 if ( $pad != 0 && $pad != 7 )
1741 $calendar_output .= "\n\t\t".'<td class="pad" colspan="'. esc_attr($pad) .'"> </td>';
1743 $calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>";
1745 $cache[ $key ] = $calendar_output;
1746 wp_cache_set( 'get_calendar', $cache, 'calendar' );
1750 * Filter the HTML calendar output.
1754 * @param string $calendar_output HTML output of the calendar.
1756 echo apply_filters( 'get_calendar', $calendar_output );
1758 /** This filter is documented in wp-includes/general-template.php */
1759 return apply_filters( 'get_calendar', $calendar_output );
1765 * Purge the cached results of get_calendar.
1770 function delete_get_calendar_cache() {
1771 wp_cache_delete( 'get_calendar', 'calendar' );
1775 * Display all of the allowed tags in HTML format with attributes.
1777 * This is useful for displaying in the comment area, which elements and
1778 * attributes are supported. As well as any plugins which want to display it.
1781 * @uses $allowedtags
1783 * @return string HTML allowed tags entity encoded.
1785 function allowed_tags() {
1786 global $allowedtags;
1788 foreach ( (array) $allowedtags as $tag => $attributes ) {
1789 $allowed .= '<'.$tag;
1790 if ( 0 < count($attributes) ) {
1791 foreach ( $attributes as $attribute => $limits ) {
1792 $allowed .= ' '.$attribute.'=""';
1797 return htmlentities($allowed);
1800 /***** Date/Time tags *****/
1803 * Outputs the date in iso8601 format for xml files.
1807 function the_date_xml() {
1808 echo mysql2date( 'Y-m-d', get_post()->post_date, false );
1812 * Display or Retrieve the date the current post was written (once per date)
1814 * Will only output the date if the current post's date is different from the
1815 * previous one output.
1817 * i.e. Only one date listing will show per day worth of posts shown in the loop, even if the
1818 * function is called several times for each post.
1820 * HTML output can be filtered with 'the_date'.
1821 * Date string output can be filtered with 'get_the_date'.
1825 * @param string $d Optional. PHP date format defaults to the date_format option if not specified.
1826 * @param string $before Optional. Output before the date.
1827 * @param string $after Optional. Output after the date.
1828 * @param bool $echo Optional, default is display. Whether to echo the date or return it.
1829 * @return string|null Null if displaying, string if retrieving.
1831 function the_date( $d = '', $before = '', $after = '', $echo = true ) {
1832 global $currentday, $previousday;
1834 if ( $currentday != $previousday ) {
1835 $the_date = $before . get_the_date( $d ) . $after;
1836 $previousday = $currentday;
1839 * Filter the date a post was published for display.
1843 * @param string $the_date The formatted date string.
1844 * @param string $d PHP date format. Defaults to 'date_format' option
1846 * @param string $before HTML output before the date.
1847 * @param string $after HTML output after the date.
1849 $the_date = apply_filters( 'the_date', $the_date, $d, $before, $after );
1861 * Retrieve the date on which the post was written.
1863 * Unlike the_date() this function will always return the date.
1864 * Modify output with 'get_the_date' filter.
1868 * @param string $d Optional. PHP date format defaults to the date_format option if not specified.
1869 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default current post.
1870 * @return false|string Date the current post was written. False on failure.
1872 function get_the_date( $d = '', $post = null ) {
1873 $post = get_post( $post );
1880 $the_date = mysql2date( get_option( 'date_format' ), $post->post_date );
1882 $the_date = mysql2date( $d, $post->post_date );
1886 * Filter the date a post was published.
1890 * @param string $the_date The formatted date.
1891 * @param string $d PHP date format. Defaults to 'date_format' option
1893 * @param int|WP_Post $post The post object or ID.
1895 return apply_filters( 'get_the_date', $the_date, $d, $post );
1899 * Display the date on which the post was last modified.
1903 * @param string $d Optional. PHP date format defaults to the date_format option if not specified.
1904 * @param string $before Optional. Output before the date.
1905 * @param string $after Optional. Output after the date.
1906 * @param bool $echo Optional, default is display. Whether to echo the date or return it.
1907 * @return string|null Null if displaying, string if retrieving.
1909 function the_modified_date($d = '', $before='', $after='', $echo = true) {
1911 $the_modified_date = $before . get_the_modified_date($d) . $after;
1914 * Filter the date a post was last modified for display.
1918 * @param string $the_modified_date The last modified date.
1919 * @param string $d PHP date format. Defaults to 'date_format' option
1921 * @param string $before HTML output before the date.
1922 * @param string $after HTML output after the date.
1924 $the_modified_date = apply_filters( 'the_modified_date', $the_modified_date, $d, $before, $after );
1927 echo $the_modified_date;
1929 return $the_modified_date;
1934 * Retrieve the date on which the post was last modified.
1938 * @param string $d Optional. PHP date format. Defaults to the "date_format" option
1941 function get_the_modified_date($d = '') {
1943 $the_time = get_post_modified_time(get_option('date_format'), null, null, true);
1945 $the_time = get_post_modified_time($d, null, null, true);
1948 * Filter the date a post was last modified.
1952 * @param string $the_time The formatted date.
1953 * @param string $d PHP date format. Defaults to value specified in
1954 * 'date_format' option.
1956 return apply_filters( 'get_the_modified_date', $the_time, $d );
1960 * Display the time at which the post was written.
1964 * @param string $d Either 'G', 'U', or php date format.
1966 function the_time( $d = '' ) {
1968 * Filter the time a post was written for display.
1972 * @param string $get_the_time The formatted time.
1973 * @param string $d The time format. Accepts 'G', 'U',
1974 * or php date format.
1976 echo apply_filters( 'the_time', get_the_time( $d ), $d );
1980 * Retrieve the time at which the post was written.
1984 * @param string $d Optional. Format to use for retrieving the time the post
1985 * was written. Either 'G', 'U', or php date format defaults
1986 * to the value specified in the time_format option. Default empty.
1987 * @param int|WP_Post $post WP_Post object or ID. Default is global $post object.
1988 * @return false|string Formatted date string or Unix timestamp. False on failure.
1990 function get_the_time( $d = '', $post = null ) {
1991 $post = get_post($post);
1998 $the_time = get_post_time(get_option('time_format'), false, $post, true);
2000 $the_time = get_post_time($d, false, $post, true);
2003 * Filter the time a post was written.
2007 * @param string $the_time The formatted time.
2008 * @param string $d Format to use for retrieving the time the post was written.
2009 * Accepts 'G', 'U', or php date format value specified
2010 * in 'time_format' option. Default empty.
2011 * @param int|WP_Post $post WP_Post object or ID.
2013 return apply_filters( 'get_the_time', $the_time, $d, $post );
2017 * Retrieve the time at which the post was written.
2021 * @param string $d Optional. Format to use for retrieving the time the post
2022 * was written. Either 'G', 'U', or php date format. Default 'U'.
2023 * @param bool $gmt Optional. Whether to retrieve the GMT time. Default false.
2024 * @param int|WP_Post $post WP_Post object or ID. Default is global $post object.
2025 * @param bool $translate Whether to translate the time string. Default false.
2026 * @return false|string|int Formatted date string or Unix timestamp. False on failure.
2028 function get_post_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
2029 $post = get_post($post);
2036 $time = $post->post_date_gmt;
2038 $time = $post->post_date;
2040 $time = mysql2date($d, $time, $translate);
2043 * Filter the localized time a post was written.
2047 * @param string $time The formatted time.
2048 * @param string $d Format to use for retrieving the time the post was written.
2049 * Accepts 'G', 'U', or php date format. Default 'U'.
2050 * @param bool $gmt Whether to retrieve the GMT time. Default false.
2052 return apply_filters( 'get_post_time', $time, $d, $gmt );
2056 * Display the time at which the post was last modified.
2060 * @param string $d Optional Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
2062 function the_modified_time($d = '') {
2064 * Filter the localized time a post was last modified, for display.
2068 * @param string $get_the_modified_time The formatted time.
2069 * @param string $d The time format. Accepts 'G', 'U',
2070 * or php date format. Defaults to value
2071 * specified in 'time_format' option.
2073 echo apply_filters( 'the_modified_time', get_the_modified_time($d), $d );
2077 * Retrieve the time at which the post was last modified.
2081 * @param string $d Optional Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
2084 function get_the_modified_time($d = '') {
2086 $the_time = get_post_modified_time(get_option('time_format'), null, null, true);
2088 $the_time = get_post_modified_time($d, null, null, true);
2091 * Filter the localized time a post was last modified.
2095 * @param string $the_time The formatted time.
2096 * @param string $d Format to use for retrieving the time the post was
2097 * written. Accepts 'G', 'U', or php date format. Defaults
2098 * to value specified in 'time_format' option.
2100 return apply_filters( 'get_the_modified_time', $the_time, $d );
2104 * Retrieve the time at which the post was last modified.
2108 * @param string $d Optional. Format to use for retrieving the time the post
2109 * was modified. Either 'G', 'U', or php date format. Default 'U'.
2110 * @param bool $gmt Optional. Whether to retrieve the GMT time. Default false.
2111 * @param int|WP_Post $post WP_Post object or ID. Default is global $post object.
2112 * @param bool $translate Whether to translate the time string. Default false.
2113 * @return false|string Formatted date string or Unix timestamp. False on failure.
2115 function get_post_modified_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
2116 $post = get_post($post);
2123 $time = $post->post_modified_gmt;
2125 $time = $post->post_modified;
2126 $time = mysql2date($d, $time, $translate);
2129 * Filter the localized time a post was last modified.
2133 * @param string $time The formatted time.
2134 * @param string $d The date format. Accepts 'G', 'U', or php date format. Default 'U'.
2135 * @param bool $gmt Whether to return the GMT time. Default false.
2137 return apply_filters( 'get_post_modified_time', $time, $d, $gmt );
2141 * Display the weekday on which the post was written.
2146 function the_weekday() {
2148 $the_weekday = $wp_locale->get_weekday( mysql2date( 'w', get_post()->post_date, false ) );
2151 * Filter the weekday on which the post was written, for display.
2155 * @param string $the_weekday
2157 $the_weekday = apply_filters( 'the_weekday', $the_weekday );
2162 * Display the weekday on which the post was written.
2164 * Will only output the weekday if the current post's weekday is different from
2165 * the previous one output.
2169 * @param string $before Optional Output before the date.
2170 * @param string $after Optional Output after the date.
2172 function the_weekday_date($before='',$after='') {
2173 global $wp_locale, $currentday, $previousweekday;
2174 $the_weekday_date = '';
2175 if ( $currentday != $previousweekday ) {
2176 $the_weekday_date .= $before;
2177 $the_weekday_date .= $wp_locale->get_weekday( mysql2date( 'w', get_post()->post_date, false ) );
2178 $the_weekday_date .= $after;
2179 $previousweekday = $currentday;
2183 * Filter the localized date on which the post was written, for display.
2187 * @param string $the_weekday_date
2188 * @param string $before The HTML to output before the date.
2189 * @param string $after The HTML to output after the date.
2191 $the_weekday_date = apply_filters( 'the_weekday_date', $the_weekday_date, $before, $after );
2192 echo $the_weekday_date;
2196 * Fire the wp_head action
2200 function wp_head() {
2202 * Print scripts or data in the head tag on the front end.
2206 do_action( 'wp_head' );
2210 * Fire the wp_footer action
2214 function wp_footer() {
2216 * Print scripts or data before the closing body tag on the front end.
2220 do_action( 'wp_footer' );
2224 * Display the links to the general feeds.
2228 * @param array $args Optional arguments.
2230 function feed_links( $args = array() ) {
2231 if ( !current_theme_supports('automatic-feed-links') )
2235 /* translators: Separator between blog name and feed type in feed links */
2236 'separator' => _x('»', 'feed link'),
2237 /* translators: 1: blog title, 2: separator (raquo) */
2238 'feedtitle' => __('%1$s %2$s Feed'),
2239 /* translators: 1: blog title, 2: separator (raquo) */
2240 'comstitle' => __('%1$s %2$s Comments Feed'),
2243 $args = wp_parse_args( $args, $defaults );
2245 echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( sprintf( $args['feedtitle'], get_bloginfo('name'), $args['separator'] ) ) . '" href="' . esc_url( get_feed_link() ) . "\" />\n";
2246 echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( sprintf( $args['comstitle'], get_bloginfo('name'), $args['separator'] ) ) . '" href="' . esc_url( get_feed_link( 'comments_' . get_default_feed() ) ) . "\" />\n";
2250 * Display the links to the extra feeds such as category feeds.
2254 * @param array $args Optional arguments.
2256 function feed_links_extra( $args = array() ) {
2258 /* translators: Separator between blog name and feed type in feed links */
2259 'separator' => _x('»', 'feed link'),
2260 /* translators: 1: blog name, 2: separator(raquo), 3: post title */
2261 'singletitle' => __('%1$s %2$s %3$s Comments Feed'),
2262 /* translators: 1: blog name, 2: separator(raquo), 3: category name */
2263 'cattitle' => __('%1$s %2$s %3$s Category Feed'),
2264 /* translators: 1: blog name, 2: separator(raquo), 3: tag name */
2265 'tagtitle' => __('%1$s %2$s %3$s Tag Feed'),
2266 /* translators: 1: blog name, 2: separator(raquo), 3: author name */
2267 'authortitle' => __('%1$s %2$s Posts by %3$s Feed'),
2268 /* translators: 1: blog name, 2: separator(raquo), 3: search phrase */
2269 'searchtitle' => __('%1$s %2$s Search Results for “%3$s” Feed'),
2270 /* translators: 1: blog name, 2: separator(raquo), 3: post type name */
2271 'posttypetitle' => __('%1$s %2$s %3$s Feed'),
2274 $args = wp_parse_args( $args, $defaults );
2276 if ( is_singular() ) {
2278 $post = get_post( $id );
2280 if ( comments_open() || pings_open() || $post->comment_count > 0 ) {
2281 $title = sprintf( $args['singletitle'], get_bloginfo('name'), $args['separator'], the_title_attribute( array( 'echo' => false ) ) );
2282 $href = get_post_comments_feed_link( $post->ID );
2284 } elseif ( is_post_type_archive() ) {
2285 $post_type = get_query_var( 'post_type' );
2286 if ( is_array( $post_type ) )
2287 $post_type = reset( $post_type );
2289 $post_type_obj = get_post_type_object( $post_type );
2290 $title = sprintf( $args['posttypetitle'], get_bloginfo( 'name' ), $args['separator'], $post_type_obj->labels->name );
2291 $href = get_post_type_archive_feed_link( $post_type_obj->name );
2292 } elseif ( is_category() ) {
2293 $term = get_queried_object();
2296 $title = sprintf( $args['cattitle'], get_bloginfo('name'), $args['separator'], $term->name );
2297 $href = get_category_feed_link( $term->term_id );
2299 } elseif ( is_tag() ) {
2300 $term = get_queried_object();
2303 $title = sprintf( $args['tagtitle'], get_bloginfo('name'), $args['separator'], $term->name );
2304 $href = get_tag_feed_link( $term->term_id );
2306 } elseif ( is_author() ) {
2307 $author_id = intval( get_query_var('author') );
2309 $title = sprintf( $args['authortitle'], get_bloginfo('name'), $args['separator'], get_the_author_meta( 'display_name', $author_id ) );
2310 $href = get_author_feed_link( $author_id );
2311 } elseif ( is_search() ) {
2312 $title = sprintf( $args['searchtitle'], get_bloginfo('name'), $args['separator'], get_search_query( false ) );
2313 $href = get_search_feed_link();
2314 } elseif ( is_post_type_archive() ) {
2315 $title = sprintf( $args['posttypetitle'], get_bloginfo('name'), $args['separator'], post_type_archive_title( '', false ) );
2316 $post_type_obj = get_queried_object();
2317 if ( $post_type_obj )
2318 $href = get_post_type_archive_feed_link( $post_type_obj->name );
2321 if ( isset($title) && isset($href) )
2322 echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( $title ) . '" href="' . esc_url( $href ) . '" />' . "\n";
2326 * Display the link to the Really Simple Discovery service endpoint.
2328 * @link http://archipelago.phrasewise.com/rsd
2331 function rsd_link() {
2332 echo '<link rel="EditURI" type="application/rsd+xml" title="RSD" href="' . get_bloginfo('wpurl') . "/xmlrpc.php?rsd\" />\n";
2336 * Display the link to the Windows Live Writer manifest file.
2338 * @link http://msdn.microsoft.com/en-us/library/bb463265.aspx
2341 function wlwmanifest_link() {
2342 echo '<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="',
2343 includes_url( 'wlwmanifest.xml' ), '" /> ', "\n";
2347 * Display a noindex meta tag if required by the blog configuration.
2349 * If a blog is marked as not being public then the noindex meta tag will be
2350 * output to tell web robots not to index the page content. Add this to the wp_head action.
2351 * Typical usage is as a wp_head callback. add_action( 'wp_head', 'noindex' );
2357 function noindex() {
2358 // If the blog is not public, tell robots to go away.
2359 if ( '0' == get_option('blog_public') )
2364 * Display a noindex meta tag.
2366 * Outputs a noindex meta tag that tells web robots not to index the page content.
2367 * Typical usage is as a wp_head callback. add_action( 'wp_head', 'wp_no_robots' );
2371 function wp_no_robots() {
2372 echo "<meta name='robots' content='noindex,follow' />\n";
2376 * Whether the user should have a WYSIWIG editor.
2378 * Checks that the user requires a WYSIWIG editor and that the editor is
2379 * supported in the users browser.
2385 function user_can_richedit() {
2386 global $wp_rich_edit, $is_gecko, $is_opera, $is_safari, $is_chrome, $is_IE;
2388 if ( !isset($wp_rich_edit) ) {
2389 $wp_rich_edit = false;
2391 if ( get_user_option( 'rich_editing' ) == 'true' || ! is_user_logged_in() ) { // default to 'true' for logged out users
2393 $wp_rich_edit = ! wp_is_mobile() || ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval( $match[1] ) >= 534 );
2394 } elseif ( $is_gecko || $is_chrome || $is_IE || ( $is_opera && !wp_is_mobile() ) ) {
2395 $wp_rich_edit = true;
2401 * Filter whether the user can access the rich (Visual) editor.
2405 * @param bool $wp_rich_edit Whether the user can access to the rich (Visual) editor.
2407 return apply_filters( 'user_can_richedit', $wp_rich_edit );
2411 * Find out which editor should be displayed by default.
2413 * Works out which of the two editors to display as the current editor for a
2414 * user. The 'html' setting is for the "Text" editor tab.
2418 * @return string Either 'tinymce', or 'html', or 'test'
2420 function wp_default_editor() {
2421 $r = user_can_richedit() ? 'tinymce' : 'html'; // defaults
2422 if ( wp_get_current_user() ) { // look for cookie
2423 $ed = get_user_setting('editor', 'tinymce');
2424 $r = ( in_array($ed, array('tinymce', 'html', 'test') ) ) ? $ed : $r;
2428 * Filter which editor should be displayed by default.
2432 * @param array $r An array of editors. Accepts 'tinymce', 'html', 'test'.
2434 return apply_filters( 'wp_default_editor', $r );
2438 * Renders an editor.
2440 * Using this function is the proper way to output all needed components for both TinyMCE and Quicktags.
2441 * _WP_Editors should not be used directly. See https://core.trac.wordpress.org/ticket/17144.
2443 * NOTE: Once initialized the TinyMCE editor cannot be safely moved in the DOM. For that reason
2444 * running wp_editor() inside of a metabox is not a good idea unless only Quicktags is used.
2445 * On the post edit screen several actions can be used to include additional editors
2446 * containing TinyMCE: 'edit_page_form', 'edit_form_advanced' and 'dbx_post_sidebar'.
2447 * See https://core.trac.wordpress.org/ticket/19173 for more information.
2449 * @see wp-includes/class-wp-editor.php
2452 * @param string $content Initial content for the editor.
2453 * @param string $editor_id HTML ID attribute value for the textarea and TinyMCE. Can only be /[a-z]+/.
2454 * @param array $settings See _WP_Editors::editor().
2456 function wp_editor( $content, $editor_id, $settings = array() ) {
2457 if ( ! class_exists( '_WP_Editors' ) )
2458 require( ABSPATH . WPINC . '/class-wp-editor.php' );
2460 _WP_Editors::editor($content, $editor_id, $settings);
2464 * Retrieve the contents of the search WordPress query variable.
2466 * The search query string is passed through {@link esc_attr()}
2467 * to ensure that it is safe for placing in an html attribute.
2471 * @param bool $escaped Whether the result is escaped. Default true.
2472 * Only use when you are later escaping it. Do not use unescaped.
2475 function get_search_query( $escaped = true ) {
2477 * Filter the contents of the search query variable.
2481 * @param mixed $search Contents of the search query variable.
2483 $query = apply_filters( 'get_search_query', get_query_var( 's' ) );
2486 $query = esc_attr( $query );
2491 * Display the contents of the search query variable.
2493 * The search query string is passed through {@link esc_attr()}
2494 * to ensure that it is safe for placing in an html attribute.
2498 function the_search_query() {
2500 * Filter the contents of the search query variable for display.
2504 * @param mixed $search Contents of the search query variable.
2506 echo esc_attr( apply_filters( 'the_search_query', get_search_query( false ) ) );
2510 * Display the language attributes for the html tag.
2512 * Builds up a set of html attributes containing the text direction and language
2513 * information for the page.
2517 * @param string $doctype The type of html document (xhtml|html).
2519 function language_attributes($doctype = 'html') {
2520 $attributes = array();
2522 if ( function_exists( 'is_rtl' ) && is_rtl() )
2523 $attributes[] = 'dir="rtl"';
2525 if ( $lang = get_bloginfo('language') ) {
2526 if ( get_option('html_type') == 'text/html' || $doctype == 'html' )
2527 $attributes[] = "lang=\"$lang\"";
2529 if ( get_option('html_type') != 'text/html' || $doctype == 'xhtml' )
2530 $attributes[] = "xml:lang=\"$lang\"";
2533 $output = implode(' ', $attributes);
2536 * Filter the language attributes for display in the html tag.
2540 * @param string $output A space-separated list of language attributes.
2542 echo apply_filters( 'language_attributes', $output );
2546 * Retrieve paginated link for archive post pages.
2548 * Technically, the function can be used to create paginated link list for any
2549 * area. The 'base' argument is used to reference the url, which will be used to
2550 * create the paginated links. The 'format' argument is then used for replacing
2551 * the page number. It is however, most likely and by default, to be used on the
2552 * archive post pages.
2554 * The 'type' argument controls format of the returned value. The default is
2555 * 'plain', which is just a string with the links separated by a newline
2556 * character. The other possible values are either 'array' or 'list'. The
2557 * 'array' value will return an array of the paginated link list to offer full
2558 * control of display. The 'list' value will place all of the paginated links in
2559 * an unordered HTML list.
2561 * The 'total' argument is the total amount of pages and is an integer. The
2562 * 'current' argument is the current page number and is also an integer.
2564 * An example of the 'base' argument is "http://example.com/all_posts.php%_%"
2565 * and the '%_%' is required. The '%_%' will be replaced by the contents of in
2566 * the 'format' argument. An example for the 'format' argument is "?page=%#%"
2567 * and the '%#%' is also required. The '%#%' will be replaced with the page
2570 * You can include the previous and next links in the list by setting the
2571 * 'prev_next' argument to true, which it is by default. You can set the
2572 * previous text, by using the 'prev_text' argument. You can set the next text
2573 * by setting the 'next_text' argument.
2575 * If the 'show_all' argument is set to true, then it will show all of the pages
2576 * instead of a short list of the pages near the current page. By default, the
2577 * 'show_all' is set to false and controlled by the 'end_size' and 'mid_size'
2578 * arguments. The 'end_size' argument is how many numbers on either the start
2579 * and the end list edges, by default is 1. The 'mid_size' argument is how many
2580 * numbers to either side of current page, but not including current page.
2582 * It is possible to add query vars to the link by using the 'add_args' argument
2583 * and see {@link add_query_arg()} for more information.
2585 * The 'before_page_number' and 'after_page_number' arguments allow users to
2586 * augment the links themselves. Typically this might be to add context to the
2587 * numbered links so that screen reader users understand what the links are for.
2588 * The text strings are added before and after the page number - within the
2593 * @param string|array $args {
2594 * Optional. Array or string of arguments for generating paginated links for archives.
2596 * @type string $base Base of the paginated url. Default empty.
2597 * @type string $format Format for the pagination structure. Default empty.
2598 * @type int $total The total amount of pages. Default is the value WP_Query's
2599 * `max_num_pages` or 1.
2600 * @type int $current The current page number. Default is 'paged' query var or 1.
2601 * @type bool $show_all Whether to show all pages. Default false.
2602 * @type int $end_size How many numbers on either the start and the end list edges.
2604 * @type int $mid_size How many numbers to either side of the current pages. Default 2.
2605 * @type bool $prev_next Whether to include the previous and next links in the list. Default true.
2606 * @type bool $prev_text The previous page text. Default '« Previous'.
2607 * @type bool $next_text The next page text. Default '« Previous'.
2608 * @type string $type Controls format of the returned value. Possible values are 'plain',
2609 * 'array' and 'list'. Default is 'plain'.
2610 * @type array $add_args An array of query args to add. Default false.
2611 * @type string $add_fragment A string to append to each link. Default empty.
2612 * @type string $before_page_number A string to appear before the page number. Default empty.
2613 * @type string $after_page_number A string to append after the page number. Default empty.
2615 * @return array|string String of page links or array of page links.
2617 function paginate_links( $args = '' ) {
2618 global $wp_query, $wp_rewrite;
2620 // Setting up default values based on the current URL.
2621 $pagenum_link = html_entity_decode( get_pagenum_link() );
2622 $url_parts = explode( '?', $pagenum_link );
2624 // Get max pages and current page out of the current query, if available.
2625 $total = isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1;
2626 $current = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1;
2628 // Append the format placeholder to the base URL.
2629 $pagenum_link = trailingslashit( $url_parts[0] ) . '%_%';
2631 // URL base depends on permalink settings.
2632 $format = $wp_rewrite->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : '';
2633 $format .= $wp_rewrite->using_permalinks() ? user_trailingslashit( $wp_rewrite->pagination_base . '/%#%', 'paged' ) : '?paged=%#%';
2636 'base' => $pagenum_link, // http://example.com/all_posts.php%_% : %_% is replaced by format (below)
2637 'format' => $format, // ?page=%#% : %#% is replaced by the page number
2639 'current' => $current,
2640 'show_all' => false,
2641 'prev_next' => true,
2642 'prev_text' => __('« Previous'),
2643 'next_text' => __('Next »'),
2647 'add_args' => array(), // array of query args to add
2648 'add_fragment' => '',
2649 'before_page_number' => '',
2650 'after_page_number' => ''
2653 $args = wp_parse_args( $args, $defaults );
2655 if ( ! is_array( $args['add_args'] ) ) {
2656 $args['add_args'] = array();
2659 // Merge additional query vars found in the original URL into 'add_args' array.
2660 if ( isset( $url_parts[1] ) ) {
2661 // Find the format argument.
2662 $format_query = parse_url( str_replace( '%_%', $args['format'], $args['base'] ), PHP_URL_QUERY );
2663 wp_parse_str( $format_query, $format_arg );
2665 // Remove the format argument from the array of query arguments, to avoid overwriting custom format.
2666 wp_parse_str( remove_query_arg( array_keys( $format_arg ), $url_parts[1] ), $query_args );
2667 $args['add_args'] = array_merge( $args['add_args'], urlencode_deep( $query_args ) );
2670 // Who knows what else people pass in $args
2671 $total = (int) $args['total'];
2675 $current = (int) $args['current'];
2676 $end_size = (int) $args['end_size']; // Out of bounds? Make it the default.
2677 if ( $end_size < 1 ) {
2680 $mid_size = (int) $args['mid_size'];
2681 if ( $mid_size < 0 ) {
2684 $add_args = $args['add_args'];
2686 $page_links = array();
2689 if ( $args['prev_next'] && $current && 1 < $current ) :
2690 $link = str_replace( '%_%', 2 == $current ? '' : $args['format'], $args['base'] );
2691 $link = str_replace( '%#%', $current - 1, $link );
2693 $link = add_query_arg( $add_args, $link );
2694 $link .= $args['add_fragment'];
2697 * Filter the paginated links for the given archive pages.
2701 * @param string $link The paginated link URL.
2703 $page_links[] = '<a class="prev page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $args['prev_text'] . '</a>';
2705 for ( $n = 1; $n <= $total; $n++ ) :
2706 if ( $n == $current ) :
2707 $page_links[] = "<span class='page-numbers current'>" . $args['before_page_number'] . number_format_i18n( $n ) . $args['after_page_number'] . "</span>";
2710 if ( $args['show_all'] || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) :
2711 $link = str_replace( '%_%', 1 == $n ? '' : $args['format'], $args['base'] );
2712 $link = str_replace( '%#%', $n, $link );
2714 $link = add_query_arg( $add_args, $link );
2715 $link .= $args['add_fragment'];
2717 /** This filter is documented in wp-includes/general-template.php */
2718 $page_links[] = "<a class='page-numbers' href='" . esc_url( apply_filters( 'paginate_links', $link ) ) . "'>" . $args['before_page_number'] . number_format_i18n( $n ) . $args['after_page_number'] . "</a>";
2720 elseif ( $dots && ! $args['show_all'] ) :
2721 $page_links[] = '<span class="page-numbers dots">' . __( '…' ) . '</span>';
2726 if ( $args['prev_next'] && $current && ( $current < $total || -1 == $total ) ) :
2727 $link = str_replace( '%_%', $args['format'], $args['base'] );
2728 $link = str_replace( '%#%', $current + 1, $link );
2730 $link = add_query_arg( $add_args, $link );
2731 $link .= $args['add_fragment'];
2733 /** This filter is documented in wp-includes/general-template.php */
2734 $page_links[] = '<a class="next page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $args['next_text'] . '</a>';
2736 switch ( $args['type'] ) {
2741 $r .= "<ul class='page-numbers'>\n\t<li>";
2742 $r .= join("</li>\n\t<li>", $page_links);
2743 $r .= "</li>\n</ul>\n";
2747 $r = join("\n", $page_links);
2754 * Registers an admin colour scheme css file.
2756 * Allows a plugin to register a new admin colour scheme. For example:
2758 * wp_admin_css_color( 'classic', __( 'Classic' ), admin_url( "css/colors-classic.css" ), array(
2759 * '#07273E', '#14568A', '#D54E21', '#2683AE'
2764 * @todo Properly document optional arguments as such
2766 * @param string $key The unique key for this theme.
2767 * @param string $name The name of the theme.
2768 * @param string $url The url of the css file containing the colour scheme.
2769 * @param array $colors Optional An array of CSS color definitions which are used to give the user a feel for the theme.
2770 * @param array $icons Optional An array of CSS color definitions used to color any SVG icons
2772 function wp_admin_css_color( $key, $name, $url, $colors = array(), $icons = array() ) {
2773 global $_wp_admin_css_colors;
2775 if ( !isset($_wp_admin_css_colors) )
2776 $_wp_admin_css_colors = array();
2778 $_wp_admin_css_colors[$key] = (object) array(
2781 'colors' => $colors,
2782 'icon_colors' => $icons,
2787 * Registers the default Admin color schemes
2791 function register_admin_color_schemes() {
2792 $suffix = is_rtl() ? '-rtl' : '';
2793 $suffix .= defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
2795 wp_admin_css_color( 'fresh', _x( 'Default', 'admin color scheme' ),
2797 array( '#222', '#333', '#0073aa', '#00a0d2' ),
2798 array( 'base' => '#999', 'focus' => '#00a0d2', 'current' => '#fff' )
2801 // Other color schemes are not available when running out of src
2802 if ( false !== strpos( $GLOBALS['wp_version'], '-src' ) )
2805 wp_admin_css_color( 'light', _x( 'Light', 'admin color scheme' ),
2806 admin_url( "css/colors/light/colors$suffix.css" ),
2807 array( '#e5e5e5', '#999', '#d64e07', '#04a4cc' ),
2808 array( 'base' => '#999', 'focus' => '#ccc', 'current' => '#ccc' )
2811 wp_admin_css_color( 'blue', _x( 'Blue', 'admin color scheme' ),
2812 admin_url( "css/colors/blue/colors$suffix.css" ),
2813 array( '#096484', '#4796b3', '#52accc', '#74B6CE' ),
2814 array( 'base' => '#e5f8ff', 'focus' => '#fff', 'current' => '#fff' )
2817 wp_admin_css_color( 'midnight', _x( 'Midnight', 'admin color scheme' ),
2818 admin_url( "css/colors/midnight/colors$suffix.css" ),
2819 array( '#25282b', '#363b3f', '#69a8bb', '#e14d43' ),
2820 array( 'base' => '#f1f2f3', 'focus' => '#fff', 'current' => '#fff' )
2823 wp_admin_css_color( 'sunrise', _x( 'Sunrise', 'admin color scheme' ),
2824 admin_url( "css/colors/sunrise/colors$suffix.css" ),
2825 array( '#b43c38', '#cf4944', '#dd823b', '#ccaf0b' ),
2826 array( 'base' => '#f3f1f1', 'focus' => '#fff', 'current' => '#fff' )
2829 wp_admin_css_color( 'ectoplasm', _x( 'Ectoplasm', 'admin color scheme' ),
2830 admin_url( "css/colors/ectoplasm/colors$suffix.css" ),
2831 array( '#413256', '#523f6d', '#a3b745', '#d46f15' ),
2832 array( 'base' => '#ece6f6', 'focus' => '#fff', 'current' => '#fff' )
2835 wp_admin_css_color( 'ocean', _x( 'Ocean', 'admin color scheme' ),
2836 admin_url( "css/colors/ocean/colors$suffix.css" ),
2837 array( '#627c83', '#738e96', '#9ebaa0', '#aa9d88' ),
2838 array( 'base' => '#f2fcff', 'focus' => '#fff', 'current' => '#fff' )
2841 wp_admin_css_color( 'coffee', _x( 'Coffee', 'admin color scheme' ),
2842 admin_url( "css/colors/coffee/colors$suffix.css" ),
2843 array( '#46403c', '#59524c', '#c7a589', '#9ea476' ),
2844 array( 'base' => '#f3f2f1', 'focus' => '#fff', 'current' => '#fff' )
2850 * Display the URL of a WordPress admin CSS file.
2852 * @see WP_Styles::_css_href and its style_loader_src filter.
2856 * @param string $file file relative to wp-admin/ without its ".css" extension.
2858 function wp_admin_css_uri( $file = 'wp-admin' ) {
2859 if ( defined('WP_INSTALLING') ) {
2860 $_file = "./$file.css";
2862 $_file = admin_url("$file.css");
2864 $_file = add_query_arg( 'version', get_bloginfo( 'version' ), $_file );
2867 * Filter the URI of a WordPress admin CSS file.
2871 * @param string $_file Relative path to the file with query arguments attached.
2872 * @param string $file Relative path to the file, minus its ".css" extension.
2874 return apply_filters( 'wp_admin_css_uri', $_file, $file );
2878 * Enqueues or directly prints a stylesheet link to the specified CSS file.
2880 * "Intelligently" decides to enqueue or to print the CSS file. If the
2881 * 'wp_print_styles' action has *not* yet been called, the CSS file will be
2882 * enqueued. If the wp_print_styles action *has* been called, the CSS link will
2883 * be printed. Printing may be forced by passing true as the $force_echo
2884 * (second) parameter.
2886 * For backward compatibility with WordPress 2.3 calling method: If the $file
2887 * (first) parameter does not correspond to a registered CSS file, we assume
2888 * $file is a file relative to wp-admin/ without its ".css" extension. A
2889 * stylesheet link to that generated URL is printed.
2892 * @uses $wp_styles WordPress Styles Object
2894 * @param string $file Optional. Style handle name or file name (without ".css" extension) relative
2895 * to wp-admin/. Defaults to 'wp-admin'.
2896 * @param bool $force_echo Optional. Force the stylesheet link to be printed rather than enqueued.
2898 function wp_admin_css( $file = 'wp-admin', $force_echo = false ) {
2900 if ( ! ( $wp_styles instanceof WP_Styles ) ) {
2901 $wp_styles = new WP_Styles();
2904 // For backward compatibility
2905 $handle = 0 === strpos( $file, 'css/' ) ? substr( $file, 4 ) : $file;
2907 if ( $wp_styles->query( $handle ) ) {
2908 if ( $force_echo || did_action( 'wp_print_styles' ) ) // we already printed the style queue. Print this one immediately
2909 wp_print_styles( $handle );
2910 else // Add to style queue
2911 wp_enqueue_style( $handle );
2916 * Filter the stylesheet link to the specified CSS file.
2918 * If the site is set to display right-to-left, the RTL stylesheet link
2919 * will be used instead.
2923 * @param string $file Style handle name or filename (without ".css" extension)
2924 * relative to wp-admin/. Defaults to 'wp-admin'.
2926 echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . esc_url( wp_admin_css_uri( $file ) ) . "' type='text/css' />\n", $file );
2928 if ( function_exists( 'is_rtl' ) && is_rtl() ) {
2929 /** This filter is documented in wp-includes/general-template.php */
2930 echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . esc_url( wp_admin_css_uri( "$file-rtl" ) ) . "' type='text/css' />\n", "$file-rtl" );
2935 * Enqueues the default ThickBox js and css.
2937 * If any of the settings need to be changed, this can be done with another js
2938 * file similar to media-upload.js. That file should
2939 * require array('thickbox') to ensure it is loaded after.
2943 function add_thickbox() {
2944 wp_enqueue_script( 'thickbox' );
2945 wp_enqueue_style( 'thickbox' );
2947 if ( is_network_admin() )
2948 add_action( 'admin_head', '_thickbox_path_admin_subfolder' );
2952 * Display the XHTML generator that is generated on the wp_head hook.
2956 function wp_generator() {
2958 * Filter the output of the XHTML generator tag.
2962 * @param string $generator_type The XHTML generator.
2964 the_generator( apply_filters( 'wp_generator_type', 'xhtml' ) );
2968 * Display the generator XML or Comment for RSS, ATOM, etc.
2970 * Returns the correct generator type for the requested output format. Allows
2971 * for a plugin to filter generators overall the the_generator filter.
2975 * @param string $type The type of generator to output - (html|xhtml|atom|rss2|rdf|comment|export).
2977 function the_generator( $type ) {
2979 * Filter the output of the XHTML generator tag for display.
2983 * @param string $generator_type The generator output.
2984 * @param string $type The type of generator to output. Accepts 'html',
2985 * 'xhtml', 'atom', 'rss2', 'rdf', 'comment', 'export'.
2987 echo apply_filters( 'the_generator', get_the_generator($type), $type ) . "\n";
2991 * Creates the generator XML or Comment for RSS, ATOM, etc.
2993 * Returns the correct generator type for the requested output format. Allows
2994 * for a plugin to filter generators on an individual basis using the
2995 * 'get_the_generator_{$type}' filter.
2999 * @param string $type The type of generator to return - (html|xhtml|atom|rss2|rdf|comment|export).
3000 * @return string The HTML content for the generator.
3002 function get_the_generator( $type = '' ) {
3003 if ( empty( $type ) ) {
3005 $current_filter = current_filter();
3006 if ( empty( $current_filter ) )
3009 switch ( $current_filter ) {
3011 case 'commentsrss2_head' :
3022 case 'comments_atom_head' :
3031 $gen = '<meta name="generator" content="WordPress ' . get_bloginfo( 'version' ) . '">';
3034 $gen = '<meta name="generator" content="WordPress ' . get_bloginfo( 'version' ) . '" />';
3037 $gen = '<generator uri="http://wordpress.org/" version="' . get_bloginfo_rss( 'version' ) . '">WordPress</generator>';
3040 $gen = '<generator>http://wordpress.org/?v=' . get_bloginfo_rss( 'version' ) . '</generator>';
3043 $gen = '<admin:generatorAgent rdf:resource="http://wordpress.org/?v=' . get_bloginfo_rss( 'version' ) . '" />';
3046 $gen = '<!-- generator="WordPress/' . get_bloginfo( 'version' ) . '" -->';
3049 $gen = '<!-- generator="WordPress/' . get_bloginfo_rss('version') . '" created="'. date('Y-m-d H:i') . '" -->';
3054 * Filter the HTML for the retrieved generator type.
3056 * The dynamic portion of the hook name, `$type`, refers to the generator type.
3060 * @param string $gen The HTML markup output to {@see wp_head()}.
3061 * @param string $type The type of generator. Accepts 'html', 'xhtml', 'atom',
3062 * 'rss2', 'rdf', 'comment', 'export'.
3064 return apply_filters( "get_the_generator_{$type}", $gen, $type );
3068 * Outputs the html checked attribute.
3070 * Compares the first two arguments and if identical marks as checked
3074 * @param mixed $checked One of the values to compare
3075 * @param mixed $current (true) The other value to compare if not just true
3076 * @param bool $echo Whether to echo or just return the string
3077 * @return string html attribute or empty string
3079 function checked( $checked, $current = true, $echo = true ) {
3080 return __checked_selected_helper( $checked, $current, $echo, 'checked' );
3084 * Outputs the html selected attribute.
3086 * Compares the first two arguments and if identical marks as selected
3090 * @param mixed $selected One of the values to compare
3091 * @param mixed $current (true) The other value to compare if not just true
3092 * @param bool $echo Whether to echo or just return the string
3093 * @return string html attribute or empty string
3095 function selected( $selected, $current = true, $echo = true ) {
3096 return __checked_selected_helper( $selected, $current, $echo, 'selected' );
3100 * Outputs the html disabled attribute.
3102 * Compares the first two arguments and if identical marks as disabled
3106 * @param mixed $disabled One of the values to compare
3107 * @param mixed $current (true) The other value to compare if not just true
3108 * @param bool $echo Whether to echo or just return the string
3109 * @return string html attribute or empty string
3111 function disabled( $disabled, $current = true, $echo = true ) {
3112 return __checked_selected_helper( $disabled, $current, $echo, 'disabled' );
3116 * Private helper function for checked, selected, and disabled.
3118 * Compares the first two arguments and if identical marks as $type
3123 * @param mixed $helper One of the values to compare
3124 * @param mixed $current (true) The other value to compare if not just true
3125 * @param bool $echo Whether to echo or just return the string
3126 * @param string $type The type of checked|selected|disabled we are doing
3127 * @return string html attribute or empty string
3129 function __checked_selected_helper( $helper, $current, $echo, $type ) {
3130 if ( (string) $helper === (string) $current )
3131 $result = " $type='$type'";
3142 * Default settings for heartbeat
3144 * Outputs the nonce used in the heartbeat XHR
3148 * @param array $settings
3149 * @return array $settings
3151 function wp_heartbeat_settings( $settings ) {
3153 $settings['ajaxurl'] = admin_url( 'admin-ajax.php', 'relative' );
3155 if ( is_user_logged_in() )
3156 $settings['nonce'] = wp_create_nonce( 'heartbeat-nonce' );