wp/wp-includes/general-template.php
changeset 9 177826044cd9
parent 7 cf61fcea0001
child 16 a86126ab1dd4
equal deleted inserted replaced
8:c7c34916027a 9:177826044cd9
    29 	 * @param string|null $name Name of the specific header file to use. null for the default header.
    29 	 * @param string|null $name Name of the specific header file to use. null for the default header.
    30 	 */
    30 	 */
    31 	do_action( 'get_header', $name );
    31 	do_action( 'get_header', $name );
    32 
    32 
    33 	$templates = array();
    33 	$templates = array();
    34 	$name = (string) $name;
    34 	$name      = (string) $name;
    35 	if ( '' !== $name ) {
    35 	if ( '' !== $name ) {
    36 		$templates[] = "header-{$name}.php";
    36 		$templates[] = "header-{$name}.php";
    37 	}
    37 	}
    38 
    38 
    39 	$templates[] = 'header.php';
    39 	$templates[] = 'header.php';
    64 	 * @param string|null $name Name of the specific footer file to use. null for the default footer.
    64 	 * @param string|null $name Name of the specific footer file to use. null for the default footer.
    65 	 */
    65 	 */
    66 	do_action( 'get_footer', $name );
    66 	do_action( 'get_footer', $name );
    67 
    67 
    68 	$templates = array();
    68 	$templates = array();
    69 	$name = (string) $name;
    69 	$name      = (string) $name;
    70 	if ( '' !== $name ) {
    70 	if ( '' !== $name ) {
    71 		$templates[] = "footer-{$name}.php";
    71 		$templates[] = "footer-{$name}.php";
    72 	}
    72 	}
    73 
    73 
    74 	$templates[]    = 'footer.php';
    74 	$templates[] = 'footer.php';
    75 
    75 
    76 	locate_template( $templates, true );
    76 	locate_template( $templates, true );
    77 }
    77 }
    78 
    78 
    79 /**
    79 /**
    99 	 * @param string|null $name Name of the specific sidebar file to use. null for the default sidebar.
    99 	 * @param string|null $name Name of the specific sidebar file to use. null for the default sidebar.
   100 	 */
   100 	 */
   101 	do_action( 'get_sidebar', $name );
   101 	do_action( 'get_sidebar', $name );
   102 
   102 
   103 	$templates = array();
   103 	$templates = array();
   104 	$name = (string) $name;
   104 	$name      = (string) $name;
   105 	if ( '' !== $name )
   105 	if ( '' !== $name ) {
   106 		$templates[] = "sidebar-{$name}.php";
   106 		$templates[] = "sidebar-{$name}.php";
       
   107 	}
   107 
   108 
   108 	$templates[] = 'sidebar.php';
   109 	$templates[] = 'sidebar.php';
   109 
   110 
   110 	locate_template( $templates, true );
   111 	locate_template( $templates, true );
   111 }
   112 }
   144 	 * @param string|null $name The name of the specialized template.
   145 	 * @param string|null $name The name of the specialized template.
   145 	 */
   146 	 */
   146 	do_action( "get_template_part_{$slug}", $slug, $name );
   147 	do_action( "get_template_part_{$slug}", $slug, $name );
   147 
   148 
   148 	$templates = array();
   149 	$templates = array();
   149 	$name = (string) $name;
   150 	$name      = (string) $name;
   150 	if ( '' !== $name )
   151 	if ( '' !== $name ) {
   151 		$templates[] = "{$slug}-{$name}.php";
   152 		$templates[] = "{$slug}-{$name}.php";
       
   153 	}
   152 
   154 
   153 	$templates[] = "{$slug}.php";
   155 	$templates[] = "{$slug}.php";
   154 
   156 
   155 	locate_template($templates, true, false);
   157 	/**
       
   158 	 * Fires before a template part is loaded.
       
   159 	 *
       
   160 	 * @since 5.2.0
       
   161 	 *
       
   162 	 * @param string   $slug      The slug name for the generic template.
       
   163 	 * @param string   $name      The name of the specialized template.
       
   164 	 * @param string[] $templates Array of template files to search for, in order.
       
   165 	 */
       
   166 	do_action( 'get_template_part', $slug, $name, $templates );
       
   167 
       
   168 	locate_template( $templates, true, false );
   156 }
   169 }
   157 
   170 
   158 /**
   171 /**
   159  * Display search form.
   172  * Display search form.
   160  *
   173  *
   171  * {@see 'pre_get_search_form'}. This can be useful for outputting JavaScript that the
   184  * {@see 'pre_get_search_form'}. This can be useful for outputting JavaScript that the
   172  * search relies on or various formatting that applies to the beginning of the
   185  * search relies on or various formatting that applies to the beginning of the
   173  * search. To give a few examples of what it can be used for.
   186  * search. To give a few examples of what it can be used for.
   174  *
   187  *
   175  * @since 2.7.0
   188  * @since 2.7.0
   176  *
   189  * @since 5.2.0 The $args array parameter was added in place of an $echo boolean flag.
   177  * @param bool $echo Default to echo and not return the form.
   190  *
   178  * @return string|void String when $echo is false.
   191  * @param array $args {
   179  */
   192  *     Optional. Array of display arguments.
   180 function get_search_form( $echo = true ) {
   193  *
       
   194  *     @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
       
   196  *                              multiple search forms on the same page and improve
       
   197  *                              accessibility. Default empty.
       
   198  * }
       
   199  * @return string|void String when the $echo param is false.
       
   200  */
       
   201 function get_search_form( $args = array() ) {
   181 	/**
   202 	/**
   182 	 * Fires before the search form is retrieved, at the start of get_search_form().
   203 	 * Fires before the search form is retrieved, at the start of get_search_form().
   183 	 *
   204 	 *
   184 	 * @since 2.7.0 as 'get_search_form' action.
   205 	 * @since 2.7.0 as 'get_search_form' action.
   185 	 * @since 3.6.0
   206 	 * @since 3.6.0
   186 	 *
   207 	 *
   187 	 * @link https://core.trac.wordpress.org/ticket/19321
   208 	 * @link https://core.trac.wordpress.org/ticket/19321
   188 	 */
   209 	 */
   189 	do_action( 'pre_get_search_form' );
   210 	do_action( 'pre_get_search_form' );
       
   211 
       
   212 	$echo = true;
       
   213 
       
   214 	if ( ! is_array( $args ) ) {
       
   215 		/*
       
   216 		 * Back compat: to ensure previous uses of get_search_form() continue to
       
   217 		 * function as expected, we handle a value for the boolean $echo param removed
       
   218 		 * in 5.2.0. Then we deal with the $args array and cast its defaults.
       
   219 		 */
       
   220 		$echo = (bool) $args;
       
   221 
       
   222 		// Set an empty array and allow default arguments to take over.
       
   223 		$args = array();
       
   224 	}
       
   225 
       
   226 	// Defaults are to echo and to output no custom label on the form.
       
   227 	$defaults = array(
       
   228 		'echo'       => $echo,
       
   229 		'aria_label' => '',
       
   230 	);
       
   231 
       
   232 	$args = wp_parse_args( $args, $defaults );
       
   233 
       
   234 	/**
       
   235 	 * Filters the array of arguments used when generating the search form.
       
   236 	 *
       
   237 	 * @since 5.2.0
       
   238 	 *
       
   239 	 * @param array $args The array of arguments for building the search form.
       
   240 	 */
       
   241 	$args = apply_filters( 'search_form_args', $args );
   190 
   242 
   191 	$format = current_theme_supports( 'html5', 'search-form' ) ? 'html5' : 'xhtml';
   243 	$format = current_theme_supports( 'html5', 'search-form' ) ? 'html5' : 'xhtml';
   192 
   244 
   193 	/**
   245 	/**
   194 	 * Filters the HTML format of the search form.
   246 	 * Filters the HTML format of the search form.
   204 	if ( '' != $search_form_template ) {
   256 	if ( '' != $search_form_template ) {
   205 		ob_start();
   257 		ob_start();
   206 		require( $search_form_template );
   258 		require( $search_form_template );
   207 		$form = ob_get_clean();
   259 		$form = ob_get_clean();
   208 	} else {
   260 	} else {
       
   261 		// Build a string containing an aria-label to use for the search form.
       
   262 		if ( isset( $args['aria_label'] ) && $args['aria_label'] ) {
       
   263 			$aria_label = 'aria-label="' . esc_attr( $args['aria_label'] ) . '" ';
       
   264 		} else {
       
   265 			/*
       
   266 			 * 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.
       
   268 			 */
       
   269 			$aria_label = '';
       
   270 		}
   209 		if ( 'html5' == $format ) {
   271 		if ( 'html5' == $format ) {
   210 			$form = '<form role="search" method="get" class="search-form" action="' . esc_url( home_url( '/' ) ) . '">
   272 			$form = '<form role="search" ' . $aria_label . 'method="get" class="search-form" action="' . esc_url( home_url( '/' ) ) . '">
   211 				<label>
   273 				<label>
   212 					<span class="screen-reader-text">' . _x( 'Search for:', 'label' ) . '</span>
   274 					<span class="screen-reader-text">' . _x( 'Search for:', 'label' ) . '</span>
   213 					<input type="search" class="search-field" placeholder="' . esc_attr_x( 'Search &hellip;', 'placeholder' ) . '" value="' . get_search_query() . '" name="s" />
   275 					<input type="search" class="search-field" placeholder="' . esc_attr_x( 'Search &hellip;', 'placeholder' ) . '" value="' . get_search_query() . '" name="s" />
   214 				</label>
   276 				</label>
   215 				<input type="submit" class="search-submit" value="'. esc_attr_x( 'Search', 'submit button' ) .'" />
   277 				<input type="submit" class="search-submit" value="' . esc_attr_x( 'Search', 'submit button' ) . '" />
   216 			</form>';
   278 			</form>';
   217 		} else {
   279 		} else {
   218 			$form = '<form role="search" method="get" id="searchform" class="searchform" action="' . esc_url( home_url( '/' ) ) . '">
   280 			$form = '<form role="search" ' . $aria_label . 'method="get" id="searchform" class="searchform" action="' . esc_url( home_url( '/' ) ) . '">
   219 				<div>
   281 				<div>
   220 					<label class="screen-reader-text" for="s">' . _x( 'Search for:', 'label' ) . '</label>
   282 					<label class="screen-reader-text" for="s">' . _x( 'Search for:', 'label' ) . '</label>
   221 					<input type="text" value="' . get_search_query() . '" name="s" id="s" />
   283 					<input type="text" value="' . get_search_query() . '" name="s" id="s" />
   222 					<input type="submit" id="searchsubmit" value="'. esc_attr_x( 'Search', 'submit button' ) .'" />
   284 					<input type="submit" id="searchsubmit" value="' . esc_attr_x( 'Search', 'submit button' ) . '" />
   223 				</div>
   285 				</div>
   224 			</form>';
   286 			</form>';
   225 		}
   287 		}
   226 	}
   288 	}
   227 
   289 
   232 	 *
   294 	 *
   233 	 * @param string $form The search form HTML output.
   295 	 * @param string $form The search form HTML output.
   234 	 */
   296 	 */
   235 	$result = apply_filters( 'get_search_form', $form );
   297 	$result = apply_filters( 'get_search_form', $form );
   236 
   298 
   237 	if ( null === $result )
   299 	if ( null === $result ) {
   238 		$result = $form;
   300 		$result = $form;
   239 
   301 	}
   240 	if ( $echo )
   302 
       
   303 	if ( isset( $args['echo'] ) && $args['echo'] ) {
   241 		echo $result;
   304 		echo $result;
   242 	else
   305 	} else {
   243 		return $result;
   306 		return $result;
       
   307 	}
   244 }
   308 }
   245 
   309 
   246 /**
   310 /**
   247  * Display the Log In/Out link.
   311  * Display the Log In/Out link.
   248  *
   312  *
   253  *
   317  *
   254  * @param string $redirect Optional path to redirect to on login/logout.
   318  * @param string $redirect Optional path to redirect to on login/logout.
   255  * @param bool   $echo     Default to echo and not return the link.
   319  * @param bool   $echo     Default to echo and not return the link.
   256  * @return string|void String when retrieving.
   320  * @return string|void String when retrieving.
   257  */
   321  */
   258 function wp_loginout($redirect = '', $echo = true) {
   322 function wp_loginout( $redirect = '', $echo = true ) {
   259 	if ( ! is_user_logged_in() )
   323 	if ( ! is_user_logged_in() ) {
   260 		$link = '<a href="' . esc_url( wp_login_url($redirect) ) . '">' . __('Log in') . '</a>';
   324 		$link = '<a href="' . esc_url( wp_login_url( $redirect ) ) . '">' . __( 'Log in' ) . '</a>';
   261 	else
   325 	} else {
   262 		$link = '<a href="' . esc_url( wp_logout_url($redirect) ) . '">' . __('Log out') . '</a>';
   326 		$link = '<a href="' . esc_url( wp_logout_url( $redirect ) ) . '">' . __( 'Log out' ) . '</a>';
       
   327 	}
   263 
   328 
   264 	if ( $echo ) {
   329 	if ( $echo ) {
   265 		/**
   330 		/**
   266 		 * Filters the HTML output for the Log In/Log Out link.
   331 		 * Filters the HTML output for the Log In/Log Out link.
   267 		 *
   332 		 *
   284  * @since 2.7.0
   349  * @since 2.7.0
   285  *
   350  *
   286  * @param string $redirect Path to redirect to on logout.
   351  * @param string $redirect Path to redirect to on logout.
   287  * @return string The logout URL. Note: HTML-encoded via esc_html() in wp_nonce_url().
   352  * @return string The logout URL. Note: HTML-encoded via esc_html() in wp_nonce_url().
   288  */
   353  */
   289 function wp_logout_url($redirect = '') {
   354 function wp_logout_url( $redirect = '' ) {
   290 	$args = array( 'action' => 'logout' );
   355 	$args = array( 'action' => 'logout' );
   291 	if ( !empty($redirect) ) {
   356 	if ( ! empty( $redirect ) ) {
   292 		$args['redirect_to'] = urlencode( $redirect );
   357 		$args['redirect_to'] = urlencode( $redirect );
   293 	}
   358 	}
   294 
   359 
   295 	$logout_url = add_query_arg($args, site_url('wp-login.php', 'login'));
   360 	$logout_url = add_query_arg( $args, site_url( 'wp-login.php', 'login' ) );
   296 	$logout_url = wp_nonce_url( $logout_url, 'log-out' );
   361 	$logout_url = wp_nonce_url( $logout_url, 'log-out' );
   297 
   362 
   298 	/**
   363 	/**
   299 	 * Filters the logout URL.
   364 	 * Filters the logout URL.
   300 	 *
   365 	 *
   314  * @param string $redirect     Path to redirect to on log in.
   379  * @param string $redirect     Path to redirect to on log in.
   315  * @param bool   $force_reauth Whether to force reauthorization, even if a cookie is present.
   380  * @param bool   $force_reauth Whether to force reauthorization, even if a cookie is present.
   316  *                             Default false.
   381  *                             Default false.
   317  * @return string The login URL. Not HTML-encoded.
   382  * @return string The login URL. Not HTML-encoded.
   318  */
   383  */
   319 function wp_login_url($redirect = '', $force_reauth = false) {
   384 function wp_login_url( $redirect = '', $force_reauth = false ) {
   320 	$login_url = site_url('wp-login.php', 'login');
   385 	$login_url = site_url( 'wp-login.php', 'login' );
   321 
   386 
   322 	if ( !empty($redirect) )
   387 	if ( ! empty( $redirect ) ) {
   323 		$login_url = add_query_arg('redirect_to', urlencode($redirect), $login_url);
   388 		$login_url = add_query_arg( 'redirect_to', urlencode( $redirect ), $login_url );
   324 
   389 	}
   325 	if ( $force_reauth )
   390 
   326 		$login_url = add_query_arg('reauth', '1', $login_url);
   391 	if ( $force_reauth ) {
       
   392 		$login_url = add_query_arg( 'reauth', '1', $login_url );
       
   393 	}
   327 
   394 
   328 	/**
   395 	/**
   329 	 * Filters the login URL.
   396 	 * Filters the login URL.
   330 	 *
   397 	 *
   331 	 * @since 2.8.0
   398 	 * @since 2.8.0
   387  * }
   454  * }
   388  * @return string|void String when retrieving.
   455  * @return string|void String when retrieving.
   389  */
   456  */
   390 function wp_login_form( $args = array() ) {
   457 function wp_login_form( $args = array() ) {
   391 	$defaults = array(
   458 	$defaults = array(
   392 		'echo' => true,
   459 		'echo'           => true,
   393 		// Default 'redirect' value takes the user back to the request URI.
   460 		// Default 'redirect' value takes the user back to the request URI.
   394 		'redirect' => ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'],
   461 		'redirect'       => ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'],
   395 		'form_id' => 'loginform',
   462 		'form_id'        => 'loginform',
   396 		'label_username' => __( 'Username or Email Address' ),
   463 		'label_username' => __( 'Username or Email Address' ),
   397 		'label_password' => __( 'Password' ),
   464 		'label_password' => __( 'Password' ),
   398 		'label_remember' => __( 'Remember Me' ),
   465 		'label_remember' => __( 'Remember Me' ),
   399 		'label_log_in' => __( 'Log In' ),
   466 		'label_log_in'   => __( 'Log In' ),
   400 		'id_username' => 'user_login',
   467 		'id_username'    => 'user_login',
   401 		'id_password' => 'user_pass',
   468 		'id_password'    => 'user_pass',
   402 		'id_remember' => 'rememberme',
   469 		'id_remember'    => 'rememberme',
   403 		'id_submit' => 'wp-submit',
   470 		'id_submit'      => 'wp-submit',
   404 		'remember' => true,
   471 		'remember'       => true,
   405 		'value_username' => '',
   472 		'value_username' => '',
   406 		// Set 'value_remember' to true to default the "Remember me" checkbox to checked.
   473 		// Set 'value_remember' to true to default the "Remember me" checkbox to checked.
   407 		'value_remember' => false,
   474 		'value_remember' => false,
   408 	);
   475 	);
   409 
   476 
   473 				<input type="hidden" name="redirect_to" value="' . esc_url( $args['redirect'] ) . '" />
   540 				<input type="hidden" name="redirect_to" value="' . esc_url( $args['redirect'] ) . '" />
   474 			</p>
   541 			</p>
   475 			' . $login_form_bottom . '
   542 			' . $login_form_bottom . '
   476 		</form>';
   543 		</form>';
   477 
   544 
   478 	if ( $args['echo'] )
   545 	if ( $args['echo'] ) {
   479 		echo $form;
   546 		echo $form;
   480 	else
   547 	} else {
   481 		return $form;
   548 		return $form;
       
   549 	}
   482 }
   550 }
   483 
   551 
   484 /**
   552 /**
   485  * Returns the URL that allows the user to retrieve the lost password
   553  * Returns the URL that allows the user to retrieve the lost password
   486  *
   554  *
   489  * @param string $redirect Path to redirect to on login.
   557  * @param string $redirect Path to redirect to on login.
   490  * @return string Lost password URL.
   558  * @return string Lost password URL.
   491  */
   559  */
   492 function wp_lostpassword_url( $redirect = '' ) {
   560 function wp_lostpassword_url( $redirect = '' ) {
   493 	$args = array( 'action' => 'lostpassword' );
   561 	$args = array( 'action' => 'lostpassword' );
   494 	if ( !empty($redirect) ) {
   562 	if ( ! empty( $redirect ) ) {
   495 		$args['redirect_to'] = urlencode( $redirect );
   563 		$args['redirect_to'] = urlencode( $redirect );
   496 	}
   564 	}
   497 
   565 
   498 	$lostpassword_url = add_query_arg( $args, network_site_url('wp-login.php', 'login') );
   566 	$lostpassword_url = add_query_arg( $args, network_site_url( 'wp-login.php', 'login' ) );
   499 
   567 
   500 	/**
   568 	/**
   501 	 * Filters the Lost Password URL.
   569 	 * Filters the Lost Password URL.
   502 	 *
   570 	 *
   503 	 * @since 2.8.0
   571 	 * @since 2.8.0
   521  * @param bool   $echo   Default to echo and not return the link.
   589  * @param bool   $echo   Default to echo and not return the link.
   522  * @return string|void String when retrieving.
   590  * @return string|void String when retrieving.
   523  */
   591  */
   524 function wp_register( $before = '<li>', $after = '</li>', $echo = true ) {
   592 function wp_register( $before = '<li>', $after = '</li>', $echo = true ) {
   525 	if ( ! is_user_logged_in() ) {
   593 	if ( ! is_user_logged_in() ) {
   526 		if ( get_option('users_can_register') )
   594 		if ( get_option( 'users_can_register' ) ) {
   527 			$link = $before . '<a href="' . esc_url( wp_registration_url() ) . '">' . __('Register') . '</a>' . $after;
   595 			$link = $before . '<a href="' . esc_url( wp_registration_url() ) . '">' . __( 'Register' ) . '</a>' . $after;
   528 		else
   596 		} else {
   529 			$link = '';
   597 			$link = '';
       
   598 		}
   530 	} elseif ( current_user_can( 'read' ) ) {
   599 	} elseif ( current_user_can( 'read' ) ) {
   531 		$link = $before . '<a href="' . admin_url() . '">' . __('Site Admin') . '</a>' . $after;
   600 		$link = $before . '<a href="' . admin_url() . '">' . __( 'Site Admin' ) . '</a>' . $after;
   532 	} else {
   601 	} else {
   533 		$link = '';
   602 		$link = '';
   534 	}
   603 	}
   535 
   604 
   536 	/**
   605 	/**
   607  *   will take precedence over this value
   676  *   will take precedence over this value
   608  * - 'template_url' / 'template_directory' - URL of the active theme's directory. An active
   677  * - 'template_url' / 'template_directory' - URL of the active theme's directory. An active
   609  *   child theme will NOT take precedence over this value
   678  *   child theme will NOT take precedence over this value
   610  * - 'pingback_url' - The pingback XML-RPC file URL (xmlrpc.php)
   679  * - 'pingback_url' - The pingback XML-RPC file URL (xmlrpc.php)
   611  * - 'atom_url' - The Atom feed URL (/feed/atom)
   680  * - 'atom_url' - The Atom feed URL (/feed/atom)
   612  * - 'rdf_url' - The RDF/RSS 1.0 feed URL (/feed/rfd)
   681  * - 'rdf_url' - The RDF/RSS 1.0 feed URL (/feed/rdf)
   613  * - 'rss_url' - The RSS 0.92 feed URL (/feed/rss)
   682  * - 'rss_url' - The RSS 0.92 feed URL (/feed/rss)
   614  * - 'rss2_url' - The RSS 2.0 feed URL (/feed)
   683  * - 'rss2_url' - The RSS 2.0 feed URL (/feed)
   615  * - 'comments_atom_url' - The comments Atom feed URL (/comments/feed)
   684  * - 'comments_atom_url' - The comments Atom feed URL (/comments/feed)
   616  * - 'comments_rss2_url' - The comments RSS 2.0 feed URL (/comments/feed)
   685  * - 'comments_rss2_url' - The comments RSS 2.0 feed URL (/comments/feed)
   617  *
   686  *
   630  * @param string $show   Optional. Site info to retrieve. Default empty (site name).
   699  * @param string $show   Optional. Site info to retrieve. Default empty (site name).
   631  * @param string $filter Optional. How to filter what is retrieved. Default 'raw'.
   700  * @param string $filter Optional. How to filter what is retrieved. Default 'raw'.
   632  * @return string Mostly string values, might be empty.
   701  * @return string Mostly string values, might be empty.
   633  */
   702  */
   634 function get_bloginfo( $show = '', $filter = 'raw' ) {
   703 function get_bloginfo( $show = '', $filter = 'raw' ) {
   635 	switch( $show ) {
   704 	switch ( $show ) {
   636 		case 'home' : // DEPRECATED
   705 		case 'home': // DEPRECATED
   637 		case 'siteurl' : // DEPRECATED
   706 		case 'siteurl': // DEPRECATED
   638 			_deprecated_argument( __FUNCTION__, '2.2.0', sprintf(
   707 			_deprecated_argument(
   639 				/* translators: 1: 'siteurl'/'home' argument, 2: bloginfo() function name, 3: 'url' argument */
   708 				__FUNCTION__,
   640 				__( 'The %1$s option is deprecated for the family of %2$s functions. Use the %3$s option instead.' ),
   709 				'2.2.0',
   641 				'<code>' . $show . '</code>',
   710 				sprintf(
   642 				'<code>bloginfo()</code>',
   711 					/* translators: 1: 'siteurl'/'home' argument, 2: bloginfo() function name, 3: 'url' argument */
   643 				'<code>url</code>'
   712 					__( 'The %1$s option is deprecated for the family of %2$s functions. Use the %3$s option instead.' ),
   644 			) );
   713 					'<code>' . $show . '</code>',
   645 		case 'url' :
   714 					'<code>bloginfo()</code>',
       
   715 					'<code>url</code>'
       
   716 				)
       
   717 			);
       
   718 			// Intentional fall-through to be handled by the 'url' case.
       
   719 		case 'url':
   646 			$output = home_url();
   720 			$output = home_url();
   647 			break;
   721 			break;
   648 		case 'wpurl' :
   722 		case 'wpurl':
   649 			$output = site_url();
   723 			$output = site_url();
   650 			break;
   724 			break;
   651 		case 'description':
   725 		case 'description':
   652 			$output = get_option('blogdescription');
   726 			$output = get_option( 'blogdescription' );
   653 			break;
   727 			break;
   654 		case 'rdf_url':
   728 		case 'rdf_url':
   655 			$output = get_feed_link('rdf');
   729 			$output = get_feed_link( 'rdf' );
   656 			break;
   730 			break;
   657 		case 'rss_url':
   731 		case 'rss_url':
   658 			$output = get_feed_link('rss');
   732 			$output = get_feed_link( 'rss' );
   659 			break;
   733 			break;
   660 		case 'rss2_url':
   734 		case 'rss2_url':
   661 			$output = get_feed_link('rss2');
   735 			$output = get_feed_link( 'rss2' );
   662 			break;
   736 			break;
   663 		case 'atom_url':
   737 		case 'atom_url':
   664 			$output = get_feed_link('atom');
   738 			$output = get_feed_link( 'atom' );
   665 			break;
   739 			break;
   666 		case 'comments_atom_url':
   740 		case 'comments_atom_url':
   667 			$output = get_feed_link('comments_atom');
   741 			$output = get_feed_link( 'comments_atom' );
   668 			break;
   742 			break;
   669 		case 'comments_rss2_url':
   743 		case 'comments_rss2_url':
   670 			$output = get_feed_link('comments_rss2');
   744 			$output = get_feed_link( 'comments_rss2' );
   671 			break;
   745 			break;
   672 		case 'pingback_url':
   746 		case 'pingback_url':
   673 			$output = site_url( 'xmlrpc.php' );
   747 			$output = site_url( 'xmlrpc.php' );
   674 			break;
   748 			break;
   675 		case 'stylesheet_url':
   749 		case 'stylesheet_url':
   681 		case 'template_directory':
   755 		case 'template_directory':
   682 		case 'template_url':
   756 		case 'template_url':
   683 			$output = get_template_directory_uri();
   757 			$output = get_template_directory_uri();
   684 			break;
   758 			break;
   685 		case 'admin_email':
   759 		case 'admin_email':
   686 			$output = get_option('admin_email');
   760 			$output = get_option( 'admin_email' );
   687 			break;
   761 			break;
   688 		case 'charset':
   762 		case 'charset':
   689 			$output = get_option('blog_charset');
   763 			$output = get_option( 'blog_charset' );
   690 			if ('' == $output) $output = 'UTF-8';
   764 			if ( '' == $output ) {
       
   765 				$output = 'UTF-8';
       
   766 			}
   691 			break;
   767 			break;
   692 		case 'html_type' :
   768 		case 'html_type':
   693 			$output = get_option('html_type');
   769 			$output = get_option( 'html_type' );
   694 			break;
   770 			break;
   695 		case 'version':
   771 		case 'version':
   696 			global $wp_version;
   772 			global $wp_version;
   697 			$output = $wp_version;
   773 			$output = $wp_version;
   698 			break;
   774 			break;
   701 			 * see https://www.w3.org/International/articles/language-tags/ for reference.
   777 			 * see https://www.w3.org/International/articles/language-tags/ for reference.
   702 			 * Do not translate into your own language.
   778 			 * Do not translate into your own language.
   703 			 */
   779 			 */
   704 			$output = __( 'html_lang_attribute' );
   780 			$output = __( 'html_lang_attribute' );
   705 			if ( 'html_lang_attribute' === $output || preg_match( '/[^a-zA-Z0-9-]/', $output ) ) {
   781 			if ( 'html_lang_attribute' === $output || preg_match( '/[^a-zA-Z0-9-]/', $output ) ) {
   706 				$output = is_admin() ? get_user_locale() : get_locale();
   782 				$output = determine_locale();
   707 				$output = str_replace( '_', '-', $output );
   783 				$output = str_replace( '_', '-', $output );
   708 			}
   784 			}
   709 			break;
   785 			break;
   710 		case 'text_direction':
   786 		case 'text_direction':
   711 			_deprecated_argument( __FUNCTION__, '2.2.0', sprintf(
   787 			_deprecated_argument(
   712 				/* translators: 1: 'text_direction' argument, 2: bloginfo() function name, 3: is_rtl() function name */
   788 				__FUNCTION__,
   713 				__( 'The %1$s option is deprecated for the family of %2$s functions. Use the %3$s function instead.' ),
   789 				'2.2.0',
   714 				'<code>' . $show . '</code>',
   790 				sprintf(
   715 				'<code>bloginfo()</code>',
   791 					/* translators: 1: 'text_direction' argument, 2: bloginfo() function name, 3: is_rtl() function name */
   716 				'<code>is_rtl()</code>'
   792 					__( 'The %1$s option is deprecated for the family of %2$s functions. Use the %3$s function instead.' ),
   717 			) );
   793 					'<code>' . $show . '</code>',
       
   794 					'<code>bloginfo()</code>',
       
   795 					'<code>is_rtl()</code>'
       
   796 				)
       
   797 			);
   718 			if ( function_exists( 'is_rtl' ) ) {
   798 			if ( function_exists( 'is_rtl' ) ) {
   719 				$output = is_rtl() ? 'rtl' : 'ltr';
   799 				$output = is_rtl() ? 'rtl' : 'ltr';
   720 			} else {
   800 			} else {
   721 				$output = 'ltr';
   801 				$output = 'ltr';
   722 			}
   802 			}
   723 			break;
   803 			break;
   724 		case 'name':
   804 		case 'name':
   725 		default:
   805 		default:
   726 			$output = get_option('blogname');
   806 			$output = get_option( 'blogname' );
   727 			break;
   807 			break;
   728 	}
   808 	}
   729 
   809 
   730 	$url = true;
   810 	$url = true;
   731 	if (strpos($show, 'url') === false &&
   811 	if ( strpos( $show, 'url' ) === false &&
   732 		strpos($show, 'directory') === false &&
   812 		strpos( $show, 'directory' ) === false &&
   733 		strpos($show, 'home') === false)
   813 		strpos( $show, 'home' ) === false ) {
   734 		$url = false;
   814 		$url = false;
       
   815 	}
   735 
   816 
   736 	if ( 'display' == $filter ) {
   817 	if ( 'display' == $filter ) {
   737 		if ( $url ) {
   818 		if ( $url ) {
   738 			/**
   819 			/**
   739 			 * Filters the URL returned by get_bloginfo().
   820 			 * Filters the URL returned by get_bloginfo().
   862  *
   943  *
   863  * @param int $blog_id Optional. ID of the blog in question. Default is the ID of the current blog.
   944  * @param int $blog_id Optional. ID of the blog in question. Default is the ID of the current blog.
   864  * @return string Custom logo markup.
   945  * @return string Custom logo markup.
   865  */
   946  */
   866 function get_custom_logo( $blog_id = 0 ) {
   947 function get_custom_logo( $blog_id = 0 ) {
   867 	$html = '';
   948 	$html          = '';
   868 	$switched_blog = false;
   949 	$switched_blog = false;
   869 
   950 
   870 	if ( is_multisite() && ! empty( $blog_id ) && (int) $blog_id !== get_current_blog_id() ) {
   951 	if ( is_multisite() && ! empty( $blog_id ) && (int) $blog_id !== get_current_blog_id() ) {
   871 		switch_to_blog( $blog_id );
   952 		switch_to_blog( $blog_id );
   872 		$switched_blog = true;
   953 		$switched_blog = true;
   875 	$custom_logo_id = get_theme_mod( 'custom_logo' );
   956 	$custom_logo_id = get_theme_mod( 'custom_logo' );
   876 
   957 
   877 	// We have a logo. Logo is go.
   958 	// We have a logo. Logo is go.
   878 	if ( $custom_logo_id ) {
   959 	if ( $custom_logo_id ) {
   879 		$custom_logo_attr = array(
   960 		$custom_logo_attr = array(
   880 			'class'    => 'custom-logo',
   961 			'class' => 'custom-logo',
   881 			'itemprop' => 'logo',
       
   882 		);
   962 		);
   883 
   963 
   884 		/*
   964 		/*
   885 		 * If the logo alt attribute is empty, get the site title and explicitly
   965 		 * If the logo alt attribute is empty, get the site title and explicitly
   886 		 * pass it to the attributes used by wp_get_attachment_image().
   966 		 * pass it to the attributes used by wp_get_attachment_image().
   892 
   972 
   893 		/*
   973 		/*
   894 		 * If the alt attribute is not empty, there's no need to explicitly pass
   974 		 * If the alt attribute is not empty, there's no need to explicitly pass
   895 		 * it because wp_get_attachment_image() already adds the alt attribute.
   975 		 * it because wp_get_attachment_image() already adds the alt attribute.
   896 		 */
   976 		 */
   897 		$html = sprintf( '<a href="%1$s" class="custom-logo-link" rel="home" itemprop="url">%2$s</a>',
   977 		$html = sprintf(
       
   978 			'<a href="%1$s" class="custom-logo-link" rel="home">%2$s</a>',
   898 			esc_url( home_url( '/' ) ),
   979 			esc_url( home_url( '/' ) ),
   899 			wp_get_attachment_image( $custom_logo_id, 'full', false, $custom_logo_attr )
   980 			wp_get_attachment_image( $custom_logo_id, 'full', false, $custom_logo_attr )
   900 		);
   981 		);
   901 	}
   982 	} elseif ( is_customize_preview() ) {
   902 
   983 		// If no logo is set but we're in the Customizer, leave a placeholder (needed for the live preview).
   903 	// If no logo is set but we're in the Customizer, leave a placeholder (needed for the live preview).
   984 		$html = sprintf(
   904 	elseif ( is_customize_preview() ) {
   985 			'<a href="%1$s" class="custom-logo-link" style="display:none;"><img class="custom-logo"/></a>',
   905 		$html = sprintf( '<a href="%1$s" class="custom-logo-link" style="display:none;"><img class="custom-logo"/></a>',
       
   906 			esc_url( home_url( '/' ) )
   986 			esc_url( home_url( '/' ) )
   907 		);
   987 		);
   908 	}
   988 	}
   909 
   989 
   910 	if ( $switched_blog ) {
   990 	if ( $switched_blog ) {
   969 
  1049 
   970 	// If it's a 404 page, use a "Page not found" title.
  1050 	// If it's a 404 page, use a "Page not found" title.
   971 	if ( is_404() ) {
  1051 	if ( is_404() ) {
   972 		$title['title'] = __( 'Page not found' );
  1052 		$title['title'] = __( 'Page not found' );
   973 
  1053 
   974 	// If it's a search, use a dynamic search results title.
  1054 		// If it's a search, use a dynamic search results title.
   975 	} elseif ( is_search() ) {
  1055 	} elseif ( is_search() ) {
   976 		/* translators: %s: search phrase */
  1056 		/* translators: %s: search phrase */
   977 		$title['title'] = sprintf( __( 'Search Results for &#8220;%s&#8221;' ), get_search_query() );
  1057 		$title['title'] = sprintf( __( 'Search Results for &#8220;%s&#8221;' ), get_search_query() );
   978 
  1058 
   979 	// If on the front page, use the site title.
  1059 		// If on the front page, use the site title.
   980 	} elseif ( is_front_page() ) {
  1060 	} elseif ( is_front_page() ) {
   981 		$title['title'] = get_bloginfo( 'name', 'display' );
  1061 		$title['title'] = get_bloginfo( 'name', 'display' );
   982 
  1062 
   983 	// If on a post type archive, use the post type archive title.
  1063 		// If on a post type archive, use the post type archive title.
   984 	} elseif ( is_post_type_archive() ) {
  1064 	} elseif ( is_post_type_archive() ) {
   985 		$title['title'] = post_type_archive_title( '', false );
  1065 		$title['title'] = post_type_archive_title( '', false );
   986 
  1066 
   987 	// If on a taxonomy archive, use the term title.
  1067 		// If on a taxonomy archive, use the term title.
   988 	} elseif ( is_tax() ) {
  1068 	} elseif ( is_tax() ) {
   989 		$title['title'] = single_term_title( '', false );
  1069 		$title['title'] = single_term_title( '', false );
   990 
  1070 
   991 	/*
  1071 		/*
   992 	 * If we're on the blog page that is not the homepage or
  1072 		* If we're on the blog page that is not the homepage or
   993 	 * a single post of any post type, use the post title.
  1073 		* a single post of any post type, use the post title.
   994 	 */
  1074 		*/
   995 	} elseif ( is_home() || is_singular() ) {
  1075 	} elseif ( is_home() || is_singular() ) {
   996 		$title['title'] = single_post_title( '', false );
  1076 		$title['title'] = single_post_title( '', false );
   997 
  1077 
   998 	// If on a category or tag archive, use the term title.
  1078 		// If on a category or tag archive, use the term title.
   999 	} elseif ( is_category() || is_tag() ) {
  1079 	} elseif ( is_category() || is_tag() ) {
  1000 		$title['title'] = single_term_title( '', false );
  1080 		$title['title'] = single_term_title( '', false );
  1001 
  1081 
  1002 	// If on an author archive, use the author's display name.
  1082 		// If on an author archive, use the author's display name.
  1003 	} elseif ( is_author() && $author = get_queried_object() ) {
  1083 	} elseif ( is_author() && $author = get_queried_object() ) {
  1004 		$title['title'] = $author->display_name;
  1084 		$title['title'] = $author->display_name;
  1005 
  1085 
  1006 	// If it's a date archive, use the date as the title.
  1086 		// If it's a date archive, use the date as the title.
  1007 	} elseif ( is_year() ) {
  1087 	} elseif ( is_year() ) {
  1008 		$title['title'] = get_the_date( _x( 'Y', 'yearly archives date format' ) );
  1088 		$title['title'] = get_the_date( _x( 'Y', 'yearly archives date format' ) );
  1009 
  1089 
  1010 	} elseif ( is_month() ) {
  1090 	} elseif ( is_month() ) {
  1011 		$title['title'] = get_the_date( _x( 'F Y', 'monthly archives date format' ) );
  1091 		$title['title'] = get_the_date( _x( 'F Y', 'monthly archives date format' ) );
  1245  * @return string|void Title when retrieving.
  1325  * @return string|void Title when retrieving.
  1246  */
  1326  */
  1247 function single_post_title( $prefix = '', $display = true ) {
  1327 function single_post_title( $prefix = '', $display = true ) {
  1248 	$_post = get_queried_object();
  1328 	$_post = get_queried_object();
  1249 
  1329 
  1250 	if ( !isset($_post->post_title) )
  1330 	if ( ! isset( $_post->post_title ) ) {
  1251 		return;
  1331 		return;
       
  1332 	}
  1252 
  1333 
  1253 	/**
  1334 	/**
  1254 	 * Filters the page title for a single post.
  1335 	 * Filters the page title for a single post.
  1255 	 *
  1336 	 *
  1256 	 * @since 0.71
  1337 	 * @since 0.71
  1257 	 *
  1338 	 *
  1258 	 * @param string $_post_title The single post page title.
  1339 	 * @param string $_post_title The single post page title.
  1259 	 * @param object $_post       The current queried object as returned by get_queried_object().
  1340 	 * @param object $_post       The current queried object as returned by get_queried_object().
  1260 	 */
  1341 	 */
  1261 	$title = apply_filters( 'single_post_title', $_post->post_title, $_post );
  1342 	$title = apply_filters( 'single_post_title', $_post->post_title, $_post );
  1262 	if ( $display )
  1343 	if ( $display ) {
  1263 		echo $prefix . $title;
  1344 		echo $prefix . $title;
  1264 	else
  1345 	} else {
  1265 		return $prefix . $title;
  1346 		return $prefix . $title;
       
  1347 	}
  1266 }
  1348 }
  1267 
  1349 
  1268 /**
  1350 /**
  1269  * Display or retrieve title for a post type archive.
  1351  * Display or retrieve title for a post type archive.
  1270  *
  1352  *
  1276  * @param string $prefix  Optional. What to display before the title.
  1358  * @param string $prefix  Optional. What to display before the title.
  1277  * @param bool   $display Optional, default is true. Whether to display or retrieve title.
  1359  * @param bool   $display Optional, default is true. Whether to display or retrieve title.
  1278  * @return string|void Title when retrieving, null when displaying or failure.
  1360  * @return string|void Title when retrieving, null when displaying or failure.
  1279  */
  1361  */
  1280 function post_type_archive_title( $prefix = '', $display = true ) {
  1362 function post_type_archive_title( $prefix = '', $display = true ) {
  1281 	if ( ! is_post_type_archive() )
  1363 	if ( ! is_post_type_archive() ) {
  1282 		return;
  1364 		return;
       
  1365 	}
  1283 
  1366 
  1284 	$post_type = get_query_var( 'post_type' );
  1367 	$post_type = get_query_var( 'post_type' );
  1285 	if ( is_array( $post_type ) )
  1368 	if ( is_array( $post_type ) ) {
  1286 		$post_type = reset( $post_type );
  1369 		$post_type = reset( $post_type );
       
  1370 	}
  1287 
  1371 
  1288 	$post_type_obj = get_post_type_object( $post_type );
  1372 	$post_type_obj = get_post_type_object( $post_type );
  1289 
  1373 
  1290 	/**
  1374 	/**
  1291 	 * Filters the post type archive title.
  1375 	 * Filters the post type archive title.
  1295 	 * @param string $post_type_name Post type 'name' label.
  1379 	 * @param string $post_type_name Post type 'name' label.
  1296 	 * @param string $post_type      Post type.
  1380 	 * @param string $post_type      Post type.
  1297 	 */
  1381 	 */
  1298 	$title = apply_filters( 'post_type_archive_title', $post_type_obj->labels->name, $post_type );
  1382 	$title = apply_filters( 'post_type_archive_title', $post_type_obj->labels->name, $post_type );
  1299 
  1383 
  1300 	if ( $display )
  1384 	if ( $display ) {
  1301 		echo $prefix . $title;
  1385 		echo $prefix . $title;
  1302 	else
  1386 	} else {
  1303 		return $prefix . $title;
  1387 		return $prefix . $title;
       
  1388 	}
  1304 }
  1389 }
  1305 
  1390 
  1306 /**
  1391 /**
  1307  * Display or retrieve page title for category archive.
  1392  * Display or retrieve page title for category archive.
  1308  *
  1393  *
  1351  * @return string|void Title when retrieving.
  1436  * @return string|void Title when retrieving.
  1352  */
  1437  */
  1353 function single_term_title( $prefix = '', $display = true ) {
  1438 function single_term_title( $prefix = '', $display = true ) {
  1354 	$term = get_queried_object();
  1439 	$term = get_queried_object();
  1355 
  1440 
  1356 	if ( !$term )
  1441 	if ( ! $term ) {
  1357 		return;
  1442 		return;
       
  1443 	}
  1358 
  1444 
  1359 	if ( is_category() ) {
  1445 	if ( is_category() ) {
  1360 		/**
  1446 		/**
  1361 		 * Filters the category archive page title.
  1447 		 * Filters the category archive page title.
  1362 		 *
  1448 		 *
  1385 		$term_name = apply_filters( 'single_term_title', $term->name );
  1471 		$term_name = apply_filters( 'single_term_title', $term->name );
  1386 	} else {
  1472 	} else {
  1387 		return;
  1473 		return;
  1388 	}
  1474 	}
  1389 
  1475 
  1390 	if ( empty( $term_name ) )
  1476 	if ( empty( $term_name ) ) {
  1391 		return;
  1477 		return;
  1392 
  1478 	}
  1393 	if ( $display )
  1479 
       
  1480 	if ( $display ) {
  1394 		echo $prefix . $term_name;
  1481 		echo $prefix . $term_name;
  1395 	else
  1482 	} else {
  1396 		return $prefix . $term_name;
  1483 		return $prefix . $term_name;
       
  1484 	}
  1397 }
  1485 }
  1398 
  1486 
  1399 /**
  1487 /**
  1400  * Display or retrieve page title for post archive based on date.
  1488  * Display or retrieve page title for post archive based on date.
  1401  *
  1489  *
  1410  *
  1498  *
  1411  * @param string $prefix  Optional. What to display before the title.
  1499  * @param string $prefix  Optional. What to display before the title.
  1412  * @param bool   $display Optional, default is true. Whether to display or retrieve title.
  1500  * @param bool   $display Optional, default is true. Whether to display or retrieve title.
  1413  * @return string|void Title when retrieving.
  1501  * @return string|void Title when retrieving.
  1414  */
  1502  */
  1415 function single_month_title($prefix = '', $display = true ) {
  1503 function single_month_title( $prefix = '', $display = true ) {
  1416 	global $wp_locale;
  1504 	global $wp_locale;
  1417 
  1505 
  1418 	$m = get_query_var('m');
  1506 	$m        = get_query_var( 'm' );
  1419 	$year = get_query_var('year');
  1507 	$year     = get_query_var( 'year' );
  1420 	$monthnum = get_query_var('monthnum');
  1508 	$monthnum = get_query_var( 'monthnum' );
  1421 
  1509 
  1422 	if ( !empty($monthnum) && !empty($year) ) {
  1510 	if ( ! empty( $monthnum ) && ! empty( $year ) ) {
  1423 		$my_year = $year;
  1511 		$my_year  = $year;
  1424 		$my_month = $wp_locale->get_month($monthnum);
  1512 		$my_month = $wp_locale->get_month( $monthnum );
  1425 	} elseif ( !empty($m) ) {
  1513 	} elseif ( ! empty( $m ) ) {
  1426 		$my_year = substr($m, 0, 4);
  1514 		$my_year  = substr( $m, 0, 4 );
  1427 		$my_month = $wp_locale->get_month(substr($m, 4, 2));
  1515 		$my_month = $wp_locale->get_month( substr( $m, 4, 2 ) );
  1428 	}
  1516 	}
  1429 
  1517 
  1430 	if ( empty($my_month) )
  1518 	if ( empty( $my_month ) ) {
  1431 		return false;
  1519 		return false;
       
  1520 	}
  1432 
  1521 
  1433 	$result = $prefix . $my_month . $prefix . $my_year;
  1522 	$result = $prefix . $my_month . $prefix . $my_year;
  1434 
  1523 
  1435 	if ( !$display )
  1524 	if ( ! $display ) {
  1436 		return $result;
  1525 		return $result;
       
  1526 	}
  1437 	echo $result;
  1527 	echo $result;
  1438 }
  1528 }
  1439 
  1529 
  1440 /**
  1530 /**
  1441  * Display the archive title based on the queried object.
  1531  * Display the archive title based on the queried object.
  1462  *
  1552  *
  1463  * @return string Archive title.
  1553  * @return string Archive title.
  1464  */
  1554  */
  1465 function get_the_archive_title() {
  1555 function get_the_archive_title() {
  1466 	if ( is_category() ) {
  1556 	if ( is_category() ) {
  1467 		/* translators: Category archive title. 1: Category name */
  1557 		/* translators: Category archive title. %s: Category name */
  1468 		$title = sprintf( __( 'Category: %s' ), single_cat_title( '', false ) );
  1558 		$title = sprintf( __( 'Category: %s' ), single_cat_title( '', false ) );
  1469 	} elseif ( is_tag() ) {
  1559 	} elseif ( is_tag() ) {
  1470 		/* translators: Tag archive title. 1: Tag name */
  1560 		/* translators: Tag archive title. %s: Tag name */
  1471 		$title = sprintf( __( 'Tag: %s' ), single_tag_title( '', false ) );
  1561 		$title = sprintf( __( 'Tag: %s' ), single_tag_title( '', false ) );
  1472 	} elseif ( is_author() ) {
  1562 	} elseif ( is_author() ) {
  1473 		/* translators: Author archive title. 1: Author name */
  1563 		/* translators: Author archive title. %s: Author name */
  1474 		$title = sprintf( __( 'Author: %s' ), '<span class="vcard">' . get_the_author() . '</span>' );
  1564 		$title = sprintf( __( 'Author: %s' ), '<span class="vcard">' . get_the_author() . '</span>' );
  1475 	} elseif ( is_year() ) {
  1565 	} elseif ( is_year() ) {
  1476 		/* translators: Yearly archive title. 1: Year */
  1566 		/* translators: Yearly archive title. %s: Year */
  1477 		$title = sprintf( __( 'Year: %s' ), get_the_date( _x( 'Y', 'yearly archives date format' ) ) );
  1567 		$title = sprintf( __( 'Year: %s' ), get_the_date( _x( 'Y', 'yearly archives date format' ) ) );
  1478 	} elseif ( is_month() ) {
  1568 	} elseif ( is_month() ) {
  1479 		/* translators: Monthly archive title. 1: Month name and year */
  1569 		/* translators: Monthly archive title. %s: Month name and year */
  1480 		$title = sprintf( __( 'Month: %s' ), 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' ) ) );
  1481 	} elseif ( is_day() ) {
  1571 	} elseif ( is_day() ) {
  1482 		/* translators: Daily archive title. 1: Date */
  1572 		/* translators: Daily archive title. %s: Date */
  1483 		$title = sprintf( __( 'Day: %s' ), 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' ) ) );
  1484 	} elseif ( is_tax( 'post_format' ) ) {
  1574 	} elseif ( is_tax( 'post_format' ) ) {
  1485 		if ( is_tax( 'post_format', 'post-format-aside' ) ) {
  1575 		if ( is_tax( 'post_format', 'post-format-aside' ) ) {
  1486 			$title = _x( 'Asides', 'post format archive title' );
  1576 			$title = _x( 'Asides', 'post format archive title' );
  1487 		} elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) {
  1577 		} elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) {
  1500 			$title = _x( 'Audio', 'post format archive title' );
  1590 			$title = _x( 'Audio', 'post format archive title' );
  1501 		} elseif ( is_tax( 'post_format', 'post-format-chat' ) ) {
  1591 		} elseif ( is_tax( 'post_format', 'post-format-chat' ) ) {
  1502 			$title = _x( 'Chats', 'post format archive title' );
  1592 			$title = _x( 'Chats', 'post format archive title' );
  1503 		}
  1593 		}
  1504 	} elseif ( is_post_type_archive() ) {
  1594 	} elseif ( is_post_type_archive() ) {
  1505 		/* translators: Post type archive title. 1: Post type name */
  1595 		/* translators: Post type archive title. %s: Post type name */
  1506 		$title = sprintf( __( 'Archives: %s' ), post_type_archive_title( '', false ) );
  1596 		$title = sprintf( __( 'Archives: %s' ), post_type_archive_title( '', false ) );
  1507 	} elseif ( is_tax() ) {
  1597 	} elseif ( is_tax() ) {
  1508 		$tax = get_taxonomy( get_queried_object()->taxonomy );
  1598 		$tax = get_taxonomy( get_queried_object()->taxonomy );
  1509 		/* translators: Taxonomy term archive title. 1: Taxonomy singular name, 2: Current taxonomy term */
  1599 		/* translators: Taxonomy term archive title. 1: Taxonomy singular name, 2: Current taxonomy term */
  1510 		$title = sprintf( __( '%1$s: %2$s' ), $tax->labels->singular_name, single_term_title( '', false ) );
  1600 		$title = sprintf( __( '%1$s: %2$s' ), $tax->labels->singular_name, single_term_title( '', false ) );
  1626  * The custom format uses the before parameter before the link ('a' HTML
  1716  * The custom format uses the before parameter before the link ('a' HTML
  1627  * element) and the after parameter after the closing link tag. If the above
  1717  * element) and the after parameter after the closing link tag. If the above
  1628  * three values for the format are not used, then custom format is assumed.
  1718  * three values for the format are not used, then custom format is assumed.
  1629  *
  1719  *
  1630  * @since 1.0.0
  1720  * @since 1.0.0
  1631  *
  1721  * @since 5.2.0 Added the `$selected` parameter.
  1632  * @param string $url    URL to archive.
  1722  *
  1633  * @param string $text   Archive text description.
  1723  * @param string $url      URL to archive.
  1634  * @param string $format Optional, default is 'html'. Can be 'link', 'option', 'html', or custom.
  1724  * @param string $text     Archive text description.
  1635  * @param string $before Optional. Content to prepend to the description. Default empty.
  1725  * @param string $format   Optional, default is 'html'. Can be 'link', 'option', 'html', or custom.
  1636  * @param string $after  Optional. Content to append to the description. Default empty.
  1726  * @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.
       
  1728  * @param bool   $selected Optional. Set to true if the current page is the selected archive page.
  1637  * @return string HTML link content for archive.
  1729  * @return string HTML link content for archive.
  1638  */
  1730  */
  1639 function get_archives_link($url, $text, $format = 'html', $before = '', $after = '') {
  1731 function get_archives_link( $url, $text, $format = 'html', $before = '', $after = '', $selected = false ) {
  1640 	$text = wptexturize($text);
  1732 	$text = wptexturize( $text );
  1641 	$url = esc_url($url);
  1733 	$url  = esc_url( $url );
  1642 
  1734 
  1643 	if ('link' == $format)
  1735 	if ( 'link' == $format ) {
  1644 		$link_html = "\t<link rel='archives' title='" . esc_attr( $text ) . "' href='$url' />\n";
  1736 		$link_html = "\t<link rel='archives' title='" . esc_attr( $text ) . "' href='$url' />\n";
  1645 	elseif ('option' == $format)
  1737 	} elseif ( 'option' == $format ) {
  1646 		$link_html = "\t<option value='$url'>$before $text $after</option>\n";
  1738 		$selected_attr = $selected ? " selected='selected'" : '';
  1647 	elseif ('html' == $format)
  1739 		$link_html     = "\t<option value='$url'$selected_attr>$before $text $after</option>\n";
       
  1740 	} elseif ( 'html' == $format ) {
  1648 		$link_html = "\t<li>$before<a href='$url'>$text</a>$after</li>\n";
  1741 		$link_html = "\t<li>$before<a href='$url'>$text</a>$after</li>\n";
  1649 	else // custom
  1742 	} else { // custom
  1650 		$link_html = "\t$before<a href='$url'>$text</a>$after\n";
  1743 		$link_html = "\t$before<a href='$url'>$text</a>$after\n";
       
  1744 	}
  1651 
  1745 
  1652 	/**
  1746 	/**
  1653 	 * Filters the archive link content.
  1747 	 * Filters the archive link content.
  1654 	 *
  1748 	 *
  1655 	 * @since 2.6.0
  1749 	 * @since 2.6.0
  1656 	 * @since 4.5.0 Added the `$url`, `$text`, `$format`, `$before`, and `$after` parameters.
  1750 	 * @since 4.5.0 Added the `$url`, `$text`, `$format`, `$before`, and `$after` parameters.
       
  1751 	 * @since 5.2.0 Added the `$selected` parameter.
  1657 	 *
  1752 	 *
  1658 	 * @param string $link_html The archive HTML link content.
  1753 	 * @param string $link_html The archive HTML link content.
  1659 	 * @param string $url       URL to archive.
  1754 	 * @param string $url       URL to archive.
  1660 	 * @param string $text      Archive text description.
  1755 	 * @param string $text      Archive text description.
  1661 	 * @param string $format    Link format. Can be 'link', 'option', 'html', or custom.
  1756 	 * @param string $format    Link format. Can be 'link', 'option', 'html', or custom.
  1662 	 * @param string $before    Content to prepend to the description.
  1757 	 * @param string $before    Content to prepend to the description.
  1663 	 * @param string $after     Content to append to the description.
  1758 	 * @param string $after     Content to append to the description.
  1664 	 */
  1759 	 * @param bool   $selected  True if the current page is the selected archive.
  1665 	return apply_filters( 'get_archives_link', $link_html, $url, $text, $format, $before, $after );
  1760 	 */
       
  1761 	return apply_filters( 'get_archives_link', $link_html, $url, $text, $format, $before, $after, $selected );
  1666 }
  1762 }
  1667 
  1763 
  1668 /**
  1764 /**
  1669  * Display archive links based on type and format.
  1765  * Display archive links based on type and format.
  1670  *
  1766  *
  1671  * @since 1.2.0
  1767  * @since 1.2.0
  1672  * @since 4.4.0 $post_type arg was added.
  1768  * @since 4.4.0 The `$post_type` argument was added.
       
  1769  * @since 5.2.0 The `$year`, `$monthnum`, `$day`, and `$w` arguments were added.
  1673  *
  1770  *
  1674  * @see get_archives_link()
  1771  * @see get_archives_link()
  1675  *
  1772  *
  1676  * @global wpdb      $wpdb
  1773  * @global wpdb      $wpdb
  1677  * @global WP_Locale $wp_locale
  1774  * @global WP_Locale $wp_locale
  1695  *     @type bool       $show_post_count Whether to display the post count alongside the link. Default false.
  1792  *     @type bool       $show_post_count Whether to display the post count alongside the link. Default false.
  1696  *     @type bool|int   $echo            Whether to echo or return the links list. Default 1|true to echo.
  1793  *     @type bool|int   $echo            Whether to echo or return the links list. Default 1|true to echo.
  1697  *     @type string     $order           Whether to use ascending or descending order. Accepts 'ASC', or 'DESC'.
  1794  *     @type string     $order           Whether to use ascending or descending order. Accepts 'ASC', or 'DESC'.
  1698  *                                       Default 'DESC'.
  1795  *                                       Default 'DESC'.
  1699  *     @type string     $post_type       Post type. Default 'post'.
  1796  *     @type string     $post_type       Post type. Default 'post'.
       
  1797  *     @type string     $year            Year. Default current year.
       
  1798  *     @type string     $monthnum        Month number. Default current month number.
       
  1799  *     @type string     $day             Day. Default current day.
       
  1800  *     @type string     $w               Week. Default current week.
  1700  * }
  1801  * }
  1701  * @return string|void String when retrieving.
  1802  * @return string|void String when retrieving.
  1702  */
  1803  */
  1703 function wp_get_archives( $args = '' ) {
  1804 function wp_get_archives( $args = '' ) {
  1704 	global $wpdb, $wp_locale;
  1805 	global $wpdb, $wp_locale;
  1705 
  1806 
  1706 	$defaults = array(
  1807 	$defaults = array(
  1707 		'type' => 'monthly', 'limit' => '',
  1808 		'type'            => 'monthly',
  1708 		'format' => 'html', 'before' => '',
  1809 		'limit'           => '',
  1709 		'after' => '', 'show_post_count' => false,
  1810 		'format'          => 'html',
  1710 		'echo' => 1, 'order' => 'DESC',
  1811 		'before'          => '',
  1711 		'post_type' => 'post'
  1812 		'after'           => '',
       
  1813 		'show_post_count' => false,
       
  1814 		'echo'            => 1,
       
  1815 		'order'           => 'DESC',
       
  1816 		'post_type'       => 'post',
       
  1817 		'year'            => get_query_var( 'year' ),
       
  1818 		'monthnum'        => get_query_var( 'monthnum' ),
       
  1819 		'day'             => get_query_var( 'day' ),
       
  1820 		'w'               => get_query_var( 'w' ),
  1712 	);
  1821 	);
  1713 
  1822 
  1714 	$r = wp_parse_args( $args, $defaults );
  1823 	$r = wp_parse_args( $args, $defaults );
  1715 
  1824 
  1716 	$post_type_object = get_post_type_object( $r['post_type'] );
  1825 	$post_type_object = get_post_type_object( $r['post_type'] );
  1764 
  1873 
  1765 	$limit = $r['limit'];
  1874 	$limit = $r['limit'];
  1766 
  1875 
  1767 	if ( 'monthly' == $r['type'] ) {
  1876 	if ( 'monthly' == $r['type'] ) {
  1768 		$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";
  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";
  1769 		$key = md5( $query );
  1878 		$key   = md5( $query );
  1770 		$key = "wp_get_archives:$key:$last_changed";
  1879 		$key   = "wp_get_archives:$key:$last_changed";
  1771 		if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
  1880 		if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
  1772 			$results = $wpdb->get_results( $query );
  1881 			$results = $wpdb->get_results( $query );
  1773 			wp_cache_set( $key, $results, 'posts' );
  1882 			wp_cache_set( $key, $results, 'posts' );
  1774 		}
  1883 		}
  1775 		if ( $results ) {
  1884 		if ( $results ) {
  1782 				/* translators: 1: month name, 2: 4-digit year */
  1891 				/* translators: 1: month name, 2: 4-digit year */
  1783 				$text = sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $result->month ), $result->year );
  1892 				$text = sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $result->month ), $result->year );
  1784 				if ( $r['show_post_count'] ) {
  1893 				if ( $r['show_post_count'] ) {
  1785 					$r['after'] = '&nbsp;(' . $result->posts . ')' . $after;
  1894 					$r['after'] = '&nbsp;(' . $result->posts . ')' . $after;
  1786 				}
  1895 				}
  1787 				$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
  1896 				$selected = is_archive() && (string) $r['year'] === $result->year && (string) $r['monthnum'] === $result->month;
       
  1897 				$output  .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'], $selected );
  1788 			}
  1898 			}
  1789 		}
  1899 		}
  1790 	} elseif ( 'yearly' == $r['type'] ) {
  1900 	} elseif ( 'yearly' == $r['type'] ) {
  1791 		$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";
  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";
  1792 		$key = md5( $query );
  1902 		$key   = md5( $query );
  1793 		$key = "wp_get_archives:$key:$last_changed";
  1903 		$key   = "wp_get_archives:$key:$last_changed";
  1794 		if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
  1904 		if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
  1795 			$results = $wpdb->get_results( $query );
  1905 			$results = $wpdb->get_results( $query );
  1796 			wp_cache_set( $key, $results, 'posts' );
  1906 			wp_cache_set( $key, $results, 'posts' );
  1797 		}
  1907 		}
  1798 		if ( $results ) {
  1908 		if ( $results ) {
  1799 			$after = $r['after'];
  1909 			$after = $r['after'];
  1800 			foreach ( (array) $results as $result) {
  1910 			foreach ( (array) $results as $result ) {
  1801 				$url = get_year_link( $result->year );
  1911 				$url = get_year_link( $result->year );
  1802 				if ( 'post' !== $r['post_type'] ) {
  1912 				if ( 'post' !== $r['post_type'] ) {
  1803 					$url = add_query_arg( 'post_type', $r['post_type'], $url );
  1913 					$url = add_query_arg( 'post_type', $r['post_type'], $url );
  1804 				}
  1914 				}
  1805 				$text = sprintf( '%d', $result->year );
  1915 				$text = sprintf( '%d', $result->year );
  1806 				if ( $r['show_post_count'] ) {
  1916 				if ( $r['show_post_count'] ) {
  1807 					$r['after'] = '&nbsp;(' . $result->posts . ')' . $after;
  1917 					$r['after'] = '&nbsp;(' . $result->posts . ')' . $after;
  1808 				}
  1918 				}
  1809 				$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
  1919 				$selected = is_archive() && (string) $r['year'] === $result->year;
       
  1920 				$output  .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'], $selected );
  1810 			}
  1921 			}
  1811 		}
  1922 		}
  1812 	} elseif ( 'daily' == $r['type'] ) {
  1923 	} elseif ( 'daily' == $r['type'] ) {
  1813 		$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";
  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";
  1814 		$key = md5( $query );
  1925 		$key   = md5( $query );
  1815 		$key = "wp_get_archives:$key:$last_changed";
  1926 		$key   = "wp_get_archives:$key:$last_changed";
  1816 		if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
  1927 		if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
  1817 			$results = $wpdb->get_results( $query );
  1928 			$results = $wpdb->get_results( $query );
  1818 			wp_cache_set( $key, $results, 'posts' );
  1929 			wp_cache_set( $key, $results, 'posts' );
  1819 		}
  1930 		}
  1820 		if ( $results ) {
  1931 		if ( $results ) {
  1821 			$after = $r['after'];
  1932 			$after = $r['after'];
  1822 			foreach ( (array) $results as $result ) {
  1933 			foreach ( (array) $results as $result ) {
  1823 				$url  = get_day_link( $result->year, $result->month, $result->dayofmonth );
  1934 				$url = get_day_link( $result->year, $result->month, $result->dayofmonth );
  1824 				if ( 'post' !== $r['post_type'] ) {
  1935 				if ( 'post' !== $r['post_type'] ) {
  1825 					$url = add_query_arg( 'post_type', $r['post_type'], $url );
  1936 					$url = add_query_arg( 'post_type', $r['post_type'], $url );
  1826 				}
  1937 				}
  1827 				$date = sprintf( '%1$d-%2$02d-%3$02d 00:00:00', $result->year, $result->month, $result->dayofmonth );
  1938 				$date = sprintf( '%1$d-%2$02d-%3$02d 00:00:00', $result->year, $result->month, $result->dayofmonth );
  1828 				$text = mysql2date( get_option( 'date_format' ), $date );
  1939 				$text = mysql2date( get_option( 'date_format' ), $date );
  1829 				if ( $r['show_post_count'] ) {
  1940 				if ( $r['show_post_count'] ) {
  1830 					$r['after'] = '&nbsp;(' . $result->posts . ')' . $after;
  1941 					$r['after'] = '&nbsp;(' . $result->posts . ')' . $after;
  1831 				}
  1942 				}
  1832 				$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
  1943 				$selected = is_archive() && (string) $r['year'] === $result->year && (string) $r['monthnum'] === $result->month && (string) $r['day'] === $result->dayofmonth;
       
  1944 				$output  .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'], $selected );
  1833 			}
  1945 			}
  1834 		}
  1946 		}
  1835 	} elseif ( 'weekly' == $r['type'] ) {
  1947 	} elseif ( 'weekly' == $r['type'] ) {
  1836 		$week = _wp_mysql_week( '`post_date`' );
  1948 		$week  = _wp_mysql_week( '`post_date`' );
  1837 		$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";
  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";
  1838 		$key = md5( $query );
  1950 		$key   = md5( $query );
  1839 		$key = "wp_get_archives:$key:$last_changed";
  1951 		$key   = "wp_get_archives:$key:$last_changed";
  1840 		if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
  1952 		if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
  1841 			$results = $wpdb->get_results( $query );
  1953 			$results = $wpdb->get_results( $query );
  1842 			wp_cache_set( $key, $results, 'posts' );
  1954 			wp_cache_set( $key, $results, 'posts' );
  1843 		}
  1955 		}
  1844 		$arc_w_last = '';
  1956 		$arc_w_last = '';
  1849 					$arc_year       = $result->yr;
  1961 					$arc_year       = $result->yr;
  1850 					$arc_w_last     = $result->week;
  1962 					$arc_w_last     = $result->week;
  1851 					$arc_week       = get_weekstartend( $result->yyyymmdd, get_option( 'start_of_week' ) );
  1963 					$arc_week       = get_weekstartend( $result->yyyymmdd, get_option( 'start_of_week' ) );
  1852 					$arc_week_start = date_i18n( get_option( 'date_format' ), $arc_week['start'] );
  1964 					$arc_week_start = date_i18n( get_option( 'date_format' ), $arc_week['start'] );
  1853 					$arc_week_end   = date_i18n( get_option( 'date_format' ), $arc_week['end'] );
  1965 					$arc_week_end   = date_i18n( get_option( 'date_format' ), $arc_week['end'] );
  1854 					$url            = add_query_arg( array( 'm' => $arc_year, 'w' => $result->week, ), home_url( '/' ) );
  1966 					$url            = add_query_arg(
       
  1967 						array(
       
  1968 							'm' => $arc_year,
       
  1969 							'w' => $result->week,
       
  1970 						),
       
  1971 						home_url( '/' )
       
  1972 					);
  1855 					if ( 'post' !== $r['post_type'] ) {
  1973 					if ( 'post' !== $r['post_type'] ) {
  1856 						$url = add_query_arg( 'post_type', $r['post_type'], $url );
  1974 						$url = add_query_arg( 'post_type', $r['post_type'], $url );
  1857 					}
  1975 					}
  1858 					$text           = $arc_week_start . $archive_week_separator . $arc_week_end;
  1976 					$text = $arc_week_start . $archive_week_separator . $arc_week_end;
  1859 					if ( $r['show_post_count'] ) {
  1977 					if ( $r['show_post_count'] ) {
  1860 						$r['after'] = '&nbsp;(' . $result->posts . ')' . $after;
  1978 						$r['after'] = '&nbsp;(' . $result->posts . ')' . $after;
  1861 					}
  1979 					}
  1862 					$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
  1980 					$selected = is_archive() && (string) $r['year'] === $result->yr && (string) $r['w'] === $result->week;
       
  1981 					$output  .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'], $selected );
  1863 				}
  1982 				}
  1864 			}
  1983 			}
  1865 		}
  1984 		}
  1866 	} elseif ( ( 'postbypost' == $r['type'] ) || ('alpha' == $r['type'] ) ) {
  1985 	} elseif ( ( 'postbypost' == $r['type'] ) || ( 'alpha' == $r['type'] ) ) {
  1867 		$orderby = ( 'alpha' == $r['type'] ) ? 'post_title ASC ' : 'post_date DESC, ID DESC ';
  1986 		$orderby = ( 'alpha' == $r['type'] ) ? 'post_title ASC ' : 'post_date DESC, ID DESC ';
  1868 		$query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit";
  1987 		$query   = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit";
  1869 		$key = md5( $query );
  1988 		$key     = md5( $query );
  1870 		$key = "wp_get_archives:$key:$last_changed";
  1989 		$key     = "wp_get_archives:$key:$last_changed";
  1871 		if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
  1990 		if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
  1872 			$results = $wpdb->get_results( $query );
  1991 			$results = $wpdb->get_results( $query );
  1873 			wp_cache_set( $key, $results, 'posts' );
  1992 			wp_cache_set( $key, $results, 'posts' );
  1874 		}
  1993 		}
  1875 		if ( $results ) {
  1994 		if ( $results ) {
  1880 						/** This filter is documented in wp-includes/post-template.php */
  1999 						/** This filter is documented in wp-includes/post-template.php */
  1881 						$text = strip_tags( apply_filters( 'the_title', $result->post_title, $result->ID ) );
  2000 						$text = strip_tags( apply_filters( 'the_title', $result->post_title, $result->ID ) );
  1882 					} else {
  2001 					} else {
  1883 						$text = $result->ID;
  2002 						$text = $result->ID;
  1884 					}
  2003 					}
  1885 					$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
  2004 					$selected = $result->ID === get_the_ID();
       
  2005 					$output  .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'], $selected );
  1886 				}
  2006 				}
  1887 			}
  2007 			}
  1888 		}
  2008 		}
  1889 	}
  2009 	}
  1890 	if ( $r['echo'] ) {
  2010 	if ( $r['echo'] ) {
  1900  * @since 1.5.0
  2020  * @since 1.5.0
  1901  *
  2021  *
  1902  * @param int $num Number of day.
  2022  * @param int $num Number of day.
  1903  * @return float Days since the start of the week.
  2023  * @return float Days since the start of the week.
  1904  */
  2024  */
  1905 function calendar_week_mod($num) {
  2025 function calendar_week_mod( $num ) {
  1906 	$base = 7;
  2026 	$base = 7;
  1907 	return ($num - $base*floor($num/$base));
  2027 	return ( $num - $base * floor( $num / $base ) );
  1908 }
  2028 }
  1909 
  2029 
  1910 /**
  2030 /**
  1911  * Display calendar with days that have posts as links.
  2031  * Display calendar with days that have posts as links.
  1912  *
  2032  *
  1927  * @return string|void String when retrieving.
  2047  * @return string|void String when retrieving.
  1928  */
  2048  */
  1929 function get_calendar( $initial = true, $echo = true ) {
  2049 function get_calendar( $initial = true, $echo = true ) {
  1930 	global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
  2050 	global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
  1931 
  2051 
  1932 	$key = md5( $m . $monthnum . $year );
  2052 	$key   = md5( $m . $monthnum . $year );
  1933 	$cache = wp_cache_get( 'get_calendar', 'calendar' );
  2053 	$cache = wp_cache_get( 'get_calendar', 'calendar' );
  1934 
  2054 
  1935 	if ( $cache && is_array( $cache ) && isset( $cache[ $key ] ) ) {
  2055 	if ( $cache && is_array( $cache ) && isset( $cache[ $key ] ) ) {
  1936 		/** This filter is documented in wp-includes/general-template.php */
  2056 		/** This filter is documented in wp-includes/general-template.php */
  1937 		$output = apply_filters( 'get_calendar', $cache[ $key ] );
  2057 		$output = apply_filters( 'get_calendar', $cache[ $key ] );
  1948 		$cache = array();
  2068 		$cache = array();
  1949 	}
  2069 	}
  1950 
  2070 
  1951 	// Quick check. If we have no posts at all, abort!
  2071 	// Quick check. If we have no posts at all, abort!
  1952 	if ( ! $posts ) {
  2072 	if ( ! $posts ) {
  1953 		$gotsome = $wpdb->get_var("SELECT 1 as test FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1");
  2073 		$gotsome = $wpdb->get_var( "SELECT 1 as test FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1" );
  1954 		if ( ! $gotsome ) {
  2074 		if ( ! $gotsome ) {
  1955 			$cache[ $key ] = '';
  2075 			$cache[ $key ] = '';
  1956 			wp_cache_set( 'get_calendar', $cache, 'calendar' );
  2076 			wp_cache_set( 'get_calendar', $cache, 'calendar' );
  1957 			return;
  2077 			return;
  1958 		}
  2078 		}
  1961 	if ( isset( $_GET['w'] ) ) {
  2081 	if ( isset( $_GET['w'] ) ) {
  1962 		$w = (int) $_GET['w'];
  2082 		$w = (int) $_GET['w'];
  1963 	}
  2083 	}
  1964 	// week_begins = 0 stands for Sunday
  2084 	// week_begins = 0 stands for Sunday
  1965 	$week_begins = (int) get_option( 'start_of_week' );
  2085 	$week_begins = (int) get_option( 'start_of_week' );
  1966 	$ts = current_time( 'timestamp' );
       
  1967 
  2086 
  1968 	// Let's figure out when we are
  2087 	// Let's figure out when we are
  1969 	if ( ! empty( $monthnum ) && ! empty( $year ) ) {
  2088 	if ( ! empty( $monthnum ) && ! empty( $year ) ) {
  1970 		$thismonth = zeroise( intval( $monthnum ), 2 );
  2089 		$thismonth = zeroise( intval( $monthnum ), 2 );
  1971 		$thisyear = (int) $year;
  2090 		$thisyear  = (int) $year;
  1972 	} elseif ( ! empty( $w ) ) {
  2091 	} elseif ( ! empty( $w ) ) {
  1973 		// We need to get the month from MySQL
  2092 		// We need to get the month from MySQL
  1974 		$thisyear = (int) substr( $m, 0, 4 );
  2093 		$thisyear = (int) substr( $m, 0, 4 );
  1975 		//it seems MySQL's weeks disagree with PHP's
  2094 		//it seems MySQL's weeks disagree with PHP's
  1976 		$d = ( ( $w - 1 ) * 7 ) + 6;
  2095 		$d         = ( ( $w - 1 ) * 7 ) + 6;
  1977 		$thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')");
  2096 		$thismonth = $wpdb->get_var( "SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')" );
  1978 	} elseif ( ! empty( $m ) ) {
  2097 	} elseif ( ! empty( $m ) ) {
  1979 		$thisyear = (int) substr( $m, 0, 4 );
  2098 		$thisyear = (int) substr( $m, 0, 4 );
  1980 		if ( strlen( $m ) < 6 ) {
  2099 		if ( strlen( $m ) < 6 ) {
  1981 			$thismonth = '01';
  2100 			$thismonth = '01';
  1982 		} else {
  2101 		} else {
  1983 			$thismonth = zeroise( (int) substr( $m, 4, 2 ), 2 );
  2102 			$thismonth = zeroise( (int) substr( $m, 4, 2 ), 2 );
  1984 		}
  2103 		}
  1985 	} else {
  2104 	} else {
  1986 		$thisyear = gmdate( 'Y', $ts );
  2105 		$thisyear  = current_time( 'Y' );
  1987 		$thismonth = gmdate( 'm', $ts );
  2106 		$thismonth = current_time( 'm' );
  1988 	}
  2107 	}
  1989 
  2108 
  1990 	$unixmonth = mktime( 0, 0 , 0, $thismonth, 1, $thisyear );
  2109 	$unixmonth = mktime( 0, 0, 0, $thismonth, 1, $thisyear );
  1991 	$last_day = date( 't', $unixmonth );
  2110 	$last_day  = date( 't', $unixmonth );
  1992 
  2111 
  1993 	// Get the next and previous month and year with at least one post
  2112 	// Get the next and previous month and year with at least one post
  1994 	$previous = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
  2113 	$previous = $wpdb->get_row(
       
  2114 		"SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
  1995 		FROM $wpdb->posts
  2115 		FROM $wpdb->posts
  1996 		WHERE post_date < '$thisyear-$thismonth-01'
  2116 		WHERE post_date < '$thisyear-$thismonth-01'
  1997 		AND post_type = 'post' AND post_status = 'publish'
  2117 		AND post_type = 'post' AND post_status = 'publish'
  1998 			ORDER BY post_date DESC
  2118 			ORDER BY post_date DESC
  1999 			LIMIT 1");
  2119 			LIMIT 1"
  2000 	$next = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
  2120 	);
       
  2121 	$next     = $wpdb->get_row(
       
  2122 		"SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
  2001 		FROM $wpdb->posts
  2123 		FROM $wpdb->posts
  2002 		WHERE post_date > '$thisyear-$thismonth-{$last_day} 23:59:59'
  2124 		WHERE post_date > '$thisyear-$thismonth-{$last_day} 23:59:59'
  2003 		AND post_type = 'post' AND post_status = 'publish'
  2125 		AND post_type = 'post' AND post_status = 'publish'
  2004 			ORDER BY post_date ASC
  2126 			ORDER BY post_date ASC
  2005 			LIMIT 1");
  2127 			LIMIT 1"
       
  2128 	);
  2006 
  2129 
  2007 	/* translators: Calendar caption: 1: month name, 2: 4-digit year */
  2130 	/* translators: Calendar caption: 1: month name, 2: 4-digit year */
  2008 	$calendar_caption = _x('%1$s %2$s', 'calendar caption');
  2131 	$calendar_caption = _x( '%1$s %2$s', 'calendar caption' );
  2009 	$calendar_output = '<table id="wp-calendar">
  2132 	$calendar_output  = '<table id="wp-calendar">
  2010 	<caption>' . sprintf(
  2133 	<caption>' . sprintf(
  2011 		$calendar_caption,
  2134 		$calendar_caption,
  2012 		$wp_locale->get_month( $thismonth ),
  2135 		$wp_locale->get_month( $thismonth ),
  2013 		date( 'Y', $unixmonth )
  2136 		date( 'Y', $unixmonth )
  2014 	) . '</caption>
  2137 	) . '</caption>
  2020 	for ( $wdcount = 0; $wdcount <= 6; $wdcount++ ) {
  2143 	for ( $wdcount = 0; $wdcount <= 6; $wdcount++ ) {
  2021 		$myweek[] = $wp_locale->get_weekday( ( $wdcount + $week_begins ) % 7 );
  2144 		$myweek[] = $wp_locale->get_weekday( ( $wdcount + $week_begins ) % 7 );
  2022 	}
  2145 	}
  2023 
  2146 
  2024 	foreach ( $myweek as $wd ) {
  2147 	foreach ( $myweek as $wd ) {
  2025 		$day_name = $initial ? $wp_locale->get_weekday_initial( $wd ) : $wp_locale->get_weekday_abbrev( $wd );
  2148 		$day_name         = $initial ? $wp_locale->get_weekday_initial( $wd ) : $wp_locale->get_weekday_abbrev( $wd );
  2026 		$wd = esc_attr( $wd );
  2149 		$wd               = esc_attr( $wd );
  2027 		$calendar_output .= "\n\t\t<th scope=\"col\" title=\"$wd\">$day_name</th>";
  2150 		$calendar_output .= "\n\t\t<th scope=\"col\" title=\"$wd\">$day_name</th>";
  2028 	}
  2151 	}
  2029 
  2152 
  2030 	$calendar_output .= '
  2153 	$calendar_output .= '
  2031 	</tr>
  2154 	</tr>
  2033 
  2156 
  2034 	<tfoot>
  2157 	<tfoot>
  2035 	<tr>';
  2158 	<tr>';
  2036 
  2159 
  2037 	if ( $previous ) {
  2160 	if ( $previous ) {
  2038 		$calendar_output .= "\n\t\t".'<td colspan="3" id="prev"><a href="' . get_month_link( $previous->year, $previous->month ) . '">&laquo; ' .
  2161 		$calendar_output .= "\n\t\t" . '<td colspan="3" id="prev"><a href="' . get_month_link( $previous->year, $previous->month ) . '">&laquo; ' .
  2039 			$wp_locale->get_month_abbrev( $wp_locale->get_month( $previous->month ) ) .
  2162 			$wp_locale->get_month_abbrev( $wp_locale->get_month( $previous->month ) ) .
  2040 		'</a></td>';
  2163 		'</a></td>';
  2041 	} else {
  2164 	} else {
  2042 		$calendar_output .= "\n\t\t".'<td colspan="3" id="prev" class="pad">&nbsp;</td>';
  2165 		$calendar_output .= "\n\t\t" . '<td colspan="3" id="prev" class="pad">&nbsp;</td>';
  2043 	}
  2166 	}
  2044 
  2167 
  2045 	$calendar_output .= "\n\t\t".'<td class="pad">&nbsp;</td>';
  2168 	$calendar_output .= "\n\t\t" . '<td class="pad">&nbsp;</td>';
  2046 
  2169 
  2047 	if ( $next ) {
  2170 	if ( $next ) {
  2048 		$calendar_output .= "\n\t\t".'<td colspan="3" id="next"><a href="' . get_month_link( $next->year, $next->month ) . '">' .
  2171 		$calendar_output .= "\n\t\t" . '<td colspan="3" id="next"><a href="' . get_month_link( $next->year, $next->month ) . '">' .
  2049 			$wp_locale->get_month_abbrev( $wp_locale->get_month( $next->month ) ) .
  2172 			$wp_locale->get_month_abbrev( $wp_locale->get_month( $next->month ) ) .
  2050 		' &raquo;</a></td>';
  2173 		' &raquo;</a></td>';
  2051 	} else {
  2174 	} else {
  2052 		$calendar_output .= "\n\t\t".'<td colspan="3" id="next" class="pad">&nbsp;</td>';
  2175 		$calendar_output .= "\n\t\t" . '<td colspan="3" id="next" class="pad">&nbsp;</td>';
  2053 	}
  2176 	}
  2054 
  2177 
  2055 	$calendar_output .= '
  2178 	$calendar_output .= '
  2056 	</tr>
  2179 	</tr>
  2057 	</tfoot>
  2180 	</tfoot>
  2060 	<tr>';
  2183 	<tr>';
  2061 
  2184 
  2062 	$daywithpost = array();
  2185 	$daywithpost = array();
  2063 
  2186 
  2064 	// Get days with posts
  2187 	// Get days with posts
  2065 	$dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
  2188 	$dayswithposts = $wpdb->get_results(
       
  2189 		"SELECT DISTINCT DAYOFMONTH(post_date)
  2066 		FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00'
  2190 		FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00'
  2067 		AND post_type = 'post' AND post_status = 'publish'
  2191 		AND post_type = 'post' AND post_status = 'publish'
  2068 		AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'", ARRAY_N);
  2192 		AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'",
       
  2193 		ARRAY_N
       
  2194 	);
  2069 	if ( $dayswithposts ) {
  2195 	if ( $dayswithposts ) {
  2070 		foreach ( (array) $dayswithposts as $daywith ) {
  2196 		foreach ( (array) $dayswithposts as $daywith ) {
  2071 			$daywithpost[] = $daywith[0];
  2197 			$daywithpost[] = $daywith[0];
  2072 		}
  2198 		}
  2073 	}
  2199 	}
  2074 
  2200 
  2075 	// See how much we should pad in the beginning
  2201 	// See how much we should pad in the beginning
  2076 	$pad = calendar_week_mod( date( 'w', $unixmonth ) - $week_begins );
  2202 	$pad = calendar_week_mod( date( 'w', $unixmonth ) - $week_begins );
  2077 	if ( 0 != $pad ) {
  2203 	if ( 0 != $pad ) {
  2078 		$calendar_output .= "\n\t\t".'<td colspan="'. esc_attr( $pad ) .'" class="pad">&nbsp;</td>';
  2204 		$calendar_output .= "\n\t\t" . '<td colspan="' . esc_attr( $pad ) . '" class="pad">&nbsp;</td>';
  2079 	}
  2205 	}
  2080 
  2206 
  2081 	$newrow = false;
  2207 	$newrow      = false;
  2082 	$daysinmonth = (int) date( 't', $unixmonth );
  2208 	$daysinmonth = (int) date( 't', $unixmonth );
  2083 
  2209 
  2084 	for ( $day = 1; $day <= $daysinmonth; ++$day ) {
  2210 	for ( $day = 1; $day <= $daysinmonth; ++$day ) {
  2085 		if ( isset($newrow) && $newrow ) {
  2211 		if ( isset( $newrow ) && $newrow ) {
  2086 			$calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
  2212 			$calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
  2087 		}
  2213 		}
  2088 		$newrow = false;
  2214 		$newrow = false;
  2089 
  2215 
  2090 		if ( $day == gmdate( 'j', $ts ) &&
  2216 		if ( $day == current_time( 'j' ) &&
  2091 			$thismonth == gmdate( 'm', $ts ) &&
  2217 			$thismonth == current_time( 'm' ) &&
  2092 			$thisyear == gmdate( 'Y', $ts ) ) {
  2218 			$thisyear == current_time( 'Y' ) ) {
  2093 			$calendar_output .= '<td id="today">';
  2219 			$calendar_output .= '<td id="today">';
  2094 		} else {
  2220 		} else {
  2095 			$calendar_output .= '<td>';
  2221 			$calendar_output .= '<td>';
  2096 		}
  2222 		}
  2097 
  2223 
  2098 		if ( in_array( $day, $daywithpost ) ) {
  2224 		if ( in_array( $day, $daywithpost ) ) {
  2099 			// any posts today?
  2225 			// any posts today?
  2100 			$date_format = date( _x( 'F j, Y', 'daily archives date format' ), strtotime( "{$thisyear}-{$thismonth}-{$day}" ) );
  2226 			$date_format = date( _x( 'F j, Y', 'daily archives date format' ), strtotime( "{$thisyear}-{$thismonth}-{$day}" ) );
  2101 			/* translators: Post calendar label. 1: Date */
  2227 			/* translators: Post calendar label. %s: Date */
  2102 			$label = sprintf( __( 'Posts published on %s' ), $date_format );
  2228 			$label            = sprintf( __( 'Posts published on %s' ), $date_format );
  2103 			$calendar_output .= sprintf(
  2229 			$calendar_output .= sprintf(
  2104 				'<a href="%s" aria-label="%s">%s</a>',
  2230 				'<a href="%s" aria-label="%s">%s</a>',
  2105 				get_day_link( $thisyear, $thismonth, $day ),
  2231 				get_day_link( $thisyear, $thismonth, $day ),
  2106 				esc_attr( $label ),
  2232 				esc_attr( $label ),
  2107 				$day
  2233 				$day
  2109 		} else {
  2235 		} else {
  2110 			$calendar_output .= $day;
  2236 			$calendar_output .= $day;
  2111 		}
  2237 		}
  2112 		$calendar_output .= '</td>';
  2238 		$calendar_output .= '</td>';
  2113 
  2239 
  2114 		if ( 6 == calendar_week_mod( date( 'w', mktime(0, 0 , 0, $thismonth, $day, $thisyear ) ) - $week_begins ) ) {
  2240 		if ( 6 == calendar_week_mod( date( 'w', mktime( 0, 0, 0, $thismonth, $day, $thisyear ) ) - $week_begins ) ) {
  2115 			$newrow = true;
  2241 			$newrow = true;
  2116 		}
  2242 		}
  2117 	}
  2243 	}
  2118 
  2244 
  2119 	$pad = 7 - calendar_week_mod( date( 'w', mktime( 0, 0 , 0, $thismonth, $day, $thisyear ) ) - $week_begins );
  2245 	$pad = 7 - calendar_week_mod( date( 'w', mktime( 0, 0, 0, $thismonth, $day, $thisyear ) ) - $week_begins );
  2120 	if ( $pad != 0 && $pad != 7 ) {
  2246 	if ( $pad != 0 && $pad != 7 ) {
  2121 		$calendar_output .= "\n\t\t".'<td class="pad" colspan="'. esc_attr( $pad ) .'">&nbsp;</td>';
  2247 		$calendar_output .= "\n\t\t" . '<td class="pad" colspan="' . esc_attr( $pad ) . '">&nbsp;</td>';
  2122 	}
  2248 	}
  2123 	$calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>";
  2249 	$calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>";
  2124 
  2250 
  2125 	$cache[ $key ] = $calendar_output;
  2251 	$cache[ $key ] = $calendar_output;
  2126 	wp_cache_set( 'get_calendar', $cache, 'calendar' );
  2252 	wp_cache_set( 'get_calendar', $cache, 'calendar' );
  2164  */
  2290  */
  2165 function allowed_tags() {
  2291 function allowed_tags() {
  2166 	global $allowedtags;
  2292 	global $allowedtags;
  2167 	$allowed = '';
  2293 	$allowed = '';
  2168 	foreach ( (array) $allowedtags as $tag => $attributes ) {
  2294 	foreach ( (array) $allowedtags as $tag => $attributes ) {
  2169 		$allowed .= '<'.$tag;
  2295 		$allowed .= '<' . $tag;
  2170 		if ( 0 < count($attributes) ) {
  2296 		if ( 0 < count( $attributes ) ) {
  2171 			foreach ( $attributes as $attribute => $limits ) {
  2297 			foreach ( $attributes as $attribute => $limits ) {
  2172 				$allowed .= ' '.$attribute.'=""';
  2298 				$allowed .= ' ' . $attribute . '=""';
  2173 			}
  2299 			}
  2174 		}
  2300 		}
  2175 		$allowed .= '> ';
  2301 		$allowed .= '> ';
  2176 	}
  2302 	}
  2177 	return htmlentities( $allowed );
  2303 	return htmlentities( $allowed );
  2178 }
  2304 }
  2179 
  2305 
  2180 /***** Date/Time tags *****/
  2306 /***** Date/Time tags */
  2181 
  2307 
  2182 /**
  2308 /**
  2183  * Outputs the date in iso8601 format for xml files.
  2309  * Outputs the date in iso8601 format for xml files.
  2184  *
  2310  *
  2185  * @since 1.0.0
  2311  * @since 1.0.0
  2213  */
  2339  */
  2214 function the_date( $d = '', $before = '', $after = '', $echo = true ) {
  2340 function the_date( $d = '', $before = '', $after = '', $echo = true ) {
  2215 	global $currentday, $previousday;
  2341 	global $currentday, $previousday;
  2216 
  2342 
  2217 	if ( is_new_day() ) {
  2343 	if ( is_new_day() ) {
  2218 		$the_date = $before . get_the_date( $d ) . $after;
  2344 		$the_date    = $before . get_the_date( $d ) . $after;
  2219 		$previousday = $currentday;
  2345 		$previousday = $currentday;
  2220 
  2346 
  2221 		/**
  2347 		/**
  2222 		 * Filters the date a post was published for display.
  2348 		 * Filters the date a post was published for display.
  2223 		 *
  2349 		 *
  2229 		 * @param string $before   HTML output before the date.
  2355 		 * @param string $before   HTML output before the date.
  2230 		 * @param string $after    HTML output after the date.
  2356 		 * @param string $after    HTML output after the date.
  2231 		 */
  2357 		 */
  2232 		$the_date = apply_filters( 'the_date', $the_date, $d, $before, $after );
  2358 		$the_date = apply_filters( 'the_date', $the_date, $d, $before, $after );
  2233 
  2359 
  2234 		if ( $echo )
  2360 		if ( $echo ) {
  2235 			echo $the_date;
  2361 			echo $the_date;
  2236 		else
  2362 		} else {
  2237 			return $the_date;
  2363 			return $the_date;
       
  2364 		}
  2238 	}
  2365 	}
  2239 }
  2366 }
  2240 
  2367 
  2241 /**
  2368 /**
  2242  * Retrieve the date on which the post was written.
  2369  * Retrieve the date on which the post was written.
  2256 	if ( ! $post ) {
  2383 	if ( ! $post ) {
  2257 		return false;
  2384 		return false;
  2258 	}
  2385 	}
  2259 
  2386 
  2260 	if ( '' == $d ) {
  2387 	if ( '' == $d ) {
  2261 		$the_date = mysql2date( get_option( 'date_format' ), $post->post_date );
  2388 		$the_date = get_post_time( get_option( 'date_format' ), false, $post, true );
  2262 	} else {
  2389 	} else {
  2263 		$the_date = mysql2date( $d, $post->post_date );
  2390 		$the_date = get_post_time( $d, false, $post, true );
  2264 	}
  2391 	}
  2265 
  2392 
  2266 	/**
  2393 	/**
  2267 	 * Filters the date a post was published.
  2394 	 * Filters the date a post was published.
  2268 	 *
  2395 	 *
  2286  * @param string $after  Optional. Output after the date.
  2413  * @param string $after  Optional. Output after the date.
  2287  * @param bool   $echo   Optional, default is display. Whether to echo the date or return it.
  2414  * @param bool   $echo   Optional, default is display. Whether to echo the date or return it.
  2288  * @return string|void String if retrieving.
  2415  * @return string|void String if retrieving.
  2289  */
  2416  */
  2290 function the_modified_date( $d = '', $before = '', $after = '', $echo = true ) {
  2417 function the_modified_date( $d = '', $before = '', $after = '', $echo = true ) {
  2291 	$the_modified_date = $before . get_the_modified_date($d) . $after;
  2418 	$the_modified_date = $before . get_the_modified_date( $d ) . $after;
  2292 
  2419 
  2293 	/**
  2420 	/**
  2294 	 * Filters the date a post was last modified for display.
  2421 	 * Filters the date a post was last modified for display.
  2295 	 *
  2422 	 *
  2296 	 * @since 2.1.0
  2423 	 * @since 2.1.0
  2301 	 * @param string $before            HTML output before the date.
  2428 	 * @param string $before            HTML output before the date.
  2302 	 * @param string $after             HTML output after the date.
  2429 	 * @param string $after             HTML output after the date.
  2303 	 */
  2430 	 */
  2304 	$the_modified_date = apply_filters( 'the_modified_date', $the_modified_date, $d, $before, $after );
  2431 	$the_modified_date = apply_filters( 'the_modified_date', $the_modified_date, $d, $before, $after );
  2305 
  2432 
  2306 	if ( $echo )
  2433 	if ( $echo ) {
  2307 		echo $the_modified_date;
  2434 		echo $the_modified_date;
  2308 	else
  2435 	} else {
  2309 		return $the_modified_date;
  2436 		return $the_modified_date;
       
  2437 	}
  2310 
  2438 
  2311 }
  2439 }
  2312 
  2440 
  2313 /**
  2441 /**
  2314  * Retrieve the date on which the post was last modified.
  2442  * Retrieve the date on which the post was last modified.
  2373  *
  2501  *
  2374  * @param string      $d    Optional. Format to use for retrieving the time the post
  2502  * @param string      $d    Optional. Format to use for retrieving the time the post
  2375  *                          was written. Either 'G', 'U', or php date format defaults
  2503  *                          was written. Either 'G', 'U', or php date format defaults
  2376  *                          to the value specified in the time_format option. Default empty.
  2504  *                          to the value specified in the time_format option. Default empty.
  2377  * @param int|WP_Post $post WP_Post object or ID. Default is global $post object.
  2505  * @param int|WP_Post $post WP_Post object or ID. Default is global $post object.
  2378  * @return string|int|false Formatted date string or Unix timestamp if `$id` is 'U' or 'G'. False on failure.
  2506  * @return string|int|false Formatted date string or Unix timestamp if `$d` is 'U' or 'G'. False on failure.
  2379  */
  2507  */
  2380 function get_the_time( $d = '', $post = null ) {
  2508 function get_the_time( $d = '', $post = null ) {
  2381 	$post = get_post($post);
  2509 	$post = get_post( $post );
  2382 
  2510 
  2383 	if ( ! $post ) {
  2511 	if ( ! $post ) {
  2384 		return false;
  2512 		return false;
  2385 	}
  2513 	}
  2386 
  2514 
  2387 	if ( '' == $d )
  2515 	if ( '' == $d ) {
  2388 		$the_time = get_post_time(get_option('time_format'), false, $post, true);
  2516 		$the_time = get_post_time( get_option( 'time_format' ), false, $post, true );
  2389 	else
  2517 	} else {
  2390 		$the_time = get_post_time($d, false, $post, true);
  2518 		$the_time = get_post_time( $d, false, $post, true );
       
  2519 	}
  2391 
  2520 
  2392 	/**
  2521 	/**
  2393 	 * Filters the time a post was written.
  2522 	 * Filters the time a post was written.
  2394 	 *
  2523 	 *
  2395 	 * @since 1.5.0
  2524 	 * @since 1.5.0
  2411  * @param string      $d         Optional. Format to use for retrieving the time the post
  2540  * @param string      $d         Optional. Format to use for retrieving the time the post
  2412  *                               was written. Either 'G', 'U', or php date format. Default 'U'.
  2541  *                               was written. Either 'G', 'U', or php date format. Default 'U'.
  2413  * @param bool        $gmt       Optional. Whether to retrieve the GMT time. Default false.
  2542  * @param bool        $gmt       Optional. Whether to retrieve the GMT time. Default false.
  2414  * @param int|WP_Post $post      WP_Post object or ID. Default is global $post object.
  2543  * @param int|WP_Post $post      WP_Post object or ID. Default is global $post object.
  2415  * @param bool        $translate Whether to translate the time string. Default false.
  2544  * @param bool        $translate Whether to translate the time string. Default false.
  2416  * @return string|int|false Formatted date string or Unix timestamp if `$id` is 'U' or 'G'. False on failure.
  2545  * @return string|int|false Formatted date string or Unix timestamp if `$d` is 'U' or 'G'. False on failure.
  2417  */
  2546  */
  2418 function get_post_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
  2547 function get_post_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
  2419 	$post = get_post($post);
  2548 	$post = get_post( $post );
  2420 
  2549 
  2421 	if ( ! $post ) {
  2550 	if ( ! $post ) {
  2422 		return false;
  2551 		return false;
  2423 	}
  2552 	}
  2424 
  2553 
  2425 	if ( $gmt )
  2554 	if ( $gmt ) {
  2426 		$time = $post->post_date_gmt;
  2555 		$time = $post->post_date_gmt;
  2427 	else
  2556 	} else {
  2428 		$time = $post->post_date;
  2557 		$time = $post->post_date;
  2429 
  2558 	}
  2430 	$time = mysql2date($d, $time, $translate);
  2559 
       
  2560 	$time = mysql2date( $d, $time, $translate );
  2431 
  2561 
  2432 	/**
  2562 	/**
  2433 	 * Filters the localized time a post was written.
  2563 	 * Filters the localized time a post was written.
  2434 	 *
  2564 	 *
  2435 	 * @since 2.6.0
  2565 	 * @since 2.6.0
  2447  *
  2577  *
  2448  * @since 2.0.0
  2578  * @since 2.0.0
  2449  *
  2579  *
  2450  * @param string $d Optional Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
  2580  * @param string $d Optional Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
  2451  */
  2581  */
  2452 function the_modified_time($d = '') {
  2582 function the_modified_time( $d = '' ) {
  2453 	/**
  2583 	/**
  2454 	 * Filters the localized time a post was last modified, for display.
  2584 	 * Filters the localized time a post was last modified, for display.
  2455 	 *
  2585 	 *
  2456 	 * @since 2.0.0
  2586 	 * @since 2.0.0
  2457 	 *
  2587 	 *
  2458 	 * @param string $get_the_modified_time The formatted time.
  2588 	 * @param string $get_the_modified_time The formatted time.
  2459 	 * @param string $d                     The time format. Accepts 'G', 'U',
  2589 	 * @param string $d                     The time format. Accepts 'G', 'U',
  2460 	 *                                      or php date format. Defaults to value
  2590 	 *                                      or php date format. Defaults to value
  2461 	 *                                      specified in 'time_format' option.
  2591 	 *                                      specified in 'time_format' option.
  2462 	 */
  2592 	 */
  2463 	echo apply_filters( 'the_modified_time', get_the_modified_time($d), $d );
  2593 	echo apply_filters( 'the_modified_time', get_the_modified_time( $d ), $d );
  2464 }
  2594 }
  2465 
  2595 
  2466 /**
  2596 /**
  2467  * Retrieve the time at which the post was last modified.
  2597  * Retrieve the time at which the post was last modified.
  2468  *
  2598  *
  2510  * @param string      $d         Optional. Format to use for retrieving the time the post
  2640  * @param string      $d         Optional. Format to use for retrieving the time the post
  2511  *                               was modified. Either 'G', 'U', or php date format. Default 'U'.
  2641  *                               was modified. Either 'G', 'U', or php date format. Default 'U'.
  2512  * @param bool        $gmt       Optional. Whether to retrieve the GMT time. Default false.
  2642  * @param bool        $gmt       Optional. Whether to retrieve the GMT time. Default false.
  2513  * @param int|WP_Post $post      WP_Post object or ID. Default is global $post object.
  2643  * @param int|WP_Post $post      WP_Post object or ID. Default is global $post object.
  2514  * @param bool        $translate Whether to translate the time string. Default false.
  2644  * @param bool        $translate Whether to translate the time string. Default false.
  2515  * @return string|int|false Formatted date string or Unix timestamp if `$id` is 'U' or 'G'. False on failure.
  2645  * @return string|int|false Formatted date string or Unix timestamp if `$d` is 'U' or 'G'. False on failure.
  2516  */
  2646  */
  2517 function get_post_modified_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
  2647 function get_post_modified_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
  2518 	$post = get_post($post);
  2648 	$post = get_post( $post );
  2519 
  2649 
  2520 	if ( ! $post ) {
  2650 	if ( ! $post ) {
  2521 		return false;
  2651 		return false;
  2522 	}
  2652 	}
  2523 
  2653 
  2524 	if ( $gmt )
  2654 	if ( $gmt ) {
  2525 		$time = $post->post_modified_gmt;
  2655 		$time = $post->post_modified_gmt;
  2526 	else
  2656 	} else {
  2527 		$time = $post->post_modified;
  2657 		$time = $post->post_modified;
  2528 	$time = mysql2date($d, $time, $translate);
  2658 	}
       
  2659 	$time = mysql2date( $d, $time, $translate );
  2529 
  2660 
  2530 	/**
  2661 	/**
  2531 	 * Filters the localized time a post was last modified.
  2662 	 * Filters the localized time a post was last modified.
  2532 	 *
  2663 	 *
  2533 	 * @since 2.8.0
  2664 	 * @since 2.8.0
  2573  * @global string|int|bool $previousweekday
  2704  * @global string|int|bool $previousweekday
  2574  *
  2705  *
  2575  * @param string $before Optional Output before the date.
  2706  * @param string $before Optional Output before the date.
  2576  * @param string $after Optional Output after the date.
  2707  * @param string $after Optional Output after the date.
  2577  */
  2708  */
  2578 function the_weekday_date($before='',$after='') {
  2709 function the_weekday_date( $before = '', $after = '' ) {
  2579 	global $wp_locale, $currentday, $previousweekday;
  2710 	global $wp_locale, $currentday, $previousweekday;
  2580 	$the_weekday_date = '';
  2711 	$the_weekday_date = '';
  2581 	if ( $currentday != $previousweekday ) {
  2712 	if ( $currentday != $previousweekday ) {
  2582 		$the_weekday_date .= $before;
  2713 		$the_weekday_date .= $before;
  2583 		$the_weekday_date .= $wp_locale->get_weekday( mysql2date( 'w', get_post()->post_date, false ) );
  2714 		$the_weekday_date .= $wp_locale->get_weekday( mysql2date( 'w', get_post()->post_date, false ) );
  2584 		$the_weekday_date .= $after;
  2715 		$the_weekday_date .= $after;
  2585 		$previousweekday = $currentday;
  2716 		$previousweekday   = $currentday;
  2586 	}
  2717 	}
  2587 
  2718 
  2588 	/**
  2719 	/**
  2589 	 * Filters the localized date on which the post was written, for display.
  2720 	 * Filters the localized date on which the post was written, for display.
  2590 	 *
  2721 	 *
  2629 	 */
  2760 	 */
  2630 	do_action( 'wp_footer' );
  2761 	do_action( 'wp_footer' );
  2631 }
  2762 }
  2632 
  2763 
  2633 /**
  2764 /**
       
  2765  * Fire the wp_body_open action.
       
  2766  *
       
  2767  * * See {@see 'wp_body_open'}.
       
  2768  *
       
  2769  * @since 5.2.0
       
  2770  */
       
  2771 function wp_body_open() {
       
  2772 	/**
       
  2773 	 * Triggered after the opening <body> tag.
       
  2774 	 *
       
  2775 	 * @since 5.2.0
       
  2776 	 */
       
  2777 	do_action( 'wp_body_open' );
       
  2778 }
       
  2779 
       
  2780 /**
  2634  * Display the links to the general feeds.
  2781  * Display the links to the general feeds.
  2635  *
  2782  *
  2636  * @since 2.8.0
  2783  * @since 2.8.0
  2637  *
  2784  *
  2638  * @param array $args Optional arguments.
  2785  * @param array $args Optional arguments.
  2639  */
  2786  */
  2640 function feed_links( $args = array() ) {
  2787 function feed_links( $args = array() ) {
  2641 	if ( !current_theme_supports('automatic-feed-links') )
  2788 	if ( ! current_theme_supports( 'automatic-feed-links' ) ) {
  2642 		return;
  2789 		return;
       
  2790 	}
  2643 
  2791 
  2644 	$defaults = array(
  2792 	$defaults = array(
  2645 		/* translators: Separator between blog name and feed type in feed links */
  2793 		/* translators: Separator between blog name and feed type in feed links */
  2646 		'separator'	=> _x('&raquo;', 'feed link'),
  2794 		'separator' => _x( '&raquo;', 'feed link' ),
  2647 		/* translators: 1: blog title, 2: separator (raquo) */
  2795 		/* translators: 1: blog title, 2: separator (raquo) */
  2648 		'feedtitle'	=> __('%1$s %2$s Feed'),
  2796 		'feedtitle' => __( '%1$s %2$s Feed' ),
  2649 		/* translators: 1: blog title, 2: separator (raquo) */
  2797 		/* translators: 1: blog title, 2: separator (raquo) */
  2650 		'comstitle'	=> __('%1$s %2$s Comments Feed'),
  2798 		'comstitle' => __( '%1$s %2$s Comments Feed' ),
  2651 	);
  2799 	);
  2652 
  2800 
  2653 	$args = wp_parse_args( $args, $defaults );
  2801 	$args = wp_parse_args( $args, $defaults );
  2654 
  2802 
  2655 	/**
  2803 	/**
  2683  * @param array $args Optional arguments.
  2831  * @param array $args Optional arguments.
  2684  */
  2832  */
  2685 function feed_links_extra( $args = array() ) {
  2833 function feed_links_extra( $args = array() ) {
  2686 	$defaults = array(
  2834 	$defaults = array(
  2687 		/* translators: Separator between blog name and feed type in feed links */
  2835 		/* translators: Separator between blog name and feed type in feed links */
  2688 		'separator'   => _x('&raquo;', 'feed link'),
  2836 		'separator'     => _x( '&raquo;', 'feed link' ),
  2689 		/* translators: 1: blog name, 2: separator(raquo), 3: post title */
  2837 		/* translators: 1: blog name, 2: separator(raquo), 3: post title */
  2690 		'singletitle' => __('%1$s %2$s %3$s Comments Feed'),
  2838 		'singletitle'   => __( '%1$s %2$s %3$s Comments Feed' ),
  2691 		/* translators: 1: blog name, 2: separator(raquo), 3: category name */
  2839 		/* translators: 1: blog name, 2: separator(raquo), 3: category name */
  2692 		'cattitle'    => __('%1$s %2$s %3$s Category Feed'),
  2840 		'cattitle'      => __( '%1$s %2$s %3$s Category Feed' ),
  2693 		/* translators: 1: blog name, 2: separator(raquo), 3: tag name */
  2841 		/* translators: 1: blog name, 2: separator(raquo), 3: tag name */
  2694 		'tagtitle'    => __('%1$s %2$s %3$s Tag Feed'),
  2842 		'tagtitle'      => __( '%1$s %2$s %3$s Tag Feed' ),
  2695 		/* translators: 1: blog name, 2: separator(raquo), 3: term name, 4: taxonomy singular name */
  2843 		/* translators: 1: blog name, 2: separator(raquo), 3: term name, 4: taxonomy singular name */
  2696 		'taxtitle'    => __('%1$s %2$s %3$s %4$s Feed'),
  2844 		'taxtitle'      => __( '%1$s %2$s %3$s %4$s Feed' ),
  2697 		/* translators: 1: blog name, 2: separator(raquo), 3: author name  */
  2845 		/* translators: 1: blog name, 2: separator(raquo), 3: author name  */
  2698 		'authortitle' => __('%1$s %2$s Posts by %3$s Feed'),
  2846 		'authortitle'   => __( '%1$s %2$s Posts by %3$s Feed' ),
  2699 		/* translators: 1: blog name, 2: separator(raquo), 3: search phrase */
  2847 		/* translators: 1: blog name, 2: separator(raquo), 3: search phrase */
  2700 		'searchtitle' => __('%1$s %2$s Search Results for &#8220;%3$s&#8221; Feed'),
  2848 		'searchtitle'   => __( '%1$s %2$s Search Results for &#8220;%3$s&#8221; Feed' ),
  2701 		/* translators: 1: blog name, 2: separator(raquo), 3: post type name */
  2849 		/* translators: 1: blog name, 2: separator(raquo), 3: post type name */
  2702 		'posttypetitle' => __('%1$s %2$s %3$s Feed'),
  2850 		'posttypetitle' => __( '%1$s %2$s %3$s Feed' ),
  2703 	);
  2851 	);
  2704 
  2852 
  2705 	$args = wp_parse_args( $args, $defaults );
  2853 	$args = wp_parse_args( $args, $defaults );
  2706 
  2854 
  2707 	if ( is_singular() ) {
  2855 	if ( is_singular() ) {
  2708 		$id = 0;
  2856 		$id   = 0;
  2709 		$post = get_post( $id );
  2857 		$post = get_post( $id );
  2710 
  2858 
  2711 		if ( comments_open() || pings_open() || $post->comment_count > 0 ) {
  2859 		if ( comments_open() || pings_open() || $post->comment_count > 0 ) {
  2712 			$title = sprintf( $args['singletitle'], get_bloginfo('name'), $args['separator'], the_title_attribute( array( 'echo' => false ) ) );
  2860 			$title = sprintf( $args['singletitle'], get_bloginfo( 'name' ), $args['separator'], the_title_attribute( array( 'echo' => false ) ) );
  2713 			$href = get_post_comments_feed_link( $post->ID );
  2861 			$href  = get_post_comments_feed_link( $post->ID );
  2714 		}
  2862 		}
  2715 	} elseif ( is_post_type_archive() ) {
  2863 	} elseif ( is_post_type_archive() ) {
  2716 		$post_type = get_query_var( 'post_type' );
  2864 		$post_type = get_query_var( 'post_type' );
  2717 		if ( is_array( $post_type ) )
  2865 		if ( is_array( $post_type ) ) {
  2718 			$post_type = reset( $post_type );
  2866 			$post_type = reset( $post_type );
       
  2867 		}
  2719 
  2868 
  2720 		$post_type_obj = get_post_type_object( $post_type );
  2869 		$post_type_obj = get_post_type_object( $post_type );
  2721 		$title = sprintf( $args['posttypetitle'], get_bloginfo( 'name' ), $args['separator'], $post_type_obj->labels->name );
  2870 		$title         = sprintf( $args['posttypetitle'], get_bloginfo( 'name' ), $args['separator'], $post_type_obj->labels->name );
  2722 		$href = get_post_type_archive_feed_link( $post_type_obj->name );
  2871 		$href          = get_post_type_archive_feed_link( $post_type_obj->name );
  2723 	} elseif ( is_category() ) {
  2872 	} elseif ( is_category() ) {
  2724 		$term = get_queried_object();
  2873 		$term = get_queried_object();
  2725 
  2874 
  2726 		if ( $term ) {
  2875 		if ( $term ) {
  2727 			$title = sprintf( $args['cattitle'], get_bloginfo('name'), $args['separator'], $term->name );
  2876 			$title = sprintf( $args['cattitle'], get_bloginfo( 'name' ), $args['separator'], $term->name );
  2728 			$href = get_category_feed_link( $term->term_id );
  2877 			$href  = get_category_feed_link( $term->term_id );
  2729 		}
  2878 		}
  2730 	} elseif ( is_tag() ) {
  2879 	} elseif ( is_tag() ) {
  2731 		$term = get_queried_object();
  2880 		$term = get_queried_object();
  2732 
  2881 
  2733 		if ( $term ) {
  2882 		if ( $term ) {
  2734 			$title = sprintf( $args['tagtitle'], get_bloginfo('name'), $args['separator'], $term->name );
  2883 			$title = sprintf( $args['tagtitle'], get_bloginfo( 'name' ), $args['separator'], $term->name );
  2735 			$href = get_tag_feed_link( $term->term_id );
  2884 			$href  = get_tag_feed_link( $term->term_id );
  2736 		}
  2885 		}
  2737 	} elseif ( is_tax() ) {
  2886 	} elseif ( is_tax() ) {
  2738  		$term = get_queried_object();
  2887 		$term  = get_queried_object();
  2739  		$tax = get_taxonomy( $term->taxonomy );
  2888 		$tax   = get_taxonomy( $term->taxonomy );
  2740  		$title = sprintf( $args['taxtitle'], get_bloginfo('name'), $args['separator'], $term->name, $tax->labels->singular_name );
  2889 		$title = sprintf( $args['taxtitle'], get_bloginfo( 'name' ), $args['separator'], $term->name, $tax->labels->singular_name );
  2741  		$href = get_term_feed_link( $term->term_id, $term->taxonomy );
  2890 		$href  = get_term_feed_link( $term->term_id, $term->taxonomy );
  2742 	} elseif ( is_author() ) {
  2891 	} elseif ( is_author() ) {
  2743 		$author_id = intval( get_query_var('author') );
  2892 		$author_id = intval( get_query_var( 'author' ) );
  2744 
  2893 
  2745 		$title = sprintf( $args['authortitle'], get_bloginfo('name'), $args['separator'], get_the_author_meta( 'display_name', $author_id ) );
  2894 		$title = sprintf( $args['authortitle'], get_bloginfo( 'name' ), $args['separator'], get_the_author_meta( 'display_name', $author_id ) );
  2746 		$href = get_author_feed_link( $author_id );
  2895 		$href  = get_author_feed_link( $author_id );
  2747 	} elseif ( is_search() ) {
  2896 	} elseif ( is_search() ) {
  2748 		$title = sprintf( $args['searchtitle'], get_bloginfo('name'), $args['separator'], get_search_query( false ) );
  2897 		$title = sprintf( $args['searchtitle'], get_bloginfo( 'name' ), $args['separator'], get_search_query( false ) );
  2749 		$href = get_search_feed_link();
  2898 		$href  = get_search_feed_link();
  2750 	} elseif ( is_post_type_archive() ) {
  2899 	} elseif ( is_post_type_archive() ) {
  2751 		$title = sprintf( $args['posttypetitle'], get_bloginfo('name'), $args['separator'], post_type_archive_title( '', false ) );
  2900 		$title         = sprintf( $args['posttypetitle'], get_bloginfo( 'name' ), $args['separator'], post_type_archive_title( '', false ) );
  2752 		$post_type_obj = get_queried_object();
  2901 		$post_type_obj = get_queried_object();
  2753 		if ( $post_type_obj )
  2902 		if ( $post_type_obj ) {
  2754 			$href = get_post_type_archive_feed_link( $post_type_obj->name );
  2903 			$href = get_post_type_archive_feed_link( $post_type_obj->name );
  2755 	}
  2904 		}
  2756 
  2905 	}
  2757 	if ( isset($title) && isset($href) )
  2906 
       
  2907 	if ( isset( $title ) && isset( $href ) ) {
  2758 		echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( $title ) . '" href="' . esc_url( $href ) . '" />' . "\n";
  2908 		echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( $title ) . '" href="' . esc_url( $href ) . '" />' . "\n";
       
  2909 	}
  2759 }
  2910 }
  2760 
  2911 
  2761 /**
  2912 /**
  2762  * Display the link to the Really Simple Discovery service endpoint.
  2913  * Display the link to the Really Simple Discovery service endpoint.
  2763  *
  2914  *
  2794  *
  2945  *
  2795  * @since 2.1.0
  2946  * @since 2.1.0
  2796  */
  2947  */
  2797 function noindex() {
  2948 function noindex() {
  2798 	// If the blog is not public, tell robots to go away.
  2949 	// If the blog is not public, tell robots to go away.
  2799 	if ( '0' == get_option('blog_public') )
  2950 	if ( '0' == get_option( 'blog_public' ) ) {
  2800 		wp_no_robots();
  2951 		wp_no_robots();
       
  2952 	}
  2801 }
  2953 }
  2802 
  2954 
  2803 /**
  2955 /**
  2804  * Display a noindex meta tag.
  2956  * Display a noindex meta tag.
  2805  *
  2957  *
  2808  *
  2960  *
  2809  * @since 3.3.0
  2961  * @since 3.3.0
  2810  */
  2962  */
  2811 function wp_no_robots() {
  2963 function wp_no_robots() {
  2812 	echo "<meta name='robots' content='noindex,follow' />\n";
  2964 	echo "<meta name='robots' content='noindex,follow' />\n";
       
  2965 }
       
  2966 
       
  2967 /**
       
  2968  * Display a noindex,noarchive meta tag and referrer origin-when-cross-origin meta tag.
       
  2969  *
       
  2970  * Outputs a noindex,noarchive meta tag that tells web robots not to index or cache the page content.
       
  2971  * Outputs a referrer origin-when-cross-origin meta tag that tells the browser not to send the full
       
  2972  * url as a referrer to other sites when cross-origin assets are loaded.
       
  2973  *
       
  2974  * Typical usage is as a wp_head callback. add_action( 'wp_head', 'wp_sensitive_page_meta' );
       
  2975  *
       
  2976  * @since 5.0.1
       
  2977  */
       
  2978 function wp_sensitive_page_meta() {
       
  2979 	?>
       
  2980 	<meta name='robots' content='noindex,noarchive' />
       
  2981 	<meta name='referrer' content='strict-origin-when-cross-origin' />
       
  2982 	<?php
  2813 }
  2983 }
  2814 
  2984 
  2815 /**
  2985 /**
  2816  * Display site icon meta tags.
  2986  * Display site icon meta tags.
  2817  *
  2987  *
  2823 	if ( ! has_site_icon() && ! is_customize_preview() ) {
  2993 	if ( ! has_site_icon() && ! is_customize_preview() ) {
  2824 		return;
  2994 		return;
  2825 	}
  2995 	}
  2826 
  2996 
  2827 	$meta_tags = array();
  2997 	$meta_tags = array();
  2828 	$icon_32 = get_site_icon_url( 32 );
  2998 	$icon_32   = get_site_icon_url( 32 );
  2829 	if ( empty( $icon_32 ) && is_customize_preview() ) {
  2999 	if ( empty( $icon_32 ) && is_customize_preview() ) {
  2830 		$icon_32 = '/favicon.ico'; // Serve default favicon URL in customizer so element can be updated for preview.
  3000 		$icon_32 = '/favicon.ico'; // Serve default favicon URL in customizer so element can be updated for preview.
  2831 	}
  3001 	}
  2832 	if ( $icon_32 ) {
  3002 	if ( $icon_32 ) {
  2833 		$meta_tags[] = sprintf( '<link rel="icon" href="%s" sizes="32x32" />', esc_url( $icon_32 ) );
  3003 		$meta_tags[] = sprintf( '<link rel="icon" href="%s" sizes="32x32" />', esc_url( $icon_32 ) );
  2844 	if ( $icon_270 ) {
  3014 	if ( $icon_270 ) {
  2845 		$meta_tags[] = sprintf( '<meta name="msapplication-TileImage" content="%s" />', esc_url( $icon_270 ) );
  3015 		$meta_tags[] = sprintf( '<meta name="msapplication-TileImage" content="%s" />', esc_url( $icon_270 ) );
  2846 	}
  3016 	}
  2847 
  3017 
  2848 	/**
  3018 	/**
  2849 	 * Filters the site icon meta tags, so Plugins can add their own.
  3019 	 * Filters the site icon meta tags, so plugins can add their own.
  2850 	 *
  3020 	 *
  2851 	 * @since 4.3.0
  3021 	 * @since 4.3.0
  2852 	 *
  3022 	 *
  2853 	 * @param array $meta_tags Site Icon meta elements.
  3023 	 * @param string[] $meta_tags Array of Site Icon meta tags.
  2854 	 */
  3024 	 */
  2855 	$meta_tags = apply_filters( 'site_icon_meta_tags', $meta_tags );
  3025 	$meta_tags = apply_filters( 'site_icon_meta_tags', $meta_tags );
  2856 	$meta_tags = array_filter( $meta_tags );
  3026 	$meta_tags = array_filter( $meta_tags );
  2857 
  3027 
  2858 	foreach ( $meta_tags as $meta_tag ) {
  3028 	foreach ( $meta_tags as $meta_tag ) {
  2883 	/*
  3053 	/*
  2884 	 * Add DNS prefetch for the Emoji CDN.
  3054 	 * Add DNS prefetch for the Emoji CDN.
  2885 	 * The path is removed in the foreach loop below.
  3055 	 * The path is removed in the foreach loop below.
  2886 	 */
  3056 	 */
  2887 	/** This filter is documented in wp-includes/formatting.php */
  3057 	/** This filter is documented in wp-includes/formatting.php */
  2888 	$hints['dns-prefetch'][] = apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/11/svg/' );
  3058 	$hints['dns-prefetch'][] = apply_filters( 'emoji_svg_url', 'https://s.w.org/images/core/emoji/12.0.0-1/svg/' );
  2889 
  3059 
  2890 	foreach ( $hints as $relation_type => $urls ) {
  3060 	foreach ( $hints as $relation_type => $urls ) {
  2891 		$unique_urls = array();
  3061 		$unique_urls = array();
  2892 
  3062 
  2893 		/**
  3063 		/**
  2935 					// Use protocol-relative URLs for dns-prefetch or if scheme is missing.
  3105 					// Use protocol-relative URLs for dns-prefetch or if scheme is missing.
  2936 					$url = '//' . $parsed['host'];
  3106 					$url = '//' . $parsed['host'];
  2937 				}
  3107 				}
  2938 			}
  3108 			}
  2939 
  3109 
  2940 			$atts['rel'] = $relation_type;
  3110 			$atts['rel']  = $relation_type;
  2941 			$atts['href'] = $url;
  3111 			$atts['href'] = $url;
  2942 
  3112 
  2943 			$unique_urls[ $url ] = $atts;
  3113 			$unique_urls[ $url ] = $atts;
  2944 		}
  3114 		}
  2945 
  3115 
  2946 		foreach ( $unique_urls as $atts ) {
  3116 		foreach ( $unique_urls as $atts ) {
  2947 			$html = '';
  3117 			$html = '';
  2948 
  3118 
  2949 			foreach ( $atts as $attr => $value ) {
  3119 			foreach ( $atts as $attr => $value ) {
  2950 				if ( ! is_scalar( $value ) ||
  3120 				if ( ! is_scalar( $value ) ||
  2951 				     ( ! in_array( $attr, array( 'as', 'crossorigin', 'href', 'pr', 'rel', 'type' ), true ) && ! is_numeric( $attr ))
  3121 					( ! in_array( $attr, array( 'as', 'crossorigin', 'href', 'pr', 'rel', 'type' ), true ) && ! is_numeric( $attr ) ) ) {
  2952 				) {
  3122 
  2953 					continue;
  3123 					continue;
  2954 				}
  3124 				}
  2955 
  3125 
  2956 				$value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
  3126 				$value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
  2957 
  3127 
  3020  * @return bool True if the user can access the visual editor, false otherwise.
  3190  * @return bool True if the user can access the visual editor, false otherwise.
  3021  */
  3191  */
  3022 function user_can_richedit() {
  3192 function user_can_richedit() {
  3023 	global $wp_rich_edit, $is_gecko, $is_opera, $is_safari, $is_chrome, $is_IE, $is_edge;
  3193 	global $wp_rich_edit, $is_gecko, $is_opera, $is_safari, $is_chrome, $is_IE, $is_edge;
  3024 
  3194 
  3025 	if ( !isset($wp_rich_edit) ) {
  3195 	if ( ! isset( $wp_rich_edit ) ) {
  3026 		$wp_rich_edit = false;
  3196 		$wp_rich_edit = false;
  3027 
  3197 
  3028 		if ( get_user_option( 'rich_editing' ) == 'true' || ! is_user_logged_in() ) { // default to 'true' for logged out users
  3198 		if ( get_user_option( 'rich_editing' ) == 'true' || ! is_user_logged_in() ) { // default to 'true' for logged out users
  3029 			if ( $is_safari ) {
  3199 			if ( $is_safari ) {
  3030 				$wp_rich_edit = ! wp_is_mobile() || ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval( $match[1] ) >= 534 );
  3200 				$wp_rich_edit = ! wp_is_mobile() || ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval( $match[1] ) >= 534 );
  3031 			} elseif ( $is_IE ) {
  3201 			} elseif ( $is_IE ) {
  3032 				$wp_rich_edit = ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Trident/7.0;' ) !== false );
  3202 				$wp_rich_edit = ( strpos( $_SERVER['HTTP_USER_AGENT'], 'Trident/7.0;' ) !== false );
  3033 			} elseif ( $is_gecko || $is_chrome || $is_edge || ( $is_opera && !wp_is_mobile() ) ) {
  3203 			} elseif ( $is_gecko || $is_chrome || $is_edge || ( $is_opera && ! wp_is_mobile() ) ) {
  3034 				$wp_rich_edit = true;
  3204 				$wp_rich_edit = true;
  3035 			}
  3205 			}
  3036 		}
  3206 		}
  3037 	}
  3207 	}
  3038 
  3208 
  3057  * @return string Either 'tinymce', or 'html', or 'test'
  3227  * @return string Either 'tinymce', or 'html', or 'test'
  3058  */
  3228  */
  3059 function wp_default_editor() {
  3229 function wp_default_editor() {
  3060 	$r = user_can_richedit() ? 'tinymce' : 'html'; // defaults
  3230 	$r = user_can_richedit() ? 'tinymce' : 'html'; // defaults
  3061 	if ( wp_get_current_user() ) { // look for cookie
  3231 	if ( wp_get_current_user() ) { // look for cookie
  3062 		$ed = get_user_setting('editor', 'tinymce');
  3232 		$ed = get_user_setting( 'editor', 'tinymce' );
  3063 		$r = ( in_array($ed, array('tinymce', 'html', 'test') ) ) ? $ed : $r;
  3233 		$r  = ( in_array( $ed, array( 'tinymce', 'html', 'test' ) ) ) ? $ed : $r;
  3064 	}
  3234 	}
  3065 
  3235 
  3066 	/**
  3236 	/**
  3067 	 * Filters which editor should be displayed by default.
  3237 	 * Filters which editor should be displayed by default.
  3068 	 *
  3238 	 *
  3091  * @param string $content   Initial content for the editor.
  3261  * @param string $content   Initial content for the editor.
  3092  * @param string $editor_id HTML ID attribute value for the textarea and TinyMCE. Can only be /[a-z]+/.
  3262  * @param string $editor_id HTML ID attribute value for the textarea and TinyMCE. Can only be /[a-z]+/.
  3093  * @param array  $settings  See _WP_Editors::editor().
  3263  * @param array  $settings  See _WP_Editors::editor().
  3094  */
  3264  */
  3095 function wp_editor( $content, $editor_id, $settings = array() ) {
  3265 function wp_editor( $content, $editor_id, $settings = array() ) {
  3096 	if ( ! class_exists( '_WP_Editors', false ) )
  3266 	if ( ! class_exists( '_WP_Editors', false ) ) {
  3097 		require( ABSPATH . WPINC . '/class-wp-editor.php' );
  3267 		require( ABSPATH . WPINC . '/class-wp-editor.php' );
  3098 	_WP_Editors::editor($content, $editor_id, $settings);
  3268 	}
       
  3269 	_WP_Editors::editor( $content, $editor_id, $settings );
  3099 }
  3270 }
  3100 
  3271 
  3101 /**
  3272 /**
  3102  * Outputs the editor scripts, stylesheets, and default settings.
  3273  * Outputs the editor scripts, stylesheets, and default settings.
  3103  *
  3274  *
  3119  * Enqueue assets needed by the code editor for the given settings.
  3290  * Enqueue assets needed by the code editor for the given settings.
  3120  *
  3291  *
  3121  * @since 4.9.0
  3292  * @since 4.9.0
  3122  *
  3293  *
  3123  * @see wp_enqueue_editor()
  3294  * @see wp_enqueue_editor()
       
  3295  * @see wp_get_code_editor_settings();
  3124  * @see _WP_Editors::parse_settings()
  3296  * @see _WP_Editors::parse_settings()
       
  3297  *
  3125  * @param array $args {
  3298  * @param array $args {
  3126  *     Args.
  3299  *     Args.
  3127  *
  3300  *
  3128  *     @type string   $type       The MIME type of the file to be edited.
  3301  *     @type string   $type       The MIME type of the file to be edited.
  3129  *     @type string   $file       Filename to be edited. Extension is used to sniff the type. Can be supplied as alternative to `$type` param.
  3302  *     @type string   $file       Filename to be edited. Extension is used to sniff the type. Can be supplied as alternative to `$type` param.
  3132  *     @type array    $codemirror Additional CodeMirror setting overrides.
  3305  *     @type array    $codemirror Additional CodeMirror setting overrides.
  3133  *     @type array    $csslint    CSSLint rule overrides.
  3306  *     @type array    $csslint    CSSLint rule overrides.
  3134  *     @type array    $jshint     JSHint rule overrides.
  3307  *     @type array    $jshint     JSHint rule overrides.
  3135  *     @type array    $htmlhint   JSHint rule overrides.
  3308  *     @type array    $htmlhint   JSHint rule overrides.
  3136  * }
  3309  * }
  3137  * @returns array|false Settings for the enqueued code editor, or false if the editor was not enqueued .
  3310  * @return array|false Settings for the enqueued code editor, or false if the editor was not enqueued.
  3138  */
  3311  */
  3139 function wp_enqueue_code_editor( $args ) {
  3312 function wp_enqueue_code_editor( $args ) {
  3140 	if ( is_user_logged_in() && 'false' === wp_get_current_user()->syntax_highlighting ) {
  3313 	if ( is_user_logged_in() && 'false' === wp_get_current_user()->syntax_highlighting ) {
  3141 		return false;
  3314 		return false;
  3142 	}
  3315 	}
  3143 
  3316 
       
  3317 	$settings = wp_get_code_editor_settings( $args );
       
  3318 
       
  3319 	if ( empty( $settings ) || empty( $settings['codemirror'] ) ) {
       
  3320 		return false;
       
  3321 	}
       
  3322 
       
  3323 	wp_enqueue_script( 'code-editor' );
       
  3324 	wp_enqueue_style( 'code-editor' );
       
  3325 
       
  3326 	if ( isset( $settings['codemirror']['mode'] ) ) {
       
  3327 		$mode = $settings['codemirror']['mode'];
       
  3328 		if ( is_string( $mode ) ) {
       
  3329 			$mode = array(
       
  3330 				'name' => $mode,
       
  3331 			);
       
  3332 		}
       
  3333 
       
  3334 		if ( ! empty( $settings['codemirror']['lint'] ) ) {
       
  3335 			switch ( $mode['name'] ) {
       
  3336 				case 'css':
       
  3337 				case 'text/css':
       
  3338 				case 'text/x-scss':
       
  3339 				case 'text/x-less':
       
  3340 					wp_enqueue_script( 'csslint' );
       
  3341 					break;
       
  3342 				case 'htmlmixed':
       
  3343 				case 'text/html':
       
  3344 				case 'php':
       
  3345 				case 'application/x-httpd-php':
       
  3346 				case 'text/x-php':
       
  3347 					wp_enqueue_script( 'htmlhint' );
       
  3348 					wp_enqueue_script( 'csslint' );
       
  3349 					wp_enqueue_script( 'jshint' );
       
  3350 					if ( ! current_user_can( 'unfiltered_html' ) ) {
       
  3351 						wp_enqueue_script( 'htmlhint-kses' );
       
  3352 					}
       
  3353 					break;
       
  3354 				case 'javascript':
       
  3355 				case 'application/ecmascript':
       
  3356 				case 'application/json':
       
  3357 				case 'application/javascript':
       
  3358 				case 'application/ld+json':
       
  3359 				case 'text/typescript':
       
  3360 				case 'application/typescript':
       
  3361 					wp_enqueue_script( 'jshint' );
       
  3362 					wp_enqueue_script( 'jsonlint' );
       
  3363 					break;
       
  3364 			}
       
  3365 		}
       
  3366 	}
       
  3367 
       
  3368 	wp_add_inline_script( 'code-editor', sprintf( 'jQuery.extend( wp.codeEditor.defaultSettings, %s );', wp_json_encode( $settings ) ) );
       
  3369 
       
  3370 	/**
       
  3371 	 * Fires when scripts and styles are enqueued for the code editor.
       
  3372 	 *
       
  3373 	 * @since 4.9.0
       
  3374 	 *
       
  3375 	 * @param array $settings Settings for the enqueued code editor.
       
  3376 	 */
       
  3377 	do_action( 'wp_enqueue_code_editor', $settings );
       
  3378 
       
  3379 	return $settings;
       
  3380 }
       
  3381 
       
  3382 /**
       
  3383  * Generate and return code editor settings.
       
  3384  *
       
  3385  * @since 5.0.0
       
  3386  *
       
  3387  * @see wp_enqueue_code_editor()
       
  3388  *
       
  3389  * @param array $args {
       
  3390  *     Args.
       
  3391  *
       
  3392  *     @type string   $type       The MIME type of the file to be edited.
       
  3393  *     @type string   $file       Filename to be edited. Extension is used to sniff the type. Can be supplied as alternative to `$type` param.
       
  3394  *     @type WP_Theme $theme      Theme being edited when on theme editor.
       
  3395  *     @type string   $plugin     Plugin being edited when on plugin editor.
       
  3396  *     @type array    $codemirror Additional CodeMirror setting overrides.
       
  3397  *     @type array    $csslint    CSSLint rule overrides.
       
  3398  *     @type array    $jshint     JSHint rule overrides.
       
  3399  *     @type array    $htmlhint   JSHint rule overrides.
       
  3400  * }
       
  3401  * @return array|false Settings for the code editor.
       
  3402  */
       
  3403 function wp_get_code_editor_settings( $args ) {
  3144 	$settings = array(
  3404 	$settings = array(
  3145 		'codemirror' => array(
  3405 		'codemirror' => array(
  3146 			'indentUnit' => 4,
  3406 			'indentUnit'       => 4,
  3147 			'indentWithTabs' => true,
  3407 			'indentWithTabs'   => true,
  3148 			'inputStyle' => 'contenteditable',
  3408 			'inputStyle'       => 'contenteditable',
  3149 			'lineNumbers' => true,
  3409 			'lineNumbers'      => true,
  3150 			'lineWrapping' => true,
  3410 			'lineWrapping'     => true,
  3151 			'styleActiveLine' => true,
  3411 			'styleActiveLine'  => true,
  3152 			'continueComments' => true,
  3412 			'continueComments' => true,
  3153 			'extraKeys' => array(
  3413 			'extraKeys'        => array(
  3154 				'Ctrl-Space' => 'autocomplete',
  3414 				'Ctrl-Space' => 'autocomplete',
  3155 				'Ctrl-/' => 'toggleComment',
  3415 				'Ctrl-/'     => 'toggleComment',
  3156 				'Cmd-/' => 'toggleComment',
  3416 				'Cmd-/'      => 'toggleComment',
  3157 				'Alt-F' => 'findPersistent',
  3417 				'Alt-F'      => 'findPersistent',
  3158 				'Ctrl-F'     => 'findPersistent',
  3418 				'Ctrl-F'     => 'findPersistent',
  3159 				'Cmd-F'      => 'findPersistent',
  3419 				'Cmd-F'      => 'findPersistent',
  3160 			),
  3420 			),
  3161 			'direction' => 'ltr', // Code is shown in LTR even in RTL languages.
  3421 			'direction'        => 'ltr', // Code is shown in LTR even in RTL languages.
  3162 			'gutters' => array(),
  3422 			'gutters'          => array(),
  3163 		),
  3423 		),
  3164 		'csslint' => array(
  3424 		'csslint'    => array(
  3165 			'errors' => true, // Parsing errors.
  3425 			'errors'                    => true, // Parsing errors.
  3166 			'box-model' => true,
  3426 			'box-model'                 => true,
  3167 			'display-property-grouping' => true,
  3427 			'display-property-grouping' => true,
  3168 			'duplicate-properties' => true,
  3428 			'duplicate-properties'      => true,
  3169 			'known-properties' => true,
  3429 			'known-properties'          => true,
  3170 			'outline-none' => true,
  3430 			'outline-none'              => true,
  3171 		),
  3431 		),
  3172 		'jshint' => array(
  3432 		'jshint'     => array(
  3173 			// The following are copied from <https://github.com/WordPress/wordpress-develop/blob/4.8.1/.jshintrc>.
  3433 			// The following are copied from <https://github.com/WordPress/wordpress-develop/blob/4.8.1/.jshintrc>.
  3174 			'boss' => true,
  3434 			'boss'     => true,
  3175 			'curly' => true,
  3435 			'curly'    => true,
  3176 			'eqeqeq' => true,
  3436 			'eqeqeq'   => true,
  3177 			'eqnull' => true,
  3437 			'eqnull'   => true,
  3178 			'es3' => true,
  3438 			'es3'      => true,
  3179 			'expr' => true,
  3439 			'expr'     => true,
  3180 			'immed' => true,
  3440 			'immed'    => true,
  3181 			'noarg' => true,
  3441 			'noarg'    => true,
  3182 			'nonbsp' => true,
  3442 			'nonbsp'   => true,
  3183 			'onevar' => true,
  3443 			'onevar'   => true,
  3184 			'quotmark' => 'single',
  3444 			'quotmark' => 'single',
  3185 			'trailing' => true,
  3445 			'trailing' => true,
  3186 			'undef' => true,
  3446 			'undef'    => true,
  3187 			'unused' => true,
  3447 			'unused'   => true,
  3188 
  3448 
  3189 			'browser' => true,
  3449 			'browser'  => true,
  3190 
  3450 
  3191 			'globals' => array(
  3451 			'globals'  => array(
  3192 				'_' => false,
  3452 				'_'        => false,
  3193 				'Backbone' => false,
  3453 				'Backbone' => false,
  3194 				'jQuery' => false,
  3454 				'jQuery'   => false,
  3195 				'JSON' => false,
  3455 				'JSON'     => false,
  3196 				'wp' => false,
  3456 				'wp'       => false,
  3197 			),
  3457 			),
  3198 		),
  3458 		),
  3199 		'htmlhint' => array(
  3459 		'htmlhint'   => array(
  3200 			'tagname-lowercase' => true,
  3460 			'tagname-lowercase'        => true,
  3201 			'attr-lowercase' => true,
  3461 			'attr-lowercase'           => true,
  3202 			'attr-value-double-quotes' => false,
  3462 			'attr-value-double-quotes' => false,
  3203 			'doctype-first' => false,
  3463 			'doctype-first'            => false,
  3204 			'tag-pair' => true,
  3464 			'tag-pair'                 => true,
  3205 			'spec-char-escape' => true,
  3465 			'spec-char-escape'         => true,
  3206 			'id-unique' => true,
  3466 			'id-unique'                => true,
  3207 			'src-not-empty' => true,
  3467 			'src-not-empty'            => true,
  3208 			'attr-no-duplication' => true,
  3468 			'attr-no-duplication'      => true,
  3209 			'alt-require' => true,
  3469 			'alt-require'              => true,
  3210 			'space-tab-mixed-disabled' => 'tab',
  3470 			'space-tab-mixed-disabled' => 'tab',
  3211 			'attr-unsafe-chars' => true,
  3471 			'attr-unsafe-chars'        => true,
  3212 		),
  3472 		),
  3213 	);
  3473 	);
  3214 
  3474 
  3215 	$type = '';
  3475 	$type = '';
  3216 	if ( isset( $args['type'] ) ) {
  3476 	if ( isset( $args['type'] ) ) {
  3303 			}
  3563 			}
  3304 		}
  3564 		}
  3305 	}
  3565 	}
  3306 
  3566 
  3307 	if ( 'text/css' === $type ) {
  3567 	if ( 'text/css' === $type ) {
  3308 		$settings['codemirror'] = array_merge( $settings['codemirror'], array(
  3568 		$settings['codemirror'] = array_merge(
  3309 			'mode' => 'css',
  3569 			$settings['codemirror'],
  3310 			'lint' => true,
  3570 			array(
  3311 			'autoCloseBrackets' => true,
  3571 				'mode'              => 'css',
  3312 			'matchBrackets' => true,
  3572 				'lint'              => true,
  3313 		) );
  3573 				'autoCloseBrackets' => true,
       
  3574 				'matchBrackets'     => true,
       
  3575 			)
       
  3576 		);
  3314 	} elseif ( 'text/x-scss' === $type || 'text/x-less' === $type || 'text/x-sass' === $type ) {
  3577 	} elseif ( 'text/x-scss' === $type || 'text/x-less' === $type || 'text/x-sass' === $type ) {
  3315 		$settings['codemirror'] = array_merge( $settings['codemirror'], array(
  3578 		$settings['codemirror'] = array_merge(
  3316 			'mode' => $type,
  3579 			$settings['codemirror'],
  3317 			'lint' => false,
  3580 			array(
  3318 			'autoCloseBrackets' => true,
  3581 				'mode'              => $type,
  3319 			'matchBrackets' => true,
  3582 				'lint'              => false,
  3320 		) );
  3583 				'autoCloseBrackets' => true,
       
  3584 				'matchBrackets'     => true,
       
  3585 			)
       
  3586 		);
  3321 	} elseif ( 'text/x-diff' === $type ) {
  3587 	} elseif ( 'text/x-diff' === $type ) {
  3322 		$settings['codemirror'] = array_merge( $settings['codemirror'], array(
  3588 		$settings['codemirror'] = array_merge(
  3323 			'mode' => 'diff',
  3589 			$settings['codemirror'],
  3324 		) );
  3590 			array(
       
  3591 				'mode' => 'diff',
       
  3592 			)
       
  3593 		);
  3325 	} elseif ( 'text/html' === $type ) {
  3594 	} elseif ( 'text/html' === $type ) {
  3326 		$settings['codemirror'] = array_merge( $settings['codemirror'], array(
  3595 		$settings['codemirror'] = array_merge(
  3327 			'mode' => 'htmlmixed',
  3596 			$settings['codemirror'],
  3328 			'lint' => true,
  3597 			array(
  3329 			'autoCloseBrackets' => true,
  3598 				'mode'              => 'htmlmixed',
  3330 			'autoCloseTags' => true,
  3599 				'lint'              => true,
  3331 			'matchTags' => array(
  3600 				'autoCloseBrackets' => true,
  3332 				'bothTags' => true,
  3601 				'autoCloseTags'     => true,
  3333 			),
  3602 				'matchTags'         => array(
  3334 		) );
  3603 					'bothTags' => true,
       
  3604 				),
       
  3605 			)
       
  3606 		);
  3335 
  3607 
  3336 		if ( ! current_user_can( 'unfiltered_html' ) ) {
  3608 		if ( ! current_user_can( 'unfiltered_html' ) ) {
  3337 			$settings['htmlhint']['kses'] = wp_kses_allowed_html( 'post' );
  3609 			$settings['htmlhint']['kses'] = wp_kses_allowed_html( 'post' );
  3338 		}
  3610 		}
  3339 	} elseif ( 'text/x-gfm' === $type ) {
  3611 	} elseif ( 'text/x-gfm' === $type ) {
  3340 		$settings['codemirror'] = array_merge( $settings['codemirror'], array(
  3612 		$settings['codemirror'] = array_merge(
  3341 			'mode' => 'gfm',
  3613 			$settings['codemirror'],
  3342 			'highlightFormatting' => true,
  3614 			array(
  3343 		) );
  3615 				'mode'                => 'gfm',
       
  3616 				'highlightFormatting' => true,
       
  3617 			)
       
  3618 		);
  3344 	} elseif ( 'application/javascript' === $type || 'text/javascript' === $type ) {
  3619 	} elseif ( 'application/javascript' === $type || 'text/javascript' === $type ) {
  3345 		$settings['codemirror'] = array_merge( $settings['codemirror'], array(
  3620 		$settings['codemirror'] = array_merge(
  3346 			'mode' => 'javascript',
  3621 			$settings['codemirror'],
  3347 			'lint' => true,
  3622 			array(
  3348 			'autoCloseBrackets' => true,
  3623 				'mode'              => 'javascript',
  3349 			'matchBrackets' => true,
  3624 				'lint'              => true,
  3350 		) );
  3625 				'autoCloseBrackets' => true,
       
  3626 				'matchBrackets'     => true,
       
  3627 			)
       
  3628 		);
  3351 	} elseif ( false !== strpos( $type, 'json' ) ) {
  3629 	} elseif ( false !== strpos( $type, 'json' ) ) {
  3352 		$settings['codemirror'] = array_merge( $settings['codemirror'], array(
  3630 		$settings['codemirror'] = array_merge(
  3353 			'mode' => array(
  3631 			$settings['codemirror'],
  3354 				'name' => 'javascript',
  3632 			array(
  3355 			),
  3633 				'mode'              => array(
  3356 			'lint' => true,
  3634 					'name' => 'javascript',
  3357 			'autoCloseBrackets' => true,
  3635 				),
  3358 			'matchBrackets' => true,
  3636 				'lint'              => true,
  3359 		) );
  3637 				'autoCloseBrackets' => true,
       
  3638 				'matchBrackets'     => true,
       
  3639 			)
       
  3640 		);
  3360 		if ( 'application/ld+json' === $type ) {
  3641 		if ( 'application/ld+json' === $type ) {
  3361 			$settings['codemirror']['mode']['jsonld'] = true;
  3642 			$settings['codemirror']['mode']['jsonld'] = true;
  3362 		} else {
  3643 		} else {
  3363 			$settings['codemirror']['mode']['json'] = true;
  3644 			$settings['codemirror']['mode']['json'] = true;
  3364 		}
  3645 		}
  3365 	} elseif ( false !== strpos( $type, 'jsx' ) ) {
  3646 	} elseif ( false !== strpos( $type, 'jsx' ) ) {
  3366 		$settings['codemirror'] = array_merge( $settings['codemirror'], array(
  3647 		$settings['codemirror'] = array_merge(
  3367 			'mode' => 'jsx',
  3648 			$settings['codemirror'],
  3368 			'autoCloseBrackets' => true,
  3649 			array(
  3369 			'matchBrackets' => true,
  3650 				'mode'              => 'jsx',
  3370 		) );
  3651 				'autoCloseBrackets' => true,
       
  3652 				'matchBrackets'     => true,
       
  3653 			)
       
  3654 		);
  3371 	} elseif ( 'text/x-markdown' === $type ) {
  3655 	} elseif ( 'text/x-markdown' === $type ) {
  3372 		$settings['codemirror'] = array_merge( $settings['codemirror'], array(
  3656 		$settings['codemirror'] = array_merge(
  3373 			'mode' => 'markdown',
  3657 			$settings['codemirror'],
  3374 			'highlightFormatting' => true,
  3658 			array(
  3375 		) );
  3659 				'mode'                => 'markdown',
       
  3660 				'highlightFormatting' => true,
       
  3661 			)
       
  3662 		);
  3376 	} elseif ( 'text/nginx' === $type ) {
  3663 	} elseif ( 'text/nginx' === $type ) {
  3377 		$settings['codemirror'] = array_merge( $settings['codemirror'], array(
  3664 		$settings['codemirror'] = array_merge(
  3378 			'mode' => 'nginx',
  3665 			$settings['codemirror'],
  3379 		) );
  3666 			array(
       
  3667 				'mode' => 'nginx',
       
  3668 			)
       
  3669 		);
  3380 	} elseif ( 'application/x-httpd-php' === $type ) {
  3670 	} elseif ( 'application/x-httpd-php' === $type ) {
  3381 		$settings['codemirror'] = array_merge( $settings['codemirror'], array(
  3671 		$settings['codemirror'] = array_merge(
  3382 			'mode' => 'php',
  3672 			$settings['codemirror'],
  3383 			'autoCloseBrackets' => true,
  3673 			array(
  3384 			'autoCloseTags' => true,
  3674 				'mode'              => 'php',
  3385 			'matchBrackets' => true,
  3675 				'autoCloseBrackets' => true,
  3386 			'matchTags' => array(
  3676 				'autoCloseTags'     => true,
  3387 				'bothTags' => true,
  3677 				'matchBrackets'     => true,
  3388 			),
  3678 				'matchTags'         => array(
  3389 		) );
  3679 					'bothTags' => true,
       
  3680 				),
       
  3681 			)
       
  3682 		);
  3390 	} elseif ( 'text/x-sql' === $type || 'text/x-mysql' === $type ) {
  3683 	} elseif ( 'text/x-sql' === $type || 'text/x-mysql' === $type ) {
  3391 		$settings['codemirror'] = array_merge( $settings['codemirror'], array(
  3684 		$settings['codemirror'] = array_merge(
  3392 			'mode' => 'sql',
  3685 			$settings['codemirror'],
  3393 			'autoCloseBrackets' => true,
  3686 			array(
  3394 			'matchBrackets' => true,
  3687 				'mode'              => 'sql',
  3395 		) );
  3688 				'autoCloseBrackets' => true,
       
  3689 				'matchBrackets'     => true,
       
  3690 			)
       
  3691 		);
  3396 	} elseif ( false !== strpos( $type, 'xml' ) ) {
  3692 	} elseif ( false !== strpos( $type, 'xml' ) ) {
  3397 		$settings['codemirror'] = array_merge( $settings['codemirror'], array(
  3693 		$settings['codemirror'] = array_merge(
  3398 			'mode' => 'xml',
  3694 			$settings['codemirror'],
  3399 			'autoCloseBrackets' => true,
  3695 			array(
  3400 			'autoCloseTags' => true,
  3696 				'mode'              => 'xml',
  3401 			'matchTags' => array(
  3697 				'autoCloseBrackets' => true,
  3402 				'bothTags' => true,
  3698 				'autoCloseTags'     => true,
  3403 			),
  3699 				'matchTags'         => array(
  3404 		) );
  3700 					'bothTags' => true,
       
  3701 				),
       
  3702 			)
       
  3703 		);
  3405 	} elseif ( 'text/x-yaml' === $type ) {
  3704 	} elseif ( 'text/x-yaml' === $type ) {
  3406 		$settings['codemirror'] = array_merge( $settings['codemirror'], array(
  3705 		$settings['codemirror'] = array_merge(
  3407 			'mode' => 'yaml',
  3706 			$settings['codemirror'],
  3408 		) );
  3707 			array(
       
  3708 				'mode' => 'yaml',
       
  3709 			)
       
  3710 		);
  3409 	} else {
  3711 	} else {
  3410 		$settings['codemirror']['mode'] = $type;
  3712 		$settings['codemirror']['mode'] = $type;
  3411 	}
  3713 	}
  3412 
  3714 
  3413 	if ( ! empty( $settings['codemirror']['lint'] ) ) {
  3715 	if ( ! empty( $settings['codemirror']['lint'] ) ) {
  3429 	 *
  3731 	 *
  3430 	 * @since 4.9.0
  3732 	 * @since 4.9.0
  3431 	 *
  3733 	 *
  3432 	 * @param array $settings The array of settings passed to the code editor. A falsey value disables the editor.
  3734 	 * @param array $settings The array of settings passed to the code editor. A falsey value disables the editor.
  3433 	 * @param array $args {
  3735 	 * @param array $args {
  3434 	 *     Args passed when calling `wp_enqueue_code_editor()`.
  3736 	 *     Args passed when calling `get_code_editor_settings()`.
  3435 	 *
  3737 	 *
  3436 	 *     @type string   $type       The MIME type of the file to be edited.
  3738 	 *     @type string   $type       The MIME type of the file to be edited.
  3437 	 *     @type string   $file       Filename being edited.
  3739 	 *     @type string   $file       Filename being edited.
  3438 	 *     @type WP_Theme $theme      Theme being edited when on theme editor.
  3740 	 *     @type WP_Theme $theme      Theme being edited when on theme editor.
  3439 	 *     @type string   $plugin     Plugin being edited when on plugin editor.
  3741 	 *     @type string   $plugin     Plugin being edited when on plugin editor.
  3441 	 *     @type array    $csslint    CSSLint rule overrides.
  3743 	 *     @type array    $csslint    CSSLint rule overrides.
  3442 	 *     @type array    $jshint     JSHint rule overrides.
  3744 	 *     @type array    $jshint     JSHint rule overrides.
  3443 	 *     @type array    $htmlhint   JSHint rule overrides.
  3745 	 *     @type array    $htmlhint   JSHint rule overrides.
  3444 	 * }
  3746 	 * }
  3445 	 */
  3747 	 */
  3446 	$settings = apply_filters( 'wp_code_editor_settings', $settings, $args );
  3748 	return apply_filters( 'wp_code_editor_settings', $settings, $args );
  3447 
       
  3448 	if ( empty( $settings ) || empty( $settings['codemirror'] ) ) {
       
  3449 		return false;
       
  3450 	}
       
  3451 
       
  3452 	wp_enqueue_script( 'code-editor' );
       
  3453 	wp_enqueue_style( 'code-editor' );
       
  3454 
       
  3455 	if ( isset( $settings['codemirror']['mode'] ) ) {
       
  3456 		$mode = $settings['codemirror']['mode'];
       
  3457 		if ( is_string( $mode ) ) {
       
  3458 			$mode = array(
       
  3459 				'name' => $mode,
       
  3460 			);
       
  3461 		}
       
  3462 
       
  3463 		if ( ! empty( $settings['codemirror']['lint'] ) ) {
       
  3464 			switch ( $mode['name'] ) {
       
  3465 				case 'css':
       
  3466 				case 'text/css':
       
  3467 				case 'text/x-scss':
       
  3468 				case 'text/x-less':
       
  3469 					wp_enqueue_script( 'csslint' );
       
  3470 					break;
       
  3471 				case 'htmlmixed':
       
  3472 				case 'text/html':
       
  3473 				case 'php':
       
  3474 				case 'application/x-httpd-php':
       
  3475 				case 'text/x-php':
       
  3476 					wp_enqueue_script( 'htmlhint' );
       
  3477 					wp_enqueue_script( 'csslint' );
       
  3478 					wp_enqueue_script( 'jshint' );
       
  3479 					if ( ! current_user_can( 'unfiltered_html' ) ) {
       
  3480 						wp_enqueue_script( 'htmlhint-kses' );
       
  3481 					}
       
  3482 					break;
       
  3483 				case 'javascript':
       
  3484 				case 'application/ecmascript':
       
  3485 				case 'application/json':
       
  3486 				case 'application/javascript':
       
  3487 				case 'application/ld+json':
       
  3488 				case 'text/typescript':
       
  3489 				case 'application/typescript':
       
  3490 					wp_enqueue_script( 'jshint' );
       
  3491 					wp_enqueue_script( 'jsonlint' );
       
  3492 					break;
       
  3493 			}
       
  3494 		}
       
  3495 	}
       
  3496 
       
  3497 	wp_add_inline_script( 'code-editor', sprintf( 'jQuery.extend( wp.codeEditor.defaultSettings, %s );', wp_json_encode( $settings ) ) );
       
  3498 
       
  3499 	/**
       
  3500 	 * Fires when scripts and styles are enqueued for the code editor.
       
  3501 	 *
       
  3502 	 * @since 4.9.0
       
  3503 	 *
       
  3504 	 * @param array $settings Settings for the enqueued code editor.
       
  3505 	 */
       
  3506 	do_action( 'wp_enqueue_code_editor', $settings );
       
  3507 
       
  3508 	return $settings;
       
  3509 }
  3749 }
  3510 
  3750 
  3511 /**
  3751 /**
  3512  * Retrieves the contents of the search WordPress query variable.
  3752  * Retrieves the contents of the search WordPress query variable.
  3513  *
  3753  *
  3515  * for placing in an html attribute.
  3755  * for placing in an html attribute.
  3516  *
  3756  *
  3517  * @since 2.3.0
  3757  * @since 2.3.0
  3518  *
  3758  *
  3519  * @param bool $escaped Whether the result is escaped. Default true.
  3759  * @param bool $escaped Whether the result is escaped. Default true.
  3520  * 	                    Only use when you are later escaping it. Do not use unescaped.
  3760  *                      Only use when you are later escaping it. Do not use unescaped.
  3521  * @return string
  3761  * @return string
  3522  */
  3762  */
  3523 function get_search_query( $escaped = true ) {
  3763 function get_search_query( $escaped = true ) {
  3524 	/**
  3764 	/**
  3525 	 * Filters the contents of the search query variable.
  3765 	 * Filters the contents of the search query variable.
  3528 	 *
  3768 	 *
  3529 	 * @param mixed $search Contents of the search query variable.
  3769 	 * @param mixed $search Contents of the search query variable.
  3530 	 */
  3770 	 */
  3531 	$query = apply_filters( 'get_search_query', get_query_var( 's' ) );
  3771 	$query = apply_filters( 'get_search_query', get_query_var( 's' ) );
  3532 
  3772 
  3533 	if ( $escaped )
  3773 	if ( $escaped ) {
  3534 		$query = esc_attr( $query );
  3774 		$query = esc_attr( $query );
       
  3775 	}
  3535 	return $query;
  3776 	return $query;
  3536 }
  3777 }
  3537 
  3778 
  3538 /**
  3779 /**
  3539  * Displays the contents of the search query variable.
  3780  * Displays the contents of the search query variable.
  3565  * @param string $doctype Optional. The type of html document. Accepts 'xhtml' or 'html'. Default 'html'.
  3806  * @param string $doctype Optional. The type of html document. Accepts 'xhtml' or 'html'. Default 'html'.
  3566  */
  3807  */
  3567 function get_language_attributes( $doctype = 'html' ) {
  3808 function get_language_attributes( $doctype = 'html' ) {
  3568 	$attributes = array();
  3809 	$attributes = array();
  3569 
  3810 
  3570 	if ( function_exists( 'is_rtl' ) && is_rtl() )
  3811 	if ( function_exists( 'is_rtl' ) && is_rtl() ) {
  3571 		$attributes[] = 'dir="rtl"';
  3812 		$attributes[] = 'dir="rtl"';
       
  3813 	}
  3572 
  3814 
  3573 	if ( $lang = get_bloginfo( 'language' ) ) {
  3815 	if ( $lang = get_bloginfo( 'language' ) ) {
  3574 		if ( get_option( 'html_type' ) == 'text/html' || $doctype == 'html' ) {
  3816 		if ( get_option( 'html_type' ) == 'text/html' || $doctype == 'html' ) {
  3575 			$attributes[] = 'lang="' . esc_attr( $lang ) . '"';
  3817 			$attributes[] = 'lang="' . esc_attr( $lang ) . '"';
  3576 		}
  3818 		}
  3578 		if ( get_option( 'html_type' ) != 'text/html' || $doctype == 'xhtml' ) {
  3820 		if ( get_option( 'html_type' ) != 'text/html' || $doctype == 'xhtml' ) {
  3579 			$attributes[] = 'xml:lang="' . esc_attr( $lang ) . '"';
  3821 			$attributes[] = 'xml:lang="' . esc_attr( $lang ) . '"';
  3580 		}
  3822 		}
  3581 	}
  3823 	}
  3582 
  3824 
  3583 	$output = implode(' ', $attributes);
  3825 	$output = implode( ' ', $attributes );
  3584 
  3826 
  3585 	/**
  3827 	/**
  3586 	 * Filters the language attributes for display in the html tag.
  3828 	 * Filters the language attributes for display in the html tag.
  3587 	 *
  3829 	 *
  3588 	 * @since 2.5.0
  3830 	 * @since 2.5.0
  3683  *     @type array  $add_args           An array of query args to add. Default false.
  3925  *     @type array  $add_args           An array of query args to add. Default false.
  3684  *     @type string $add_fragment       A string to append to each link. Default empty.
  3926  *     @type string $add_fragment       A string to append to each link. Default empty.
  3685  *     @type string $before_page_number A string to appear before the page number. Default empty.
  3927  *     @type string $before_page_number A string to appear before the page number. Default empty.
  3686  *     @type string $after_page_number  A string to append after the page number. Default empty.
  3928  *     @type string $after_page_number  A string to append after the page number. Default empty.
  3687  * }
  3929  * }
  3688  * @return array|string|void String of page links or array of page links.
  3930  * @return string|array|void String of page links or array of page links.
  3689  */
  3931  */
  3690 function paginate_links( $args = '' ) {
  3932 function paginate_links( $args = '' ) {
  3691 	global $wp_query, $wp_rewrite;
  3933 	global $wp_query, $wp_rewrite;
  3692 
  3934 
  3693 	// Setting up default values based on the current URL.
  3935 	// Setting up default values based on the current URL.
  3731 	}
  3973 	}
  3732 
  3974 
  3733 	// Merge additional query vars found in the original URL into 'add_args' array.
  3975 	// Merge additional query vars found in the original URL into 'add_args' array.
  3734 	if ( isset( $url_parts[1] ) ) {
  3976 	if ( isset( $url_parts[1] ) ) {
  3735 		// Find the format argument.
  3977 		// Find the format argument.
  3736 		$format = explode( '?', str_replace( '%_%', $args['format'], $args['base'] ) );
  3978 		$format       = explode( '?', str_replace( '%_%', $args['format'], $args['base'] ) );
  3737 		$format_query = isset( $format[1] ) ? $format[1] : '';
  3979 		$format_query = isset( $format[1] ) ? $format[1] : '';
  3738 		wp_parse_str( $format_query, $format_args );
  3980 		wp_parse_str( $format_query, $format_args );
  3739 
  3981 
  3740 		// Find the query args of the requested URL.
  3982 		// Find the query args of the requested URL.
  3741 		wp_parse_str( $url_parts[1], $url_query_args );
  3983 		wp_parse_str( $url_parts[1], $url_query_args );
  3760 	}
  4002 	}
  3761 	$mid_size = (int) $args['mid_size'];
  4003 	$mid_size = (int) $args['mid_size'];
  3762 	if ( $mid_size < 0 ) {
  4004 	if ( $mid_size < 0 ) {
  3763 		$mid_size = 2;
  4005 		$mid_size = 2;
  3764 	}
  4006 	}
  3765 	$add_args = $args['add_args'];
  4007 	$add_args   = $args['add_args'];
  3766 	$r = '';
  4008 	$r          = '';
  3767 	$page_links = array();
  4009 	$page_links = array();
  3768 	$dots = false;
  4010 	$dots       = false;
  3769 
  4011 
  3770 	if ( $args['prev_next'] && $current && 1 < $current ) :
  4012 	if ( $args['prev_next'] && $current && 1 < $current ) :
  3771 		$link = str_replace( '%_%', 2 == $current ? '' : $args['format'], $args['base'] );
  4013 		$link = str_replace( '%_%', 2 == $current ? '' : $args['format'], $args['base'] );
  3772 		$link = str_replace( '%#%', $current - 1, $link );
  4014 		$link = str_replace( '%#%', $current - 1, $link );
  3773 		if ( $add_args )
  4015 		if ( $add_args ) {
  3774 			$link = add_query_arg( $add_args, $link );
  4016 			$link = add_query_arg( $add_args, $link );
       
  4017 		}
  3775 		$link .= $args['add_fragment'];
  4018 		$link .= $args['add_fragment'];
  3776 
  4019 
  3777 		/**
  4020 		/**
  3778 		 * Filters the paginated links for the given archive pages.
  4021 		 * Filters the paginated links for the given archive pages.
  3779 		 *
  4022 		 *
  3783 		 */
  4026 		 */
  3784 		$page_links[] = '<a class="prev page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $args['prev_text'] . '</a>';
  4027 		$page_links[] = '<a class="prev page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $args['prev_text'] . '</a>';
  3785 	endif;
  4028 	endif;
  3786 	for ( $n = 1; $n <= $total; $n++ ) :
  4029 	for ( $n = 1; $n <= $total; $n++ ) :
  3787 		if ( $n == $current ) :
  4030 		if ( $n == $current ) :
  3788 			$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>";
  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>';
  3789 			$dots = true;
  4032 			$dots         = true;
  3790 		else :
  4033 		else :
  3791 			if ( $args['show_all'] || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) :
  4034 			if ( $args['show_all'] || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) :
  3792 				$link = str_replace( '%_%', 1 == $n ? '' : $args['format'], $args['base'] );
  4035 				$link = str_replace( '%_%', 1 == $n ? '' : $args['format'], $args['base'] );
  3793 				$link = str_replace( '%#%', $n, $link );
  4036 				$link = str_replace( '%#%', $n, $link );
  3794 				if ( $add_args )
  4037 				if ( $add_args ) {
  3795 					$link = add_query_arg( $add_args, $link );
  4038 					$link = add_query_arg( $add_args, $link );
       
  4039 				}
  3796 				$link .= $args['add_fragment'];
  4040 				$link .= $args['add_fragment'];
  3797 
  4041 
  3798 				/** This filter is documented in wp-includes/general-template.php */
  4042 				/** This filter is documented in wp-includes/general-template.php */
  3799 				$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>";
  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>';
  3800 				$dots = true;
  4044 				$dots         = true;
  3801 			elseif ( $dots && ! $args['show_all'] ) :
  4045 			elseif ( $dots && ! $args['show_all'] ) :
  3802 				$page_links[] = '<span class="page-numbers dots">' . __( '&hellip;' ) . '</span>';
  4046 				$page_links[] = '<span class="page-numbers dots">' . __( '&hellip;' ) . '</span>';
  3803 				$dots = false;
  4047 				$dots         = false;
  3804 			endif;
  4048 			endif;
  3805 		endif;
  4049 		endif;
  3806 	endfor;
  4050 	endfor;
  3807 	if ( $args['prev_next'] && $current && $current < $total ) :
  4051 	if ( $args['prev_next'] && $current && $current < $total ) :
  3808 		$link = str_replace( '%_%', $args['format'], $args['base'] );
  4052 		$link = str_replace( '%_%', $args['format'], $args['base'] );
  3809 		$link = str_replace( '%#%', $current + 1, $link );
  4053 		$link = str_replace( '%#%', $current + 1, $link );
  3810 		if ( $add_args )
  4054 		if ( $add_args ) {
  3811 			$link = add_query_arg( $add_args, $link );
  4055 			$link = add_query_arg( $add_args, $link );
       
  4056 		}
  3812 		$link .= $args['add_fragment'];
  4057 		$link .= $args['add_fragment'];
  3813 
  4058 
  3814 		/** This filter is documented in wp-includes/general-template.php */
  4059 		/** This filter is documented in wp-includes/general-template.php */
  3815 		$page_links[] = '<a class="next page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $args['next_text'] . '</a>';
  4060 		$page_links[] = '<a class="next page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $args['next_text'] . '</a>';
  3816 	endif;
  4061 	endif;
  3817 	switch ( $args['type'] ) {
  4062 	switch ( $args['type'] ) {
  3818 		case 'array' :
  4063 		case 'array':
  3819 			return $page_links;
  4064 			return $page_links;
  3820 
  4065 
  3821 		case 'list' :
  4066 		case 'list':
  3822 			$r .= "<ul class='page-numbers'>\n\t<li>";
  4067 			$r .= "<ul class='page-numbers'>\n\t<li>";
  3823 			$r .= join("</li>\n\t<li>", $page_links);
  4068 			$r .= join( "</li>\n\t<li>", $page_links );
  3824 			$r .= "</li>\n</ul>\n";
  4069 			$r .= "</li>\n</ul>\n";
  3825 			break;
  4070 			break;
  3826 
  4071 
  3827 		default :
  4072 		default:
  3828 			$r = join("\n", $page_links);
  4073 			$r = join( "\n", $page_links );
  3829 			break;
  4074 			break;
  3830 	}
  4075 	}
  3831 	return $r;
  4076 	return $r;
  3832 }
  4077 }
  3833 
  4078 
  3834 /**
  4079 /**
  3835  * Registers an admin colour scheme css file.
  4080  * Registers an admin color scheme css file.
  3836  *
  4081  *
  3837  * Allows a plugin to register a new admin colour scheme. For example:
  4082  * Allows a plugin to register a new admin color scheme. For example:
  3838  *
  4083  *
  3839  *     wp_admin_css_color( 'classic', __( 'Classic' ), admin_url( "css/colors-classic.css" ), array(
  4084  *     wp_admin_css_color( 'classic', __( 'Classic' ), admin_url( "css/colors-classic.css" ), array(
  3840  *         '#07273E', '#14568A', '#D54E21', '#2683AE'
  4085  *         '#07273E', '#14568A', '#D54E21', '#2683AE'
  3841  *     ) );
  4086  *     ) );
  3842  *
  4087  *
  3858  * }
  4103  * }
  3859  */
  4104  */
  3860 function wp_admin_css_color( $key, $name, $url, $colors = array(), $icons = array() ) {
  4105 function wp_admin_css_color( $key, $name, $url, $colors = array(), $icons = array() ) {
  3861 	global $_wp_admin_css_colors;
  4106 	global $_wp_admin_css_colors;
  3862 
  4107 
  3863 	if ( !isset($_wp_admin_css_colors) )
  4108 	if ( ! isset( $_wp_admin_css_colors ) ) {
  3864 		$_wp_admin_css_colors = array();
  4109 		$_wp_admin_css_colors = array();
  3865 
  4110 	}
  3866 	$_wp_admin_css_colors[$key] = (object) array(
  4111 
  3867 		'name' => $name,
  4112 	$_wp_admin_css_colors[ $key ] = (object) array(
  3868 		'url' => $url,
  4113 		'name'        => $name,
  3869 		'colors' => $colors,
  4114 		'url'         => $url,
       
  4115 		'colors'      => $colors,
  3870 		'icon_colors' => $icons,
  4116 		'icon_colors' => $icons,
  3871 	);
  4117 	);
  3872 }
  4118 }
  3873 
  4119 
  3874 /**
  4120 /**
  3875  * Registers the default Admin color schemes
  4121  * Registers the default admin color schemes.
       
  4122  *
       
  4123  * Registers the initial set of eight color schemes in the Profile section
       
  4124  * of the dashboard which allows for styling the admin menu and toolbar.
       
  4125  *
       
  4126  * @see wp_admin_css_color()
  3876  *
  4127  *
  3877  * @since 3.0.0
  4128  * @since 3.0.0
  3878  */
  4129  */
  3879 function register_admin_color_schemes() {
  4130 function register_admin_color_schemes() {
  3880 	$suffix = is_rtl() ? '-rtl' : '';
  4131 	$suffix  = is_rtl() ? '-rtl' : '';
  3881 	$suffix .= SCRIPT_DEBUG ? '' : '.min';
  4132 	$suffix .= SCRIPT_DEBUG ? '' : '.min';
  3882 
  4133 
  3883 	wp_admin_css_color( 'fresh', _x( 'Default', 'admin color scheme' ),
  4134 	wp_admin_css_color(
       
  4135 		'fresh',
       
  4136 		_x( 'Default', 'admin color scheme' ),
  3884 		false,
  4137 		false,
  3885 		array( '#222', '#333', '#0073aa', '#00a0d2' ),
  4138 		array( '#222', '#333', '#0073aa', '#00a0d2' ),
  3886 		array( 'base' => '#82878c', 'focus' => '#00a0d2', 'current' => '#fff' )
  4139 		array(
       
  4140 			'base'    => '#a0a5aa',
       
  4141 			'focus'   => '#00a0d2',
       
  4142 			'current' => '#fff',
       
  4143 		)
  3887 	);
  4144 	);
  3888 
  4145 
  3889 	// Other color schemes are not available when running out of src
  4146 	// Other color schemes are not available when running out of src
  3890 	if ( false !== strpos( get_bloginfo( 'version' ), '-src' ) ) {
  4147 	if ( false !== strpos( get_bloginfo( 'version' ), '-src' ) ) {
  3891 		return;
  4148 		return;
  3892 	}
  4149 	}
  3893 
  4150 
  3894 	wp_admin_css_color( 'light', _x( 'Light', 'admin color scheme' ),
  4151 	wp_admin_css_color(
       
  4152 		'light',
       
  4153 		_x( 'Light', 'admin color scheme' ),
  3895 		admin_url( "css/colors/light/colors$suffix.css" ),
  4154 		admin_url( "css/colors/light/colors$suffix.css" ),
  3896 		array( '#e5e5e5', '#999', '#d64e07', '#04a4cc' ),
  4155 		array( '#e5e5e5', '#999', '#d64e07', '#04a4cc' ),
  3897 		array( 'base' => '#999', 'focus' => '#ccc', 'current' => '#ccc' )
  4156 		array(
       
  4157 			'base'    => '#999',
       
  4158 			'focus'   => '#ccc',
       
  4159 			'current' => '#ccc',
       
  4160 		)
  3898 	);
  4161 	);
  3899 
  4162 
  3900 	wp_admin_css_color( 'blue', _x( 'Blue', 'admin color scheme' ),
  4163 	wp_admin_css_color(
       
  4164 		'blue',
       
  4165 		_x( 'Blue', 'admin color scheme' ),
  3901 		admin_url( "css/colors/blue/colors$suffix.css" ),
  4166 		admin_url( "css/colors/blue/colors$suffix.css" ),
  3902 		array( '#096484', '#4796b3', '#52accc', '#74B6CE' ),
  4167 		array( '#096484', '#4796b3', '#52accc', '#74B6CE' ),
  3903 		array( 'base' => '#e5f8ff', 'focus' => '#fff', 'current' => '#fff' )
  4168 		array(
       
  4169 			'base'    => '#e5f8ff',
       
  4170 			'focus'   => '#fff',
       
  4171 			'current' => '#fff',
       
  4172 		)
  3904 	);
  4173 	);
  3905 
  4174 
  3906 	wp_admin_css_color( 'midnight', _x( 'Midnight', 'admin color scheme' ),
  4175 	wp_admin_css_color(
       
  4176 		'midnight',
       
  4177 		_x( 'Midnight', 'admin color scheme' ),
  3907 		admin_url( "css/colors/midnight/colors$suffix.css" ),
  4178 		admin_url( "css/colors/midnight/colors$suffix.css" ),
  3908 		array( '#25282b', '#363b3f', '#69a8bb', '#e14d43' ),
  4179 		array( '#25282b', '#363b3f', '#69a8bb', '#e14d43' ),
  3909 		array( 'base' => '#f1f2f3', 'focus' => '#fff', 'current' => '#fff' )
  4180 		array(
       
  4181 			'base'    => '#f1f2f3',
       
  4182 			'focus'   => '#fff',
       
  4183 			'current' => '#fff',
       
  4184 		)
  3910 	);
  4185 	);
  3911 
  4186 
  3912 	wp_admin_css_color( 'sunrise', _x( 'Sunrise', 'admin color scheme' ),
  4187 	wp_admin_css_color(
       
  4188 		'sunrise',
       
  4189 		_x( 'Sunrise', 'admin color scheme' ),
  3913 		admin_url( "css/colors/sunrise/colors$suffix.css" ),
  4190 		admin_url( "css/colors/sunrise/colors$suffix.css" ),
  3914 		array( '#b43c38', '#cf4944', '#dd823b', '#ccaf0b' ),
  4191 		array( '#b43c38', '#cf4944', '#dd823b', '#ccaf0b' ),
  3915 		array( 'base' => '#f3f1f1', 'focus' => '#fff', 'current' => '#fff' )
  4192 		array(
       
  4193 			'base'    => '#f3f1f1',
       
  4194 			'focus'   => '#fff',
       
  4195 			'current' => '#fff',
       
  4196 		)
  3916 	);
  4197 	);
  3917 
  4198 
  3918 	wp_admin_css_color( 'ectoplasm', _x( 'Ectoplasm', 'admin color scheme' ),
  4199 	wp_admin_css_color(
       
  4200 		'ectoplasm',
       
  4201 		_x( 'Ectoplasm', 'admin color scheme' ),
  3919 		admin_url( "css/colors/ectoplasm/colors$suffix.css" ),
  4202 		admin_url( "css/colors/ectoplasm/colors$suffix.css" ),
  3920 		array( '#413256', '#523f6d', '#a3b745', '#d46f15' ),
  4203 		array( '#413256', '#523f6d', '#a3b745', '#d46f15' ),
  3921 		array( 'base' => '#ece6f6', 'focus' => '#fff', 'current' => '#fff' )
  4204 		array(
       
  4205 			'base'    => '#ece6f6',
       
  4206 			'focus'   => '#fff',
       
  4207 			'current' => '#fff',
       
  4208 		)
  3922 	);
  4209 	);
  3923 
  4210 
  3924 	wp_admin_css_color( 'ocean', _x( 'Ocean', 'admin color scheme' ),
  4211 	wp_admin_css_color(
       
  4212 		'ocean',
       
  4213 		_x( 'Ocean', 'admin color scheme' ),
  3925 		admin_url( "css/colors/ocean/colors$suffix.css" ),
  4214 		admin_url( "css/colors/ocean/colors$suffix.css" ),
  3926 		array( '#627c83', '#738e96', '#9ebaa0', '#aa9d88' ),
  4215 		array( '#627c83', '#738e96', '#9ebaa0', '#aa9d88' ),
  3927 		array( 'base' => '#f2fcff', 'focus' => '#fff', 'current' => '#fff' )
  4216 		array(
       
  4217 			'base'    => '#f2fcff',
       
  4218 			'focus'   => '#fff',
       
  4219 			'current' => '#fff',
       
  4220 		)
  3928 	);
  4221 	);
  3929 
  4222 
  3930 	wp_admin_css_color( 'coffee', _x( 'Coffee', 'admin color scheme' ),
  4223 	wp_admin_css_color(
       
  4224 		'coffee',
       
  4225 		_x( 'Coffee', 'admin color scheme' ),
  3931 		admin_url( "css/colors/coffee/colors$suffix.css" ),
  4226 		admin_url( "css/colors/coffee/colors$suffix.css" ),
  3932 		array( '#46403c', '#59524c', '#c7a589', '#9ea476' ),
  4227 		array( '#46403c', '#59524c', '#c7a589', '#9ea476' ),
  3933 		array( 'base' => '#f3f2f1', 'focus' => '#fff', 'current' => '#fff' )
  4228 		array(
       
  4229 			'base'    => '#f3f2f1',
       
  4230 			'focus'   => '#fff',
       
  4231 			'current' => '#fff',
       
  4232 		)
  3934 	);
  4233 	);
  3935 
  4234 
  3936 }
  4235 }
  3937 
  4236 
  3938 /**
  4237 /**
  3944  *
  4243  *
  3945  * @param string $file file relative to wp-admin/ without its ".css" extension.
  4244  * @param string $file file relative to wp-admin/ without its ".css" extension.
  3946  * @return string
  4245  * @return string
  3947  */
  4246  */
  3948 function wp_admin_css_uri( $file = 'wp-admin' ) {
  4247 function wp_admin_css_uri( $file = 'wp-admin' ) {
  3949 	if ( defined('WP_INSTALLING') ) {
  4248 	if ( defined( 'WP_INSTALLING' ) ) {
  3950 		$_file = "./$file.css";
  4249 		$_file = "./$file.css";
  3951 	} else {
  4250 	} else {
  3952 		$_file = admin_url("$file.css");
  4251 		$_file = admin_url( "$file.css" );
  3953 	}
  4252 	}
  3954 	$_file = add_query_arg( 'version', get_bloginfo( 'version' ),  $_file );
  4253 	$_file = add_query_arg( 'version', get_bloginfo( 'version' ), $_file );
  3955 
  4254 
  3956 	/**
  4255 	/**
  3957 	 * Filters the URI of a WordPress admin CSS file.
  4256 	 * Filters the URI of a WordPress admin CSS file.
  3958 	 *
  4257 	 *
  3959 	 * @since 2.3.0
  4258 	 * @since 2.3.0
  3979  * stylesheet link to that generated URL is printed.
  4278  * stylesheet link to that generated URL is printed.
  3980  *
  4279  *
  3981  * @since 2.3.0
  4280  * @since 2.3.0
  3982  *
  4281  *
  3983  * @param string $file       Optional. Style handle name or file name (without ".css" extension) relative
  4282  * @param string $file       Optional. Style handle name or file name (without ".css" extension) relative
  3984  * 	                         to wp-admin/. Defaults to 'wp-admin'.
  4283  *                           to wp-admin/. Defaults to 'wp-admin'.
  3985  * @param bool   $force_echo Optional. Force the stylesheet link to be printed rather than enqueued.
  4284  * @param bool   $force_echo Optional. Force the stylesheet link to be printed rather than enqueued.
  3986  */
  4285  */
  3987 function wp_admin_css( $file = 'wp-admin', $force_echo = false ) {
  4286 function wp_admin_css( $file = 'wp-admin', $force_echo = false ) {
  3988 	// For backward compatibility
  4287 	// For backward compatibility
  3989 	$handle = 0 === strpos( $file, 'css/' ) ? substr( $file, 4 ) : $file;
  4288 	$handle = 0 === strpos( $file, 'css/' ) ? substr( $file, 4 ) : $file;
  3990 
  4289 
  3991 	if ( wp_styles()->query( $handle ) ) {
  4290 	if ( wp_styles()->query( $handle ) ) {
  3992 		if ( $force_echo || did_action( 'wp_print_styles' ) ) // we already printed the style queue. Print this one immediately
  4291 		if ( $force_echo || did_action( 'wp_print_styles' ) ) { // we already printed the style queue. Print this one immediately
  3993 			wp_print_styles( $handle );
  4292 			wp_print_styles( $handle );
  3994 		else // Add to style queue
  4293 		} else { // Add to style queue
  3995 			wp_enqueue_style( $handle );
  4294 			wp_enqueue_style( $handle );
       
  4295 		}
  3996 		return;
  4296 		return;
  3997 	}
  4297 	}
  3998 
  4298 
  3999 	/**
  4299 	/**
  4000 	 * Filters the stylesheet link to the specified CSS file.
  4300 	 * Filters the stylesheet link to the specified CSS file.
  4026  */
  4326  */
  4027 function add_thickbox() {
  4327 function add_thickbox() {
  4028 	wp_enqueue_script( 'thickbox' );
  4328 	wp_enqueue_script( 'thickbox' );
  4029 	wp_enqueue_style( 'thickbox' );
  4329 	wp_enqueue_style( 'thickbox' );
  4030 
  4330 
  4031 	if ( is_network_admin() )
  4331 	if ( is_network_admin() ) {
  4032 		add_action( 'admin_head', '_thickbox_path_admin_subfolder' );
  4332 		add_action( 'admin_head', '_thickbox_path_admin_subfolder' );
       
  4333 	}
  4033 }
  4334 }
  4034 
  4335 
  4035 /**
  4336 /**
  4036  * Displays the XHTML generator that is generated on the wp_head hook.
  4337  * Displays the XHTML generator that is generated on the wp_head hook.
  4037  *
  4338  *
  4068 	 *
  4369 	 *
  4069 	 * @param string $generator_type The generator output.
  4370 	 * @param string $generator_type The generator output.
  4070 	 * @param string $type           The type of generator to output. Accepts 'html',
  4371 	 * @param string $type           The type of generator to output. Accepts 'html',
  4071 	 *                               'xhtml', 'atom', 'rss2', 'rdf', 'comment', 'export'.
  4372 	 *                               'xhtml', 'atom', 'rss2', 'rdf', 'comment', 'export'.
  4072 	 */
  4373 	 */
  4073 	echo apply_filters( 'the_generator', get_the_generator($type), $type ) . "\n";
  4374 	echo apply_filters( 'the_generator', get_the_generator( $type ), $type ) . "\n";
  4074 }
  4375 }
  4075 
  4376 
  4076 /**
  4377 /**
  4077  * Creates the generator XML or Comment for RSS, ATOM, etc.
  4378  * Creates the generator XML or Comment for RSS, ATOM, etc.
  4078  *
  4379  *
  4087  */
  4388  */
  4088 function get_the_generator( $type = '' ) {
  4389 function get_the_generator( $type = '' ) {
  4089 	if ( empty( $type ) ) {
  4390 	if ( empty( $type ) ) {
  4090 
  4391 
  4091 		$current_filter = current_filter();
  4392 		$current_filter = current_filter();
  4092 		if ( empty( $current_filter ) )
  4393 		if ( empty( $current_filter ) ) {
  4093 			return;
  4394 			return;
       
  4395 		}
  4094 
  4396 
  4095 		switch ( $current_filter ) {
  4397 		switch ( $current_filter ) {
  4096 			case 'rss2_head' :
  4398 			case 'rss2_head':
  4097 			case 'commentsrss2_head' :
  4399 			case 'commentsrss2_head':
  4098 				$type = 'rss2';
  4400 				$type = 'rss2';
  4099 				break;
  4401 				break;
  4100 			case 'rss_head' :
  4402 			case 'rss_head':
  4101 			case 'opml_head' :
  4403 			case 'opml_head':
  4102 				$type = 'comment';
  4404 				$type = 'comment';
  4103 				break;
  4405 				break;
  4104 			case 'rdf_header' :
  4406 			case 'rdf_header':
  4105 				$type = 'rdf';
  4407 				$type = 'rdf';
  4106 				break;
  4408 				break;
  4107 			case 'atom_head' :
  4409 			case 'atom_head':
  4108 			case 'comments_atom_head' :
  4410 			case 'comments_atom_head':
  4109 			case 'app_head' :
  4411 			case 'app_head':
  4110 				$type = 'atom';
  4412 				$type = 'atom';
  4111 				break;
  4413 				break;
  4112 		}
  4414 		}
  4113 	}
  4415 	}
  4114 
  4416 
  4227  * @param bool   $echo    Whether to echo or just return the string
  4529  * @param bool   $echo    Whether to echo or just return the string
  4228  * @param string $type    The type of checked|selected|disabled|readonly we are doing
  4530  * @param string $type    The type of checked|selected|disabled|readonly we are doing
  4229  * @return string html attribute or empty string
  4531  * @return string html attribute or empty string
  4230  */
  4532  */
  4231 function __checked_selected_helper( $helper, $current, $echo, $type ) {
  4533 function __checked_selected_helper( $helper, $current, $echo, $type ) {
  4232 	if ( (string) $helper === (string) $current )
  4534 	if ( (string) $helper === (string) $current ) {
  4233 		$result = " $type='$type'";
  4535 		$result = " $type='$type'";
  4234 	else
  4536 	} else {
  4235 		$result = '';
  4537 		$result = '';
  4236 
  4538 	}
  4237 	if ( $echo )
  4539 
       
  4540 	if ( $echo ) {
  4238 		echo $result;
  4541 		echo $result;
       
  4542 	}
  4239 
  4543 
  4240 	return $result;
  4544 	return $result;
  4241 }
  4545 }
  4242 
  4546 
  4243 /**
  4547 /**
  4249  *
  4553  *
  4250  * @param array $settings
  4554  * @param array $settings
  4251  * @return array $settings
  4555  * @return array $settings
  4252  */
  4556  */
  4253 function wp_heartbeat_settings( $settings ) {
  4557 function wp_heartbeat_settings( $settings ) {
  4254 	if ( ! is_admin() )
  4558 	if ( ! is_admin() ) {
  4255 		$settings['ajaxurl'] = admin_url( 'admin-ajax.php', 'relative' );
  4559 		$settings['ajaxurl'] = admin_url( 'admin-ajax.php', 'relative' );
  4256 
  4560 	}
  4257 	if ( is_user_logged_in() )
  4561 
       
  4562 	if ( is_user_logged_in() ) {
  4258 		$settings['nonce'] = wp_create_nonce( 'heartbeat-nonce' );
  4563 		$settings['nonce'] = wp_create_nonce( 'heartbeat-nonce' );
       
  4564 	}
  4259 
  4565 
  4260 	return $settings;
  4566 	return $settings;
  4261 }
  4567 }