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";
43 $templates[] = 'header.php';
45 locate_template( $templates, true );
49 * Load footer template.
51 * Includes the footer template for a theme or if a name is specified then a
52 * specialised footer will be included.
54 * For the parameter, if the file is called "footer-special.php" then specify
59 * @param string $name The name of the specialised footer.
61 function get_footer( $name = null ) {
63 * Fires before the footer template file is loaded.
65 * The hook allows a specific footer template file to be used in place of the
66 * default footer template file. If your file is called footer-new.php,
67 * you would specify the filename in the hook as get_footer( 'new' ).
70 * @since 2.8.0 $name parameter added.
72 * @param string $name Name of the specific footer file to use.
74 do_action( 'get_footer', $name );
77 $name = (string) $name;
79 $templates[] = "footer-{$name}.php";
82 $templates[] = 'footer.php';
84 locate_template( $templates, true );
88 * Load sidebar template.
90 * Includes the sidebar template for a theme or if a name is specified then a
91 * specialised sidebar will be included.
93 * For the parameter, if the file is called "sidebar-special.php" then specify
98 * @param string $name The name of the specialised sidebar.
100 function get_sidebar( $name = null ) {
102 * Fires before the sidebar template file is loaded.
104 * The hook allows a specific sidebar template file to be used in place of the
105 * default sidebar template file. If your file is called sidebar-new.php,
106 * you would specify the filename in the hook as get_sidebar( 'new' ).
109 * @since 2.8.0 $name parameter added.
111 * @param string $name Name of the specific sidebar file to use.
113 do_action( 'get_sidebar', $name );
115 $templates = array();
116 $name = (string) $name;
118 $templates[] = "sidebar-{$name}.php";
120 $templates[] = 'sidebar.php';
122 locate_template( $templates, true );
126 * Load a template part into a template
128 * Makes it easy for a theme to reuse sections of code in a easy to overload way
131 * Includes the named template part for a theme or if a name is specified then a
132 * specialised part will be included. If the theme contains no {slug}.php file
133 * then no template will be included.
135 * The template is included using require, not require_once, so you may include the
136 * same template part multiple times.
138 * For the $name parameter, if the file is called "{slug}-special.php" then specify
143 * @param string $slug The slug name for the generic template.
144 * @param string $name The name of the specialised template.
146 function get_template_part( $slug, $name = null ) {
148 * Fires before the specified template part file is loaded.
150 * The dynamic portion of the hook name, `$slug`, refers to the slug name
151 * for the generic template part.
155 * @param string $slug The slug name for the generic template.
156 * @param string $name The name of the specialized template.
158 do_action( "get_template_part_{$slug}", $slug, $name );
160 $templates = array();
161 $name = (string) $name;
163 $templates[] = "{$slug}-{$name}.php";
165 $templates[] = "{$slug}.php";
167 locate_template($templates, true, false);
171 * Display search form.
173 * Will first attempt to locate the searchform.php file in either the child or
174 * the parent, then load it. If it doesn't exist, then the default search form
175 * will be displayed. The default search form is HTML, which will be displayed.
176 * There is a filter applied to the search form HTML in order to edit or replace
177 * it. The filter is 'get_search_form'.
179 * This function is primarily used by themes which want to hardcode the search
180 * form into the sidebar and also by the search widget in WordPress.
182 * There is also an action that is called whenever the function is run called,
183 * 'pre_get_search_form'. This can be useful for outputting JavaScript that the
184 * search relies on or various formatting that applies to the beginning of the
185 * search. To give a few examples of what it can be used for.
189 * @param bool $echo Default to echo and not return the form.
190 * @return string|void String when $echo is false.
192 function get_search_form( $echo = true ) {
194 * Fires before the search form is retrieved, at the start of get_search_form().
196 * @since 2.7.0 as 'get_search_form' action.
199 * @link https://core.trac.wordpress.org/ticket/19321
201 do_action( 'pre_get_search_form' );
203 $format = current_theme_supports( 'html5', 'search-form' ) ? 'html5' : 'xhtml';
206 * Filter the HTML format of the search form.
210 * @param string $format The type of markup to use in the search form.
211 * Accepts 'html5', 'xhtml'.
213 $format = apply_filters( 'search_form_format', $format );
215 $search_form_template = locate_template( 'searchform.php' );
216 if ( '' != $search_form_template ) {
218 require( $search_form_template );
219 $form = ob_get_clean();
221 if ( 'html5' == $format ) {
222 $form = '<form role="search" method="get" class="search-form" action="' . esc_url( home_url( '/' ) ) . '">
224 <span class="screen-reader-text">' . _x( 'Search for:', 'label' ) . '</span>
225 <input type="search" class="search-field" placeholder="' . esc_attr_x( 'Search …', 'placeholder' ) . '" value="' . get_search_query() . '" name="s" />
227 <input type="submit" class="search-submit" value="'. esc_attr_x( 'Search', 'submit button' ) .'" />
230 $form = '<form role="search" method="get" id="searchform" class="searchform" action="' . esc_url( home_url( '/' ) ) . '">
232 <label class="screen-reader-text" for="s">' . _x( 'Search for:', 'label' ) . '</label>
233 <input type="text" value="' . get_search_query() . '" name="s" id="s" />
234 <input type="submit" id="searchsubmit" value="'. esc_attr_x( 'Search', 'submit button' ) .'" />
241 * Filter the HTML output of the search form.
245 * @param string $form The search form HTML output.
247 $result = apply_filters( 'get_search_form', $form );
249 if ( null === $result )
259 * Display the Log In/Out link.
261 * Displays a link, which allows users to navigate to the Log In page to log in
262 * or log out depending on whether they are currently logged in.
266 * @param string $redirect Optional path to redirect to on login/logout.
267 * @param bool $echo Default to echo and not return the link.
268 * @return string|void String when retrieving.
270 function wp_loginout($redirect = '', $echo = true) {
271 if ( ! is_user_logged_in() )
272 $link = '<a href="' . esc_url( wp_login_url($redirect) ) . '">' . __('Log in') . '</a>';
274 $link = '<a href="' . esc_url( wp_logout_url($redirect) ) . '">' . __('Log out') . '</a>';
278 * Filter the HTML output for the Log In/Log Out link.
282 * @param string $link The HTML link content.
284 echo apply_filters( 'loginout', $link );
286 /** This filter is documented in wp-includes/general-template.php */
287 return apply_filters( 'loginout', $link );
292 * Returns the Log Out URL.
294 * Returns the URL that allows the user to log out of the site.
298 * @param string $redirect Path to redirect to on logout.
299 * @return string A log out URL.
301 function wp_logout_url($redirect = '') {
302 $args = array( 'action' => 'logout' );
303 if ( !empty($redirect) ) {
304 $args['redirect_to'] = urlencode( $redirect );
307 $logout_url = add_query_arg($args, site_url('wp-login.php', 'login'));
308 $logout_url = wp_nonce_url( $logout_url, 'log-out' );
311 * Filter the logout URL.
315 * @param string $logout_url The Log Out URL.
316 * @param string $redirect Path to redirect to on logout.
318 return apply_filters( 'logout_url', $logout_url, $redirect );
322 * Returns the URL that allows the user to log in to the site.
326 * @param string $redirect Path to redirect to on login.
327 * @param bool $force_reauth Whether to force reauthorization, even if a cookie is present. Default is false.
328 * @return string A log in URL.
330 function wp_login_url($redirect = '', $force_reauth = false) {
331 $login_url = site_url('wp-login.php', 'login');
333 if ( !empty($redirect) )
334 $login_url = add_query_arg('redirect_to', urlencode($redirect), $login_url);
337 $login_url = add_query_arg('reauth', '1', $login_url);
340 * Filter the login URL.
343 * @since 4.2.0 The `$force_reauth` parameter was added.
345 * @param string $login_url The login URL.
346 * @param string $redirect The path to redirect to on login, if supplied.
347 * @param bool $force_reauth Whether to force reauthorization, even if a cookie is present.
349 return apply_filters( 'login_url', $login_url, $redirect, $force_reauth );
353 * Returns the URL that allows the user to register on the site.
357 * @return string User registration URL.
359 function wp_registration_url() {
361 * Filter the user registration URL.
365 * @param string $register The user registration URL.
367 return apply_filters( 'register_url', site_url( 'wp-login.php?action=register', 'login' ) );
371 * Provides a simple login form for use anywhere within WordPress.
373 * The login format HTML is echoed by default. Pass a false value for `$echo` to return it instead.
377 * @param array $args {
378 * Optional. Array of options to control the form output. Default empty array.
380 * @type bool $echo Whether to display the login form or return the form HTML code.
381 * Default true (echo).
382 * @type string $redirect URL to redirect to. Must be absolute, as in "https://example.com/mypage/".
383 * Default is to redirect back to the request URI.
384 * @type string $form_id ID attribute value for the form. Default 'loginform'.
385 * @type string $label_username Label for the username or email address field. Default 'Username or Email'.
386 * @type string $label_password Label for the password field. Default 'Password'.
387 * @type string $label_remember Label for the remember field. Default 'Remember Me'.
388 * @type string $label_log_in Label for the submit button. Default 'Log In'.
389 * @type string $id_username ID attribute value for the username field. Default 'user_login'.
390 * @type string $id_password ID attribute value for the password field. Default 'user_pass'.
391 * @type string $id_remember ID attribute value for the remember field. Default 'rememberme'.
392 * @type string $id_submit ID attribute value for the submit button. Default 'wp-submit'.
393 * @type bool $remember Whether to display the "rememberme" checkbox in the form.
394 * @type string $value_username Default value for the username field. Default empty.
395 * @type bool $value_remember Whether the "Remember Me" checkbox should be checked by default.
396 * Default false (unchecked).
399 * @return string|void String when retrieving.
401 function wp_login_form( $args = array() ) {
404 // Default 'redirect' value takes the user back to the request URI.
405 'redirect' => ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'],
406 'form_id' => 'loginform',
407 'label_username' => __( 'Username or Email' ),
408 'label_password' => __( 'Password' ),
409 'label_remember' => __( 'Remember Me' ),
410 'label_log_in' => __( 'Log In' ),
411 'id_username' => 'user_login',
412 'id_password' => 'user_pass',
413 'id_remember' => 'rememberme',
414 'id_submit' => 'wp-submit',
416 'value_username' => '',
417 // Set 'value_remember' to true to default the "Remember me" checkbox to checked.
418 'value_remember' => false,
422 * Filter the default login form output arguments.
426 * @see wp_login_form()
428 * @param array $defaults An array of default login form arguments.
430 $args = wp_parse_args( $args, apply_filters( 'login_form_defaults', $defaults ) );
433 * Filter content to display at the top of the login form.
435 * The filter evaluates just following the opening form tag element.
439 * @param string $content Content to display. Default empty.
440 * @param array $args Array of login form arguments.
442 $login_form_top = apply_filters( 'login_form_top', '', $args );
445 * Filter content to display in the middle of the login form.
447 * The filter evaluates just following the location where the 'login-password'
448 * field is displayed.
452 * @param string $content Content to display. Default empty.
453 * @param array $args Array of login form arguments.
455 $login_form_middle = apply_filters( 'login_form_middle', '', $args );
458 * Filter content to display at the bottom of the login form.
460 * The filter evaluates just preceding the closing form tag element.
464 * @param string $content Content to display. Default empty.
465 * @param array $args Array of login form arguments.
467 $login_form_bottom = apply_filters( 'login_form_bottom', '', $args );
470 <form name="' . $args['form_id'] . '" id="' . $args['form_id'] . '" action="' . esc_url( site_url( 'wp-login.php', 'login_post' ) ) . '" method="post">
471 ' . $login_form_top . '
472 <p class="login-username">
473 <label for="' . esc_attr( $args['id_username'] ) . '">' . esc_html( $args['label_username'] ) . '</label>
474 <input type="text" name="log" id="' . esc_attr( $args['id_username'] ) . '" class="input" value="' . esc_attr( $args['value_username'] ) . '" size="20" />
476 <p class="login-password">
477 <label for="' . esc_attr( $args['id_password'] ) . '">' . esc_html( $args['label_password'] ) . '</label>
478 <input type="password" name="pwd" id="' . esc_attr( $args['id_password'] ) . '" class="input" value="" size="20" />
480 ' . $login_form_middle . '
481 ' . ( $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>' : '' ) . '
482 <p class="login-submit">
483 <input type="submit" name="wp-submit" id="' . esc_attr( $args['id_submit'] ) . '" class="button-primary" value="' . esc_attr( $args['label_log_in'] ) . '" />
484 <input type="hidden" name="redirect_to" value="' . esc_url( $args['redirect'] ) . '" />
486 ' . $login_form_bottom . '
496 * Returns the URL that allows the user to retrieve the lost password
500 * @param string $redirect Path to redirect to on login.
501 * @return string Lost password URL.
503 function wp_lostpassword_url( $redirect = '' ) {
504 $args = array( 'action' => 'lostpassword' );
505 if ( !empty($redirect) ) {
506 $args['redirect_to'] = $redirect;
509 $lostpassword_url = add_query_arg( $args, network_site_url('wp-login.php', 'login') );
512 * Filter the Lost Password URL.
516 * @param string $lostpassword_url The lost password page URL.
517 * @param string $redirect The path to redirect to on login.
519 return apply_filters( 'lostpassword_url', $lostpassword_url, $redirect );
523 * Display the Registration or Admin link.
525 * Display a link which allows the user to navigate to the registration page if
526 * not logged in and registration is enabled or to the dashboard if logged in.
530 * @param string $before Text to output before the link. Default `<li>`.
531 * @param string $after Text to output after the link. Default `</li>`.
532 * @param bool $echo Default to echo and not return the link.
533 * @return string|void String when retrieving.
535 function wp_register( $before = '<li>', $after = '</li>', $echo = true ) {
536 if ( ! is_user_logged_in() ) {
537 if ( get_option('users_can_register') )
538 $link = $before . '<a href="' . esc_url( wp_registration_url() ) . '">' . __('Register') . '</a>' . $after;
541 } elseif ( current_user_can( 'read' ) ) {
542 $link = $before . '<a href="' . admin_url() . '">' . __('Site Admin') . '</a>' . $after;
548 * Filter the HTML link to the Registration or Admin page.
550 * Users are sent to the admin page if logged-in, or the registration page
551 * if enabled and logged-out.
555 * @param string $link The HTML code for the link to the Registration or Admin page.
557 $link = apply_filters( 'register', $link );
567 * Theme container function for the 'wp_meta' action.
569 * The 'wp_meta' action can have several purposes, depending on how you use it,
570 * but one purpose might have been to allow for theme switching.
574 * @link https://core.trac.wordpress.org/ticket/1458 Explanation of 'wp_meta' action.
578 * Fires before displaying echoed content in the sidebar.
582 do_action( 'wp_meta' );
586 * Displays information about the current site.
590 * @see get_bloginfo() For possible `$show` values
592 * @param string $show Optional. Site information to display. Default empty.
594 function bloginfo( $show = '' ) {
595 echo get_bloginfo( $show, 'display' );
599 * Retrieves information about the current site.
601 * Possible values for `$show` include:
603 * - 'name' - Site title (set in Settings > General)
604 * - 'description' - Site tagline (set in Settings > General)
605 * - 'wpurl' - The WordPress address (URL) (set in Settings > General)
606 * - 'url' - The Site address (URL) (set in Settings > General)
607 * - 'admin_email' - Admin email (set in Settings > General)
608 * - 'charset' - The "Encoding for pages and feeds" (set in Settings > Reading)
609 * - 'version' - The current WordPress version
610 * - 'html_type' - The content-type (default: "text/html"). Themes and plugins
611 * can override the default value using the {@see 'pre_option_html_type'} filter
612 * - 'text_direction' - The text direction determined by the site's language. is_rtl()
613 * should be used instead
614 * - 'language' - Language code for the current site
615 * - 'stylesheet_url' - URL to the stylesheet for the active theme. An active child theme
616 * will take precedence over this value
617 * - 'stylesheet_directory' - Directory path for the active theme. An active child theme
618 * will take precedence over this value
619 * - 'template_url' / 'template_directory' - URL of the active theme's directory. An active
620 * child theme will NOT take precedence over this value
621 * - 'pingback_url' - The pingback XML-RPC file URL (xmlrpc.php)
622 * - 'atom_url' - The Atom feed URL (/feed/atom)
623 * - 'rdf_url' - The RDF/RSS 1.0 feed URL (/feed/rfd)
624 * - 'rss_url' - The RSS 0.92 feed URL (/feed/rss)
625 * - 'rss2_url' - The RSS 2.0 feed URL (/feed)
626 * - 'comments_atom_url' - The comments Atom feed URL (/comments/feed)
627 * - 'comments_rss2_url' - The comments RSS 2.0 feed URL (/comments/feed)
629 * Some `$show` values are deprecated and will be removed in future versions.
630 * These options will trigger the _deprecated_argument() function.
632 * Deprecated arguments include:
634 * - 'siteurl' - Use 'url' instead
635 * - 'home' - Use 'url' instead
639 * @global string $wp_version
641 * @param string $show Optional. Site info to retrieve. Default empty (site name).
642 * @param string $filter Optional. How to filter what is retrieved. Default 'raw'.
643 * @return string Mostly string values, might be empty.
645 function get_bloginfo( $show = '', $filter = 'raw' ) {
647 case 'home' : // DEPRECATED
648 case 'siteurl' : // DEPRECATED
649 _deprecated_argument( __FUNCTION__, '2.2', sprintf(
650 /* translators: 1: 'siteurl'/'home' argument, 2: bloginfo() function name, 3: 'url' argument */
651 __( 'The %1$s option is deprecated for the family of %2$s functions. Use the %3$s option instead.' ),
652 '<code>' . $show . '</code>',
653 '<code>bloginfo()</code>',
657 $output = home_url();
660 $output = site_url();
663 $output = get_option('blogdescription');
666 $output = get_feed_link('rdf');
669 $output = get_feed_link('rss');
672 $output = get_feed_link('rss2');
675 $output = get_feed_link('atom');
677 case 'comments_atom_url':
678 $output = get_feed_link('comments_atom');
680 case 'comments_rss2_url':
681 $output = get_feed_link('comments_rss2');
684 $output = site_url( 'xmlrpc.php' );
686 case 'stylesheet_url':
687 $output = get_stylesheet_uri();
689 case 'stylesheet_directory':
690 $output = get_stylesheet_directory_uri();
692 case 'template_directory':
694 $output = get_template_directory_uri();
697 $output = get_option('admin_email');
700 $output = get_option('blog_charset');
701 if ('' == $output) $output = 'UTF-8';
704 $output = get_option('html_type');
708 $output = $wp_version;
711 /* translators: Translate this to the correct language tag for your locale,
712 * see https://www.w3.org/International/articles/language-tags/ for reference.
713 * Do not translate into your own language.
715 $output = __( 'html_lang_attribute' );
716 if ( 'html_lang_attribute' === $output || preg_match( '/[^a-zA-Z0-9-]/', $output ) ) {
717 $output = get_locale();
718 $output = str_replace( '_', '-', $output );
721 case 'text_direction':
722 _deprecated_argument( __FUNCTION__, '2.2', sprintf(
723 /* translators: 1: 'text_direction' argument, 2: bloginfo() function name, 3: is_rtl() function name */
724 __( 'The %1$s option is deprecated for the family of %2$s functions. Use the %3$s function instead.' ),
725 '<code>' . $show . '</code>',
726 '<code>bloginfo()</code>',
727 '<code>is_rtl()</code>'
729 if ( function_exists( 'is_rtl' ) ) {
730 $output = is_rtl() ? 'rtl' : 'ltr';
737 $output = get_option('blogname');
742 if (strpos($show, 'url') === false &&
743 strpos($show, 'directory') === false &&
744 strpos($show, 'home') === false)
747 if ( 'display' == $filter ) {
750 * Filter the URL returned by get_bloginfo().
754 * @param mixed $output The URL returned by bloginfo().
755 * @param mixed $show Type of information requested.
757 $output = apply_filters( 'bloginfo_url', $output, $show );
760 * Filter the site information returned by get_bloginfo().
764 * @param mixed $output The requested non-URL site information.
765 * @param mixed $show Type of information requested.
767 $output = apply_filters( 'bloginfo', $output, $show );
775 * Returns the Site Icon URL.
779 * @param int $size Optional. Size of the site icon. Default 512 (pixels).
780 * @param string $url Optional. Fallback url if no site icon is found. Default empty.
781 * @param int $blog_id Optional. ID of the blog to get the site icon for. Default current blog.
782 * @return string Site Icon URL.
784 function get_site_icon_url( $size = 512, $url = '', $blog_id = 0 ) {
785 if ( is_multisite() && (int) $blog_id !== get_current_blog_id() ) {
786 switch_to_blog( $blog_id );
789 $site_icon_id = get_option( 'site_icon' );
791 if ( $site_icon_id ) {
792 if ( $size >= 512 ) {
795 $size_data = array( $size, $size );
797 $url = wp_get_attachment_image_url( $site_icon_id, $size_data );
800 if ( is_multisite() && ms_is_switched() ) {
801 restore_current_blog();
805 * Filter the site icon URL.
809 * @param string $url Site icon URL.
810 * @param int $size Size of the site icon.
811 * @param int $blog_id ID of the blog to get the site icon for.
813 return apply_filters( 'get_site_icon_url', $url, $size, $blog_id );
817 * Displays the Site Icon URL.
821 * @param int $size Optional. Size of the site icon. Default 512 (pixels).
822 * @param string $url Optional. Fallback url if no site icon is found. Default empty.
823 * @param int $blog_id Optional. ID of the blog to get the site icon for. Default current blog.
825 function site_icon_url( $size = 512, $url = '', $blog_id = 0 ) {
826 echo esc_url( get_site_icon_url( $size, $url, $blog_id ) );
830 * Whether the site has a Site Icon.
834 * @param int $blog_id Optional. ID of the blog in question. Default current blog.
835 * @return bool Whether the site has a site icon or not.
837 function has_site_icon( $blog_id = 0 ) {
838 return (bool) get_site_icon_url( 512, '', $blog_id );
842 * Determines whether the site has a custom logo.
846 * @param int $blog_id Optional. ID of the blog in question. Default is the ID of the current blog.
847 * @return bool Whether the site has a custom logo or not.
849 function has_custom_logo( $blog_id = 0 ) {
850 if ( is_multisite() && (int) $blog_id !== get_current_blog_id() ) {
851 switch_to_blog( $blog_id );
854 $custom_logo_id = get_theme_mod( 'custom_logo' );
856 if ( is_multisite() && ms_is_switched() ) {
857 restore_current_blog();
860 return (bool) $custom_logo_id;
864 * Returns a custom logo, linked to home.
868 * @param int $blog_id Optional. ID of the blog in question. Default is the ID of the current blog.
869 * @return string Custom logo markup.
871 function get_custom_logo( $blog_id = 0 ) {
874 if ( is_multisite() && (int) $blog_id !== get_current_blog_id() ) {
875 switch_to_blog( $blog_id );
878 $custom_logo_id = get_theme_mod( 'custom_logo' );
880 // We have a logo. Logo is go.
881 if ( $custom_logo_id ) {
882 $html = sprintf( '<a href="%1$s" class="custom-logo-link" rel="home" itemprop="url">%2$s</a>',
883 esc_url( home_url( '/' ) ),
884 wp_get_attachment_image( $custom_logo_id, 'full', false, array(
885 'class' => 'custom-logo',
886 'itemprop' => 'logo',
891 // If no logo is set but we're in the Customizer, leave a placeholder (needed for the live preview).
892 elseif ( is_customize_preview() ) {
893 $html = sprintf( '<a href="%1$s" class="custom-logo-link" style="display:none;"><img class="custom-logo"/></a>',
894 esc_url( home_url( '/' ) )
898 if ( is_multisite() && ms_is_switched() ) {
899 restore_current_blog();
903 * Filter the custom logo output.
907 * @param string $html Custom logo HTML output.
909 return apply_filters( 'get_custom_logo', $html );
913 * Displays a custom logo, linked to home.
917 * @param int $blog_id Optional. ID of the blog in question. Default is the ID of the current blog.
919 function the_custom_logo( $blog_id = 0 ) {
920 echo get_custom_logo( $blog_id );
924 * Returns document title for the current page.
928 * @global int $page Page number of a single post.
929 * @global int $paged Page number of a list of posts.
931 * @return string Tag with the document title.
933 function wp_get_document_title() {
936 * Filter the document title before it is generated.
938 * Passing a non-empty value will short-circuit wp_get_document_title(),
939 * returning that value instead.
943 * @param string $title The document title. Default empty string.
945 $title = apply_filters( 'pre_get_document_title', '' );
946 if ( ! empty( $title ) ) {
950 global $page, $paged;
956 // If it's a 404 page, use a "Page not found" title.
958 $title['title'] = __( 'Page not found' );
960 // If it's a search, use a dynamic search results title.
961 } elseif ( is_search() ) {
962 /* translators: %s: search phrase */
963 $title['title'] = sprintf( __( 'Search Results for “%s”' ), get_search_query() );
965 // If on the front page, use the site title.
966 } elseif ( is_front_page() ) {
967 $title['title'] = get_bloginfo( 'name', 'display' );
969 // If on a post type archive, use the post type archive title.
970 } elseif ( is_post_type_archive() ) {
971 $title['title'] = post_type_archive_title( '', false );
973 // If on a taxonomy archive, use the term title.
974 } elseif ( is_tax() ) {
975 $title['title'] = single_term_title( '', false );
978 * If we're on the blog page that is not the homepage or
979 * a single post of any post type, use the post title.
981 } elseif ( is_home() || is_singular() ) {
982 $title['title'] = single_post_title( '', false );
984 // If on a category or tag archive, use the term title.
985 } elseif ( is_category() || is_tag() ) {
986 $title['title'] = single_term_title( '', false );
988 // If on an author archive, use the author's display name.
989 } elseif ( is_author() && $author = get_queried_object() ) {
990 $title['title'] = $author->display_name;
992 // If it's a date archive, use the date as the title.
993 } elseif ( is_year() ) {
994 $title['title'] = get_the_date( _x( 'Y', 'yearly archives date format' ) );
996 } elseif ( is_month() ) {
997 $title['title'] = get_the_date( _x( 'F Y', 'monthly archives date format' ) );
999 } elseif ( is_day() ) {
1000 $title['title'] = get_the_date();
1003 // Add a page number if necessary.
1004 if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) {
1005 $title['page'] = sprintf( __( 'Page %s' ), max( $paged, $page ) );
1008 // Append the description or site title to give context.
1009 if ( is_front_page() ) {
1010 $title['tagline'] = get_bloginfo( 'description', 'display' );
1012 $title['site'] = get_bloginfo( 'name', 'display' );
1016 * Filter the separator for the document title.
1020 * @param string $sep Document title separator. Default '-'.
1022 $sep = apply_filters( 'document_title_separator', '-' );
1025 * Filter the parts of the document title.
1029 * @param array $title {
1030 * The document title parts.
1032 * @type string $title Title of the viewed page.
1033 * @type string $page Optional. Page number if paginated.
1034 * @type string $tagline Optional. Site description when on home page.
1035 * @type string $site Optional. Site title when not on home page.
1038 $title = apply_filters( 'document_title_parts', $title );
1040 $title = implode( " $sep ", array_filter( $title ) );
1041 $title = wptexturize( $title );
1042 $title = convert_chars( $title );
1043 $title = esc_html( $title );
1044 $title = capital_P_dangit( $title );
1050 * Displays title tag with content.
1054 * @since 4.4.0 Improved title output replaced `wp_title()`.
1057 function _wp_render_title_tag() {
1058 if ( ! current_theme_supports( 'title-tag' ) ) {
1062 echo '<title>' . wp_get_document_title() . '</title>' . "\n";
1066 * Display or retrieve page title for all areas of blog.
1068 * By default, the page title will display the separator before the page title,
1069 * so that the blog title will be before the page title. This is not good for
1070 * title display, since the blog title shows up on most tabs and not what is
1071 * important, which is the page that the user is looking at.
1073 * There are also SEO benefits to having the blog title after or to the 'right'
1074 * or the page title. However, it is mostly common sense to have the blog title
1075 * to the right with most browsers supporting tabs. You can achieve this by
1076 * using the seplocation parameter and setting the value to 'right'. This change
1077 * was introduced around 2.5.0, in case backwards compatibility of themes is
1082 * @global WP_Locale $wp_locale
1084 * @param string $sep Optional, default is '»'. How to separate the various items
1085 * within the page title.
1086 * @param bool $display Optional, default is true. Whether to display or retrieve title.
1087 * @param string $seplocation Optional. Direction to display title, 'right'.
1088 * @return string|null String on retrieve, null when displaying.
1090 function wp_title( $sep = '»', $display = true, $seplocation = '' ) {
1093 $m = get_query_var( 'm' );
1094 $year = get_query_var( 'year' );
1095 $monthnum = get_query_var( 'monthnum' );
1096 $day = get_query_var( 'day' );
1097 $search = get_query_var( 's' );
1100 $t_sep = '%WP_TITLE_SEP%'; // Temporary separator, for accurate flipping, if necessary
1102 // If there is a post
1103 if ( is_single() || ( is_home() && ! is_front_page() ) || ( is_page() && ! is_front_page() ) ) {
1104 $title = single_post_title( '', false );
1107 // If there's a post type archive
1108 if ( is_post_type_archive() ) {
1109 $post_type = get_query_var( 'post_type' );
1110 if ( is_array( $post_type ) ) {
1111 $post_type = reset( $post_type );
1113 $post_type_object = get_post_type_object( $post_type );
1114 if ( ! $post_type_object->has_archive ) {
1115 $title = post_type_archive_title( '', false );
1119 // If there's a category or tag
1120 if ( is_category() || is_tag() ) {
1121 $title = single_term_title( '', false );
1124 // If there's a taxonomy
1126 $term = get_queried_object();
1128 $tax = get_taxonomy( $term->taxonomy );
1129 $title = single_term_title( $tax->labels->name . $t_sep, false );
1133 // If there's an author
1134 if ( is_author() && ! is_post_type_archive() ) {
1135 $author = get_queried_object();
1137 $title = $author->display_name;
1141 // Post type archives with has_archive should override terms.
1142 if ( is_post_type_archive() && $post_type_object->has_archive ) {
1143 $title = post_type_archive_title( '', false );
1146 // If there's a month
1147 if ( is_archive() && ! empty( $m ) ) {
1148 $my_year = substr( $m, 0, 4 );
1149 $my_month = $wp_locale->get_month( substr( $m, 4, 2 ) );
1150 $my_day = intval( substr( $m, 6, 2 ) );
1151 $title = $my_year . ( $my_month ? $t_sep . $my_month : '' ) . ( $my_day ? $t_sep . $my_day : '' );
1154 // If there's a year
1155 if ( is_archive() && ! empty( $year ) ) {
1157 if ( ! empty( $monthnum ) ) {
1158 $title .= $t_sep . $wp_locale->get_month( $monthnum );
1160 if ( ! empty( $day ) ) {
1161 $title .= $t_sep . zeroise( $day, 2 );
1166 if ( is_search() ) {
1167 /* translators: 1: separator, 2: search phrase */
1168 $title = sprintf( __( 'Search Results %1$s %2$s' ), $t_sep, strip_tags( $search ) );
1171 // If it's a 404 page
1173 $title = __( 'Page not found' );
1177 if ( ! empty( $title ) ) {
1182 * Filter the parts of the page title.
1186 * @param array $title_array Parts of the page title.
1188 $title_array = apply_filters( 'wp_title_parts', explode( $t_sep, $title ) );
1190 // Determines position of the separator and direction of the breadcrumb
1191 if ( 'right' == $seplocation ) { // sep on right, so reverse the order
1192 $title_array = array_reverse( $title_array );
1193 $title = implode( " $sep ", $title_array ) . $prefix;
1195 $title = $prefix . implode( " $sep ", $title_array );
1199 * Filter the text of the page title.
1203 * @param string $title Page title.
1204 * @param string $sep Title separator.
1205 * @param string $seplocation Location of the separator (left or right).
1207 $title = apply_filters( 'wp_title', $title, $sep, $seplocation );
1218 * Display or retrieve page title for post.
1220 * This is optimized for single.php template file for displaying the post title.
1222 * It does not support placing the separator after the title, but by leaving the
1223 * prefix parameter empty, you can set the title separator manually. The prefix
1224 * does not automatically place a space between the prefix, so if there should
1225 * be a space, the parameter value will need to have it at the end.
1229 * @param string $prefix Optional. What to display before the title.
1230 * @param bool $display Optional, default is true. Whether to display or retrieve title.
1231 * @return string|void Title when retrieving.
1233 function single_post_title( $prefix = '', $display = true ) {
1234 $_post = get_queried_object();
1236 if ( !isset($_post->post_title) )
1240 * Filter the page title for a single post.
1244 * @param string $_post_title The single post page title.
1245 * @param object $_post The current queried object as returned by get_queried_object().
1247 $title = apply_filters( 'single_post_title', $_post->post_title, $_post );
1249 echo $prefix . $title;
1251 return $prefix . $title;
1255 * Display or retrieve title for a post type archive.
1257 * This is optimized for archive.php and archive-{$post_type}.php template files
1258 * for displaying the title of the post type.
1262 * @param string $prefix Optional. What to display before the title.
1263 * @param bool $display Optional, default is true. Whether to display or retrieve title.
1264 * @return string|void Title when retrieving, null when displaying or failure.
1266 function post_type_archive_title( $prefix = '', $display = true ) {
1267 if ( ! is_post_type_archive() )
1270 $post_type = get_query_var( 'post_type' );
1271 if ( is_array( $post_type ) )
1272 $post_type = reset( $post_type );
1274 $post_type_obj = get_post_type_object( $post_type );
1277 * Filter the post type archive title.
1281 * @param string $post_type_name Post type 'name' label.
1282 * @param string $post_type Post type.
1284 $title = apply_filters( 'post_type_archive_title', $post_type_obj->labels->name, $post_type );
1287 echo $prefix . $title;
1289 return $prefix . $title;
1293 * Display or retrieve page title for category archive.
1295 * Useful for category template files for displaying the category page title.
1296 * The prefix does not automatically place a space between the prefix, so if
1297 * there should be a space, the parameter value will need to have it at the end.
1301 * @param string $prefix Optional. What to display before the title.
1302 * @param bool $display Optional, default is true. Whether to display or retrieve title.
1303 * @return string|void Title when retrieving.
1305 function single_cat_title( $prefix = '', $display = true ) {
1306 return single_term_title( $prefix, $display );
1310 * Display or retrieve page title for tag post archive.
1312 * Useful for tag template files for displaying the tag page title. The prefix
1313 * does not automatically place a space between the prefix, so if there should
1314 * be a space, the parameter value will need to have it at the end.
1318 * @param string $prefix Optional. What to display before the title.
1319 * @param bool $display Optional, default is true. Whether to display or retrieve title.
1320 * @return string|void Title when retrieving.
1322 function single_tag_title( $prefix = '', $display = true ) {
1323 return single_term_title( $prefix, $display );
1327 * Display or retrieve page title for taxonomy term archive.
1329 * Useful for taxonomy term template files for displaying the taxonomy term page title.
1330 * The prefix does not automatically place a space between the prefix, so if there should
1331 * be a space, the parameter value will need to have it at the end.
1335 * @param string $prefix Optional. What to display before the title.
1336 * @param bool $display Optional, default is true. Whether to display or retrieve title.
1337 * @return string|void Title when retrieving.
1339 function single_term_title( $prefix = '', $display = true ) {
1340 $term = get_queried_object();
1345 if ( is_category() ) {
1347 * Filter the category archive page title.
1351 * @param string $term_name Category name for archive being displayed.
1353 $term_name = apply_filters( 'single_cat_title', $term->name );
1354 } elseif ( is_tag() ) {
1356 * Filter the tag archive page title.
1360 * @param string $term_name Tag name for archive being displayed.
1362 $term_name = apply_filters( 'single_tag_title', $term->name );
1363 } elseif ( is_tax() ) {
1365 * Filter the custom taxonomy archive page title.
1369 * @param string $term_name Term name for archive being displayed.
1371 $term_name = apply_filters( 'single_term_title', $term->name );
1376 if ( empty( $term_name ) )
1380 echo $prefix . $term_name;
1382 return $prefix . $term_name;
1386 * Display or retrieve page title for post archive based on date.
1388 * Useful for when the template only needs to display the month and year,
1389 * if either are available. The prefix does not automatically place a space
1390 * between the prefix, so if there should be a space, the parameter value
1391 * will need to have it at the end.
1395 * @global WP_Locale $wp_locale
1397 * @param string $prefix Optional. What to display before the title.
1398 * @param bool $display Optional, default is true. Whether to display or retrieve title.
1399 * @return string|void Title when retrieving.
1401 function single_month_title($prefix = '', $display = true ) {
1404 $m = get_query_var('m');
1405 $year = get_query_var('year');
1406 $monthnum = get_query_var('monthnum');
1408 if ( !empty($monthnum) && !empty($year) ) {
1410 $my_month = $wp_locale->get_month($monthnum);
1411 } elseif ( !empty($m) ) {
1412 $my_year = substr($m, 0, 4);
1413 $my_month = $wp_locale->get_month(substr($m, 4, 2));
1416 if ( empty($my_month) )
1419 $result = $prefix . $my_month . $prefix . $my_year;
1427 * Display the archive title based on the queried object.
1431 * @see get_the_archive_title()
1433 * @param string $before Optional. Content to prepend to the title. Default empty.
1434 * @param string $after Optional. Content to append to the title. Default empty.
1436 function the_archive_title( $before = '', $after = '' ) {
1437 $title = get_the_archive_title();
1439 if ( ! empty( $title ) ) {
1440 echo $before . $title . $after;
1445 * Retrieve the archive title based on the queried object.
1449 * @return string Archive title.
1451 function get_the_archive_title() {
1452 if ( is_category() ) {
1453 $title = sprintf( __( 'Category: %s' ), single_cat_title( '', false ) );
1454 } elseif ( is_tag() ) {
1455 $title = sprintf( __( 'Tag: %s' ), single_tag_title( '', false ) );
1456 } elseif ( is_author() ) {
1457 $title = sprintf( __( 'Author: %s' ), '<span class="vcard">' . get_the_author() . '</span>' );
1458 } elseif ( is_year() ) {
1459 $title = sprintf( __( 'Year: %s' ), get_the_date( _x( 'Y', 'yearly archives date format' ) ) );
1460 } elseif ( is_month() ) {
1461 $title = sprintf( __( 'Month: %s' ), get_the_date( _x( 'F Y', 'monthly archives date format' ) ) );
1462 } elseif ( is_day() ) {
1463 $title = sprintf( __( 'Day: %s' ), get_the_date( _x( 'F j, Y', 'daily archives date format' ) ) );
1464 } elseif ( is_tax( 'post_format' ) ) {
1465 if ( is_tax( 'post_format', 'post-format-aside' ) ) {
1466 $title = _x( 'Asides', 'post format archive title' );
1467 } elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) {
1468 $title = _x( 'Galleries', 'post format archive title' );
1469 } elseif ( is_tax( 'post_format', 'post-format-image' ) ) {
1470 $title = _x( 'Images', 'post format archive title' );
1471 } elseif ( is_tax( 'post_format', 'post-format-video' ) ) {
1472 $title = _x( 'Videos', 'post format archive title' );
1473 } elseif ( is_tax( 'post_format', 'post-format-quote' ) ) {
1474 $title = _x( 'Quotes', 'post format archive title' );
1475 } elseif ( is_tax( 'post_format', 'post-format-link' ) ) {
1476 $title = _x( 'Links', 'post format archive title' );
1477 } elseif ( is_tax( 'post_format', 'post-format-status' ) ) {
1478 $title = _x( 'Statuses', 'post format archive title' );
1479 } elseif ( is_tax( 'post_format', 'post-format-audio' ) ) {
1480 $title = _x( 'Audio', 'post format archive title' );
1481 } elseif ( is_tax( 'post_format', 'post-format-chat' ) ) {
1482 $title = _x( 'Chats', 'post format archive title' );
1484 } elseif ( is_post_type_archive() ) {
1485 $title = sprintf( __( 'Archives: %s' ), post_type_archive_title( '', false ) );
1486 } elseif ( is_tax() ) {
1487 $tax = get_taxonomy( get_queried_object()->taxonomy );
1488 /* translators: 1: Taxonomy singular name, 2: Current taxonomy term */
1489 $title = sprintf( __( '%1$s: %2$s' ), $tax->labels->singular_name, single_term_title( '', false ) );
1491 $title = __( 'Archives' );
1495 * Filter the archive title.
1499 * @param string $title Archive title to be displayed.
1501 return apply_filters( 'get_the_archive_title', $title );
1505 * Display category, tag, or term description.
1509 * @see get_the_archive_description()
1511 * @param string $before Optional. Content to prepend to the description. Default empty.
1512 * @param string $after Optional. Content to append to the description. Default empty.
1514 function the_archive_description( $before = '', $after = '' ) {
1515 $description = get_the_archive_description();
1516 if ( $description ) {
1517 echo $before . $description . $after;
1522 * Retrieve category, tag, or term description.
1526 * @return string Archive description.
1528 function get_the_archive_description() {
1530 * Filter the archive description.
1534 * @see term_description()
1536 * @param string $description Archive description to be displayed.
1538 return apply_filters( 'get_the_archive_description', term_description() );
1542 * Retrieve archive link content based on predefined or custom code.
1544 * The format can be one of four styles. The 'link' for head element, 'option'
1545 * for use in the select element, 'html' for use in list (either ol or ul HTML
1546 * elements). Custom content is also supported using the before and after
1549 * The 'link' format uses the `<link>` HTML element with the **archives**
1550 * relationship. The before and after parameters are not used. The text
1551 * parameter is used to describe the link.
1553 * The 'option' format uses the option HTML element for use in select element.
1554 * The value is the url parameter and the before and after parameters are used
1555 * between the text description.
1557 * The 'html' format, which is the default, uses the li HTML element for use in
1558 * the list HTML elements. The before parameter is before the link and the after
1559 * parameter is after the closing link.
1561 * The custom format uses the before parameter before the link ('a' HTML
1562 * element) and the after parameter after the closing link tag. If the above
1563 * three values for the format are not used, then custom format is assumed.
1567 * @param string $url URL to archive.
1568 * @param string $text Archive text description.
1569 * @param string $format Optional, default is 'html'. Can be 'link', 'option', 'html', or custom.
1570 * @param string $before Optional. Content to prepend to the description. Default empty.
1571 * @param string $after Optional. Content to append to the description. Default empty.
1572 * @return string HTML link content for archive.
1574 function get_archives_link($url, $text, $format = 'html', $before = '', $after = '') {
1575 $text = wptexturize($text);
1576 $url = esc_url($url);
1578 if ('link' == $format)
1579 $link_html = "\t<link rel='archives' title='" . esc_attr( $text ) . "' href='$url' />\n";
1580 elseif ('option' == $format)
1581 $link_html = "\t<option value='$url'>$before $text $after</option>\n";
1582 elseif ('html' == $format)
1583 $link_html = "\t<li>$before<a href='$url'>$text</a>$after</li>\n";
1585 $link_html = "\t$before<a href='$url'>$text</a>$after\n";
1588 * Filter the archive link content.
1591 * @since 4.5.0 Added the `$url`, `$text`, `$format`, `$before`, and `$after` parameters.
1593 * @param string $link_html The archive HTML link content.
1594 * @param string $url URL to archive.
1595 * @param string $text Archive text description.
1596 * @param string $format Link format. Can be 'link', 'option', 'html', or custom.
1597 * @param string $before Content to prepend to the description.
1598 * @param string $after Content to append to the description.
1600 return apply_filters( 'get_archives_link', $link_html, $url, $text, $format, $before, $after );
1604 * Display archive links based on type and format.
1607 * @since 4.4.0 $post_type arg was added.
1609 * @see get_archives_link()
1611 * @global wpdb $wpdb
1612 * @global WP_Locale $wp_locale
1614 * @param string|array $args {
1615 * Default archive links arguments. Optional.
1617 * @type string $type Type of archive to retrieve. Accepts 'daily', 'weekly', 'monthly',
1618 * 'yearly', 'postbypost', or 'alpha'. Both 'postbypost' and 'alpha'
1619 * display the same archive link list as well as post titles instead
1620 * of displaying dates. The difference between the two is that 'alpha'
1621 * will order by post title and 'postbypost' will order by post date.
1622 * Default 'monthly'.
1623 * @type string|int $limit Number of links to limit the query to. Default empty (no limit).
1624 * @type string $format Format each link should take using the $before and $after args.
1625 * Accepts 'link' (`<link>` tag), 'option' (`<option>` tag), 'html'
1626 * (`<li>` tag), or a custom format, which generates a link anchor
1627 * with $before preceding and $after succeeding. Default 'html'.
1628 * @type string $before Markup to prepend to the beginning of each link. Default empty.
1629 * @type string $after Markup to append to the end of each link. Default empty.
1630 * @type bool $show_post_count Whether to display the post count alongside the link. Default false.
1631 * @type bool|int $echo Whether to echo or return the links list. Default 1|true to echo.
1632 * @type string $order Whether to use ascending or descending order. Accepts 'ASC', or 'DESC'.
1634 * @type string $post_type Post type. Default 'post'.
1636 * @return string|void String when retrieving.
1638 function wp_get_archives( $args = '' ) {
1639 global $wpdb, $wp_locale;
1642 'type' => 'monthly', 'limit' => '',
1643 'format' => 'html', 'before' => '',
1644 'after' => '', 'show_post_count' => false,
1645 'echo' => 1, 'order' => 'DESC',
1646 'post_type' => 'post'
1649 $r = wp_parse_args( $args, $defaults );
1651 $post_type_object = get_post_type_object( $r['post_type'] );
1652 if ( ! is_post_type_viewable( $post_type_object ) ) {
1655 $r['post_type'] = $post_type_object->name;
1657 if ( '' == $r['type'] ) {
1658 $r['type'] = 'monthly';
1661 if ( ! empty( $r['limit'] ) ) {
1662 $r['limit'] = absint( $r['limit'] );
1663 $r['limit'] = ' LIMIT ' . $r['limit'];
1666 $order = strtoupper( $r['order'] );
1667 if ( $order !== 'ASC' ) {
1671 // this is what will separate dates on weekly archive links
1672 $archive_week_separator = '–';
1674 $sql_where = $wpdb->prepare( "WHERE post_type = %s AND post_status = 'publish'", $r['post_type'] );
1677 * Filter the SQL WHERE clause for retrieving archives.
1681 * @param string $sql_where Portion of SQL query containing the WHERE clause.
1682 * @param array $r An array of default arguments.
1684 $where = apply_filters( 'getarchives_where', $sql_where, $r );
1687 * Filter the SQL JOIN clause for retrieving archives.
1691 * @param string $sql_join Portion of SQL query containing JOIN clause.
1692 * @param array $r An array of default arguments.
1694 $join = apply_filters( 'getarchives_join', '', $r );
1698 $last_changed = wp_cache_get( 'last_changed', 'posts' );
1699 if ( ! $last_changed ) {
1700 $last_changed = microtime();
1701 wp_cache_set( 'last_changed', $last_changed, 'posts' );
1704 $limit = $r['limit'];
1706 if ( 'monthly' == $r['type'] ) {
1707 $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";
1708 $key = md5( $query );
1709 $key = "wp_get_archives:$key:$last_changed";
1710 if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
1711 $results = $wpdb->get_results( $query );
1712 wp_cache_set( $key, $results, 'posts' );
1715 $after = $r['after'];
1716 foreach ( (array) $results as $result ) {
1717 $url = get_month_link( $result->year, $result->month );
1718 if ( 'post' !== $r['post_type'] ) {
1719 $url = add_query_arg( 'post_type', $r['post_type'], $url );
1721 /* translators: 1: month name, 2: 4-digit year */
1722 $text = sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $result->month ), $result->year );
1723 if ( $r['show_post_count'] ) {
1724 $r['after'] = ' (' . $result->posts . ')' . $after;
1726 $output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
1729 } elseif ( 'yearly' == $r['type'] ) {
1730 $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";
1731 $key = md5( $query );
1732 $key = "wp_get_archives:$key:$last_changed";
1733 if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
1734 $results = $wpdb->get_results( $query );
1735 wp_cache_set( $key, $results, 'posts' );
1738 $after = $r['after'];
1739 foreach ( (array) $results as $result) {
1740 $url = get_year_link( $result->year );
1741 if ( 'post' !== $r['post_type'] ) {
1742 $url = add_query_arg( 'post_type', $r['post_type'], $url );
1744 $text = sprintf( '%d', $result->year );
1745 if ( $r['show_post_count'] ) {
1746 $r['after'] = ' (' . $result->posts . ')' . $after;
1748 $output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
1751 } elseif ( 'daily' == $r['type'] ) {
1752 $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";
1753 $key = md5( $query );
1754 $key = "wp_get_archives:$key:$last_changed";
1755 if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
1756 $results = $wpdb->get_results( $query );
1757 wp_cache_set( $key, $results, 'posts' );
1760 $after = $r['after'];
1761 foreach ( (array) $results as $result ) {
1762 $url = get_day_link( $result->year, $result->month, $result->dayofmonth );
1763 if ( 'post' !== $r['post_type'] ) {
1764 $url = add_query_arg( 'post_type', $r['post_type'], $url );
1766 $date = sprintf( '%1$d-%2$02d-%3$02d 00:00:00', $result->year, $result->month, $result->dayofmonth );
1767 $text = mysql2date( get_option( 'date_format' ), $date );
1768 if ( $r['show_post_count'] ) {
1769 $r['after'] = ' (' . $result->posts . ')' . $after;
1771 $output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
1774 } elseif ( 'weekly' == $r['type'] ) {
1775 $week = _wp_mysql_week( '`post_date`' );
1776 $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";
1777 $key = md5( $query );
1778 $key = "wp_get_archives:$key:$last_changed";
1779 if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
1780 $results = $wpdb->get_results( $query );
1781 wp_cache_set( $key, $results, 'posts' );
1785 $after = $r['after'];
1786 foreach ( (array) $results as $result ) {
1787 if ( $result->week != $arc_w_last ) {
1788 $arc_year = $result->yr;
1789 $arc_w_last = $result->week;
1790 $arc_week = get_weekstartend( $result->yyyymmdd, get_option( 'start_of_week' ) );
1791 $arc_week_start = date_i18n( get_option( 'date_format' ), $arc_week['start'] );
1792 $arc_week_end = date_i18n( get_option( 'date_format' ), $arc_week['end'] );
1793 $url = sprintf( '%1$s/%2$s%3$sm%4$s%5$s%6$sw%7$s%8$d', home_url(), '', '?', '=', $arc_year, '&', '=', $result->week );
1794 if ( 'post' !== $r['post_type'] ) {
1795 $url = add_query_arg( 'post_type', $r['post_type'], $url );
1797 $text = $arc_week_start . $archive_week_separator . $arc_week_end;
1798 if ( $r['show_post_count'] ) {
1799 $r['after'] = ' (' . $result->posts . ')' . $after;
1801 $output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
1805 } elseif ( ( 'postbypost' == $r['type'] ) || ('alpha' == $r['type'] ) ) {
1806 $orderby = ( 'alpha' == $r['type'] ) ? 'post_title ASC ' : 'post_date DESC, ID DESC ';
1807 $query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit";
1808 $key = md5( $query );
1809 $key = "wp_get_archives:$key:$last_changed";
1810 if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
1811 $results = $wpdb->get_results( $query );
1812 wp_cache_set( $key, $results, 'posts' );
1815 foreach ( (array) $results as $result ) {
1816 if ( $result->post_date != '0000-00-00 00:00:00' ) {
1817 $url = get_permalink( $result );
1818 if ( $result->post_title ) {
1819 /** This filter is documented in wp-includes/post-template.php */
1820 $text = strip_tags( apply_filters( 'the_title', $result->post_title, $result->ID ) );
1822 $text = $result->ID;
1824 $output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
1837 * Get number of days since the start of the week.
1841 * @param int $num Number of day.
1842 * @return int Days since the start of the week.
1844 function calendar_week_mod($num) {
1846 return ($num - $base*floor($num/$base));
1850 * Display calendar with days that have posts as links.
1852 * The calendar is cached, which will be retrieved, if it exists. If there are
1853 * no posts for the month, then it will not be displayed.
1857 * @global wpdb $wpdb
1859 * @global int $monthnum
1861 * @global WP_Locale $wp_locale
1862 * @global array $posts
1864 * @param bool $initial Optional, default is true. Use initial calendar names.
1865 * @param bool $echo Optional, default is true. Set to false for return.
1866 * @return string|void String when retrieving.
1868 function get_calendar( $initial = true, $echo = true ) {
1869 global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
1871 $key = md5( $m . $monthnum . $year );
1872 $cache = wp_cache_get( 'get_calendar', 'calendar' );
1874 if ( $cache && is_array( $cache ) && isset( $cache[ $key ] ) ) {
1875 /** This filter is documented in wp-includes/general-template.php */
1876 $output = apply_filters( 'get_calendar', $cache[ $key ] );
1886 if ( ! is_array( $cache ) ) {
1890 // Quick check. If we have no posts at all, abort!
1892 $gotsome = $wpdb->get_var("SELECT 1 as test FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1");
1894 $cache[ $key ] = '';
1895 wp_cache_set( 'get_calendar', $cache, 'calendar' );
1900 if ( isset( $_GET['w'] ) ) {
1901 $w = (int) $_GET['w'];
1903 // week_begins = 0 stands for Sunday
1904 $week_begins = (int) get_option( 'start_of_week' );
1905 $ts = current_time( 'timestamp' );
1907 // Let's figure out when we are
1908 if ( ! empty( $monthnum ) && ! empty( $year ) ) {
1909 $thismonth = zeroise( intval( $monthnum ), 2 );
1910 $thisyear = (int) $year;
1911 } elseif ( ! empty( $w ) ) {
1912 // We need to get the month from MySQL
1913 $thisyear = (int) substr( $m, 0, 4 );
1914 //it seems MySQL's weeks disagree with PHP's
1915 $d = ( ( $w - 1 ) * 7 ) + 6;
1916 $thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')");
1917 } elseif ( ! empty( $m ) ) {
1918 $thisyear = (int) substr( $m, 0, 4 );
1919 if ( strlen( $m ) < 6 ) {
1922 $thismonth = zeroise( (int) substr( $m, 4, 2 ), 2 );
1925 $thisyear = gmdate( 'Y', $ts );
1926 $thismonth = gmdate( 'm', $ts );
1929 $unixmonth = mktime( 0, 0 , 0, $thismonth, 1, $thisyear );
1930 $last_day = date( 't', $unixmonth );
1932 // Get the next and previous month and year with at least one post
1933 $previous = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
1935 WHERE post_date < '$thisyear-$thismonth-01'
1936 AND post_type = 'post' AND post_status = 'publish'
1937 ORDER BY post_date DESC
1939 $next = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
1941 WHERE post_date > '$thisyear-$thismonth-{$last_day} 23:59:59'
1942 AND post_type = 'post' AND post_status = 'publish'
1943 ORDER BY post_date ASC
1946 /* translators: Calendar caption: 1: month name, 2: 4-digit year */
1947 $calendar_caption = _x('%1$s %2$s', 'calendar caption');
1948 $calendar_output = '<table id="wp-calendar">
1949 <caption>' . sprintf(
1951 $wp_locale->get_month( $thismonth ),
1952 date( 'Y', $unixmonth )
1959 for ( $wdcount = 0; $wdcount <= 6; $wdcount++ ) {
1960 $myweek[] = $wp_locale->get_weekday( ( $wdcount + $week_begins ) % 7 );
1963 foreach ( $myweek as $wd ) {
1964 $day_name = $initial ? $wp_locale->get_weekday_initial( $wd ) : $wp_locale->get_weekday_abbrev( $wd );
1965 $wd = esc_attr( $wd );
1966 $calendar_output .= "\n\t\t<th scope=\"col\" title=\"$wd\">$day_name</th>";
1969 $calendar_output .= '
1977 $calendar_output .= "\n\t\t".'<td colspan="3" id="prev"><a href="' . get_month_link( $previous->year, $previous->month ) . '">« ' .
1978 $wp_locale->get_month_abbrev( $wp_locale->get_month( $previous->month ) ) .
1981 $calendar_output .= "\n\t\t".'<td colspan="3" id="prev" class="pad"> </td>';
1984 $calendar_output .= "\n\t\t".'<td class="pad"> </td>';
1987 $calendar_output .= "\n\t\t".'<td colspan="3" id="next"><a href="' . get_month_link( $next->year, $next->month ) . '">' .
1988 $wp_locale->get_month_abbrev( $wp_locale->get_month( $next->month ) ) .
1989 ' »</a></td>';
1991 $calendar_output .= "\n\t\t".'<td colspan="3" id="next" class="pad"> </td>';
1994 $calendar_output .= '
2001 $daywithpost = array();
2003 // Get days with posts
2004 $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
2005 FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00'
2006 AND post_type = 'post' AND post_status = 'publish'
2007 AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'", ARRAY_N);
2008 if ( $dayswithposts ) {
2009 foreach ( (array) $dayswithposts as $daywith ) {
2010 $daywithpost[] = $daywith[0];
2014 // See how much we should pad in the beginning
2015 $pad = calendar_week_mod( date( 'w', $unixmonth ) - $week_begins );
2017 $calendar_output .= "\n\t\t".'<td colspan="'. esc_attr( $pad ) .'" class="pad"> </td>';
2021 $daysinmonth = (int) date( 't', $unixmonth );
2023 for ( $day = 1; $day <= $daysinmonth; ++$day ) {
2024 if ( isset($newrow) && $newrow ) {
2025 $calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
2029 if ( $day == gmdate( 'j', $ts ) &&
2030 $thismonth == gmdate( 'm', $ts ) &&
2031 $thisyear == gmdate( 'Y', $ts ) ) {
2032 $calendar_output .= '<td id="today">';
2034 $calendar_output .= '<td>';
2037 if ( in_array( $day, $daywithpost ) ) {
2039 $date_format = date( _x( 'F j, Y', 'daily archives date format' ), strtotime( "{$thisyear}-{$thismonth}-{$day}" ) );
2040 $label = sprintf( __( 'Posts published on %s' ), $date_format );
2041 $calendar_output .= sprintf(
2042 '<a href="%s" aria-label="%s">%s</a>',
2043 get_day_link( $thisyear, $thismonth, $day ),
2048 $calendar_output .= $day;
2050 $calendar_output .= '</td>';
2052 if ( 6 == calendar_week_mod( date( 'w', mktime(0, 0 , 0, $thismonth, $day, $thisyear ) ) - $week_begins ) ) {
2057 $pad = 7 - calendar_week_mod( date( 'w', mktime( 0, 0 , 0, $thismonth, $day, $thisyear ) ) - $week_begins );
2058 if ( $pad != 0 && $pad != 7 ) {
2059 $calendar_output .= "\n\t\t".'<td class="pad" colspan="'. esc_attr( $pad ) .'"> </td>';
2061 $calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>";
2063 $cache[ $key ] = $calendar_output;
2064 wp_cache_set( 'get_calendar', $cache, 'calendar' );
2068 * Filter the HTML calendar output.
2072 * @param string $calendar_output HTML output of the calendar.
2074 echo apply_filters( 'get_calendar', $calendar_output );
2077 /** This filter is documented in wp-includes/general-template.php */
2078 return apply_filters( 'get_calendar', $calendar_output );
2082 * Purge the cached results of get_calendar.
2087 function delete_get_calendar_cache() {
2088 wp_cache_delete( 'get_calendar', 'calendar' );
2092 * Display all of the allowed tags in HTML format with attributes.
2094 * This is useful for displaying in the comment area, which elements and
2095 * attributes are supported. As well as any plugins which want to display it.
2099 * @global array $allowedtags
2101 * @return string HTML allowed tags entity encoded.
2103 function allowed_tags() {
2104 global $allowedtags;
2106 foreach ( (array) $allowedtags as $tag => $attributes ) {
2107 $allowed .= '<'.$tag;
2108 if ( 0 < count($attributes) ) {
2109 foreach ( $attributes as $attribute => $limits ) {
2110 $allowed .= ' '.$attribute.'=""';
2115 return htmlentities( $allowed );
2118 /***** Date/Time tags *****/
2121 * Outputs the date in iso8601 format for xml files.
2125 function the_date_xml() {
2126 echo mysql2date( 'Y-m-d', get_post()->post_date, false );
2130 * Display or Retrieve the date the current post was written (once per date)
2132 * Will only output the date if the current post's date is different from the
2133 * previous one output.
2135 * i.e. Only one date listing will show per day worth of posts shown in the loop, even if the
2136 * function is called several times for each post.
2138 * HTML output can be filtered with 'the_date'.
2139 * Date string output can be filtered with 'get_the_date'.
2143 * @global string|int|bool $currentday
2144 * @global string|int|bool $previousday
2146 * @param string $d Optional. PHP date format defaults to the date_format option if not specified.
2147 * @param string $before Optional. Output before the date.
2148 * @param string $after Optional. Output after the date.
2149 * @param bool $echo Optional, default is display. Whether to echo the date or return it.
2150 * @return string|void String if retrieving.
2152 function the_date( $d = '', $before = '', $after = '', $echo = true ) {
2153 global $currentday, $previousday;
2155 if ( is_new_day() ) {
2156 $the_date = $before . get_the_date( $d ) . $after;
2157 $previousday = $currentday;
2160 * Filter the date a post was published for display.
2164 * @param string $the_date The formatted date string.
2165 * @param string $d PHP date format. Defaults to 'date_format' option
2167 * @param string $before HTML output before the date.
2168 * @param string $after HTML output after the date.
2170 $the_date = apply_filters( 'the_date', $the_date, $d, $before, $after );
2180 * Retrieve the date on which the post was written.
2182 * Unlike the_date() this function will always return the date.
2183 * Modify output with 'get_the_date' filter.
2187 * @param string $d Optional. PHP date format defaults to the date_format option if not specified.
2188 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default current post.
2189 * @return false|string Date the current post was written. False on failure.
2191 function get_the_date( $d = '', $post = null ) {
2192 $post = get_post( $post );
2199 $the_date = mysql2date( get_option( 'date_format' ), $post->post_date );
2201 $the_date = mysql2date( $d, $post->post_date );
2205 * Filter the date a post was published.
2209 * @param string $the_date The formatted date.
2210 * @param string $d PHP date format. Defaults to 'date_format' option
2212 * @param int|WP_Post $post The post object or ID.
2214 return apply_filters( 'get_the_date', $the_date, $d, $post );
2218 * Display the date on which the post was last modified.
2222 * @param string $d Optional. PHP date format defaults to the date_format option if not specified.
2223 * @param string $before Optional. Output before the date.
2224 * @param string $after Optional. Output after the date.
2225 * @param bool $echo Optional, default is display. Whether to echo the date or return it.
2226 * @return string|void String if retrieving.
2228 function the_modified_date( $d = '', $before = '', $after = '', $echo = true ) {
2229 $the_modified_date = $before . get_the_modified_date($d) . $after;
2232 * Filter the date a post was last modified for display.
2236 * @param string $the_modified_date The last modified date.
2237 * @param string $d PHP date format. Defaults to 'date_format' option
2239 * @param string $before HTML output before the date.
2240 * @param string $after HTML output after the date.
2242 $the_modified_date = apply_filters( 'the_modified_date', $the_modified_date, $d, $before, $after );
2245 echo $the_modified_date;
2247 return $the_modified_date;
2252 * Retrieve the date on which the post was last modified.
2256 * @param string $d Optional. PHP date format. Defaults to the "date_format" option
2259 function get_the_modified_date($d = '') {
2261 $the_time = get_post_modified_time(get_option('date_format'), null, null, true);
2263 $the_time = get_post_modified_time($d, null, null, true);
2266 * Filter the date a post was last modified.
2270 * @param string $the_time The formatted date.
2271 * @param string $d PHP date format. Defaults to value specified in
2272 * 'date_format' option.
2274 return apply_filters( 'get_the_modified_date', $the_time, $d );
2278 * Display the time at which the post was written.
2282 * @param string $d Either 'G', 'U', or php date format.
2284 function the_time( $d = '' ) {
2286 * Filter the time a post was written for display.
2290 * @param string $get_the_time The formatted time.
2291 * @param string $d The time format. Accepts 'G', 'U',
2292 * or php date format.
2294 echo apply_filters( 'the_time', get_the_time( $d ), $d );
2298 * Retrieve the time at which the post was written.
2302 * @param string $d Optional. Format to use for retrieving the time the post
2303 * was written. Either 'G', 'U', or php date format defaults
2304 * to the value specified in the time_format option. Default empty.
2305 * @param int|WP_Post $post WP_Post object or ID. Default is global $post object.
2306 * @return false|string Formatted date string or Unix timestamp. False on failure.
2308 function get_the_time( $d = '', $post = null ) {
2309 $post = get_post($post);
2316 $the_time = get_post_time(get_option('time_format'), false, $post, true);
2318 $the_time = get_post_time($d, false, $post, true);
2321 * Filter the time a post was written.
2325 * @param string $the_time The formatted time.
2326 * @param string $d Format to use for retrieving the time the post was written.
2327 * Accepts 'G', 'U', or php date format value specified
2328 * in 'time_format' option. Default empty.
2329 * @param int|WP_Post $post WP_Post object or ID.
2331 return apply_filters( 'get_the_time', $the_time, $d, $post );
2335 * Retrieve the time at which the post was written.
2339 * @param string $d Optional. Format to use for retrieving the time the post
2340 * was written. Either 'G', 'U', or php date format. Default 'U'.
2341 * @param bool $gmt Optional. Whether to retrieve the GMT time. Default false.
2342 * @param int|WP_Post $post WP_Post object or ID. Default is global $post object.
2343 * @param bool $translate Whether to translate the time string. Default false.
2344 * @return false|string|int Formatted date string or Unix timestamp. False on failure.
2346 function get_post_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
2347 $post = get_post($post);
2354 $time = $post->post_date_gmt;
2356 $time = $post->post_date;
2358 $time = mysql2date($d, $time, $translate);
2361 * Filter the localized time a post was written.
2365 * @param string $time The formatted time.
2366 * @param string $d Format to use for retrieving the time the post was written.
2367 * Accepts 'G', 'U', or php date format. Default 'U'.
2368 * @param bool $gmt Whether to retrieve the GMT time. Default false.
2370 return apply_filters( 'get_post_time', $time, $d, $gmt );
2374 * Display the time at which the post was last modified.
2378 * @param string $d Optional Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
2380 function the_modified_time($d = '') {
2382 * Filter the localized time a post was last modified, for display.
2386 * @param string $get_the_modified_time The formatted time.
2387 * @param string $d The time format. Accepts 'G', 'U',
2388 * or php date format. Defaults to value
2389 * specified in 'time_format' option.
2391 echo apply_filters( 'the_modified_time', get_the_modified_time($d), $d );
2395 * Retrieve the time at which the post was last modified.
2399 * @param string $d Optional Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
2402 function get_the_modified_time($d = '') {
2404 $the_time = get_post_modified_time(get_option('time_format'), null, null, true);
2406 $the_time = get_post_modified_time($d, null, null, true);
2409 * Filter the localized time a post was last modified.
2413 * @param string $the_time The formatted time.
2414 * @param string $d Format to use for retrieving the time the post was
2415 * written. Accepts 'G', 'U', or php date format. Defaults
2416 * to value specified in 'time_format' option.
2418 return apply_filters( 'get_the_modified_time', $the_time, $d );
2422 * Retrieve the time at which the post was last modified.
2426 * @param string $d Optional. Format to use for retrieving the time the post
2427 * was modified. Either 'G', 'U', or php date format. Default 'U'.
2428 * @param bool $gmt Optional. Whether to retrieve the GMT time. Default false.
2429 * @param int|WP_Post $post WP_Post object or ID. Default is global $post object.
2430 * @param bool $translate Whether to translate the time string. Default false.
2431 * @return false|string Formatted date string or Unix timestamp. False on failure.
2433 function get_post_modified_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
2434 $post = get_post($post);
2441 $time = $post->post_modified_gmt;
2443 $time = $post->post_modified;
2444 $time = mysql2date($d, $time, $translate);
2447 * Filter the localized time a post was last modified.
2451 * @param string $time The formatted time.
2452 * @param string $d The date format. Accepts 'G', 'U', or php date format. Default 'U'.
2453 * @param bool $gmt Whether to return the GMT time. Default false.
2455 return apply_filters( 'get_post_modified_time', $time, $d, $gmt );
2459 * Display the weekday on which the post was written.
2463 * @global WP_Locale $wp_locale
2465 function the_weekday() {
2467 $the_weekday = $wp_locale->get_weekday( mysql2date( 'w', get_post()->post_date, false ) );
2470 * Filter the weekday on which the post was written, for display.
2474 * @param string $the_weekday
2476 echo apply_filters( 'the_weekday', $the_weekday );
2480 * Display the weekday on which the post was written.
2482 * Will only output the weekday if the current post's weekday is different from
2483 * the previous one output.
2487 * @global WP_Locale $wp_locale
2488 * @global string|int|bool $currentday
2489 * @global string|int|bool $previousweekday
2491 * @param string $before Optional Output before the date.
2492 * @param string $after Optional Output after the date.
2494 function the_weekday_date($before='',$after='') {
2495 global $wp_locale, $currentday, $previousweekday;
2496 $the_weekday_date = '';
2497 if ( $currentday != $previousweekday ) {
2498 $the_weekday_date .= $before;
2499 $the_weekday_date .= $wp_locale->get_weekday( mysql2date( 'w', get_post()->post_date, false ) );
2500 $the_weekday_date .= $after;
2501 $previousweekday = $currentday;
2505 * Filter the localized date on which the post was written, for display.
2509 * @param string $the_weekday_date
2510 * @param string $before The HTML to output before the date.
2511 * @param string $after The HTML to output after the date.
2513 $the_weekday_date = apply_filters( 'the_weekday_date', $the_weekday_date, $before, $after );
2514 echo $the_weekday_date;
2518 * Fire the wp_head action
2522 function wp_head() {
2524 * Print scripts or data in the head tag on the front end.
2528 do_action( 'wp_head' );
2532 * Fire the wp_footer action
2536 function wp_footer() {
2538 * Print scripts or data before the closing body tag on the front end.
2542 do_action( 'wp_footer' );
2546 * Display the links to the general feeds.
2550 * @param array $args Optional arguments.
2552 function feed_links( $args = array() ) {
2553 if ( !current_theme_supports('automatic-feed-links') )
2557 /* translators: Separator between blog name and feed type in feed links */
2558 'separator' => _x('»', 'feed link'),
2559 /* translators: 1: blog title, 2: separator (raquo) */
2560 'feedtitle' => __('%1$s %2$s Feed'),
2561 /* translators: 1: blog title, 2: separator (raquo) */
2562 'comstitle' => __('%1$s %2$s Comments Feed'),
2565 $args = wp_parse_args( $args, $defaults );
2568 * Filter whether to display the posts feed link.
2572 * @param bool $show Whether to display the posts feed link. Default true.
2574 if ( apply_filters( 'feed_links_show_posts_feed', true ) ) {
2575 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";
2579 * Filter whether to display the comments feed link.
2583 * @param bool $show Whether to display the comments feed link. Default true.
2585 if ( apply_filters( 'feed_links_show_comments_feed', true ) ) {
2586 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";
2591 * Display the links to the extra feeds such as category feeds.
2595 * @param array $args Optional arguments.
2597 function feed_links_extra( $args = array() ) {
2599 /* translators: Separator between blog name and feed type in feed links */
2600 'separator' => _x('»', 'feed link'),
2601 /* translators: 1: blog name, 2: separator(raquo), 3: post title */
2602 'singletitle' => __('%1$s %2$s %3$s Comments Feed'),
2603 /* translators: 1: blog name, 2: separator(raquo), 3: category name */
2604 'cattitle' => __('%1$s %2$s %3$s Category Feed'),
2605 /* translators: 1: blog name, 2: separator(raquo), 3: tag name */
2606 'tagtitle' => __('%1$s %2$s %3$s Tag Feed'),
2607 /* translators: 1: blog name, 2: separator(raquo), 3: term name, 4: taxonomy singular name */
2608 'taxtitle' => __('%1$s %2$s %3$s %4$s Feed'),
2609 /* translators: 1: blog name, 2: separator(raquo), 3: author name */
2610 'authortitle' => __('%1$s %2$s Posts by %3$s Feed'),
2611 /* translators: 1: blog name, 2: separator(raquo), 3: search phrase */
2612 'searchtitle' => __('%1$s %2$s Search Results for “%3$s” Feed'),
2613 /* translators: 1: blog name, 2: separator(raquo), 3: post type name */
2614 'posttypetitle' => __('%1$s %2$s %3$s Feed'),
2617 $args = wp_parse_args( $args, $defaults );
2619 if ( is_singular() ) {
2621 $post = get_post( $id );
2623 if ( comments_open() || pings_open() || $post->comment_count > 0 ) {
2624 $title = sprintf( $args['singletitle'], get_bloginfo('name'), $args['separator'], the_title_attribute( array( 'echo' => false ) ) );
2625 $href = get_post_comments_feed_link( $post->ID );
2627 } elseif ( is_post_type_archive() ) {
2628 $post_type = get_query_var( 'post_type' );
2629 if ( is_array( $post_type ) )
2630 $post_type = reset( $post_type );
2632 $post_type_obj = get_post_type_object( $post_type );
2633 $title = sprintf( $args['posttypetitle'], get_bloginfo( 'name' ), $args['separator'], $post_type_obj->labels->name );
2634 $href = get_post_type_archive_feed_link( $post_type_obj->name );
2635 } elseif ( is_category() ) {
2636 $term = get_queried_object();
2639 $title = sprintf( $args['cattitle'], get_bloginfo('name'), $args['separator'], $term->name );
2640 $href = get_category_feed_link( $term->term_id );
2642 } elseif ( is_tag() ) {
2643 $term = get_queried_object();
2646 $title = sprintf( $args['tagtitle'], get_bloginfo('name'), $args['separator'], $term->name );
2647 $href = get_tag_feed_link( $term->term_id );
2649 } elseif ( is_tax() ) {
2650 $term = get_queried_object();
2651 $tax = get_taxonomy( $term->taxonomy );
2652 $title = sprintf( $args['taxtitle'], get_bloginfo('name'), $args['separator'], $term->name, $tax->labels->singular_name );
2653 $href = get_term_feed_link( $term->term_id, $term->taxonomy );
2654 } elseif ( is_author() ) {
2655 $author_id = intval( get_query_var('author') );
2657 $title = sprintf( $args['authortitle'], get_bloginfo('name'), $args['separator'], get_the_author_meta( 'display_name', $author_id ) );
2658 $href = get_author_feed_link( $author_id );
2659 } elseif ( is_search() ) {
2660 $title = sprintf( $args['searchtitle'], get_bloginfo('name'), $args['separator'], get_search_query( false ) );
2661 $href = get_search_feed_link();
2662 } elseif ( is_post_type_archive() ) {
2663 $title = sprintf( $args['posttypetitle'], get_bloginfo('name'), $args['separator'], post_type_archive_title( '', false ) );
2664 $post_type_obj = get_queried_object();
2665 if ( $post_type_obj )
2666 $href = get_post_type_archive_feed_link( $post_type_obj->name );
2669 if ( isset($title) && isset($href) )
2670 echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( $title ) . '" href="' . esc_url( $href ) . '" />' . "\n";
2674 * Display the link to the Really Simple Discovery service endpoint.
2676 * @link http://archipelago.phrasewise.com/rsd
2679 function rsd_link() {
2680 echo '<link rel="EditURI" type="application/rsd+xml" title="RSD" href="' . esc_url( site_url( 'xmlrpc.php?rsd', 'rpc' ) ) . '" />' . "\n";
2684 * Display the link to the Windows Live Writer manifest file.
2686 * @link http://msdn.microsoft.com/en-us/library/bb463265.aspx
2689 function wlwmanifest_link() {
2690 echo '<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="',
2691 includes_url( 'wlwmanifest.xml' ), '" /> ', "\n";
2695 * Display a noindex meta tag if required by the blog configuration.
2697 * If a blog is marked as not being public then the noindex meta tag will be
2698 * output to tell web robots not to index the page content. Add this to the wp_head action.
2699 * Typical usage is as a wp_head callback. add_action( 'wp_head', 'noindex' );
2705 function noindex() {
2706 // If the blog is not public, tell robots to go away.
2707 if ( '0' == get_option('blog_public') )
2712 * Display a noindex meta tag.
2714 * Outputs a noindex meta tag that tells web robots not to index the page content.
2715 * Typical usage is as a wp_head callback. add_action( 'wp_head', 'wp_no_robots' );
2719 function wp_no_robots() {
2720 echo "<meta name='robots' content='noindex,follow' />\n";
2724 * Display site icon meta tags.
2728 * @link http://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#rel-icon HTML5 specification link icon.
2730 function wp_site_icon() {
2731 if ( ! has_site_icon() && ! is_customize_preview() ) {
2736 sprintf( '<link rel="icon" href="%s" sizes="32x32" />', esc_url( get_site_icon_url( 32 ) ) ),
2737 sprintf( '<link rel="icon" href="%s" sizes="192x192" />', esc_url( get_site_icon_url( 192 ) ) ),
2738 sprintf( '<link rel="apple-touch-icon-precomposed" href="%s" />', esc_url( get_site_icon_url( 180 ) ) ),
2739 sprintf( '<meta name="msapplication-TileImage" content="%s" />', esc_url( get_site_icon_url( 270 ) ) ),
2743 * Filter the site icon meta tags, so Plugins can add their own.
2747 * @param array $meta_tags Site Icon meta elements.
2749 $meta_tags = apply_filters( 'site_icon_meta_tags', $meta_tags );
2750 $meta_tags = array_filter( $meta_tags );
2752 foreach ( $meta_tags as $meta_tag ) {
2758 * Whether the user should have a WYSIWIG editor.
2760 * Checks that the user requires a WYSIWIG editor and that the editor is
2761 * supported in the users browser.
2765 * @global bool $wp_rich_edit
2766 * @global bool $is_gecko
2767 * @global bool $is_opera
2768 * @global bool $is_safari
2769 * @global bool $is_chrome
2770 * @global bool $is_IE
2774 function user_can_richedit() {
2775 global $wp_rich_edit, $is_gecko, $is_opera, $is_safari, $is_chrome, $is_IE, $is_edge;
2777 if ( !isset($wp_rich_edit) ) {
2778 $wp_rich_edit = false;
2780 if ( get_user_option( 'rich_editing' ) == 'true' || ! is_user_logged_in() ) { // default to 'true' for logged out users
2782 $wp_rich_edit = ! wp_is_mobile() || ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval( $match[1] ) >= 534 );
2783 } elseif ( $is_gecko || $is_chrome || $is_IE || $is_edge || ( $is_opera && !wp_is_mobile() ) ) {
2784 $wp_rich_edit = true;
2790 * Filter whether the user can access the rich (Visual) editor.
2794 * @param bool $wp_rich_edit Whether the user can access to the rich (Visual) editor.
2796 return apply_filters( 'user_can_richedit', $wp_rich_edit );
2800 * Find out which editor should be displayed by default.
2802 * Works out which of the two editors to display as the current editor for a
2803 * user. The 'html' setting is for the "Text" editor tab.
2807 * @return string Either 'tinymce', or 'html', or 'test'
2809 function wp_default_editor() {
2810 $r = user_can_richedit() ? 'tinymce' : 'html'; // defaults
2811 if ( wp_get_current_user() ) { // look for cookie
2812 $ed = get_user_setting('editor', 'tinymce');
2813 $r = ( in_array($ed, array('tinymce', 'html', 'test') ) ) ? $ed : $r;
2817 * Filter which editor should be displayed by default.
2821 * @param array $r An array of editors. Accepts 'tinymce', 'html', 'test'.
2823 return apply_filters( 'wp_default_editor', $r );
2827 * Renders an editor.
2829 * Using this function is the proper way to output all needed components for both TinyMCE and Quicktags.
2830 * _WP_Editors should not be used directly. See https://core.trac.wordpress.org/ticket/17144.
2832 * NOTE: Once initialized the TinyMCE editor cannot be safely moved in the DOM. For that reason
2833 * running wp_editor() inside of a metabox is not a good idea unless only Quicktags is used.
2834 * On the post edit screen several actions can be used to include additional editors
2835 * containing TinyMCE: 'edit_page_form', 'edit_form_advanced' and 'dbx_post_sidebar'.
2836 * See https://core.trac.wordpress.org/ticket/19173 for more information.
2838 * @see _WP_Editors::editor()
2841 * @param string $content Initial content for the editor.
2842 * @param string $editor_id HTML ID attribute value for the textarea and TinyMCE. Can only be /[a-z]+/.
2843 * @param array $settings See _WP_Editors::editor().
2845 function wp_editor( $content, $editor_id, $settings = array() ) {
2846 if ( ! class_exists( '_WP_Editors', false ) )
2847 require( ABSPATH . WPINC . '/class-wp-editor.php' );
2849 _WP_Editors::editor($content, $editor_id, $settings);
2853 * Retrieve the contents of the search WordPress query variable.
2855 * The search query string is passed through {@link esc_attr()}
2856 * to ensure that it is safe for placing in an html attribute.
2860 * @param bool $escaped Whether the result is escaped. Default true.
2861 * Only use when you are later escaping it. Do not use unescaped.
2864 function get_search_query( $escaped = true ) {
2866 * Filter the contents of the search query variable.
2870 * @param mixed $search Contents of the search query variable.
2872 $query = apply_filters( 'get_search_query', get_query_var( 's' ) );
2875 $query = esc_attr( $query );
2880 * Display the contents of the search query variable.
2882 * The search query string is passed through {@link esc_attr()}
2883 * to ensure that it is safe for placing in an html attribute.
2887 function the_search_query() {
2889 * Filter the contents of the search query variable for display.
2893 * @param mixed $search Contents of the search query variable.
2895 echo esc_attr( apply_filters( 'the_search_query', get_search_query( false ) ) );
2899 * Gets the language attributes for the html tag.
2901 * Builds up a set of html attributes containing the text direction and language
2902 * information for the page.
2906 * @param string $doctype Optional. The type of html document. Accepts 'xhtml' or 'html'. Default 'html'.
2908 function get_language_attributes( $doctype = 'html' ) {
2909 $attributes = array();
2911 if ( function_exists( 'is_rtl' ) && is_rtl() )
2912 $attributes[] = 'dir="rtl"';
2914 if ( $lang = get_bloginfo('language') ) {
2915 if ( get_option('html_type') == 'text/html' || $doctype == 'html' )
2916 $attributes[] = "lang=\"$lang\"";
2918 if ( get_option('html_type') != 'text/html' || $doctype == 'xhtml' )
2919 $attributes[] = "xml:lang=\"$lang\"";
2922 $output = implode(' ', $attributes);
2925 * Filter the language attributes for display in the html tag.
2928 * @since 4.3.0 Added the `$doctype` parameter.
2930 * @param string $output A space-separated list of language attributes.
2931 * @param string $doctype The type of html document (xhtml|html).
2933 return apply_filters( 'language_attributes', $output, $doctype );
2937 * Displays the language attributes for the html tag.
2939 * Builds up a set of html attributes containing the text direction and language
2940 * information for the page.
2943 * @since 4.3.0 Converted into a wrapper for get_language_attributes().
2945 * @param string $doctype Optional. The type of html document. Accepts 'xhtml' or 'html'. Default 'html'.
2947 function language_attributes( $doctype = 'html' ) {
2948 echo get_language_attributes( $doctype );
2952 * Retrieve paginated link for archive post pages.
2954 * Technically, the function can be used to create paginated link list for any
2955 * area. The 'base' argument is used to reference the url, which will be used to
2956 * create the paginated links. The 'format' argument is then used for replacing
2957 * the page number. It is however, most likely and by default, to be used on the
2958 * archive post pages.
2960 * The 'type' argument controls format of the returned value. The default is
2961 * 'plain', which is just a string with the links separated by a newline
2962 * character. The other possible values are either 'array' or 'list'. The
2963 * 'array' value will return an array of the paginated link list to offer full
2964 * control of display. The 'list' value will place all of the paginated links in
2965 * an unordered HTML list.
2967 * The 'total' argument is the total amount of pages and is an integer. The
2968 * 'current' argument is the current page number and is also an integer.
2970 * An example of the 'base' argument is "http://example.com/all_posts.php%_%"
2971 * and the '%_%' is required. The '%_%' will be replaced by the contents of in
2972 * the 'format' argument. An example for the 'format' argument is "?page=%#%"
2973 * and the '%#%' is also required. The '%#%' will be replaced with the page
2976 * You can include the previous and next links in the list by setting the
2977 * 'prev_next' argument to true, which it is by default. You can set the
2978 * previous text, by using the 'prev_text' argument. You can set the next text
2979 * by setting the 'next_text' argument.
2981 * If the 'show_all' argument is set to true, then it will show all of the pages
2982 * instead of a short list of the pages near the current page. By default, the
2983 * 'show_all' is set to false and controlled by the 'end_size' and 'mid_size'
2984 * arguments. The 'end_size' argument is how many numbers on either the start
2985 * and the end list edges, by default is 1. The 'mid_size' argument is how many
2986 * numbers to either side of current page, but not including current page.
2988 * It is possible to add query vars to the link by using the 'add_args' argument
2989 * and see {@link add_query_arg()} for more information.
2991 * The 'before_page_number' and 'after_page_number' arguments allow users to
2992 * augment the links themselves. Typically this might be to add context to the
2993 * numbered links so that screen reader users understand what the links are for.
2994 * The text strings are added before and after the page number - within the
2999 * @global WP_Query $wp_query
3000 * @global WP_Rewrite $wp_rewrite
3002 * @param string|array $args {
3003 * Optional. Array or string of arguments for generating paginated links for archives.
3005 * @type string $base Base of the paginated url. Default empty.
3006 * @type string $format Format for the pagination structure. Default empty.
3007 * @type int $total The total amount of pages. Default is the value WP_Query's
3008 * `max_num_pages` or 1.
3009 * @type int $current The current page number. Default is 'paged' query var or 1.
3010 * @type bool $show_all Whether to show all pages. Default false.
3011 * @type int $end_size How many numbers on either the start and the end list edges.
3013 * @type int $mid_size How many numbers to either side of the current pages. Default 2.
3014 * @type bool $prev_next Whether to include the previous and next links in the list. Default true.
3015 * @type bool $prev_text The previous page text. Default '« Previous'.
3016 * @type bool $next_text The next page text. Default '« Previous'.
3017 * @type string $type Controls format of the returned value. Possible values are 'plain',
3018 * 'array' and 'list'. Default is 'plain'.
3019 * @type array $add_args An array of query args to add. Default false.
3020 * @type string $add_fragment A string to append to each link. Default empty.
3021 * @type string $before_page_number A string to appear before the page number. Default empty.
3022 * @type string $after_page_number A string to append after the page number. Default empty.
3024 * @return array|string|void String of page links or array of page links.
3026 function paginate_links( $args = '' ) {
3027 global $wp_query, $wp_rewrite;
3029 // Setting up default values based on the current URL.
3030 $pagenum_link = html_entity_decode( get_pagenum_link() );
3031 $url_parts = explode( '?', $pagenum_link );
3033 // Get max pages and current page out of the current query, if available.
3034 $total = isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1;
3035 $current = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1;
3037 // Append the format placeholder to the base URL.
3038 $pagenum_link = trailingslashit( $url_parts[0] ) . '%_%';
3040 // URL base depends on permalink settings.
3041 $format = $wp_rewrite->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : '';
3042 $format .= $wp_rewrite->using_permalinks() ? user_trailingslashit( $wp_rewrite->pagination_base . '/%#%', 'paged' ) : '?paged=%#%';
3045 'base' => $pagenum_link, // http://example.com/all_posts.php%_% : %_% is replaced by format (below)
3046 'format' => $format, // ?page=%#% : %#% is replaced by the page number
3048 'current' => $current,
3049 'show_all' => false,
3050 'prev_next' => true,
3051 'prev_text' => __('« Previous'),
3052 'next_text' => __('Next »'),
3056 'add_args' => array(), // array of query args to add
3057 'add_fragment' => '',
3058 'before_page_number' => '',
3059 'after_page_number' => ''
3062 $args = wp_parse_args( $args, $defaults );
3064 if ( ! is_array( $args['add_args'] ) ) {
3065 $args['add_args'] = array();
3068 // Merge additional query vars found in the original URL into 'add_args' array.
3069 if ( isset( $url_parts[1] ) ) {
3070 // Find the format argument.
3071 $format = explode( '?', str_replace( '%_%', $args['format'], $args['base'] ) );
3072 $format_query = isset( $format[1] ) ? $format[1] : '';
3073 wp_parse_str( $format_query, $format_args );
3075 // Find the query args of the requested URL.
3076 wp_parse_str( $url_parts[1], $url_query_args );
3078 // Remove the format argument from the array of query arguments, to avoid overwriting custom format.
3079 foreach ( $format_args as $format_arg => $format_arg_value ) {
3080 unset( $url_query_args[ $format_arg ] );
3083 $args['add_args'] = array_merge( $args['add_args'], urlencode_deep( $url_query_args ) );
3086 // Who knows what else people pass in $args
3087 $total = (int) $args['total'];
3091 $current = (int) $args['current'];
3092 $end_size = (int) $args['end_size']; // Out of bounds? Make it the default.
3093 if ( $end_size < 1 ) {
3096 $mid_size = (int) $args['mid_size'];
3097 if ( $mid_size < 0 ) {
3100 $add_args = $args['add_args'];
3102 $page_links = array();
3105 if ( $args['prev_next'] && $current && 1 < $current ) :
3106 $link = str_replace( '%_%', 2 == $current ? '' : $args['format'], $args['base'] );
3107 $link = str_replace( '%#%', $current - 1, $link );
3109 $link = add_query_arg( $add_args, $link );
3110 $link .= $args['add_fragment'];
3113 * Filter the paginated links for the given archive pages.
3117 * @param string $link The paginated link URL.
3119 $page_links[] = '<a class="prev page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $args['prev_text'] . '</a>';
3121 for ( $n = 1; $n <= $total; $n++ ) :
3122 if ( $n == $current ) :
3123 $page_links[] = "<span class='page-numbers current'>" . $args['before_page_number'] . number_format_i18n( $n ) . $args['after_page_number'] . "</span>";
3126 if ( $args['show_all'] || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) :
3127 $link = str_replace( '%_%', 1 == $n ? '' : $args['format'], $args['base'] );
3128 $link = str_replace( '%#%', $n, $link );
3130 $link = add_query_arg( $add_args, $link );
3131 $link .= $args['add_fragment'];
3133 /** This filter is documented in wp-includes/general-template.php */
3134 $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>";
3136 elseif ( $dots && ! $args['show_all'] ) :
3137 $page_links[] = '<span class="page-numbers dots">' . __( '…' ) . '</span>';
3142 if ( $args['prev_next'] && $current && ( $current < $total || -1 == $total ) ) :
3143 $link = str_replace( '%_%', $args['format'], $args['base'] );
3144 $link = str_replace( '%#%', $current + 1, $link );
3146 $link = add_query_arg( $add_args, $link );
3147 $link .= $args['add_fragment'];
3149 /** This filter is documented in wp-includes/general-template.php */
3150 $page_links[] = '<a class="next page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $args['next_text'] . '</a>';
3152 switch ( $args['type'] ) {
3157 $r .= "<ul class='page-numbers'>\n\t<li>";
3158 $r .= join("</li>\n\t<li>", $page_links);
3159 $r .= "</li>\n</ul>\n";
3163 $r = join("\n", $page_links);
3170 * Registers an admin colour scheme css file.
3172 * Allows a plugin to register a new admin colour scheme. For example:
3174 * wp_admin_css_color( 'classic', __( 'Classic' ), admin_url( "css/colors-classic.css" ), array(
3175 * '#07273E', '#14568A', '#D54E21', '#2683AE'
3180 * @global array $_wp_admin_css_colors
3182 * @param string $key The unique key for this theme.
3183 * @param string $name The name of the theme.
3184 * @param string $url The URL of the CSS file containing the color scheme.
3185 * @param array $colors Optional. An array of CSS color definition strings which are used
3186 * to give the user a feel for the theme.
3187 * @param array $icons {
3188 * Optional. CSS color definitions used to color any SVG icons.
3190 * @type string $base SVG icon base color.
3191 * @type string $focus SVG icon color on focus.
3192 * @type string $current SVG icon color of current admin menu link.
3195 function wp_admin_css_color( $key, $name, $url, $colors = array(), $icons = array() ) {
3196 global $_wp_admin_css_colors;
3198 if ( !isset($_wp_admin_css_colors) )
3199 $_wp_admin_css_colors = array();
3201 $_wp_admin_css_colors[$key] = (object) array(
3204 'colors' => $colors,
3205 'icon_colors' => $icons,
3210 * Registers the default Admin color schemes
3214 * @global string $wp_version
3216 function register_admin_color_schemes() {
3217 $suffix = is_rtl() ? '-rtl' : '';
3218 $suffix .= SCRIPT_DEBUG ? '' : '.min';
3220 wp_admin_css_color( 'fresh', _x( 'Default', 'admin color scheme' ),
3222 array( '#222', '#333', '#0073aa', '#00a0d2' ),
3223 array( 'base' => '#82878c', 'focus' => '#00a0d2', 'current' => '#fff' )
3226 // Other color schemes are not available when running out of src
3227 if ( false !== strpos( $GLOBALS['wp_version'], '-src' ) )
3230 wp_admin_css_color( 'light', _x( 'Light', 'admin color scheme' ),
3231 admin_url( "css/colors/light/colors$suffix.css" ),
3232 array( '#e5e5e5', '#999', '#d64e07', '#04a4cc' ),
3233 array( 'base' => '#999', 'focus' => '#ccc', 'current' => '#ccc' )
3236 wp_admin_css_color( 'blue', _x( 'Blue', 'admin color scheme' ),
3237 admin_url( "css/colors/blue/colors$suffix.css" ),
3238 array( '#096484', '#4796b3', '#52accc', '#74B6CE' ),
3239 array( 'base' => '#e5f8ff', 'focus' => '#fff', 'current' => '#fff' )
3242 wp_admin_css_color( 'midnight', _x( 'Midnight', 'admin color scheme' ),
3243 admin_url( "css/colors/midnight/colors$suffix.css" ),
3244 array( '#25282b', '#363b3f', '#69a8bb', '#e14d43' ),
3245 array( 'base' => '#f1f2f3', 'focus' => '#fff', 'current' => '#fff' )
3248 wp_admin_css_color( 'sunrise', _x( 'Sunrise', 'admin color scheme' ),
3249 admin_url( "css/colors/sunrise/colors$suffix.css" ),
3250 array( '#b43c38', '#cf4944', '#dd823b', '#ccaf0b' ),
3251 array( 'base' => '#f3f1f1', 'focus' => '#fff', 'current' => '#fff' )
3254 wp_admin_css_color( 'ectoplasm', _x( 'Ectoplasm', 'admin color scheme' ),
3255 admin_url( "css/colors/ectoplasm/colors$suffix.css" ),
3256 array( '#413256', '#523f6d', '#a3b745', '#d46f15' ),
3257 array( 'base' => '#ece6f6', 'focus' => '#fff', 'current' => '#fff' )
3260 wp_admin_css_color( 'ocean', _x( 'Ocean', 'admin color scheme' ),
3261 admin_url( "css/colors/ocean/colors$suffix.css" ),
3262 array( '#627c83', '#738e96', '#9ebaa0', '#aa9d88' ),
3263 array( 'base' => '#f2fcff', 'focus' => '#fff', 'current' => '#fff' )
3266 wp_admin_css_color( 'coffee', _x( 'Coffee', 'admin color scheme' ),
3267 admin_url( "css/colors/coffee/colors$suffix.css" ),
3268 array( '#46403c', '#59524c', '#c7a589', '#9ea476' ),
3269 array( 'base' => '#f3f2f1', 'focus' => '#fff', 'current' => '#fff' )
3275 * Display the URL of a WordPress admin CSS file.
3277 * @see WP_Styles::_css_href and its style_loader_src filter.
3281 * @param string $file file relative to wp-admin/ without its ".css" extension.
3284 function wp_admin_css_uri( $file = 'wp-admin' ) {
3285 if ( defined('WP_INSTALLING') ) {
3286 $_file = "./$file.css";
3288 $_file = admin_url("$file.css");
3290 $_file = add_query_arg( 'version', get_bloginfo( 'version' ), $_file );
3293 * Filter the URI of a WordPress admin CSS file.
3297 * @param string $_file Relative path to the file with query arguments attached.
3298 * @param string $file Relative path to the file, minus its ".css" extension.
3300 return apply_filters( 'wp_admin_css_uri', $_file, $file );
3304 * Enqueues or directly prints a stylesheet link to the specified CSS file.
3306 * "Intelligently" decides to enqueue or to print the CSS file. If the
3307 * 'wp_print_styles' action has *not* yet been called, the CSS file will be
3308 * enqueued. If the wp_print_styles action *has* been called, the CSS link will
3309 * be printed. Printing may be forced by passing true as the $force_echo
3310 * (second) parameter.
3312 * For backward compatibility with WordPress 2.3 calling method: If the $file
3313 * (first) parameter does not correspond to a registered CSS file, we assume
3314 * $file is a file relative to wp-admin/ without its ".css" extension. A
3315 * stylesheet link to that generated URL is printed.
3319 * @param string $file Optional. Style handle name or file name (without ".css" extension) relative
3320 * to wp-admin/. Defaults to 'wp-admin'.
3321 * @param bool $force_echo Optional. Force the stylesheet link to be printed rather than enqueued.
3323 function wp_admin_css( $file = 'wp-admin', $force_echo = false ) {
3324 // For backward compatibility
3325 $handle = 0 === strpos( $file, 'css/' ) ? substr( $file, 4 ) : $file;
3327 if ( wp_styles()->query( $handle ) ) {
3328 if ( $force_echo || did_action( 'wp_print_styles' ) ) // we already printed the style queue. Print this one immediately
3329 wp_print_styles( $handle );
3330 else // Add to style queue
3331 wp_enqueue_style( $handle );
3336 * Filter the stylesheet link to the specified CSS file.
3338 * If the site is set to display right-to-left, the RTL stylesheet link
3339 * will be used instead.
3343 * @param string $file Style handle name or filename (without ".css" extension)
3344 * relative to wp-admin/. Defaults to 'wp-admin'.
3346 echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . esc_url( wp_admin_css_uri( $file ) ) . "' type='text/css' />\n", $file );
3348 if ( function_exists( 'is_rtl' ) && is_rtl() ) {
3349 /** This filter is documented in wp-includes/general-template.php */
3350 echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . esc_url( wp_admin_css_uri( "$file-rtl" ) ) . "' type='text/css' />\n", "$file-rtl" );
3355 * Enqueues the default ThickBox js and css.
3357 * If any of the settings need to be changed, this can be done with another js
3358 * file similar to media-upload.js. That file should
3359 * require array('thickbox') to ensure it is loaded after.
3363 function add_thickbox() {
3364 wp_enqueue_script( 'thickbox' );
3365 wp_enqueue_style( 'thickbox' );
3367 if ( is_network_admin() )
3368 add_action( 'admin_head', '_thickbox_path_admin_subfolder' );
3372 * Display the XHTML generator that is generated on the wp_head hook.
3376 function wp_generator() {
3378 * Filter the output of the XHTML generator tag.
3382 * @param string $generator_type The XHTML generator.
3384 the_generator( apply_filters( 'wp_generator_type', 'xhtml' ) );
3388 * Display the generator XML or Comment for RSS, ATOM, etc.
3390 * Returns the correct generator type for the requested output format. Allows
3391 * for a plugin to filter generators overall the the_generator filter.
3395 * @param string $type The type of generator to output - (html|xhtml|atom|rss2|rdf|comment|export).
3397 function the_generator( $type ) {
3399 * Filter the output of the XHTML generator tag for display.
3403 * @param string $generator_type The generator output.
3404 * @param string $type The type of generator to output. Accepts 'html',
3405 * 'xhtml', 'atom', 'rss2', 'rdf', 'comment', 'export'.
3407 echo apply_filters( 'the_generator', get_the_generator($type), $type ) . "\n";
3411 * Creates the generator XML or Comment for RSS, ATOM, etc.
3413 * Returns the correct generator type for the requested output format. Allows
3414 * for a plugin to filter generators on an individual basis using the
3415 * 'get_the_generator_{$type}' filter.
3419 * @param string $type The type of generator to return - (html|xhtml|atom|rss2|rdf|comment|export).
3420 * @return string|void The HTML content for the generator.
3422 function get_the_generator( $type = '' ) {
3423 if ( empty( $type ) ) {
3425 $current_filter = current_filter();
3426 if ( empty( $current_filter ) )
3429 switch ( $current_filter ) {
3431 case 'commentsrss2_head' :
3442 case 'comments_atom_head' :
3451 $gen = '<meta name="generator" content="WordPress ' . get_bloginfo( 'version' ) . '">';
3454 $gen = '<meta name="generator" content="WordPress ' . get_bloginfo( 'version' ) . '" />';
3457 $gen = '<generator uri="https://wordpress.org/" version="' . get_bloginfo_rss( 'version' ) . '">WordPress</generator>';
3460 $gen = '<generator>https://wordpress.org/?v=' . get_bloginfo_rss( 'version' ) . '</generator>';
3463 $gen = '<admin:generatorAgent rdf:resource="https://wordpress.org/?v=' . get_bloginfo_rss( 'version' ) . '" />';
3466 $gen = '<!-- generator="WordPress/' . get_bloginfo( 'version' ) . '" -->';
3469 $gen = '<!-- generator="WordPress/' . get_bloginfo_rss('version') . '" created="'. date('Y-m-d H:i') . '" -->';
3474 * Filter the HTML for the retrieved generator type.
3476 * The dynamic portion of the hook name, `$type`, refers to the generator type.
3480 * @param string $gen The HTML markup output to {@see wp_head()}.
3481 * @param string $type The type of generator. Accepts 'html', 'xhtml', 'atom',
3482 * 'rss2', 'rdf', 'comment', 'export'.
3484 return apply_filters( "get_the_generator_{$type}", $gen, $type );
3488 * Outputs the html checked attribute.
3490 * Compares the first two arguments and if identical marks as checked
3494 * @param mixed $checked One of the values to compare
3495 * @param mixed $current (true) The other value to compare if not just true
3496 * @param bool $echo Whether to echo or just return the string
3497 * @return string html attribute or empty string
3499 function checked( $checked, $current = true, $echo = true ) {
3500 return __checked_selected_helper( $checked, $current, $echo, 'checked' );
3504 * Outputs the html selected attribute.
3506 * Compares the first two arguments and if identical marks as selected
3510 * @param mixed $selected One of the values to compare
3511 * @param mixed $current (true) The other value to compare if not just true
3512 * @param bool $echo Whether to echo or just return the string
3513 * @return string html attribute or empty string
3515 function selected( $selected, $current = true, $echo = true ) {
3516 return __checked_selected_helper( $selected, $current, $echo, 'selected' );
3520 * Outputs the html disabled attribute.
3522 * Compares the first two arguments and if identical marks as disabled
3526 * @param mixed $disabled One of the values to compare
3527 * @param mixed $current (true) The other value to compare if not just true
3528 * @param bool $echo Whether to echo or just return the string
3529 * @return string html attribute or empty string
3531 function disabled( $disabled, $current = true, $echo = true ) {
3532 return __checked_selected_helper( $disabled, $current, $echo, 'disabled' );
3536 * Private helper function for checked, selected, and disabled.
3538 * Compares the first two arguments and if identical marks as $type
3543 * @param mixed $helper One of the values to compare
3544 * @param mixed $current (true) The other value to compare if not just true
3545 * @param bool $echo Whether to echo or just return the string
3546 * @param string $type The type of checked|selected|disabled we are doing
3547 * @return string html attribute or empty string
3549 function __checked_selected_helper( $helper, $current, $echo, $type ) {
3550 if ( (string) $helper === (string) $current )
3551 $result = " $type='$type'";
3562 * Default settings for heartbeat
3564 * Outputs the nonce used in the heartbeat XHR
3568 * @param array $settings
3569 * @return array $settings
3571 function wp_heartbeat_settings( $settings ) {
3573 $settings['ajaxurl'] = admin_url( 'admin-ajax.php', 'relative' );
3575 if ( is_user_logged_in() )
3576 $settings['nonce'] = wp_create_nonce( 'heartbeat-nonce' );