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 bool $echo Default to echo and not return the form.
194 * @return string|void String when $echo is false.
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 bool $echo Default to echo and not return the link.
272 * @return string|void String when retrieving.
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 URL that allows the user to log in to the site.
330 * @param string $redirect Path to redirect to on login.
331 * @param bool $force_reauth Whether to force reauthorization, even if a cookie is present. Default is false.
332 * @return string A log in URL.
334 function wp_login_url($redirect = '', $force_reauth = false) {
335 $login_url = site_url('wp-login.php', 'login');
337 if ( !empty($redirect) )
338 $login_url = add_query_arg('redirect_to', urlencode($redirect), $login_url);
341 $login_url = add_query_arg('reauth', '1', $login_url);
344 * Filter the login URL.
347 * @since 4.2.0 The `$force_reauth` parameter was added.
349 * @param string $login_url The login URL.
350 * @param string $redirect The path to redirect to on login, if supplied.
351 * @param bool $force_reauth Whether to force reauthorization, even if a cookie is present.
353 return apply_filters( 'login_url', $login_url, $redirect, $force_reauth );
357 * Returns the URL that allows the user to register on the site.
361 * @return string User registration URL.
363 function wp_registration_url() {
365 * Filter the user registration URL.
369 * @param string $register The user registration URL.
371 return apply_filters( 'register_url', site_url( 'wp-login.php?action=register', 'login' ) );
375 * Provides a simple login form for use anywhere within WordPress. By default, it echoes
376 * the HTML immediately. Pass array('echo'=>false) to return the string instead.
380 * @param array $args Configuration options to modify the form output.
381 * @return string|void String when retrieving.
383 function wp_login_form( $args = array() ) {
386 'redirect' => ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], // Default redirect is back to the current page
387 'form_id' => 'loginform',
388 'label_username' => __( 'Username' ),
389 'label_password' => __( 'Password' ),
390 'label_remember' => __( 'Remember Me' ),
391 'label_log_in' => __( 'Log In' ),
392 'id_username' => 'user_login',
393 'id_password' => 'user_pass',
394 'id_remember' => 'rememberme',
395 'id_submit' => 'wp-submit',
397 'value_username' => '',
398 'value_remember' => false, // Set this to true to default the "Remember me" checkbox to checked
402 * Filter the default login form output arguments.
406 * @see wp_login_form()
408 * @param array $defaults An array of default login form arguments.
410 $args = wp_parse_args( $args, apply_filters( 'login_form_defaults', $defaults ) );
413 * Filter content to display at the top of the login form.
415 * The filter evaluates just following the opening form tag element.
419 * @param string $content Content to display. Default empty.
420 * @param array $args Array of login form arguments.
422 $login_form_top = apply_filters( 'login_form_top', '', $args );
425 * Filter content to display in the middle of the login form.
427 * The filter evaluates just following the location where the 'login-password'
428 * field is displayed.
432 * @param string $content Content to display. Default empty.
433 * @param array $args Array of login form arguments.
435 $login_form_middle = apply_filters( 'login_form_middle', '', $args );
438 * Filter content to display at the bottom of the login form.
440 * The filter evaluates just preceding the closing form tag element.
444 * @param string $content Content to display. Default empty.
445 * @param array $args Array of login form arguments.
447 $login_form_bottom = apply_filters( 'login_form_bottom', '', $args );
450 <form name="' . $args['form_id'] . '" id="' . $args['form_id'] . '" action="' . esc_url( site_url( 'wp-login.php', 'login_post' ) ) . '" method="post">
451 ' . $login_form_top . '
452 <p class="login-username">
453 <label for="' . esc_attr( $args['id_username'] ) . '">' . esc_html( $args['label_username'] ) . '</label>
454 <input type="text" name="log" id="' . esc_attr( $args['id_username'] ) . '" class="input" value="' . esc_attr( $args['value_username'] ) . '" size="20" />
456 <p class="login-password">
457 <label for="' . esc_attr( $args['id_password'] ) . '">' . esc_html( $args['label_password'] ) . '</label>
458 <input type="password" name="pwd" id="' . esc_attr( $args['id_password'] ) . '" class="input" value="" size="20" />
460 ' . $login_form_middle . '
461 ' . ( $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>' : '' ) . '
462 <p class="login-submit">
463 <input type="submit" name="wp-submit" id="' . esc_attr( $args['id_submit'] ) . '" class="button-primary" value="' . esc_attr( $args['label_log_in'] ) . '" />
464 <input type="hidden" name="redirect_to" value="' . esc_url( $args['redirect'] ) . '" />
466 ' . $login_form_bottom . '
476 * Returns the URL that allows the user to retrieve the lost password
480 * @param string $redirect Path to redirect to on login.
481 * @return string Lost password URL.
483 function wp_lostpassword_url( $redirect = '' ) {
484 $args = array( 'action' => 'lostpassword' );
485 if ( !empty($redirect) ) {
486 $args['redirect_to'] = $redirect;
489 $lostpassword_url = add_query_arg( $args, network_site_url('wp-login.php', 'login') );
492 * Filter the Lost Password URL.
496 * @param string $lostpassword_url The lost password page URL.
497 * @param string $redirect The path to redirect to on login.
499 return apply_filters( 'lostpassword_url', $lostpassword_url, $redirect );
503 * Display the Registration or Admin link.
505 * Display a link which allows the user to navigate to the registration page if
506 * not logged in and registration is enabled or to the dashboard if logged in.
510 * @param string $before Text to output before the link. Default `<li>`.
511 * @param string $after Text to output after the link. Default `</li>`.
512 * @param bool $echo Default to echo and not return the link.
513 * @return string|void String when retrieving.
515 function wp_register( $before = '<li>', $after = '</li>', $echo = true ) {
516 if ( ! is_user_logged_in() ) {
517 if ( get_option('users_can_register') )
518 $link = $before . '<a href="' . esc_url( wp_registration_url() ) . '">' . __('Register') . '</a>' . $after;
522 $link = $before . '<a href="' . admin_url() . '">' . __('Site Admin') . '</a>' . $after;
526 * Filter the HTML link to the Registration or Admin page.
528 * Users are sent to the admin page if logged-in, or the registration page
529 * if enabled and logged-out.
533 * @param string $link The HTML code for the link to the Registration or Admin page.
535 $link = apply_filters( 'register', $link );
545 * Theme container function for the 'wp_meta' action.
547 * The 'wp_meta' action can have several purposes, depending on how you use it,
548 * but one purpose might have been to allow for theme switching.
552 * @link https://core.trac.wordpress.org/ticket/1458 Explanation of 'wp_meta' action.
556 * Fires before displaying echoed content in the sidebar.
560 do_action( 'wp_meta' );
564 * Display information about the blog.
566 * @see get_bloginfo() For possible values for the parameter.
569 * @param string $show What to display.
571 function bloginfo( $show='' ) {
572 echo get_bloginfo( $show, 'display' );
576 * Retrieve information about the blog.
578 * Some show parameter values are deprecated and will be removed in future
579 * versions. These options will trigger the {@see _deprecated_argument()}
580 * function. The deprecated blog info options are listed in the function
583 * The possible values for the 'show' parameter are listed below.
585 * 1. url - Blog URI to homepage.
586 * 2. wpurl - Blog URI path to WordPress.
587 * 3. description - Secondary title
589 * The feed URL options can be retrieved from 'rdf_url' (RSS 0.91),
590 * 'rss_url' (RSS 1.0), 'rss2_url' (RSS 2.0), or 'atom_url' (Atom feed). The
591 * comment feeds can be retrieved from the 'comments_atom_url' (Atom comment
592 * feed) or 'comments_rss2_url' (RSS 2.0 comment feed).
596 * @global string $wp_version
598 * @param string $show Blog info to retrieve.
599 * @param string $filter How to filter what is retrieved.
600 * @return string Mostly string values, might be empty.
602 function get_bloginfo( $show = '', $filter = 'raw' ) {
604 case 'home' : // DEPRECATED
605 case 'siteurl' : // DEPRECATED
606 _deprecated_argument( __FUNCTION__, '2.2', sprintf(
607 /* translators: 1: 'siteurl'/'home' argument, 2: bloginfo() function name, 3: 'url' argument */
608 __( 'The %1$s option is deprecated for the family of %2$s functions. Use the %3$s option instead.' ),
609 '<code>' . $show . '</code>',
610 '<code>bloginfo()</code>',
614 $output = home_url();
617 $output = site_url();
620 $output = get_option('blogdescription');
623 $output = get_feed_link('rdf');
626 $output = get_feed_link('rss');
629 $output = get_feed_link('rss2');
632 $output = get_feed_link('atom');
634 case 'comments_atom_url':
635 $output = get_feed_link('comments_atom');
637 case 'comments_rss2_url':
638 $output = get_feed_link('comments_rss2');
641 $output = site_url( 'xmlrpc.php' );
643 case 'stylesheet_url':
644 $output = get_stylesheet_uri();
646 case 'stylesheet_directory':
647 $output = get_stylesheet_directory_uri();
649 case 'template_directory':
651 $output = get_template_directory_uri();
654 $output = get_option('admin_email');
657 $output = get_option('blog_charset');
658 if ('' == $output) $output = 'UTF-8';
661 $output = get_option('html_type');
665 $output = $wp_version;
668 $output = get_locale();
669 $output = str_replace('_', '-', $output);
671 case 'text_direction':
672 _deprecated_argument( __FUNCTION__, '2.2', sprintf(
673 /* translators: 1: 'text_direction' argument, 2: bloginfo() function name, 3: is_rtl() function name */
674 __( 'The %1$s option is deprecated for the family of %2$s functions. Use the %3$s function instead.' ),
675 '<code>' . $show . '</code>',
676 '<code>bloginfo()</code>',
677 '<code>is_rtl()</code>'
679 if ( function_exists( 'is_rtl' ) ) {
680 $output = is_rtl() ? 'rtl' : 'ltr';
687 $output = get_option('blogname');
692 if (strpos($show, 'url') === false &&
693 strpos($show, 'directory') === false &&
694 strpos($show, 'home') === false)
697 if ( 'display' == $filter ) {
700 * Filter the URL returned by get_bloginfo().
704 * @param mixed $output The URL returned by bloginfo().
705 * @param mixed $show Type of information requested.
707 $output = apply_filters( 'bloginfo_url', $output, $show );
710 * Filter the site information returned by get_bloginfo().
714 * @param mixed $output The requested non-URL site information.
715 * @param mixed $show Type of information requested.
717 $output = apply_filters( 'bloginfo', $output, $show );
725 * Returns the Site Icon URL.
727 * @param int $size Size of the site icon.
728 * @param string $url Fallback url if no site icon is found.
729 * @param int $blog_id Id of the blog to get the site icon for.
730 * @return string Site Icon URL.
732 function get_site_icon_url( $size = 512, $url = '', $blog_id = 0 ) {
733 if ( $blog_id && is_multisite() ) {
734 $site_icon_id = get_blog_option( $blog_id, 'site_icon' );
736 $site_icon_id = get_option( 'site_icon' );
739 if ( $site_icon_id ) {
740 if ( $size >= 512 ) {
743 $size_data = array( $size, $size );
745 $url_data = wp_get_attachment_image_src( $site_icon_id, $size_data );
755 * Displays the Site Icon URL.
757 * @param int $size Size of the site icon.
758 * @param string $url Fallback url if no site icon is found.
759 * @param int $blog_id Id of the blog to get the site icon for.
761 function site_icon_url( $size = 512, $url = '', $blog_id = 0 ) {
762 echo esc_url( get_site_icon_url( $size, $url, $blog_id ) );
766 * Whether the site has a Site Icon.
768 * @param int $blog_id Optional. Blog ID. Default: Current blog.
771 function has_site_icon( $blog_id = 0 ) {
772 return (bool) get_site_icon_url( 512, '', $blog_id );
776 * Display title tag with contents.
784 function _wp_render_title_tag() {
785 if ( ! current_theme_supports( 'title-tag' ) ) {
789 // This can only work internally on wp_head.
790 if ( ! did_action( 'wp_head' ) && ! doing_action( 'wp_head' ) ) {
794 echo '<title>' . wp_title( '|', false, 'right' ) . "</title>\n";
798 * Display or retrieve page title for all areas of blog.
800 * By default, the page title will display the separator before the page title,
801 * so that the blog title will be before the page title. This is not good for
802 * title display, since the blog title shows up on most tabs and not what is
803 * important, which is the page that the user is looking at.
805 * There are also SEO benefits to having the blog title after or to the 'right'
806 * or the page title. However, it is mostly common sense to have the blog title
807 * to the right with most browsers supporting tabs. You can achieve this by
808 * using the seplocation parameter and setting the value to 'right'. This change
809 * was introduced around 2.5.0, in case backwards compatibility of themes is
814 * @global WP_Locale $wp_locale
818 * @param string $sep Optional, default is '»'. How to separate the various items within the page title.
819 * @param bool $display Optional, default is true. Whether to display or retrieve title.
820 * @param string $seplocation Optional. Direction to display title, 'right'.
821 * @return string|void String on retrieve.
823 function wp_title( $sep = '»', $display = true, $seplocation = '' ) {
824 global $wp_locale, $page, $paged;
826 $m = get_query_var('m');
827 $year = get_query_var('year');
828 $monthnum = get_query_var('monthnum');
829 $day = get_query_var('day');
830 $search = get_query_var('s');
833 $t_sep = '%WP_TITILE_SEP%'; // Temporary separator, for accurate flipping, if necessary
835 // If there is a post
836 if ( is_single() || ( is_home() && !is_front_page() ) || ( is_page() && !is_front_page() ) ) {
837 $title = single_post_title( '', false );
840 // If there's a post type archive
841 if ( is_post_type_archive() ) {
842 $post_type = get_query_var( 'post_type' );
843 if ( is_array( $post_type ) )
844 $post_type = reset( $post_type );
845 $post_type_object = get_post_type_object( $post_type );
846 if ( ! $post_type_object->has_archive )
847 $title = post_type_archive_title( '', false );
850 // If there's a category or tag
851 if ( is_category() || is_tag() ) {
852 $title = single_term_title( '', false );
855 // If there's a taxonomy
857 $term = get_queried_object();
859 $tax = get_taxonomy( $term->taxonomy );
860 $title = single_term_title( $tax->labels->name . $t_sep, false );
864 // If there's an author
865 if ( is_author() && ! is_post_type_archive() ) {
866 $author = get_queried_object();
868 $title = $author->display_name;
871 // Post type archives with has_archive should override terms.
872 if ( is_post_type_archive() && $post_type_object->has_archive )
873 $title = post_type_archive_title( '', false );
875 // If there's a month
876 if ( is_archive() && !empty($m) ) {
877 $my_year = substr($m, 0, 4);
878 $my_month = $wp_locale->get_month(substr($m, 4, 2));
879 $my_day = intval(substr($m, 6, 2));
880 $title = $my_year . ( $my_month ? $t_sep . $my_month : '' ) . ( $my_day ? $t_sep . $my_day : '' );
884 if ( is_archive() && !empty($year) ) {
886 if ( !empty($monthnum) )
887 $title .= $t_sep . $wp_locale->get_month($monthnum);
889 $title .= $t_sep . zeroise($day, 2);
894 /* translators: 1: separator, 2: search phrase */
895 $title = sprintf(__('Search Results %1$s %2$s'), $t_sep, strip_tags($search));
898 // If it's a 404 page
900 $title = __('Page not found');
904 if ( !empty($title) )
908 * Filter the parts of the page title.
912 * @param array $title_array Parts of the page title.
914 $title_array = apply_filters( 'wp_title_parts', explode( $t_sep, $title ) );
916 // Determines position of the separator and direction of the breadcrumb
917 if ( 'right' == $seplocation ) { // sep on right, so reverse the order
918 $title_array = array_reverse( $title_array );
919 $title = implode( " $sep ", $title_array ) . $prefix;
921 $title = $prefix . implode( " $sep ", $title_array );
924 if ( current_theme_supports( 'title-tag' ) && ! is_feed() ) {
925 $title .= get_bloginfo( 'name', 'display' );
927 $site_description = get_bloginfo( 'description', 'display' );
928 if ( $site_description && ( is_home() || is_front_page() ) ) {
929 $title .= " $sep $site_description";
932 if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) {
933 $title .= " $sep " . sprintf( __( 'Page %s' ), max( $paged, $page ) );
938 * Filter the text of the page title.
942 * @param string $title Page title.
943 * @param string $sep Title separator.
944 * @param string $seplocation Location of the separator (left or right).
946 $title = apply_filters( 'wp_title', $title, $sep, $seplocation );
957 * Display or retrieve page title for post.
959 * This is optimized for single.php template file for displaying the post title.
961 * It does not support placing the separator after the title, but by leaving the
962 * prefix parameter empty, you can set the title separator manually. The prefix
963 * does not automatically place a space between the prefix, so if there should
964 * be a space, the parameter value will need to have it at the end.
968 * @param string $prefix Optional. What to display before the title.
969 * @param bool $display Optional, default is true. Whether to display or retrieve title.
970 * @return string|void Title when retrieving.
972 function single_post_title( $prefix = '', $display = true ) {
973 $_post = get_queried_object();
975 if ( !isset($_post->post_title) )
979 * Filter the page title for a single post.
983 * @param string $_post_title The single post page title.
984 * @param object $_post The current queried object as returned by get_queried_object().
986 $title = apply_filters( 'single_post_title', $_post->post_title, $_post );
988 echo $prefix . $title;
990 return $prefix . $title;
994 * Display or retrieve title for a post type archive.
996 * This is optimized for archive.php and archive-{$post_type}.php template files
997 * for displaying the title of the post type.
1001 * @param string $prefix Optional. What to display before the title.
1002 * @param bool $display Optional, default is true. Whether to display or retrieve title.
1003 * @return string|void Title when retrieving, null when displaying or failure.
1005 function post_type_archive_title( $prefix = '', $display = true ) {
1006 if ( ! is_post_type_archive() )
1009 $post_type = get_query_var( 'post_type' );
1010 if ( is_array( $post_type ) )
1011 $post_type = reset( $post_type );
1013 $post_type_obj = get_post_type_object( $post_type );
1016 * Filter the post type archive title.
1020 * @param string $post_type_name Post type 'name' label.
1021 * @param string $post_type Post type.
1023 $title = apply_filters( 'post_type_archive_title', $post_type_obj->labels->name, $post_type );
1026 echo $prefix . $title;
1028 return $prefix . $title;
1032 * Display or retrieve page title for category archive.
1034 * This is useful for category template file or files, because it is optimized
1035 * for category page title and with less overhead than {@link wp_title()}.
1037 * It does not support placing the separator after the title, but by leaving the
1038 * prefix parameter empty, you can set the title separator manually. The prefix
1039 * does not automatically place a space between the prefix, so if there should
1040 * be a space, the parameter value will need to have it at the end.
1044 * @param string $prefix Optional. What to display before the title.
1045 * @param bool $display Optional, default is true. Whether to display or retrieve title.
1046 * @return string|void Title when retrieving.
1048 function single_cat_title( $prefix = '', $display = true ) {
1049 return single_term_title( $prefix, $display );
1053 * Display or retrieve page title for tag post archive.
1055 * Useful for tag template files for displaying the tag page title. It has less
1056 * overhead than {@link wp_title()}, because of its limited implementation.
1058 * It does not support placing the separator after the title, but by leaving the
1059 * prefix parameter empty, you can set the title separator manually. The prefix
1060 * does not automatically place a space between the prefix, so if there should
1061 * be a space, the parameter value will need to have it at the end.
1065 * @param string $prefix Optional. What to display before the title.
1066 * @param bool $display Optional, default is true. Whether to display or retrieve title.
1067 * @return string|void Title when retrieving.
1069 function single_tag_title( $prefix = '', $display = true ) {
1070 return single_term_title( $prefix, $display );
1074 * Display or retrieve page title for taxonomy term archive.
1076 * Useful for taxonomy term template files for displaying the taxonomy term page title.
1077 * It has less overhead than {@link wp_title()}, because of its limited implementation.
1079 * It does not support placing the separator after the title, but by leaving the
1080 * prefix parameter empty, you can set the title separator manually. The prefix
1081 * does not automatically place a space between the prefix, so if there should
1082 * be a space, the parameter value will need to have it at the end.
1086 * @param string $prefix Optional. What to display before the title.
1087 * @param bool $display Optional, default is true. Whether to display or retrieve title.
1088 * @return string|void Title when retrieving.
1090 function single_term_title( $prefix = '', $display = true ) {
1091 $term = get_queried_object();
1096 if ( is_category() ) {
1098 * Filter the category archive page title.
1102 * @param string $term_name Category name for archive being displayed.
1104 $term_name = apply_filters( 'single_cat_title', $term->name );
1105 } elseif ( is_tag() ) {
1107 * Filter the tag archive page title.
1111 * @param string $term_name Tag name for archive being displayed.
1113 $term_name = apply_filters( 'single_tag_title', $term->name );
1114 } elseif ( is_tax() ) {
1116 * Filter the custom taxonomy archive page title.
1120 * @param string $term_name Term name for archive being displayed.
1122 $term_name = apply_filters( 'single_term_title', $term->name );
1127 if ( empty( $term_name ) )
1131 echo $prefix . $term_name;
1133 return $prefix . $term_name;
1137 * Display or retrieve page title for post archive based on date.
1139 * Useful for when the template only needs to display the month and year, if
1140 * either are available. Optimized for just this purpose, so if it is all that
1141 * is needed, should be better than {@link wp_title()}.
1143 * It does not support placing the separator after the title, but by leaving the
1144 * prefix parameter empty, you can set the title separator manually. The prefix
1145 * does not automatically place a space between the prefix, so if there should
1146 * be a space, the parameter value will need to have it at the end.
1150 * @global WP_Locale $wp_locale
1152 * @param string $prefix Optional. What to display before the title.
1153 * @param bool $display Optional, default is true. Whether to display or retrieve title.
1154 * @return string|void Title when retrieving.
1156 function single_month_title($prefix = '', $display = true ) {
1159 $m = get_query_var('m');
1160 $year = get_query_var('year');
1161 $monthnum = get_query_var('monthnum');
1163 if ( !empty($monthnum) && !empty($year) ) {
1165 $my_month = $wp_locale->get_month($monthnum);
1166 } elseif ( !empty($m) ) {
1167 $my_year = substr($m, 0, 4);
1168 $my_month = $wp_locale->get_month(substr($m, 4, 2));
1171 if ( empty($my_month) )
1174 $result = $prefix . $my_month . $prefix . $my_year;
1182 * Display the archive title based on the queried object.
1186 * @see get_the_archive_title()
1188 * @param string $before Optional. Content to prepend to the title. Default empty.
1189 * @param string $after Optional. Content to append to the title. Default empty.
1191 function the_archive_title( $before = '', $after = '' ) {
1192 $title = get_the_archive_title();
1194 if ( ! empty( $title ) ) {
1195 echo $before . $title . $after;
1200 * Retrieve the archive title based on the queried object.
1204 * @return string Archive title.
1206 function get_the_archive_title() {
1207 if ( is_category() ) {
1208 $title = sprintf( __( 'Category: %s' ), single_cat_title( '', false ) );
1209 } elseif ( is_tag() ) {
1210 $title = sprintf( __( 'Tag: %s' ), single_tag_title( '', false ) );
1211 } elseif ( is_author() ) {
1212 $title = sprintf( __( 'Author: %s' ), '<span class="vcard">' . get_the_author() . '</span>' );
1213 } elseif ( is_year() ) {
1214 $title = sprintf( __( 'Year: %s' ), get_the_date( _x( 'Y', 'yearly archives date format' ) ) );
1215 } elseif ( is_month() ) {
1216 $title = sprintf( __( 'Month: %s' ), get_the_date( _x( 'F Y', 'monthly archives date format' ) ) );
1217 } elseif ( is_day() ) {
1218 $title = sprintf( __( 'Day: %s' ), get_the_date( _x( 'F j, Y', 'daily archives date format' ) ) );
1219 } elseif ( is_tax( 'post_format' ) ) {
1220 if ( is_tax( 'post_format', 'post-format-aside' ) ) {
1221 $title = _x( 'Asides', 'post format archive title' );
1222 } elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) {
1223 $title = _x( 'Galleries', 'post format archive title' );
1224 } elseif ( is_tax( 'post_format', 'post-format-image' ) ) {
1225 $title = _x( 'Images', 'post format archive title' );
1226 } elseif ( is_tax( 'post_format', 'post-format-video' ) ) {
1227 $title = _x( 'Videos', 'post format archive title' );
1228 } elseif ( is_tax( 'post_format', 'post-format-quote' ) ) {
1229 $title = _x( 'Quotes', 'post format archive title' );
1230 } elseif ( is_tax( 'post_format', 'post-format-link' ) ) {
1231 $title = _x( 'Links', 'post format archive title' );
1232 } elseif ( is_tax( 'post_format', 'post-format-status' ) ) {
1233 $title = _x( 'Statuses', 'post format archive title' );
1234 } elseif ( is_tax( 'post_format', 'post-format-audio' ) ) {
1235 $title = _x( 'Audio', 'post format archive title' );
1236 } elseif ( is_tax( 'post_format', 'post-format-chat' ) ) {
1237 $title = _x( 'Chats', 'post format archive title' );
1239 } elseif ( is_post_type_archive() ) {
1240 $title = sprintf( __( 'Archives: %s' ), post_type_archive_title( '', false ) );
1241 } elseif ( is_tax() ) {
1242 $tax = get_taxonomy( get_queried_object()->taxonomy );
1243 /* translators: 1: Taxonomy singular name, 2: Current taxonomy term */
1244 $title = sprintf( __( '%1$s: %2$s' ), $tax->labels->singular_name, single_term_title( '', false ) );
1246 $title = __( 'Archives' );
1250 * Filter the archive title.
1254 * @param string $title Archive title to be displayed.
1256 return apply_filters( 'get_the_archive_title', $title );
1260 * Display category, tag, or term description.
1264 * @see get_the_archive_description()
1266 * @param string $before Optional. Content to prepend to the description. Default empty.
1267 * @param string $after Optional. Content to append to the description. Default empty.
1269 function the_archive_description( $before = '', $after = '' ) {
1270 $description = get_the_archive_description();
1271 if ( $description ) {
1272 echo $before . $description . $after;
1277 * Retrieve category, tag, or term description.
1281 * @return string Archive description.
1283 function get_the_archive_description() {
1285 * Filter the archive description.
1289 * @see term_description()
1291 * @param string $description Archive description to be displayed.
1293 return apply_filters( 'get_the_archive_description', term_description() );
1297 * Retrieve archive link content based on predefined or custom code.
1299 * The format can be one of four styles. The 'link' for head element, 'option'
1300 * for use in the select element, 'html' for use in list (either ol or ul HTML
1301 * elements). Custom content is also supported using the before and after
1304 * The 'link' format uses the `<link>` HTML element with the **archives**
1305 * relationship. The before and after parameters are not used. The text
1306 * parameter is used to describe the link.
1308 * The 'option' format uses the option HTML element for use in select element.
1309 * The value is the url parameter and the before and after parameters are used
1310 * between the text description.
1312 * The 'html' format, which is the default, uses the li HTML element for use in
1313 * the list HTML elements. The before parameter is before the link and the after
1314 * parameter is after the closing link.
1316 * The custom format uses the before parameter before the link ('a' HTML
1317 * element) and the after parameter after the closing link tag. If the above
1318 * three values for the format are not used, then custom format is assumed.
1322 * @todo Properly document optional arguments as such
1324 * @param string $url URL to archive.
1325 * @param string $text Archive text description.
1326 * @param string $format Optional, default is 'html'. Can be 'link', 'option', 'html', or custom.
1327 * @param string $before Optional.
1328 * @param string $after Optional.
1329 * @return string HTML link content for archive.
1331 function get_archives_link($url, $text, $format = 'html', $before = '', $after = '') {
1332 $text = wptexturize($text);
1333 $url = esc_url($url);
1335 if ('link' == $format)
1336 $link_html = "\t<link rel='archives' title='" . esc_attr( $text ) . "' href='$url' />\n";
1337 elseif ('option' == $format)
1338 $link_html = "\t<option value='$url'>$before $text $after</option>\n";
1339 elseif ('html' == $format)
1340 $link_html = "\t<li>$before<a href='$url'>$text</a>$after</li>\n";
1342 $link_html = "\t$before<a href='$url'>$text</a>$after\n";
1345 * Filter the archive link content.
1349 * @param string $link_html The archive HTML link content.
1351 return apply_filters( 'get_archives_link', $link_html );
1355 * Display archive links based on type and format.
1359 * @see get_archives_link()
1361 * @global wpdb $wpdb
1362 * @global WP_Locale $wp_locale
1364 * @param string|array $args {
1365 * Default archive links arguments. Optional.
1367 * @type string $type Type of archive to retrieve. Accepts 'daily', 'weekly', 'monthly',
1368 * 'yearly', 'postbypost', or 'alpha'. Both 'postbypost' and 'alpha'
1369 * display the same archive link list as well as post titles instead
1370 * of displaying dates. The difference between the two is that 'alpha'
1371 * will order by post title and 'postbypost' will order by post date.
1372 * Default 'monthly'.
1373 * @type string|int $limit Number of links to limit the query to. Default empty (no limit).
1374 * @type string $format Format each link should take using the $before and $after args.
1375 * Accepts 'link' (`<link>` tag), 'option' (`<option>` tag), 'html'
1376 * (`<li>` tag), or a custom format, which generates a link anchor
1377 * with $before preceding and $after succeeding. Default 'html'.
1378 * @type string $before Markup to prepend to the beginning of each link. Default empty.
1379 * @type string $after Markup to append to the end of each link. Default empty.
1380 * @type bool $show_post_count Whether to display the post count alongside the link. Default false.
1381 * @type bool|int $echo Whether to echo or return the links list. Default 1|true to echo.
1382 * @type string $order Whether to use ascending or descending order. Accepts 'ASC', or 'DESC'.
1385 * @return string|void String when retrieving.
1387 function wp_get_archives( $args = '' ) {
1388 global $wpdb, $wp_locale;
1391 'type' => 'monthly', 'limit' => '',
1392 'format' => 'html', 'before' => '',
1393 'after' => '', 'show_post_count' => false,
1394 'echo' => 1, 'order' => 'DESC',
1397 $r = wp_parse_args( $args, $defaults );
1399 if ( '' == $r['type'] ) {
1400 $r['type'] = 'monthly';
1403 if ( ! empty( $r['limit'] ) ) {
1404 $r['limit'] = absint( $r['limit'] );
1405 $r['limit'] = ' LIMIT ' . $r['limit'];
1408 $order = strtoupper( $r['order'] );
1409 if ( $order !== 'ASC' ) {
1413 // this is what will separate dates on weekly archive links
1414 $archive_week_separator = '–';
1416 // over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride
1417 $archive_date_format_over_ride = 0;
1419 // options for daily archive (only if you over-ride the general date format)
1420 $archive_day_date_format = 'Y/m/d';
1422 // options for weekly archive (only if you over-ride the general date format)
1423 $archive_week_start_date_format = 'Y/m/d';
1424 $archive_week_end_date_format = 'Y/m/d';
1426 if ( ! $archive_date_format_over_ride ) {
1427 $archive_day_date_format = get_option( 'date_format' );
1428 $archive_week_start_date_format = get_option( 'date_format' );
1429 $archive_week_end_date_format = get_option( 'date_format' );
1433 * Filter the SQL WHERE clause for retrieving archives.
1437 * @param string $sql_where Portion of SQL query containing the WHERE clause.
1438 * @param array $r An array of default arguments.
1440 $where = apply_filters( 'getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r );
1443 * Filter the SQL JOIN clause for retrieving archives.
1447 * @param string $sql_join Portion of SQL query containing JOIN clause.
1448 * @param array $r An array of default arguments.
1450 $join = apply_filters( 'getarchives_join', '', $r );
1454 $last_changed = wp_cache_get( 'last_changed', 'posts' );
1455 if ( ! $last_changed ) {
1456 $last_changed = microtime();
1457 wp_cache_set( 'last_changed', $last_changed, 'posts' );
1460 $limit = $r['limit'];
1462 if ( 'monthly' == $r['type'] ) {
1463 $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";
1464 $key = md5( $query );
1465 $key = "wp_get_archives:$key:$last_changed";
1466 if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
1467 $results = $wpdb->get_results( $query );
1468 wp_cache_set( $key, $results, 'posts' );
1471 $after = $r['after'];
1472 foreach ( (array) $results as $result ) {
1473 $url = get_month_link( $result->year, $result->month );
1474 /* translators: 1: month name, 2: 4-digit year */
1475 $text = sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $result->month ), $result->year );
1476 if ( $r['show_post_count'] ) {
1477 $r['after'] = ' (' . $result->posts . ')' . $after;
1479 $output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
1482 } elseif ( 'yearly' == $r['type'] ) {
1483 $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";
1484 $key = md5( $query );
1485 $key = "wp_get_archives:$key:$last_changed";
1486 if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
1487 $results = $wpdb->get_results( $query );
1488 wp_cache_set( $key, $results, 'posts' );
1491 $after = $r['after'];
1492 foreach ( (array) $results as $result) {
1493 $url = get_year_link( $result->year );
1494 $text = sprintf( '%d', $result->year );
1495 if ( $r['show_post_count'] ) {
1496 $r['after'] = ' (' . $result->posts . ')' . $after;
1498 $output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
1501 } elseif ( 'daily' == $r['type'] ) {
1502 $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";
1503 $key = md5( $query );
1504 $key = "wp_get_archives:$key:$last_changed";
1505 if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
1506 $results = $wpdb->get_results( $query );
1507 wp_cache_set( $key, $results, 'posts' );
1510 $after = $r['after'];
1511 foreach ( (array) $results as $result ) {
1512 $url = get_day_link( $result->year, $result->month, $result->dayofmonth );
1513 $date = sprintf( '%1$d-%2$02d-%3$02d 00:00:00', $result->year, $result->month, $result->dayofmonth );
1514 $text = mysql2date( $archive_day_date_format, $date );
1515 if ( $r['show_post_count'] ) {
1516 $r['after'] = ' (' . $result->posts . ')' . $after;
1518 $output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
1521 } elseif ( 'weekly' == $r['type'] ) {
1522 $week = _wp_mysql_week( '`post_date`' );
1523 $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";
1524 $key = md5( $query );
1525 $key = "wp_get_archives:$key:$last_changed";
1526 if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
1527 $results = $wpdb->get_results( $query );
1528 wp_cache_set( $key, $results, 'posts' );
1532 $after = $r['after'];
1533 foreach ( (array) $results as $result ) {
1534 if ( $result->week != $arc_w_last ) {
1535 $arc_year = $result->yr;
1536 $arc_w_last = $result->week;
1537 $arc_week = get_weekstartend( $result->yyyymmdd, get_option( 'start_of_week' ) );
1538 $arc_week_start = date_i18n( $archive_week_start_date_format, $arc_week['start'] );
1539 $arc_week_end = date_i18n( $archive_week_end_date_format, $arc_week['end'] );
1540 $url = sprintf( '%1$s/%2$s%3$sm%4$s%5$s%6$sw%7$s%8$d', home_url(), '', '?', '=', $arc_year, '&', '=', $result->week );
1541 $text = $arc_week_start . $archive_week_separator . $arc_week_end;
1542 if ( $r['show_post_count'] ) {
1543 $r['after'] = ' (' . $result->posts . ')' . $after;
1545 $output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
1549 } elseif ( ( 'postbypost' == $r['type'] ) || ('alpha' == $r['type'] ) ) {
1550 $orderby = ( 'alpha' == $r['type'] ) ? 'post_title ASC ' : 'post_date DESC, ID DESC ';
1551 $query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit";
1552 $key = md5( $query );
1553 $key = "wp_get_archives:$key:$last_changed";
1554 if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
1555 $results = $wpdb->get_results( $query );
1556 wp_cache_set( $key, $results, 'posts' );
1559 foreach ( (array) $results as $result ) {
1560 if ( $result->post_date != '0000-00-00 00:00:00' ) {
1561 $url = get_permalink( $result );
1562 if ( $result->post_title ) {
1563 /** This filter is documented in wp-includes/post-template.php */
1564 $text = strip_tags( apply_filters( 'the_title', $result->post_title, $result->ID ) );
1566 $text = $result->ID;
1568 $output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
1581 * Get number of days since the start of the week.
1585 * @param int $num Number of day.
1586 * @return int Days since the start of the week.
1588 function calendar_week_mod($num) {
1590 return ($num - $base*floor($num/$base));
1594 * Display calendar with days that have posts as links.
1596 * The calendar is cached, which will be retrieved, if it exists. If there are
1597 * no posts for the month, then it will not be displayed.
1601 * @global wpdb $wpdb
1603 * @global int $monthnum
1605 * @global WP_Locale $wp_locale
1606 * @global array $posts
1608 * @param bool $initial Optional, default is true. Use initial calendar names.
1609 * @param bool $echo Optional, default is true. Set to false for return.
1610 * @return string|void String when retrieving.
1612 function get_calendar($initial = true, $echo = true) {
1613 global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
1615 $key = md5( $m . $monthnum . $year );
1616 if ( $cache = wp_cache_get( 'get_calendar', 'calendar' ) ) {
1617 if ( is_array($cache) && isset( $cache[ $key ] ) ) {
1619 /** This filter is documented in wp-includes/general-template.php */
1620 echo apply_filters( 'get_calendar', $cache[$key] );
1623 /** This filter is documented in wp-includes/general-template.php */
1624 return apply_filters( 'get_calendar', $cache[$key] );
1629 if ( !is_array($cache) )
1632 // Quick check. If we have no posts at all, abort!
1634 $gotsome = $wpdb->get_var("SELECT 1 as test FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1");
1636 $cache[ $key ] = '';
1637 wp_cache_set( 'get_calendar', $cache, 'calendar' );
1642 if ( isset($_GET['w']) )
1643 $w = ''.intval($_GET['w']);
1645 // week_begins = 0 stands for Sunday
1646 $week_begins = intval(get_option('start_of_week'));
1648 // Let's figure out when we are
1649 if ( !empty($monthnum) && !empty($year) ) {
1650 $thismonth = ''.zeroise(intval($monthnum), 2);
1651 $thisyear = ''.intval($year);
1652 } elseif ( !empty($w) ) {
1653 // We need to get the month from MySQL
1654 $thisyear = ''.intval(substr($m, 0, 4));
1655 $d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's
1656 $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')");
1657 } elseif ( !empty($m) ) {
1658 $thisyear = ''.intval(substr($m, 0, 4));
1659 if ( strlen($m) < 6 )
1662 $thismonth = ''.zeroise(intval(substr($m, 4, 2)), 2);
1664 $thisyear = gmdate('Y', current_time('timestamp'));
1665 $thismonth = gmdate('m', current_time('timestamp'));
1668 $unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear);
1669 $last_day = date('t', $unixmonth);
1671 // Get the next and previous month and year with at least one post
1672 $previous = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
1674 WHERE post_date < '$thisyear-$thismonth-01'
1675 AND post_type = 'post' AND post_status = 'publish'
1676 ORDER BY post_date DESC
1678 $next = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
1680 WHERE post_date > '$thisyear-$thismonth-{$last_day} 23:59:59'
1681 AND post_type = 'post' AND post_status = 'publish'
1682 ORDER BY post_date ASC
1685 /* translators: Calendar caption: 1: month name, 2: 4-digit year */
1686 $calendar_caption = _x('%1$s %2$s', 'calendar caption');
1687 $calendar_output = '<table id="wp-calendar">
1688 <caption>' . sprintf($calendar_caption, $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '</caption>
1694 for ( $wdcount=0; $wdcount<=6; $wdcount++ ) {
1695 $myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7);
1698 foreach ( $myweek as $wd ) {
1699 $day_name = $initial ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
1700 $wd = esc_attr($wd);
1701 $calendar_output .= "\n\t\t<th scope=\"col\" title=\"$wd\">$day_name</th>";
1704 $calendar_output .= '
1712 $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>';
1714 $calendar_output .= "\n\t\t".'<td colspan="3" id="prev" class="pad"> </td>';
1717 $calendar_output .= "\n\t\t".'<td class="pad"> </td>';
1720 $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>';
1722 $calendar_output .= "\n\t\t".'<td colspan="3" id="next" class="pad"> </td>';
1725 $calendar_output .= '
1732 $daywithpost = array();
1734 // Get days with posts
1735 $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
1736 FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00'
1737 AND post_type = 'post' AND post_status = 'publish'
1738 AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'", ARRAY_N);
1739 if ( $dayswithposts ) {
1740 foreach ( (array) $dayswithposts as $daywith ) {
1741 $daywithpost[] = $daywith[0];
1745 if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'camino') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false)
1746 $ak_title_separator = "\n";
1748 $ak_title_separator = ', ';
1750 $ak_titles_for_day = array();
1751 $ak_post_titles = $wpdb->get_results("SELECT ID, post_title, DAYOFMONTH(post_date) as dom "
1752 ."FROM $wpdb->posts "
1753 ."WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' "
1754 ."AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59' "
1755 ."AND post_type = 'post' AND post_status = 'publish'"
1757 if ( $ak_post_titles ) {
1758 foreach ( (array) $ak_post_titles as $ak_post_title ) {
1760 /** This filter is documented in wp-includes/post-template.php */
1761 $post_title = esc_attr( apply_filters( 'the_title', $ak_post_title->post_title, $ak_post_title->ID ) );
1763 if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) )
1764 $ak_titles_for_day['day_'.$ak_post_title->dom] = '';
1765 if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one
1766 $ak_titles_for_day["$ak_post_title->dom"] = $post_title;
1768 $ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . $post_title;
1772 // See how much we should pad in the beginning
1773 $pad = calendar_week_mod(date('w', $unixmonth)-$week_begins);
1775 $calendar_output .= "\n\t\t".'<td colspan="'. esc_attr($pad) .'" class="pad"> </td>';
1777 $daysinmonth = intval(date('t', $unixmonth));
1778 for ( $day = 1; $day <= $daysinmonth; ++$day ) {
1779 if ( isset($newrow) && $newrow )
1780 $calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
1783 if ( $day == gmdate('j', current_time('timestamp')) && $thismonth == gmdate('m', current_time('timestamp')) && $thisyear == gmdate('Y', current_time('timestamp')) )
1784 $calendar_output .= '<td id="today">';
1786 $calendar_output .= '<td>';
1788 if ( in_array($day, $daywithpost) ) // any posts today?
1789 $calendar_output .= '<a href="' . get_day_link( $thisyear, $thismonth, $day ) . '" title="' . esc_attr( $ak_titles_for_day[ $day ] ) . "\">$day</a>";
1791 $calendar_output .= $day;
1792 $calendar_output .= '</td>';
1794 if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) )
1798 $pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins);
1799 if ( $pad != 0 && $pad != 7 )
1800 $calendar_output .= "\n\t\t".'<td class="pad" colspan="'. esc_attr($pad) .'"> </td>';
1802 $calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>";
1804 $cache[ $key ] = $calendar_output;
1805 wp_cache_set( 'get_calendar', $cache, 'calendar' );
1809 * Filter the HTML calendar output.
1813 * @param string $calendar_output HTML output of the calendar.
1815 echo apply_filters( 'get_calendar', $calendar_output );
1817 /** This filter is documented in wp-includes/general-template.php */
1818 return apply_filters( 'get_calendar', $calendar_output );
1824 * Purge the cached results of get_calendar.
1829 function delete_get_calendar_cache() {
1830 wp_cache_delete( 'get_calendar', 'calendar' );
1834 * Display all of the allowed tags in HTML format with attributes.
1836 * This is useful for displaying in the comment area, which elements and
1837 * attributes are supported. As well as any plugins which want to display it.
1841 * @global array $allowedtags
1843 * @return string HTML allowed tags entity encoded.
1845 function allowed_tags() {
1846 global $allowedtags;
1848 foreach ( (array) $allowedtags as $tag => $attributes ) {
1849 $allowed .= '<'.$tag;
1850 if ( 0 < count($attributes) ) {
1851 foreach ( $attributes as $attribute => $limits ) {
1852 $allowed .= ' '.$attribute.'=""';
1857 return htmlentities( $allowed );
1860 /***** Date/Time tags *****/
1863 * Outputs the date in iso8601 format for xml files.
1867 function the_date_xml() {
1868 echo mysql2date( 'Y-m-d', get_post()->post_date, false );
1872 * Display or Retrieve the date the current post was written (once per date)
1874 * Will only output the date if the current post's date is different from the
1875 * previous one output.
1877 * i.e. Only one date listing will show per day worth of posts shown in the loop, even if the
1878 * function is called several times for each post.
1880 * HTML output can be filtered with 'the_date'.
1881 * Date string output can be filtered with 'get_the_date'.
1885 * @global string|int|bool $currentday
1886 * @global string|int|bool $previousday
1888 * @param string $d Optional. PHP date format defaults to the date_format option if not specified.
1889 * @param string $before Optional. Output before the date.
1890 * @param string $after Optional. Output after the date.
1891 * @param bool $echo Optional, default is display. Whether to echo the date or return it.
1892 * @return string|void String if retrieving.
1894 function the_date( $d = '', $before = '', $after = '', $echo = true ) {
1895 global $currentday, $previousday;
1897 if ( $currentday != $previousday ) {
1898 $the_date = $before . get_the_date( $d ) . $after;
1899 $previousday = $currentday;
1902 * Filter the date a post was published for display.
1906 * @param string $the_date The formatted date string.
1907 * @param string $d PHP date format. Defaults to 'date_format' option
1909 * @param string $before HTML output before the date.
1910 * @param string $after HTML output after the date.
1912 $the_date = apply_filters( 'the_date', $the_date, $d, $before, $after );
1922 * Retrieve the date on which the post was written.
1924 * Unlike the_date() this function will always return the date.
1925 * Modify output with 'get_the_date' filter.
1929 * @param string $d Optional. PHP date format defaults to the date_format option if not specified.
1930 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default current post.
1931 * @return false|string Date the current post was written. False on failure.
1933 function get_the_date( $d = '', $post = null ) {
1934 $post = get_post( $post );
1941 $the_date = mysql2date( get_option( 'date_format' ), $post->post_date );
1943 $the_date = mysql2date( $d, $post->post_date );
1947 * Filter the date a post was published.
1951 * @param string $the_date The formatted date.
1952 * @param string $d PHP date format. Defaults to 'date_format' option
1954 * @param int|WP_Post $post The post object or ID.
1956 return apply_filters( 'get_the_date', $the_date, $d, $post );
1960 * Display the date on which the post was last modified.
1964 * @param string $d Optional. PHP date format defaults to the date_format option if not specified.
1965 * @param string $before Optional. Output before the date.
1966 * @param string $after Optional. Output after the date.
1967 * @param bool $echo Optional, default is display. Whether to echo the date or return it.
1968 * @return string|void String if retrieving.
1970 function the_modified_date( $d = '', $before = '', $after = '', $echo = true ) {
1971 $the_modified_date = $before . get_the_modified_date($d) . $after;
1974 * Filter the date a post was last modified for display.
1978 * @param string $the_modified_date The last modified date.
1979 * @param string $d PHP date format. Defaults to 'date_format' option
1981 * @param string $before HTML output before the date.
1982 * @param string $after HTML output after the date.
1984 $the_modified_date = apply_filters( 'the_modified_date', $the_modified_date, $d, $before, $after );
1987 echo $the_modified_date;
1989 return $the_modified_date;
1994 * Retrieve the date on which the post was last modified.
1998 * @param string $d Optional. PHP date format. Defaults to the "date_format" option
2001 function get_the_modified_date($d = '') {
2003 $the_time = get_post_modified_time(get_option('date_format'), null, null, true);
2005 $the_time = get_post_modified_time($d, null, null, true);
2008 * Filter the date a post was last modified.
2012 * @param string $the_time The formatted date.
2013 * @param string $d PHP date format. Defaults to value specified in
2014 * 'date_format' option.
2016 return apply_filters( 'get_the_modified_date', $the_time, $d );
2020 * Display the time at which the post was written.
2024 * @param string $d Either 'G', 'U', or php date format.
2026 function the_time( $d = '' ) {
2028 * Filter the time a post was written for display.
2032 * @param string $get_the_time The formatted time.
2033 * @param string $d The time format. Accepts 'G', 'U',
2034 * or php date format.
2036 echo apply_filters( 'the_time', get_the_time( $d ), $d );
2040 * Retrieve the time at which the post was written.
2044 * @param string $d Optional. Format to use for retrieving the time the post
2045 * was written. Either 'G', 'U', or php date format defaults
2046 * to the value specified in the time_format option. Default empty.
2047 * @param int|WP_Post $post WP_Post object or ID. Default is global $post object.
2048 * @return false|string Formatted date string or Unix timestamp. False on failure.
2050 function get_the_time( $d = '', $post = null ) {
2051 $post = get_post($post);
2058 $the_time = get_post_time(get_option('time_format'), false, $post, true);
2060 $the_time = get_post_time($d, false, $post, true);
2063 * Filter the time a post was written.
2067 * @param string $the_time The formatted time.
2068 * @param string $d Format to use for retrieving the time the post was written.
2069 * Accepts 'G', 'U', or php date format value specified
2070 * in 'time_format' option. Default empty.
2071 * @param int|WP_Post $post WP_Post object or ID.
2073 return apply_filters( 'get_the_time', $the_time, $d, $post );
2077 * Retrieve the time at which the post was written.
2081 * @param string $d Optional. Format to use for retrieving the time the post
2082 * was written. Either 'G', 'U', or php date format. Default 'U'.
2083 * @param bool $gmt Optional. Whether to retrieve the GMT time. Default false.
2084 * @param int|WP_Post $post WP_Post object or ID. Default is global $post object.
2085 * @param bool $translate Whether to translate the time string. Default false.
2086 * @return false|string|int Formatted date string or Unix timestamp. False on failure.
2088 function get_post_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
2089 $post = get_post($post);
2096 $time = $post->post_date_gmt;
2098 $time = $post->post_date;
2100 $time = mysql2date($d, $time, $translate);
2103 * Filter the localized time a post was written.
2107 * @param string $time The formatted time.
2108 * @param string $d Format to use for retrieving the time the post was written.
2109 * Accepts 'G', 'U', or php date format. Default 'U'.
2110 * @param bool $gmt Whether to retrieve the GMT time. Default false.
2112 return apply_filters( 'get_post_time', $time, $d, $gmt );
2116 * Display the time at which the post was last modified.
2120 * @param string $d Optional Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
2122 function the_modified_time($d = '') {
2124 * Filter the localized time a post was last modified, for display.
2128 * @param string $get_the_modified_time The formatted time.
2129 * @param string $d The time format. Accepts 'G', 'U',
2130 * or php date format. Defaults to value
2131 * specified in 'time_format' option.
2133 echo apply_filters( 'the_modified_time', get_the_modified_time($d), $d );
2137 * Retrieve the time at which the post was last modified.
2141 * @param string $d Optional Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
2144 function get_the_modified_time($d = '') {
2146 $the_time = get_post_modified_time(get_option('time_format'), null, null, true);
2148 $the_time = get_post_modified_time($d, null, null, true);
2151 * Filter the localized time a post was last modified.
2155 * @param string $the_time The formatted time.
2156 * @param string $d Format to use for retrieving the time the post was
2157 * written. Accepts 'G', 'U', or php date format. Defaults
2158 * to value specified in 'time_format' option.
2160 return apply_filters( 'get_the_modified_time', $the_time, $d );
2164 * Retrieve the time at which the post was last modified.
2168 * @param string $d Optional. Format to use for retrieving the time the post
2169 * was modified. Either 'G', 'U', or php date format. Default 'U'.
2170 * @param bool $gmt Optional. Whether to retrieve the GMT time. Default false.
2171 * @param int|WP_Post $post WP_Post object or ID. Default is global $post object.
2172 * @param bool $translate Whether to translate the time string. Default false.
2173 * @return false|string Formatted date string or Unix timestamp. False on failure.
2175 function get_post_modified_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
2176 $post = get_post($post);
2183 $time = $post->post_modified_gmt;
2185 $time = $post->post_modified;
2186 $time = mysql2date($d, $time, $translate);
2189 * Filter the localized time a post was last modified.
2193 * @param string $time The formatted time.
2194 * @param string $d The date format. Accepts 'G', 'U', or php date format. Default 'U'.
2195 * @param bool $gmt Whether to return the GMT time. Default false.
2197 return apply_filters( 'get_post_modified_time', $time, $d, $gmt );
2201 * Display the weekday on which the post was written.
2205 * @global WP_Locale $wp_locale
2207 function the_weekday() {
2209 $the_weekday = $wp_locale->get_weekday( mysql2date( 'w', get_post()->post_date, false ) );
2212 * Filter the weekday on which the post was written, for display.
2216 * @param string $the_weekday
2218 echo apply_filters( 'the_weekday', $the_weekday );
2222 * Display the weekday on which the post was written.
2224 * Will only output the weekday if the current post's weekday is different from
2225 * the previous one output.
2229 * @global WP_Locale $wp_locale
2230 * @global string|int|bool $currentday
2231 * @global string|int|bool $previousweekday
2233 * @param string $before Optional Output before the date.
2234 * @param string $after Optional Output after the date.
2236 function the_weekday_date($before='',$after='') {
2237 global $wp_locale, $currentday, $previousweekday;
2238 $the_weekday_date = '';
2239 if ( $currentday != $previousweekday ) {
2240 $the_weekday_date .= $before;
2241 $the_weekday_date .= $wp_locale->get_weekday( mysql2date( 'w', get_post()->post_date, false ) );
2242 $the_weekday_date .= $after;
2243 $previousweekday = $currentday;
2247 * Filter the localized date on which the post was written, for display.
2251 * @param string $the_weekday_date
2252 * @param string $before The HTML to output before the date.
2253 * @param string $after The HTML to output after the date.
2255 $the_weekday_date = apply_filters( 'the_weekday_date', $the_weekday_date, $before, $after );
2256 echo $the_weekday_date;
2260 * Fire the wp_head action
2264 function wp_head() {
2266 * Print scripts or data in the head tag on the front end.
2270 do_action( 'wp_head' );
2274 * Fire the wp_footer action
2278 function wp_footer() {
2280 * Print scripts or data before the closing body tag on the front end.
2284 do_action( 'wp_footer' );
2288 * Display the links to the general feeds.
2292 * @param array $args Optional arguments.
2294 function feed_links( $args = array() ) {
2295 if ( !current_theme_supports('automatic-feed-links') )
2299 /* translators: Separator between blog name and feed type in feed links */
2300 'separator' => _x('»', 'feed link'),
2301 /* translators: 1: blog title, 2: separator (raquo) */
2302 'feedtitle' => __('%1$s %2$s Feed'),
2303 /* translators: 1: blog title, 2: separator (raquo) */
2304 'comstitle' => __('%1$s %2$s Comments Feed'),
2307 $args = wp_parse_args( $args, $defaults );
2309 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";
2310 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";
2314 * Display the links to the extra feeds such as category feeds.
2318 * @param array $args Optional arguments.
2320 function feed_links_extra( $args = array() ) {
2322 /* translators: Separator between blog name and feed type in feed links */
2323 'separator' => _x('»', 'feed link'),
2324 /* translators: 1: blog name, 2: separator(raquo), 3: post title */
2325 'singletitle' => __('%1$s %2$s %3$s Comments Feed'),
2326 /* translators: 1: blog name, 2: separator(raquo), 3: category name */
2327 'cattitle' => __('%1$s %2$s %3$s Category Feed'),
2328 /* translators: 1: blog name, 2: separator(raquo), 3: tag name */
2329 'tagtitle' => __('%1$s %2$s %3$s Tag Feed'),
2330 /* translators: 1: blog name, 2: separator(raquo), 3: author name */
2331 'authortitle' => __('%1$s %2$s Posts by %3$s Feed'),
2332 /* translators: 1: blog name, 2: separator(raquo), 3: search phrase */
2333 'searchtitle' => __('%1$s %2$s Search Results for “%3$s” Feed'),
2334 /* translators: 1: blog name, 2: separator(raquo), 3: post type name */
2335 'posttypetitle' => __('%1$s %2$s %3$s Feed'),
2338 $args = wp_parse_args( $args, $defaults );
2340 if ( is_singular() ) {
2342 $post = get_post( $id );
2344 if ( comments_open() || pings_open() || $post->comment_count > 0 ) {
2345 $title = sprintf( $args['singletitle'], get_bloginfo('name'), $args['separator'], the_title_attribute( array( 'echo' => false ) ) );
2346 $href = get_post_comments_feed_link( $post->ID );
2348 } elseif ( is_post_type_archive() ) {
2349 $post_type = get_query_var( 'post_type' );
2350 if ( is_array( $post_type ) )
2351 $post_type = reset( $post_type );
2353 $post_type_obj = get_post_type_object( $post_type );
2354 $title = sprintf( $args['posttypetitle'], get_bloginfo( 'name' ), $args['separator'], $post_type_obj->labels->name );
2355 $href = get_post_type_archive_feed_link( $post_type_obj->name );
2356 } elseif ( is_category() ) {
2357 $term = get_queried_object();
2360 $title = sprintf( $args['cattitle'], get_bloginfo('name'), $args['separator'], $term->name );
2361 $href = get_category_feed_link( $term->term_id );
2363 } elseif ( is_tag() ) {
2364 $term = get_queried_object();
2367 $title = sprintf( $args['tagtitle'], get_bloginfo('name'), $args['separator'], $term->name );
2368 $href = get_tag_feed_link( $term->term_id );
2370 } elseif ( is_author() ) {
2371 $author_id = intval( get_query_var('author') );
2373 $title = sprintf( $args['authortitle'], get_bloginfo('name'), $args['separator'], get_the_author_meta( 'display_name', $author_id ) );
2374 $href = get_author_feed_link( $author_id );
2375 } elseif ( is_search() ) {
2376 $title = sprintf( $args['searchtitle'], get_bloginfo('name'), $args['separator'], get_search_query( false ) );
2377 $href = get_search_feed_link();
2378 } elseif ( is_post_type_archive() ) {
2379 $title = sprintf( $args['posttypetitle'], get_bloginfo('name'), $args['separator'], post_type_archive_title( '', false ) );
2380 $post_type_obj = get_queried_object();
2381 if ( $post_type_obj )
2382 $href = get_post_type_archive_feed_link( $post_type_obj->name );
2385 if ( isset($title) && isset($href) )
2386 echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( $title ) . '" href="' . esc_url( $href ) . '" />' . "\n";
2390 * Display the link to the Really Simple Discovery service endpoint.
2392 * @link http://archipelago.phrasewise.com/rsd
2395 function rsd_link() {
2396 echo '<link rel="EditURI" type="application/rsd+xml" title="RSD" href="' . get_bloginfo('wpurl') . "/xmlrpc.php?rsd\" />\n";
2400 * Display the link to the Windows Live Writer manifest file.
2402 * @link http://msdn.microsoft.com/en-us/library/bb463265.aspx
2405 function wlwmanifest_link() {
2406 echo '<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="',
2407 includes_url( 'wlwmanifest.xml' ), '" /> ', "\n";
2411 * Display a noindex meta tag if required by the blog configuration.
2413 * If a blog is marked as not being public then the noindex meta tag will be
2414 * output to tell web robots not to index the page content. Add this to the wp_head action.
2415 * Typical usage is as a wp_head callback. add_action( 'wp_head', 'noindex' );
2421 function noindex() {
2422 // If the blog is not public, tell robots to go away.
2423 if ( '0' == get_option('blog_public') )
2428 * Display a noindex meta tag.
2430 * Outputs a noindex meta tag that tells web robots not to index the page content.
2431 * Typical usage is as a wp_head callback. add_action( 'wp_head', 'wp_no_robots' );
2435 function wp_no_robots() {
2436 echo "<meta name='robots' content='noindex,follow' />\n";
2440 * Display site icon meta tags.
2444 * @link http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#rel-icon HTML5 specification link icon.
2446 function wp_site_icon() {
2447 if ( ! has_site_icon() && ! is_customize_preview() ) {
2452 sprintf( '<link rel="icon" href="%s" sizes="32x32" />', esc_url( get_site_icon_url( 32 ) ) ),
2453 sprintf( '<link rel="icon" href="%s" sizes="192x192" />', esc_url( get_site_icon_url( 192 ) ) ),
2454 sprintf( '<link rel="apple-touch-icon-precomposed" href="%s">', esc_url( get_site_icon_url( 180 ) ) ),
2455 sprintf( '<meta name="msapplication-TileImage" content="%s">', esc_url( get_site_icon_url( 270 ) ) ),
2459 * Filter the site icon meta tags, so Plugins can add their own.
2463 * @param array $meta_tags Site Icon meta elements.
2465 $meta_tags = apply_filters( 'site_icon_meta_tags', $meta_tags );
2466 $meta_tags = array_filter( $meta_tags );
2468 foreach ( $meta_tags as $meta_tag ) {
2474 * Whether the user should have a WYSIWIG editor.
2476 * Checks that the user requires a WYSIWIG editor and that the editor is
2477 * supported in the users browser.
2481 * @global bool $wp_rich_edit
2482 * @global bool $is_gecko
2483 * @global bool $is_opera
2484 * @global bool $is_safari
2485 * @global bool $is_chrome
2486 * @global bool $is_IE
2490 function user_can_richedit() {
2491 global $wp_rich_edit, $is_gecko, $is_opera, $is_safari, $is_chrome, $is_IE;
2493 if ( !isset($wp_rich_edit) ) {
2494 $wp_rich_edit = false;
2496 if ( get_user_option( 'rich_editing' ) == 'true' || ! is_user_logged_in() ) { // default to 'true' for logged out users
2498 $wp_rich_edit = ! wp_is_mobile() || ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval( $match[1] ) >= 534 );
2499 } elseif ( $is_gecko || $is_chrome || $is_IE || ( $is_opera && !wp_is_mobile() ) ) {
2500 $wp_rich_edit = true;
2506 * Filter whether the user can access the rich (Visual) editor.
2510 * @param bool $wp_rich_edit Whether the user can access to the rich (Visual) editor.
2512 return apply_filters( 'user_can_richedit', $wp_rich_edit );
2516 * Find out which editor should be displayed by default.
2518 * Works out which of the two editors to display as the current editor for a
2519 * user. The 'html' setting is for the "Text" editor tab.
2523 * @return string Either 'tinymce', or 'html', or 'test'
2525 function wp_default_editor() {
2526 $r = user_can_richedit() ? 'tinymce' : 'html'; // defaults
2527 if ( wp_get_current_user() ) { // look for cookie
2528 $ed = get_user_setting('editor', 'tinymce');
2529 $r = ( in_array($ed, array('tinymce', 'html', 'test') ) ) ? $ed : $r;
2533 * Filter which editor should be displayed by default.
2537 * @param array $r An array of editors. Accepts 'tinymce', 'html', 'test'.
2539 return apply_filters( 'wp_default_editor', $r );
2543 * Renders an editor.
2545 * Using this function is the proper way to output all needed components for both TinyMCE and Quicktags.
2546 * _WP_Editors should not be used directly. See https://core.trac.wordpress.org/ticket/17144.
2548 * NOTE: Once initialized the TinyMCE editor cannot be safely moved in the DOM. For that reason
2549 * running wp_editor() inside of a metabox is not a good idea unless only Quicktags is used.
2550 * On the post edit screen several actions can be used to include additional editors
2551 * containing TinyMCE: 'edit_page_form', 'edit_form_advanced' and 'dbx_post_sidebar'.
2552 * See https://core.trac.wordpress.org/ticket/19173 for more information.
2554 * @see wp-includes/class-wp-editor.php
2557 * @param string $content Initial content for the editor.
2558 * @param string $editor_id HTML ID attribute value for the textarea and TinyMCE. Can only be /[a-z]+/.
2559 * @param array $settings See _WP_Editors::editor().
2561 function wp_editor( $content, $editor_id, $settings = array() ) {
2562 if ( ! class_exists( '_WP_Editors' ) )
2563 require( ABSPATH . WPINC . '/class-wp-editor.php' );
2565 _WP_Editors::editor($content, $editor_id, $settings);
2569 * Retrieve the contents of the search WordPress query variable.
2571 * The search query string is passed through {@link esc_attr()}
2572 * to ensure that it is safe for placing in an html attribute.
2576 * @param bool $escaped Whether the result is escaped. Default true.
2577 * Only use when you are later escaping it. Do not use unescaped.
2580 function get_search_query( $escaped = true ) {
2582 * Filter the contents of the search query variable.
2586 * @param mixed $search Contents of the search query variable.
2588 $query = apply_filters( 'get_search_query', get_query_var( 's' ) );
2591 $query = esc_attr( $query );
2596 * Display the contents of the search query variable.
2598 * The search query string is passed through {@link esc_attr()}
2599 * to ensure that it is safe for placing in an html attribute.
2603 function the_search_query() {
2605 * Filter the contents of the search query variable for display.
2609 * @param mixed $search Contents of the search query variable.
2611 echo esc_attr( apply_filters( 'the_search_query', get_search_query( false ) ) );
2615 * Gets the language attributes for the html tag.
2617 * Builds up a set of html attributes containing the text direction and language
2618 * information for the page.
2622 * @param string $doctype Optional. The type of html document. Accepts 'xhtml' or 'html'. Default 'html'.
2624 function get_language_attributes( $doctype = 'html' ) {
2625 $attributes = array();
2627 if ( function_exists( 'is_rtl' ) && is_rtl() )
2628 $attributes[] = 'dir="rtl"';
2630 if ( $lang = get_bloginfo('language') ) {
2631 if ( get_option('html_type') == 'text/html' || $doctype == 'html' )
2632 $attributes[] = "lang=\"$lang\"";
2634 if ( get_option('html_type') != 'text/html' || $doctype == 'xhtml' )
2635 $attributes[] = "xml:lang=\"$lang\"";
2638 $output = implode(' ', $attributes);
2641 * Filter the language attributes for display in the html tag.
2644 * @since 4.3.0 Added the `$doctype` parameter.
2646 * @param string $output A space-separated list of language attributes.
2647 * @param string $doctype The type of html document (xhtml|html).
2649 return apply_filters( 'language_attributes', $output, $doctype );
2653 * Displays the language attributes for the html tag.
2655 * Builds up a set of html attributes containing the text direction and language
2656 * information for the page.
2659 * @since 4.3.0 Converted into a wrapper for get_language_attributes().
2661 * @param string $doctype Optional. The type of html document. Accepts 'xhtml' or 'html'. Default 'html'.
2663 function language_attributes( $doctype = 'html' ) {
2664 echo get_language_attributes( $doctype );
2668 * Retrieve paginated link for archive post pages.
2670 * Technically, the function can be used to create paginated link list for any
2671 * area. The 'base' argument is used to reference the url, which will be used to
2672 * create the paginated links. The 'format' argument is then used for replacing
2673 * the page number. It is however, most likely and by default, to be used on the
2674 * archive post pages.
2676 * The 'type' argument controls format of the returned value. The default is
2677 * 'plain', which is just a string with the links separated by a newline
2678 * character. The other possible values are either 'array' or 'list'. The
2679 * 'array' value will return an array of the paginated link list to offer full
2680 * control of display. The 'list' value will place all of the paginated links in
2681 * an unordered HTML list.
2683 * The 'total' argument is the total amount of pages and is an integer. The
2684 * 'current' argument is the current page number and is also an integer.
2686 * An example of the 'base' argument is "http://example.com/all_posts.php%_%"
2687 * and the '%_%' is required. The '%_%' will be replaced by the contents of in
2688 * the 'format' argument. An example for the 'format' argument is "?page=%#%"
2689 * and the '%#%' is also required. The '%#%' will be replaced with the page
2692 * You can include the previous and next links in the list by setting the
2693 * 'prev_next' argument to true, which it is by default. You can set the
2694 * previous text, by using the 'prev_text' argument. You can set the next text
2695 * by setting the 'next_text' argument.
2697 * If the 'show_all' argument is set to true, then it will show all of the pages
2698 * instead of a short list of the pages near the current page. By default, the
2699 * 'show_all' is set to false and controlled by the 'end_size' and 'mid_size'
2700 * arguments. The 'end_size' argument is how many numbers on either the start
2701 * and the end list edges, by default is 1. The 'mid_size' argument is how many
2702 * numbers to either side of current page, but not including current page.
2704 * It is possible to add query vars to the link by using the 'add_args' argument
2705 * and see {@link add_query_arg()} for more information.
2707 * The 'before_page_number' and 'after_page_number' arguments allow users to
2708 * augment the links themselves. Typically this might be to add context to the
2709 * numbered links so that screen reader users understand what the links are for.
2710 * The text strings are added before and after the page number - within the
2715 * @global WP_Query $wp_query
2716 * @global WP_Rewrite $wp_rewrite
2718 * @param string|array $args {
2719 * Optional. Array or string of arguments for generating paginated links for archives.
2721 * @type string $base Base of the paginated url. Default empty.
2722 * @type string $format Format for the pagination structure. Default empty.
2723 * @type int $total The total amount of pages. Default is the value WP_Query's
2724 * `max_num_pages` or 1.
2725 * @type int $current The current page number. Default is 'paged' query var or 1.
2726 * @type bool $show_all Whether to show all pages. Default false.
2727 * @type int $end_size How many numbers on either the start and the end list edges.
2729 * @type int $mid_size How many numbers to either side of the current pages. Default 2.
2730 * @type bool $prev_next Whether to include the previous and next links in the list. Default true.
2731 * @type bool $prev_text The previous page text. Default '« Previous'.
2732 * @type bool $next_text The next page text. Default '« Previous'.
2733 * @type string $type Controls format of the returned value. Possible values are 'plain',
2734 * 'array' and 'list'. Default is 'plain'.
2735 * @type array $add_args An array of query args to add. Default false.
2736 * @type string $add_fragment A string to append to each link. Default empty.
2737 * @type string $before_page_number A string to appear before the page number. Default empty.
2738 * @type string $after_page_number A string to append after the page number. Default empty.
2740 * @return array|string|void String of page links or array of page links.
2742 function paginate_links( $args = '' ) {
2743 global $wp_query, $wp_rewrite;
2745 // Setting up default values based on the current URL.
2746 $pagenum_link = html_entity_decode( get_pagenum_link() );
2747 $url_parts = explode( '?', $pagenum_link );
2749 // Get max pages and current page out of the current query, if available.
2750 $total = isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1;
2751 $current = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1;
2753 // Append the format placeholder to the base URL.
2754 $pagenum_link = trailingslashit( $url_parts[0] ) . '%_%';
2756 // URL base depends on permalink settings.
2757 $format = $wp_rewrite->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : '';
2758 $format .= $wp_rewrite->using_permalinks() ? user_trailingslashit( $wp_rewrite->pagination_base . '/%#%', 'paged' ) : '?paged=%#%';
2761 'base' => $pagenum_link, // http://example.com/all_posts.php%_% : %_% is replaced by format (below)
2762 'format' => $format, // ?page=%#% : %#% is replaced by the page number
2764 'current' => $current,
2765 'show_all' => false,
2766 'prev_next' => true,
2767 'prev_text' => __('« Previous'),
2768 'next_text' => __('Next »'),
2772 'add_args' => array(), // array of query args to add
2773 'add_fragment' => '',
2774 'before_page_number' => '',
2775 'after_page_number' => ''
2778 $args = wp_parse_args( $args, $defaults );
2780 if ( ! is_array( $args['add_args'] ) ) {
2781 $args['add_args'] = array();
2784 // Merge additional query vars found in the original URL into 'add_args' array.
2785 if ( isset( $url_parts[1] ) ) {
2786 // Find the format argument.
2787 $format = explode( '?', str_replace( '%_%', $args['format'], $args['base'] ) );
2788 $format_query = isset( $format[1] ) ? $format[1] : '';
2789 wp_parse_str( $format_query, $format_args );
2791 // Find the query args of the requested URL.
2792 wp_parse_str( $url_parts[1], $url_query_args );
2794 // Remove the format argument from the array of query arguments, to avoid overwriting custom format.
2795 foreach ( $format_args as $format_arg => $format_arg_value ) {
2796 unset( $url_query_args[ $format_arg ] );
2799 $args['add_args'] = array_merge( $args['add_args'], urlencode_deep( $url_query_args ) );
2802 // Who knows what else people pass in $args
2803 $total = (int) $args['total'];
2807 $current = (int) $args['current'];
2808 $end_size = (int) $args['end_size']; // Out of bounds? Make it the default.
2809 if ( $end_size < 1 ) {
2812 $mid_size = (int) $args['mid_size'];
2813 if ( $mid_size < 0 ) {
2816 $add_args = $args['add_args'];
2818 $page_links = array();
2821 if ( $args['prev_next'] && $current && 1 < $current ) :
2822 $link = str_replace( '%_%', 2 == $current ? '' : $args['format'], $args['base'] );
2823 $link = str_replace( '%#%', $current - 1, $link );
2825 $link = add_query_arg( $add_args, $link );
2826 $link .= $args['add_fragment'];
2829 * Filter the paginated links for the given archive pages.
2833 * @param string $link The paginated link URL.
2835 $page_links[] = '<a class="prev page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $args['prev_text'] . '</a>';
2837 for ( $n = 1; $n <= $total; $n++ ) :
2838 if ( $n == $current ) :
2839 $page_links[] = "<span class='page-numbers current'>" . $args['before_page_number'] . number_format_i18n( $n ) . $args['after_page_number'] . "</span>";
2842 if ( $args['show_all'] || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) :
2843 $link = str_replace( '%_%', 1 == $n ? '' : $args['format'], $args['base'] );
2844 $link = str_replace( '%#%', $n, $link );
2846 $link = add_query_arg( $add_args, $link );
2847 $link .= $args['add_fragment'];
2849 /** This filter is documented in wp-includes/general-template.php */
2850 $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>";
2852 elseif ( $dots && ! $args['show_all'] ) :
2853 $page_links[] = '<span class="page-numbers dots">' . __( '…' ) . '</span>';
2858 if ( $args['prev_next'] && $current && ( $current < $total || -1 == $total ) ) :
2859 $link = str_replace( '%_%', $args['format'], $args['base'] );
2860 $link = str_replace( '%#%', $current + 1, $link );
2862 $link = add_query_arg( $add_args, $link );
2863 $link .= $args['add_fragment'];
2865 /** This filter is documented in wp-includes/general-template.php */
2866 $page_links[] = '<a class="next page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $args['next_text'] . '</a>';
2868 switch ( $args['type'] ) {
2873 $r .= "<ul class='page-numbers'>\n\t<li>";
2874 $r .= join("</li>\n\t<li>", $page_links);
2875 $r .= "</li>\n</ul>\n";
2879 $r = join("\n", $page_links);
2886 * Registers an admin colour scheme css file.
2888 * Allows a plugin to register a new admin colour scheme. For example:
2890 * wp_admin_css_color( 'classic', __( 'Classic' ), admin_url( "css/colors-classic.css" ), array(
2891 * '#07273E', '#14568A', '#D54E21', '#2683AE'
2896 * @todo Properly document optional arguments as such
2898 * @global array $_wp_admin_css_colors
2900 * @param string $key The unique key for this theme.
2901 * @param string $name The name of the theme.
2902 * @param string $url The url of the css file containing the colour scheme.
2903 * @param array $colors Optional An array of CSS color definitions which are used to give the user a feel for the theme.
2904 * @param array $icons Optional An array of CSS color definitions used to color any SVG icons
2906 function wp_admin_css_color( $key, $name, $url, $colors = array(), $icons = array() ) {
2907 global $_wp_admin_css_colors;
2909 if ( !isset($_wp_admin_css_colors) )
2910 $_wp_admin_css_colors = array();
2912 $_wp_admin_css_colors[$key] = (object) array(
2915 'colors' => $colors,
2916 'icon_colors' => $icons,
2921 * Registers the default Admin color schemes
2925 * @global string $wp_version
2927 function register_admin_color_schemes() {
2928 $suffix = is_rtl() ? '-rtl' : '';
2929 $suffix .= SCRIPT_DEBUG ? '' : '.min';
2931 wp_admin_css_color( 'fresh', _x( 'Default', 'admin color scheme' ),
2933 array( '#222', '#333', '#0073aa', '#00a0d2' ),
2934 array( 'base' => '#999', 'focus' => '#00a0d2', 'current' => '#fff' )
2937 // Other color schemes are not available when running out of src
2938 if ( false !== strpos( $GLOBALS['wp_version'], '-src' ) )
2941 wp_admin_css_color( 'light', _x( 'Light', 'admin color scheme' ),
2942 admin_url( "css/colors/light/colors$suffix.css" ),
2943 array( '#e5e5e5', '#999', '#d64e07', '#04a4cc' ),
2944 array( 'base' => '#999', 'focus' => '#ccc', 'current' => '#ccc' )
2947 wp_admin_css_color( 'blue', _x( 'Blue', 'admin color scheme' ),
2948 admin_url( "css/colors/blue/colors$suffix.css" ),
2949 array( '#096484', '#4796b3', '#52accc', '#74B6CE' ),
2950 array( 'base' => '#e5f8ff', 'focus' => '#fff', 'current' => '#fff' )
2953 wp_admin_css_color( 'midnight', _x( 'Midnight', 'admin color scheme' ),
2954 admin_url( "css/colors/midnight/colors$suffix.css" ),
2955 array( '#25282b', '#363b3f', '#69a8bb', '#e14d43' ),
2956 array( 'base' => '#f1f2f3', 'focus' => '#fff', 'current' => '#fff' )
2959 wp_admin_css_color( 'sunrise', _x( 'Sunrise', 'admin color scheme' ),
2960 admin_url( "css/colors/sunrise/colors$suffix.css" ),
2961 array( '#b43c38', '#cf4944', '#dd823b', '#ccaf0b' ),
2962 array( 'base' => '#f3f1f1', 'focus' => '#fff', 'current' => '#fff' )
2965 wp_admin_css_color( 'ectoplasm', _x( 'Ectoplasm', 'admin color scheme' ),
2966 admin_url( "css/colors/ectoplasm/colors$suffix.css" ),
2967 array( '#413256', '#523f6d', '#a3b745', '#d46f15' ),
2968 array( 'base' => '#ece6f6', 'focus' => '#fff', 'current' => '#fff' )
2971 wp_admin_css_color( 'ocean', _x( 'Ocean', 'admin color scheme' ),
2972 admin_url( "css/colors/ocean/colors$suffix.css" ),
2973 array( '#627c83', '#738e96', '#9ebaa0', '#aa9d88' ),
2974 array( 'base' => '#f2fcff', 'focus' => '#fff', 'current' => '#fff' )
2977 wp_admin_css_color( 'coffee', _x( 'Coffee', 'admin color scheme' ),
2978 admin_url( "css/colors/coffee/colors$suffix.css" ),
2979 array( '#46403c', '#59524c', '#c7a589', '#9ea476' ),
2980 array( 'base' => '#f3f2f1', 'focus' => '#fff', 'current' => '#fff' )
2986 * Display the URL of a WordPress admin CSS file.
2988 * @see WP_Styles::_css_href and its style_loader_src filter.
2992 * @param string $file file relative to wp-admin/ without its ".css" extension.
2995 function wp_admin_css_uri( $file = 'wp-admin' ) {
2996 if ( defined('WP_INSTALLING') ) {
2997 $_file = "./$file.css";
2999 $_file = admin_url("$file.css");
3001 $_file = add_query_arg( 'version', get_bloginfo( 'version' ), $_file );
3004 * Filter the URI of a WordPress admin CSS file.
3008 * @param string $_file Relative path to the file with query arguments attached.
3009 * @param string $file Relative path to the file, minus its ".css" extension.
3011 return apply_filters( 'wp_admin_css_uri', $_file, $file );
3015 * Enqueues or directly prints a stylesheet link to the specified CSS file.
3017 * "Intelligently" decides to enqueue or to print the CSS file. If the
3018 * 'wp_print_styles' action has *not* yet been called, the CSS file will be
3019 * enqueued. If the wp_print_styles action *has* been called, the CSS link will
3020 * be printed. Printing may be forced by passing true as the $force_echo
3021 * (second) parameter.
3023 * For backward compatibility with WordPress 2.3 calling method: If the $file
3024 * (first) parameter does not correspond to a registered CSS file, we assume
3025 * $file is a file relative to wp-admin/ without its ".css" extension. A
3026 * stylesheet link to that generated URL is printed.
3030 * @param string $file Optional. Style handle name or file name (without ".css" extension) relative
3031 * to wp-admin/. Defaults to 'wp-admin'.
3032 * @param bool $force_echo Optional. Force the stylesheet link to be printed rather than enqueued.
3034 function wp_admin_css( $file = 'wp-admin', $force_echo = false ) {
3035 // For backward compatibility
3036 $handle = 0 === strpos( $file, 'css/' ) ? substr( $file, 4 ) : $file;
3038 if ( wp_styles()->query( $handle ) ) {
3039 if ( $force_echo || did_action( 'wp_print_styles' ) ) // we already printed the style queue. Print this one immediately
3040 wp_print_styles( $handle );
3041 else // Add to style queue
3042 wp_enqueue_style( $handle );
3047 * Filter the stylesheet link to the specified CSS file.
3049 * If the site is set to display right-to-left, the RTL stylesheet link
3050 * will be used instead.
3054 * @param string $file Style handle name or filename (without ".css" extension)
3055 * relative to wp-admin/. Defaults to 'wp-admin'.
3057 echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . esc_url( wp_admin_css_uri( $file ) ) . "' type='text/css' />\n", $file );
3059 if ( function_exists( 'is_rtl' ) && is_rtl() ) {
3060 /** This filter is documented in wp-includes/general-template.php */
3061 echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . esc_url( wp_admin_css_uri( "$file-rtl" ) ) . "' type='text/css' />\n", "$file-rtl" );
3066 * Enqueues the default ThickBox js and css.
3068 * If any of the settings need to be changed, this can be done with another js
3069 * file similar to media-upload.js. That file should
3070 * require array('thickbox') to ensure it is loaded after.
3074 function add_thickbox() {
3075 wp_enqueue_script( 'thickbox' );
3076 wp_enqueue_style( 'thickbox' );
3078 if ( is_network_admin() )
3079 add_action( 'admin_head', '_thickbox_path_admin_subfolder' );
3083 * Display the XHTML generator that is generated on the wp_head hook.
3087 function wp_generator() {
3089 * Filter the output of the XHTML generator tag.
3093 * @param string $generator_type The XHTML generator.
3095 the_generator( apply_filters( 'wp_generator_type', 'xhtml' ) );
3099 * Display the generator XML or Comment for RSS, ATOM, etc.
3101 * Returns the correct generator type for the requested output format. Allows
3102 * for a plugin to filter generators overall the the_generator filter.
3106 * @param string $type The type of generator to output - (html|xhtml|atom|rss2|rdf|comment|export).
3108 function the_generator( $type ) {
3110 * Filter the output of the XHTML generator tag for display.
3114 * @param string $generator_type The generator output.
3115 * @param string $type The type of generator to output. Accepts 'html',
3116 * 'xhtml', 'atom', 'rss2', 'rdf', 'comment', 'export'.
3118 echo apply_filters( 'the_generator', get_the_generator($type), $type ) . "\n";
3122 * Creates the generator XML or Comment for RSS, ATOM, etc.
3124 * Returns the correct generator type for the requested output format. Allows
3125 * for a plugin to filter generators on an individual basis using the
3126 * 'get_the_generator_{$type}' filter.
3130 * @param string $type The type of generator to return - (html|xhtml|atom|rss2|rdf|comment|export).
3131 * @return string|void The HTML content for the generator.
3133 function get_the_generator( $type = '' ) {
3134 if ( empty( $type ) ) {
3136 $current_filter = current_filter();
3137 if ( empty( $current_filter ) )
3140 switch ( $current_filter ) {
3142 case 'commentsrss2_head' :
3153 case 'comments_atom_head' :
3162 $gen = '<meta name="generator" content="WordPress ' . get_bloginfo( 'version' ) . '">';
3165 $gen = '<meta name="generator" content="WordPress ' . get_bloginfo( 'version' ) . '" />';
3168 $gen = '<generator uri="http://wordpress.org/" version="' . get_bloginfo_rss( 'version' ) . '">WordPress</generator>';
3171 $gen = '<generator>http://wordpress.org/?v=' . get_bloginfo_rss( 'version' ) . '</generator>';
3174 $gen = '<admin:generatorAgent rdf:resource="http://wordpress.org/?v=' . get_bloginfo_rss( 'version' ) . '" />';
3177 $gen = '<!-- generator="WordPress/' . get_bloginfo( 'version' ) . '" -->';
3180 $gen = '<!-- generator="WordPress/' . get_bloginfo_rss('version') . '" created="'. date('Y-m-d H:i') . '" -->';
3185 * Filter the HTML for the retrieved generator type.
3187 * The dynamic portion of the hook name, `$type`, refers to the generator type.
3191 * @param string $gen The HTML markup output to {@see wp_head()}.
3192 * @param string $type The type of generator. Accepts 'html', 'xhtml', 'atom',
3193 * 'rss2', 'rdf', 'comment', 'export'.
3195 return apply_filters( "get_the_generator_{$type}", $gen, $type );
3199 * Outputs the html checked attribute.
3201 * Compares the first two arguments and if identical marks as checked
3205 * @param mixed $checked One of the values to compare
3206 * @param mixed $current (true) The other value to compare if not just true
3207 * @param bool $echo Whether to echo or just return the string
3208 * @return string html attribute or empty string
3210 function checked( $checked, $current = true, $echo = true ) {
3211 return __checked_selected_helper( $checked, $current, $echo, 'checked' );
3215 * Outputs the html selected attribute.
3217 * Compares the first two arguments and if identical marks as selected
3221 * @param mixed $selected One of the values to compare
3222 * @param mixed $current (true) The other value to compare if not just true
3223 * @param bool $echo Whether to echo or just return the string
3224 * @return string html attribute or empty string
3226 function selected( $selected, $current = true, $echo = true ) {
3227 return __checked_selected_helper( $selected, $current, $echo, 'selected' );
3231 * Outputs the html disabled attribute.
3233 * Compares the first two arguments and if identical marks as disabled
3237 * @param mixed $disabled One of the values to compare
3238 * @param mixed $current (true) The other value to compare if not just true
3239 * @param bool $echo Whether to echo or just return the string
3240 * @return string html attribute or empty string
3242 function disabled( $disabled, $current = true, $echo = true ) {
3243 return __checked_selected_helper( $disabled, $current, $echo, 'disabled' );
3247 * Private helper function for checked, selected, and disabled.
3249 * Compares the first two arguments and if identical marks as $type
3254 * @param mixed $helper One of the values to compare
3255 * @param mixed $current (true) The other value to compare if not just true
3256 * @param bool $echo Whether to echo or just return the string
3257 * @param string $type The type of checked|selected|disabled we are doing
3258 * @return string html attribute or empty string
3260 function __checked_selected_helper( $helper, $current, $echo, $type ) {
3261 if ( (string) $helper === (string) $current )
3262 $result = " $type='$type'";
3273 * Default settings for heartbeat
3275 * Outputs the nonce used in the heartbeat XHR
3279 * @param array $settings
3280 * @return array $settings
3282 function wp_heartbeat_settings( $settings ) {
3284 $settings['ajaxurl'] = admin_url( 'admin-ajax.php', 'relative' );
3286 if ( is_user_logged_in() )
3287 $settings['nonce'] = wp_create_nonce( 'heartbeat-nonce' );