wp/wp-includes/general-template.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
    14  *
    14  *
    15  * For the parameter, if the file is called "header-special.php" then specify
    15  * For the parameter, if the file is called "header-special.php" then specify
    16  * "special".
    16  * "special".
    17  *
    17  *
    18  * @since 1.5.0
    18  * @since 1.5.0
       
    19  * @since 5.5.0 A return value was added.
       
    20  * @since 5.5.0 The `$args` parameter was added.
    19  *
    21  *
    20  * @param string $name The name of the specialised header.
    22  * @param string $name The name of the specialised header.
    21  */
    23  * @param array  $args Optional. Additional arguments passed to the header template.
    22 function get_header( $name = null ) {
    24  *                     Default empty array.
       
    25  * @return void|false Void on success, false if the template does not exist.
       
    26  */
       
    27 function get_header( $name = null, $args = array() ) {
    23 	/**
    28 	/**
    24 	 * Fires before the header template file is loaded.
    29 	 * Fires before the header template file is loaded.
    25 	 *
    30 	 *
    26 	 * @since 2.1.0
    31 	 * @since 2.1.0
    27 	 * @since 2.8.0 $name parameter added.
    32 	 * @since 2.8.0 The `$name` parameter was added.
    28 	 *
    33 	 * @since 5.5.0 The `$args` parameter was added.
    29 	 * @param string|null $name Name of the specific header file to use. null for the default header.
    34 	 *
    30 	 */
    35 	 * @param string|null $name Name of the specific header file to use. Null for the default header.
    31 	do_action( 'get_header', $name );
    36 	 * @param array       $args Additional arguments passed to the header template.
       
    37 	 */
       
    38 	do_action( 'get_header', $name, $args );
    32 
    39 
    33 	$templates = array();
    40 	$templates = array();
    34 	$name      = (string) $name;
    41 	$name      = (string) $name;
    35 	if ( '' !== $name ) {
    42 	if ( '' !== $name ) {
    36 		$templates[] = "header-{$name}.php";
    43 		$templates[] = "header-{$name}.php";
    37 	}
    44 	}
    38 
    45 
    39 	$templates[] = 'header.php';
    46 	$templates[] = 'header.php';
    40 
    47 
    41 	locate_template( $templates, true );
    48 	if ( ! locate_template( $templates, true, true, $args ) ) {
       
    49 		return false;
       
    50 	}
    42 }
    51 }
    43 
    52 
    44 /**
    53 /**
    45  * Load footer template.
    54  * Load footer template.
    46  *
    55  *
    49  *
    58  *
    50  * For the parameter, if the file is called "footer-special.php" then specify
    59  * For the parameter, if the file is called "footer-special.php" then specify
    51  * "special".
    60  * "special".
    52  *
    61  *
    53  * @since 1.5.0
    62  * @since 1.5.0
       
    63  * @since 5.5.0 A return value was added.
       
    64  * @since 5.5.0 The `$args` parameter was added.
    54  *
    65  *
    55  * @param string $name The name of the specialised footer.
    66  * @param string $name The name of the specialised footer.
    56  */
    67  * @param array  $args Optional. Additional arguments passed to the footer template.
    57 function get_footer( $name = null ) {
    68  *                     Default empty array.
       
    69  * @return void|false Void on success, false if the template does not exist.
       
    70  */
       
    71 function get_footer( $name = null, $args = array() ) {
    58 	/**
    72 	/**
    59 	 * Fires before the footer template file is loaded.
    73 	 * Fires before the footer template file is loaded.
    60 	 *
    74 	 *
    61 	 * @since 2.1.0
    75 	 * @since 2.1.0
    62 	 * @since 2.8.0 $name parameter added.
    76 	 * @since 2.8.0 The `$name` parameter was added.
    63 	 *
    77 	 * @since 5.5.0 The `$args` parameter was added.
    64 	 * @param string|null $name Name of the specific footer file to use. null for the default footer.
    78 	 *
    65 	 */
    79 	 * @param string|null $name Name of the specific footer file to use. Null for the default footer.
    66 	do_action( 'get_footer', $name );
    80 	 * @param array       $args Additional arguments passed to the footer template.
       
    81 	 */
       
    82 	do_action( 'get_footer', $name, $args );
    67 
    83 
    68 	$templates = array();
    84 	$templates = array();
    69 	$name      = (string) $name;
    85 	$name      = (string) $name;
    70 	if ( '' !== $name ) {
    86 	if ( '' !== $name ) {
    71 		$templates[] = "footer-{$name}.php";
    87 		$templates[] = "footer-{$name}.php";
    72 	}
    88 	}
    73 
    89 
    74 	$templates[] = 'footer.php';
    90 	$templates[] = 'footer.php';
    75 
    91 
    76 	locate_template( $templates, true );
    92 	if ( ! locate_template( $templates, true, true, $args ) ) {
       
    93 		return false;
       
    94 	}
    77 }
    95 }
    78 
    96 
    79 /**
    97 /**
    80  * Load sidebar template.
    98  * Load sidebar template.
    81  *
    99  *
    84  *
   102  *
    85  * For the parameter, if the file is called "sidebar-special.php" then specify
   103  * For the parameter, if the file is called "sidebar-special.php" then specify
    86  * "special".
   104  * "special".
    87  *
   105  *
    88  * @since 1.5.0
   106  * @since 1.5.0
       
   107  * @since 5.5.0 A return value was added.
       
   108  * @since 5.5.0 The `$args` parameter was added.
    89  *
   109  *
    90  * @param string $name The name of the specialised sidebar.
   110  * @param string $name The name of the specialised sidebar.
    91  */
   111  * @param array  $args Optional. Additional arguments passed to the sidebar template.
    92 function get_sidebar( $name = null ) {
   112  *                     Default empty array.
       
   113  * @return void|false Void on success, false if the template does not exist.
       
   114  */
       
   115 function get_sidebar( $name = null, $args = array() ) {
    93 	/**
   116 	/**
    94 	 * Fires before the sidebar template file is loaded.
   117 	 * Fires before the sidebar template file is loaded.
    95 	 *
   118 	 *
    96 	 * @since 2.2.0
   119 	 * @since 2.2.0
    97 	 * @since 2.8.0 $name parameter added.
   120 	 * @since 2.8.0 The `$name` parameter was added.
    98 	 *
   121 	 * @since 5.5.0 The `$args` parameter was added.
    99 	 * @param string|null $name Name of the specific sidebar file to use. null for the default sidebar.
   122 	 *
   100 	 */
   123 	 * @param string|null $name Name of the specific sidebar file to use. Null for the default sidebar.
   101 	do_action( 'get_sidebar', $name );
   124 	 * @param array       $args Additional arguments passed to the sidebar template.
       
   125 	 */
       
   126 	do_action( 'get_sidebar', $name, $args );
   102 
   127 
   103 	$templates = array();
   128 	$templates = array();
   104 	$name      = (string) $name;
   129 	$name      = (string) $name;
   105 	if ( '' !== $name ) {
   130 	if ( '' !== $name ) {
   106 		$templates[] = "sidebar-{$name}.php";
   131 		$templates[] = "sidebar-{$name}.php";
   107 	}
   132 	}
   108 
   133 
   109 	$templates[] = 'sidebar.php';
   134 	$templates[] = 'sidebar.php';
   110 
   135 
   111 	locate_template( $templates, true );
   136 	if ( ! locate_template( $templates, true, true, $args ) ) {
       
   137 		return false;
       
   138 	}
   112 }
   139 }
   113 
   140 
   114 /**
   141 /**
   115  * Loads a template part into a template.
   142  * Loads a template part into a template.
   116  *
   143  *
   126  *
   153  *
   127  * For the $name parameter, if the file is called "{slug}-special.php" then specify
   154  * For the $name parameter, if the file is called "{slug}-special.php" then specify
   128  * "special".
   155  * "special".
   129  *
   156  *
   130  * @since 3.0.0
   157  * @since 3.0.0
       
   158  * @since 5.5.0 A return value was added.
       
   159  * @since 5.5.0 The `$args` parameter was added.
   131  *
   160  *
   132  * @param string $slug The slug name for the generic template.
   161  * @param string $slug The slug name for the generic template.
   133  * @param string $name The name of the specialised template.
   162  * @param string $name The name of the specialised template.
   134  */
   163  * @param array  $args Optional. Additional arguments passed to the template.
   135 function get_template_part( $slug, $name = null ) {
   164  *                     Default empty array.
       
   165  * @return void|false Void on success, false if the template does not exist.
       
   166  */
       
   167 function get_template_part( $slug, $name = null, $args = array() ) {
   136 	/**
   168 	/**
   137 	 * Fires before the specified template part file is loaded.
   169 	 * Fires before the specified template part file is loaded.
   138 	 *
   170 	 *
   139 	 * The dynamic portion of the hook name, `$slug`, refers to the slug name
   171 	 * The dynamic portion of the hook name, `$slug`, refers to the slug name
   140 	 * for the generic template part.
   172 	 * for the generic template part.
   141 	 *
   173 	 *
   142 	 * @since 3.0.0
   174 	 * @since 3.0.0
       
   175 	 * @since 5.5.0 The `$args` parameter was added.
   143 	 *
   176 	 *
   144 	 * @param string      $slug The slug name for the generic template.
   177 	 * @param string      $slug The slug name for the generic template.
   145 	 * @param string|null $name The name of the specialized template.
   178 	 * @param string|null $name The name of the specialized template.
   146 	 */
   179 	 * @param array       $args Additional arguments passed to the template.
   147 	do_action( "get_template_part_{$slug}", $slug, $name );
   180 	 */
       
   181 	do_action( "get_template_part_{$slug}", $slug, $name, $args );
   148 
   182 
   149 	$templates = array();
   183 	$templates = array();
   150 	$name      = (string) $name;
   184 	$name      = (string) $name;
   151 	if ( '' !== $name ) {
   185 	if ( '' !== $name ) {
   152 		$templates[] = "{$slug}-{$name}.php";
   186 		$templates[] = "{$slug}-{$name}.php";
   156 
   190 
   157 	/**
   191 	/**
   158 	 * Fires before a template part is loaded.
   192 	 * Fires before a template part is loaded.
   159 	 *
   193 	 *
   160 	 * @since 5.2.0
   194 	 * @since 5.2.0
       
   195 	 * @since 5.5.0 The `$args` parameter was added.
   161 	 *
   196 	 *
   162 	 * @param string   $slug      The slug name for the generic template.
   197 	 * @param string   $slug      The slug name for the generic template.
   163 	 * @param string   $name      The name of the specialized template.
   198 	 * @param string   $name      The name of the specialized template.
   164 	 * @param string[] $templates Array of template files to search for, in order.
   199 	 * @param string[] $templates Array of template files to search for, in order.
   165 	 */
   200 	 * @param array    $args      Additional arguments passed to the template.
   166 	do_action( 'get_template_part', $slug, $name, $templates );
   201 	 */
   167 
   202 	do_action( 'get_template_part', $slug, $name, $templates, $args );
   168 	locate_template( $templates, true, false );
   203 
       
   204 	if ( ! locate_template( $templates, true, false, $args ) ) {
       
   205 		return false;
       
   206 	}
   169 }
   207 }
   170 
   208 
   171 /**
   209 /**
   172  * Display search form.
   210  * Display search form.
   173  *
   211  *
   184  * {@see 'pre_get_search_form'}. This can be useful for outputting JavaScript that the
   222  * {@see 'pre_get_search_form'}. This can be useful for outputting JavaScript that the
   185  * search relies on or various formatting that applies to the beginning of the
   223  * search relies on or various formatting that applies to the beginning of the
   186  * search. To give a few examples of what it can be used for.
   224  * search. To give a few examples of what it can be used for.
   187  *
   225  *
   188  * @since 2.7.0
   226  * @since 2.7.0
   189  * @since 5.2.0 The $args array parameter was added in place of an $echo boolean flag.
   227  * @since 5.2.0 The `$args` array parameter was added in place of an `$echo` boolean flag.
   190  *
   228  *
   191  * @param array $args {
   229  * @param array $args {
   192  *     Optional. Array of display arguments.
   230  *     Optional. Array of display arguments.
   193  *
   231  *
   194  *     @type bool   $echo       Whether to echo or return the form. Default true.
   232  *     @type bool   $echo       Whether to echo or return the form. Default true.
   195  *     @type string $aria_label ARIA label for the search form. Useful to distinguish
   233  *     @type string $aria_label ARIA label for the search form. Useful to distinguish
   196  *                              multiple search forms on the same page and improve
   234  *                              multiple search forms on the same page and improve
   197  *                              accessibility. Default empty.
   235  *                              accessibility. Default empty.
   198  * }
   236  * }
   199  * @return string|void String when the $echo param is false.
   237  * @return void|string Void if 'echo' argument is true, search form HTML if 'echo' is false.
   200  */
   238  */
   201 function get_search_form( $args = array() ) {
   239 function get_search_form( $args = array() ) {
   202 	/**
   240 	/**
   203 	 * Fires before the search form is retrieved, at the start of get_search_form().
   241 	 * Fires before the search form is retrieved, at the start of get_search_form().
   204 	 *
   242 	 *
   205 	 * @since 2.7.0 as 'get_search_form' action.
   243 	 * @since 2.7.0 as 'get_search_form' action.
   206 	 * @since 3.6.0
   244 	 * @since 3.6.0
       
   245 	 * @since 5.5.0 The `$args` parameter was added.
   207 	 *
   246 	 *
   208 	 * @link https://core.trac.wordpress.org/ticket/19321
   247 	 * @link https://core.trac.wordpress.org/ticket/19321
   209 	 */
   248 	 *
   210 	do_action( 'pre_get_search_form' );
   249 	 * @param array $args The array of arguments for building the search form.
       
   250 	 */
       
   251 	do_action( 'pre_get_search_form', $args );
   211 
   252 
   212 	$echo = true;
   253 	$echo = true;
   213 
   254 
   214 	if ( ! is_array( $args ) ) {
   255 	if ( ! is_array( $args ) ) {
   215 		/*
   256 		/*
   244 
   285 
   245 	/**
   286 	/**
   246 	 * Filters the HTML format of the search form.
   287 	 * Filters the HTML format of the search form.
   247 	 *
   288 	 *
   248 	 * @since 3.6.0
   289 	 * @since 3.6.0
       
   290 	 * @since 5.5.0 The `$args` parameter was added.
   249 	 *
   291 	 *
   250 	 * @param string $format The type of markup to use in the search form.
   292 	 * @param string $format The type of markup to use in the search form.
   251 	 *                       Accepts 'html5', 'xhtml'.
   293 	 *                       Accepts 'html5', 'xhtml'.
   252 	 */
   294 	 * @param array  $args   The array of arguments for building the search form.
   253 	$format = apply_filters( 'search_form_format', $format );
   295 	 */
       
   296 	$format = apply_filters( 'search_form_format', $format, $args );
   254 
   297 
   255 	$search_form_template = locate_template( 'searchform.php' );
   298 	$search_form_template = locate_template( 'searchform.php' );
   256 	if ( '' != $search_form_template ) {
   299 
       
   300 	if ( '' !== $search_form_template ) {
   257 		ob_start();
   301 		ob_start();
   258 		require( $search_form_template );
   302 		require $search_form_template;
   259 		$form = ob_get_clean();
   303 		$form = ob_get_clean();
   260 	} else {
   304 	} else {
   261 		// Build a string containing an aria-label to use for the search form.
   305 		// Build a string containing an aria-label to use for the search form.
   262 		if ( isset( $args['aria_label'] ) && $args['aria_label'] ) {
   306 		if ( isset( $args['aria_label'] ) && $args['aria_label'] ) {
   263 			$aria_label = 'aria-label="' . esc_attr( $args['aria_label'] ) . '" ';
   307 			$aria_label = 'aria-label="' . esc_attr( $args['aria_label'] ) . '" ';
   266 			 * If there's no custom aria-label, we can set a default here. At the
   310 			 * If there's no custom aria-label, we can set a default here. At the
   267 			 * moment it's empty as there's uncertainty about what the default should be.
   311 			 * moment it's empty as there's uncertainty about what the default should be.
   268 			 */
   312 			 */
   269 			$aria_label = '';
   313 			$aria_label = '';
   270 		}
   314 		}
   271 		if ( 'html5' == $format ) {
   315 
       
   316 		if ( 'html5' === $format ) {
   272 			$form = '<form role="search" ' . $aria_label . 'method="get" class="search-form" action="' . esc_url( home_url( '/' ) ) . '">
   317 			$form = '<form role="search" ' . $aria_label . 'method="get" class="search-form" action="' . esc_url( home_url( '/' ) ) . '">
   273 				<label>
   318 				<label>
   274 					<span class="screen-reader-text">' . _x( 'Search for:', 'label' ) . '</span>
   319 					<span class="screen-reader-text">' . _x( 'Search for:', 'label' ) . '</span>
   275 					<input type="search" class="search-field" placeholder="' . esc_attr_x( 'Search &hellip;', 'placeholder' ) . '" value="' . get_search_query() . '" name="s" />
   320 					<input type="search" class="search-field" placeholder="' . esc_attr_x( 'Search &hellip;', 'placeholder' ) . '" value="' . get_search_query() . '" name="s" />
   276 				</label>
   321 				</label>
   289 
   334 
   290 	/**
   335 	/**
   291 	 * Filters the HTML output of the search form.
   336 	 * Filters the HTML output of the search form.
   292 	 *
   337 	 *
   293 	 * @since 2.7.0
   338 	 * @since 2.7.0
       
   339 	 * @since 5.5.0 The `$args` parameter was added.
   294 	 *
   340 	 *
   295 	 * @param string $form The search form HTML output.
   341 	 * @param string $form The search form HTML output.
   296 	 */
   342 	 * @param array  $args The array of arguments for building the search form.
   297 	$result = apply_filters( 'get_search_form', $form );
   343 	 */
       
   344 	$result = apply_filters( 'get_search_form', $form, $args );
   298 
   345 
   299 	if ( null === $result ) {
   346 	if ( null === $result ) {
   300 		$result = $form;
   347 		$result = $form;
   301 	}
   348 	}
   302 
   349 
   303 	if ( isset( $args['echo'] ) && $args['echo'] ) {
   350 	if ( $args['echo'] ) {
   304 		echo $result;
   351 		echo $result;
   305 	} else {
   352 	} else {
   306 		return $result;
   353 		return $result;
   307 	}
   354 	}
   308 }
   355 }
   315  *
   362  *
   316  * @since 1.5.0
   363  * @since 1.5.0
   317  *
   364  *
   318  * @param string $redirect Optional path to redirect to on login/logout.
   365  * @param string $redirect Optional path to redirect to on login/logout.
   319  * @param bool   $echo     Default to echo and not return the link.
   366  * @param bool   $echo     Default to echo and not return the link.
   320  * @return string|void String when retrieving.
   367  * @return void|string Void if `$echo` argument is true, log in/out link if `$echo` is false.
   321  */
   368  */
   322 function wp_loginout( $redirect = '', $echo = true ) {
   369 function wp_loginout( $redirect = '', $echo = true ) {
   323 	if ( ! is_user_logged_in() ) {
   370 	if ( ! is_user_logged_in() ) {
   324 		$link = '<a href="' . esc_url( wp_login_url( $redirect ) ) . '">' . __( 'Log in' ) . '</a>';
   371 		$link = '<a href="' . esc_url( wp_login_url( $redirect ) ) . '">' . __( 'Log in' ) . '</a>';
   325 	} else {
   372 	} else {
   350  *
   397  *
   351  * @param string $redirect Path to redirect to on logout.
   398  * @param string $redirect Path to redirect to on logout.
   352  * @return string The logout URL. Note: HTML-encoded via esc_html() in wp_nonce_url().
   399  * @return string The logout URL. Note: HTML-encoded via esc_html() in wp_nonce_url().
   353  */
   400  */
   354 function wp_logout_url( $redirect = '' ) {
   401 function wp_logout_url( $redirect = '' ) {
   355 	$args = array( 'action' => 'logout' );
   402 	$args = array();
   356 	if ( ! empty( $redirect ) ) {
   403 	if ( ! empty( $redirect ) ) {
   357 		$args['redirect_to'] = urlencode( $redirect );
   404 		$args['redirect_to'] = urlencode( $redirect );
   358 	}
   405 	}
   359 
   406 
   360 	$logout_url = add_query_arg( $args, site_url( 'wp-login.php', 'login' ) );
   407 	$logout_url = add_query_arg( $args, site_url( 'wp-login.php?action=logout', 'login' ) );
   361 	$logout_url = wp_nonce_url( $logout_url, 'log-out' );
   408 	$logout_url = wp_nonce_url( $logout_url, 'log-out' );
   362 
   409 
   363 	/**
   410 	/**
   364 	 * Filters the logout URL.
   411 	 * Filters the logout URL.
   365 	 *
   412 	 *
   424 }
   471 }
   425 
   472 
   426 /**
   473 /**
   427  * Provides a simple login form for use anywhere within WordPress.
   474  * Provides a simple login form for use anywhere within WordPress.
   428  *
   475  *
   429  * The login format HTML is echoed by default. Pass a false value for `$echo` to return it instead.
   476  * The login form HTML is echoed by default. Pass a false value for `$echo` to return it instead.
   430  *
   477  *
   431  * @since 3.0.0
   478  * @since 3.0.0
   432  *
   479  *
   433  * @param array $args {
   480  * @param array $args {
   434  *     Optional. Array of options to control the form output. Default empty array.
   481  *     Optional. Array of options to control the form output. Default empty array.
   450  *     @type string $value_username Default value for the username field. Default empty.
   497  *     @type string $value_username Default value for the username field. Default empty.
   451  *     @type bool   $value_remember Whether the "Remember Me" checkbox should be checked by default.
   498  *     @type bool   $value_remember Whether the "Remember Me" checkbox should be checked by default.
   452  *                                  Default false (unchecked).
   499  *                                  Default false (unchecked).
   453  *
   500  *
   454  * }
   501  * }
   455  * @return string|void String when retrieving.
   502  * @return void|string Void if 'echo' argument is true, login form HTML if 'echo' is false.
   456  */
   503  */
   457 function wp_login_form( $args = array() ) {
   504 function wp_login_form( $args = array() ) {
   458 	$defaults = array(
   505 	$defaults = array(
   459 		'echo'           => true,
   506 		'echo'           => true,
   460 		// Default 'redirect' value takes the user back to the request URI.
   507 		// Default 'redirect' value takes the user back to the request URI.
   556  *
   603  *
   557  * @param string $redirect Path to redirect to on login.
   604  * @param string $redirect Path to redirect to on login.
   558  * @return string Lost password URL.
   605  * @return string Lost password URL.
   559  */
   606  */
   560 function wp_lostpassword_url( $redirect = '' ) {
   607 function wp_lostpassword_url( $redirect = '' ) {
   561 	$args = array( 'action' => 'lostpassword' );
   608 	$args = array(
       
   609 		'action' => 'lostpassword',
       
   610 	);
       
   611 
   562 	if ( ! empty( $redirect ) ) {
   612 	if ( ! empty( $redirect ) ) {
   563 		$args['redirect_to'] = urlencode( $redirect );
   613 		$args['redirect_to'] = urlencode( $redirect );
   564 	}
   614 	}
   565 
   615 
   566 	$lostpassword_url = add_query_arg( $args, network_site_url( 'wp-login.php', 'login' ) );
   616 	if ( is_multisite() ) {
       
   617 		$blog_details  = get_blog_details();
       
   618 		$wp_login_path = $blog_details->path . 'wp-login.php';
       
   619 	} else {
       
   620 		$wp_login_path = 'wp-login.php';
       
   621 	}
       
   622 
       
   623 	$lostpassword_url = add_query_arg( $args, network_site_url( $wp_login_path, 'login' ) );
   567 
   624 
   568 	/**
   625 	/**
   569 	 * Filters the Lost Password URL.
   626 	 * Filters the Lost Password URL.
   570 	 *
   627 	 *
   571 	 * @since 2.8.0
   628 	 * @since 2.8.0
   585  * @since 1.5.0
   642  * @since 1.5.0
   586  *
   643  *
   587  * @param string $before Text to output before the link. Default `<li>`.
   644  * @param string $before Text to output before the link. Default `<li>`.
   588  * @param string $after  Text to output after the link. Default `</li>`.
   645  * @param string $after  Text to output after the link. Default `</li>`.
   589  * @param bool   $echo   Default to echo and not return the link.
   646  * @param bool   $echo   Default to echo and not return the link.
   590  * @return string|void String when retrieving.
   647  * @return void|string Void if `$echo` argument is true, registration or admin link
       
   648  *                     if `$echo` is false.
   591  */
   649  */
   592 function wp_register( $before = '<li>', $after = '</li>', $echo = true ) {
   650 function wp_register( $before = '<li>', $after = '</li>', $echo = true ) {
   593 	if ( ! is_user_logged_in() ) {
   651 	if ( ! is_user_logged_in() ) {
   594 		if ( get_option( 'users_can_register' ) ) {
   652 		if ( get_option( 'users_can_register' ) ) {
   595 			$link = $before . '<a href="' . esc_url( wp_registration_url() ) . '">' . __( 'Register' ) . '</a>' . $after;
   653 			$link = $before . '<a href="' . esc_url( wp_registration_url() ) . '">' . __( 'Register' ) . '</a>' . $after;
   692  * - 'siteurl' - Use 'url' instead
   750  * - 'siteurl' - Use 'url' instead
   693  * - 'home' - Use 'url' instead
   751  * - 'home' - Use 'url' instead
   694  *
   752  *
   695  * @since 0.71
   753  * @since 0.71
   696  *
   754  *
   697  * @global string $wp_version
   755  * @global string $wp_version The WordPress version string.
   698  *
   756  *
   699  * @param string $show   Optional. Site info to retrieve. Default empty (site name).
   757  * @param string $show   Optional. Site info to retrieve. Default empty (site name).
   700  * @param string $filter Optional. How to filter what is retrieved. Default 'raw'.
   758  * @param string $filter Optional. How to filter what is retrieved. Default 'raw'.
   701  * @return string Mostly string values, might be empty.
   759  * @return string Mostly string values, might be empty.
   702  */
   760  */
   703 function get_bloginfo( $show = '', $filter = 'raw' ) {
   761 function get_bloginfo( $show = '', $filter = 'raw' ) {
   704 	switch ( $show ) {
   762 	switch ( $show ) {
   705 		case 'home': // DEPRECATED
   763 		case 'home':    // Deprecated.
   706 		case 'siteurl': // DEPRECATED
   764 		case 'siteurl': // Deprecated.
   707 			_deprecated_argument(
   765 			_deprecated_argument(
   708 				__FUNCTION__,
   766 				__FUNCTION__,
   709 				'2.2.0',
   767 				'2.2.0',
   710 				sprintf(
   768 				sprintf(
   711 					/* translators: 1: 'siteurl'/'home' argument, 2: bloginfo() function name, 3: 'url' argument */
   769 					/* translators: 1: 'siteurl'/'home' argument, 2: bloginfo() function name, 3: 'url' argument. */
   712 					__( 'The %1$s option is deprecated for the family of %2$s functions. Use the %3$s option instead.' ),
   770 					__( 'The %1$s option is deprecated for the family of %2$s functions. Use the %3$s option instead.' ),
   713 					'<code>' . $show . '</code>',
   771 					'<code>' . $show . '</code>',
   714 					'<code>bloginfo()</code>',
   772 					'<code>bloginfo()</code>',
   715 					'<code>url</code>'
   773 					'<code>url</code>'
   716 				)
   774 				)
   759 		case 'admin_email':
   817 		case 'admin_email':
   760 			$output = get_option( 'admin_email' );
   818 			$output = get_option( 'admin_email' );
   761 			break;
   819 			break;
   762 		case 'charset':
   820 		case 'charset':
   763 			$output = get_option( 'blog_charset' );
   821 			$output = get_option( 'blog_charset' );
   764 			if ( '' == $output ) {
   822 			if ( '' === $output ) {
   765 				$output = 'UTF-8';
   823 				$output = 'UTF-8';
   766 			}
   824 			}
   767 			break;
   825 			break;
   768 		case 'html_type':
   826 		case 'html_type':
   769 			$output = get_option( 'html_type' );
   827 			$output = get_option( 'html_type' );
   771 		case 'version':
   829 		case 'version':
   772 			global $wp_version;
   830 			global $wp_version;
   773 			$output = $wp_version;
   831 			$output = $wp_version;
   774 			break;
   832 			break;
   775 		case 'language':
   833 		case 'language':
   776 			/* translators: Translate this to the correct language tag for your locale,
   834 			/*
       
   835 			 * translators: Translate this to the correct language tag for your locale,
   777 			 * see https://www.w3.org/International/articles/language-tags/ for reference.
   836 			 * see https://www.w3.org/International/articles/language-tags/ for reference.
   778 			 * Do not translate into your own language.
   837 			 * Do not translate into your own language.
   779 			 */
   838 			 */
   780 			$output = __( 'html_lang_attribute' );
   839 			$output = __( 'html_lang_attribute' );
   781 			if ( 'html_lang_attribute' === $output || preg_match( '/[^a-zA-Z0-9-]/', $output ) ) {
   840 			if ( 'html_lang_attribute' === $output || preg_match( '/[^a-zA-Z0-9-]/', $output ) ) {
   786 		case 'text_direction':
   845 		case 'text_direction':
   787 			_deprecated_argument(
   846 			_deprecated_argument(
   788 				__FUNCTION__,
   847 				__FUNCTION__,
   789 				'2.2.0',
   848 				'2.2.0',
   790 				sprintf(
   849 				sprintf(
   791 					/* translators: 1: 'text_direction' argument, 2: bloginfo() function name, 3: is_rtl() function name */
   850 					/* translators: 1: 'text_direction' argument, 2: bloginfo() function name, 3: is_rtl() function name. */
   792 					__( 'The %1$s option is deprecated for the family of %2$s functions. Use the %3$s function instead.' ),
   851 					__( 'The %1$s option is deprecated for the family of %2$s functions. Use the %3$s function instead.' ),
   793 					'<code>' . $show . '</code>',
   852 					'<code>' . $show . '</code>',
   794 					'<code>bloginfo()</code>',
   853 					'<code>bloginfo()</code>',
   795 					'<code>is_rtl()</code>'
   854 					'<code>is_rtl()</code>'
   796 				)
   855 				)
   812 		strpos( $show, 'directory' ) === false &&
   871 		strpos( $show, 'directory' ) === false &&
   813 		strpos( $show, 'home' ) === false ) {
   872 		strpos( $show, 'home' ) === false ) {
   814 		$url = false;
   873 		$url = false;
   815 	}
   874 	}
   816 
   875 
   817 	if ( 'display' == $filter ) {
   876 	if ( 'display' === $filter ) {
   818 		if ( $url ) {
   877 		if ( $url ) {
   819 			/**
   878 			/**
   820 			 * Filters the URL returned by get_bloginfo().
   879 			 * Filters the URL returned by get_bloginfo().
   821 			 *
   880 			 *
   822 			 * @since 2.0.5
   881 			 * @since 2.0.5
   823 			 *
   882 			 *
   824 			 * @param mixed $output The URL returned by bloginfo().
   883 			 * @param string $output The URL returned by bloginfo().
   825 			 * @param mixed $show   Type of information requested.
   884 			 * @param string $show   Type of information requested.
   826 			 */
   885 			 */
   827 			$output = apply_filters( 'bloginfo_url', $output, $show );
   886 			$output = apply_filters( 'bloginfo_url', $output, $show );
   828 		} else {
   887 		} else {
   829 			/**
   888 			/**
   830 			 * Filters the site information returned by get_bloginfo().
   889 			 * Filters the site information returned by get_bloginfo().
   831 			 *
   890 			 *
   832 			 * @since 0.71
   891 			 * @since 0.71
   833 			 *
   892 			 *
   834 			 * @param mixed $output The requested non-URL site information.
   893 			 * @param mixed  $output The requested non-URL site information.
   835 			 * @param mixed $show   Type of information requested.
   894 			 * @param string $show   Type of information requested.
   836 			 */
   895 			 */
   837 			$output = apply_filters( 'bloginfo', $output, $show );
   896 			$output = apply_filters( 'bloginfo', $output, $show );
   838 		}
   897 		}
   839 	}
   898 	}
   840 
   899 
   852  * @return string Site Icon URL.
   911  * @return string Site Icon URL.
   853  */
   912  */
   854 function get_site_icon_url( $size = 512, $url = '', $blog_id = 0 ) {
   913 function get_site_icon_url( $size = 512, $url = '', $blog_id = 0 ) {
   855 	$switched_blog = false;
   914 	$switched_blog = false;
   856 
   915 
   857 	if ( is_multisite() && ! empty( $blog_id ) && (int) $blog_id !== get_current_blog_id() ) {
   916 	if ( is_multisite() && ! empty( $blog_id ) && get_current_blog_id() !== (int) $blog_id ) {
   858 		switch_to_blog( $blog_id );
   917 		switch_to_blog( $blog_id );
   859 		$switched_blog = true;
   918 		$switched_blog = true;
   860 	}
   919 	}
   861 
   920 
   862 	$site_icon_id = get_option( 'site_icon' );
   921 	$site_icon_id = get_option( 'site_icon' );
   920  * @return bool Whether the site has a custom logo or not.
   979  * @return bool Whether the site has a custom logo or not.
   921  */
   980  */
   922 function has_custom_logo( $blog_id = 0 ) {
   981 function has_custom_logo( $blog_id = 0 ) {
   923 	$switched_blog = false;
   982 	$switched_blog = false;
   924 
   983 
   925 	if ( is_multisite() && ! empty( $blog_id ) && (int) $blog_id !== get_current_blog_id() ) {
   984 	if ( is_multisite() && ! empty( $blog_id ) && get_current_blog_id() !== (int) $blog_id ) {
   926 		switch_to_blog( $blog_id );
   985 		switch_to_blog( $blog_id );
   927 		$switched_blog = true;
   986 		$switched_blog = true;
   928 	}
   987 	}
   929 
   988 
   930 	$custom_logo_id = get_theme_mod( 'custom_logo' );
   989 	$custom_logo_id = get_theme_mod( 'custom_logo' );
   935 
   994 
   936 	return (bool) $custom_logo_id;
   995 	return (bool) $custom_logo_id;
   937 }
   996 }
   938 
   997 
   939 /**
   998 /**
   940  * Returns a custom logo, linked to home.
   999  * Returns a custom logo, linked to home unless the theme supports removing the link on the home page.
   941  *
  1000  *
   942  * @since 4.5.0
  1001  * @since 4.5.0
       
  1002  * @since 5.5.0 Added option to remove the link on the home page with `unlink-homepage-logo` theme support.
       
  1003  * @since 5.5.1 Disabled lazy-loading by default.
   943  *
  1004  *
   944  * @param int $blog_id Optional. ID of the blog in question. Default is the ID of the current blog.
  1005  * @param int $blog_id Optional. ID of the blog in question. Default is the ID of the current blog.
   945  * @return string Custom logo markup.
  1006  * @return string Custom logo markup.
   946  */
  1007  */
   947 function get_custom_logo( $blog_id = 0 ) {
  1008 function get_custom_logo( $blog_id = 0 ) {
   948 	$html          = '';
  1009 	$html          = '';
   949 	$switched_blog = false;
  1010 	$switched_blog = false;
   950 
  1011 
   951 	if ( is_multisite() && ! empty( $blog_id ) && (int) $blog_id !== get_current_blog_id() ) {
  1012 	if ( is_multisite() && ! empty( $blog_id ) && get_current_blog_id() !== (int) $blog_id ) {
   952 		switch_to_blog( $blog_id );
  1013 		switch_to_blog( $blog_id );
   953 		$switched_blog = true;
  1014 		$switched_blog = true;
   954 	}
  1015 	}
   955 
  1016 
   956 	$custom_logo_id = get_theme_mod( 'custom_logo' );
  1017 	$custom_logo_id = get_theme_mod( 'custom_logo' );
   957 
  1018 
   958 	// We have a logo. Logo is go.
  1019 	// We have a logo. Logo is go.
   959 	if ( $custom_logo_id ) {
  1020 	if ( $custom_logo_id ) {
   960 		$custom_logo_attr = array(
  1021 		$custom_logo_attr = array(
   961 			'class' => 'custom-logo',
  1022 			'class'   => 'custom-logo',
       
  1023 			'loading' => false,
   962 		);
  1024 		);
   963 
  1025 
       
  1026 		$unlink_homepage_logo = (bool) get_theme_support( 'custom-logo', 'unlink-homepage-logo' );
       
  1027 
       
  1028 		if ( $unlink_homepage_logo && is_front_page() && ! is_paged() ) {
       
  1029 			/*
       
  1030 			 * If on the home page, set the logo alt attribute to an empty string,
       
  1031 			 * as the image is decorative and doesn't need its purpose to be described.
       
  1032 			 */
       
  1033 			$custom_logo_attr['alt'] = '';
       
  1034 		} else {
       
  1035 			/*
       
  1036 			 * If the logo alt attribute is empty, get the site title and explicitly pass it
       
  1037 			 * to the attributes used by wp_get_attachment_image().
       
  1038 			 */
       
  1039 			$image_alt = get_post_meta( $custom_logo_id, '_wp_attachment_image_alt', true );
       
  1040 			if ( empty( $image_alt ) ) {
       
  1041 				$custom_logo_attr['alt'] = get_bloginfo( 'name', 'display' );
       
  1042 			}
       
  1043 		}
       
  1044 
       
  1045 		/**
       
  1046 		 * Filters the list of custom logo image attributes.
       
  1047 		 *
       
  1048 		 * @since 5.5.0
       
  1049 		 *
       
  1050 		 * @param array $custom_logo_attr Custom logo image attributes.
       
  1051 		 * @param int   $custom_logo_id   Custom logo attachment ID.
       
  1052 		 * @param int   $blog_id          ID of the blog to get the custom logo for.
       
  1053 		 */
       
  1054 		$custom_logo_attr = apply_filters( 'get_custom_logo_image_attributes', $custom_logo_attr, $custom_logo_id, $blog_id );
       
  1055 
   964 		/*
  1056 		/*
   965 		 * If the logo alt attribute is empty, get the site title and explicitly
  1057 		 * If the alt attribute is not empty, there's no need to explicitly pass it
   966 		 * pass it to the attributes used by wp_get_attachment_image().
  1058 		 * because wp_get_attachment_image() already adds the alt attribute.
   967 		 */
  1059 		 */
   968 		$image_alt = get_post_meta( $custom_logo_id, '_wp_attachment_image_alt', true );
  1060 		$image = wp_get_attachment_image( $custom_logo_id, 'full', false, $custom_logo_attr );
   969 		if ( empty( $image_alt ) ) {
  1061 
   970 			$custom_logo_attr['alt'] = get_bloginfo( 'name', 'display' );
  1062 		if ( $unlink_homepage_logo && is_front_page() && ! is_paged() ) {
   971 		}
  1063 			// If on the home page, don't link the logo to home.
   972 
  1064 			$html = sprintf(
   973 		/*
  1065 				'<span class="custom-logo-link">%1$s</span>',
   974 		 * If the alt attribute is not empty, there's no need to explicitly pass
  1066 				$image
   975 		 * it because wp_get_attachment_image() already adds the alt attribute.
  1067 			);
   976 		 */
  1068 		} else {
   977 		$html = sprintf(
  1069 			$aria_current = is_front_page() && ! is_paged() ? ' aria-current="page"' : '';
   978 			'<a href="%1$s" class="custom-logo-link" rel="home">%2$s</a>',
  1070 
   979 			esc_url( home_url( '/' ) ),
  1071 			$html = sprintf(
   980 			wp_get_attachment_image( $custom_logo_id, 'full', false, $custom_logo_attr )
  1072 				'<a href="%1$s" class="custom-logo-link" rel="home"%2$s>%3$s</a>',
   981 		);
  1073 				esc_url( home_url( '/' ) ),
       
  1074 				$aria_current,
       
  1075 				$image
       
  1076 			);
       
  1077 		}
   982 	} elseif ( is_customize_preview() ) {
  1078 	} elseif ( is_customize_preview() ) {
   983 		// If no logo is set but we're in the Customizer, leave a placeholder (needed for the live preview).
  1079 		// If no logo is set but we're in the Customizer, leave a placeholder (needed for the live preview).
   984 		$html = sprintf(
  1080 		$html = sprintf(
   985 			'<a href="%1$s" class="custom-logo-link" style="display:none;"><img class="custom-logo"/></a>',
  1081 			'<a href="%1$s" class="custom-logo-link" style="display:none;"><img class="custom-logo"/></a>',
   986 			esc_url( home_url( '/' ) )
  1082 			esc_url( home_url( '/' ) )
  1002 	 */
  1098 	 */
  1003 	return apply_filters( 'get_custom_logo', $html, $blog_id );
  1099 	return apply_filters( 'get_custom_logo', $html, $blog_id );
  1004 }
  1100 }
  1005 
  1101 
  1006 /**
  1102 /**
  1007  * Displays a custom logo, linked to home.
  1103  * Displays a custom logo, linked to home unless the theme supports removing the link on the home page.
  1008  *
  1104  *
  1009  * @since 4.5.0
  1105  * @since 4.5.0
  1010  *
  1106  *
  1011  * @param int $blog_id Optional. ID of the blog in question. Default is the ID of the current blog.
  1107  * @param int $blog_id Optional. ID of the blog in question. Default is the ID of the current blog.
  1012  */
  1108  */
  1051 	if ( is_404() ) {
  1147 	if ( is_404() ) {
  1052 		$title['title'] = __( 'Page not found' );
  1148 		$title['title'] = __( 'Page not found' );
  1053 
  1149 
  1054 		// If it's a search, use a dynamic search results title.
  1150 		// If it's a search, use a dynamic search results title.
  1055 	} elseif ( is_search() ) {
  1151 	} elseif ( is_search() ) {
  1056 		/* translators: %s: search phrase */
  1152 		/* translators: %s: Search query. */
  1057 		$title['title'] = sprintf( __( 'Search Results for &#8220;%s&#8221;' ), get_search_query() );
  1153 		$title['title'] = sprintf( __( 'Search Results for &#8220;%s&#8221;' ), get_search_query() );
  1058 
  1154 
  1059 		// If on the front page, use the site title.
  1155 		// If on the front page, use the site title.
  1060 	} elseif ( is_front_page() ) {
  1156 	} elseif ( is_front_page() ) {
  1061 		$title['title'] = get_bloginfo( 'name', 'display' );
  1157 		$title['title'] = get_bloginfo( 'name', 'display' );
  1067 		// If on a taxonomy archive, use the term title.
  1163 		// If on a taxonomy archive, use the term title.
  1068 	} elseif ( is_tax() ) {
  1164 	} elseif ( is_tax() ) {
  1069 		$title['title'] = single_term_title( '', false );
  1165 		$title['title'] = single_term_title( '', false );
  1070 
  1166 
  1071 		/*
  1167 		/*
  1072 		* If we're on the blog page that is not the homepage or
  1168 		* If we're on the blog page that is not the homepage
  1073 		* a single post of any post type, use the post title.
  1169 		* or a single post of any post type, use the post title.
  1074 		*/
  1170 		*/
  1075 	} elseif ( is_home() || is_singular() ) {
  1171 	} elseif ( is_home() || is_singular() ) {
  1076 		$title['title'] = single_post_title( '', false );
  1172 		$title['title'] = single_post_title( '', false );
  1077 
  1173 
  1078 		// If on a category or tag archive, use the term title.
  1174 		// If on a category or tag archive, use the term title.
  1079 	} elseif ( is_category() || is_tag() ) {
  1175 	} elseif ( is_category() || is_tag() ) {
  1080 		$title['title'] = single_term_title( '', false );
  1176 		$title['title'] = single_term_title( '', false );
  1081 
  1177 
  1082 		// If on an author archive, use the author's display name.
  1178 		// If on an author archive, use the author's display name.
  1083 	} elseif ( is_author() && $author = get_queried_object() ) {
  1179 	} elseif ( is_author() && get_queried_object() ) {
       
  1180 		$author         = get_queried_object();
  1084 		$title['title'] = $author->display_name;
  1181 		$title['title'] = $author->display_name;
  1085 
  1182 
  1086 		// If it's a date archive, use the date as the title.
  1183 		// If it's a date archive, use the date as the title.
  1087 	} elseif ( is_year() ) {
  1184 	} elseif ( is_year() ) {
  1088 		$title['title'] = get_the_date( _x( 'Y', 'yearly archives date format' ) );
  1185 		$title['title'] = get_the_date( _x( 'Y', 'yearly archives date format' ) );
  1094 		$title['title'] = get_the_date();
  1191 		$title['title'] = get_the_date();
  1095 	}
  1192 	}
  1096 
  1193 
  1097 	// Add a page number if necessary.
  1194 	// Add a page number if necessary.
  1098 	if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) {
  1195 	if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) {
       
  1196 		/* translators: %s: Page number. */
  1099 		$title['page'] = sprintf( __( 'Page %s' ), max( $paged, $page ) );
  1197 		$title['page'] = sprintf( __( 'Page %s' ), max( $paged, $page ) );
  1100 	}
  1198 	}
  1101 
  1199 
  1102 	// Append the description or site title to give context.
  1200 	// Append the description or site title to give context.
  1103 	if ( is_front_page() ) {
  1201 	if ( is_front_page() ) {
  1171  * was introduced around 2.5.0, in case backward compatibility of themes is
  1269  * was introduced around 2.5.0, in case backward compatibility of themes is
  1172  * important.
  1270  * important.
  1173  *
  1271  *
  1174  * @since 1.0.0
  1272  * @since 1.0.0
  1175  *
  1273  *
  1176  * @global WP_Locale $wp_locale
  1274  * @global WP_Locale $wp_locale WordPress date and time locale object.
  1177  *
  1275  *
  1178  * @param string $sep         Optional, default is '&raquo;'. How to separate the various items
  1276  * @param string $sep         Optional. How to separate the various items within the page title.
  1179  *                            within the page title.
  1277  *                            Default '&raquo;'.
  1180  * @param bool   $display     Optional, default is true. Whether to display or retrieve title.
  1278  * @param bool   $display     Optional. Whether to display or retrieve title. Default true.
  1181  * @param string $seplocation Optional. Direction to display title, 'right'.
  1279  * @param string $seplocation Optional. Location of the separator ('left' or 'right').
  1182  * @return string|null String on retrieve, null when displaying.
  1280  * @return string|null String on retrieve, null when displaying.
  1183  */
  1281  */
  1184 function wp_title( $sep = '&raquo;', $display = true, $seplocation = '' ) {
  1282 function wp_title( $sep = '&raquo;', $display = true, $seplocation = '' ) {
  1185 	global $wp_locale;
  1283 	global $wp_locale;
  1186 
  1284 
  1189 	$monthnum = get_query_var( 'monthnum' );
  1287 	$monthnum = get_query_var( 'monthnum' );
  1190 	$day      = get_query_var( 'day' );
  1288 	$day      = get_query_var( 'day' );
  1191 	$search   = get_query_var( 's' );
  1289 	$search   = get_query_var( 's' );
  1192 	$title    = '';
  1290 	$title    = '';
  1193 
  1291 
  1194 	$t_sep = '%WP_TITLE_SEP%'; // Temporary separator, for accurate flipping, if necessary
  1292 	$t_sep = '%WP_TITLE_SEP%'; // Temporary separator, for accurate flipping, if necessary.
  1195 
  1293 
  1196 	// If there is a post
  1294 	// If there is a post.
  1197 	if ( is_single() || ( is_home() && ! is_front_page() ) || ( is_page() && ! is_front_page() ) ) {
  1295 	if ( is_single() || ( is_home() && ! is_front_page() ) || ( is_page() && ! is_front_page() ) ) {
  1198 		$title = single_post_title( '', false );
  1296 		$title = single_post_title( '', false );
  1199 	}
  1297 	}
  1200 
  1298 
  1201 	// If there's a post type archive
  1299 	// If there's a post type archive.
  1202 	if ( is_post_type_archive() ) {
  1300 	if ( is_post_type_archive() ) {
  1203 		$post_type = get_query_var( 'post_type' );
  1301 		$post_type = get_query_var( 'post_type' );
  1204 		if ( is_array( $post_type ) ) {
  1302 		if ( is_array( $post_type ) ) {
  1205 			$post_type = reset( $post_type );
  1303 			$post_type = reset( $post_type );
  1206 		}
  1304 		}
  1208 		if ( ! $post_type_object->has_archive ) {
  1306 		if ( ! $post_type_object->has_archive ) {
  1209 			$title = post_type_archive_title( '', false );
  1307 			$title = post_type_archive_title( '', false );
  1210 		}
  1308 		}
  1211 	}
  1309 	}
  1212 
  1310 
  1213 	// If there's a category or tag
  1311 	// If there's a category or tag.
  1214 	if ( is_category() || is_tag() ) {
  1312 	if ( is_category() || is_tag() ) {
  1215 		$title = single_term_title( '', false );
  1313 		$title = single_term_title( '', false );
  1216 	}
  1314 	}
  1217 
  1315 
  1218 	// If there's a taxonomy
  1316 	// If there's a taxonomy.
  1219 	if ( is_tax() ) {
  1317 	if ( is_tax() ) {
  1220 		$term = get_queried_object();
  1318 		$term = get_queried_object();
  1221 		if ( $term ) {
  1319 		if ( $term ) {
  1222 			$tax   = get_taxonomy( $term->taxonomy );
  1320 			$tax   = get_taxonomy( $term->taxonomy );
  1223 			$title = single_term_title( $tax->labels->name . $t_sep, false );
  1321 			$title = single_term_title( $tax->labels->name . $t_sep, false );
  1224 		}
  1322 		}
  1225 	}
  1323 	}
  1226 
  1324 
  1227 	// If there's an author
  1325 	// If there's an author.
  1228 	if ( is_author() && ! is_post_type_archive() ) {
  1326 	if ( is_author() && ! is_post_type_archive() ) {
  1229 		$author = get_queried_object();
  1327 		$author = get_queried_object();
  1230 		if ( $author ) {
  1328 		if ( $author ) {
  1231 			$title = $author->display_name;
  1329 			$title = $author->display_name;
  1232 		}
  1330 		}
  1235 	// Post type archives with has_archive should override terms.
  1333 	// Post type archives with has_archive should override terms.
  1236 	if ( is_post_type_archive() && $post_type_object->has_archive ) {
  1334 	if ( is_post_type_archive() && $post_type_object->has_archive ) {
  1237 		$title = post_type_archive_title( '', false );
  1335 		$title = post_type_archive_title( '', false );
  1238 	}
  1336 	}
  1239 
  1337 
  1240 	// If there's a month
  1338 	// If there's a month.
  1241 	if ( is_archive() && ! empty( $m ) ) {
  1339 	if ( is_archive() && ! empty( $m ) ) {
  1242 		$my_year  = substr( $m, 0, 4 );
  1340 		$my_year  = substr( $m, 0, 4 );
  1243 		$my_month = $wp_locale->get_month( substr( $m, 4, 2 ) );
  1341 		$my_month = $wp_locale->get_month( substr( $m, 4, 2 ) );
  1244 		$my_day   = intval( substr( $m, 6, 2 ) );
  1342 		$my_day   = intval( substr( $m, 6, 2 ) );
  1245 		$title    = $my_year . ( $my_month ? $t_sep . $my_month : '' ) . ( $my_day ? $t_sep . $my_day : '' );
  1343 		$title    = $my_year . ( $my_month ? $t_sep . $my_month : '' ) . ( $my_day ? $t_sep . $my_day : '' );
  1246 	}
  1344 	}
  1247 
  1345 
  1248 	// If there's a year
  1346 	// If there's a year.
  1249 	if ( is_archive() && ! empty( $year ) ) {
  1347 	if ( is_archive() && ! empty( $year ) ) {
  1250 		$title = $year;
  1348 		$title = $year;
  1251 		if ( ! empty( $monthnum ) ) {
  1349 		if ( ! empty( $monthnum ) ) {
  1252 			$title .= $t_sep . $wp_locale->get_month( $monthnum );
  1350 			$title .= $t_sep . $wp_locale->get_month( $monthnum );
  1253 		}
  1351 		}
  1254 		if ( ! empty( $day ) ) {
  1352 		if ( ! empty( $day ) ) {
  1255 			$title .= $t_sep . zeroise( $day, 2 );
  1353 			$title .= $t_sep . zeroise( $day, 2 );
  1256 		}
  1354 		}
  1257 	}
  1355 	}
  1258 
  1356 
  1259 	// If it's a search
  1357 	// If it's a search.
  1260 	if ( is_search() ) {
  1358 	if ( is_search() ) {
  1261 		/* translators: 1: separator, 2: search phrase */
  1359 		/* translators: 1: Separator, 2: Search query. */
  1262 		$title = sprintf( __( 'Search Results %1$s %2$s' ), $t_sep, strip_tags( $search ) );
  1360 		$title = sprintf( __( 'Search Results %1$s %2$s' ), $t_sep, strip_tags( $search ) );
  1263 	}
  1361 	}
  1264 
  1362 
  1265 	// If it's a 404 page
  1363 	// If it's a 404 page.
  1266 	if ( is_404() ) {
  1364 	if ( is_404() ) {
  1267 		$title = __( 'Page not found' );
  1365 		$title = __( 'Page not found' );
  1268 	}
  1366 	}
  1269 
  1367 
  1270 	$prefix = '';
  1368 	$prefix = '';
  1275 	/**
  1373 	/**
  1276 	 * Filters the parts of the page title.
  1374 	 * Filters the parts of the page title.
  1277 	 *
  1375 	 *
  1278 	 * @since 4.0.0
  1376 	 * @since 4.0.0
  1279 	 *
  1377 	 *
  1280 	 * @param array $title_array Parts of the page title.
  1378 	 * @param string[] $title_array Array of parts of the page title.
  1281 	 */
  1379 	 */
  1282 	$title_array = apply_filters( 'wp_title_parts', explode( $t_sep, $title ) );
  1380 	$title_array = apply_filters( 'wp_title_parts', explode( $t_sep, $title ) );
  1283 
  1381 
  1284 	// Determines position of the separator and direction of the breadcrumb
  1382 	// Determines position of the separator and direction of the breadcrumb.
  1285 	if ( 'right' == $seplocation ) { // sep on right, so reverse the order
  1383 	if ( 'right' === $seplocation ) { // Separator on right, so reverse the order.
  1286 		$title_array = array_reverse( $title_array );
  1384 		$title_array = array_reverse( $title_array );
  1287 		$title       = implode( " $sep ", $title_array ) . $prefix;
  1385 		$title       = implode( " $sep ", $title_array ) . $prefix;
  1288 	} else {
  1386 	} else {
  1289 		$title = $prefix . implode( " $sep ", $title_array );
  1387 		$title = $prefix . implode( " $sep ", $title_array );
  1290 	}
  1388 	}
  1292 	/**
  1390 	/**
  1293 	 * Filters the text of the page title.
  1391 	 * Filters the text of the page title.
  1294 	 *
  1392 	 *
  1295 	 * @since 2.0.0
  1393 	 * @since 2.0.0
  1296 	 *
  1394 	 *
  1297 	 * @param string $title Page title.
  1395 	 * @param string $title       Page title.
  1298 	 * @param string $sep Title separator.
  1396 	 * @param string $sep         Title separator.
  1299 	 * @param string $seplocation Location of the separator (left or right).
  1397 	 * @param string $seplocation Location of the separator ('left' or 'right').
  1300 	 */
  1398 	 */
  1301 	$title = apply_filters( 'wp_title', $title, $sep, $seplocation );
  1399 	$title = apply_filters( 'wp_title', $title, $sep, $seplocation );
  1302 
  1400 
  1303 	// Send it out
  1401 	// Send it out.
  1304 	if ( $display ) {
  1402 	if ( $display ) {
  1305 		echo $title;
  1403 		echo $title;
  1306 	} else {
  1404 	} else {
  1307 		return $title;
  1405 		return $title;
  1308 	}
  1406 	}
  1319  * be a space, the parameter value will need to have it at the end.
  1417  * be a space, the parameter value will need to have it at the end.
  1320  *
  1418  *
  1321  * @since 0.71
  1419  * @since 0.71
  1322  *
  1420  *
  1323  * @param string $prefix  Optional. What to display before the title.
  1421  * @param string $prefix  Optional. What to display before the title.
  1324  * @param bool   $display Optional, default is true. Whether to display or retrieve title.
  1422  * @param bool   $display Optional. Whether to display or retrieve title. Default true.
  1325  * @return string|void Title when retrieving.
  1423  * @return string|void Title when retrieving.
  1326  */
  1424  */
  1327 function single_post_title( $prefix = '', $display = true ) {
  1425 function single_post_title( $prefix = '', $display = true ) {
  1328 	$_post = get_queried_object();
  1426 	$_post = get_queried_object();
  1329 
  1427 
  1334 	/**
  1432 	/**
  1335 	 * Filters the page title for a single post.
  1433 	 * Filters the page title for a single post.
  1336 	 *
  1434 	 *
  1337 	 * @since 0.71
  1435 	 * @since 0.71
  1338 	 *
  1436 	 *
  1339 	 * @param string $_post_title The single post page title.
  1437 	 * @param string  $_post_title The single post page title.
  1340 	 * @param object $_post       The current queried object as returned by get_queried_object().
  1438 	 * @param WP_Post $_post       The current post.
  1341 	 */
  1439 	 */
  1342 	$title = apply_filters( 'single_post_title', $_post->post_title, $_post );
  1440 	$title = apply_filters( 'single_post_title', $_post->post_title, $_post );
  1343 	if ( $display ) {
  1441 	if ( $display ) {
  1344 		echo $prefix . $title;
  1442 		echo $prefix . $title;
  1345 	} else {
  1443 	} else {
  1354  * for displaying the title of the post type.
  1452  * for displaying the title of the post type.
  1355  *
  1453  *
  1356  * @since 3.1.0
  1454  * @since 3.1.0
  1357  *
  1455  *
  1358  * @param string $prefix  Optional. What to display before the title.
  1456  * @param string $prefix  Optional. What to display before the title.
  1359  * @param bool   $display Optional, default is true. Whether to display or retrieve title.
  1457  * @param bool   $display Optional. Whether to display or retrieve title. Default true.
  1360  * @return string|void Title when retrieving, null when displaying or failure.
  1458  * @return string|void Title when retrieving, null when displaying or failure.
  1361  */
  1459  */
  1362 function post_type_archive_title( $prefix = '', $display = true ) {
  1460 function post_type_archive_title( $prefix = '', $display = true ) {
  1363 	if ( ! is_post_type_archive() ) {
  1461 	if ( ! is_post_type_archive() ) {
  1364 		return;
  1462 		return;
  1396  * there should be a space, the parameter value will need to have it at the end.
  1494  * there should be a space, the parameter value will need to have it at the end.
  1397  *
  1495  *
  1398  * @since 0.71
  1496  * @since 0.71
  1399  *
  1497  *
  1400  * @param string $prefix  Optional. What to display before the title.
  1498  * @param string $prefix  Optional. What to display before the title.
  1401  * @param bool   $display Optional, default is true. Whether to display or retrieve title.
  1499  * @param bool   $display Optional. Whether to display or retrieve title. Default true.
  1402  * @return string|void Title when retrieving.
  1500  * @return string|void Title when retrieving.
  1403  */
  1501  */
  1404 function single_cat_title( $prefix = '', $display = true ) {
  1502 function single_cat_title( $prefix = '', $display = true ) {
  1405 	return single_term_title( $prefix, $display );
  1503 	return single_term_title( $prefix, $display );
  1406 }
  1504 }
  1413  * be a space, the parameter value will need to have it at the end.
  1511  * be a space, the parameter value will need to have it at the end.
  1414  *
  1512  *
  1415  * @since 2.3.0
  1513  * @since 2.3.0
  1416  *
  1514  *
  1417  * @param string $prefix  Optional. What to display before the title.
  1515  * @param string $prefix  Optional. What to display before the title.
  1418  * @param bool   $display Optional, default is true. Whether to display or retrieve title.
  1516  * @param bool   $display Optional. Whether to display or retrieve title. Default true.
  1419  * @return string|void Title when retrieving.
  1517  * @return string|void Title when retrieving.
  1420  */
  1518  */
  1421 function single_tag_title( $prefix = '', $display = true ) {
  1519 function single_tag_title( $prefix = '', $display = true ) {
  1422 	return single_term_title( $prefix, $display );
  1520 	return single_term_title( $prefix, $display );
  1423 }
  1521 }
  1430  * be a space, the parameter value will need to have it at the end.
  1528  * be a space, the parameter value will need to have it at the end.
  1431  *
  1529  *
  1432  * @since 3.1.0
  1530  * @since 3.1.0
  1433  *
  1531  *
  1434  * @param string $prefix  Optional. What to display before the title.
  1532  * @param string $prefix  Optional. What to display before the title.
  1435  * @param bool   $display Optional, default is true. Whether to display or retrieve title.
  1533  * @param bool   $display Optional. Whether to display or retrieve title. Default true.
  1436  * @return string|void Title when retrieving.
  1534  * @return string|void Title when retrieving.
  1437  */
  1535  */
  1438 function single_term_title( $prefix = '', $display = true ) {
  1536 function single_term_title( $prefix = '', $display = true ) {
  1439 	$term = get_queried_object();
  1537 	$term = get_queried_object();
  1440 
  1538 
  1492  * between the prefix, so if there should be a space, the parameter value
  1590  * between the prefix, so if there should be a space, the parameter value
  1493  * will need to have it at the end.
  1591  * will need to have it at the end.
  1494  *
  1592  *
  1495  * @since 0.71
  1593  * @since 0.71
  1496  *
  1594  *
  1497  * @global WP_Locale $wp_locale
  1595  * @global WP_Locale $wp_locale WordPress date and time locale object.
  1498  *
  1596  *
  1499  * @param string $prefix  Optional. What to display before the title.
  1597  * @param string $prefix  Optional. What to display before the title.
  1500  * @param bool   $display Optional, default is true. Whether to display or retrieve title.
  1598  * @param bool   $display Optional. Whether to display or retrieve title. Default true.
  1501  * @return string|void Title when retrieving.
  1599  * @return string|void Title when retrieving.
  1502  */
  1600  */
  1503 function single_month_title( $prefix = '', $display = true ) {
  1601 function single_month_title( $prefix = '', $display = true ) {
  1504 	global $wp_locale;
  1602 	global $wp_locale;
  1505 
  1603 
  1547 
  1645 
  1548 /**
  1646 /**
  1549  * Retrieve the archive title based on the queried object.
  1647  * Retrieve the archive title based on the queried object.
  1550  *
  1648  *
  1551  * @since 4.1.0
  1649  * @since 4.1.0
       
  1650  * @since 5.5.0 The title part is wrapped in a `<span>` element.
  1552  *
  1651  *
  1553  * @return string Archive title.
  1652  * @return string Archive title.
  1554  */
  1653  */
  1555 function get_the_archive_title() {
  1654 function get_the_archive_title() {
       
  1655 	$title  = __( 'Archives' );
       
  1656 	$prefix = '';
       
  1657 
  1556 	if ( is_category() ) {
  1658 	if ( is_category() ) {
  1557 		/* translators: Category archive title. %s: Category name */
  1659 		$title  = single_cat_title( '', false );
  1558 		$title = sprintf( __( 'Category: %s' ), single_cat_title( '', false ) );
  1660 		$prefix = _x( 'Category:', 'category archive title prefix' );
  1559 	} elseif ( is_tag() ) {
  1661 	} elseif ( is_tag() ) {
  1560 		/* translators: Tag archive title. %s: Tag name */
  1662 		$title  = single_tag_title( '', false );
  1561 		$title = sprintf( __( 'Tag: %s' ), single_tag_title( '', false ) );
  1663 		$prefix = _x( 'Tag:', 'tag archive title prefix' );
  1562 	} elseif ( is_author() ) {
  1664 	} elseif ( is_author() ) {
  1563 		/* translators: Author archive title. %s: Author name */
  1665 		$title  = get_the_author();
  1564 		$title = sprintf( __( 'Author: %s' ), '<span class="vcard">' . get_the_author() . '</span>' );
  1666 		$prefix = _x( 'Author:', 'author archive title prefix' );
  1565 	} elseif ( is_year() ) {
  1667 	} elseif ( is_year() ) {
  1566 		/* translators: Yearly archive title. %s: Year */
  1668 		$title  = get_the_date( _x( 'Y', 'yearly archives date format' ) );
  1567 		$title = sprintf( __( 'Year: %s' ), get_the_date( _x( 'Y', 'yearly archives date format' ) ) );
  1669 		$prefix = _x( 'Year:', 'date archive title prefix' );
  1568 	} elseif ( is_month() ) {
  1670 	} elseif ( is_month() ) {
  1569 		/* translators: Monthly archive title. %s: Month name and year */
  1671 		$title  = get_the_date( _x( 'F Y', 'monthly archives date format' ) );
  1570 		$title = sprintf( __( 'Month: %s' ), get_the_date( _x( 'F Y', 'monthly archives date format' ) ) );
  1672 		$prefix = _x( 'Month:', 'date archive title prefix' );
  1571 	} elseif ( is_day() ) {
  1673 	} elseif ( is_day() ) {
  1572 		/* translators: Daily archive title. %s: Date */
  1674 		$title  = get_the_date( _x( 'F j, Y', 'daily archives date format' ) );
  1573 		$title = sprintf( __( 'Day: %s' ), get_the_date( _x( 'F j, Y', 'daily archives date format' ) ) );
  1675 		$prefix = _x( 'Day:', 'date archive title prefix' );
  1574 	} elseif ( is_tax( 'post_format' ) ) {
  1676 	} elseif ( is_tax( 'post_format' ) ) {
  1575 		if ( is_tax( 'post_format', 'post-format-aside' ) ) {
  1677 		if ( is_tax( 'post_format', 'post-format-aside' ) ) {
  1576 			$title = _x( 'Asides', 'post format archive title' );
  1678 			$title = _x( 'Asides', 'post format archive title' );
  1577 		} elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) {
  1679 		} elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) {
  1578 			$title = _x( 'Galleries', 'post format archive title' );
  1680 			$title = _x( 'Galleries', 'post format archive title' );
  1590 			$title = _x( 'Audio', 'post format archive title' );
  1692 			$title = _x( 'Audio', 'post format archive title' );
  1591 		} elseif ( is_tax( 'post_format', 'post-format-chat' ) ) {
  1693 		} elseif ( is_tax( 'post_format', 'post-format-chat' ) ) {
  1592 			$title = _x( 'Chats', 'post format archive title' );
  1694 			$title = _x( 'Chats', 'post format archive title' );
  1593 		}
  1695 		}
  1594 	} elseif ( is_post_type_archive() ) {
  1696 	} elseif ( is_post_type_archive() ) {
  1595 		/* translators: Post type archive title. %s: Post type name */
  1697 		$title  = post_type_archive_title( '', false );
  1596 		$title = sprintf( __( 'Archives: %s' ), post_type_archive_title( '', false ) );
  1698 		$prefix = _x( 'Archives:', 'post type archive title prefix' );
  1597 	} elseif ( is_tax() ) {
  1699 	} elseif ( is_tax() ) {
  1598 		$tax = get_taxonomy( get_queried_object()->taxonomy );
  1700 		$queried_object = get_queried_object();
  1599 		/* translators: Taxonomy term archive title. 1: Taxonomy singular name, 2: Current taxonomy term */
  1701 		if ( $queried_object ) {
  1600 		$title = sprintf( __( '%1$s: %2$s' ), $tax->labels->singular_name, single_term_title( '', false ) );
  1702 			$tax    = get_taxonomy( $queried_object->taxonomy );
  1601 	} else {
  1703 			$title  = single_term_title( '', false );
  1602 		$title = __( 'Archives' );
  1704 			$prefix = sprintf(
       
  1705 				/* translators: %s: Taxonomy singular name. */
       
  1706 				_x( '%s:', 'taxonomy term archive title prefix' ),
       
  1707 				$tax->labels->singular_name
       
  1708 			);
       
  1709 		}
       
  1710 	}
       
  1711 
       
  1712 	$original_title = $title;
       
  1713 
       
  1714 	/**
       
  1715 	 * Filters the archive title prefix.
       
  1716 	 *
       
  1717 	 * @since 5.5.0
       
  1718 	 *
       
  1719 	 * @param string $prefix Archive title prefix.
       
  1720 	 */
       
  1721 	$prefix = apply_filters( 'get_the_archive_title_prefix', $prefix );
       
  1722 	if ( $prefix ) {
       
  1723 		$title = sprintf(
       
  1724 			/* translators: 1: Title prefix. 2: Title. */
       
  1725 			_x( '%1$s %2$s', 'archive title' ),
       
  1726 			$prefix,
       
  1727 			'<span>' . $title . '</span>'
       
  1728 		);
  1603 	}
  1729 	}
  1604 
  1730 
  1605 	/**
  1731 	/**
  1606 	 * Filters the archive title.
  1732 	 * Filters the archive title.
  1607 	 *
  1733 	 *
  1608 	 * @since 4.1.0
  1734 	 * @since 4.1.0
  1609 	 *
  1735 	 * @since 5.5.0 Added the `$prefix` and `$original_title` parameters.
  1610 	 * @param string $title Archive title to be displayed.
  1736 	 *
  1611 	 */
  1737 	 * @param string $title          Archive title to be displayed.
  1612 	return apply_filters( 'get_the_archive_title', $title );
  1738 	 * @param string $original_title Archive title without prefix.
       
  1739 	 * @param string $prefix         Archive title prefix.
       
  1740 	 */
       
  1741 	return apply_filters( 'get_the_archive_title', $title, $original_title, $prefix );
  1613 }
  1742 }
  1614 
  1743 
  1615 /**
  1744 /**
  1616  * Display category, tag, term, or author description.
  1745  * Display category, tag, term, or author description.
  1617  *
  1746  *
  1720  * @since 1.0.0
  1849  * @since 1.0.0
  1721  * @since 5.2.0 Added the `$selected` parameter.
  1850  * @since 5.2.0 Added the `$selected` parameter.
  1722  *
  1851  *
  1723  * @param string $url      URL to archive.
  1852  * @param string $url      URL to archive.
  1724  * @param string $text     Archive text description.
  1853  * @param string $text     Archive text description.
  1725  * @param string $format   Optional, default is 'html'. Can be 'link', 'option', 'html', or custom.
  1854  * @param string $format   Optional. Can be 'link', 'option', 'html', or custom. Default 'html'.
  1726  * @param string $before   Optional. Content to prepend to the description. Default empty.
  1855  * @param string $before   Optional. Content to prepend to the description. Default empty.
  1727  * @param string $after    Optional. Content to append to the description. Default empty.
  1856  * @param string $after    Optional. Content to append to the description. Default empty.
  1728  * @param bool   $selected Optional. Set to true if the current page is the selected archive page.
  1857  * @param bool   $selected Optional. Set to true if the current page is the selected archive page.
  1729  * @return string HTML link content for archive.
  1858  * @return string HTML link content for archive.
  1730  */
  1859  */
  1731 function get_archives_link( $url, $text, $format = 'html', $before = '', $after = '', $selected = false ) {
  1860 function get_archives_link( $url, $text, $format = 'html', $before = '', $after = '', $selected = false ) {
  1732 	$text = wptexturize( $text );
  1861 	$text         = wptexturize( $text );
  1733 	$url  = esc_url( $url );
  1862 	$url          = esc_url( $url );
  1734 
  1863 	$aria_current = $selected ? ' aria-current="page"' : '';
  1735 	if ( 'link' == $format ) {
  1864 
       
  1865 	if ( 'link' === $format ) {
  1736 		$link_html = "\t<link rel='archives' title='" . esc_attr( $text ) . "' href='$url' />\n";
  1866 		$link_html = "\t<link rel='archives' title='" . esc_attr( $text ) . "' href='$url' />\n";
  1737 	} elseif ( 'option' == $format ) {
  1867 	} elseif ( 'option' === $format ) {
  1738 		$selected_attr = $selected ? " selected='selected'" : '';
  1868 		$selected_attr = $selected ? " selected='selected'" : '';
  1739 		$link_html     = "\t<option value='$url'$selected_attr>$before $text $after</option>\n";
  1869 		$link_html     = "\t<option value='$url'$selected_attr>$before $text $after</option>\n";
  1740 	} elseif ( 'html' == $format ) {
  1870 	} elseif ( 'html' === $format ) {
  1741 		$link_html = "\t<li>$before<a href='$url'>$text</a>$after</li>\n";
  1871 		$link_html = "\t<li>$before<a href='$url'$aria_current>$text</a>$after</li>\n";
  1742 	} else { // custom
  1872 	} else { // Custom.
  1743 		$link_html = "\t$before<a href='$url'>$text</a>$after\n";
  1873 		$link_html = "\t$before<a href='$url'$aria_current>$text</a>$after\n";
  1744 	}
  1874 	}
  1745 
  1875 
  1746 	/**
  1876 	/**
  1747 	 * Filters the archive link content.
  1877 	 * Filters the archive link content.
  1748 	 *
  1878 	 *
  1768  * @since 4.4.0 The `$post_type` argument was added.
  1898  * @since 4.4.0 The `$post_type` argument was added.
  1769  * @since 5.2.0 The `$year`, `$monthnum`, `$day`, and `$w` arguments were added.
  1899  * @since 5.2.0 The `$year`, `$monthnum`, `$day`, and `$w` arguments were added.
  1770  *
  1900  *
  1771  * @see get_archives_link()
  1901  * @see get_archives_link()
  1772  *
  1902  *
  1773  * @global wpdb      $wpdb
  1903  * @global wpdb      $wpdb      WordPress database abstraction object.
  1774  * @global WP_Locale $wp_locale
  1904  * @global WP_Locale $wp_locale WordPress date and time locale object.
  1775  *
  1905  *
  1776  * @param string|array $args {
  1906  * @param string|array $args {
  1777  *     Default archive links arguments. Optional.
  1907  *     Default archive links arguments. Optional.
  1778  *
  1908  *
  1779  *     @type string     $type            Type of archive to retrieve. Accepts 'daily', 'weekly', 'monthly',
  1909  *     @type string     $type            Type of archive to retrieve. Accepts 'daily', 'weekly', 'monthly',
  1797  *     @type string     $year            Year. Default current year.
  1927  *     @type string     $year            Year. Default current year.
  1798  *     @type string     $monthnum        Month number. Default current month number.
  1928  *     @type string     $monthnum        Month number. Default current month number.
  1799  *     @type string     $day             Day. Default current day.
  1929  *     @type string     $day             Day. Default current day.
  1800  *     @type string     $w               Week. Default current week.
  1930  *     @type string     $w               Week. Default current week.
  1801  * }
  1931  * }
  1802  * @return string|void String when retrieving.
  1932  * @return void|string Void if 'echo' argument is true, archive links if 'echo' is false.
  1803  */
  1933  */
  1804 function wp_get_archives( $args = '' ) {
  1934 function wp_get_archives( $args = '' ) {
  1805 	global $wpdb, $wp_locale;
  1935 	global $wpdb, $wp_locale;
  1806 
  1936 
  1807 	$defaults = array(
  1937 	$defaults = array(
  1818 		'monthnum'        => get_query_var( 'monthnum' ),
  1948 		'monthnum'        => get_query_var( 'monthnum' ),
  1819 		'day'             => get_query_var( 'day' ),
  1949 		'day'             => get_query_var( 'day' ),
  1820 		'w'               => get_query_var( 'w' ),
  1950 		'w'               => get_query_var( 'w' ),
  1821 	);
  1951 	);
  1822 
  1952 
  1823 	$r = wp_parse_args( $args, $defaults );
  1953 	$parsed_args = wp_parse_args( $args, $defaults );
  1824 
  1954 
  1825 	$post_type_object = get_post_type_object( $r['post_type'] );
  1955 	$post_type_object = get_post_type_object( $parsed_args['post_type'] );
  1826 	if ( ! is_post_type_viewable( $post_type_object ) ) {
  1956 	if ( ! is_post_type_viewable( $post_type_object ) ) {
  1827 		return;
  1957 		return;
  1828 	}
  1958 	}
  1829 	$r['post_type'] = $post_type_object->name;
  1959 
  1830 
  1960 	$parsed_args['post_type'] = $post_type_object->name;
  1831 	if ( '' == $r['type'] ) {
  1961 
  1832 		$r['type'] = 'monthly';
  1962 	if ( '' === $parsed_args['type'] ) {
  1833 	}
  1963 		$parsed_args['type'] = 'monthly';
  1834 
  1964 	}
  1835 	if ( ! empty( $r['limit'] ) ) {
  1965 
  1836 		$r['limit'] = absint( $r['limit'] );
  1966 	if ( ! empty( $parsed_args['limit'] ) ) {
  1837 		$r['limit'] = ' LIMIT ' . $r['limit'];
  1967 		$parsed_args['limit'] = absint( $parsed_args['limit'] );
  1838 	}
  1968 		$parsed_args['limit'] = ' LIMIT ' . $parsed_args['limit'];
  1839 
  1969 	}
  1840 	$order = strtoupper( $r['order'] );
  1970 
  1841 	if ( $order !== 'ASC' ) {
  1971 	$order = strtoupper( $parsed_args['order'] );
       
  1972 	if ( 'ASC' !== $order ) {
  1842 		$order = 'DESC';
  1973 		$order = 'DESC';
  1843 	}
  1974 	}
  1844 
  1975 
  1845 	// this is what will separate dates on weekly archive links
  1976 	// This is what will separate dates on weekly archive links.
  1846 	$archive_week_separator = '&#8211;';
  1977 	$archive_week_separator = '&#8211;';
  1847 
  1978 
  1848 	$sql_where = $wpdb->prepare( "WHERE post_type = %s AND post_status = 'publish'", $r['post_type'] );
  1979 	$sql_where = $wpdb->prepare( "WHERE post_type = %s AND post_status = 'publish'", $parsed_args['post_type'] );
  1849 
  1980 
  1850 	/**
  1981 	/**
  1851 	 * Filters the SQL WHERE clause for retrieving archives.
  1982 	 * Filters the SQL WHERE clause for retrieving archives.
  1852 	 *
  1983 	 *
  1853 	 * @since 2.2.0
  1984 	 * @since 2.2.0
  1854 	 *
  1985 	 *
  1855 	 * @param string $sql_where Portion of SQL query containing the WHERE clause.
  1986 	 * @param string $sql_where   Portion of SQL query containing the WHERE clause.
  1856 	 * @param array  $r         An array of default arguments.
  1987 	 * @param array  $parsed_args An array of default arguments.
  1857 	 */
  1988 	 */
  1858 	$where = apply_filters( 'getarchives_where', $sql_where, $r );
  1989 	$where = apply_filters( 'getarchives_where', $sql_where, $parsed_args );
  1859 
  1990 
  1860 	/**
  1991 	/**
  1861 	 * Filters the SQL JOIN clause for retrieving archives.
  1992 	 * Filters the SQL JOIN clause for retrieving archives.
  1862 	 *
  1993 	 *
  1863 	 * @since 2.2.0
  1994 	 * @since 2.2.0
  1864 	 *
  1995 	 *
  1865 	 * @param string $sql_join Portion of SQL query containing JOIN clause.
  1996 	 * @param string $sql_join    Portion of SQL query containing JOIN clause.
  1866 	 * @param array  $r        An array of default arguments.
  1997 	 * @param array  $parsed_args An array of default arguments.
  1867 	 */
  1998 	 */
  1868 	$join = apply_filters( 'getarchives_join', '', $r );
  1999 	$join = apply_filters( 'getarchives_join', '', $parsed_args );
  1869 
  2000 
  1870 	$output = '';
  2001 	$output = '';
  1871 
  2002 
  1872 	$last_changed = wp_cache_get_last_changed( 'posts' );
  2003 	$last_changed = wp_cache_get_last_changed( 'posts' );
  1873 
  2004 
  1874 	$limit = $r['limit'];
  2005 	$limit = $parsed_args['limit'];
  1875 
  2006 
  1876 	if ( 'monthly' == $r['type'] ) {
  2007 	if ( 'monthly' === $parsed_args['type'] ) {
  1877 		$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";
  2008 		$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";
  1878 		$key   = md5( $query );
  2009 		$key     = md5( $query );
  1879 		$key   = "wp_get_archives:$key:$last_changed";
  2010 		$key     = "wp_get_archives:$key:$last_changed";
  1880 		if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
  2011 		$results = wp_cache_get( $key, 'posts' );
       
  2012 		if ( ! $results ) {
  1881 			$results = $wpdb->get_results( $query );
  2013 			$results = $wpdb->get_results( $query );
  1882 			wp_cache_set( $key, $results, 'posts' );
  2014 			wp_cache_set( $key, $results, 'posts' );
  1883 		}
  2015 		}
  1884 		if ( $results ) {
  2016 		if ( $results ) {
  1885 			$after = $r['after'];
  2017 			$after = $parsed_args['after'];
  1886 			foreach ( (array) $results as $result ) {
  2018 			foreach ( (array) $results as $result ) {
  1887 				$url = get_month_link( $result->year, $result->month );
  2019 				$url = get_month_link( $result->year, $result->month );
  1888 				if ( 'post' !== $r['post_type'] ) {
  2020 				if ( 'post' !== $parsed_args['post_type'] ) {
  1889 					$url = add_query_arg( 'post_type', $r['post_type'], $url );
  2021 					$url = add_query_arg( 'post_type', $parsed_args['post_type'], $url );
  1890 				}
  2022 				}
  1891 				/* translators: 1: month name, 2: 4-digit year */
  2023 				/* translators: 1: Month name, 2: 4-digit year. */
  1892 				$text = sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $result->month ), $result->year );
  2024 				$text = sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $result->month ), $result->year );
  1893 				if ( $r['show_post_count'] ) {
  2025 				if ( $parsed_args['show_post_count'] ) {
  1894 					$r['after'] = '&nbsp;(' . $result->posts . ')' . $after;
  2026 					$parsed_args['after'] = '&nbsp;(' . $result->posts . ')' . $after;
  1895 				}
  2027 				}
  1896 				$selected = is_archive() && (string) $r['year'] === $result->year && (string) $r['monthnum'] === $result->month;
  2028 				$selected = is_archive() && (string) $parsed_args['year'] === $result->year && (string) $parsed_args['monthnum'] === $result->month;
  1897 				$output  .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'], $selected );
  2029 				$output  .= get_archives_link( $url, $text, $parsed_args['format'], $parsed_args['before'], $parsed_args['after'], $selected );
  1898 			}
  2030 			}
  1899 		}
  2031 		}
  1900 	} elseif ( 'yearly' == $r['type'] ) {
  2032 	} elseif ( 'yearly' === $parsed_args['type'] ) {
  1901 		$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";
  2033 		$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";
  1902 		$key   = md5( $query );
  2034 		$key     = md5( $query );
  1903 		$key   = "wp_get_archives:$key:$last_changed";
  2035 		$key     = "wp_get_archives:$key:$last_changed";
  1904 		if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
  2036 		$results = wp_cache_get( $key, 'posts' );
       
  2037 		if ( ! $results ) {
  1905 			$results = $wpdb->get_results( $query );
  2038 			$results = $wpdb->get_results( $query );
  1906 			wp_cache_set( $key, $results, 'posts' );
  2039 			wp_cache_set( $key, $results, 'posts' );
  1907 		}
  2040 		}
  1908 		if ( $results ) {
  2041 		if ( $results ) {
  1909 			$after = $r['after'];
  2042 			$after = $parsed_args['after'];
  1910 			foreach ( (array) $results as $result ) {
  2043 			foreach ( (array) $results as $result ) {
  1911 				$url = get_year_link( $result->year );
  2044 				$url = get_year_link( $result->year );
  1912 				if ( 'post' !== $r['post_type'] ) {
  2045 				if ( 'post' !== $parsed_args['post_type'] ) {
  1913 					$url = add_query_arg( 'post_type', $r['post_type'], $url );
  2046 					$url = add_query_arg( 'post_type', $parsed_args['post_type'], $url );
  1914 				}
  2047 				}
  1915 				$text = sprintf( '%d', $result->year );
  2048 				$text = sprintf( '%d', $result->year );
  1916 				if ( $r['show_post_count'] ) {
  2049 				if ( $parsed_args['show_post_count'] ) {
  1917 					$r['after'] = '&nbsp;(' . $result->posts . ')' . $after;
  2050 					$parsed_args['after'] = '&nbsp;(' . $result->posts . ')' . $after;
  1918 				}
  2051 				}
  1919 				$selected = is_archive() && (string) $r['year'] === $result->year;
  2052 				$selected = is_archive() && (string) $parsed_args['year'] === $result->year;
  1920 				$output  .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'], $selected );
  2053 				$output  .= get_archives_link( $url, $text, $parsed_args['format'], $parsed_args['before'], $parsed_args['after'], $selected );
  1921 			}
  2054 			}
  1922 		}
  2055 		}
  1923 	} elseif ( 'daily' == $r['type'] ) {
  2056 	} elseif ( 'daily' === $parsed_args['type'] ) {
  1924 		$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";
  2057 		$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";
  1925 		$key   = md5( $query );
  2058 		$key     = md5( $query );
  1926 		$key   = "wp_get_archives:$key:$last_changed";
  2059 		$key     = "wp_get_archives:$key:$last_changed";
  1927 		if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
  2060 		$results = wp_cache_get( $key, 'posts' );
       
  2061 		if ( ! $results ) {
  1928 			$results = $wpdb->get_results( $query );
  2062 			$results = $wpdb->get_results( $query );
  1929 			wp_cache_set( $key, $results, 'posts' );
  2063 			wp_cache_set( $key, $results, 'posts' );
  1930 		}
  2064 		}
  1931 		if ( $results ) {
  2065 		if ( $results ) {
  1932 			$after = $r['after'];
  2066 			$after = $parsed_args['after'];
  1933 			foreach ( (array) $results as $result ) {
  2067 			foreach ( (array) $results as $result ) {
  1934 				$url = get_day_link( $result->year, $result->month, $result->dayofmonth );
  2068 				$url = get_day_link( $result->year, $result->month, $result->dayofmonth );
  1935 				if ( 'post' !== $r['post_type'] ) {
  2069 				if ( 'post' !== $parsed_args['post_type'] ) {
  1936 					$url = add_query_arg( 'post_type', $r['post_type'], $url );
  2070 					$url = add_query_arg( 'post_type', $parsed_args['post_type'], $url );
  1937 				}
  2071 				}
  1938 				$date = sprintf( '%1$d-%2$02d-%3$02d 00:00:00', $result->year, $result->month, $result->dayofmonth );
  2072 				$date = sprintf( '%1$d-%2$02d-%3$02d 00:00:00', $result->year, $result->month, $result->dayofmonth );
  1939 				$text = mysql2date( get_option( 'date_format' ), $date );
  2073 				$text = mysql2date( get_option( 'date_format' ), $date );
  1940 				if ( $r['show_post_count'] ) {
  2074 				if ( $parsed_args['show_post_count'] ) {
  1941 					$r['after'] = '&nbsp;(' . $result->posts . ')' . $after;
  2075 					$parsed_args['after'] = '&nbsp;(' . $result->posts . ')' . $after;
  1942 				}
  2076 				}
  1943 				$selected = is_archive() && (string) $r['year'] === $result->year && (string) $r['monthnum'] === $result->month && (string) $r['day'] === $result->dayofmonth;
  2077 				$selected = is_archive() && (string) $parsed_args['year'] === $result->year && (string) $parsed_args['monthnum'] === $result->month && (string) $parsed_args['day'] === $result->dayofmonth;
  1944 				$output  .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'], $selected );
  2078 				$output  .= get_archives_link( $url, $text, $parsed_args['format'], $parsed_args['before'], $parsed_args['after'], $selected );
  1945 			}
  2079 			}
  1946 		}
  2080 		}
  1947 	} elseif ( 'weekly' == $r['type'] ) {
  2081 	} elseif ( 'weekly' === $parsed_args['type'] ) {
  1948 		$week  = _wp_mysql_week( '`post_date`' );
  2082 		$week    = _wp_mysql_week( '`post_date`' );
  1949 		$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";
  2083 		$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";
  1950 		$key   = md5( $query );
  2084 		$key     = md5( $query );
  1951 		$key   = "wp_get_archives:$key:$last_changed";
  2085 		$key     = "wp_get_archives:$key:$last_changed";
  1952 		if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
  2086 		$results = wp_cache_get( $key, 'posts' );
       
  2087 		if ( ! $results ) {
  1953 			$results = $wpdb->get_results( $query );
  2088 			$results = $wpdb->get_results( $query );
  1954 			wp_cache_set( $key, $results, 'posts' );
  2089 			wp_cache_set( $key, $results, 'posts' );
  1955 		}
  2090 		}
  1956 		$arc_w_last = '';
  2091 		$arc_w_last = '';
  1957 		if ( $results ) {
  2092 		if ( $results ) {
  1958 			$after = $r['after'];
  2093 			$after = $parsed_args['after'];
  1959 			foreach ( (array) $results as $result ) {
  2094 			foreach ( (array) $results as $result ) {
  1960 				if ( $result->week != $arc_w_last ) {
  2095 				if ( $result->week != $arc_w_last ) {
  1961 					$arc_year       = $result->yr;
  2096 					$arc_year       = $result->yr;
  1962 					$arc_w_last     = $result->week;
  2097 					$arc_w_last     = $result->week;
  1963 					$arc_week       = get_weekstartend( $result->yyyymmdd, get_option( 'start_of_week' ) );
  2098 					$arc_week       = get_weekstartend( $result->yyyymmdd, get_option( 'start_of_week' ) );
  1968 							'm' => $arc_year,
  2103 							'm' => $arc_year,
  1969 							'w' => $result->week,
  2104 							'w' => $result->week,
  1970 						),
  2105 						),
  1971 						home_url( '/' )
  2106 						home_url( '/' )
  1972 					);
  2107 					);
  1973 					if ( 'post' !== $r['post_type'] ) {
  2108 					if ( 'post' !== $parsed_args['post_type'] ) {
  1974 						$url = add_query_arg( 'post_type', $r['post_type'], $url );
  2109 						$url = add_query_arg( 'post_type', $parsed_args['post_type'], $url );
  1975 					}
  2110 					}
  1976 					$text = $arc_week_start . $archive_week_separator . $arc_week_end;
  2111 					$text = $arc_week_start . $archive_week_separator . $arc_week_end;
  1977 					if ( $r['show_post_count'] ) {
  2112 					if ( $parsed_args['show_post_count'] ) {
  1978 						$r['after'] = '&nbsp;(' . $result->posts . ')' . $after;
  2113 						$parsed_args['after'] = '&nbsp;(' . $result->posts . ')' . $after;
  1979 					}
  2114 					}
  1980 					$selected = is_archive() && (string) $r['year'] === $result->yr && (string) $r['w'] === $result->week;
  2115 					$selected = is_archive() && (string) $parsed_args['year'] === $result->yr && (string) $parsed_args['w'] === $result->week;
  1981 					$output  .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'], $selected );
  2116 					$output  .= get_archives_link( $url, $text, $parsed_args['format'], $parsed_args['before'], $parsed_args['after'], $selected );
  1982 				}
  2117 				}
  1983 			}
  2118 			}
  1984 		}
  2119 		}
  1985 	} elseif ( ( 'postbypost' == $r['type'] ) || ( 'alpha' == $r['type'] ) ) {
  2120 	} elseif ( ( 'postbypost' === $parsed_args['type'] ) || ( 'alpha' === $parsed_args['type'] ) ) {
  1986 		$orderby = ( 'alpha' == $r['type'] ) ? 'post_title ASC ' : 'post_date DESC, ID DESC ';
  2121 		$orderby = ( 'alpha' === $parsed_args['type'] ) ? 'post_title ASC ' : 'post_date DESC, ID DESC ';
  1987 		$query   = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit";
  2122 		$query   = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit";
  1988 		$key     = md5( $query );
  2123 		$key     = md5( $query );
  1989 		$key     = "wp_get_archives:$key:$last_changed";
  2124 		$key     = "wp_get_archives:$key:$last_changed";
  1990 		if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
  2125 		$results = wp_cache_get( $key, 'posts' );
       
  2126 		if ( ! $results ) {
  1991 			$results = $wpdb->get_results( $query );
  2127 			$results = $wpdb->get_results( $query );
  1992 			wp_cache_set( $key, $results, 'posts' );
  2128 			wp_cache_set( $key, $results, 'posts' );
  1993 		}
  2129 		}
  1994 		if ( $results ) {
  2130 		if ( $results ) {
  1995 			foreach ( (array) $results as $result ) {
  2131 			foreach ( (array) $results as $result ) {
  1996 				if ( $result->post_date != '0000-00-00 00:00:00' ) {
  2132 				if ( '0000-00-00 00:00:00' !== $result->post_date ) {
  1997 					$url = get_permalink( $result );
  2133 					$url = get_permalink( $result );
  1998 					if ( $result->post_title ) {
  2134 					if ( $result->post_title ) {
  1999 						/** This filter is documented in wp-includes/post-template.php */
  2135 						/** This filter is documented in wp-includes/post-template.php */
  2000 						$text = strip_tags( apply_filters( 'the_title', $result->post_title, $result->ID ) );
  2136 						$text = strip_tags( apply_filters( 'the_title', $result->post_title, $result->ID ) );
  2001 					} else {
  2137 					} else {
  2002 						$text = $result->ID;
  2138 						$text = $result->ID;
  2003 					}
  2139 					}
  2004 					$selected = $result->ID === get_the_ID();
  2140 					$selected = get_the_ID() === $result->ID;
  2005 					$output  .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'], $selected );
  2141 					$output  .= get_archives_link( $url, $text, $parsed_args['format'], $parsed_args['before'], $parsed_args['after'], $selected );
  2006 				}
  2142 				}
  2007 			}
  2143 			}
  2008 		}
  2144 		}
  2009 	}
  2145 	}
  2010 	if ( $r['echo'] ) {
  2146 
       
  2147 	if ( $parsed_args['echo'] ) {
  2011 		echo $output;
  2148 		echo $output;
  2012 	} else {
  2149 	} else {
  2013 		return $output;
  2150 		return $output;
  2014 	}
  2151 	}
  2015 }
  2152 }
  2033  * The calendar is cached, which will be retrieved, if it exists. If there are
  2170  * The calendar is cached, which will be retrieved, if it exists. If there are
  2034  * no posts for the month, then it will not be displayed.
  2171  * no posts for the month, then it will not be displayed.
  2035  *
  2172  *
  2036  * @since 1.0.0
  2173  * @since 1.0.0
  2037  *
  2174  *
  2038  * @global wpdb      $wpdb
  2175  * @global wpdb      $wpdb      WordPress database abstraction object.
  2039  * @global int       $m
  2176  * @global int       $m
  2040  * @global int       $monthnum
  2177  * @global int       $monthnum
  2041  * @global int       $year
  2178  * @global int       $year
  2042  * @global WP_Locale $wp_locale
  2179  * @global WP_Locale $wp_locale WordPress date and time locale object.
  2043  * @global array     $posts
  2180  * @global array     $posts
  2044  *
  2181  *
  2045  * @param bool $initial Optional, default is true. Use initial calendar names.
  2182  * @param bool $initial Optional. Whether to use initial calendar names. Default true.
  2046  * @param bool $echo    Optional, default is true. Set to false for return.
  2183  * @param bool $echo    Optional. Whether to display the calendar output. Default true.
  2047  * @return string|void String when retrieving.
  2184  * @return void|string Void if `$echo` argument is true, calendar HTML if `$echo` is false.
  2048  */
  2185  */
  2049 function get_calendar( $initial = true, $echo = true ) {
  2186 function get_calendar( $initial = true, $echo = true ) {
  2050 	global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
  2187 	global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
  2051 
  2188 
  2052 	$key   = md5( $m . $monthnum . $year );
  2189 	$key   = md5( $m . $monthnum . $year );
  2079 	}
  2216 	}
  2080 
  2217 
  2081 	if ( isset( $_GET['w'] ) ) {
  2218 	if ( isset( $_GET['w'] ) ) {
  2082 		$w = (int) $_GET['w'];
  2219 		$w = (int) $_GET['w'];
  2083 	}
  2220 	}
  2084 	// week_begins = 0 stands for Sunday
  2221 	// week_begins = 0 stands for Sunday.
  2085 	$week_begins = (int) get_option( 'start_of_week' );
  2222 	$week_begins = (int) get_option( 'start_of_week' );
  2086 
  2223 
  2087 	// Let's figure out when we are
  2224 	// Let's figure out when we are.
  2088 	if ( ! empty( $monthnum ) && ! empty( $year ) ) {
  2225 	if ( ! empty( $monthnum ) && ! empty( $year ) ) {
  2089 		$thismonth = zeroise( intval( $monthnum ), 2 );
  2226 		$thismonth = zeroise( intval( $monthnum ), 2 );
  2090 		$thisyear  = (int) $year;
  2227 		$thisyear  = (int) $year;
  2091 	} elseif ( ! empty( $w ) ) {
  2228 	} elseif ( ! empty( $w ) ) {
  2092 		// We need to get the month from MySQL
  2229 		// We need to get the month from MySQL.
  2093 		$thisyear = (int) substr( $m, 0, 4 );
  2230 		$thisyear = (int) substr( $m, 0, 4 );
  2094 		//it seems MySQL's weeks disagree with PHP's
  2231 		// It seems MySQL's weeks disagree with PHP's.
  2095 		$d         = ( ( $w - 1 ) * 7 ) + 6;
  2232 		$d         = ( ( $w - 1 ) * 7 ) + 6;
  2096 		$thismonth = $wpdb->get_var( "SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')" );
  2233 		$thismonth = $wpdb->get_var( "SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')" );
  2097 	} elseif ( ! empty( $m ) ) {
  2234 	} elseif ( ! empty( $m ) ) {
  2098 		$thisyear = (int) substr( $m, 0, 4 );
  2235 		$thisyear = (int) substr( $m, 0, 4 );
  2099 		if ( strlen( $m ) < 6 ) {
  2236 		if ( strlen( $m ) < 6 ) {
  2105 		$thisyear  = current_time( 'Y' );
  2242 		$thisyear  = current_time( 'Y' );
  2106 		$thismonth = current_time( 'm' );
  2243 		$thismonth = current_time( 'm' );
  2107 	}
  2244 	}
  2108 
  2245 
  2109 	$unixmonth = mktime( 0, 0, 0, $thismonth, 1, $thisyear );
  2246 	$unixmonth = mktime( 0, 0, 0, $thismonth, 1, $thisyear );
  2110 	$last_day  = date( 't', $unixmonth );
  2247 	$last_day  = gmdate( 't', $unixmonth );
  2111 
  2248 
  2112 	// Get the next and previous month and year with at least one post
  2249 	// Get the next and previous month and year with at least one post.
  2113 	$previous = $wpdb->get_row(
  2250 	$previous = $wpdb->get_row(
  2114 		"SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
  2251 		"SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
  2115 		FROM $wpdb->posts
  2252 		FROM $wpdb->posts
  2116 		WHERE post_date < '$thisyear-$thismonth-01'
  2253 		WHERE post_date < '$thisyear-$thismonth-01'
  2117 		AND post_type = 'post' AND post_status = 'publish'
  2254 		AND post_type = 'post' AND post_status = 'publish'
  2125 		AND post_type = 'post' AND post_status = 'publish'
  2262 		AND post_type = 'post' AND post_status = 'publish'
  2126 			ORDER BY post_date ASC
  2263 			ORDER BY post_date ASC
  2127 			LIMIT 1"
  2264 			LIMIT 1"
  2128 	);
  2265 	);
  2129 
  2266 
  2130 	/* translators: Calendar caption: 1: month name, 2: 4-digit year */
  2267 	/* translators: Calendar caption: 1: Month name, 2: 4-digit year. */
  2131 	$calendar_caption = _x( '%1$s %2$s', 'calendar caption' );
  2268 	$calendar_caption = _x( '%1$s %2$s', 'calendar caption' );
  2132 	$calendar_output  = '<table id="wp-calendar">
  2269 	$calendar_output  = '<table id="wp-calendar" class="wp-calendar-table">
  2133 	<caption>' . sprintf(
  2270 	<caption>' . sprintf(
  2134 		$calendar_caption,
  2271 		$calendar_caption,
  2135 		$wp_locale->get_month( $thismonth ),
  2272 		$wp_locale->get_month( $thismonth ),
  2136 		date( 'Y', $unixmonth )
  2273 		gmdate( 'Y', $unixmonth )
  2137 	) . '</caption>
  2274 	) . '</caption>
  2138 	<thead>
  2275 	<thead>
  2139 	<tr>';
  2276 	<tr>';
  2140 
  2277 
  2141 	$myweek = array();
  2278 	$myweek = array();
  2151 	}
  2288 	}
  2152 
  2289 
  2153 	$calendar_output .= '
  2290 	$calendar_output .= '
  2154 	</tr>
  2291 	</tr>
  2155 	</thead>
  2292 	</thead>
  2156 
       
  2157 	<tfoot>
       
  2158 	<tr>';
       
  2159 
       
  2160 	if ( $previous ) {
       
  2161 		$calendar_output .= "\n\t\t" . '<td colspan="3" id="prev"><a href="' . get_month_link( $previous->year, $previous->month ) . '">&laquo; ' .
       
  2162 			$wp_locale->get_month_abbrev( $wp_locale->get_month( $previous->month ) ) .
       
  2163 		'</a></td>';
       
  2164 	} else {
       
  2165 		$calendar_output .= "\n\t\t" . '<td colspan="3" id="prev" class="pad">&nbsp;</td>';
       
  2166 	}
       
  2167 
       
  2168 	$calendar_output .= "\n\t\t" . '<td class="pad">&nbsp;</td>';
       
  2169 
       
  2170 	if ( $next ) {
       
  2171 		$calendar_output .= "\n\t\t" . '<td colspan="3" id="next"><a href="' . get_month_link( $next->year, $next->month ) . '">' .
       
  2172 			$wp_locale->get_month_abbrev( $wp_locale->get_month( $next->month ) ) .
       
  2173 		' &raquo;</a></td>';
       
  2174 	} else {
       
  2175 		$calendar_output .= "\n\t\t" . '<td colspan="3" id="next" class="pad">&nbsp;</td>';
       
  2176 	}
       
  2177 
       
  2178 	$calendar_output .= '
       
  2179 	</tr>
       
  2180 	</tfoot>
       
  2181 
       
  2182 	<tbody>
  2293 	<tbody>
  2183 	<tr>';
  2294 	<tr>';
  2184 
  2295 
  2185 	$daywithpost = array();
  2296 	$daywithpost = array();
  2186 
  2297 
  2187 	// Get days with posts
  2298 	// Get days with posts.
  2188 	$dayswithposts = $wpdb->get_results(
  2299 	$dayswithposts = $wpdb->get_results(
  2189 		"SELECT DISTINCT DAYOFMONTH(post_date)
  2300 		"SELECT DISTINCT DAYOFMONTH(post_date)
  2190 		FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00'
  2301 		FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00'
  2191 		AND post_type = 'post' AND post_status = 'publish'
  2302 		AND post_type = 'post' AND post_status = 'publish'
  2192 		AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'",
  2303 		AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'",
  2193 		ARRAY_N
  2304 		ARRAY_N
  2194 	);
  2305 	);
       
  2306 
  2195 	if ( $dayswithposts ) {
  2307 	if ( $dayswithposts ) {
  2196 		foreach ( (array) $dayswithposts as $daywith ) {
  2308 		foreach ( (array) $dayswithposts as $daywith ) {
  2197 			$daywithpost[] = $daywith[0];
  2309 			$daywithpost[] = (int) $daywith[0];
  2198 		}
  2310 		}
  2199 	}
  2311 	}
  2200 
  2312 
  2201 	// See how much we should pad in the beginning
  2313 	// See how much we should pad in the beginning.
  2202 	$pad = calendar_week_mod( date( 'w', $unixmonth ) - $week_begins );
  2314 	$pad = calendar_week_mod( gmdate( 'w', $unixmonth ) - $week_begins );
  2203 	if ( 0 != $pad ) {
  2315 	if ( 0 != $pad ) {
  2204 		$calendar_output .= "\n\t\t" . '<td colspan="' . esc_attr( $pad ) . '" class="pad">&nbsp;</td>';
  2316 		$calendar_output .= "\n\t\t" . '<td colspan="' . esc_attr( $pad ) . '" class="pad">&nbsp;</td>';
  2205 	}
  2317 	}
  2206 
  2318 
  2207 	$newrow      = false;
  2319 	$newrow      = false;
  2208 	$daysinmonth = (int) date( 't', $unixmonth );
  2320 	$daysinmonth = (int) gmdate( 't', $unixmonth );
  2209 
  2321 
  2210 	for ( $day = 1; $day <= $daysinmonth; ++$day ) {
  2322 	for ( $day = 1; $day <= $daysinmonth; ++$day ) {
  2211 		if ( isset( $newrow ) && $newrow ) {
  2323 		if ( isset( $newrow ) && $newrow ) {
  2212 			$calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
  2324 			$calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
  2213 		}
  2325 		}
  2214 		$newrow = false;
  2326 		$newrow = false;
  2215 
  2327 
  2216 		if ( $day == current_time( 'j' ) &&
  2328 		if ( current_time( 'j' ) == $day &&
  2217 			$thismonth == current_time( 'm' ) &&
  2329 			current_time( 'm' ) == $thismonth &&
  2218 			$thisyear == current_time( 'Y' ) ) {
  2330 			current_time( 'Y' ) == $thisyear ) {
  2219 			$calendar_output .= '<td id="today">';
  2331 			$calendar_output .= '<td id="today">';
  2220 		} else {
  2332 		} else {
  2221 			$calendar_output .= '<td>';
  2333 			$calendar_output .= '<td>';
  2222 		}
  2334 		}
  2223 
  2335 
  2224 		if ( in_array( $day, $daywithpost ) ) {
  2336 		if ( in_array( $day, $daywithpost, true ) ) {
  2225 			// any posts today?
  2337 			// Any posts today?
  2226 			$date_format = date( _x( 'F j, Y', 'daily archives date format' ), strtotime( "{$thisyear}-{$thismonth}-{$day}" ) );
  2338 			$date_format = gmdate( _x( 'F j, Y', 'daily archives date format' ), strtotime( "{$thisyear}-{$thismonth}-{$day}" ) );
  2227 			/* translators: Post calendar label. %s: Date */
  2339 			/* translators: Post calendar label. %s: Date. */
  2228 			$label            = sprintf( __( 'Posts published on %s' ), $date_format );
  2340 			$label            = sprintf( __( 'Posts published on %s' ), $date_format );
  2229 			$calendar_output .= sprintf(
  2341 			$calendar_output .= sprintf(
  2230 				'<a href="%s" aria-label="%s">%s</a>',
  2342 				'<a href="%s" aria-label="%s">%s</a>',
  2231 				get_day_link( $thisyear, $thismonth, $day ),
  2343 				get_day_link( $thisyear, $thismonth, $day ),
  2232 				esc_attr( $label ),
  2344 				esc_attr( $label ),
  2233 				$day
  2345 				$day
  2234 			);
  2346 			);
  2235 		} else {
  2347 		} else {
  2236 			$calendar_output .= $day;
  2348 			$calendar_output .= $day;
  2237 		}
  2349 		}
       
  2350 
  2238 		$calendar_output .= '</td>';
  2351 		$calendar_output .= '</td>';
  2239 
  2352 
  2240 		if ( 6 == calendar_week_mod( date( 'w', mktime( 0, 0, 0, $thismonth, $day, $thisyear ) ) - $week_begins ) ) {
  2353 		if ( 6 == calendar_week_mod( gmdate( 'w', mktime( 0, 0, 0, $thismonth, $day, $thisyear ) ) - $week_begins ) ) {
  2241 			$newrow = true;
  2354 			$newrow = true;
  2242 		}
  2355 		}
  2243 	}
  2356 	}
  2244 
  2357 
  2245 	$pad = 7 - calendar_week_mod( date( 'w', mktime( 0, 0, 0, $thismonth, $day, $thisyear ) ) - $week_begins );
  2358 	$pad = 7 - calendar_week_mod( gmdate( 'w', mktime( 0, 0, 0, $thismonth, $day, $thisyear ) ) - $week_begins );
  2246 	if ( $pad != 0 && $pad != 7 ) {
  2359 	if ( 0 != $pad && 7 != $pad ) {
  2247 		$calendar_output .= "\n\t\t" . '<td class="pad" colspan="' . esc_attr( $pad ) . '">&nbsp;</td>';
  2360 		$calendar_output .= "\n\t\t" . '<td class="pad" colspan="' . esc_attr( $pad ) . '">&nbsp;</td>';
  2248 	}
  2361 	}
  2249 	$calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>";
  2362 
       
  2363 	$calendar_output .= "\n\t</tr>\n\t</tbody>";
       
  2364 
       
  2365 	$calendar_output .= "\n\t</table>";
       
  2366 
       
  2367 	$calendar_output .= '<nav aria-label="' . __( 'Previous and next months' ) . '" class="wp-calendar-nav">';
       
  2368 
       
  2369 	if ( $previous ) {
       
  2370 		$calendar_output .= "\n\t\t" . '<span class="wp-calendar-nav-prev"><a href="' . get_month_link( $previous->year, $previous->month ) . '">&laquo; ' .
       
  2371 			$wp_locale->get_month_abbrev( $wp_locale->get_month( $previous->month ) ) .
       
  2372 		'</a></span>';
       
  2373 	} else {
       
  2374 		$calendar_output .= "\n\t\t" . '<span class="wp-calendar-nav-prev">&nbsp;</span>';
       
  2375 	}
       
  2376 
       
  2377 	$calendar_output .= "\n\t\t" . '<span class="pad">&nbsp;</span>';
       
  2378 
       
  2379 	if ( $next ) {
       
  2380 		$calendar_output .= "\n\t\t" . '<span class="wp-calendar-nav-next"><a href="' . get_month_link( $next->year, $next->month ) . '">' .
       
  2381 			$wp_locale->get_month_abbrev( $wp_locale->get_month( $next->month ) ) .
       
  2382 		' &raquo;</a></span>';
       
  2383 	} else {
       
  2384 		$calendar_output .= "\n\t\t" . '<span class="wp-calendar-nav-next">&nbsp;</span>';
       
  2385 	}
       
  2386 
       
  2387 	$calendar_output .= '
       
  2388 	</nav>';
  2250 
  2389 
  2251 	$cache[ $key ] = $calendar_output;
  2390 	$cache[ $key ] = $calendar_output;
  2252 	wp_cache_set( 'get_calendar', $cache, 'calendar' );
  2391 	wp_cache_set( 'get_calendar', $cache, 'calendar' );
  2253 
  2392 
  2254 	if ( $echo ) {
  2393 	if ( $echo ) {
  2326  * HTML output can be filtered with 'the_date'.
  2465  * HTML output can be filtered with 'the_date'.
  2327  * Date string output can be filtered with 'get_the_date'.
  2466  * Date string output can be filtered with 'get_the_date'.
  2328  *
  2467  *
  2329  * @since 0.71
  2468  * @since 0.71
  2330  *
  2469  *
  2331  * @global string|int|bool $currentday
  2470  * @global string $currentday  The day of the current post in the loop.
  2332  * @global string|int|bool $previousday
  2471  * @global string $previousday The day of the previous post in the loop.
  2333  *
  2472  *
  2334  * @param string $d      Optional. PHP date format defaults to the date_format option if not specified.
  2473  * @param string $format Optional. PHP date format defaults to the date_format option if not specified.
  2335  * @param string $before Optional. Output before the date.
  2474  * @param string $before Optional. Output before the date.
  2336  * @param string $after  Optional. Output after the date.
  2475  * @param string $after  Optional. Output after the date.
  2337  * @param bool   $echo   Optional, default is display. Whether to echo the date or return it.
  2476  * @param bool   $echo   Optional. Whether to echo the date or return it. Default true.
  2338  * @return string|void String if retrieving.
  2477  * @return string|void String if retrieving.
  2339  */
  2478  */
  2340 function the_date( $d = '', $before = '', $after = '', $echo = true ) {
  2479 function the_date( $format = '', $before = '', $after = '', $echo = true ) {
  2341 	global $currentday, $previousday;
  2480 	global $currentday, $previousday;
  2342 
  2481 
       
  2482 	$the_date = '';
       
  2483 
  2343 	if ( is_new_day() ) {
  2484 	if ( is_new_day() ) {
  2344 		$the_date    = $before . get_the_date( $d ) . $after;
  2485 		$the_date    = $before . get_the_date( $format ) . $after;
  2345 		$previousday = $currentday;
  2486 		$previousday = $currentday;
  2346 
  2487 	}
  2347 		/**
  2488 
  2348 		 * Filters the date a post was published for display.
  2489 	/**
  2349 		 *
  2490 	 * Filters the date a post was published for display.
  2350 		 * @since 0.71
  2491 	 *
  2351 		 *
  2492 	 * @since 0.71
  2352 		 * @param string $the_date The formatted date string.
  2493 	 *
  2353 		 * @param string $d        PHP date format. Defaults to 'date_format' option
  2494 	 * @param string $the_date The formatted date string.
  2354 		 *                         if not specified.
  2495 	 * @param string $format   PHP date format. Defaults to 'date_format' option
  2355 		 * @param string $before   HTML output before the date.
  2496 	 *                         if not specified.
  2356 		 * @param string $after    HTML output after the date.
  2497 	 * @param string $before   HTML output before the date.
  2357 		 */
  2498 	 * @param string $after    HTML output after the date.
  2358 		$the_date = apply_filters( 'the_date', $the_date, $d, $before, $after );
  2499 	 */
  2359 
  2500 	$the_date = apply_filters( 'the_date', $the_date, $format, $before, $after );
  2360 		if ( $echo ) {
  2501 
  2361 			echo $the_date;
  2502 	if ( $echo ) {
  2362 		} else {
  2503 		echo $the_date;
  2363 			return $the_date;
  2504 	} else {
  2364 		}
  2505 		return $the_date;
  2365 	}
  2506 	}
  2366 }
  2507 }
  2367 
  2508 
  2368 /**
  2509 /**
  2369  * Retrieve the date on which the post was written.
  2510  * Retrieve the date on which the post was written.
  2371  * Unlike the_date() this function will always return the date.
  2512  * Unlike the_date() this function will always return the date.
  2372  * Modify output with the {@see 'get_the_date'} filter.
  2513  * Modify output with the {@see 'get_the_date'} filter.
  2373  *
  2514  *
  2374  * @since 3.0.0
  2515  * @since 3.0.0
  2375  *
  2516  *
  2376  * @param  string      $d    Optional. PHP date format defaults to the date_format option if not specified.
  2517  * @param string      $format Optional. PHP date format defaults to the date_format option if not specified.
  2377  * @param  int|WP_Post $post Optional. Post ID or WP_Post object. Default current post.
  2518  * @param int|WP_Post $post   Optional. Post ID or WP_Post object. Default current post.
  2378  * @return false|string Date the current post was written. False on failure.
  2519  * @return string|false Date the current post was written. False on failure.
  2379  */
  2520  */
  2380 function get_the_date( $d = '', $post = null ) {
  2521 function get_the_date( $format = '', $post = null ) {
  2381 	$post = get_post( $post );
  2522 	$post = get_post( $post );
  2382 
  2523 
  2383 	if ( ! $post ) {
  2524 	if ( ! $post ) {
  2384 		return false;
  2525 		return false;
  2385 	}
  2526 	}
  2386 
  2527 
  2387 	if ( '' == $d ) {
  2528 	$_format = ! empty( $format ) ? $format : get_option( 'date_format' );
  2388 		$the_date = get_post_time( get_option( 'date_format' ), false, $post, true );
  2529 
  2389 	} else {
  2530 	$the_date = get_post_time( $_format, false, $post, true );
  2390 		$the_date = get_post_time( $d, false, $post, true );
       
  2391 	}
       
  2392 
  2531 
  2393 	/**
  2532 	/**
  2394 	 * Filters the date a post was published.
  2533 	 * Filters the date a post was published.
  2395 	 *
  2534 	 *
  2396 	 * @since 3.0.0
  2535 	 * @since 3.0.0
  2397 	 *
  2536 	 *
  2398 	 * @param string      $the_date The formatted date.
  2537 	 * @param string      $the_date The formatted date.
  2399 	 * @param string      $d        PHP date format. Defaults to 'date_format' option
  2538 	 * @param string      $format   PHP date format. Defaults to 'date_format' option
  2400 	 *                              if not specified.
  2539 	 *                              if not specified.
  2401 	 * @param int|WP_Post $post     The post object or ID.
  2540 	 * @param int|WP_Post $post     The post object or ID.
  2402 	 */
  2541 	 */
  2403 	return apply_filters( 'get_the_date', $the_date, $d, $post );
  2542 	return apply_filters( 'get_the_date', $the_date, $format, $post );
  2404 }
  2543 }
  2405 
  2544 
  2406 /**
  2545 /**
  2407  * Display the date on which the post was last modified.
  2546  * Display the date on which the post was last modified.
  2408  *
  2547  *
  2409  * @since 2.1.0
  2548  * @since 2.1.0
  2410  *
  2549  *
  2411  * @param string $d      Optional. PHP date format defaults to the date_format option if not specified.
  2550  * @param string $format Optional. PHP date format defaults to the date_format option if not specified.
  2412  * @param string $before Optional. Output before the date.
  2551  * @param string $before Optional. Output before the date.
  2413  * @param string $after  Optional. Output after the date.
  2552  * @param string $after  Optional. Output after the date.
  2414  * @param bool   $echo   Optional, default is display. Whether to echo the date or return it.
  2553  * @param bool   $echo   Optional. Whether to echo the date or return it. Default true.
  2415  * @return string|void String if retrieving.
  2554  * @return string|void String if retrieving.
  2416  */
  2555  */
  2417 function the_modified_date( $d = '', $before = '', $after = '', $echo = true ) {
  2556 function the_modified_date( $format = '', $before = '', $after = '', $echo = true ) {
  2418 	$the_modified_date = $before . get_the_modified_date( $d ) . $after;
  2557 	$the_modified_date = $before . get_the_modified_date( $format ) . $after;
  2419 
  2558 
  2420 	/**
  2559 	/**
  2421 	 * Filters the date a post was last modified for display.
  2560 	 * Filters the date a post was last modified for display.
  2422 	 *
  2561 	 *
  2423 	 * @since 2.1.0
  2562 	 * @since 2.1.0
  2424 	 *
  2563 	 *
  2425 	 * @param string $the_modified_date The last modified date.
  2564 	 * @param string $the_modified_date The last modified date.
  2426 	 * @param string $d                 PHP date format. Defaults to 'date_format' option
  2565 	 * @param string $format            PHP date format. Defaults to 'date_format' option
  2427 	 *                                  if not specified.
  2566 	 *                                  if not specified.
  2428 	 * @param string $before            HTML output before the date.
  2567 	 * @param string $before            HTML output before the date.
  2429 	 * @param string $after             HTML output after the date.
  2568 	 * @param string $after             HTML output after the date.
  2430 	 */
  2569 	 */
  2431 	$the_modified_date = apply_filters( 'the_modified_date', $the_modified_date, $d, $before, $after );
  2570 	$the_modified_date = apply_filters( 'the_modified_date', $the_modified_date, $format, $before, $after );
  2432 
  2571 
  2433 	if ( $echo ) {
  2572 	if ( $echo ) {
  2434 		echo $the_modified_date;
  2573 		echo $the_modified_date;
  2435 	} else {
  2574 	} else {
  2436 		return $the_modified_date;
  2575 		return $the_modified_date;
  2442  * Retrieve the date on which the post was last modified.
  2581  * Retrieve the date on which the post was last modified.
  2443  *
  2582  *
  2444  * @since 2.1.0
  2583  * @since 2.1.0
  2445  * @since 4.6.0 Added the `$post` parameter.
  2584  * @since 4.6.0 Added the `$post` parameter.
  2446  *
  2585  *
  2447  * @param string      $d    Optional. PHP date format defaults to the date_format option if not specified.
  2586  * @param string      $format Optional. PHP date format defaults to the date_format option if not specified.
  2448  * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default current post.
  2587  * @param int|WP_Post $post   Optional. Post ID or WP_Post object. Default current post.
  2449  * @return false|string Date the current post was modified. False on failure.
  2588  * @return string|false Date the current post was modified. False on failure.
  2450  */
  2589  */
  2451 function get_the_modified_date( $d = '', $post = null ) {
  2590 function get_the_modified_date( $format = '', $post = null ) {
  2452 	$post = get_post( $post );
  2591 	$post = get_post( $post );
  2453 
  2592 
  2454 	if ( ! $post ) {
  2593 	if ( ! $post ) {
  2455 		// For backward compatibility, failures go through the filter below.
  2594 		// For backward compatibility, failures go through the filter below.
  2456 		$the_time = false;
  2595 		$the_time = false;
  2457 	} elseif ( empty( $d ) ) {
       
  2458 		$the_time = get_post_modified_time( get_option( 'date_format' ), false, $post, true );
       
  2459 	} else {
  2596 	} else {
  2460 		$the_time = get_post_modified_time( $d, false, $post, true );
  2597 		$_format = ! empty( $format ) ? $format : get_option( 'date_format' );
       
  2598 
       
  2599 		$the_time = get_post_modified_time( $_format, false, $post, true );
  2461 	}
  2600 	}
  2462 
  2601 
  2463 	/**
  2602 	/**
  2464 	 * Filters the date a post was last modified.
  2603 	 * Filters the date a post was last modified.
  2465 	 *
  2604 	 *
  2466 	 * @since 2.1.0
  2605 	 * @since 2.1.0
  2467 	 * @since 4.6.0 Added the `$post` parameter.
  2606 	 * @since 4.6.0 Added the `$post` parameter.
  2468 	 *
  2607 	 *
  2469 	 * @param string|bool  $the_time The formatted date or false if no post is found.
  2608 	 * @param string|bool  $the_time The formatted date or false if no post is found.
  2470 	 * @param string       $d        PHP date format. Defaults to value specified in
  2609 	 * @param string       $format   PHP date format. Defaults to value specified in
  2471 	 *                               'date_format' option.
  2610 	 *                               'date_format' option.
  2472 	 * @param WP_Post|null $post     WP_Post object or null if no post is found.
  2611 	 * @param WP_Post|null $post     WP_Post object or null if no post is found.
  2473 	 */
  2612 	 */
  2474 	return apply_filters( 'get_the_modified_date', $the_time, $d, $post );
  2613 	return apply_filters( 'get_the_modified_date', $the_time, $format, $post );
  2475 }
  2614 }
  2476 
  2615 
  2477 /**
  2616 /**
  2478  * Display the time at which the post was written.
  2617  * Display the time at which the post was written.
  2479  *
  2618  *
  2480  * @since 0.71
  2619  * @since 0.71
  2481  *
  2620  *
  2482  * @param string $d Either 'G', 'U', or php date format.
  2621  * @param string $format Either 'G', 'U', or PHP date format.
  2483  */
  2622  */
  2484 function the_time( $d = '' ) {
  2623 function the_time( $format = '' ) {
  2485 	/**
  2624 	/**
  2486 	 * Filters the time a post was written for display.
  2625 	 * Filters the time a post was written for display.
  2487 	 *
  2626 	 *
  2488 	 * @since 0.71
  2627 	 * @since 0.71
  2489 	 *
  2628 	 *
  2490 	 * @param string $get_the_time The formatted time.
  2629 	 * @param string $get_the_time The formatted time.
  2491 	 * @param string $d            The time format. Accepts 'G', 'U',
  2630 	 * @param string $format       The time format. Accepts 'G', 'U',
  2492 	 *                             or php date format.
  2631 	 *                             or PHP date format.
  2493 	 */
  2632 	 */
  2494 	echo apply_filters( 'the_time', get_the_time( $d ), $d );
  2633 	echo apply_filters( 'the_time', get_the_time( $format ), $format );
  2495 }
  2634 }
  2496 
  2635 
  2497 /**
  2636 /**
  2498  * Retrieve the time at which the post was written.
  2637  * Retrieve the time at which the post was written.
  2499  *
  2638  *
  2500  * @since 1.5.0
  2639  * @since 1.5.0
  2501  *
  2640  *
  2502  * @param string      $d    Optional. Format to use for retrieving the time the post
  2641  * @param string      $format Optional. Format to use for retrieving the time the post
  2503  *                          was written. Either 'G', 'U', or php date format defaults
  2642  *                            was written. Either 'G', 'U', or PHP date format defaults
  2504  *                          to the value specified in the time_format option. Default empty.
  2643  *                            to the value specified in the time_format option. Default empty.
  2505  * @param int|WP_Post $post WP_Post object or ID. Default is global $post object.
  2644  * @param int|WP_Post $post   WP_Post object or ID. Default is global `$post` object.
  2506  * @return string|int|false Formatted date string or Unix timestamp if `$d` is 'U' or 'G'. False on failure.
  2645  * @return string|int|false Formatted date string or Unix timestamp if `$format` is 'U' or 'G'.
  2507  */
  2646  *                          False on failure.
  2508 function get_the_time( $d = '', $post = null ) {
  2647  */
       
  2648 function get_the_time( $format = '', $post = null ) {
  2509 	$post = get_post( $post );
  2649 	$post = get_post( $post );
  2510 
  2650 
  2511 	if ( ! $post ) {
  2651 	if ( ! $post ) {
  2512 		return false;
  2652 		return false;
  2513 	}
  2653 	}
  2514 
  2654 
  2515 	if ( '' == $d ) {
  2655 	$_format = ! empty( $format ) ? $format : get_option( 'time_format' );
  2516 		$the_time = get_post_time( get_option( 'time_format' ), false, $post, true );
  2656 
  2517 	} else {
  2657 	$the_time = get_post_time( $_format, false, $post, true );
  2518 		$the_time = get_post_time( $d, false, $post, true );
       
  2519 	}
       
  2520 
  2658 
  2521 	/**
  2659 	/**
  2522 	 * Filters the time a post was written.
  2660 	 * Filters the time a post was written.
  2523 	 *
  2661 	 *
  2524 	 * @since 1.5.0
  2662 	 * @since 1.5.0
  2525 	 *
  2663 	 *
  2526 	 * @param string      $the_time The formatted time.
  2664 	 * @param string      $the_time The formatted time.
  2527 	 * @param string      $d        Format to use for retrieving the time the post was written.
  2665 	 * @param string      $format   Format to use for retrieving the time the post was written.
  2528 	 *                              Accepts 'G', 'U', or php date format value specified
  2666 	 *                              Accepts 'G', 'U', or PHP date format value specified
  2529 	 *                              in 'time_format' option. Default empty.
  2667 	 *                              in 'time_format' option. Default empty.
  2530 	 * @param int|WP_Post $post     WP_Post object or ID.
  2668 	 * @param int|WP_Post $post     WP_Post object or ID.
  2531 	 */
  2669 	 */
  2532 	return apply_filters( 'get_the_time', $the_time, $d, $post );
  2670 	return apply_filters( 'get_the_time', $the_time, $format, $post );
  2533 }
  2671 }
  2534 
  2672 
  2535 /**
  2673 /**
  2536  * Retrieve the time at which the post was written.
  2674  * Retrieve the time at which the post was written.
  2537  *
  2675  *
  2538  * @since 2.0.0
  2676  * @since 2.0.0
  2539  *
  2677  *
  2540  * @param string      $d         Optional. Format to use for retrieving the time the post
  2678  * @param string      $format    Optional. Format to use for retrieving the time the post
  2541  *                               was written. Either 'G', 'U', or php date format. Default 'U'.
  2679  *                               was written. Either 'G', 'U', or PHP date format. Default 'U'.
  2542  * @param bool        $gmt       Optional. Whether to retrieve the GMT time. Default false.
  2680  * @param bool        $gmt       Optional. Whether to retrieve the GMT time. Default false.
  2543  * @param int|WP_Post $post      WP_Post object or ID. Default is global $post object.
  2681  * @param int|WP_Post $post      WP_Post object or ID. Default is global `$post` object.
  2544  * @param bool        $translate Whether to translate the time string. Default false.
  2682  * @param bool        $translate Whether to translate the time string. Default false.
  2545  * @return string|int|false Formatted date string or Unix timestamp if `$d` is 'U' or 'G'. False on failure.
  2683  * @return string|int|false Formatted date string or Unix timestamp if `$format` is 'U' or 'G'.
  2546  */
  2684  *                          False on failure.
  2547 function get_post_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
  2685  */
       
  2686 function get_post_time( $format = 'U', $gmt = false, $post = null, $translate = false ) {
  2548 	$post = get_post( $post );
  2687 	$post = get_post( $post );
  2549 
  2688 
  2550 	if ( ! $post ) {
  2689 	if ( ! $post ) {
  2551 		return false;
  2690 		return false;
  2552 	}
  2691 	}
  2553 
  2692 
  2554 	if ( $gmt ) {
  2693 	$source   = ( $gmt ) ? 'gmt' : 'local';
  2555 		$time = $post->post_date_gmt;
  2694 	$datetime = get_post_datetime( $post, 'date', $source );
       
  2695 
       
  2696 	if ( false === $datetime ) {
       
  2697 		return false;
       
  2698 	}
       
  2699 
       
  2700 	if ( 'U' === $format || 'G' === $format ) {
       
  2701 		$time = $datetime->getTimestamp();
       
  2702 
       
  2703 		// Returns a sum of timestamp with timezone offset. Ideally should never be used.
       
  2704 		if ( ! $gmt ) {
       
  2705 			$time += $datetime->getOffset();
       
  2706 		}
       
  2707 	} elseif ( $translate ) {
       
  2708 		$time = wp_date( $format, $datetime->getTimestamp(), $gmt ? new DateTimeZone( 'UTC' ) : null );
  2556 	} else {
  2709 	} else {
  2557 		$time = $post->post_date;
  2710 		if ( $gmt ) {
  2558 	}
  2711 			$datetime = $datetime->setTimezone( new DateTimeZone( 'UTC' ) );
  2559 
  2712 		}
  2560 	$time = mysql2date( $d, $time, $translate );
  2713 
       
  2714 		$time = $datetime->format( $format );
       
  2715 	}
  2561 
  2716 
  2562 	/**
  2717 	/**
  2563 	 * Filters the localized time a post was written.
  2718 	 * Filters the localized time a post was written.
  2564 	 *
  2719 	 *
  2565 	 * @since 2.6.0
  2720 	 * @since 2.6.0
  2566 	 *
  2721 	 *
  2567 	 * @param string $time The formatted time.
  2722 	 * @param string $time   The formatted time.
  2568 	 * @param string $d    Format to use for retrieving the time the post was written.
  2723 	 * @param string $format Format to use for retrieving the time the post was written.
  2569 	 *                     Accepts 'G', 'U', or php date format. Default 'U'.
  2724 	 *                       Accepts 'G', 'U', or PHP date format. Default 'U'.
  2570 	 * @param bool   $gmt  Whether to retrieve the GMT time. Default false.
  2725 	 * @param bool   $gmt    Whether to retrieve the GMT time. Default false.
  2571 	 */
  2726 	 */
  2572 	return apply_filters( 'get_post_time', $time, $d, $gmt );
  2727 	return apply_filters( 'get_post_time', $time, $format, $gmt );
       
  2728 }
       
  2729 
       
  2730 /**
       
  2731  * Retrieve post published or modified time as a `DateTimeImmutable` object instance.
       
  2732  *
       
  2733  * The object will be set to the timezone from WordPress settings.
       
  2734  *
       
  2735  * For legacy reasons, this function allows to choose to instantiate from local or UTC time in database.
       
  2736  * Normally this should make no difference to the result. However, the values might get out of sync in database,
       
  2737  * typically because of timezone setting changes. The parameter ensures the ability to reproduce backwards
       
  2738  * compatible behaviors in such cases.
       
  2739  *
       
  2740  * @since 5.3.0
       
  2741  *
       
  2742  * @param int|WP_Post $post   Optional. WP_Post object or ID. Default is global `$post` object.
       
  2743  * @param string      $field  Optional. Published or modified time to use from database. Accepts 'date' or 'modified'.
       
  2744  *                            Default 'date'.
       
  2745  * @param string      $source Optional. Local or UTC time to use from database. Accepts 'local' or 'gmt'.
       
  2746  *                            Default 'local'.
       
  2747  * @return DateTimeImmutable|false Time object on success, false on failure.
       
  2748  */
       
  2749 function get_post_datetime( $post = null, $field = 'date', $source = 'local' ) {
       
  2750 	$post = get_post( $post );
       
  2751 
       
  2752 	if ( ! $post ) {
       
  2753 		return false;
       
  2754 	}
       
  2755 
       
  2756 	$wp_timezone = wp_timezone();
       
  2757 
       
  2758 	if ( 'gmt' === $source ) {
       
  2759 		$time     = ( 'modified' === $field ) ? $post->post_modified_gmt : $post->post_date_gmt;
       
  2760 		$timezone = new DateTimeZone( 'UTC' );
       
  2761 	} else {
       
  2762 		$time     = ( 'modified' === $field ) ? $post->post_modified : $post->post_date;
       
  2763 		$timezone = $wp_timezone;
       
  2764 	}
       
  2765 
       
  2766 	if ( empty( $time ) || '0000-00-00 00:00:00' === $time ) {
       
  2767 		return false;
       
  2768 	}
       
  2769 
       
  2770 	$datetime = date_create_immutable_from_format( 'Y-m-d H:i:s', $time, $timezone );
       
  2771 
       
  2772 	if ( false === $datetime ) {
       
  2773 		return false;
       
  2774 	}
       
  2775 
       
  2776 	return $datetime->setTimezone( $wp_timezone );
       
  2777 }
       
  2778 
       
  2779 /**
       
  2780  * Retrieve post published or modified time as a Unix timestamp.
       
  2781  *
       
  2782  * Note that this function returns a true Unix timestamp, not summed with timezone offset
       
  2783  * like older WP functions.
       
  2784  *
       
  2785  * @since 5.3.0
       
  2786  *
       
  2787  * @param int|WP_Post $post  Optional. WP_Post object or ID. Default is global `$post` object.
       
  2788  * @param string      $field Optional. Published or modified time to use from database. Accepts 'date' or 'modified'.
       
  2789  *                           Default 'date'.
       
  2790  * @return int|false Unix timestamp on success, false on failure.
       
  2791  */
       
  2792 function get_post_timestamp( $post = null, $field = 'date' ) {
       
  2793 	$datetime = get_post_datetime( $post, $field );
       
  2794 
       
  2795 	if ( false === $datetime ) {
       
  2796 		return false;
       
  2797 	}
       
  2798 
       
  2799 	return $datetime->getTimestamp();
  2573 }
  2800 }
  2574 
  2801 
  2575 /**
  2802 /**
  2576  * Display the time at which the post was last modified.
  2803  * Display the time at which the post was last modified.
  2577  *
  2804  *
  2578  * @since 2.0.0
  2805  * @since 2.0.0
  2579  *
  2806  *
  2580  * @param string $d Optional Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
  2807  * @param string $format Optional. Either 'G', 'U', or PHP date format defaults
  2581  */
  2808  *                       to the value specified in the time_format option.
  2582 function the_modified_time( $d = '' ) {
  2809  */
       
  2810 function the_modified_time( $format = '' ) {
  2583 	/**
  2811 	/**
  2584 	 * Filters the localized time a post was last modified, for display.
  2812 	 * Filters the localized time a post was last modified, for display.
  2585 	 *
  2813 	 *
  2586 	 * @since 2.0.0
  2814 	 * @since 2.0.0
  2587 	 *
  2815 	 *
  2588 	 * @param string $get_the_modified_time The formatted time.
  2816 	 * @param string $get_the_modified_time The formatted time.
  2589 	 * @param string $d                     The time format. Accepts 'G', 'U',
  2817 	 * @param string $format                The time format. Accepts 'G', 'U',
  2590 	 *                                      or php date format. Defaults to value
  2818 	 *                                      or PHP date format. Defaults to value
  2591 	 *                                      specified in 'time_format' option.
  2819 	 *                                      specified in 'time_format' option.
  2592 	 */
  2820 	 */
  2593 	echo apply_filters( 'the_modified_time', get_the_modified_time( $d ), $d );
  2821 	echo apply_filters( 'the_modified_time', get_the_modified_time( $format ), $format );
  2594 }
  2822 }
  2595 
  2823 
  2596 /**
  2824 /**
  2597  * Retrieve the time at which the post was last modified.
  2825  * Retrieve the time at which the post was last modified.
  2598  *
  2826  *
  2599  * @since 2.0.0
  2827  * @since 2.0.0
  2600  * @since 4.6.0 Added the `$post` parameter.
  2828  * @since 4.6.0 Added the `$post` parameter.
  2601  *
  2829  *
  2602  * @param string      $d     Optional. Format to use for retrieving the time the post
  2830  * @param string      $format Optional. Format to use for retrieving the time the post
  2603  *                           was modified. Either 'G', 'U', or php date format defaults
  2831  *                            was modified. Either 'G', 'U', or PHP date format defaults
  2604  *                           to the value specified in the time_format option. Default empty.
  2832  *                            to the value specified in the time_format option. Default empty.
  2605  * @param int|WP_Post $post  Optional. Post ID or WP_Post object. Default current post.
  2833  * @param int|WP_Post $post   Optional. Post ID or WP_Post object. Default current post.
  2606  * @return false|string Formatted date string or Unix timestamp. False on failure.
  2834  * @return string|false Formatted date string or Unix timestamp. False on failure.
  2607  */
  2835  */
  2608 function get_the_modified_time( $d = '', $post = null ) {
  2836 function get_the_modified_time( $format = '', $post = null ) {
  2609 	$post = get_post( $post );
  2837 	$post = get_post( $post );
  2610 
  2838 
  2611 	if ( ! $post ) {
  2839 	if ( ! $post ) {
  2612 		// For backward compatibility, failures go through the filter below.
  2840 		// For backward compatibility, failures go through the filter below.
  2613 		$the_time = false;
  2841 		$the_time = false;
  2614 	} elseif ( empty( $d ) ) {
       
  2615 		$the_time = get_post_modified_time( get_option( 'time_format' ), false, $post, true );
       
  2616 	} else {
  2842 	} else {
  2617 		$the_time = get_post_modified_time( $d, false, $post, true );
  2843 		$_format = ! empty( $format ) ? $format : get_option( 'time_format' );
       
  2844 
       
  2845 		$the_time = get_post_modified_time( $_format, false, $post, true );
  2618 	}
  2846 	}
  2619 
  2847 
  2620 	/**
  2848 	/**
  2621 	 * Filters the localized time a post was last modified.
  2849 	 * Filters the localized time a post was last modified.
  2622 	 *
  2850 	 *
  2623 	 * @since 2.0.0
  2851 	 * @since 2.0.0
  2624 	 * @since 4.6.0 Added the `$post` parameter.
  2852 	 * @since 4.6.0 Added the `$post` parameter.
  2625 	 *
  2853 	 *
  2626 	 * @param string|bool  $the_time The formatted time or false if no post is found.
  2854 	 * @param string|bool  $the_time The formatted time or false if no post is found.
  2627 	 * @param string       $d        Format to use for retrieving the time the post was
  2855 	 * @param string       $format   Format to use for retrieving the time the post was
  2628 	 *                               written. Accepts 'G', 'U', or php date format. Defaults
  2856 	 *                               written. Accepts 'G', 'U', or PHP date format. Defaults
  2629 	 *                               to value specified in 'time_format' option.
  2857 	 *                               to value specified in 'time_format' option.
  2630 	 * @param WP_Post|null $post     WP_Post object or null if no post is found.
  2858 	 * @param WP_Post|null $post     WP_Post object or null if no post is found.
  2631 	 */
  2859 	 */
  2632 	return apply_filters( 'get_the_modified_time', $the_time, $d, $post );
  2860 	return apply_filters( 'get_the_modified_time', $the_time, $format, $post );
  2633 }
  2861 }
  2634 
  2862 
  2635 /**
  2863 /**
  2636  * Retrieve the time at which the post was last modified.
  2864  * Retrieve the time at which the post was last modified.
  2637  *
  2865  *
  2638  * @since 2.0.0
  2866  * @since 2.0.0
  2639  *
  2867  *
  2640  * @param string      $d         Optional. Format to use for retrieving the time the post
  2868  * @param string      $format    Optional. Format to use for retrieving the time the post
  2641  *                               was modified. Either 'G', 'U', or php date format. Default 'U'.
  2869  *                               was modified. Either 'G', 'U', or PHP date format. Default 'U'.
  2642  * @param bool        $gmt       Optional. Whether to retrieve the GMT time. Default false.
  2870  * @param bool        $gmt       Optional. Whether to retrieve the GMT time. Default false.
  2643  * @param int|WP_Post $post      WP_Post object or ID. Default is global $post object.
  2871  * @param int|WP_Post $post      WP_Post object or ID. Default is global `$post` object.
  2644  * @param bool        $translate Whether to translate the time string. Default false.
  2872  * @param bool        $translate Whether to translate the time string. Default false.
  2645  * @return string|int|false Formatted date string or Unix timestamp if `$d` is 'U' or 'G'. False on failure.
  2873  * @return string|int|false Formatted date string or Unix timestamp if `$format` is 'U' or 'G'.
  2646  */
  2874  *                          False on failure.
  2647 function get_post_modified_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
  2875  */
       
  2876 function get_post_modified_time( $format = 'U', $gmt = false, $post = null, $translate = false ) {
  2648 	$post = get_post( $post );
  2877 	$post = get_post( $post );
  2649 
  2878 
  2650 	if ( ! $post ) {
  2879 	if ( ! $post ) {
  2651 		return false;
  2880 		return false;
  2652 	}
  2881 	}
  2653 
  2882 
  2654 	if ( $gmt ) {
  2883 	$source   = ( $gmt ) ? 'gmt' : 'local';
  2655 		$time = $post->post_modified_gmt;
  2884 	$datetime = get_post_datetime( $post, 'modified', $source );
       
  2885 
       
  2886 	if ( false === $datetime ) {
       
  2887 		return false;
       
  2888 	}
       
  2889 
       
  2890 	if ( 'U' === $format || 'G' === $format ) {
       
  2891 		$time = $datetime->getTimestamp();
       
  2892 
       
  2893 		// Returns a sum of timestamp with timezone offset. Ideally should never be used.
       
  2894 		if ( ! $gmt ) {
       
  2895 			$time += $datetime->getOffset();
       
  2896 		}
       
  2897 	} elseif ( $translate ) {
       
  2898 		$time = wp_date( $format, $datetime->getTimestamp(), $gmt ? new DateTimeZone( 'UTC' ) : null );
  2656 	} else {
  2899 	} else {
  2657 		$time = $post->post_modified;
  2900 		if ( $gmt ) {
  2658 	}
  2901 			$datetime = $datetime->setTimezone( new DateTimeZone( 'UTC' ) );
  2659 	$time = mysql2date( $d, $time, $translate );
  2902 		}
       
  2903 
       
  2904 		$time = $datetime->format( $format );
       
  2905 	}
  2660 
  2906 
  2661 	/**
  2907 	/**
  2662 	 * Filters the localized time a post was last modified.
  2908 	 * Filters the localized time a post was last modified.
  2663 	 *
  2909 	 *
  2664 	 * @since 2.8.0
  2910 	 * @since 2.8.0
  2665 	 *
  2911 	 *
  2666 	 * @param string $time The formatted time.
  2912 	 * @param string $time   The formatted time.
  2667 	 * @param string $d    The date format. Accepts 'G', 'U', or php date format. Default 'U'.
  2913 	 * @param string $format Format to use for retrieving the time the post was modified.
  2668 	 * @param bool   $gmt  Whether to return the GMT time. Default false.
  2914 	 *                       Accepts 'G', 'U', or PHP date format. Default 'U'.
  2669 	 */
  2915 	 * @param bool   $gmt    Whether to retrieve the GMT time. Default false.
  2670 	return apply_filters( 'get_post_modified_time', $time, $d, $gmt );
  2916 	 */
       
  2917 	return apply_filters( 'get_post_modified_time', $time, $format, $gmt );
  2671 }
  2918 }
  2672 
  2919 
  2673 /**
  2920 /**
  2674  * Display the weekday on which the post was written.
  2921  * Display the weekday on which the post was written.
  2675  *
  2922  *
  2676  * @since 0.71
  2923  * @since 0.71
  2677  *
  2924  *
  2678  * @global WP_Locale $wp_locale
  2925  * @global WP_Locale $wp_locale WordPress date and time locale object.
  2679  */
  2926  */
  2680 function the_weekday() {
  2927 function the_weekday() {
  2681 	global $wp_locale;
  2928 	global $wp_locale;
  2682 	$the_weekday = $wp_locale->get_weekday( mysql2date( 'w', get_post()->post_date, false ) );
  2929 
       
  2930 	$post = get_post();
       
  2931 
       
  2932 	if ( ! $post ) {
       
  2933 		return;
       
  2934 	}
       
  2935 
       
  2936 	$the_weekday = $wp_locale->get_weekday( get_post_time( 'w', false, $post ) );
  2683 
  2937 
  2684 	/**
  2938 	/**
  2685 	 * Filters the weekday on which the post was written, for display.
  2939 	 * Filters the weekday on which the post was written, for display.
  2686 	 *
  2940 	 *
  2687 	 * @since 0.71
  2941 	 * @since 0.71
  2697  * Will only output the weekday if the current post's weekday is different from
  2951  * Will only output the weekday if the current post's weekday is different from
  2698  * the previous one output.
  2952  * the previous one output.
  2699  *
  2953  *
  2700  * @since 0.71
  2954  * @since 0.71
  2701  *
  2955  *
  2702  * @global WP_Locale       $wp_locale
  2956  * @global WP_Locale $wp_locale       WordPress date and time locale object.
  2703  * @global string|int|bool $currentday
  2957  * @global string    $currentday      The day of the current post in the loop.
  2704  * @global string|int|bool $previousweekday
  2958  * @global string    $previousweekday The day of the previous post in the loop.
  2705  *
  2959  *
  2706  * @param string $before Optional Output before the date.
  2960  * @param string $before Optional. Output before the date.
  2707  * @param string $after Optional Output after the date.
  2961  * @param string $after  Optional. Output after the date.
  2708  */
  2962  */
  2709 function the_weekday_date( $before = '', $after = '' ) {
  2963 function the_weekday_date( $before = '', $after = '' ) {
  2710 	global $wp_locale, $currentday, $previousweekday;
  2964 	global $wp_locale, $currentday, $previousweekday;
       
  2965 
       
  2966 	$post = get_post();
       
  2967 
       
  2968 	if ( ! $post ) {
       
  2969 		return;
       
  2970 	}
       
  2971 
  2711 	$the_weekday_date = '';
  2972 	$the_weekday_date = '';
  2712 	if ( $currentday != $previousweekday ) {
  2973 
       
  2974 	if ( $currentday !== $previousweekday ) {
  2713 		$the_weekday_date .= $before;
  2975 		$the_weekday_date .= $before;
  2714 		$the_weekday_date .= $wp_locale->get_weekday( mysql2date( 'w', get_post()->post_date, false ) );
  2976 		$the_weekday_date .= $wp_locale->get_weekday( get_post_time( 'w', false, $post ) );
  2715 		$the_weekday_date .= $after;
  2977 		$the_weekday_date .= $after;
  2716 		$previousweekday   = $currentday;
  2978 		$previousweekday   = $currentday;
  2717 	}
  2979 	}
  2718 
  2980 
  2719 	/**
  2981 	/**
  2720 	 * Filters the localized date on which the post was written, for display.
  2982 	 * Filters the localized date on which the post was written, for display.
  2721 	 *
  2983 	 *
  2722 	 * @since 0.71
  2984 	 * @since 0.71
  2723 	 *
  2985 	 *
  2724 	 * @param string $the_weekday_date
  2986 	 * @param string $the_weekday_date The weekday on which the post was written.
  2725 	 * @param string $before           The HTML to output before the date.
  2987 	 * @param string $before           The HTML to output before the date.
  2726 	 * @param string $after            The HTML to output after the date.
  2988 	 * @param string $after            The HTML to output after the date.
  2727 	 */
  2989 	 */
  2728 	$the_weekday_date = apply_filters( 'the_weekday_date', $the_weekday_date, $before, $after );
  2990 	echo apply_filters( 'the_weekday_date', $the_weekday_date, $before, $after );
  2729 	echo $the_weekday_date;
       
  2730 }
  2991 }
  2731 
  2992 
  2732 /**
  2993 /**
  2733  * Fire the wp_head action.
  2994  * Fire the wp_head action.
  2734  *
  2995  *
  2762 }
  3023 }
  2763 
  3024 
  2764 /**
  3025 /**
  2765  * Fire the wp_body_open action.
  3026  * Fire the wp_body_open action.
  2766  *
  3027  *
  2767  * * See {@see 'wp_body_open'}.
  3028  * See {@see 'wp_body_open'}.
  2768  *
  3029  *
  2769  * @since 5.2.0
  3030  * @since 5.2.0
  2770  */
  3031  */
  2771 function wp_body_open() {
  3032 function wp_body_open() {
  2772 	/**
  3033 	/**
  2773 	 * Triggered after the opening <body> tag.
  3034 	 * Triggered after the opening body tag.
  2774 	 *
  3035 	 *
  2775 	 * @since 5.2.0
  3036 	 * @since 5.2.0
  2776 	 */
  3037 	 */
  2777 	do_action( 'wp_body_open' );
  3038 	do_action( 'wp_body_open' );
  2778 }
  3039 }
  2788 	if ( ! current_theme_supports( 'automatic-feed-links' ) ) {
  3049 	if ( ! current_theme_supports( 'automatic-feed-links' ) ) {
  2789 		return;
  3050 		return;
  2790 	}
  3051 	}
  2791 
  3052 
  2792 	$defaults = array(
  3053 	$defaults = array(
  2793 		/* translators: Separator between blog name and feed type in feed links */
  3054 		/* translators: Separator between blog name and feed type in feed links. */
  2794 		'separator' => _x( '&raquo;', 'feed link' ),
  3055 		'separator' => _x( '&raquo;', 'feed link' ),
  2795 		/* translators: 1: blog title, 2: separator (raquo) */
  3056 		/* translators: 1: Blog title, 2: Separator (raquo). */
  2796 		'feedtitle' => __( '%1$s %2$s Feed' ),
  3057 		'feedtitle' => __( '%1$s %2$s Feed' ),
  2797 		/* translators: 1: blog title, 2: separator (raquo) */
  3058 		/* translators: 1: Blog title, 2: Separator (raquo). */
  2798 		'comstitle' => __( '%1$s %2$s Comments Feed' ),
  3059 		'comstitle' => __( '%1$s %2$s Comments Feed' ),
  2799 	);
  3060 	);
  2800 
  3061 
  2801 	$args = wp_parse_args( $args, $defaults );
  3062 	$args = wp_parse_args( $args, $defaults );
  2802 
  3063 
  2830  *
  3091  *
  2831  * @param array $args Optional arguments.
  3092  * @param array $args Optional arguments.
  2832  */
  3093  */
  2833 function feed_links_extra( $args = array() ) {
  3094 function feed_links_extra( $args = array() ) {
  2834 	$defaults = array(
  3095 	$defaults = array(
  2835 		/* translators: Separator between blog name and feed type in feed links */
  3096 		/* translators: Separator between blog name and feed type in feed links. */
  2836 		'separator'     => _x( '&raquo;', 'feed link' ),
  3097 		'separator'     => _x( '&raquo;', 'feed link' ),
  2837 		/* translators: 1: blog name, 2: separator(raquo), 3: post title */
  3098 		/* translators: 1: Blog name, 2: Separator (raquo), 3: Post title. */
  2838 		'singletitle'   => __( '%1$s %2$s %3$s Comments Feed' ),
  3099 		'singletitle'   => __( '%1$s %2$s %3$s Comments Feed' ),
  2839 		/* translators: 1: blog name, 2: separator(raquo), 3: category name */
  3100 		/* translators: 1: Blog name, 2: Separator (raquo), 3: Category name. */
  2840 		'cattitle'      => __( '%1$s %2$s %3$s Category Feed' ),
  3101 		'cattitle'      => __( '%1$s %2$s %3$s Category Feed' ),
  2841 		/* translators: 1: blog name, 2: separator(raquo), 3: tag name */
  3102 		/* translators: 1: Blog name, 2: Separator (raquo), 3: Tag name. */
  2842 		'tagtitle'      => __( '%1$s %2$s %3$s Tag Feed' ),
  3103 		'tagtitle'      => __( '%1$s %2$s %3$s Tag Feed' ),
  2843 		/* translators: 1: blog name, 2: separator(raquo), 3: term name, 4: taxonomy singular name */
  3104 		/* translators: 1: Blog name, 2: Separator (raquo), 3: Term name, 4: Taxonomy singular name. */
  2844 		'taxtitle'      => __( '%1$s %2$s %3$s %4$s Feed' ),
  3105 		'taxtitle'      => __( '%1$s %2$s %3$s %4$s Feed' ),
  2845 		/* translators: 1: blog name, 2: separator(raquo), 3: author name  */
  3106 		/* translators: 1: Blog name, 2: Separator (raquo), 3: Author name. */
  2846 		'authortitle'   => __( '%1$s %2$s Posts by %3$s Feed' ),
  3107 		'authortitle'   => __( '%1$s %2$s Posts by %3$s Feed' ),
  2847 		/* translators: 1: blog name, 2: separator(raquo), 3: search phrase */
  3108 		/* translators: 1: Blog name, 2: Separator (raquo), 3: Search query. */
  2848 		'searchtitle'   => __( '%1$s %2$s Search Results for &#8220;%3$s&#8221; Feed' ),
  3109 		'searchtitle'   => __( '%1$s %2$s Search Results for &#8220;%3$s&#8221; Feed' ),
  2849 		/* translators: 1: blog name, 2: separator(raquo), 3: post type name */
  3110 		/* translators: 1: Blog name, 2: Separator (raquo), 3: Post type name. */
  2850 		'posttypetitle' => __( '%1$s %2$s %3$s Feed' ),
  3111 		'posttypetitle' => __( '%1$s %2$s %3$s Feed' ),
  2851 	);
  3112 	);
  2852 
  3113 
  2853 	$args = wp_parse_args( $args, $defaults );
  3114 	$args = wp_parse_args( $args, $defaults );
  2854 
  3115 
  2882 		if ( $term ) {
  3143 		if ( $term ) {
  2883 			$title = sprintf( $args['tagtitle'], get_bloginfo( 'name' ), $args['separator'], $term->name );
  3144 			$title = sprintf( $args['tagtitle'], get_bloginfo( 'name' ), $args['separator'], $term->name );
  2884 			$href  = get_tag_feed_link( $term->term_id );
  3145 			$href  = get_tag_feed_link( $term->term_id );
  2885 		}
  3146 		}
  2886 	} elseif ( is_tax() ) {
  3147 	} elseif ( is_tax() ) {
  2887 		$term  = get_queried_object();
  3148 		$term = get_queried_object();
  2888 		$tax   = get_taxonomy( $term->taxonomy );
  3149 
  2889 		$title = sprintf( $args['taxtitle'], get_bloginfo( 'name' ), $args['separator'], $term->name, $tax->labels->singular_name );
  3150 		if ( $term ) {
  2890 		$href  = get_term_feed_link( $term->term_id, $term->taxonomy );
  3151 			$tax   = get_taxonomy( $term->taxonomy );
       
  3152 			$title = sprintf( $args['taxtitle'], get_bloginfo( 'name' ), $args['separator'], $term->name, $tax->labels->singular_name );
       
  3153 			$href  = get_term_feed_link( $term->term_id, $term->taxonomy );
       
  3154 		}
  2891 	} elseif ( is_author() ) {
  3155 	} elseif ( is_author() ) {
  2892 		$author_id = intval( get_query_var( 'author' ) );
  3156 		$author_id = intval( get_query_var( 'author' ) );
  2893 
  3157 
  2894 		$title = sprintf( $args['authortitle'], get_bloginfo( 'name' ), $args['separator'], get_the_author_meta( 'display_name', $author_id ) );
  3158 		$title = sprintf( $args['authortitle'], get_bloginfo( 'name' ), $args['separator'], get_the_author_meta( 'display_name', $author_id ) );
  2895 		$href  = get_author_feed_link( $author_id );
  3159 		$href  = get_author_feed_link( $author_id );
  2896 	} elseif ( is_search() ) {
  3160 	} elseif ( is_search() ) {
  2897 		$title = sprintf( $args['searchtitle'], get_bloginfo( 'name' ), $args['separator'], get_search_query( false ) );
  3161 		$title = sprintf( $args['searchtitle'], get_bloginfo( 'name' ), $args['separator'], get_search_query( false ) );
  2898 		$href  = get_search_feed_link();
  3162 		$href  = get_search_feed_link();
  2899 	} elseif ( is_post_type_archive() ) {
       
  2900 		$title         = sprintf( $args['posttypetitle'], get_bloginfo( 'name' ), $args['separator'], post_type_archive_title( '', false ) );
       
  2901 		$post_type_obj = get_queried_object();
       
  2902 		if ( $post_type_obj ) {
       
  2903 			$href = get_post_type_archive_feed_link( $post_type_obj->name );
       
  2904 		}
       
  2905 	}
  3163 	}
  2906 
  3164 
  2907 	if ( isset( $title ) && isset( $href ) ) {
  3165 	if ( isset( $title ) && isset( $href ) ) {
  2908 		echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( $title ) . '" href="' . esc_url( $href ) . '" />' . "\n";
  3166 		echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( $title ) . '" href="' . esc_url( $href ) . '" />' . "\n";
  2909 	}
  3167 	}
  2924  *
  3182  *
  2925  * @link https://msdn.microsoft.com/en-us/library/bb463265.aspx
  3183  * @link https://msdn.microsoft.com/en-us/library/bb463265.aspx
  2926  * @since 2.3.1
  3184  * @since 2.3.1
  2927  */
  3185  */
  2928 function wlwmanifest_link() {
  3186 function wlwmanifest_link() {
  2929 	echo '<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="',
  3187 	echo '<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="' . includes_url( 'wlwmanifest.xml' ) . '" /> ' . "\n";
  2930 		includes_url( 'wlwmanifest.xml' ), '" /> ', "\n";
       
  2931 }
  3188 }
  2932 
  3189 
  2933 /**
  3190 /**
  2934  * Displays a noindex meta tag if required by the blog configuration.
  3191  * Displays a noindex meta tag if required by the blog configuration.
  2935  *
  3192  *
  2954 
  3211 
  2955 /**
  3212 /**
  2956  * Display a noindex meta tag.
  3213  * Display a noindex meta tag.
  2957  *
  3214  *
  2958  * Outputs a noindex meta tag that tells web robots not to index the page content.
  3215  * Outputs a noindex meta tag that tells web robots not to index the page content.
  2959  * Typical usage is as a wp_head callback. add_action( 'wp_head', 'wp_no_robots' );
  3216  * Typical usage is as a {@see 'wp_head'} callback. add_action( 'wp_head', 'wp_no_robots' );
  2960  *
  3217  *
  2961  * @since 3.3.0
  3218  * @since 3.3.0
       
  3219  * @since 5.3.0 Echo "noindex,nofollow" if search engine visibility is discouraged.
  2962  */
  3220  */
  2963 function wp_no_robots() {
  3221 function wp_no_robots() {
  2964 	echo "<meta name='robots' content='noindex,follow' />\n";
  3222 	if ( get_option( 'blog_public' ) ) {
       
  3223 		echo "<meta name='robots' content='noindex,follow' />\n";
       
  3224 		return;
       
  3225 	}
       
  3226 
       
  3227 	echo "<meta name='robots' content='noindex,nofollow' />\n";
  2965 }
  3228 }
  2966 
  3229 
  2967 /**
  3230 /**
  2968  * Display a noindex,noarchive meta tag and referrer origin-when-cross-origin meta tag.
  3231  * Display a noindex,noarchive meta tag and referrer origin-when-cross-origin meta tag.
  2969  *
  3232  *
  3006 	if ( $icon_192 ) {
  3269 	if ( $icon_192 ) {
  3007 		$meta_tags[] = sprintf( '<link rel="icon" href="%s" sizes="192x192" />', esc_url( $icon_192 ) );
  3270 		$meta_tags[] = sprintf( '<link rel="icon" href="%s" sizes="192x192" />', esc_url( $icon_192 ) );
  3008 	}
  3271 	}
  3009 	$icon_180 = get_site_icon_url( 180 );
  3272 	$icon_180 = get_site_icon_url( 180 );
  3010 	if ( $icon_180 ) {
  3273 	if ( $icon_180 ) {
  3011 		$meta_tags[] = sprintf( '<link rel="apple-touch-icon-precomposed" href="%s" />', esc_url( $icon_180 ) );
  3274 		$meta_tags[] = sprintf( '<link rel="apple-touch-icon" href="%s" />', esc_url( $icon_180 ) );
  3012 	}
  3275 	}
  3013 	$icon_270 = get_site_icon_url( 270 );
  3276 	$icon_270 = get_site_icon_url( 270 );
  3014 	if ( $icon_270 ) {
  3277 	if ( $icon_270 ) {
  3015 		$meta_tags[] = sprintf( '<meta name="msapplication-TileImage" content="%s" />', esc_url( $icon_270 ) );
  3278 		$meta_tags[] = sprintf( '<meta name="msapplication-TileImage" content="%s" />', esc_url( $icon_270 ) );
  3016 	}
  3279 	}
  3053 	/*
  3316 	/*
  3054 	 * Add DNS prefetch for the Emoji CDN.
  3317 	 * Add DNS prefetch for the Emoji CDN.
  3055 	 * The path is removed in the foreach loop below.
  3318 	 * The path is removed in the foreach loop below.
  3056 	 */
  3319 	 */
  3057 	/** This filter is documented in wp-includes/formatting.php */
  3320 	/** This filter is documented in wp-includes/formatting.php */
  3058 	$hints['dns-prefetch'][] = apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/12.0.0-1/svg/' );
  3321 	$hints['dns-prefetch'][] = apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/13.0.0/svg/' );
  3059 
  3322 
  3060 	foreach ( $hints as $relation_type => $urls ) {
  3323 	foreach ( $hints as $relation_type => $urls ) {
  3061 		$unique_urls = array();
  3324 		$unique_urls = array();
  3062 
  3325 
  3063 		/**
  3326 		/**
  3090 
  3353 
  3091 			if ( isset( $unique_urls[ $url ] ) ) {
  3354 			if ( isset( $unique_urls[ $url ] ) ) {
  3092 				continue;
  3355 				continue;
  3093 			}
  3356 			}
  3094 
  3357 
  3095 			if ( in_array( $relation_type, array( 'preconnect', 'dns-prefetch' ) ) ) {
  3358 			if ( in_array( $relation_type, array( 'preconnect', 'dns-prefetch' ), true ) ) {
  3096 				$parsed = wp_parse_url( $url );
  3359 				$parsed = wp_parse_url( $url );
  3097 
  3360 
  3098 				if ( empty( $parsed['host'] ) ) {
  3361 				if ( empty( $parsed['host'] ) ) {
  3099 					continue;
  3362 					continue;
  3100 				}
  3363 				}
  3115 
  3378 
  3116 		foreach ( $unique_urls as $atts ) {
  3379 		foreach ( $unique_urls as $atts ) {
  3117 			$html = '';
  3380 			$html = '';
  3118 
  3381 
  3119 			foreach ( $atts as $attr => $value ) {
  3382 			foreach ( $atts as $attr => $value ) {
  3120 				if ( ! is_scalar( $value ) ||
  3383 				if ( ! is_scalar( $value )
  3121 					( ! in_array( $attr, array( 'as', 'crossorigin', 'href', 'pr', 'rel', 'type' ), true ) && ! is_numeric( $attr ) ) ) {
  3384 					|| ( ! in_array( $attr, array( 'as', 'crossorigin', 'href', 'pr', 'rel', 'type' ), true ) && ! is_numeric( $attr ) )
       
  3385 				) {
  3122 
  3386 
  3123 					continue;
  3387 					continue;
  3124 				}
  3388 				}
  3125 
  3389 
  3126 				$value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
  3390 				$value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
  3142 /**
  3406 /**
  3143  * Retrieves a list of unique hosts of all enqueued scripts and styles.
  3407  * Retrieves a list of unique hosts of all enqueued scripts and styles.
  3144  *
  3408  *
  3145  * @since 4.6.0
  3409  * @since 4.6.0
  3146  *
  3410  *
  3147  * @return array A list of unique hosts of enqueued scripts and styles.
  3411  * @return string[] A list of unique hosts of enqueued scripts and styles.
  3148  */
  3412  */
  3149 function wp_dependencies_unique_hosts() {
  3413 function wp_dependencies_unique_hosts() {
  3150 	global $wp_scripts, $wp_styles;
  3414 	global $wp_scripts, $wp_styles;
  3151 
  3415 
  3152 	$unique_hosts = array();
  3416 	$unique_hosts = array();
  3160 
  3424 
  3161 				/* @var _WP_Dependency $dependency */
  3425 				/* @var _WP_Dependency $dependency */
  3162 				$dependency = $dependencies->registered[ $handle ];
  3426 				$dependency = $dependencies->registered[ $handle ];
  3163 				$parsed     = wp_parse_url( $dependency->src );
  3427 				$parsed     = wp_parse_url( $dependency->src );
  3164 
  3428 
  3165 				if ( ! empty( $parsed['host'] ) && ! in_array( $parsed['host'], $unique_hosts ) && $parsed['host'] !== $_SERVER['SERVER_NAME'] ) {
  3429 				if ( ! empty( $parsed['host'] )
       
  3430 					&& ! in_array( $parsed['host'], $unique_hosts, true ) && $parsed['host'] !== $_SERVER['SERVER_NAME']
       
  3431 				) {
  3166 					$unique_hosts[] = $parsed['host'];
  3432 					$unique_hosts[] = $parsed['host'];
  3167 				}
  3433 				}
  3168 			}
  3434 			}
  3169 		}
  3435 		}
  3170 	}
  3436 	}
  3193 	global $wp_rich_edit, $is_gecko, $is_opera, $is_safari, $is_chrome, $is_IE, $is_edge;
  3459 	global $wp_rich_edit, $is_gecko, $is_opera, $is_safari, $is_chrome, $is_IE, $is_edge;
  3194 
  3460 
  3195 	if ( ! isset( $wp_rich_edit ) ) {
  3461 	if ( ! isset( $wp_rich_edit ) ) {
  3196 		$wp_rich_edit = false;
  3462 		$wp_rich_edit = false;
  3197 
  3463 
  3198 		if ( get_user_option( 'rich_editing' ) == 'true' || ! is_user_logged_in() ) { // default to 'true' for logged out users
  3464 		if ( 'true' === get_user_option( 'rich_editing' ) || ! is_user_logged_in() ) { // Default to 'true' for logged out users.
  3199 			if ( $is_safari ) {
  3465 			if ( $is_safari ) {
  3200 				$wp_rich_edit = ! wp_is_mobile() || ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval( $match[1] ) >= 534 );
  3466 				$wp_rich_edit = ! wp_is_mobile() || ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval( $match[1] ) >= 534 );
  3201 			} elseif ( $is_IE ) {
  3467 			} elseif ( $is_IE ) {
  3202 				$wp_rich_edit = ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Trident/7.0;' ) !== false );
  3468 				$wp_rich_edit = ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Trident/7.0;' ) !== false );
  3203 			} elseif ( $is_gecko || $is_chrome || $is_edge || ( $is_opera && ! wp_is_mobile() ) ) {
  3469 			} elseif ( $is_gecko || $is_chrome || $is_edge || ( $is_opera && ! wp_is_mobile() ) ) {
  3225  * @since 2.5.0
  3491  * @since 2.5.0
  3226  *
  3492  *
  3227  * @return string Either 'tinymce', or 'html', or 'test'
  3493  * @return string Either 'tinymce', or 'html', or 'test'
  3228  */
  3494  */
  3229 function wp_default_editor() {
  3495 function wp_default_editor() {
  3230 	$r = user_can_richedit() ? 'tinymce' : 'html'; // defaults
  3496 	$r = user_can_richedit() ? 'tinymce' : 'html'; // Defaults.
  3231 	if ( wp_get_current_user() ) { // look for cookie
  3497 	if ( wp_get_current_user() ) { // Look for cookie.
  3232 		$ed = get_user_setting( 'editor', 'tinymce' );
  3498 		$ed = get_user_setting( 'editor', 'tinymce' );
  3233 		$r  = ( in_array( $ed, array( 'tinymce', 'html', 'test' ) ) ) ? $ed : $r;
  3499 		$r  = ( in_array( $ed, array( 'tinymce', 'html', 'test' ), true ) ) ? $ed : $r;
  3234 	}
  3500 	}
  3235 
  3501 
  3236 	/**
  3502 	/**
  3237 	 * Filters which editor should be displayed by default.
  3503 	 * Filters which editor should be displayed by default.
  3238 	 *
  3504 	 *
  3254  * On the post edit screen several actions can be used to include additional editors
  3520  * On the post edit screen several actions can be used to include additional editors
  3255  * containing TinyMCE: 'edit_page_form', 'edit_form_advanced' and 'dbx_post_sidebar'.
  3521  * containing TinyMCE: 'edit_page_form', 'edit_form_advanced' and 'dbx_post_sidebar'.
  3256  * See https://core.trac.wordpress.org/ticket/19173 for more information.
  3522  * See https://core.trac.wordpress.org/ticket/19173 for more information.
  3257  *
  3523  *
  3258  * @see _WP_Editors::editor()
  3524  * @see _WP_Editors::editor()
       
  3525  * @see _WP_Editors::parse_settings()
  3259  * @since 3.3.0
  3526  * @since 3.3.0
  3260  *
  3527  *
  3261  * @param string $content   Initial content for the editor.
  3528  * @param string $content   Initial content for the editor.
  3262  * @param string $editor_id HTML ID attribute value for the textarea and TinyMCE. Can only be /[a-z]+/.
  3529  * @param string $editor_id HTML ID attribute value for the textarea and TinyMCE.
  3263  * @param array  $settings  See _WP_Editors::editor().
  3530  *                          Should not contain square brackets.
       
  3531  * @param array  $settings  See _WP_Editors::parse_settings() for description.
  3264  */
  3532  */
  3265 function wp_editor( $content, $editor_id, $settings = array() ) {
  3533 function wp_editor( $content, $editor_id, $settings = array() ) {
  3266 	if ( ! class_exists( '_WP_Editors', false ) ) {
  3534 	if ( ! class_exists( '_WP_Editors', false ) ) {
  3267 		require( ABSPATH . WPINC . '/class-wp-editor.php' );
  3535 		require ABSPATH . WPINC . '/class-wp-editor.php';
  3268 	}
  3536 	}
  3269 	_WP_Editors::editor( $content, $editor_id, $settings );
  3537 	_WP_Editors::editor( $content, $editor_id, $settings );
  3270 }
  3538 }
  3271 
  3539 
  3272 /**
  3540 /**
  3278  * @uses _WP_Editors
  3546  * @uses _WP_Editors
  3279  * @since 4.8.0
  3547  * @since 4.8.0
  3280  */
  3548  */
  3281 function wp_enqueue_editor() {
  3549 function wp_enqueue_editor() {
  3282 	if ( ! class_exists( '_WP_Editors', false ) ) {
  3550 	if ( ! class_exists( '_WP_Editors', false ) ) {
  3283 		require( ABSPATH . WPINC . '/class-wp-editor.php' );
  3551 		require ABSPATH . WPINC . '/class-wp-editor.php';
  3284 	}
  3552 	}
  3285 
  3553 
  3286 	_WP_Editors::enqueue_default_editor();
  3554 	_WP_Editors::enqueue_default_editor();
  3287 }
  3555 }
  3288 
  3556 
  3562 					break;
  3830 					break;
  3563 			}
  3831 			}
  3564 		}
  3832 		}
  3565 	}
  3833 	}
  3566 
  3834 
  3567 	if ( 'text/css' === $type ) {
  3835 	if ( in_array( $type, array( 'text/css', 'text/x-scss', 'text/x-less', 'text/x-sass' ), true ) ) {
  3568 		$settings['codemirror'] = array_merge(
       
  3569 			$settings['codemirror'],
       
  3570 			array(
       
  3571 				'mode'              => 'css',
       
  3572 				'lint'              => true,
       
  3573 				'autoCloseBrackets' => true,
       
  3574 				'matchBrackets'     => true,
       
  3575 			)
       
  3576 		);
       
  3577 	} elseif ( 'text/x-scss' === $type || 'text/x-less' === $type || 'text/x-sass' === $type ) {
       
  3578 		$settings['codemirror'] = array_merge(
  3836 		$settings['codemirror'] = array_merge(
  3579 			$settings['codemirror'],
  3837 			$settings['codemirror'],
  3580 			array(
  3838 			array(
  3581 				'mode'              => $type,
  3839 				'mode'              => $type,
  3582 				'lint'              => false,
  3840 				'lint'              => false,
  3729 	 *
  3987 	 *
  3730 	 * Returning a falsey value will disable the syntax-highlighting code editor.
  3988 	 * Returning a falsey value will disable the syntax-highlighting code editor.
  3731 	 *
  3989 	 *
  3732 	 * @since 4.9.0
  3990 	 * @since 4.9.0
  3733 	 *
  3991 	 *
  3734 	 * @param array $settings The array of settings passed to the code editor. A falsey value disables the editor.
  3992 	 * @param array $settings The array of settings passed to the code editor.
       
  3993 	 *                        A falsey value disables the editor.
  3735 	 * @param array $args {
  3994 	 * @param array $args {
  3736 	 *     Args passed when calling `get_code_editor_settings()`.
  3995 	 *     Args passed when calling `get_code_editor_settings()`.
  3737 	 *
  3996 	 *
  3738 	 *     @type string   $type       The MIME type of the file to be edited.
  3997 	 *     @type string   $type       The MIME type of the file to be edited.
  3739 	 *     @type string   $file       Filename being edited.
  3998 	 *     @type string   $file       Filename being edited.
  3750 
  4009 
  3751 /**
  4010 /**
  3752  * Retrieves the contents of the search WordPress query variable.
  4011  * Retrieves the contents of the search WordPress query variable.
  3753  *
  4012  *
  3754  * The search query string is passed through esc_attr() to ensure that it is safe
  4013  * The search query string is passed through esc_attr() to ensure that it is safe
  3755  * for placing in an html attribute.
  4014  * for placing in an HTML attribute.
  3756  *
  4015  *
  3757  * @since 2.3.0
  4016  * @since 2.3.0
  3758  *
  4017  *
  3759  * @param bool $escaped Whether the result is escaped. Default true.
  4018  * @param bool $escaped Whether the result is escaped. Default true.
  3760  *                      Only use when you are later escaping it. Do not use unescaped.
  4019  *                      Only use when you are later escaping it. Do not use unescaped.
  3778 
  4037 
  3779 /**
  4038 /**
  3780  * Displays the contents of the search query variable.
  4039  * Displays the contents of the search query variable.
  3781  *
  4040  *
  3782  * The search query string is passed through esc_attr() to ensure that it is safe
  4041  * The search query string is passed through esc_attr() to ensure that it is safe
  3783  * for placing in an html attribute.
  4042  * for placing in an HTML attribute.
  3784  *
  4043  *
  3785  * @since 2.1.0
  4044  * @since 2.1.0
  3786  */
  4045  */
  3787 function the_search_query() {
  4046 function the_search_query() {
  3788 	/**
  4047 	/**
  3794 	 */
  4053 	 */
  3795 	echo esc_attr( apply_filters( 'the_search_query', get_search_query( false ) ) );
  4054 	echo esc_attr( apply_filters( 'the_search_query', get_search_query( false ) ) );
  3796 }
  4055 }
  3797 
  4056 
  3798 /**
  4057 /**
  3799  * Gets the language attributes for the html tag.
  4058  * Gets the language attributes for the 'html' tag.
  3800  *
  4059  *
  3801  * Builds up a set of html attributes containing the text direction and language
  4060  * Builds up a set of HTML attributes containing the text direction and language
  3802  * information for the page.
  4061  * information for the page.
  3803  *
  4062  *
  3804  * @since 4.3.0
  4063  * @since 4.3.0
  3805  *
  4064  *
  3806  * @param string $doctype Optional. The type of html document. Accepts 'xhtml' or 'html'. Default 'html'.
  4065  * @param string $doctype Optional. The type of HTML document. Accepts 'xhtml' or 'html'. Default 'html'.
  3807  */
  4066  */
  3808 function get_language_attributes( $doctype = 'html' ) {
  4067 function get_language_attributes( $doctype = 'html' ) {
  3809 	$attributes = array();
  4068 	$attributes = array();
  3810 
  4069 
  3811 	if ( function_exists( 'is_rtl' ) && is_rtl() ) {
  4070 	if ( function_exists( 'is_rtl' ) && is_rtl() ) {
  3812 		$attributes[] = 'dir="rtl"';
  4071 		$attributes[] = 'dir="rtl"';
  3813 	}
  4072 	}
  3814 
  4073 
  3815 	if ( $lang = get_bloginfo( 'language' ) ) {
  4074 	$lang = get_bloginfo( 'language' );
  3816 		if ( get_option( 'html_type' ) == 'text/html' || $doctype == 'html' ) {
  4075 	if ( $lang ) {
       
  4076 		if ( 'text/html' === get_option( 'html_type' ) || 'html' === $doctype ) {
  3817 			$attributes[] = 'lang="' . esc_attr( $lang ) . '"';
  4077 			$attributes[] = 'lang="' . esc_attr( $lang ) . '"';
  3818 		}
  4078 		}
  3819 
  4079 
  3820 		if ( get_option( 'html_type' ) != 'text/html' || $doctype == 'xhtml' ) {
  4080 		if ( 'text/html' !== get_option( 'html_type' ) || 'xhtml' === $doctype ) {
  3821 			$attributes[] = 'xml:lang="' . esc_attr( $lang ) . '"';
  4081 			$attributes[] = 'xml:lang="' . esc_attr( $lang ) . '"';
  3822 		}
  4082 		}
  3823 	}
  4083 	}
  3824 
  4084 
  3825 	$output = implode( ' ', $attributes );
  4085 	$output = implode( ' ', $attributes );
  3826 
  4086 
  3827 	/**
  4087 	/**
  3828 	 * Filters the language attributes for display in the html tag.
  4088 	 * Filters the language attributes for display in the 'html' tag.
  3829 	 *
  4089 	 *
  3830 	 * @since 2.5.0
  4090 	 * @since 2.5.0
  3831 	 * @since 4.3.0 Added the `$doctype` parameter.
  4091 	 * @since 4.3.0 Added the `$doctype` parameter.
  3832 	 *
  4092 	 *
  3833 	 * @param string $output A space-separated list of language attributes.
  4093 	 * @param string $output A space-separated list of language attributes.
  3834 	 * @param string $doctype The type of html document (xhtml|html).
  4094 	 * @param string $doctype The type of HTML document (xhtml|html).
  3835 	 */
  4095 	 */
  3836 	return apply_filters( 'language_attributes', $output, $doctype );
  4096 	return apply_filters( 'language_attributes', $output, $doctype );
  3837 }
  4097 }
  3838 
  4098 
  3839 /**
  4099 /**
  3840  * Displays the language attributes for the html tag.
  4100  * Displays the language attributes for the 'html' tag.
  3841  *
  4101  *
  3842  * Builds up a set of html attributes containing the text direction and language
  4102  * Builds up a set of HTML attributes containing the text direction and language
  3843  * information for the page.
  4103  * information for the page.
  3844  *
  4104  *
  3845  * @since 2.1.0
  4105  * @since 2.1.0
  3846  * @since 4.3.0 Converted into a wrapper for get_language_attributes().
  4106  * @since 4.3.0 Converted into a wrapper for get_language_attributes().
  3847  *
  4107  *
  3848  * @param string $doctype Optional. The type of html document. Accepts 'xhtml' or 'html'. Default 'html'.
  4108  * @param string $doctype Optional. The type of HTML document. Accepts 'xhtml' or 'html'. Default 'html'.
  3849  */
  4109  */
  3850 function language_attributes( $doctype = 'html' ) {
  4110 function language_attributes( $doctype = 'html' ) {
  3851 	echo get_language_attributes( $doctype );
  4111 	echo get_language_attributes( $doctype );
  3852 }
  4112 }
  3853 
  4113 
  3898  * anchor tag.
  4158  * anchor tag.
  3899  *
  4159  *
  3900  * @since 2.1.0
  4160  * @since 2.1.0
  3901  * @since 4.9.0 Added the `aria_current` argument.
  4161  * @since 4.9.0 Added the `aria_current` argument.
  3902  *
  4162  *
  3903  * @global WP_Query   $wp_query
  4163  * @global WP_Query   $wp_query   WordPress Query object.
  3904  * @global WP_Rewrite $wp_rewrite
  4164  * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
  3905  *
  4165  *
  3906  * @param string|array $args {
  4166  * @param string|array $args {
  3907  *     Optional. Array or string of arguments for generating paginated links for archives.
  4167  *     Optional. Array or string of arguments for generating paginated links for archives.
  3908  *
  4168  *
  3909  *     @type string $base               Base of the paginated url. Default empty.
  4169  *     @type string $base               Base of the paginated url. Default empty.
  3925  *     @type array  $add_args           An array of query args to add. Default false.
  4185  *     @type array  $add_args           An array of query args to add. Default false.
  3926  *     @type string $add_fragment       A string to append to each link. Default empty.
  4186  *     @type string $add_fragment       A string to append to each link. Default empty.
  3927  *     @type string $before_page_number A string to appear before the page number. Default empty.
  4187  *     @type string $before_page_number A string to appear before the page number. Default empty.
  3928  *     @type string $after_page_number  A string to append after the page number. Default empty.
  4188  *     @type string $after_page_number  A string to append after the page number. Default empty.
  3929  * }
  4189  * }
  3930  * @return string|array|void String of page links or array of page links.
  4190  * @return string|array|void String of page links or array of page links, depending on 'type' argument.
       
  4191  *                           Void if total number of pages is less than 2.
  3931  */
  4192  */
  3932 function paginate_links( $args = '' ) {
  4193 function paginate_links( $args = '' ) {
  3933 	global $wp_query, $wp_rewrite;
  4194 	global $wp_query, $wp_rewrite;
  3934 
  4195 
  3935 	// Setting up default values based on the current URL.
  4196 	// Setting up default values based on the current URL.
  3946 	// URL base depends on permalink settings.
  4207 	// URL base depends on permalink settings.
  3947 	$format  = $wp_rewrite->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : '';
  4208 	$format  = $wp_rewrite->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : '';
  3948 	$format .= $wp_rewrite->using_permalinks() ? user_trailingslashit( $wp_rewrite->pagination_base . '/%#%', 'paged' ) : '?paged=%#%';
  4209 	$format .= $wp_rewrite->using_permalinks() ? user_trailingslashit( $wp_rewrite->pagination_base . '/%#%', 'paged' ) : '?paged=%#%';
  3949 
  4210 
  3950 	$defaults = array(
  4211 	$defaults = array(
  3951 		'base'               => $pagenum_link, // http://example.com/all_posts.php%_% : %_% is replaced by format (below)
  4212 		'base'               => $pagenum_link, // http://example.com/all_posts.php%_% : %_% is replaced by format (below).
  3952 		'format'             => $format, // ?page=%#% : %#% is replaced by the page number
  4213 		'format'             => $format, // ?page=%#% : %#% is replaced by the page number.
  3953 		'total'              => $total,
  4214 		'total'              => $total,
  3954 		'current'            => $current,
  4215 		'current'            => $current,
  3955 		'aria_current'       => 'page',
  4216 		'aria_current'       => 'page',
  3956 		'show_all'           => false,
  4217 		'show_all'           => false,
  3957 		'prev_next'          => true,
  4218 		'prev_next'          => true,
  3958 		'prev_text'          => __( '&laquo; Previous' ),
  4219 		'prev_text'          => __( '&laquo; Previous' ),
  3959 		'next_text'          => __( 'Next &raquo;' ),
  4220 		'next_text'          => __( 'Next &raquo;' ),
  3960 		'end_size'           => 1,
  4221 		'end_size'           => 1,
  3961 		'mid_size'           => 2,
  4222 		'mid_size'           => 2,
  3962 		'type'               => 'plain',
  4223 		'type'               => 'plain',
  3963 		'add_args'           => array(), // array of query args to add
  4224 		'add_args'           => array(), // Array of query args to add.
  3964 		'add_fragment'       => '',
  4225 		'add_fragment'       => '',
  3965 		'before_page_number' => '',
  4226 		'before_page_number' => '',
  3966 		'after_page_number'  => '',
  4227 		'after_page_number'  => '',
  3967 	);
  4228 	);
  3968 
  4229 
  3988 		}
  4249 		}
  3989 
  4250 
  3990 		$args['add_args'] = array_merge( $args['add_args'], urlencode_deep( $url_query_args ) );
  4251 		$args['add_args'] = array_merge( $args['add_args'], urlencode_deep( $url_query_args ) );
  3991 	}
  4252 	}
  3992 
  4253 
  3993 	// Who knows what else people pass in $args
  4254 	// Who knows what else people pass in $args.
  3994 	$total = (int) $args['total'];
  4255 	$total = (int) $args['total'];
  3995 	if ( $total < 2 ) {
  4256 	if ( $total < 2 ) {
  3996 		return;
  4257 		return;
  3997 	}
  4258 	}
  3998 	$current  = (int) $args['current'];
  4259 	$current  = (int) $args['current'];
  3999 	$end_size = (int) $args['end_size']; // Out of bounds?  Make it the default.
  4260 	$end_size = (int) $args['end_size']; // Out of bounds? Make it the default.
  4000 	if ( $end_size < 1 ) {
  4261 	if ( $end_size < 1 ) {
  4001 		$end_size = 1;
  4262 		$end_size = 1;
  4002 	}
  4263 	}
  4003 	$mid_size = (int) $args['mid_size'];
  4264 	$mid_size = (int) $args['mid_size'];
  4004 	if ( $mid_size < 0 ) {
  4265 	if ( $mid_size < 0 ) {
  4005 		$mid_size = 2;
  4266 		$mid_size = 2;
  4006 	}
  4267 	}
       
  4268 
  4007 	$add_args   = $args['add_args'];
  4269 	$add_args   = $args['add_args'];
  4008 	$r          = '';
  4270 	$r          = '';
  4009 	$page_links = array();
  4271 	$page_links = array();
  4010 	$dots       = false;
  4272 	$dots       = false;
  4011 
  4273 
  4015 		if ( $add_args ) {
  4277 		if ( $add_args ) {
  4016 			$link = add_query_arg( $add_args, $link );
  4278 			$link = add_query_arg( $add_args, $link );
  4017 		}
  4279 		}
  4018 		$link .= $args['add_fragment'];
  4280 		$link .= $args['add_fragment'];
  4019 
  4281 
  4020 		/**
  4282 		$page_links[] = sprintf(
  4021 		 * Filters the paginated links for the given archive pages.
  4283 			'<a class="prev page-numbers" href="%s">%s</a>',
  4022 		 *
  4284 			/**
  4023 		 * @since 3.0.0
  4285 			 * Filters the paginated links for the given archive pages.
  4024 		 *
  4286 			 *
  4025 		 * @param string $link The paginated link URL.
  4287 			 * @since 3.0.0
  4026 		 */
  4288 			 *
  4027 		$page_links[] = '<a class="prev page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $args['prev_text'] . '</a>';
  4289 			 * @param string $link The paginated link URL.
       
  4290 			 */
       
  4291 			esc_url( apply_filters( 'paginate_links', $link ) ),
       
  4292 			$args['prev_text']
       
  4293 		);
  4028 	endif;
  4294 	endif;
       
  4295 
  4029 	for ( $n = 1; $n <= $total; $n++ ) :
  4296 	for ( $n = 1; $n <= $total; $n++ ) :
  4030 		if ( $n == $current ) :
  4297 		if ( $n == $current ) :
  4031 			$page_links[] = "<span aria-current='" . esc_attr( $args['aria_current'] ) . "' class='page-numbers current'>" . $args['before_page_number'] . number_format_i18n( $n ) . $args['after_page_number'] . '</span>';
  4298 			$page_links[] = sprintf(
  4032 			$dots         = true;
  4299 				'<span aria-current="%s" class="page-numbers current">%s</span>',
       
  4300 				esc_attr( $args['aria_current'] ),
       
  4301 				$args['before_page_number'] . number_format_i18n( $n ) . $args['after_page_number']
       
  4302 			);
       
  4303 
       
  4304 			$dots = true;
  4033 		else :
  4305 		else :
  4034 			if ( $args['show_all'] || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) :
  4306 			if ( $args['show_all'] || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) :
  4035 				$link = str_replace( '%_%', 1 == $n ? '' : $args['format'], $args['base'] );
  4307 				$link = str_replace( '%_%', 1 == $n ? '' : $args['format'], $args['base'] );
  4036 				$link = str_replace( '%#%', $n, $link );
  4308 				$link = str_replace( '%#%', $n, $link );
  4037 				if ( $add_args ) {
  4309 				if ( $add_args ) {
  4038 					$link = add_query_arg( $add_args, $link );
  4310 					$link = add_query_arg( $add_args, $link );
  4039 				}
  4311 				}
  4040 				$link .= $args['add_fragment'];
  4312 				$link .= $args['add_fragment'];
  4041 
  4313 
  4042 				/** This filter is documented in wp-includes/general-template.php */
  4314 				$page_links[] = sprintf(
  4043 				$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>';
  4315 					'<a class="page-numbers" href="%s">%s</a>',
  4044 				$dots         = true;
  4316 					/** This filter is documented in wp-includes/general-template.php */
       
  4317 					esc_url( apply_filters( 'paginate_links', $link ) ),
       
  4318 					$args['before_page_number'] . number_format_i18n( $n ) . $args['after_page_number']
       
  4319 				);
       
  4320 
       
  4321 				$dots = true;
  4045 			elseif ( $dots && ! $args['show_all'] ) :
  4322 			elseif ( $dots && ! $args['show_all'] ) :
  4046 				$page_links[] = '<span class="page-numbers dots">' . __( '&hellip;' ) . '</span>';
  4323 				$page_links[] = '<span class="page-numbers dots">' . __( '&hellip;' ) . '</span>';
  4047 				$dots         = false;
  4324 
       
  4325 				$dots = false;
  4048 			endif;
  4326 			endif;
  4049 		endif;
  4327 		endif;
  4050 	endfor;
  4328 	endfor;
       
  4329 
  4051 	if ( $args['prev_next'] && $current && $current < $total ) :
  4330 	if ( $args['prev_next'] && $current && $current < $total ) :
  4052 		$link = str_replace( '%_%', $args['format'], $args['base'] );
  4331 		$link = str_replace( '%_%', $args['format'], $args['base'] );
  4053 		$link = str_replace( '%#%', $current + 1, $link );
  4332 		$link = str_replace( '%#%', $current + 1, $link );
  4054 		if ( $add_args ) {
  4333 		if ( $add_args ) {
  4055 			$link = add_query_arg( $add_args, $link );
  4334 			$link = add_query_arg( $add_args, $link );
  4056 		}
  4335 		}
  4057 		$link .= $args['add_fragment'];
  4336 		$link .= $args['add_fragment'];
  4058 
  4337 
  4059 		/** This filter is documented in wp-includes/general-template.php */
  4338 		$page_links[] = sprintf(
  4060 		$page_links[] = '<a class="next page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $args['next_text'] . '</a>';
  4339 			'<a class="next page-numbers" href="%s">%s</a>',
       
  4340 			/** This filter is documented in wp-includes/general-template.php */
       
  4341 			esc_url( apply_filters( 'paginate_links', $link ) ),
       
  4342 			$args['next_text']
       
  4343 		);
  4061 	endif;
  4344 	endif;
       
  4345 
  4062 	switch ( $args['type'] ) {
  4346 	switch ( $args['type'] ) {
  4063 		case 'array':
  4347 		case 'array':
  4064 			return $page_links;
  4348 			return $page_links;
  4065 
  4349 
  4066 		case 'list':
  4350 		case 'list':
  4071 
  4355 
  4072 		default:
  4356 		default:
  4073 			$r = join( "\n", $page_links );
  4357 			$r = join( "\n", $page_links );
  4074 			break;
  4358 			break;
  4075 	}
  4359 	}
       
  4360 
  4076 	return $r;
  4361 	return $r;
  4077 }
  4362 }
  4078 
  4363 
  4079 /**
  4364 /**
  4080  * Registers an admin color scheme css file.
  4365  * Registers an admin color scheme css file.
  4141 			'focus'   => '#00a0d2',
  4426 			'focus'   => '#00a0d2',
  4142 			'current' => '#fff',
  4427 			'current' => '#fff',
  4143 		)
  4428 		)
  4144 	);
  4429 	);
  4145 
  4430 
  4146 	// Other color schemes are not available when running out of src
       
  4147 	if ( false !== strpos( get_bloginfo( 'version' ), '-src' ) ) {
       
  4148 		return;
       
  4149 	}
       
  4150 
       
  4151 	wp_admin_css_color(
  4431 	wp_admin_css_color(
  4152 		'light',
  4432 		'light',
  4153 		_x( 'Light', 'admin color scheme' ),
  4433 		_x( 'Light', 'admin color scheme' ),
  4154 		admin_url( "css/colors/light/colors$suffix.css" ),
  4434 		admin_url( "css/colors/light/colors$suffix.css" ),
  4155 		array( '#e5e5e5', '#999', '#d64e07', '#04a4cc' ),
  4435 		array( '#e5e5e5', '#999', '#d64e07', '#04a4cc' ),
  4159 			'current' => '#ccc',
  4439 			'current' => '#ccc',
  4160 		)
  4440 		)
  4161 	);
  4441 	);
  4162 
  4442 
  4163 	wp_admin_css_color(
  4443 	wp_admin_css_color(
       
  4444 		'modern',
       
  4445 		_x( 'Modern', 'admin color scheme' ),
       
  4446 		admin_url( "css/colors/modern/colors$suffix.css" ),
       
  4447 		array( '#1e1e1e', '#3858e9', '#33f078' ),
       
  4448 		array(
       
  4449 			'base'    => '#f3f1f1',
       
  4450 			'focus'   => '#fff',
       
  4451 			'current' => '#fff',
       
  4452 		)
       
  4453 	);
       
  4454 
       
  4455 	wp_admin_css_color(
  4164 		'blue',
  4456 		'blue',
  4165 		_x( 'Blue', 'admin color scheme' ),
  4457 		_x( 'Blue', 'admin color scheme' ),
  4166 		admin_url( "css/colors/blue/colors$suffix.css" ),
  4458 		admin_url( "css/colors/blue/colors$suffix.css" ),
  4167 		array( '#096484', '#4796b3', '#52accc', '#74B6CE' ),
  4459 		array( '#096484', '#4796b3', '#52accc', '#74B6CE' ),
  4168 		array(
  4460 		array(
  4282  * @param string $file       Optional. Style handle name or file name (without ".css" extension) relative
  4574  * @param string $file       Optional. Style handle name or file name (without ".css" extension) relative
  4283  *                           to wp-admin/. Defaults to 'wp-admin'.
  4575  *                           to wp-admin/. Defaults to 'wp-admin'.
  4284  * @param bool   $force_echo Optional. Force the stylesheet link to be printed rather than enqueued.
  4576  * @param bool   $force_echo Optional. Force the stylesheet link to be printed rather than enqueued.
  4285  */
  4577  */
  4286 function wp_admin_css( $file = 'wp-admin', $force_echo = false ) {
  4578 function wp_admin_css( $file = 'wp-admin', $force_echo = false ) {
  4287 	// For backward compatibility
  4579 	// For backward compatibility.
  4288 	$handle = 0 === strpos( $file, 'css/' ) ? substr( $file, 4 ) : $file;
  4580 	$handle = 0 === strpos( $file, 'css/' ) ? substr( $file, 4 ) : $file;
  4289 
  4581 
  4290 	if ( wp_styles()->query( $handle ) ) {
  4582 	if ( wp_styles()->query( $handle ) ) {
  4291 		if ( $force_echo || did_action( 'wp_print_styles' ) ) { // we already printed the style queue. Print this one immediately
  4583 		if ( $force_echo || did_action( 'wp_print_styles' ) ) {
       
  4584 			// We already printed the style queue. Print this one immediately.
  4292 			wp_print_styles( $handle );
  4585 			wp_print_styles( $handle );
  4293 		} else { // Add to style queue
  4586 		} else {
       
  4587 			// Add to style queue.
  4294 			wp_enqueue_style( $handle );
  4588 			wp_enqueue_style( $handle );
  4295 		}
  4589 		}
  4296 		return;
  4590 		return;
  4297 	}
  4591 	}
       
  4592 
       
  4593 	$stylesheet_link = sprintf(
       
  4594 		"<link rel='stylesheet' href='%s' type='text/css' />\n",
       
  4595 		esc_url( wp_admin_css_uri( $file ) )
       
  4596 	);
  4298 
  4597 
  4299 	/**
  4598 	/**
  4300 	 * Filters the stylesheet link to the specified CSS file.
  4599 	 * Filters the stylesheet link to the specified CSS file.
  4301 	 *
  4600 	 *
  4302 	 * If the site is set to display right-to-left, the RTL stylesheet link
  4601 	 * If the site is set to display right-to-left, the RTL stylesheet link
  4305 	 * @since 2.3.0
  4604 	 * @since 2.3.0
  4306 	 * @param string $stylesheet_link HTML link element for the stylesheet.
  4605 	 * @param string $stylesheet_link HTML link element for the stylesheet.
  4307 	 * @param string $file            Style handle name or filename (without ".css" extension)
  4606 	 * @param string $file            Style handle name or filename (without ".css" extension)
  4308 	 *                                relative to wp-admin/. Defaults to 'wp-admin'.
  4607 	 *                                relative to wp-admin/. Defaults to 'wp-admin'.
  4309 	 */
  4608 	 */
  4310 	echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . esc_url( wp_admin_css_uri( $file ) ) . "' type='text/css' />\n", $file );
  4609 	echo apply_filters( 'wp_admin_css', $stylesheet_link, $file );
  4311 
  4610 
  4312 	if ( function_exists( 'is_rtl' ) && is_rtl() ) {
  4611 	if ( function_exists( 'is_rtl' ) && is_rtl() ) {
       
  4612 		$rtl_stylesheet_link = sprintf(
       
  4613 			"<link rel='stylesheet' href='%s' type='text/css' />\n",
       
  4614 			esc_url( wp_admin_css_uri( "$file-rtl" ) )
       
  4615 		);
       
  4616 
  4313 		/** This filter is documented in wp-includes/general-template.php */
  4617 		/** This filter is documented in wp-includes/general-template.php */
  4314 		echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . esc_url( wp_admin_css_uri( "$file-rtl" ) ) . "' type='text/css' />\n", "$file-rtl" );
  4618 		echo apply_filters( 'wp_admin_css', $rtl_stylesheet_link, "$file-rtl" );
  4315 	}
  4619 	}
  4316 }
  4620 }
  4317 
  4621 
  4318 /**
  4622 /**
  4319  * Enqueues the default ThickBox js and css.
  4623  * Enqueues the default ThickBox js and css.
  4432 			break;
  4736 			break;
  4433 		case 'comment':
  4737 		case 'comment':
  4434 			$gen = '<!-- generator="WordPress/' . esc_attr( get_bloginfo( 'version' ) ) . '" -->';
  4738 			$gen = '<!-- generator="WordPress/' . esc_attr( get_bloginfo( 'version' ) ) . '" -->';
  4435 			break;
  4739 			break;
  4436 		case 'export':
  4740 		case 'export':
  4437 			$gen = '<!-- generator="WordPress/' . esc_attr( get_bloginfo_rss( 'version' ) ) . '" created="' . date( 'Y-m-d H:i' ) . '" -->';
  4741 			$gen = '<!-- generator="WordPress/' . esc_attr( get_bloginfo_rss( 'version' ) ) . '" created="' . gmdate( 'Y-m-d H:i' ) . '" -->';
  4438 			break;
  4742 			break;
  4439 	}
  4743 	}
  4440 
  4744 
  4441 	/**
  4745 	/**
  4442 	 * Filters the HTML for the retrieved generator type.
  4746 	 * Filters the HTML for the retrieved generator type.
  4451 	 */
  4755 	 */
  4452 	return apply_filters( "get_the_generator_{$type}", $gen, $type );
  4756 	return apply_filters( "get_the_generator_{$type}", $gen, $type );
  4453 }
  4757 }
  4454 
  4758 
  4455 /**
  4759 /**
  4456  * Outputs the html checked attribute.
  4760  * Outputs the HTML checked attribute.
  4457  *
  4761  *
  4458  * Compares the first two arguments and if identical marks as checked
  4762  * Compares the first two arguments and if identical marks as checked
  4459  *
  4763  *
  4460  * @since 1.0.0
  4764  * @since 1.0.0
  4461  *
  4765  *
  4462  * @param mixed $checked One of the values to compare
  4766  * @param mixed $checked One of the values to compare
  4463  * @param mixed $current (true) The other value to compare if not just true
  4767  * @param mixed $current (true) The other value to compare if not just true
  4464  * @param bool  $echo    Whether to echo or just return the string
  4768  * @param bool  $echo    Whether to echo or just return the string
  4465  * @return string html attribute or empty string
  4769  * @return string HTML attribute or empty string
  4466  */
  4770  */
  4467 function checked( $checked, $current = true, $echo = true ) {
  4771 function checked( $checked, $current = true, $echo = true ) {
  4468 	return __checked_selected_helper( $checked, $current, $echo, 'checked' );
  4772 	return __checked_selected_helper( $checked, $current, $echo, 'checked' );
  4469 }
  4773 }
  4470 
  4774 
  4471 /**
  4775 /**
  4472  * Outputs the html selected attribute.
  4776  * Outputs the HTML selected attribute.
  4473  *
  4777  *
  4474  * Compares the first two arguments and if identical marks as selected
  4778  * Compares the first two arguments and if identical marks as selected
  4475  *
  4779  *
  4476  * @since 1.0.0
  4780  * @since 1.0.0
  4477  *
  4781  *
  4478  * @param mixed $selected One of the values to compare
  4782  * @param mixed $selected One of the values to compare
  4479  * @param mixed $current  (true) The other value to compare if not just true
  4783  * @param mixed $current  (true) The other value to compare if not just true
  4480  * @param bool  $echo     Whether to echo or just return the string
  4784  * @param bool  $echo     Whether to echo or just return the string
  4481  * @return string html attribute or empty string
  4785  * @return string HTML attribute or empty string
  4482  */
  4786  */
  4483 function selected( $selected, $current = true, $echo = true ) {
  4787 function selected( $selected, $current = true, $echo = true ) {
  4484 	return __checked_selected_helper( $selected, $current, $echo, 'selected' );
  4788 	return __checked_selected_helper( $selected, $current, $echo, 'selected' );
  4485 }
  4789 }
  4486 
  4790 
  4487 /**
  4791 /**
  4488  * Outputs the html disabled attribute.
  4792  * Outputs the HTML disabled attribute.
  4489  *
  4793  *
  4490  * Compares the first two arguments and if identical marks as disabled
  4794  * Compares the first two arguments and if identical marks as disabled
  4491  *
  4795  *
  4492  * @since 3.0.0
  4796  * @since 3.0.0
  4493  *
  4797  *
  4494  * @param mixed $disabled One of the values to compare
  4798  * @param mixed $disabled One of the values to compare
  4495  * @param mixed $current  (true) The other value to compare if not just true
  4799  * @param mixed $current  (true) The other value to compare if not just true
  4496  * @param bool  $echo     Whether to echo or just return the string
  4800  * @param bool  $echo     Whether to echo or just return the string
  4497  * @return string html attribute or empty string
  4801  * @return string HTML attribute or empty string
  4498  */
  4802  */
  4499 function disabled( $disabled, $current = true, $echo = true ) {
  4803 function disabled( $disabled, $current = true, $echo = true ) {
  4500 	return __checked_selected_helper( $disabled, $current, $echo, 'disabled' );
  4804 	return __checked_selected_helper( $disabled, $current, $echo, 'disabled' );
  4501 }
  4805 }
  4502 
  4806 
  4503 /**
  4807 /**
  4504  * Outputs the html readonly attribute.
  4808  * Outputs the HTML readonly attribute.
  4505  *
  4809  *
  4506  * Compares the first two arguments and if identical marks as readonly
  4810  * Compares the first two arguments and if identical marks as readonly
  4507  *
  4811  *
  4508  * @since 4.9.0
  4812  * @since 4.9.0
  4509  *
  4813  *
  4510  * @param mixed $readonly One of the values to compare
  4814  * @param mixed $readonly One of the values to compare
  4511  * @param mixed $current  (true) The other value to compare if not just true
  4815  * @param mixed $current  (true) The other value to compare if not just true
  4512  * @param bool  $echo     Whether to echo or just return the string
  4816  * @param bool  $echo     Whether to echo or just return the string
  4513  * @return string html attribute or empty string
  4817  * @return string HTML attribute or empty string
  4514  */
  4818  */
  4515 function readonly( $readonly, $current = true, $echo = true ) {
  4819 function readonly( $readonly, $current = true, $echo = true ) {
  4516 	return __checked_selected_helper( $readonly, $current, $echo, 'readonly' );
  4820 	return __checked_selected_helper( $readonly, $current, $echo, 'readonly' );
  4517 }
  4821 }
  4518 
  4822 
  4526  *
  4830  *
  4527  * @param mixed  $helper  One of the values to compare
  4831  * @param mixed  $helper  One of the values to compare
  4528  * @param mixed  $current (true) The other value to compare if not just true
  4832  * @param mixed  $current (true) The other value to compare if not just true
  4529  * @param bool   $echo    Whether to echo or just return the string
  4833  * @param bool   $echo    Whether to echo or just return the string
  4530  * @param string $type    The type of checked|selected|disabled|readonly we are doing
  4834  * @param string $type    The type of checked|selected|disabled|readonly we are doing
  4531  * @return string html attribute or empty string
  4835  * @return string HTML attribute or empty string
  4532  */
  4836  */
  4533 function __checked_selected_helper( $helper, $current, $echo, $type ) {
  4837 function __checked_selected_helper( $helper, $current, $echo, $type ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore
  4534 	if ( (string) $helper === (string) $current ) {
  4838 	if ( (string) $helper === (string) $current ) {
  4535 		$result = " $type='$type'";
  4839 		$result = " $type='$type'";
  4536 	} else {
  4840 	} else {
  4537 		$result = '';
  4841 		$result = '';
  4538 	}
  4842 	}
  4550  * Outputs the nonce used in the heartbeat XHR
  4854  * Outputs the nonce used in the heartbeat XHR
  4551  *
  4855  *
  4552  * @since 3.6.0
  4856  * @since 3.6.0
  4553  *
  4857  *
  4554  * @param array $settings
  4858  * @param array $settings
  4555  * @return array $settings
  4859  * @return array Heartbeat settings.
  4556  */
  4860  */
  4557 function wp_heartbeat_settings( $settings ) {
  4861 function wp_heartbeat_settings( $settings ) {
  4558 	if ( ! is_admin() ) {
  4862 	if ( ! is_admin() ) {
  4559 		$settings['ajaxurl'] = admin_url( 'admin-ajax.php', 'relative' );
  4863 		$settings['ajaxurl'] = admin_url( 'admin-ajax.php', 'relative' );
  4560 	}
  4864 	}