wp/wp-includes/general-template.php
changeset 7 cf61fcea0001
parent 5 5e2f62d02dcd
child 9 177826044cd9
equal deleted inserted replaced
6:490d5cc509ed 7:cf61fcea0001
    21  */
    21  */
    22 function get_header( $name = null ) {
    22 function get_header( $name = null ) {
    23 	/**
    23 	/**
    24 	 * Fires before the header template file is loaded.
    24 	 * Fires before the header template file is loaded.
    25 	 *
    25 	 *
    26 	 * The hook allows a specific header template file to be used in place of the
       
    27 	 * default header template file. If your file is called header-new.php,
       
    28 	 * you would specify the filename in the hook as get_header( 'new' ).
       
    29 	 *
       
    30 	 * @since 2.1.0
    26 	 * @since 2.1.0
    31 	 * @since 2.8.0 $name parameter added.
    27 	 * @since 2.8.0 $name parameter added.
    32 	 *
    28 	 *
    33 	 * @param string $name Name of the specific header file to use.
    29 	 * @param string|null $name Name of the specific header file to use. null for the default header.
    34 	 */
    30 	 */
    35 	do_action( 'get_header', $name );
    31 	do_action( 'get_header', $name );
    36 
    32 
    37 	$templates = array();
    33 	$templates = array();
    38 	$name = (string) $name;
    34 	$name = (string) $name;
    39 	if ( '' !== $name )
    35 	if ( '' !== $name ) {
    40 		$templates[] = "header-{$name}.php";
    36 		$templates[] = "header-{$name}.php";
       
    37 	}
    41 
    38 
    42 	$templates[] = 'header.php';
    39 	$templates[] = 'header.php';
    43 
    40 
    44 	// Backward compat code will be removed in a future release
    41 	locate_template( $templates, true );
    45 	if ('' == locate_template($templates, true))
       
    46 		load_template( ABSPATH . WPINC . '/theme-compat/header.php');
       
    47 }
    42 }
    48 
    43 
    49 /**
    44 /**
    50  * Load footer template.
    45  * Load footer template.
    51  *
    46  *
    61  */
    56  */
    62 function get_footer( $name = null ) {
    57 function get_footer( $name = null ) {
    63 	/**
    58 	/**
    64 	 * Fires before the footer template file is loaded.
    59 	 * Fires before the footer template file is loaded.
    65 	 *
    60 	 *
    66 	 * The hook allows a specific footer template file to be used in place of the
       
    67 	 * default footer template file. If your file is called footer-new.php,
       
    68 	 * you would specify the filename in the hook as get_footer( 'new' ).
       
    69 	 *
       
    70 	 * @since 2.1.0
    61 	 * @since 2.1.0
    71 	 * @since 2.8.0 $name parameter added.
    62 	 * @since 2.8.0 $name parameter added.
    72 	 *
    63 	 *
    73 	 * @param string $name Name of the specific footer file to use.
    64 	 * @param string|null $name Name of the specific footer file to use. null for the default footer.
    74 	 */
    65 	 */
    75 	do_action( 'get_footer', $name );
    66 	do_action( 'get_footer', $name );
    76 
    67 
    77 	$templates = array();
    68 	$templates = array();
    78 	$name = (string) $name;
    69 	$name = (string) $name;
    79 	if ( '' !== $name )
    70 	if ( '' !== $name ) {
    80 		$templates[] = "footer-{$name}.php";
    71 		$templates[] = "footer-{$name}.php";
    81 
    72 	}
    82 	$templates[] = 'footer.php';
    73 
    83 
    74 	$templates[]    = 'footer.php';
    84 	// Backward compat code will be removed in a future release
    75 
    85 	if ('' == locate_template($templates, true))
    76 	locate_template( $templates, true );
    86 		load_template( ABSPATH . WPINC . '/theme-compat/footer.php');
       
    87 }
    77 }
    88 
    78 
    89 /**
    79 /**
    90  * Load sidebar template.
    80  * Load sidebar template.
    91  *
    81  *
   101  */
    91  */
   102 function get_sidebar( $name = null ) {
    92 function get_sidebar( $name = null ) {
   103 	/**
    93 	/**
   104 	 * Fires before the sidebar template file is loaded.
    94 	 * Fires before the sidebar template file is loaded.
   105 	 *
    95 	 *
   106 	 * The hook allows a specific sidebar template file to be used in place of the
       
   107 	 * default sidebar template file. If your file is called sidebar-new.php,
       
   108 	 * you would specify the filename in the hook as get_sidebar( 'new' ).
       
   109 	 *
       
   110 	 * @since 2.2.0
    96 	 * @since 2.2.0
   111 	 * @since 2.8.0 $name parameter added.
    97 	 * @since 2.8.0 $name parameter added.
   112 	 *
    98 	 *
   113 	 * @param string $name Name of the specific sidebar file to use.
    99 	 * @param string|null $name Name of the specific sidebar file to use. null for the default sidebar.
   114 	 */
   100 	 */
   115 	do_action( 'get_sidebar', $name );
   101 	do_action( 'get_sidebar', $name );
   116 
   102 
   117 	$templates = array();
   103 	$templates = array();
   118 	$name = (string) $name;
   104 	$name = (string) $name;
   119 	if ( '' !== $name )
   105 	if ( '' !== $name )
   120 		$templates[] = "sidebar-{$name}.php";
   106 		$templates[] = "sidebar-{$name}.php";
   121 
   107 
   122 	$templates[] = 'sidebar.php';
   108 	$templates[] = 'sidebar.php';
   123 
   109 
   124 	// Backward compat code will be removed in a future release
   110 	locate_template( $templates, true );
   125 	if ('' == locate_template($templates, true))
   111 }
   126 		load_template( ABSPATH . WPINC . '/theme-compat/sidebar.php');
   112 
   127 }
   113 /**
   128 
   114  * Loads a template part into a template.
   129 /**
   115  *
   130  * Load a template part into a template
   116  * Provides a simple mechanism for child themes to overload reusable sections of code
   131  *
   117  * in the theme.
   132  * Makes it easy for a theme to reuse sections of code in a easy to overload way
       
   133  * for child themes.
       
   134  *
   118  *
   135  * Includes the named template part for a theme or if a name is specified then a
   119  * Includes the named template part for a theme or if a name is specified then a
   136  * specialised part will be included. If the theme contains no {slug}.php file
   120  * specialised part will be included. If the theme contains no {slug}.php file
   137  * then no template will be included.
   121  * then no template will be included.
   138  *
   122  *
   154 	 * The dynamic portion of the hook name, `$slug`, refers to the slug name
   138 	 * The dynamic portion of the hook name, `$slug`, refers to the slug name
   155 	 * for the generic template part.
   139 	 * for the generic template part.
   156 	 *
   140 	 *
   157 	 * @since 3.0.0
   141 	 * @since 3.0.0
   158 	 *
   142 	 *
   159 	 * @param string $slug The slug name for the generic template.
   143 	 * @param string      $slug The slug name for the generic template.
   160 	 * @param string $name The name of the specialized template.
   144 	 * @param string|null $name The name of the specialized template.
   161 	 */
   145 	 */
   162 	do_action( "get_template_part_{$slug}", $slug, $name );
   146 	do_action( "get_template_part_{$slug}", $slug, $name );
   163 
   147 
   164 	$templates = array();
   148 	$templates = array();
   165 	$name = (string) $name;
   149 	$name = (string) $name;
   176  *
   160  *
   177  * Will first attempt to locate the searchform.php file in either the child or
   161  * Will first attempt to locate the searchform.php file in either the child or
   178  * the parent, then load it. If it doesn't exist, then the default search form
   162  * the parent, then load it. If it doesn't exist, then the default search form
   179  * will be displayed. The default search form is HTML, which will be displayed.
   163  * will be displayed. The default search form is HTML, which will be displayed.
   180  * There is a filter applied to the search form HTML in order to edit or replace
   164  * There is a filter applied to the search form HTML in order to edit or replace
   181  * it. The filter is 'get_search_form'.
   165  * it. The filter is {@see 'get_search_form'}.
   182  *
   166  *
   183  * This function is primarily used by themes which want to hardcode the search
   167  * This function is primarily used by themes which want to hardcode the search
   184  * form into the sidebar and also by the search widget in WordPress.
   168  * form into the sidebar and also by the search widget in WordPress.
   185  *
   169  *
   186  * There is also an action that is called whenever the function is run called,
   170  * There is also an action that is called whenever the function is run called,
   187  * 'pre_get_search_form'. This can be useful for outputting JavaScript that the
   171  * {@see 'pre_get_search_form'}. This can be useful for outputting JavaScript that the
   188  * search relies on or various formatting that applies to the beginning of the
   172  * search relies on or various formatting that applies to the beginning of the
   189  * search. To give a few examples of what it can be used for.
   173  * search. To give a few examples of what it can be used for.
   190  *
   174  *
   191  * @since 2.7.0
   175  * @since 2.7.0
   192  *
   176  *
   193  * @param boolean $echo Default to echo and not return the form.
   177  * @param bool $echo Default to echo and not return the form.
   194  * @return string|null String when retrieving, null when displaying or if searchform.php exists.
   178  * @return string|void String when $echo is false.
   195  */
   179  */
   196 function get_search_form( $echo = true ) {
   180 function get_search_form( $echo = true ) {
   197 	/**
   181 	/**
   198 	 * Fires before the search form is retrieved, at the start of get_search_form().
   182 	 * Fires before the search form is retrieved, at the start of get_search_form().
   199 	 *
   183 	 *
   205 	do_action( 'pre_get_search_form' );
   189 	do_action( 'pre_get_search_form' );
   206 
   190 
   207 	$format = current_theme_supports( 'html5', 'search-form' ) ? 'html5' : 'xhtml';
   191 	$format = current_theme_supports( 'html5', 'search-form' ) ? 'html5' : 'xhtml';
   208 
   192 
   209 	/**
   193 	/**
   210 	 * Filter the HTML format of the search form.
   194 	 * Filters the HTML format of the search form.
   211 	 *
   195 	 *
   212 	 * @since 3.6.0
   196 	 * @since 3.6.0
   213 	 *
   197 	 *
   214 	 * @param string $format The type of markup to use in the search form.
   198 	 * @param string $format The type of markup to use in the search form.
   215 	 *                       Accepts 'html5', 'xhtml'.
   199 	 *                       Accepts 'html5', 'xhtml'.
   224 	} else {
   208 	} else {
   225 		if ( 'html5' == $format ) {
   209 		if ( 'html5' == $format ) {
   226 			$form = '<form role="search" method="get" class="search-form" action="' . esc_url( home_url( '/' ) ) . '">
   210 			$form = '<form role="search" method="get" class="search-form" action="' . esc_url( home_url( '/' ) ) . '">
   227 				<label>
   211 				<label>
   228 					<span class="screen-reader-text">' . _x( 'Search for:', 'label' ) . '</span>
   212 					<span class="screen-reader-text">' . _x( 'Search for:', 'label' ) . '</span>
   229 					<input type="search" class="search-field" placeholder="' . esc_attr_x( 'Search &hellip;', 'placeholder' ) . '" value="' . get_search_query() . '" name="s" title="' . esc_attr_x( 'Search for:', 'label' ) . '" />
   213 					<input type="search" class="search-field" placeholder="' . esc_attr_x( 'Search &hellip;', 'placeholder' ) . '" value="' . get_search_query() . '" name="s" />
   230 				</label>
   214 				</label>
   231 				<input type="submit" class="search-submit" value="'. esc_attr_x( 'Search', 'submit button' ) .'" />
   215 				<input type="submit" class="search-submit" value="'. esc_attr_x( 'Search', 'submit button' ) .'" />
   232 			</form>';
   216 			</form>';
   233 		} else {
   217 		} else {
   234 			$form = '<form role="search" method="get" id="searchform" class="searchform" action="' . esc_url( home_url( '/' ) ) . '">
   218 			$form = '<form role="search" method="get" id="searchform" class="searchform" action="' . esc_url( home_url( '/' ) ) . '">
   240 			</form>';
   224 			</form>';
   241 		}
   225 		}
   242 	}
   226 	}
   243 
   227 
   244 	/**
   228 	/**
   245 	 * Filter the HTML output of the search form.
   229 	 * Filters the HTML output of the search form.
   246 	 *
   230 	 *
   247 	 * @since 2.7.0
   231 	 * @since 2.7.0
   248 	 *
   232 	 *
   249 	 * @param string $form The search form HTML output.
   233 	 * @param string $form The search form HTML output.
   250 	 */
   234 	 */
   266  * or log out depending on whether they are currently logged in.
   250  * or log out depending on whether they are currently logged in.
   267  *
   251  *
   268  * @since 1.5.0
   252  * @since 1.5.0
   269  *
   253  *
   270  * @param string $redirect Optional path to redirect to on login/logout.
   254  * @param string $redirect Optional path to redirect to on login/logout.
   271  * @param boolean $echo Default to echo and not return the link.
   255  * @param bool   $echo     Default to echo and not return the link.
   272  * @return string|null String when retrieving, null when displaying.
   256  * @return string|void String when retrieving.
   273  */
   257  */
   274 function wp_loginout($redirect = '', $echo = true) {
   258 function wp_loginout($redirect = '', $echo = true) {
   275 	if ( ! is_user_logged_in() )
   259 	if ( ! is_user_logged_in() )
   276 		$link = '<a href="' . esc_url( wp_login_url($redirect) ) . '">' . __('Log in') . '</a>';
   260 		$link = '<a href="' . esc_url( wp_login_url($redirect) ) . '">' . __('Log in') . '</a>';
   277 	else
   261 	else
   278 		$link = '<a href="' . esc_url( wp_logout_url($redirect) ) . '">' . __('Log out') . '</a>';
   262 		$link = '<a href="' . esc_url( wp_logout_url($redirect) ) . '">' . __('Log out') . '</a>';
   279 
   263 
   280 	if ( $echo ) {
   264 	if ( $echo ) {
   281 		/**
   265 		/**
   282 		 * Filter the HTML output for the Log In/Log Out link.
   266 		 * Filters the HTML output for the Log In/Log Out link.
   283 		 *
   267 		 *
   284 		 * @since 1.5.0
   268 		 * @since 1.5.0
   285 		 *
   269 		 *
   286 		 * @param string $link The HTML link content.
   270 		 * @param string $link The HTML link content.
   287 		 */
   271 		 */
   291 		return apply_filters( 'loginout', $link );
   275 		return apply_filters( 'loginout', $link );
   292 	}
   276 	}
   293 }
   277 }
   294 
   278 
   295 /**
   279 /**
   296  * Returns the Log Out URL.
   280  * Retrieves the logout URL.
   297  *
   281  *
   298  * Returns the URL that allows the user to log out of the site.
   282  * Returns the URL that allows the user to log out of the site.
   299  *
   283  *
   300  * @since 2.7.0
   284  * @since 2.7.0
   301  *
   285  *
   302  * @param string $redirect Path to redirect to on logout.
   286  * @param string $redirect Path to redirect to on logout.
   303  * @return string A log out URL.
   287  * @return string The logout URL. Note: HTML-encoded via esc_html() in wp_nonce_url().
   304  */
   288  */
   305 function wp_logout_url($redirect = '') {
   289 function wp_logout_url($redirect = '') {
   306 	$args = array( 'action' => 'logout' );
   290 	$args = array( 'action' => 'logout' );
   307 	if ( !empty($redirect) ) {
   291 	if ( !empty($redirect) ) {
   308 		$args['redirect_to'] = urlencode( $redirect );
   292 		$args['redirect_to'] = urlencode( $redirect );
   310 
   294 
   311 	$logout_url = add_query_arg($args, site_url('wp-login.php', 'login'));
   295 	$logout_url = add_query_arg($args, site_url('wp-login.php', 'login'));
   312 	$logout_url = wp_nonce_url( $logout_url, 'log-out' );
   296 	$logout_url = wp_nonce_url( $logout_url, 'log-out' );
   313 
   297 
   314 	/**
   298 	/**
   315 	 * Filter the logout URL.
   299 	 * Filters the logout URL.
   316 	 *
   300 	 *
   317 	 * @since 2.8.0
   301 	 * @since 2.8.0
   318 	 *
   302 	 *
   319 	 * @param string $logout_url The Log Out URL.
   303 	 * @param string $logout_url The HTML-encoded logout URL.
   320 	 * @param string $redirect   Path to redirect to on logout.
   304 	 * @param string $redirect   Path to redirect to on logout.
   321 	 */
   305 	 */
   322 	return apply_filters( 'logout_url', $logout_url, $redirect );
   306 	return apply_filters( 'logout_url', $logout_url, $redirect );
   323 }
   307 }
   324 
   308 
   325 /**
   309 /**
   326  * Returns the Log In URL.
   310  * Retrieves the login URL.
   327  *
       
   328  * Returns the URL that allows the user to log in to the site.
       
   329  *
   311  *
   330  * @since 2.7.0
   312  * @since 2.7.0
   331  *
   313  *
   332  * @param string $redirect Path to redirect to on login.
   314  * @param string $redirect     Path to redirect to on log in.
   333  * @param bool $force_reauth Whether to force reauthorization, even if a cookie is present. Default is false.
   315  * @param bool   $force_reauth Whether to force reauthorization, even if a cookie is present.
   334  * @return string A log in URL.
   316  *                             Default false.
       
   317  * @return string The login URL. Not HTML-encoded.
   335  */
   318  */
   336 function wp_login_url($redirect = '', $force_reauth = false) {
   319 function wp_login_url($redirect = '', $force_reauth = false) {
   337 	$login_url = site_url('wp-login.php', 'login');
   320 	$login_url = site_url('wp-login.php', 'login');
   338 
   321 
   339 	if ( !empty($redirect) )
   322 	if ( !empty($redirect) )
   341 
   324 
   342 	if ( $force_reauth )
   325 	if ( $force_reauth )
   343 		$login_url = add_query_arg('reauth', '1', $login_url);
   326 		$login_url = add_query_arg('reauth', '1', $login_url);
   344 
   327 
   345 	/**
   328 	/**
   346 	 * Filter the login URL.
   329 	 * Filters the login URL.
   347 	 *
   330 	 *
   348 	 * @since 2.8.0
   331 	 * @since 2.8.0
   349 	 * @since 4.2.0 The `$force_reauth` parameter was added.
   332 	 * @since 4.2.0 The `$force_reauth` parameter was added.
   350 	 *
   333 	 *
   351 	 * @param string $login_url    The login URL.
   334 	 * @param string $login_url    The login URL. Not HTML-encoded.
   352 	 * @param string $redirect     The path to redirect to on login, if supplied.
   335 	 * @param string $redirect     The path to redirect to on login, if supplied.
   353 	 * @param bool   $force_reauth Whether to force reauthorization, even if a cookie is present.
   336 	 * @param bool   $force_reauth Whether to force reauthorization, even if a cookie is present.
   354 	 */
   337 	 */
   355 	return apply_filters( 'login_url', $login_url, $redirect, $force_reauth );
   338 	return apply_filters( 'login_url', $login_url, $redirect, $force_reauth );
   356 }
   339 }
   357 
   340 
   358 /**
   341 /**
   359  * Returns the user registration URL.
       
   360  *
       
   361  * Returns the URL that allows the user to register on the site.
   342  * Returns the URL that allows the user to register on the site.
   362  *
   343  *
   363  * @since 3.6.0
   344  * @since 3.6.0
   364  *
   345  *
   365  * @return string User registration URL.
   346  * @return string User registration URL.
   366  */
   347  */
   367 function wp_registration_url() {
   348 function wp_registration_url() {
   368 	/**
   349 	/**
   369 	 * Filter the user registration URL.
   350 	 * Filters the user registration URL.
   370 	 *
   351 	 *
   371 	 * @since 3.6.0
   352 	 * @since 3.6.0
   372 	 *
   353 	 *
   373 	 * @param string $register The user registration URL.
   354 	 * @param string $register The user registration URL.
   374 	 */
   355 	 */
   375 	return apply_filters( 'register_url', site_url( 'wp-login.php?action=register', 'login' ) );
   356 	return apply_filters( 'register_url', site_url( 'wp-login.php?action=register', 'login' ) );
   376 }
   357 }
   377 
   358 
   378 /**
   359 /**
   379  * Provides a simple login form for use anywhere within WordPress. By default, it echoes
   360  * Provides a simple login form for use anywhere within WordPress.
   380  * the HTML immediately. Pass array('echo'=>false) to return the string instead.
   361  *
       
   362  * The login format HTML is echoed by default. Pass a false value for `$echo` to return it instead.
   381  *
   363  *
   382  * @since 3.0.0
   364  * @since 3.0.0
   383  *
   365  *
   384  * @param array $args Configuration options to modify the form output.
   366  * @param array $args {
   385  * @return string|null String when retrieving, null when displaying.
   367  *     Optional. Array of options to control the form output. Default empty array.
       
   368  *
       
   369  *     @type bool   $echo           Whether to display the login form or return the form HTML code.
       
   370  *                                  Default true (echo).
       
   371  *     @type string $redirect       URL to redirect to. Must be absolute, as in "https://example.com/mypage/".
       
   372  *                                  Default is to redirect back to the request URI.
       
   373  *     @type string $form_id        ID attribute value for the form. Default 'loginform'.
       
   374  *     @type string $label_username Label for the username or email address field. Default 'Username or Email Address'.
       
   375  *     @type string $label_password Label for the password field. Default 'Password'.
       
   376  *     @type string $label_remember Label for the remember field. Default 'Remember Me'.
       
   377  *     @type string $label_log_in   Label for the submit button. Default 'Log In'.
       
   378  *     @type string $id_username    ID attribute value for the username field. Default 'user_login'.
       
   379  *     @type string $id_password    ID attribute value for the password field. Default 'user_pass'.
       
   380  *     @type string $id_remember    ID attribute value for the remember field. Default 'rememberme'.
       
   381  *     @type string $id_submit      ID attribute value for the submit button. Default 'wp-submit'.
       
   382  *     @type bool   $remember       Whether to display the "rememberme" checkbox in the form.
       
   383  *     @type string $value_username Default value for the username field. Default empty.
       
   384  *     @type bool   $value_remember Whether the "Remember Me" checkbox should be checked by default.
       
   385  *                                  Default false (unchecked).
       
   386  *
       
   387  * }
       
   388  * @return string|void String when retrieving.
   386  */
   389  */
   387 function wp_login_form( $args = array() ) {
   390 function wp_login_form( $args = array() ) {
   388 	$defaults = array(
   391 	$defaults = array(
   389 		'echo' => true,
   392 		'echo' => true,
   390 		'redirect' => ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], // Default redirect is back to the current page
   393 		// Default 'redirect' value takes the user back to the request URI.
       
   394 		'redirect' => ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'],
   391 		'form_id' => 'loginform',
   395 		'form_id' => 'loginform',
   392 		'label_username' => __( 'Username' ),
   396 		'label_username' => __( 'Username or Email Address' ),
   393 		'label_password' => __( 'Password' ),
   397 		'label_password' => __( 'Password' ),
   394 		'label_remember' => __( 'Remember Me' ),
   398 		'label_remember' => __( 'Remember Me' ),
   395 		'label_log_in' => __( 'Log In' ),
   399 		'label_log_in' => __( 'Log In' ),
   396 		'id_username' => 'user_login',
   400 		'id_username' => 'user_login',
   397 		'id_password' => 'user_pass',
   401 		'id_password' => 'user_pass',
   398 		'id_remember' => 'rememberme',
   402 		'id_remember' => 'rememberme',
   399 		'id_submit' => 'wp-submit',
   403 		'id_submit' => 'wp-submit',
   400 		'remember' => true,
   404 		'remember' => true,
   401 		'value_username' => '',
   405 		'value_username' => '',
   402 		'value_remember' => false, // Set this to true to default the "Remember me" checkbox to checked
   406 		// Set 'value_remember' to true to default the "Remember me" checkbox to checked.
       
   407 		'value_remember' => false,
   403 	);
   408 	);
   404 
   409 
   405 	/**
   410 	/**
   406 	 * Filter the default login form output arguments.
   411 	 * Filters the default login form output arguments.
   407 	 *
   412 	 *
   408 	 * @since 3.0.0
   413 	 * @since 3.0.0
   409 	 *
   414 	 *
   410 	 * @see wp_login_form()
   415 	 * @see wp_login_form()
   411 	 *
   416 	 *
   412 	 * @param array $defaults An array of default login form arguments.
   417 	 * @param array $defaults An array of default login form arguments.
   413 	 */
   418 	 */
   414 	$args = wp_parse_args( $args, apply_filters( 'login_form_defaults', $defaults ) );
   419 	$args = wp_parse_args( $args, apply_filters( 'login_form_defaults', $defaults ) );
   415 
   420 
   416 	/**
   421 	/**
   417 	 * Filter content to display at the top of the login form.
   422 	 * Filters content to display at the top of the login form.
   418 	 *
   423 	 *
   419 	 * The filter evaluates just following the opening form tag element.
   424 	 * The filter evaluates just following the opening form tag element.
   420 	 *
   425 	 *
   421 	 * @since 3.0.0
   426 	 * @since 3.0.0
   422 	 *
   427 	 *
   424 	 * @param array  $args    Array of login form arguments.
   429 	 * @param array  $args    Array of login form arguments.
   425 	 */
   430 	 */
   426 	$login_form_top = apply_filters( 'login_form_top', '', $args );
   431 	$login_form_top = apply_filters( 'login_form_top', '', $args );
   427 
   432 
   428 	/**
   433 	/**
   429 	 * Filter content to display in the middle of the login form.
   434 	 * Filters content to display in the middle of the login form.
   430 	 *
   435 	 *
   431 	 * The filter evaluates just following the location where the 'login-password'
   436 	 * The filter evaluates just following the location where the 'login-password'
   432 	 * field is displayed.
   437 	 * field is displayed.
   433 	 *
   438 	 *
   434 	 * @since 3.0.0
   439 	 * @since 3.0.0
   437 	 * @param array  $args    Array of login form arguments.
   442 	 * @param array  $args    Array of login form arguments.
   438 	 */
   443 	 */
   439 	$login_form_middle = apply_filters( 'login_form_middle', '', $args );
   444 	$login_form_middle = apply_filters( 'login_form_middle', '', $args );
   440 
   445 
   441 	/**
   446 	/**
   442 	 * Filter content to display at the bottom of the login form.
   447 	 * Filters content to display at the bottom of the login form.
   443 	 *
   448 	 *
   444 	 * The filter evaluates just preceding the closing form tag element.
   449 	 * The filter evaluates just preceding the closing form tag element.
   445 	 *
   450 	 *
   446 	 * @since 3.0.0
   451 	 * @since 3.0.0
   447 	 *
   452 	 *
   462 				<input type="password" name="pwd" id="' . esc_attr( $args['id_password'] ) . '" class="input" value="" size="20" />
   467 				<input type="password" name="pwd" id="' . esc_attr( $args['id_password'] ) . '" class="input" value="" size="20" />
   463 			</p>
   468 			</p>
   464 			' . $login_form_middle . '
   469 			' . $login_form_middle . '
   465 			' . ( $args['remember'] ? '<p class="login-remember"><label><input name="rememberme" type="checkbox" id="' . esc_attr( $args['id_remember'] ) . '" value="forever"' . ( $args['value_remember'] ? ' checked="checked"' : '' ) . ' /> ' . esc_html( $args['label_remember'] ) . '</label></p>' : '' ) . '
   470 			' . ( $args['remember'] ? '<p class="login-remember"><label><input name="rememberme" type="checkbox" id="' . esc_attr( $args['id_remember'] ) . '" value="forever"' . ( $args['value_remember'] ? ' checked="checked"' : '' ) . ' /> ' . esc_html( $args['label_remember'] ) . '</label></p>' : '' ) . '
   466 			<p class="login-submit">
   471 			<p class="login-submit">
   467 				<input type="submit" name="wp-submit" id="' . esc_attr( $args['id_submit'] ) . '" class="button-primary" value="' . esc_attr( $args['label_log_in'] ) . '" />
   472 				<input type="submit" name="wp-submit" id="' . esc_attr( $args['id_submit'] ) . '" class="button button-primary" value="' . esc_attr( $args['label_log_in'] ) . '" />
   468 				<input type="hidden" name="redirect_to" value="' . esc_url( $args['redirect'] ) . '" />
   473 				<input type="hidden" name="redirect_to" value="' . esc_url( $args['redirect'] ) . '" />
   469 			</p>
   474 			</p>
   470 			' . $login_form_bottom . '
   475 			' . $login_form_bottom . '
   471 		</form>';
   476 		</form>';
   472 
   477 
   475 	else
   480 	else
   476 		return $form;
   481 		return $form;
   477 }
   482 }
   478 
   483 
   479 /**
   484 /**
   480  * Returns the Lost Password URL.
       
   481  *
       
   482  * Returns the URL that allows the user to retrieve the lost password
   485  * Returns the URL that allows the user to retrieve the lost password
   483  *
   486  *
   484  * @since 2.8.0
   487  * @since 2.8.0
   485  *
   488  *
   486  * @param string $redirect Path to redirect to on login.
   489  * @param string $redirect Path to redirect to on login.
   487  * @return string Lost password URL.
   490  * @return string Lost password URL.
   488  */
   491  */
   489 function wp_lostpassword_url( $redirect = '' ) {
   492 function wp_lostpassword_url( $redirect = '' ) {
   490 	$args = array( 'action' => 'lostpassword' );
   493 	$args = array( 'action' => 'lostpassword' );
   491 	if ( !empty($redirect) ) {
   494 	if ( !empty($redirect) ) {
   492 		$args['redirect_to'] = $redirect;
   495 		$args['redirect_to'] = urlencode( $redirect );
   493 	}
   496 	}
   494 
   497 
   495 	$lostpassword_url = add_query_arg( $args, network_site_url('wp-login.php', 'login') );
   498 	$lostpassword_url = add_query_arg( $args, network_site_url('wp-login.php', 'login') );
   496 
   499 
   497 	/**
   500 	/**
   498 	 * Filter the Lost Password URL.
   501 	 * Filters the Lost Password URL.
   499 	 *
   502 	 *
   500 	 * @since 2.8.0
   503 	 * @since 2.8.0
   501 	 *
   504 	 *
   502 	 * @param string $lostpassword_url The lost password page URL.
   505 	 * @param string $lostpassword_url The lost password page URL.
   503 	 * @param string $redirect         The path to redirect to on login.
   506 	 * @param string $redirect         The path to redirect to on login.
   512  * not logged in and registration is enabled or to the dashboard if logged in.
   515  * not logged in and registration is enabled or to the dashboard if logged in.
   513  *
   516  *
   514  * @since 1.5.0
   517  * @since 1.5.0
   515  *
   518  *
   516  * @param string $before Text to output before the link. Default `<li>`.
   519  * @param string $before Text to output before the link. Default `<li>`.
   517  * @param string $after Text to output after the link. Default `</li>`.
   520  * @param string $after  Text to output after the link. Default `</li>`.
   518  * @param boolean $echo Default to echo and not return the link.
   521  * @param bool   $echo   Default to echo and not return the link.
   519  * @return string|null String when retrieving, null when displaying.
   522  * @return string|void String when retrieving.
   520  */
   523  */
   521 function wp_register( $before = '<li>', $after = '</li>', $echo = true ) {
   524 function wp_register( $before = '<li>', $after = '</li>', $echo = true ) {
   522 
       
   523 	if ( ! is_user_logged_in() ) {
   525 	if ( ! is_user_logged_in() ) {
   524 		if ( get_option('users_can_register') )
   526 		if ( get_option('users_can_register') )
   525 			$link = $before . '<a href="' . esc_url( wp_registration_url() ) . '">' . __('Register') . '</a>' . $after;
   527 			$link = $before . '<a href="' . esc_url( wp_registration_url() ) . '">' . __('Register') . '</a>' . $after;
   526 		else
   528 		else
   527 			$link = '';
   529 			$link = '';
       
   530 	} elseif ( current_user_can( 'read' ) ) {
       
   531 		$link = $before . '<a href="' . admin_url() . '">' . __('Site Admin') . '</a>' . $after;
   528 	} else {
   532 	} else {
   529 		$link = $before . '<a href="' . admin_url() . '">' . __('Site Admin') . '</a>' . $after;
   533 		$link = '';
   530 	}
   534 	}
   531 
   535 
   532 	/**
   536 	/**
   533 	 * Filter the HTML link to the Registration or Admin page.
   537 	 * Filters the HTML link to the Registration or Admin page.
   534 	 *
   538 	 *
   535 	 * Users are sent to the admin page if logged-in, or the registration page
   539 	 * Users are sent to the admin page if logged-in, or the registration page
   536 	 * if enabled and logged-out.
   540 	 * if enabled and logged-out.
   537 	 *
   541 	 *
   538 	 * @since 1.5.0
   542 	 * @since 1.5.0
   549 }
   553 }
   550 
   554 
   551 /**
   555 /**
   552  * Theme container function for the 'wp_meta' action.
   556  * Theme container function for the 'wp_meta' action.
   553  *
   557  *
   554  * The 'wp_meta' action can have several purposes, depending on how you use it,
   558  * The {@see 'wp_meta'} action can have several purposes, depending on how you use it,
   555  * but one purpose might have been to allow for theme switching.
   559  * but one purpose might have been to allow for theme switching.
   556  *
   560  *
   557  * @since 1.5.0
   561  * @since 1.5.0
   558  *
   562  *
   559  * @link https://core.trac.wordpress.org/ticket/1458 Explanation of 'wp_meta' action.
   563  * @link https://core.trac.wordpress.org/ticket/1458 Explanation of 'wp_meta' action.
   566 	 */
   570 	 */
   567 	do_action( 'wp_meta' );
   571 	do_action( 'wp_meta' );
   568 }
   572 }
   569 
   573 
   570 /**
   574 /**
   571  * Display information about the blog.
   575  * Displays information about the current site.
   572  *
   576  *
   573  * @see get_bloginfo() For possible values for the parameter.
       
   574  * @since 0.71
   577  * @since 0.71
   575  *
   578  *
   576  * @param string $show What to display.
   579  * @see get_bloginfo() For possible `$show` values
   577  */
   580  *
   578 function bloginfo( $show='' ) {
   581  * @param string $show Optional. Site information to display. Default empty.
       
   582  */
       
   583 function bloginfo( $show = '' ) {
   579 	echo get_bloginfo( $show, 'display' );
   584 	echo get_bloginfo( $show, 'display' );
   580 }
   585 }
   581 
   586 
   582 /**
   587 /**
   583  * Retrieve information about the blog.
   588  * Retrieves information about the current site.
   584  *
   589  *
   585  * Some show parameter values are deprecated and will be removed in future
   590  * Possible values for `$show` include:
   586  * versions. These options will trigger the {@see _deprecated_argument()}
   591  *
   587  * function. The deprecated blog info options are listed in the function
   592  * - 'name' - Site title (set in Settings > General)
   588  * contents.
   593  * - 'description' - Site tagline (set in Settings > General)
   589  *
   594  * - 'wpurl' - The WordPress address (URL) (set in Settings > General)
   590  * The possible values for the 'show' parameter are listed below.
   595  * - 'url' - The Site address (URL) (set in Settings > General)
   591  *
   596  * - 'admin_email' - Admin email (set in Settings > General)
   592  * 1. url - Blog URI to homepage.
   597  * - 'charset' - The "Encoding for pages and feeds"  (set in Settings > Reading)
   593  * 2. wpurl - Blog URI path to WordPress.
   598  * - 'version' - The current WordPress version
   594  * 3. description - Secondary title
   599  * - 'html_type' - The content-type (default: "text/html"). Themes and plugins
   595  *
   600  *   can override the default value using the {@see 'pre_option_html_type'} filter
   596  * The feed URL options can be retrieved from 'rdf_url' (RSS 0.91),
   601  * - 'text_direction' - The text direction determined by the site's language. is_rtl()
   597  * 'rss_url' (RSS 1.0), 'rss2_url' (RSS 2.0), or 'atom_url' (Atom feed). The
   602  *   should be used instead
   598  * comment feeds can be retrieved from the 'comments_atom_url' (Atom comment
   603  * - 'language' - Language code for the current site
   599  * feed) or 'comments_rss2_url' (RSS 2.0 comment feed).
   604  * - 'stylesheet_url' - URL to the stylesheet for the active theme. An active child theme
       
   605  *   will take precedence over this value
       
   606  * - 'stylesheet_directory' - Directory path for the active theme.  An active child theme
       
   607  *   will take precedence over this value
       
   608  * - 'template_url' / 'template_directory' - URL of the active theme's directory. An active
       
   609  *   child theme will NOT take precedence over this value
       
   610  * - 'pingback_url' - The pingback XML-RPC file URL (xmlrpc.php)
       
   611  * - 'atom_url' - The Atom feed URL (/feed/atom)
       
   612  * - 'rdf_url' - The RDF/RSS 1.0 feed URL (/feed/rfd)
       
   613  * - 'rss_url' - The RSS 0.92 feed URL (/feed/rss)
       
   614  * - 'rss2_url' - The RSS 2.0 feed URL (/feed)
       
   615  * - 'comments_atom_url' - The comments Atom feed URL (/comments/feed)
       
   616  * - 'comments_rss2_url' - The comments RSS 2.0 feed URL (/comments/feed)
       
   617  *
       
   618  * Some `$show` values are deprecated and will be removed in future versions.
       
   619  * These options will trigger the _deprecated_argument() function.
       
   620  *
       
   621  * Deprecated arguments include:
       
   622  *
       
   623  * - 'siteurl' - Use 'url' instead
       
   624  * - 'home' - Use 'url' instead
   600  *
   625  *
   601  * @since 0.71
   626  * @since 0.71
   602  *
   627  *
   603  * @param string $show Blog info to retrieve.
   628  * @global string $wp_version
   604  * @param string $filter How to filter what is retrieved.
   629  *
       
   630  * @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'.
   605  * @return string Mostly string values, might be empty.
   632  * @return string Mostly string values, might be empty.
   606  */
   633  */
   607 function get_bloginfo( $show = '', $filter = 'raw' ) {
   634 function get_bloginfo( $show = '', $filter = 'raw' ) {
   608 
       
   609 	switch( $show ) {
   635 	switch( $show ) {
   610 		case 'home' : // DEPRECATED
   636 		case 'home' : // DEPRECATED
   611 		case 'siteurl' : // DEPRECATED
   637 		case 'siteurl' : // DEPRECATED
   612 			_deprecated_argument( __FUNCTION__, '2.2', sprintf(
   638 			_deprecated_argument( __FUNCTION__, '2.2.0', sprintf(
   613 				/* translators: 1: 'siteurl'/'home' argument, 2: bloginfo() function name, 3: 'url' argument */
   639 				/* translators: 1: 'siteurl'/'home' argument, 2: bloginfo() function name, 3: 'url' argument */
   614 				__( 'The %1$s option is deprecated for the family of %2$s functions. Use the %3$s option instead.' ),
   640 				__( 'The %1$s option is deprecated for the family of %2$s functions. Use the %3$s option instead.' ),
   615 				'<code>' . $show . '</code>',
   641 				'<code>' . $show . '</code>',
   616 				'<code>bloginfo()</code>',
   642 				'<code>bloginfo()</code>',
   617 				'<code>url</code>'
   643 				'<code>url</code>'
   669 		case 'version':
   695 		case 'version':
   670 			global $wp_version;
   696 			global $wp_version;
   671 			$output = $wp_version;
   697 			$output = $wp_version;
   672 			break;
   698 			break;
   673 		case 'language':
   699 		case 'language':
   674 			$output = get_locale();
   700 			/* translators: Translate this to the correct language tag for your locale,
   675 			$output = str_replace('_', '-', $output);
   701 			 * see https://www.w3.org/International/articles/language-tags/ for reference.
       
   702 			 * Do not translate into your own language.
       
   703 			 */
       
   704 			$output = __( 'html_lang_attribute' );
       
   705 			if ( 'html_lang_attribute' === $output || preg_match( '/[^a-zA-Z0-9-]/', $output ) ) {
       
   706 				$output = is_admin() ? get_user_locale() : get_locale();
       
   707 				$output = str_replace( '_', '-', $output );
       
   708 			}
   676 			break;
   709 			break;
   677 		case 'text_direction':
   710 		case 'text_direction':
   678 			_deprecated_argument( __FUNCTION__, '2.2', sprintf(
   711 			_deprecated_argument( __FUNCTION__, '2.2.0', sprintf(
   679 				/* translators: 1: 'text_direction' argument, 2: bloginfo() function name, 3: is_rtl() function name */
   712 				/* translators: 1: 'text_direction' argument, 2: bloginfo() function name, 3: is_rtl() function name */
   680 				__( 'The %1$s option is deprecated for the family of %2$s functions. Use the %3$s function instead.' ),
   713 				__( 'The %1$s option is deprecated for the family of %2$s functions. Use the %3$s function instead.' ),
   681 				'<code>' . $show . '</code>',
   714 				'<code>' . $show . '</code>',
   682 				'<code>bloginfo()</code>',
   715 				'<code>bloginfo()</code>',
   683 				'<code>is_rtl()</code>'
   716 				'<code>is_rtl()</code>'
   701 		$url = false;
   734 		$url = false;
   702 
   735 
   703 	if ( 'display' == $filter ) {
   736 	if ( 'display' == $filter ) {
   704 		if ( $url ) {
   737 		if ( $url ) {
   705 			/**
   738 			/**
   706 			 * Filter the URL returned by get_bloginfo().
   739 			 * Filters the URL returned by get_bloginfo().
   707 			 *
   740 			 *
   708 			 * @since 2.0.5
   741 			 * @since 2.0.5
   709 			 *
   742 			 *
   710 			 * @param mixed $output The URL returned by bloginfo().
   743 			 * @param mixed $output The URL returned by bloginfo().
   711 			 * @param mixed $show   Type of information requested.
   744 			 * @param mixed $show   Type of information requested.
   712 			 */
   745 			 */
   713 			$output = apply_filters( 'bloginfo_url', $output, $show );
   746 			$output = apply_filters( 'bloginfo_url', $output, $show );
   714 		} else {
   747 		} else {
   715 			/**
   748 			/**
   716 			 * Filter the site information returned by get_bloginfo().
   749 			 * Filters the site information returned by get_bloginfo().
   717 			 *
   750 			 *
   718 			 * @since 0.71
   751 			 * @since 0.71
   719 			 *
   752 			 *
   720 			 * @param mixed $output The requested non-URL site information.
   753 			 * @param mixed $output The requested non-URL site information.
   721 			 * @param mixed $show   Type of information requested.
   754 			 * @param mixed $show   Type of information requested.
   726 
   759 
   727 	return $output;
   760 	return $output;
   728 }
   761 }
   729 
   762 
   730 /**
   763 /**
   731  * Display title tag with contents.
   764  * Returns the Site Icon URL.
       
   765  *
       
   766  * @since 4.3.0
       
   767  *
       
   768  * @param int    $size    Optional. Size of the site icon. Default 512 (pixels).
       
   769  * @param string $url     Optional. Fallback url if no site icon is found. Default empty.
       
   770  * @param int    $blog_id Optional. ID of the blog to get the site icon for. Default current blog.
       
   771  * @return string Site Icon URL.
       
   772  */
       
   773 function get_site_icon_url( $size = 512, $url = '', $blog_id = 0 ) {
       
   774 	$switched_blog = false;
       
   775 
       
   776 	if ( is_multisite() && ! empty( $blog_id ) && (int) $blog_id !== get_current_blog_id() ) {
       
   777 		switch_to_blog( $blog_id );
       
   778 		$switched_blog = true;
       
   779 	}
       
   780 
       
   781 	$site_icon_id = get_option( 'site_icon' );
       
   782 
       
   783 	if ( $site_icon_id ) {
       
   784 		if ( $size >= 512 ) {
       
   785 			$size_data = 'full';
       
   786 		} else {
       
   787 			$size_data = array( $size, $size );
       
   788 		}
       
   789 		$url = wp_get_attachment_image_url( $site_icon_id, $size_data );
       
   790 	}
       
   791 
       
   792 	if ( $switched_blog ) {
       
   793 		restore_current_blog();
       
   794 	}
       
   795 
       
   796 	/**
       
   797 	 * Filters the site icon URL.
       
   798 	 *
       
   799 	 * @since 4.4.0
       
   800 	 *
       
   801 	 * @param string $url     Site icon URL.
       
   802 	 * @param int    $size    Size of the site icon.
       
   803 	 * @param int    $blog_id ID of the blog to get the site icon for.
       
   804 	 */
       
   805 	return apply_filters( 'get_site_icon_url', $url, $size, $blog_id );
       
   806 }
       
   807 
       
   808 /**
       
   809  * Displays the Site Icon URL.
       
   810  *
       
   811  * @since 4.3.0
       
   812  *
       
   813  * @param int    $size    Optional. Size of the site icon. Default 512 (pixels).
       
   814  * @param string $url     Optional. Fallback url if no site icon is found. Default empty.
       
   815  * @param int    $blog_id Optional. ID of the blog to get the site icon for. Default current blog.
       
   816  */
       
   817 function site_icon_url( $size = 512, $url = '', $blog_id = 0 ) {
       
   818 	echo esc_url( get_site_icon_url( $size, $url, $blog_id ) );
       
   819 }
       
   820 
       
   821 /**
       
   822  * Whether the site has a Site Icon.
       
   823  *
       
   824  * @since 4.3.0
       
   825  *
       
   826  * @param int $blog_id Optional. ID of the blog in question. Default current blog.
       
   827  * @return bool Whether the site has a site icon or not.
       
   828  */
       
   829 function has_site_icon( $blog_id = 0 ) {
       
   830 	return (bool) get_site_icon_url( 512, '', $blog_id );
       
   831 }
       
   832 
       
   833 /**
       
   834  * Determines whether the site has a custom logo.
       
   835  *
       
   836  * @since 4.5.0
       
   837  *
       
   838  * @param int $blog_id Optional. ID of the blog in question. Default is the ID of the current blog.
       
   839  * @return bool Whether the site has a custom logo or not.
       
   840  */
       
   841 function has_custom_logo( $blog_id = 0 ) {
       
   842 	$switched_blog = false;
       
   843 
       
   844 	if ( is_multisite() && ! empty( $blog_id ) && (int) $blog_id !== get_current_blog_id() ) {
       
   845 		switch_to_blog( $blog_id );
       
   846 		$switched_blog = true;
       
   847 	}
       
   848 
       
   849 	$custom_logo_id = get_theme_mod( 'custom_logo' );
       
   850 
       
   851 	if ( $switched_blog ) {
       
   852 		restore_current_blog();
       
   853 	}
       
   854 
       
   855 	return (bool) $custom_logo_id;
       
   856 }
       
   857 
       
   858 /**
       
   859  * Returns a custom logo, linked to home.
       
   860  *
       
   861  * @since 4.5.0
       
   862  *
       
   863  * @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.
       
   865  */
       
   866 function get_custom_logo( $blog_id = 0 ) {
       
   867 	$html = '';
       
   868 	$switched_blog = false;
       
   869 
       
   870 	if ( is_multisite() && ! empty( $blog_id ) && (int) $blog_id !== get_current_blog_id() ) {
       
   871 		switch_to_blog( $blog_id );
       
   872 		$switched_blog = true;
       
   873 	}
       
   874 
       
   875 	$custom_logo_id = get_theme_mod( 'custom_logo' );
       
   876 
       
   877 	// We have a logo. Logo is go.
       
   878 	if ( $custom_logo_id ) {
       
   879 		$custom_logo_attr = array(
       
   880 			'class'    => 'custom-logo',
       
   881 			'itemprop' => 'logo',
       
   882 		);
       
   883 
       
   884 		/*
       
   885 		 * 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().
       
   887 		 */
       
   888 		$image_alt = get_post_meta( $custom_logo_id, '_wp_attachment_image_alt', true );
       
   889 		if ( empty( $image_alt ) ) {
       
   890 			$custom_logo_attr['alt'] = get_bloginfo( 'name', 'display' );
       
   891 		}
       
   892 
       
   893 		/*
       
   894 		 * 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.
       
   896 		 */
       
   897 		$html = sprintf( '<a href="%1$s" class="custom-logo-link" rel="home" itemprop="url">%2$s</a>',
       
   898 			esc_url( home_url( '/' ) ),
       
   899 			wp_get_attachment_image( $custom_logo_id, 'full', false, $custom_logo_attr )
       
   900 		);
       
   901 	}
       
   902 
       
   903 	// If no logo is set but we're in the Customizer, leave a placeholder (needed for the live preview).
       
   904 	elseif ( is_customize_preview() ) {
       
   905 		$html = sprintf( '<a href="%1$s" class="custom-logo-link" style="display:none;"><img class="custom-logo"/></a>',
       
   906 			esc_url( home_url( '/' ) )
       
   907 		);
       
   908 	}
       
   909 
       
   910 	if ( $switched_blog ) {
       
   911 		restore_current_blog();
       
   912 	}
       
   913 
       
   914 	/**
       
   915 	 * Filters the custom logo output.
       
   916 	 *
       
   917 	 * @since 4.5.0
       
   918 	 * @since 4.6.0 Added the `$blog_id` parameter.
       
   919 	 *
       
   920 	 * @param string $html    Custom logo HTML output.
       
   921 	 * @param int    $blog_id ID of the blog to get the custom logo for.
       
   922 	 */
       
   923 	return apply_filters( 'get_custom_logo', $html, $blog_id );
       
   924 }
       
   925 
       
   926 /**
       
   927  * Displays a custom logo, linked to home.
       
   928  *
       
   929  * @since 4.5.0
       
   930  *
       
   931  * @param int $blog_id Optional. ID of the blog in question. Default is the ID of the current blog.
       
   932  */
       
   933 function the_custom_logo( $blog_id = 0 ) {
       
   934 	echo get_custom_logo( $blog_id );
       
   935 }
       
   936 
       
   937 /**
       
   938  * Returns document title for the current page.
       
   939  *
       
   940  * @since 4.4.0
       
   941  *
       
   942  * @global int $page  Page number of a single post.
       
   943  * @global int $paged Page number of a list of posts.
       
   944  *
       
   945  * @return string Tag with the document title.
       
   946  */
       
   947 function wp_get_document_title() {
       
   948 
       
   949 	/**
       
   950 	 * Filters the document title before it is generated.
       
   951 	 *
       
   952 	 * Passing a non-empty value will short-circuit wp_get_document_title(),
       
   953 	 * returning that value instead.
       
   954 	 *
       
   955 	 * @since 4.4.0
       
   956 	 *
       
   957 	 * @param string $title The document title. Default empty string.
       
   958 	 */
       
   959 	$title = apply_filters( 'pre_get_document_title', '' );
       
   960 	if ( ! empty( $title ) ) {
       
   961 		return $title;
       
   962 	}
       
   963 
       
   964 	global $page, $paged;
       
   965 
       
   966 	$title = array(
       
   967 		'title' => '',
       
   968 	);
       
   969 
       
   970 	// If it's a 404 page, use a "Page not found" title.
       
   971 	if ( is_404() ) {
       
   972 		$title['title'] = __( 'Page not found' );
       
   973 
       
   974 	// If it's a search, use a dynamic search results title.
       
   975 	} elseif ( is_search() ) {
       
   976 		/* translators: %s: search phrase */
       
   977 		$title['title'] = sprintf( __( 'Search Results for &#8220;%s&#8221;' ), get_search_query() );
       
   978 
       
   979 	// If on the front page, use the site title.
       
   980 	} elseif ( is_front_page() ) {
       
   981 		$title['title'] = get_bloginfo( 'name', 'display' );
       
   982 
       
   983 	// If on a post type archive, use the post type archive title.
       
   984 	} elseif ( is_post_type_archive() ) {
       
   985 		$title['title'] = post_type_archive_title( '', false );
       
   986 
       
   987 	// If on a taxonomy archive, use the term title.
       
   988 	} elseif ( is_tax() ) {
       
   989 		$title['title'] = single_term_title( '', false );
       
   990 
       
   991 	/*
       
   992 	 * 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.
       
   994 	 */
       
   995 	} elseif ( is_home() || is_singular() ) {
       
   996 		$title['title'] = single_post_title( '', false );
       
   997 
       
   998 	// If on a category or tag archive, use the term title.
       
   999 	} elseif ( is_category() || is_tag() ) {
       
  1000 		$title['title'] = single_term_title( '', false );
       
  1001 
       
  1002 	// If on an author archive, use the author's display name.
       
  1003 	} elseif ( is_author() && $author = get_queried_object() ) {
       
  1004 		$title['title'] = $author->display_name;
       
  1005 
       
  1006 	// If it's a date archive, use the date as the title.
       
  1007 	} elseif ( is_year() ) {
       
  1008 		$title['title'] = get_the_date( _x( 'Y', 'yearly archives date format' ) );
       
  1009 
       
  1010 	} elseif ( is_month() ) {
       
  1011 		$title['title'] = get_the_date( _x( 'F Y', 'monthly archives date format' ) );
       
  1012 
       
  1013 	} elseif ( is_day() ) {
       
  1014 		$title['title'] = get_the_date();
       
  1015 	}
       
  1016 
       
  1017 	// Add a page number if necessary.
       
  1018 	if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) {
       
  1019 		$title['page'] = sprintf( __( 'Page %s' ), max( $paged, $page ) );
       
  1020 	}
       
  1021 
       
  1022 	// Append the description or site title to give context.
       
  1023 	if ( is_front_page() ) {
       
  1024 		$title['tagline'] = get_bloginfo( 'description', 'display' );
       
  1025 	} else {
       
  1026 		$title['site'] = get_bloginfo( 'name', 'display' );
       
  1027 	}
       
  1028 
       
  1029 	/**
       
  1030 	 * Filters the separator for the document title.
       
  1031 	 *
       
  1032 	 * @since 4.4.0
       
  1033 	 *
       
  1034 	 * @param string $sep Document title separator. Default '-'.
       
  1035 	 */
       
  1036 	$sep = apply_filters( 'document_title_separator', '-' );
       
  1037 
       
  1038 	/**
       
  1039 	 * Filters the parts of the document title.
       
  1040 	 *
       
  1041 	 * @since 4.4.0
       
  1042 	 *
       
  1043 	 * @param array $title {
       
  1044 	 *     The document title parts.
       
  1045 	 *
       
  1046 	 *     @type string $title   Title of the viewed page.
       
  1047 	 *     @type string $page    Optional. Page number if paginated.
       
  1048 	 *     @type string $tagline Optional. Site description when on home page.
       
  1049 	 *     @type string $site    Optional. Site title when not on home page.
       
  1050 	 * }
       
  1051 	 */
       
  1052 	$title = apply_filters( 'document_title_parts', $title );
       
  1053 
       
  1054 	$title = implode( " $sep ", array_filter( $title ) );
       
  1055 	$title = wptexturize( $title );
       
  1056 	$title = convert_chars( $title );
       
  1057 	$title = esc_html( $title );
       
  1058 	$title = capital_P_dangit( $title );
       
  1059 
       
  1060 	return $title;
       
  1061 }
       
  1062 
       
  1063 /**
       
  1064  * Displays title tag with content.
   732  *
  1065  *
   733  * @ignore
  1066  * @ignore
   734  * @since 4.1.0
  1067  * @since 4.1.0
       
  1068  * @since 4.4.0 Improved title output replaced `wp_title()`.
   735  * @access private
  1069  * @access private
   736  *
       
   737  * @see wp_title()
       
   738  */
  1070  */
   739 function _wp_render_title_tag() {
  1071 function _wp_render_title_tag() {
   740 	if ( ! current_theme_supports( 'title-tag' ) ) {
  1072 	if ( ! current_theme_supports( 'title-tag' ) ) {
   741 		return;
  1073 		return;
   742 	}
  1074 	}
   743 
  1075 
   744 	// This can only work internally on wp_head.
  1076 	echo '<title>' . wp_get_document_title() . '</title>' . "\n";
   745 	if ( ! did_action( 'wp_head' ) && ! doing_action( 'wp_head' ) ) {
       
   746 		return;
       
   747 	}
       
   748 
       
   749 	echo '<title>' . wp_title( '|', false, 'right' ) . "</title>\n";
       
   750 }
  1077 }
   751 
  1078 
   752 /**
  1079 /**
   753  * Display or retrieve page title for all areas of blog.
  1080  * Display or retrieve page title for all areas of blog.
   754  *
  1081  *
   756  * so that the blog title will be before the page title. This is not good for
  1083  * so that the blog title will be before the page title. This is not good for
   757  * title display, since the blog title shows up on most tabs and not what is
  1084  * title display, since the blog title shows up on most tabs and not what is
   758  * important, which is the page that the user is looking at.
  1085  * important, which is the page that the user is looking at.
   759  *
  1086  *
   760  * There are also SEO benefits to having the blog title after or to the 'right'
  1087  * There are also SEO benefits to having the blog title after or to the 'right'
   761  * or the page title. However, it is mostly common sense to have the blog title
  1088  * of the page title. However, it is mostly common sense to have the blog title
   762  * to the right with most browsers supporting tabs. You can achieve this by
  1089  * to the right with most browsers supporting tabs. You can achieve this by
   763  * using the seplocation parameter and setting the value to 'right'. This change
  1090  * using the seplocation parameter and setting the value to 'right'. This change
   764  * was introduced around 2.5.0, in case backwards compatibility of themes is
  1091  * was introduced around 2.5.0, in case backward compatibility of themes is
   765  * important.
  1092  * important.
   766  *
  1093  *
   767  * @since 1.0.0
  1094  * @since 1.0.0
   768  *
  1095  *
   769  * @param string $sep Optional, default is '&raquo;'. How to separate the various items within the page title.
  1096  * @global WP_Locale $wp_locale
   770  * @param bool $display Optional, default is true. Whether to display or retrieve title.
  1097  *
       
  1098  * @param string $sep         Optional, default is '&raquo;'. How to separate the various items
       
  1099  *                            within the page title.
       
  1100  * @param bool   $display     Optional, default is true. Whether to display or retrieve title.
   771  * @param string $seplocation Optional. Direction to display title, 'right'.
  1101  * @param string $seplocation Optional. Direction to display title, 'right'.
   772  * @return string|null String on retrieve, null when displaying.
  1102  * @return string|null String on retrieve, null when displaying.
   773  */
  1103  */
   774 function wp_title($sep = '&raquo;', $display = true, $seplocation = '') {
  1104 function wp_title( $sep = '&raquo;', $display = true, $seplocation = '' ) {
   775 	global $wp_locale, $page, $paged;
  1105 	global $wp_locale;
   776 
  1106 
   777 	$m = get_query_var('m');
  1107 	$m        = get_query_var( 'm' );
   778 	$year = get_query_var('year');
  1108 	$year     = get_query_var( 'year' );
   779 	$monthnum = get_query_var('monthnum');
  1109 	$monthnum = get_query_var( 'monthnum' );
   780 	$day = get_query_var('day');
  1110 	$day      = get_query_var( 'day' );
   781 	$search = get_query_var('s');
  1111 	$search   = get_query_var( 's' );
   782 	$title = '';
  1112 	$title    = '';
   783 
  1113 
   784 	$t_sep = '%WP_TITILE_SEP%'; // Temporary separator, for accurate flipping, if necessary
  1114 	$t_sep = '%WP_TITLE_SEP%'; // Temporary separator, for accurate flipping, if necessary
   785 
  1115 
   786 	// If there is a post
  1116 	// If there is a post
   787 	if ( is_single() || ( is_home() && !is_front_page() ) || ( is_page() && !is_front_page() ) ) {
  1117 	if ( is_single() || ( is_home() && ! is_front_page() ) || ( is_page() && ! is_front_page() ) ) {
   788 		$title = single_post_title( '', false );
  1118 		$title = single_post_title( '', false );
   789 	}
  1119 	}
   790 
  1120 
   791 	// If there's a post type archive
  1121 	// If there's a post type archive
   792 	if ( is_post_type_archive() ) {
  1122 	if ( is_post_type_archive() ) {
   793 		$post_type = get_query_var( 'post_type' );
  1123 		$post_type = get_query_var( 'post_type' );
   794 		if ( is_array( $post_type ) )
  1124 		if ( is_array( $post_type ) ) {
   795 			$post_type = reset( $post_type );
  1125 			$post_type = reset( $post_type );
       
  1126 		}
   796 		$post_type_object = get_post_type_object( $post_type );
  1127 		$post_type_object = get_post_type_object( $post_type );
   797 		if ( ! $post_type_object->has_archive )
  1128 		if ( ! $post_type_object->has_archive ) {
   798 			$title = post_type_archive_title( '', false );
  1129 			$title = post_type_archive_title( '', false );
       
  1130 		}
   799 	}
  1131 	}
   800 
  1132 
   801 	// If there's a category or tag
  1133 	// If there's a category or tag
   802 	if ( is_category() || is_tag() ) {
  1134 	if ( is_category() || is_tag() ) {
   803 		$title = single_term_title( '', false );
  1135 		$title = single_term_title( '', false );
   805 
  1137 
   806 	// If there's a taxonomy
  1138 	// If there's a taxonomy
   807 	if ( is_tax() ) {
  1139 	if ( is_tax() ) {
   808 		$term = get_queried_object();
  1140 		$term = get_queried_object();
   809 		if ( $term ) {
  1141 		if ( $term ) {
   810 			$tax = get_taxonomy( $term->taxonomy );
  1142 			$tax   = get_taxonomy( $term->taxonomy );
   811 			$title = single_term_title( $tax->labels->name . $t_sep, false );
  1143 			$title = single_term_title( $tax->labels->name . $t_sep, false );
   812 		}
  1144 		}
   813 	}
  1145 	}
   814 
  1146 
   815 	// If there's an author
  1147 	// If there's an author
   816 	if ( is_author() && ! is_post_type_archive() ) {
  1148 	if ( is_author() && ! is_post_type_archive() ) {
   817 		$author = get_queried_object();
  1149 		$author = get_queried_object();
   818 		if ( $author )
  1150 		if ( $author ) {
   819 			$title = $author->display_name;
  1151 			$title = $author->display_name;
       
  1152 		}
   820 	}
  1153 	}
   821 
  1154 
   822 	// Post type archives with has_archive should override terms.
  1155 	// Post type archives with has_archive should override terms.
   823 	if ( is_post_type_archive() && $post_type_object->has_archive )
  1156 	if ( is_post_type_archive() && $post_type_object->has_archive ) {
   824 		$title = post_type_archive_title( '', false );
  1157 		$title = post_type_archive_title( '', false );
       
  1158 	}
   825 
  1159 
   826 	// If there's a month
  1160 	// If there's a month
   827 	if ( is_archive() && !empty($m) ) {
  1161 	if ( is_archive() && ! empty( $m ) ) {
   828 		$my_year = substr($m, 0, 4);
  1162 		$my_year  = substr( $m, 0, 4 );
   829 		$my_month = $wp_locale->get_month(substr($m, 4, 2));
  1163 		$my_month = $wp_locale->get_month( substr( $m, 4, 2 ) );
   830 		$my_day = intval(substr($m, 6, 2));
  1164 		$my_day   = intval( substr( $m, 6, 2 ) );
   831 		$title = $my_year . ( $my_month ? $t_sep . $my_month : '' ) . ( $my_day ? $t_sep . $my_day : '' );
  1165 		$title    = $my_year . ( $my_month ? $t_sep . $my_month : '' ) . ( $my_day ? $t_sep . $my_day : '' );
   832 	}
  1166 	}
   833 
  1167 
   834 	// If there's a year
  1168 	// If there's a year
   835 	if ( is_archive() && !empty($year) ) {
  1169 	if ( is_archive() && ! empty( $year ) ) {
   836 		$title = $year;
  1170 		$title = $year;
   837 		if ( !empty($monthnum) )
  1171 		if ( ! empty( $monthnum ) ) {
   838 			$title .= $t_sep . $wp_locale->get_month($monthnum);
  1172 			$title .= $t_sep . $wp_locale->get_month( $monthnum );
   839 		if ( !empty($day) )
  1173 		}
   840 			$title .= $t_sep . zeroise($day, 2);
  1174 		if ( ! empty( $day ) ) {
       
  1175 			$title .= $t_sep . zeroise( $day, 2 );
       
  1176 		}
   841 	}
  1177 	}
   842 
  1178 
   843 	// If it's a search
  1179 	// If it's a search
   844 	if ( is_search() ) {
  1180 	if ( is_search() ) {
   845 		/* translators: 1: separator, 2: search phrase */
  1181 		/* translators: 1: separator, 2: search phrase */
   846 		$title = sprintf(__('Search Results %1$s %2$s'), $t_sep, strip_tags($search));
  1182 		$title = sprintf( __( 'Search Results %1$s %2$s' ), $t_sep, strip_tags( $search ) );
   847 	}
  1183 	}
   848 
  1184 
   849 	// If it's a 404 page
  1185 	// If it's a 404 page
   850 	if ( is_404() ) {
  1186 	if ( is_404() ) {
   851 		$title = __('Page not found');
  1187 		$title = __( 'Page not found' );
   852 	}
  1188 	}
   853 
  1189 
   854 	$prefix = '';
  1190 	$prefix = '';
   855 	if ( !empty($title) )
  1191 	if ( ! empty( $title ) ) {
   856 		$prefix = " $sep ";
  1192 		$prefix = " $sep ";
   857 
  1193 	}
   858 	/**
  1194 
   859 	 * Filter the parts of the page title.
  1195 	/**
       
  1196 	 * Filters the parts of the page title.
   860 	 *
  1197 	 *
   861 	 * @since 4.0.0
  1198 	 * @since 4.0.0
   862 	 *
  1199 	 *
   863 	 * @param array $title_array Parts of the page title.
  1200 	 * @param array $title_array Parts of the page title.
   864 	 */
  1201 	 */
   865 	$title_array = apply_filters( 'wp_title_parts', explode( $t_sep, $title ) );
  1202 	$title_array = apply_filters( 'wp_title_parts', explode( $t_sep, $title ) );
   866 
  1203 
   867  	// Determines position of the separator and direction of the breadcrumb
  1204 	// Determines position of the separator and direction of the breadcrumb
   868 	if ( 'right' == $seplocation ) { // sep on right, so reverse the order
  1205 	if ( 'right' == $seplocation ) { // sep on right, so reverse the order
   869 		$title_array = array_reverse( $title_array );
  1206 		$title_array = array_reverse( $title_array );
   870 		$title = implode( " $sep ", $title_array ) . $prefix;
  1207 		$title       = implode( " $sep ", $title_array ) . $prefix;
   871 	} else {
  1208 	} else {
   872 		$title = $prefix . implode( " $sep ", $title_array );
  1209 		$title = $prefix . implode( " $sep ", $title_array );
   873 	}
  1210 	}
   874 
  1211 
   875 	if ( current_theme_supports( 'title-tag' ) && ! is_feed() ) {
  1212 	/**
   876 		$title .= get_bloginfo( 'name', 'display' );
  1213 	 * Filters the text of the page title.
   877 
       
   878 		$site_description = get_bloginfo( 'description', 'display' );
       
   879 		if ( $site_description && ( is_home() || is_front_page() ) ) {
       
   880 			$title .= " $sep $site_description";
       
   881 		}
       
   882 
       
   883 		if ( ( $paged >= 2 || $page >= 2 ) && ! is_404() ) {
       
   884 			$title .= " $sep " . sprintf( __( 'Page %s' ), max( $paged, $page ) );
       
   885 		}
       
   886 	}
       
   887 
       
   888 	/**
       
   889 	 * Filter the text of the page title.
       
   890 	 *
  1214 	 *
   891 	 * @since 2.0.0
  1215 	 * @since 2.0.0
   892 	 *
  1216 	 *
   893 	 * @param string $title       Page title.
  1217 	 * @param string $title Page title.
   894 	 * @param string $sep         Title separator.
  1218 	 * @param string $sep Title separator.
   895 	 * @param string $seplocation Location of the separator (left or right).
  1219 	 * @param string $seplocation Location of the separator (left or right).
   896 	 */
  1220 	 */
   897 	$title = apply_filters( 'wp_title', $title, $sep, $seplocation );
  1221 	$title = apply_filters( 'wp_title', $title, $sep, $seplocation );
   898 
  1222 
   899 	// Send it out
  1223 	// Send it out
   900 	if ( $display )
  1224 	if ( $display ) {
   901 		echo $title;
  1225 		echo $title;
   902 	else
  1226 	} else {
   903 		return $title;
  1227 		return $title;
   904 
  1228 	}
   905 }
  1229 }
   906 
  1230 
   907 /**
  1231 /**
   908  * Display or retrieve page title for post.
  1232  * Display or retrieve page title for post.
   909  *
  1233  *
   914  * does not automatically place a space between the prefix, so if there should
  1238  * does not automatically place a space between the prefix, so if there should
   915  * be a space, the parameter value will need to have it at the end.
  1239  * be a space, the parameter value will need to have it at the end.
   916  *
  1240  *
   917  * @since 0.71
  1241  * @since 0.71
   918  *
  1242  *
   919  * @param string $prefix Optional. What to display before the title.
  1243  * @param string $prefix  Optional. What to display before the title.
   920  * @param bool $display Optional, default is true. Whether to display or retrieve title.
  1244  * @param bool   $display Optional, default is true. Whether to display or retrieve title.
   921  * @return string|null Title when retrieving, null when displaying or failure.
  1245  * @return string|void Title when retrieving.
   922  */
  1246  */
   923 function single_post_title($prefix = '', $display = true) {
  1247 function single_post_title( $prefix = '', $display = true ) {
   924 	$_post = get_queried_object();
  1248 	$_post = get_queried_object();
   925 
  1249 
   926 	if ( !isset($_post->post_title) )
  1250 	if ( !isset($_post->post_title) )
   927 		return;
  1251 		return;
   928 
  1252 
   929 	/**
  1253 	/**
   930 	 * Filter the page title for a single post.
  1254 	 * Filters the page title for a single post.
   931 	 *
  1255 	 *
   932 	 * @since 0.71
  1256 	 * @since 0.71
   933 	 *
  1257 	 *
   934 	 * @param string $_post_title The single post page title.
  1258 	 * @param string $_post_title The single post page title.
   935 	 * @param object $_post       The current queried object as returned by get_queried_object().
  1259 	 * @param object $_post       The current queried object as returned by get_queried_object().
   947  * This is optimized for archive.php and archive-{$post_type}.php template files
  1271  * This is optimized for archive.php and archive-{$post_type}.php template files
   948  * for displaying the title of the post type.
  1272  * for displaying the title of the post type.
   949  *
  1273  *
   950  * @since 3.1.0
  1274  * @since 3.1.0
   951  *
  1275  *
   952  * @param string $prefix Optional. What to display before the title.
  1276  * @param string $prefix  Optional. What to display before the title.
   953  * @param bool $display Optional, default is true. Whether to display or retrieve title.
  1277  * @param bool   $display Optional, default is true. Whether to display or retrieve title.
   954  * @return string|null Title when retrieving, null when displaying or failure.
  1278  * @return string|void Title when retrieving, null when displaying or failure.
   955  */
  1279  */
   956 function post_type_archive_title( $prefix = '', $display = true ) {
  1280 function post_type_archive_title( $prefix = '', $display = true ) {
   957 	if ( ! is_post_type_archive() )
  1281 	if ( ! is_post_type_archive() )
   958 		return;
  1282 		return;
   959 
  1283 
   962 		$post_type = reset( $post_type );
  1286 		$post_type = reset( $post_type );
   963 
  1287 
   964 	$post_type_obj = get_post_type_object( $post_type );
  1288 	$post_type_obj = get_post_type_object( $post_type );
   965 
  1289 
   966 	/**
  1290 	/**
   967 	 * Filter the post type archive title.
  1291 	 * Filters the post type archive title.
   968 	 *
  1292 	 *
   969 	 * @since 3.1.0
  1293 	 * @since 3.1.0
   970 	 *
  1294 	 *
   971 	 * @param string $post_type_name Post type 'name' label.
  1295 	 * @param string $post_type_name Post type 'name' label.
   972 	 * @param string $post_type      Post type.
  1296 	 * @param string $post_type      Post type.
   980 }
  1304 }
   981 
  1305 
   982 /**
  1306 /**
   983  * Display or retrieve page title for category archive.
  1307  * Display or retrieve page title for category archive.
   984  *
  1308  *
   985  * This is useful for category template file or files, because it is optimized
  1309  * Useful for category template files for displaying the category page title.
   986  * for category page title and with less overhead than {@link wp_title()}.
  1310  * The prefix does not automatically place a space between the prefix, so if
   987  *
  1311  * there should be a space, the parameter value will need to have it at the end.
   988  * It does not support placing the separator after the title, but by leaving the
  1312  *
   989  * prefix parameter empty, you can set the title separator manually. The prefix
  1313  * @since 0.71
       
  1314  *
       
  1315  * @param string $prefix  Optional. What to display before the title.
       
  1316  * @param bool   $display Optional, default is true. Whether to display or retrieve title.
       
  1317  * @return string|void Title when retrieving.
       
  1318  */
       
  1319 function single_cat_title( $prefix = '', $display = true ) {
       
  1320 	return single_term_title( $prefix, $display );
       
  1321 }
       
  1322 
       
  1323 /**
       
  1324  * Display or retrieve page title for tag post archive.
       
  1325  *
       
  1326  * Useful for tag template files for displaying the tag page title. The prefix
   990  * does not automatically place a space between the prefix, so if there should
  1327  * does not automatically place a space between the prefix, so if there should
   991  * be a space, the parameter value will need to have it at the end.
  1328  * be a space, the parameter value will need to have it at the end.
   992  *
  1329  *
   993  * @since 0.71
       
   994  *
       
   995  * @param string $prefix Optional. What to display before the title.
       
   996  * @param bool $display Optional, default is true. Whether to display or retrieve title.
       
   997  * @return string|null Title when retrieving, null when displaying or failure.
       
   998  */
       
   999 function single_cat_title( $prefix = '', $display = true ) {
       
  1000 	return single_term_title( $prefix, $display );
       
  1001 }
       
  1002 
       
  1003 /**
       
  1004  * Display or retrieve page title for tag post archive.
       
  1005  *
       
  1006  * Useful for tag template files for displaying the tag page title. It has less
       
  1007  * overhead than {@link wp_title()}, because of its limited implementation.
       
  1008  *
       
  1009  * It does not support placing the separator after the title, but by leaving the
       
  1010  * prefix parameter empty, you can set the title separator manually. The prefix
       
  1011  * does not automatically place a space between the prefix, so if there should
       
  1012  * be a space, the parameter value will need to have it at the end.
       
  1013  *
       
  1014  * @since 2.3.0
  1330  * @since 2.3.0
  1015  *
  1331  *
  1016  * @param string $prefix Optional. What to display before the title.
  1332  * @param string $prefix  Optional. What to display before the title.
  1017  * @param bool $display Optional, default is true. Whether to display or retrieve title.
  1333  * @param bool   $display Optional, default is true. Whether to display or retrieve title.
  1018  * @return string|null Title when retrieving, null when displaying or failure.
  1334  * @return string|void Title when retrieving.
  1019  */
  1335  */
  1020 function single_tag_title( $prefix = '', $display = true ) {
  1336 function single_tag_title( $prefix = '', $display = true ) {
  1021 	return single_term_title( $prefix, $display );
  1337 	return single_term_title( $prefix, $display );
  1022 }
  1338 }
  1023 
  1339 
  1024 /**
  1340 /**
  1025  * Display or retrieve page title for taxonomy term archive.
  1341  * Display or retrieve page title for taxonomy term archive.
  1026  *
  1342  *
  1027  * Useful for taxonomy term template files for displaying the taxonomy term page title.
  1343  * Useful for taxonomy term template files for displaying the taxonomy term page title.
  1028  * It has less overhead than {@link wp_title()}, because of its limited implementation.
  1344  * The prefix does not automatically place a space between the prefix, so if there should
  1029  *
       
  1030  * It does not support placing the separator after the title, but by leaving the
       
  1031  * prefix parameter empty, you can set the title separator manually. The prefix
       
  1032  * does not automatically place a space between the prefix, so if there should
       
  1033  * be a space, the parameter value will need to have it at the end.
  1345  * be a space, the parameter value will need to have it at the end.
  1034  *
  1346  *
  1035  * @since 3.1.0
  1347  * @since 3.1.0
  1036  *
  1348  *
  1037  * @param string $prefix Optional. What to display before the title.
  1349  * @param string $prefix  Optional. What to display before the title.
  1038  * @param bool $display Optional, default is true. Whether to display or retrieve title.
  1350  * @param bool   $display Optional, default is true. Whether to display or retrieve title.
  1039  * @return string|null Title when retrieving, null when displaying or failure.
  1351  * @return string|void Title when retrieving.
  1040  */
  1352  */
  1041 function single_term_title( $prefix = '', $display = true ) {
  1353 function single_term_title( $prefix = '', $display = true ) {
  1042 	$term = get_queried_object();
  1354 	$term = get_queried_object();
  1043 
  1355 
  1044 	if ( !$term )
  1356 	if ( !$term )
  1045 		return;
  1357 		return;
  1046 
  1358 
  1047 	if ( is_category() ) {
  1359 	if ( is_category() ) {
  1048 		/**
  1360 		/**
  1049 		 * Filter the category archive page title.
  1361 		 * Filters the category archive page title.
  1050 		 *
  1362 		 *
  1051 		 * @since 2.0.10
  1363 		 * @since 2.0.10
  1052 		 *
  1364 		 *
  1053 		 * @param string $term_name Category name for archive being displayed.
  1365 		 * @param string $term_name Category name for archive being displayed.
  1054 		 */
  1366 		 */
  1055 		$term_name = apply_filters( 'single_cat_title', $term->name );
  1367 		$term_name = apply_filters( 'single_cat_title', $term->name );
  1056 	} elseif ( is_tag() ) {
  1368 	} elseif ( is_tag() ) {
  1057 		/**
  1369 		/**
  1058 		 * Filter the tag archive page title.
  1370 		 * Filters the tag archive page title.
  1059 		 *
  1371 		 *
  1060 		 * @since 2.3.0
  1372 		 * @since 2.3.0
  1061 		 *
  1373 		 *
  1062 		 * @param string $term_name Tag name for archive being displayed.
  1374 		 * @param string $term_name Tag name for archive being displayed.
  1063 		 */
  1375 		 */
  1064 		$term_name = apply_filters( 'single_tag_title', $term->name );
  1376 		$term_name = apply_filters( 'single_tag_title', $term->name );
  1065 	} elseif ( is_tax() ) {
  1377 	} elseif ( is_tax() ) {
  1066 		/**
  1378 		/**
  1067 		 * Filter the custom taxonomy archive page title.
  1379 		 * Filters the custom taxonomy archive page title.
  1068 		 *
  1380 		 *
  1069 		 * @since 3.1.0
  1381 		 * @since 3.1.0
  1070 		 *
  1382 		 *
  1071 		 * @param string $term_name Term name for archive being displayed.
  1383 		 * @param string $term_name Term name for archive being displayed.
  1072 		 */
  1384 		 */
  1085 }
  1397 }
  1086 
  1398 
  1087 /**
  1399 /**
  1088  * Display or retrieve page title for post archive based on date.
  1400  * Display or retrieve page title for post archive based on date.
  1089  *
  1401  *
  1090  * Useful for when the template only needs to display the month and year, if
  1402  * Useful for when the template only needs to display the month and year,
  1091  * either are available. Optimized for just this purpose, so if it is all that
  1403  * if either are available. The prefix does not automatically place a space
  1092  * is needed, should be better than {@link wp_title()}.
  1404  * between the prefix, so if there should be a space, the parameter value
  1093  *
  1405  * will need to have it at the end.
  1094  * It does not support placing the separator after the title, but by leaving the
       
  1095  * prefix parameter empty, you can set the title separator manually. The prefix
       
  1096  * does not automatically place a space between the prefix, so if there should
       
  1097  * be a space, the parameter value will need to have it at the end.
       
  1098  *
  1406  *
  1099  * @since 0.71
  1407  * @since 0.71
  1100  *
  1408  *
  1101  * @param string $prefix Optional. What to display before the title.
  1409  * @global WP_Locale $wp_locale
  1102  * @param bool $display Optional, default is true. Whether to display or retrieve title.
  1410  *
  1103  * @return string|null Title when retrieving, null when displaying or failure.
  1411  * @param string $prefix  Optional. What to display before the title.
       
  1412  * @param bool   $display Optional, default is true. Whether to display or retrieve title.
       
  1413  * @return string|void Title when retrieving.
  1104  */
  1414  */
  1105 function single_month_title($prefix = '', $display = true ) {
  1415 function single_month_title($prefix = '', $display = true ) {
  1106 	global $wp_locale;
  1416 	global $wp_locale;
  1107 
  1417 
  1108 	$m = get_query_var('m');
  1418 	$m = get_query_var('m');
  1152  *
  1462  *
  1153  * @return string Archive title.
  1463  * @return string Archive title.
  1154  */
  1464  */
  1155 function get_the_archive_title() {
  1465 function get_the_archive_title() {
  1156 	if ( is_category() ) {
  1466 	if ( is_category() ) {
       
  1467 		/* translators: Category archive title. 1: Category name */
  1157 		$title = sprintf( __( 'Category: %s' ), single_cat_title( '', false ) );
  1468 		$title = sprintf( __( 'Category: %s' ), single_cat_title( '', false ) );
  1158 	} elseif ( is_tag() ) {
  1469 	} elseif ( is_tag() ) {
       
  1470 		/* translators: Tag archive title. 1: Tag name */
  1159 		$title = sprintf( __( 'Tag: %s' ), single_tag_title( '', false ) );
  1471 		$title = sprintf( __( 'Tag: %s' ), single_tag_title( '', false ) );
  1160 	} elseif ( is_author() ) {
  1472 	} elseif ( is_author() ) {
       
  1473 		/* translators: Author archive title. 1: Author name */
  1161 		$title = sprintf( __( 'Author: %s' ), '<span class="vcard">' . get_the_author() . '</span>' );
  1474 		$title = sprintf( __( 'Author: %s' ), '<span class="vcard">' . get_the_author() . '</span>' );
  1162 	} elseif ( is_year() ) {
  1475 	} elseif ( is_year() ) {
       
  1476 		/* translators: Yearly archive title. 1: Year */
  1163 		$title = sprintf( __( 'Year: %s' ), get_the_date( _x( 'Y', 'yearly archives date format' ) ) );
  1477 		$title = sprintf( __( 'Year: %s' ), get_the_date( _x( 'Y', 'yearly archives date format' ) ) );
  1164 	} elseif ( is_month() ) {
  1478 	} elseif ( is_month() ) {
       
  1479 		/* translators: Monthly archive title. 1: Month name and year */
  1165 		$title = sprintf( __( 'Month: %s' ), get_the_date( _x( 'F Y', 'monthly archives date format' ) ) );
  1480 		$title = sprintf( __( 'Month: %s' ), get_the_date( _x( 'F Y', 'monthly archives date format' ) ) );
  1166 	} elseif ( is_day() ) {
  1481 	} elseif ( is_day() ) {
       
  1482 		/* translators: Daily archive title. 1: Date */
  1167 		$title = sprintf( __( 'Day: %s' ), get_the_date( _x( 'F j, Y', 'daily archives date format' ) ) );
  1483 		$title = sprintf( __( 'Day: %s' ), get_the_date( _x( 'F j, Y', 'daily archives date format' ) ) );
  1168 	} elseif ( is_tax( 'post_format' ) ) {
  1484 	} elseif ( is_tax( 'post_format' ) ) {
  1169 		if ( is_tax( 'post_format', 'post-format-aside' ) ) {
  1485 		if ( is_tax( 'post_format', 'post-format-aside' ) ) {
  1170 			$title = _x( 'Asides', 'post format archive title' );
  1486 			$title = _x( 'Asides', 'post format archive title' );
  1171 		} elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) {
  1487 		} elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) {
  1184 			$title = _x( 'Audio', 'post format archive title' );
  1500 			$title = _x( 'Audio', 'post format archive title' );
  1185 		} elseif ( is_tax( 'post_format', 'post-format-chat' ) ) {
  1501 		} elseif ( is_tax( 'post_format', 'post-format-chat' ) ) {
  1186 			$title = _x( 'Chats', 'post format archive title' );
  1502 			$title = _x( 'Chats', 'post format archive title' );
  1187 		}
  1503 		}
  1188 	} elseif ( is_post_type_archive() ) {
  1504 	} elseif ( is_post_type_archive() ) {
       
  1505 		/* translators: Post type archive title. 1: Post type name */
  1189 		$title = sprintf( __( 'Archives: %s' ), post_type_archive_title( '', false ) );
  1506 		$title = sprintf( __( 'Archives: %s' ), post_type_archive_title( '', false ) );
  1190 	} elseif ( is_tax() ) {
  1507 	} elseif ( is_tax() ) {
  1191 		$tax = get_taxonomy( get_queried_object()->taxonomy );
  1508 		$tax = get_taxonomy( get_queried_object()->taxonomy );
  1192 		/* translators: 1: Taxonomy singular name, 2: Current taxonomy term */
  1509 		/* translators: Taxonomy term archive title. 1: Taxonomy singular name, 2: Current taxonomy term */
  1193 		$title = sprintf( __( '%1$s: %2$s' ), $tax->labels->singular_name, single_term_title( '', false ) );
  1510 		$title = sprintf( __( '%1$s: %2$s' ), $tax->labels->singular_name, single_term_title( '', false ) );
  1194 	} else {
  1511 	} else {
  1195 		$title = __( 'Archives' );
  1512 		$title = __( 'Archives' );
  1196 	}
  1513 	}
  1197 
  1514 
  1198 	/**
  1515 	/**
  1199 	 * Filter the archive title.
  1516 	 * Filters the archive title.
  1200 	 *
  1517 	 *
  1201 	 * @since 4.1.0
  1518 	 * @since 4.1.0
  1202 	 *
  1519 	 *
  1203 	 * @param string $title Archive title to be displayed.
  1520 	 * @param string $title Archive title to be displayed.
  1204 	 */
  1521 	 */
  1205 	return apply_filters( 'get_the_archive_title', $title );
  1522 	return apply_filters( 'get_the_archive_title', $title );
  1206 }
  1523 }
  1207 
  1524 
  1208 /**
  1525 /**
  1209  * Display category, tag, or term description.
  1526  * Display category, tag, term, or author description.
  1210  *
  1527  *
  1211  * @since 4.1.0
  1528  * @since 4.1.0
  1212  *
  1529  *
  1213  * @see get_the_archive_description()
  1530  * @see get_the_archive_description()
  1214  *
  1531  *
  1221 		echo $before . $description . $after;
  1538 		echo $before . $description . $after;
  1222 	}
  1539 	}
  1223 }
  1540 }
  1224 
  1541 
  1225 /**
  1542 /**
  1226  * Retrieve category, tag, or term description.
  1543  * Retrieves the description for an author, post type, or term archive.
  1227  *
  1544  *
  1228  * @since 4.1.0
  1545  * @since 4.1.0
       
  1546  * @since 4.7.0 Added support for author archives.
       
  1547  * @since 4.9.0 Added support for post type archives.
       
  1548  *
       
  1549  * @see term_description()
  1229  *
  1550  *
  1230  * @return string Archive description.
  1551  * @return string Archive description.
  1231  */
  1552  */
  1232 function get_the_archive_description() {
  1553 function get_the_archive_description() {
  1233 	/**
  1554 	if ( is_author() ) {
  1234 	 * Filter the archive description.
  1555 		$description = get_the_author_meta( 'description' );
       
  1556 	} elseif ( is_post_type_archive() ) {
       
  1557 		$description = get_the_post_type_description();
       
  1558 	} else {
       
  1559 		$description = term_description();
       
  1560 	}
       
  1561 
       
  1562 	/**
       
  1563 	 * Filters the archive description.
  1235 	 *
  1564 	 *
  1236 	 * @since 4.1.0
  1565 	 * @since 4.1.0
  1237 	 *
  1566 	 *
  1238 	 * @see term_description()
       
  1239 	 *
       
  1240 	 * @param string $description Archive description to be displayed.
  1567 	 * @param string $description Archive description to be displayed.
  1241 	 */
  1568 	 */
  1242 	return apply_filters( 'get_the_archive_description', term_description() );
  1569 	return apply_filters( 'get_the_archive_description', $description );
       
  1570 }
       
  1571 
       
  1572 /**
       
  1573  * Retrieves the description for a post type archive.
       
  1574  *
       
  1575  * @since 4.9.0
       
  1576  *
       
  1577  * @return string The post type description.
       
  1578  */
       
  1579 function get_the_post_type_description() {
       
  1580 	$post_type = get_query_var( 'post_type' );
       
  1581 
       
  1582 	if ( is_array( $post_type ) ) {
       
  1583 		$post_type = reset( $post_type );
       
  1584 	}
       
  1585 
       
  1586 	$post_type_obj = get_post_type_object( $post_type );
       
  1587 
       
  1588 	// Check if a description is set.
       
  1589 	if ( isset( $post_type_obj->description ) ) {
       
  1590 		$description = $post_type_obj->description;
       
  1591 	} else {
       
  1592 		$description = '';
       
  1593 	}
       
  1594 
       
  1595 	/**
       
  1596 	 * Filters the description for a post type archive.
       
  1597 	 *
       
  1598 	 * @since 4.9.0
       
  1599 	 *
       
  1600 	 * @param string       $description   The post type description.
       
  1601 	 * @param WP_Post_Type $post_type_obj The post type object.
       
  1602 	 */
       
  1603 	return apply_filters( 'get_the_post_type_description', $description, $post_type_obj );
  1243 }
  1604 }
  1244 
  1605 
  1245 /**
  1606 /**
  1246  * Retrieve archive link content based on predefined or custom code.
  1607  * Retrieve archive link content based on predefined or custom code.
  1247  *
  1608  *
  1266  * element) and the after parameter after the closing link tag. If the above
  1627  * element) and the after parameter after the closing link tag. If the above
  1267  * three values for the format are not used, then custom format is assumed.
  1628  * three values for the format are not used, then custom format is assumed.
  1268  *
  1629  *
  1269  * @since 1.0.0
  1630  * @since 1.0.0
  1270  *
  1631  *
  1271  * @todo Properly document optional arguments as such
  1632  * @param string $url    URL to archive.
  1272  *
  1633  * @param string $text   Archive text description.
  1273  * @param string $url URL to archive.
       
  1274  * @param string $text Archive text description.
       
  1275  * @param string $format Optional, default is 'html'. Can be 'link', 'option', 'html', or custom.
  1634  * @param string $format Optional, default is 'html'. Can be 'link', 'option', 'html', or custom.
  1276  * @param string $before Optional.
  1635  * @param string $before Optional. Content to prepend to the description. Default empty.
  1277  * @param string $after Optional.
  1636  * @param string $after  Optional. Content to append to the description. Default empty.
  1278  * @return string HTML link content for archive.
  1637  * @return string HTML link content for archive.
  1279  */
  1638  */
  1280 function get_archives_link($url, $text, $format = 'html', $before = '', $after = '') {
  1639 function get_archives_link($url, $text, $format = 'html', $before = '', $after = '') {
  1281 	$text = wptexturize($text);
  1640 	$text = wptexturize($text);
  1282 	$url = esc_url($url);
  1641 	$url = esc_url($url);
  1289 		$link_html = "\t<li>$before<a href='$url'>$text</a>$after</li>\n";
  1648 		$link_html = "\t<li>$before<a href='$url'>$text</a>$after</li>\n";
  1290 	else // custom
  1649 	else // custom
  1291 		$link_html = "\t$before<a href='$url'>$text</a>$after\n";
  1650 		$link_html = "\t$before<a href='$url'>$text</a>$after\n";
  1292 
  1651 
  1293 	/**
  1652 	/**
  1294 	 * Filter the archive link content.
  1653 	 * Filters the archive link content.
  1295 	 *
  1654 	 *
  1296 	 * @since 2.6.0
  1655 	 * @since 2.6.0
       
  1656 	 * @since 4.5.0 Added the `$url`, `$text`, `$format`, `$before`, and `$after` parameters.
  1297 	 *
  1657 	 *
  1298 	 * @param string $link_html The archive HTML link content.
  1658 	 * @param string $link_html The archive HTML link content.
  1299 	 */
  1659 	 * @param string $url       URL to archive.
  1300 	$link_html = apply_filters( 'get_archives_link', $link_html );
  1660 	 * @param string $text      Archive text description.
  1301 
  1661 	 * @param string $format    Link format. Can be 'link', 'option', 'html', or custom.
  1302 	return $link_html;
  1662 	 * @param string $before    Content to prepend to the description.
       
  1663 	 * @param string $after     Content to append to the description.
       
  1664 	 */
       
  1665 	return apply_filters( 'get_archives_link', $link_html, $url, $text, $format, $before, $after );
  1303 }
  1666 }
  1304 
  1667 
  1305 /**
  1668 /**
  1306  * Display archive links based on type and format.
  1669  * Display archive links based on type and format.
  1307  *
  1670  *
  1308  * @since 1.2.0
  1671  * @since 1.2.0
       
  1672  * @since 4.4.0 $post_type arg was added.
  1309  *
  1673  *
  1310  * @see get_archives_link()
  1674  * @see get_archives_link()
       
  1675  *
       
  1676  * @global wpdb      $wpdb
       
  1677  * @global WP_Locale $wp_locale
  1311  *
  1678  *
  1312  * @param string|array $args {
  1679  * @param string|array $args {
  1313  *     Default archive links arguments. Optional.
  1680  *     Default archive links arguments. Optional.
  1314  *
  1681  *
  1315  *     @type string     $type            Type of archive to retrieve. Accepts 'daily', 'weekly', 'monthly',
  1682  *     @type string     $type            Type of archive to retrieve. Accepts 'daily', 'weekly', 'monthly',
  1327  *     @type string     $after           Markup to append to the end of each link. Default empty.
  1694  *     @type string     $after           Markup to append to the end of each link. Default empty.
  1328  *     @type bool       $show_post_count Whether to display the post count alongside the link. Default false.
  1695  *     @type bool       $show_post_count Whether to display the post count alongside the link. Default false.
  1329  *     @type bool|int   $echo            Whether to echo or return the links list. Default 1|true to echo.
  1696  *     @type bool|int   $echo            Whether to echo or return the links list. Default 1|true to echo.
  1330  *     @type string     $order           Whether to use ascending or descending order. Accepts 'ASC', or 'DESC'.
  1697  *     @type string     $order           Whether to use ascending or descending order. Accepts 'ASC', or 'DESC'.
  1331  *                                       Default 'DESC'.
  1698  *                                       Default 'DESC'.
       
  1699  *     @type string     $post_type       Post type. Default 'post'.
  1332  * }
  1700  * }
  1333  * @return string|null String when retrieving, null when displaying.
  1701  * @return string|void String when retrieving.
  1334  */
  1702  */
  1335 function wp_get_archives( $args = '' ) {
  1703 function wp_get_archives( $args = '' ) {
  1336 	global $wpdb, $wp_locale;
  1704 	global $wpdb, $wp_locale;
  1337 
  1705 
  1338 	$defaults = array(
  1706 	$defaults = array(
  1339 		'type' => 'monthly', 'limit' => '',
  1707 		'type' => 'monthly', 'limit' => '',
  1340 		'format' => 'html', 'before' => '',
  1708 		'format' => 'html', 'before' => '',
  1341 		'after' => '', 'show_post_count' => false,
  1709 		'after' => '', 'show_post_count' => false,
  1342 		'echo' => 1, 'order' => 'DESC',
  1710 		'echo' => 1, 'order' => 'DESC',
       
  1711 		'post_type' => 'post'
  1343 	);
  1712 	);
  1344 
  1713 
  1345 	$r = wp_parse_args( $args, $defaults );
  1714 	$r = wp_parse_args( $args, $defaults );
       
  1715 
       
  1716 	$post_type_object = get_post_type_object( $r['post_type'] );
       
  1717 	if ( ! is_post_type_viewable( $post_type_object ) ) {
       
  1718 		return;
       
  1719 	}
       
  1720 	$r['post_type'] = $post_type_object->name;
  1346 
  1721 
  1347 	if ( '' == $r['type'] ) {
  1722 	if ( '' == $r['type'] ) {
  1348 		$r['type'] = 'monthly';
  1723 		$r['type'] = 'monthly';
  1349 	}
  1724 	}
  1350 
  1725 
  1359 	}
  1734 	}
  1360 
  1735 
  1361 	// this is what will separate dates on weekly archive links
  1736 	// this is what will separate dates on weekly archive links
  1362 	$archive_week_separator = '&#8211;';
  1737 	$archive_week_separator = '&#8211;';
  1363 
  1738 
  1364 	// over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride
  1739 	$sql_where = $wpdb->prepare( "WHERE post_type = %s AND post_status = 'publish'", $r['post_type'] );
  1365 	$archive_date_format_over_ride = 0;
  1740 
  1366 
  1741 	/**
  1367 	// options for daily archive (only if you over-ride the general date format)
  1742 	 * Filters the SQL WHERE clause for retrieving archives.
  1368 	$archive_day_date_format = 'Y/m/d';
       
  1369 
       
  1370 	// options for weekly archive (only if you over-ride the general date format)
       
  1371 	$archive_week_start_date_format = 'Y/m/d';
       
  1372 	$archive_week_end_date_format	= 'Y/m/d';
       
  1373 
       
  1374 	if ( ! $archive_date_format_over_ride ) {
       
  1375 		$archive_day_date_format = get_option( 'date_format' );
       
  1376 		$archive_week_start_date_format = get_option( 'date_format' );
       
  1377 		$archive_week_end_date_format = get_option( 'date_format' );
       
  1378 	}
       
  1379 
       
  1380 	/**
       
  1381 	 * Filter the SQL WHERE clause for retrieving archives.
       
  1382 	 *
  1743 	 *
  1383 	 * @since 2.2.0
  1744 	 * @since 2.2.0
  1384 	 *
  1745 	 *
  1385 	 * @param string $sql_where Portion of SQL query containing the WHERE clause.
  1746 	 * @param string $sql_where Portion of SQL query containing the WHERE clause.
  1386 	 * @param array  $r         An array of default arguments.
  1747 	 * @param array  $r         An array of default arguments.
  1387 	 */
  1748 	 */
  1388 	$where = apply_filters( 'getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r );
  1749 	$where = apply_filters( 'getarchives_where', $sql_where, $r );
  1389 
  1750 
  1390 	/**
  1751 	/**
  1391 	 * Filter the SQL JOIN clause for retrieving archives.
  1752 	 * Filters the SQL JOIN clause for retrieving archives.
  1392 	 *
  1753 	 *
  1393 	 * @since 2.2.0
  1754 	 * @since 2.2.0
  1394 	 *
  1755 	 *
  1395 	 * @param string $sql_join Portion of SQL query containing JOIN clause.
  1756 	 * @param string $sql_join Portion of SQL query containing JOIN clause.
  1396 	 * @param array  $r        An array of default arguments.
  1757 	 * @param array  $r        An array of default arguments.
  1397 	 */
  1758 	 */
  1398 	$join = apply_filters( 'getarchives_join', '', $r );
  1759 	$join = apply_filters( 'getarchives_join', '', $r );
  1399 
  1760 
  1400 	$output = '';
  1761 	$output = '';
  1401 
  1762 
  1402 	$last_changed = wp_cache_get( 'last_changed', 'posts' );
  1763 	$last_changed = wp_cache_get_last_changed( 'posts' );
  1403 	if ( ! $last_changed ) {
       
  1404 		$last_changed = microtime();
       
  1405 		wp_cache_set( 'last_changed', $last_changed, 'posts' );
       
  1406 	}
       
  1407 
  1764 
  1408 	$limit = $r['limit'];
  1765 	$limit = $r['limit'];
  1409 
  1766 
  1410 	if ( 'monthly' == $r['type'] ) {
  1767 	if ( 'monthly' == $r['type'] ) {
  1411 		$query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date $order $limit";
  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";
  1417 		}
  1774 		}
  1418 		if ( $results ) {
  1775 		if ( $results ) {
  1419 			$after = $r['after'];
  1776 			$after = $r['after'];
  1420 			foreach ( (array) $results as $result ) {
  1777 			foreach ( (array) $results as $result ) {
  1421 				$url = get_month_link( $result->year, $result->month );
  1778 				$url = get_month_link( $result->year, $result->month );
       
  1779 				if ( 'post' !== $r['post_type'] ) {
       
  1780 					$url = add_query_arg( 'post_type', $r['post_type'], $url );
       
  1781 				}
  1422 				/* translators: 1: month name, 2: 4-digit year */
  1782 				/* translators: 1: month name, 2: 4-digit year */
  1423 				$text = sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $result->month ), $result->year );
  1783 				$text = sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $result->month ), $result->year );
  1424 				if ( $r['show_post_count'] ) {
  1784 				if ( $r['show_post_count'] ) {
  1425 					$r['after'] = '&nbsp;(' . $result->posts . ')' . $after;
  1785 					$r['after'] = '&nbsp;(' . $result->posts . ')' . $after;
  1426 				}
  1786 				}
  1437 		}
  1797 		}
  1438 		if ( $results ) {
  1798 		if ( $results ) {
  1439 			$after = $r['after'];
  1799 			$after = $r['after'];
  1440 			foreach ( (array) $results as $result) {
  1800 			foreach ( (array) $results as $result) {
  1441 				$url = get_year_link( $result->year );
  1801 				$url = get_year_link( $result->year );
       
  1802 				if ( 'post' !== $r['post_type'] ) {
       
  1803 					$url = add_query_arg( 'post_type', $r['post_type'], $url );
       
  1804 				}
  1442 				$text = sprintf( '%d', $result->year );
  1805 				$text = sprintf( '%d', $result->year );
  1443 				if ( $r['show_post_count'] ) {
  1806 				if ( $r['show_post_count'] ) {
  1444 					$r['after'] = '&nbsp;(' . $result->posts . ')' . $after;
  1807 					$r['after'] = '&nbsp;(' . $result->posts . ')' . $after;
  1445 				}
  1808 				}
  1446 				$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
  1809 				$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
  1456 		}
  1819 		}
  1457 		if ( $results ) {
  1820 		if ( $results ) {
  1458 			$after = $r['after'];
  1821 			$after = $r['after'];
  1459 			foreach ( (array) $results as $result ) {
  1822 			foreach ( (array) $results as $result ) {
  1460 				$url  = get_day_link( $result->year, $result->month, $result->dayofmonth );
  1823 				$url  = get_day_link( $result->year, $result->month, $result->dayofmonth );
       
  1824 				if ( 'post' !== $r['post_type'] ) {
       
  1825 					$url = add_query_arg( 'post_type', $r['post_type'], $url );
       
  1826 				}
  1461 				$date = sprintf( '%1$d-%2$02d-%3$02d 00:00:00', $result->year, $result->month, $result->dayofmonth );
  1827 				$date = sprintf( '%1$d-%2$02d-%3$02d 00:00:00', $result->year, $result->month, $result->dayofmonth );
  1462 				$text = mysql2date( $archive_day_date_format, $date );
  1828 				$text = mysql2date( get_option( 'date_format' ), $date );
  1463 				if ( $r['show_post_count'] ) {
  1829 				if ( $r['show_post_count'] ) {
  1464 					$r['after'] = '&nbsp;(' . $result->posts . ')' . $after;
  1830 					$r['after'] = '&nbsp;(' . $result->posts . ')' . $after;
  1465 				}
  1831 				}
  1466 				$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
  1832 				$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
  1467 			}
  1833 			}
  1481 			foreach ( (array) $results as $result ) {
  1847 			foreach ( (array) $results as $result ) {
  1482 				if ( $result->week != $arc_w_last ) {
  1848 				if ( $result->week != $arc_w_last ) {
  1483 					$arc_year       = $result->yr;
  1849 					$arc_year       = $result->yr;
  1484 					$arc_w_last     = $result->week;
  1850 					$arc_w_last     = $result->week;
  1485 					$arc_week       = get_weekstartend( $result->yyyymmdd, get_option( 'start_of_week' ) );
  1851 					$arc_week       = get_weekstartend( $result->yyyymmdd, get_option( 'start_of_week' ) );
  1486 					$arc_week_start = date_i18n( $archive_week_start_date_format, $arc_week['start'] );
  1852 					$arc_week_start = date_i18n( get_option( 'date_format' ), $arc_week['start'] );
  1487 					$arc_week_end   = date_i18n( $archive_week_end_date_format, $arc_week['end'] );
  1853 					$arc_week_end   = date_i18n( get_option( 'date_format' ), $arc_week['end'] );
  1488 					$url            = sprintf( '%1$s/%2$s%3$sm%4$s%5$s%6$sw%7$s%8$d', home_url(), '', '?', '=', $arc_year, '&amp;', '=', $result->week );
  1854 					$url            = add_query_arg( array( 'm' => $arc_year, 'w' => $result->week, ), home_url( '/' ) );
       
  1855 					if ( 'post' !== $r['post_type'] ) {
       
  1856 						$url = add_query_arg( 'post_type', $r['post_type'], $url );
       
  1857 					}
  1489 					$text           = $arc_week_start . $archive_week_separator . $arc_week_end;
  1858 					$text           = $arc_week_start . $archive_week_separator . $arc_week_end;
  1490 					if ( $r['show_post_count'] ) {
  1859 					if ( $r['show_post_count'] ) {
  1491 						$r['after'] = '&nbsp;(' . $result->posts . ')' . $after;
  1860 						$r['after'] = '&nbsp;(' . $result->posts . ')' . $after;
  1492 					}
  1861 					}
  1493 					$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
  1862 					$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
  1529  * Get number of days since the start of the week.
  1898  * Get number of days since the start of the week.
  1530  *
  1899  *
  1531  * @since 1.5.0
  1900  * @since 1.5.0
  1532  *
  1901  *
  1533  * @param int $num Number of day.
  1902  * @param int $num Number of day.
  1534  * @return int Days since the start of the week.
  1903  * @return float Days since the start of the week.
  1535  */
  1904  */
  1536 function calendar_week_mod($num) {
  1905 function calendar_week_mod($num) {
  1537 	$base = 7;
  1906 	$base = 7;
  1538 	return ($num - $base*floor($num/$base));
  1907 	return ($num - $base*floor($num/$base));
  1539 }
  1908 }
  1544  * The calendar is cached, which will be retrieved, if it exists. If there are
  1913  * The calendar is cached, which will be retrieved, if it exists. If there are
  1545  * no posts for the month, then it will not be displayed.
  1914  * no posts for the month, then it will not be displayed.
  1546  *
  1915  *
  1547  * @since 1.0.0
  1916  * @since 1.0.0
  1548  *
  1917  *
       
  1918  * @global wpdb      $wpdb
       
  1919  * @global int       $m
       
  1920  * @global int       $monthnum
       
  1921  * @global int       $year
       
  1922  * @global WP_Locale $wp_locale
       
  1923  * @global array     $posts
       
  1924  *
  1549  * @param bool $initial Optional, default is true. Use initial calendar names.
  1925  * @param bool $initial Optional, default is true. Use initial calendar names.
  1550  * @param bool $echo Optional, default is true. Set to false for return.
  1926  * @param bool $echo    Optional, default is true. Set to false for return.
  1551  * @return string|null String when retrieving, null when displaying.
  1927  * @return string|void String when retrieving.
  1552  */
  1928  */
  1553 function get_calendar($initial = true, $echo = true) {
  1929 function get_calendar( $initial = true, $echo = true ) {
  1554 	global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
  1930 	global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
  1555 
  1931 
  1556 	$key = md5( $m . $monthnum . $year );
  1932 	$key = md5( $m . $monthnum . $year );
  1557 	if ( $cache = wp_cache_get( 'get_calendar', 'calendar' ) ) {
  1933 	$cache = wp_cache_get( 'get_calendar', 'calendar' );
  1558 		if ( is_array($cache) && isset( $cache[ $key ] ) ) {
  1934 
  1559 			if ( $echo ) {
  1935 	if ( $cache && is_array( $cache ) && isset( $cache[ $key ] ) ) {
  1560 				/** This filter is documented in wp-includes/general-template.php */
  1936 		/** This filter is documented in wp-includes/general-template.php */
  1561 				echo apply_filters( 'get_calendar', $cache[$key] );
  1937 		$output = apply_filters( 'get_calendar', $cache[ $key ] );
  1562 				return;
  1938 
  1563 			} else {
  1939 		if ( $echo ) {
  1564 				/** This filter is documented in wp-includes/general-template.php */
  1940 			echo $output;
  1565 				return apply_filters( 'get_calendar', $cache[$key] );
  1941 			return;
  1566 			}
  1942 		}
  1567 		}
  1943 
  1568 	}
  1944 		return $output;
  1569 
  1945 	}
  1570 	if ( !is_array($cache) )
  1946 
       
  1947 	if ( ! is_array( $cache ) ) {
  1571 		$cache = array();
  1948 		$cache = array();
       
  1949 	}
  1572 
  1950 
  1573 	// Quick check. If we have no posts at all, abort!
  1951 	// Quick check. If we have no posts at all, abort!
  1574 	if ( !$posts ) {
  1952 	if ( ! $posts ) {
  1575 		$gotsome = $wpdb->get_var("SELECT 1 as test FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1");
  1953 		$gotsome = $wpdb->get_var("SELECT 1 as test FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1");
  1576 		if ( !$gotsome ) {
  1954 		if ( ! $gotsome ) {
  1577 			$cache[ $key ] = '';
  1955 			$cache[ $key ] = '';
  1578 			wp_cache_set( 'get_calendar', $cache, 'calendar' );
  1956 			wp_cache_set( 'get_calendar', $cache, 'calendar' );
  1579 			return;
  1957 			return;
  1580 		}
  1958 		}
  1581 	}
  1959 	}
  1582 
  1960 
  1583 	if ( isset($_GET['w']) )
  1961 	if ( isset( $_GET['w'] ) ) {
  1584 		$w = ''.intval($_GET['w']);
  1962 		$w = (int) $_GET['w'];
  1585 
  1963 	}
  1586 	// week_begins = 0 stands for Sunday
  1964 	// week_begins = 0 stands for Sunday
  1587 	$week_begins = intval(get_option('start_of_week'));
  1965 	$week_begins = (int) get_option( 'start_of_week' );
       
  1966 	$ts = current_time( 'timestamp' );
  1588 
  1967 
  1589 	// Let's figure out when we are
  1968 	// Let's figure out when we are
  1590 	if ( !empty($monthnum) && !empty($year) ) {
  1969 	if ( ! empty( $monthnum ) && ! empty( $year ) ) {
  1591 		$thismonth = ''.zeroise(intval($monthnum), 2);
  1970 		$thismonth = zeroise( intval( $monthnum ), 2 );
  1592 		$thisyear = ''.intval($year);
  1971 		$thisyear = (int) $year;
  1593 	} elseif ( !empty($w) ) {
  1972 	} elseif ( ! empty( $w ) ) {
  1594 		// We need to get the month from MySQL
  1973 		// We need to get the month from MySQL
  1595 		$thisyear = ''.intval(substr($m, 0, 4));
  1974 		$thisyear = (int) substr( $m, 0, 4 );
  1596 		$d = (($w - 1) * 7) + 6; //it seems MySQL's weeks disagree with PHP's
  1975 		//it seems MySQL's weeks disagree with PHP's
       
  1976 		$d = ( ( $w - 1 ) * 7 ) + 6;
  1597 		$thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')");
  1977 		$thismonth = $wpdb->get_var("SELECT DATE_FORMAT((DATE_ADD('{$thisyear}0101', INTERVAL $d DAY) ), '%m')");
  1598 	} elseif ( !empty($m) ) {
  1978 	} elseif ( ! empty( $m ) ) {
  1599 		$thisyear = ''.intval(substr($m, 0, 4));
  1979 		$thisyear = (int) substr( $m, 0, 4 );
  1600 		if ( strlen($m) < 6 )
  1980 		if ( strlen( $m ) < 6 ) {
  1601 				$thismonth = '01';
  1981 			$thismonth = '01';
  1602 		else
  1982 		} else {
  1603 				$thismonth = ''.zeroise(intval(substr($m, 4, 2)), 2);
  1983 			$thismonth = zeroise( (int) substr( $m, 4, 2 ), 2 );
       
  1984 		}
  1604 	} else {
  1985 	} else {
  1605 		$thisyear = gmdate('Y', current_time('timestamp'));
  1986 		$thisyear = gmdate( 'Y', $ts );
  1606 		$thismonth = gmdate('m', current_time('timestamp'));
  1987 		$thismonth = gmdate( 'm', $ts );
  1607 	}
  1988 	}
  1608 
  1989 
  1609 	$unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear);
  1990 	$unixmonth = mktime( 0, 0 , 0, $thismonth, 1, $thisyear );
  1610 	$last_day = date('t', $unixmonth);
  1991 	$last_day = date( 't', $unixmonth );
  1611 
  1992 
  1612 	// Get the next and previous month and year with at least one post
  1993 	// Get the next and previous month and year with at least one post
  1613 	$previous = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
  1994 	$previous = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
  1614 		FROM $wpdb->posts
  1995 		FROM $wpdb->posts
  1615 		WHERE post_date < '$thisyear-$thismonth-01'
  1996 		WHERE post_date < '$thisyear-$thismonth-01'
  1624 			LIMIT 1");
  2005 			LIMIT 1");
  1625 
  2006 
  1626 	/* translators: Calendar caption: 1: month name, 2: 4-digit year */
  2007 	/* translators: Calendar caption: 1: month name, 2: 4-digit year */
  1627 	$calendar_caption = _x('%1$s %2$s', 'calendar caption');
  2008 	$calendar_caption = _x('%1$s %2$s', 'calendar caption');
  1628 	$calendar_output = '<table id="wp-calendar">
  2009 	$calendar_output = '<table id="wp-calendar">
  1629 	<caption>' . sprintf($calendar_caption, $wp_locale->get_month($thismonth), date('Y', $unixmonth)) . '</caption>
  2010 	<caption>' . sprintf(
       
  2011 		$calendar_caption,
       
  2012 		$wp_locale->get_month( $thismonth ),
       
  2013 		date( 'Y', $unixmonth )
       
  2014 	) . '</caption>
  1630 	<thead>
  2015 	<thead>
  1631 	<tr>';
  2016 	<tr>';
  1632 
  2017 
  1633 	$myweek = array();
  2018 	$myweek = array();
  1634 
  2019 
  1635 	for ( $wdcount=0; $wdcount<=6; $wdcount++ ) {
  2020 	for ( $wdcount = 0; $wdcount <= 6; $wdcount++ ) {
  1636 		$myweek[] = $wp_locale->get_weekday(($wdcount+$week_begins)%7);
  2021 		$myweek[] = $wp_locale->get_weekday( ( $wdcount + $week_begins ) % 7 );
  1637 	}
  2022 	}
  1638 
  2023 
  1639 	foreach ( $myweek as $wd ) {
  2024 	foreach ( $myweek as $wd ) {
  1640 		$day_name = (true == $initial) ? $wp_locale->get_weekday_initial($wd) : $wp_locale->get_weekday_abbrev($wd);
  2025 		$day_name = $initial ? $wp_locale->get_weekday_initial( $wd ) : $wp_locale->get_weekday_abbrev( $wd );
  1641 		$wd = esc_attr($wd);
  2026 		$wd = esc_attr( $wd );
  1642 		$calendar_output .= "\n\t\t<th scope=\"col\" title=\"$wd\">$day_name</th>";
  2027 		$calendar_output .= "\n\t\t<th scope=\"col\" title=\"$wd\">$day_name</th>";
  1643 	}
  2028 	}
  1644 
  2029 
  1645 	$calendar_output .= '
  2030 	$calendar_output .= '
  1646 	</tr>
  2031 	</tr>
  1648 
  2033 
  1649 	<tfoot>
  2034 	<tfoot>
  1650 	<tr>';
  2035 	<tr>';
  1651 
  2036 
  1652 	if ( $previous ) {
  2037 	if ( $previous ) {
  1653 		$calendar_output .= "\n\t\t".'<td colspan="3" id="prev"><a href="' . get_month_link($previous->year, $previous->month) . '">&laquo; ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . '</a></td>';
  2038 		$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 ) ) .
       
  2040 		'</a></td>';
  1654 	} else {
  2041 	} else {
  1655 		$calendar_output .= "\n\t\t".'<td colspan="3" id="prev" class="pad">&nbsp;</td>';
  2042 		$calendar_output .= "\n\t\t".'<td colspan="3" id="prev" class="pad">&nbsp;</td>';
  1656 	}
  2043 	}
  1657 
  2044 
  1658 	$calendar_output .= "\n\t\t".'<td class="pad">&nbsp;</td>';
  2045 	$calendar_output .= "\n\t\t".'<td class="pad">&nbsp;</td>';
  1659 
  2046 
  1660 	if ( $next ) {
  2047 	if ( $next ) {
  1661 		$calendar_output .= "\n\t\t".'<td colspan="3" id="next"><a href="' . get_month_link($next->year, $next->month) . '">' . $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)) . ' &raquo;</a></td>';
  2048 		$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 ) ) .
       
  2050 		' &raquo;</a></td>';
  1662 	} else {
  2051 	} else {
  1663 		$calendar_output .= "\n\t\t".'<td colspan="3" id="next" class="pad">&nbsp;</td>';
  2052 		$calendar_output .= "\n\t\t".'<td colspan="3" id="next" class="pad">&nbsp;</td>';
  1664 	}
  2053 	}
  1665 
  2054 
  1666 	$calendar_output .= '
  2055 	$calendar_output .= '
  1681 		foreach ( (array) $dayswithposts as $daywith ) {
  2070 		foreach ( (array) $dayswithposts as $daywith ) {
  1682 			$daywithpost[] = $daywith[0];
  2071 			$daywithpost[] = $daywith[0];
  1683 		}
  2072 		}
  1684 	}
  2073 	}
  1685 
  2074 
  1686 	if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'camino') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false)
       
  1687 		$ak_title_separator = "\n";
       
  1688 	else
       
  1689 		$ak_title_separator = ', ';
       
  1690 
       
  1691 	$ak_titles_for_day = array();
       
  1692 	$ak_post_titles = $wpdb->get_results("SELECT ID, post_title, DAYOFMONTH(post_date) as dom "
       
  1693 		."FROM $wpdb->posts "
       
  1694 		."WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' "
       
  1695 		."AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59' "
       
  1696 		."AND post_type = 'post' AND post_status = 'publish'"
       
  1697 	);
       
  1698 	if ( $ak_post_titles ) {
       
  1699 		foreach ( (array) $ak_post_titles as $ak_post_title ) {
       
  1700 
       
  1701 				/** This filter is documented in wp-includes/post-template.php */
       
  1702 				$post_title = esc_attr( apply_filters( 'the_title', $ak_post_title->post_title, $ak_post_title->ID ) );
       
  1703 
       
  1704 				if ( empty($ak_titles_for_day['day_'.$ak_post_title->dom]) )
       
  1705 					$ak_titles_for_day['day_'.$ak_post_title->dom] = '';
       
  1706 				if ( empty($ak_titles_for_day["$ak_post_title->dom"]) ) // first one
       
  1707 					$ak_titles_for_day["$ak_post_title->dom"] = $post_title;
       
  1708 				else
       
  1709 					$ak_titles_for_day["$ak_post_title->dom"] .= $ak_title_separator . $post_title;
       
  1710 		}
       
  1711 	}
       
  1712 
       
  1713 	// See how much we should pad in the beginning
  2075 	// See how much we should pad in the beginning
  1714 	$pad = calendar_week_mod(date('w', $unixmonth)-$week_begins);
  2076 	$pad = calendar_week_mod( date( 'w', $unixmonth ) - $week_begins );
  1715 	if ( 0 != $pad )
  2077 	if ( 0 != $pad ) {
  1716 		$calendar_output .= "\n\t\t".'<td colspan="'. esc_attr($pad) .'" class="pad">&nbsp;</td>';
  2078 		$calendar_output .= "\n\t\t".'<td colspan="'. esc_attr( $pad ) .'" class="pad">&nbsp;</td>';
  1717 
  2079 	}
  1718 	$daysinmonth = intval(date('t', $unixmonth));
  2080 
       
  2081 	$newrow = false;
       
  2082 	$daysinmonth = (int) date( 't', $unixmonth );
       
  2083 
  1719 	for ( $day = 1; $day <= $daysinmonth; ++$day ) {
  2084 	for ( $day = 1; $day <= $daysinmonth; ++$day ) {
  1720 		if ( isset($newrow) && $newrow )
  2085 		if ( isset($newrow) && $newrow ) {
  1721 			$calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
  2086 			$calendar_output .= "\n\t</tr>\n\t<tr>\n\t\t";
       
  2087 		}
  1722 		$newrow = false;
  2088 		$newrow = false;
  1723 
  2089 
  1724 		if ( $day == gmdate('j', current_time('timestamp')) && $thismonth == gmdate('m', current_time('timestamp')) && $thisyear == gmdate('Y', current_time('timestamp')) )
  2090 		if ( $day == gmdate( 'j', $ts ) &&
       
  2091 			$thismonth == gmdate( 'm', $ts ) &&
       
  2092 			$thisyear == gmdate( 'Y', $ts ) ) {
  1725 			$calendar_output .= '<td id="today">';
  2093 			$calendar_output .= '<td id="today">';
  1726 		else
  2094 		} else {
  1727 			$calendar_output .= '<td>';
  2095 			$calendar_output .= '<td>';
  1728 
  2096 		}
  1729 		if ( in_array($day, $daywithpost) ) // any posts today?
  2097 
  1730 				$calendar_output .= '<a href="' . get_day_link( $thisyear, $thismonth, $day ) . '" title="' . esc_attr( $ak_titles_for_day[ $day ] ) . "\">$day</a>";
  2098 		if ( in_array( $day, $daywithpost ) ) {
  1731 		else
  2099 			// any posts today?
       
  2100 			$date_format = date( _x( 'F j, Y', 'daily archives date format' ), strtotime( "{$thisyear}-{$thismonth}-{$day}" ) );
       
  2101 			/* translators: Post calendar label. 1: Date */
       
  2102 			$label = sprintf( __( 'Posts published on %s' ), $date_format );
       
  2103 			$calendar_output .= sprintf(
       
  2104 				'<a href="%s" aria-label="%s">%s</a>',
       
  2105 				get_day_link( $thisyear, $thismonth, $day ),
       
  2106 				esc_attr( $label ),
       
  2107 				$day
       
  2108 			);
       
  2109 		} else {
  1732 			$calendar_output .= $day;
  2110 			$calendar_output .= $day;
       
  2111 		}
  1733 		$calendar_output .= '</td>';
  2112 		$calendar_output .= '</td>';
  1734 
  2113 
  1735 		if ( 6 == calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins) )
  2114 		if ( 6 == calendar_week_mod( date( 'w', mktime(0, 0 , 0, $thismonth, $day, $thisyear ) ) - $week_begins ) ) {
  1736 			$newrow = true;
  2115 			$newrow = true;
  1737 	}
  2116 		}
  1738 
  2117 	}
  1739 	$pad = 7 - calendar_week_mod(date('w', mktime(0, 0 , 0, $thismonth, $day, $thisyear))-$week_begins);
  2118 
  1740 	if ( $pad != 0 && $pad != 7 )
  2119 	$pad = 7 - calendar_week_mod( date( 'w', mktime( 0, 0 , 0, $thismonth, $day, $thisyear ) ) - $week_begins );
  1741 		$calendar_output .= "\n\t\t".'<td class="pad" colspan="'. esc_attr($pad) .'">&nbsp;</td>';
  2120 	if ( $pad != 0 && $pad != 7 ) {
  1742 
  2121 		$calendar_output .= "\n\t\t".'<td class="pad" colspan="'. esc_attr( $pad ) .'">&nbsp;</td>';
       
  2122 	}
  1743 	$calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>";
  2123 	$calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>";
  1744 
  2124 
  1745 	$cache[ $key ] = $calendar_output;
  2125 	$cache[ $key ] = $calendar_output;
  1746 	wp_cache_set( 'get_calendar', $cache, 'calendar' );
  2126 	wp_cache_set( 'get_calendar', $cache, 'calendar' );
  1747 
  2127 
  1748 	if ( $echo ) {
  2128 	if ( $echo ) {
  1749 		/**
  2129 		/**
  1750 		 * Filter the HTML calendar output.
  2130 		 * Filters the HTML calendar output.
  1751 		 *
  2131 		 *
  1752 		 * @since 3.0.0
  2132 		 * @since 3.0.0
  1753 		 *
  2133 		 *
  1754 		 * @param string $calendar_output HTML output of the calendar.
  2134 		 * @param string $calendar_output HTML output of the calendar.
  1755 		 */
  2135 		 */
  1756 		echo apply_filters( 'get_calendar', $calendar_output );
  2136 		echo apply_filters( 'get_calendar', $calendar_output );
  1757 	} else {
  2137 		return;
  1758 		/** This filter is documented in wp-includes/general-template.php */
  2138 	}
  1759 		return apply_filters( 'get_calendar', $calendar_output );
  2139 	/** This filter is documented in wp-includes/general-template.php */
  1760 	}
  2140 	return apply_filters( 'get_calendar', $calendar_output );
  1761 
       
  1762 }
  2141 }
  1763 
  2142 
  1764 /**
  2143 /**
  1765  * Purge the cached results of get_calendar.
  2144  * Purge the cached results of get_calendar.
  1766  *
  2145  *
  1776  *
  2155  *
  1777  * This is useful for displaying in the comment area, which elements and
  2156  * This is useful for displaying in the comment area, which elements and
  1778  * attributes are supported. As well as any plugins which want to display it.
  2157  * attributes are supported. As well as any plugins which want to display it.
  1779  *
  2158  *
  1780  * @since 1.0.1
  2159  * @since 1.0.1
  1781  * @uses $allowedtags
  2160  *
       
  2161  * @global array $allowedtags
  1782  *
  2162  *
  1783  * @return string HTML allowed tags entity encoded.
  2163  * @return string HTML allowed tags entity encoded.
  1784  */
  2164  */
  1785 function allowed_tags() {
  2165 function allowed_tags() {
  1786 	global $allowedtags;
  2166 	global $allowedtags;
  1792 				$allowed .= ' '.$attribute.'=""';
  2172 				$allowed .= ' '.$attribute.'=""';
  1793 			}
  2173 			}
  1794 		}
  2174 		}
  1795 		$allowed .= '> ';
  2175 		$allowed .= '> ';
  1796 	}
  2176 	}
  1797 	return htmlentities($allowed);
  2177 	return htmlentities( $allowed );
  1798 }
  2178 }
  1799 
  2179 
  1800 /***** Date/Time tags *****/
  2180 /***** Date/Time tags *****/
  1801 
  2181 
  1802 /**
  2182 /**
  1820  * HTML output can be filtered with 'the_date'.
  2200  * HTML output can be filtered with 'the_date'.
  1821  * Date string output can be filtered with 'get_the_date'.
  2201  * Date string output can be filtered with 'get_the_date'.
  1822  *
  2202  *
  1823  * @since 0.71
  2203  * @since 0.71
  1824  *
  2204  *
  1825  * @param string $d Optional. PHP date format defaults to the date_format option if not specified.
  2205  * @global string|int|bool $currentday
       
  2206  * @global string|int|bool $previousday
       
  2207  *
       
  2208  * @param string $d      Optional. PHP date format defaults to the date_format option if not specified.
  1826  * @param string $before Optional. Output before the date.
  2209  * @param string $before Optional. Output before the date.
  1827  * @param string $after Optional. Output after the date.
  2210  * @param string $after  Optional. Output after the date.
  1828  * @param bool $echo Optional, default is display. Whether to echo the date or return it.
  2211  * @param bool   $echo   Optional, default is display. Whether to echo the date or return it.
  1829  * @return string|null Null if displaying, string if retrieving.
  2212  * @return string|void String if retrieving.
  1830  */
  2213  */
  1831 function the_date( $d = '', $before = '', $after = '', $echo = true ) {
  2214 function the_date( $d = '', $before = '', $after = '', $echo = true ) {
  1832 	global $currentday, $previousday;
  2215 	global $currentday, $previousday;
  1833 
  2216 
  1834 	if ( $currentday != $previousday ) {
  2217 	if ( is_new_day() ) {
  1835 		$the_date = $before . get_the_date( $d ) . $after;
  2218 		$the_date = $before . get_the_date( $d ) . $after;
  1836 		$previousday = $currentday;
  2219 		$previousday = $currentday;
  1837 
  2220 
  1838 		/**
  2221 		/**
  1839 		 * Filter the date a post was published for display.
  2222 		 * Filters the date a post was published for display.
  1840 		 *
  2223 		 *
  1841 		 * @since 0.71
  2224 		 * @since 0.71
  1842 		 *
  2225 		 *
  1843 		 * @param string $the_date The formatted date string.
  2226 		 * @param string $the_date The formatted date string.
  1844 		 * @param string $d        PHP date format. Defaults to 'date_format' option
  2227 		 * @param string $d        PHP date format. Defaults to 'date_format' option
  1851 		if ( $echo )
  2234 		if ( $echo )
  1852 			echo $the_date;
  2235 			echo $the_date;
  1853 		else
  2236 		else
  1854 			return $the_date;
  2237 			return $the_date;
  1855 	}
  2238 	}
  1856 
       
  1857 	return null;
       
  1858 }
  2239 }
  1859 
  2240 
  1860 /**
  2241 /**
  1861  * Retrieve the date on which the post was written.
  2242  * Retrieve the date on which the post was written.
  1862  *
  2243  *
  1863  * Unlike the_date() this function will always return the date.
  2244  * Unlike the_date() this function will always return the date.
  1864  * Modify output with 'get_the_date' filter.
  2245  * Modify output with the {@see 'get_the_date'} filter.
  1865  *
  2246  *
  1866  * @since 3.0.0
  2247  * @since 3.0.0
  1867  *
  2248  *
  1868  * @param  string      $d    Optional. PHP date format defaults to the date_format option if not specified.
  2249  * @param  string      $d    Optional. PHP date format defaults to the date_format option if not specified.
  1869  * @param  int|WP_Post $post Optional. Post ID or WP_Post object. Default current post.
  2250  * @param  int|WP_Post $post Optional. Post ID or WP_Post object. Default current post.
  1881 	} else {
  2262 	} else {
  1882 		$the_date = mysql2date( $d, $post->post_date );
  2263 		$the_date = mysql2date( $d, $post->post_date );
  1883 	}
  2264 	}
  1884 
  2265 
  1885 	/**
  2266 	/**
  1886 	 * Filter the date a post was published.
  2267 	 * Filters the date a post was published.
  1887 	 *
  2268 	 *
  1888 	 * @since 3.0.0
  2269 	 * @since 3.0.0
  1889 	 *
  2270 	 *
  1890 	 * @param string      $the_date The formatted date.
  2271 	 * @param string      $the_date The formatted date.
  1891 	 * @param string      $d        PHP date format. Defaults to 'date_format' option
  2272 	 * @param string      $d        PHP date format. Defaults to 'date_format' option
  1898 /**
  2279 /**
  1899  * Display the date on which the post was last modified.
  2280  * Display the date on which the post was last modified.
  1900  *
  2281  *
  1901  * @since 2.1.0
  2282  * @since 2.1.0
  1902  *
  2283  *
  1903  * @param string $d Optional. PHP date format defaults to the date_format option if not specified.
  2284  * @param string $d      Optional. PHP date format defaults to the date_format option if not specified.
  1904  * @param string $before Optional. Output before the date.
  2285  * @param string $before Optional. Output before the date.
  1905  * @param string $after Optional. Output after the date.
  2286  * @param string $after  Optional. Output after the date.
  1906  * @param bool $echo Optional, default is display. Whether to echo the date or return it.
  2287  * @param bool   $echo   Optional, default is display. Whether to echo the date or return it.
  1907  * @return string|null Null if displaying, string if retrieving.
  2288  * @return string|void String if retrieving.
  1908  */
  2289  */
  1909 function the_modified_date($d = '', $before='', $after='', $echo = true) {
  2290 function the_modified_date( $d = '', $before = '', $after = '', $echo = true ) {
  1910 
       
  1911 	$the_modified_date = $before . get_the_modified_date($d) . $after;
  2291 	$the_modified_date = $before . get_the_modified_date($d) . $after;
  1912 
  2292 
  1913 	/**
  2293 	/**
  1914 	 * Filter the date a post was last modified for display.
  2294 	 * Filters the date a post was last modified for display.
  1915 	 *
  2295 	 *
  1916 	 * @since 2.1.0
  2296 	 * @since 2.1.0
  1917 	 *
  2297 	 *
  1918 	 * @param string $the_modified_date The last modified date.
  2298 	 * @param string $the_modified_date The last modified date.
  1919 	 * @param string $d                 PHP date format. Defaults to 'date_format' option
  2299 	 * @param string $d                 PHP date format. Defaults to 'date_format' option
  1932 
  2312 
  1933 /**
  2313 /**
  1934  * Retrieve the date on which the post was last modified.
  2314  * Retrieve the date on which the post was last modified.
  1935  *
  2315  *
  1936  * @since 2.1.0
  2316  * @since 2.1.0
  1937  *
  2317  * @since 4.6.0 Added the `$post` parameter.
  1938  * @param string $d Optional. PHP date format. Defaults to the "date_format" option
  2318  *
  1939  * @return string
  2319  * @param string      $d    Optional. PHP date format defaults to the date_format option if not specified.
  1940  */
  2320  * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default current post.
  1941 function get_the_modified_date($d = '') {
  2321  * @return false|string Date the current post was modified. False on failure.
  1942 	if ( '' == $d )
  2322  */
  1943 		$the_time = get_post_modified_time(get_option('date_format'), null, null, true);
  2323 function get_the_modified_date( $d = '', $post = null ) {
  1944 	else
  2324 	$post = get_post( $post );
  1945 		$the_time = get_post_modified_time($d, null, null, true);
  2325 
  1946 
  2326 	if ( ! $post ) {
  1947 	/**
  2327 		// For backward compatibility, failures go through the filter below.
  1948 	 * Filter the date a post was last modified.
  2328 		$the_time = false;
       
  2329 	} elseif ( empty( $d ) ) {
       
  2330 		$the_time = get_post_modified_time( get_option( 'date_format' ), false, $post, true );
       
  2331 	} else {
       
  2332 		$the_time = get_post_modified_time( $d, false, $post, true );
       
  2333 	}
       
  2334 
       
  2335 	/**
       
  2336 	 * Filters the date a post was last modified.
  1949 	 *
  2337 	 *
  1950 	 * @since 2.1.0
  2338 	 * @since 2.1.0
  1951 	 *
  2339 	 * @since 4.6.0 Added the `$post` parameter.
  1952 	 * @param string $the_time The formatted date.
  2340 	 *
  1953 	 * @param string $d        PHP date format. Defaults to value specified in
  2341 	 * @param string|bool  $the_time The formatted date or false if no post is found.
  1954 	 *                         'date_format' option.
  2342 	 * @param string       $d        PHP date format. Defaults to value specified in
  1955 	 */
  2343 	 *                               'date_format' option.
  1956 	return apply_filters( 'get_the_modified_date', $the_time, $d );
  2344 	 * @param WP_Post|null $post     WP_Post object or null if no post is found.
       
  2345 	 */
       
  2346 	return apply_filters( 'get_the_modified_date', $the_time, $d, $post );
  1957 }
  2347 }
  1958 
  2348 
  1959 /**
  2349 /**
  1960  * Display the time at which the post was written.
  2350  * Display the time at which the post was written.
  1961  *
  2351  *
  1963  *
  2353  *
  1964  * @param string $d Either 'G', 'U', or php date format.
  2354  * @param string $d Either 'G', 'U', or php date format.
  1965  */
  2355  */
  1966 function the_time( $d = '' ) {
  2356 function the_time( $d = '' ) {
  1967 	/**
  2357 	/**
  1968 	 * Filter the time a post was written for display.
  2358 	 * Filters the time a post was written for display.
  1969 	 *
  2359 	 *
  1970 	 * @since 0.71
  2360 	 * @since 0.71
  1971 	 *
  2361 	 *
  1972 	 * @param string $get_the_time The formatted time.
  2362 	 * @param string $get_the_time The formatted time.
  1973 	 * @param string $d            The time format. Accepts 'G', 'U',
  2363 	 * @param string $d            The time format. Accepts 'G', 'U',
  1983  *
  2373  *
  1984  * @param string      $d    Optional. Format to use for retrieving the time the post
  2374  * @param string      $d    Optional. Format to use for retrieving the time the post
  1985  *                          was written. Either 'G', 'U', or php date format defaults
  2375  *                          was written. Either 'G', 'U', or php date format defaults
  1986  *                          to the value specified in the time_format option. Default empty.
  2376  *                          to the value specified in the time_format option. Default empty.
  1987  * @param int|WP_Post $post WP_Post object or ID. Default is global $post object.
  2377  * @param int|WP_Post $post WP_Post object or ID. Default is global $post object.
  1988  * @return false|string Formatted date string or Unix timestamp. False on failure.
  2378  * @return string|int|false Formatted date string or Unix timestamp if `$id` is 'U' or 'G'. False on failure.
  1989  */
  2379  */
  1990 function get_the_time( $d = '', $post = null ) {
  2380 function get_the_time( $d = '', $post = null ) {
  1991 	$post = get_post($post);
  2381 	$post = get_post($post);
  1992 
  2382 
  1993 	if ( ! $post ) {
  2383 	if ( ! $post ) {
  1998 		$the_time = get_post_time(get_option('time_format'), false, $post, true);
  2388 		$the_time = get_post_time(get_option('time_format'), false, $post, true);
  1999 	else
  2389 	else
  2000 		$the_time = get_post_time($d, false, $post, true);
  2390 		$the_time = get_post_time($d, false, $post, true);
  2001 
  2391 
  2002 	/**
  2392 	/**
  2003 	 * Filter the time a post was written.
  2393 	 * Filters the time a post was written.
  2004 	 *
  2394 	 *
  2005 	 * @since 1.5.0
  2395 	 * @since 1.5.0
  2006 	 *
  2396 	 *
  2007 	 * @param string      $the_time The formatted time.
  2397 	 * @param string      $the_time The formatted time.
  2008 	 * @param string      $d        Format to use for retrieving the time the post was written.
  2398 	 * @param string      $d        Format to use for retrieving the time the post was written.
  2021  * @param string      $d         Optional. Format to use for retrieving the time the post
  2411  * @param string      $d         Optional. Format to use for retrieving the time the post
  2022  *                               was written. Either 'G', 'U', or php date format. Default 'U'.
  2412  *                               was written. Either 'G', 'U', or php date format. Default 'U'.
  2023  * @param bool        $gmt       Optional. Whether to retrieve the GMT time. Default false.
  2413  * @param bool        $gmt       Optional. Whether to retrieve the GMT time. Default false.
  2024  * @param int|WP_Post $post      WP_Post object or ID. Default is global $post object.
  2414  * @param int|WP_Post $post      WP_Post object or ID. Default is global $post object.
  2025  * @param bool        $translate Whether to translate the time string. Default false.
  2415  * @param bool        $translate Whether to translate the time string. Default false.
  2026  * @return false|string|int Formatted date string or Unix timestamp. False on failure.
  2416  * @return string|int|false Formatted date string or Unix timestamp if `$id` is 'U' or 'G'. False on failure.
  2027  */
  2417  */
  2028 function get_post_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
  2418 function get_post_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
  2029 	$post = get_post($post);
  2419 	$post = get_post($post);
  2030 
  2420 
  2031 	if ( ! $post ) {
  2421 	if ( ! $post ) {
  2038 		$time = $post->post_date;
  2428 		$time = $post->post_date;
  2039 
  2429 
  2040 	$time = mysql2date($d, $time, $translate);
  2430 	$time = mysql2date($d, $time, $translate);
  2041 
  2431 
  2042 	/**
  2432 	/**
  2043 	 * Filter the localized time a post was written.
  2433 	 * Filters the localized time a post was written.
  2044 	 *
  2434 	 *
  2045 	 * @since 2.6.0
  2435 	 * @since 2.6.0
  2046 	 *
  2436 	 *
  2047 	 * @param string $time The formatted time.
  2437 	 * @param string $time The formatted time.
  2048 	 * @param string $d    Format to use for retrieving the time the post was written.
  2438 	 * @param string $d    Format to use for retrieving the time the post was written.
  2059  *
  2449  *
  2060  * @param string $d Optional Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
  2450  * @param string $d Optional Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
  2061  */
  2451  */
  2062 function the_modified_time($d = '') {
  2452 function the_modified_time($d = '') {
  2063 	/**
  2453 	/**
  2064 	 * Filter the localized time a post was last modified, for display.
  2454 	 * Filters the localized time a post was last modified, for display.
  2065 	 *
  2455 	 *
  2066 	 * @since 2.0.0
  2456 	 * @since 2.0.0
  2067 	 *
  2457 	 *
  2068 	 * @param string $get_the_modified_time The formatted time.
  2458 	 * @param string $get_the_modified_time The formatted time.
  2069 	 * @param string $d                     The time format. Accepts 'G', 'U',
  2459 	 * @param string $d                     The time format. Accepts 'G', 'U',
  2075 
  2465 
  2076 /**
  2466 /**
  2077  * Retrieve the time at which the post was last modified.
  2467  * Retrieve the time at which the post was last modified.
  2078  *
  2468  *
  2079  * @since 2.0.0
  2469  * @since 2.0.0
  2080  *
  2470  * @since 4.6.0 Added the `$post` parameter.
  2081  * @param string $d Optional Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
  2471  *
  2082  * @return string
  2472  * @param string      $d     Optional. Format to use for retrieving the time the post
  2083  */
  2473  *                           was modified. Either 'G', 'U', or php date format defaults
  2084 function get_the_modified_time($d = '') {
  2474  *                           to the value specified in the time_format option. Default empty.
  2085 	if ( '' == $d )
  2475  * @param int|WP_Post $post  Optional. Post ID or WP_Post object. Default current post.
  2086 		$the_time = get_post_modified_time(get_option('time_format'), null, null, true);
  2476  * @return false|string Formatted date string or Unix timestamp. False on failure.
  2087 	else
  2477  */
  2088 		$the_time = get_post_modified_time($d, null, null, true);
  2478 function get_the_modified_time( $d = '', $post = null ) {
  2089 
  2479 	$post = get_post( $post );
  2090 	/**
  2480 
  2091 	 * Filter the localized time a post was last modified.
  2481 	if ( ! $post ) {
       
  2482 		// For backward compatibility, failures go through the filter below.
       
  2483 		$the_time = false;
       
  2484 	} elseif ( empty( $d ) ) {
       
  2485 		$the_time = get_post_modified_time( get_option( 'time_format' ), false, $post, true );
       
  2486 	} else {
       
  2487 		$the_time = get_post_modified_time( $d, false, $post, true );
       
  2488 	}
       
  2489 
       
  2490 	/**
       
  2491 	 * Filters the localized time a post was last modified.
  2092 	 *
  2492 	 *
  2093 	 * @since 2.0.0
  2493 	 * @since 2.0.0
  2094 	 *
  2494 	 * @since 4.6.0 Added the `$post` parameter.
  2095 	 * @param string $the_time The formatted time.
  2495 	 *
  2096 	 * @param string $d        Format to use for retrieving the time the post was
  2496 	 * @param string|bool  $the_time The formatted time or false if no post is found.
  2097 	 *                         written. Accepts 'G', 'U', or php date format. Defaults
  2497 	 * @param string       $d        Format to use for retrieving the time the post was
  2098 	 *                         to value specified in 'time_format' option.
  2498 	 *                               written. Accepts 'G', 'U', or php date format. Defaults
  2099 	 */
  2499 	 *                               to value specified in 'time_format' option.
  2100 	return apply_filters( 'get_the_modified_time', $the_time, $d );
  2500 	 * @param WP_Post|null $post     WP_Post object or null if no post is found.
       
  2501 	 */
       
  2502 	return apply_filters( 'get_the_modified_time', $the_time, $d, $post );
  2101 }
  2503 }
  2102 
  2504 
  2103 /**
  2505 /**
  2104  * Retrieve the time at which the post was last modified.
  2506  * Retrieve the time at which the post was last modified.
  2105  *
  2507  *
  2108  * @param string      $d         Optional. Format to use for retrieving the time the post
  2510  * @param string      $d         Optional. Format to use for retrieving the time the post
  2109  *                               was modified. Either 'G', 'U', or php date format. Default 'U'.
  2511  *                               was modified. Either 'G', 'U', or php date format. Default 'U'.
  2110  * @param bool        $gmt       Optional. Whether to retrieve the GMT time. Default false.
  2512  * @param bool        $gmt       Optional. Whether to retrieve the GMT time. Default false.
  2111  * @param int|WP_Post $post      WP_Post object or ID. Default is global $post object.
  2513  * @param int|WP_Post $post      WP_Post object or ID. Default is global $post object.
  2112  * @param bool        $translate Whether to translate the time string. Default false.
  2514  * @param bool        $translate Whether to translate the time string. Default false.
  2113  * @return false|string Formatted date string or Unix timestamp. False on failure.
  2515  * @return string|int|false Formatted date string or Unix timestamp if `$id` is 'U' or 'G'. False on failure.
  2114  */
  2516  */
  2115 function get_post_modified_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
  2517 function get_post_modified_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
  2116 	$post = get_post($post);
  2518 	$post = get_post($post);
  2117 
  2519 
  2118 	if ( ! $post ) {
  2520 	if ( ! $post ) {
  2124 	else
  2526 	else
  2125 		$time = $post->post_modified;
  2527 		$time = $post->post_modified;
  2126 	$time = mysql2date($d, $time, $translate);
  2528 	$time = mysql2date($d, $time, $translate);
  2127 
  2529 
  2128 	/**
  2530 	/**
  2129 	 * Filter the localized time a post was last modified.
  2531 	 * Filters the localized time a post was last modified.
  2130 	 *
  2532 	 *
  2131 	 * @since 2.8.0
  2533 	 * @since 2.8.0
  2132 	 *
  2534 	 *
  2133 	 * @param string $time The formatted time.
  2535 	 * @param string $time The formatted time.
  2134 	 * @param string $d    The date format. Accepts 'G', 'U', or php date format. Default 'U'.
  2536 	 * @param string $d    The date format. Accepts 'G', 'U', or php date format. Default 'U'.
  2139 
  2541 
  2140 /**
  2542 /**
  2141  * Display the weekday on which the post was written.
  2543  * Display the weekday on which the post was written.
  2142  *
  2544  *
  2143  * @since 0.71
  2545  * @since 0.71
  2144  * @uses $wp_locale
  2546  *
       
  2547  * @global WP_Locale $wp_locale
  2145  */
  2548  */
  2146 function the_weekday() {
  2549 function the_weekday() {
  2147 	global $wp_locale;
  2550 	global $wp_locale;
  2148 	$the_weekday = $wp_locale->get_weekday( mysql2date( 'w', get_post()->post_date, false ) );
  2551 	$the_weekday = $wp_locale->get_weekday( mysql2date( 'w', get_post()->post_date, false ) );
  2149 
  2552 
  2150 	/**
  2553 	/**
  2151 	 * Filter the weekday on which the post was written, for display.
  2554 	 * Filters the weekday on which the post was written, for display.
  2152 	 *
  2555 	 *
  2153 	 * @since 0.71
  2556 	 * @since 0.71
  2154 	 *
  2557 	 *
  2155 	 * @param string $the_weekday
  2558 	 * @param string $the_weekday
  2156 	 */
  2559 	 */
  2157 	$the_weekday = apply_filters( 'the_weekday', $the_weekday );
  2560 	echo apply_filters( 'the_weekday', $the_weekday );
  2158 	echo $the_weekday;
       
  2159 }
  2561 }
  2160 
  2562 
  2161 /**
  2563 /**
  2162  * Display the weekday on which the post was written.
  2564  * Display the weekday on which the post was written.
  2163  *
  2565  *
  2164  * Will only output the weekday if the current post's weekday is different from
  2566  * Will only output the weekday if the current post's weekday is different from
  2165  * the previous one output.
  2567  * the previous one output.
  2166  *
  2568  *
  2167  * @since 0.71
  2569  * @since 0.71
       
  2570  *
       
  2571  * @global WP_Locale       $wp_locale
       
  2572  * @global string|int|bool $currentday
       
  2573  * @global string|int|bool $previousweekday
  2168  *
  2574  *
  2169  * @param string $before Optional Output before the date.
  2575  * @param string $before Optional Output before the date.
  2170  * @param string $after Optional Output after the date.
  2576  * @param string $after Optional Output after the date.
  2171  */
  2577  */
  2172 function the_weekday_date($before='',$after='') {
  2578 function the_weekday_date($before='',$after='') {
  2178 		$the_weekday_date .= $after;
  2584 		$the_weekday_date .= $after;
  2179 		$previousweekday = $currentday;
  2585 		$previousweekday = $currentday;
  2180 	}
  2586 	}
  2181 
  2587 
  2182 	/**
  2588 	/**
  2183 	 * Filter the localized date on which the post was written, for display.
  2589 	 * Filters the localized date on which the post was written, for display.
  2184 	 *
  2590 	 *
  2185 	 * @since 0.71
  2591 	 * @since 0.71
  2186 	 *
  2592 	 *
  2187 	 * @param string $the_weekday_date
  2593 	 * @param string $the_weekday_date
  2188 	 * @param string $before           The HTML to output before the date.
  2594 	 * @param string $before           The HTML to output before the date.
  2191 	$the_weekday_date = apply_filters( 'the_weekday_date', $the_weekday_date, $before, $after );
  2597 	$the_weekday_date = apply_filters( 'the_weekday_date', $the_weekday_date, $before, $after );
  2192 	echo $the_weekday_date;
  2598 	echo $the_weekday_date;
  2193 }
  2599 }
  2194 
  2600 
  2195 /**
  2601 /**
  2196  * Fire the wp_head action
  2602  * Fire the wp_head action.
       
  2603  *
       
  2604  * See {@see 'wp_head'}.
  2197  *
  2605  *
  2198  * @since 1.2.0
  2606  * @since 1.2.0
  2199  */
  2607  */
  2200 function wp_head() {
  2608 function wp_head() {
  2201 	/**
  2609 	/**
  2202 	 * Print scripts or data in the head tag on the front end.
  2610 	 * Prints scripts or data in the head tag on the front end.
  2203 	 *
  2611 	 *
  2204 	 * @since 1.5.0
  2612 	 * @since 1.5.0
  2205 	 */
  2613 	 */
  2206 	do_action( 'wp_head' );
  2614 	do_action( 'wp_head' );
  2207 }
  2615 }
  2208 
  2616 
  2209 /**
  2617 /**
  2210  * Fire the wp_footer action
  2618  * Fire the wp_footer action.
       
  2619  *
       
  2620  * See {@see 'wp_footer'}.
  2211  *
  2621  *
  2212  * @since 1.5.1
  2622  * @since 1.5.1
  2213  */
  2623  */
  2214 function wp_footer() {
  2624 function wp_footer() {
  2215 	/**
  2625 	/**
  2216 	 * Print scripts or data before the closing body tag on the front end.
  2626 	 * Prints scripts or data before the closing body tag on the front end.
  2217 	 *
  2627 	 *
  2218 	 * @since 1.5.1
  2628 	 * @since 1.5.1
  2219 	 */
  2629 	 */
  2220 	do_action( 'wp_footer' );
  2630 	do_action( 'wp_footer' );
  2221 }
  2631 }
  2240 		'comstitle'	=> __('%1$s %2$s Comments Feed'),
  2650 		'comstitle'	=> __('%1$s %2$s Comments Feed'),
  2241 	);
  2651 	);
  2242 
  2652 
  2243 	$args = wp_parse_args( $args, $defaults );
  2653 	$args = wp_parse_args( $args, $defaults );
  2244 
  2654 
  2245 	echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( sprintf( $args['feedtitle'], get_bloginfo('name'), $args['separator'] ) ) . '" href="' . esc_url( get_feed_link() ) . "\" />\n";
  2655 	/**
  2246 	echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( sprintf( $args['comstitle'], get_bloginfo('name'), $args['separator'] ) ) . '" href="' . esc_url( get_feed_link( 'comments_' . get_default_feed() ) ) . "\" />\n";
  2656 	 * Filters whether to display the posts feed link.
       
  2657 	 *
       
  2658 	 * @since 4.4.0
       
  2659 	 *
       
  2660 	 * @param bool $show Whether to display the posts feed link. Default true.
       
  2661 	 */
       
  2662 	if ( apply_filters( 'feed_links_show_posts_feed', true ) ) {
       
  2663 		echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( sprintf( $args['feedtitle'], get_bloginfo( 'name' ), $args['separator'] ) ) . '" href="' . esc_url( get_feed_link() ) . "\" />\n";
       
  2664 	}
       
  2665 
       
  2666 	/**
       
  2667 	 * Filters whether to display the comments feed link.
       
  2668 	 *
       
  2669 	 * @since 4.4.0
       
  2670 	 *
       
  2671 	 * @param bool $show Whether to display the comments feed link. Default true.
       
  2672 	 */
       
  2673 	if ( apply_filters( 'feed_links_show_comments_feed', true ) ) {
       
  2674 		echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( sprintf( $args['comstitle'], get_bloginfo( 'name' ), $args['separator'] ) ) . '" href="' . esc_url( get_feed_link( 'comments_' . get_default_feed() ) ) . "\" />\n";
       
  2675 	}
  2247 }
  2676 }
  2248 
  2677 
  2249 /**
  2678 /**
  2250  * Display the links to the extra feeds such as category feeds.
  2679  * Display the links to the extra feeds such as category feeds.
  2251  *
  2680  *
  2261 		'singletitle' => __('%1$s %2$s %3$s Comments Feed'),
  2690 		'singletitle' => __('%1$s %2$s %3$s Comments Feed'),
  2262 		/* translators: 1: blog name, 2: separator(raquo), 3: category name */
  2691 		/* translators: 1: blog name, 2: separator(raquo), 3: category name */
  2263 		'cattitle'    => __('%1$s %2$s %3$s Category Feed'),
  2692 		'cattitle'    => __('%1$s %2$s %3$s Category Feed'),
  2264 		/* translators: 1: blog name, 2: separator(raquo), 3: tag name */
  2693 		/* translators: 1: blog name, 2: separator(raquo), 3: tag name */
  2265 		'tagtitle'    => __('%1$s %2$s %3$s Tag Feed'),
  2694 		'tagtitle'    => __('%1$s %2$s %3$s Tag Feed'),
       
  2695 		/* 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'),
  2266 		/* translators: 1: blog name, 2: separator(raquo), 3: author name  */
  2697 		/* translators: 1: blog name, 2: separator(raquo), 3: author name  */
  2267 		'authortitle' => __('%1$s %2$s Posts by %3$s Feed'),
  2698 		'authortitle' => __('%1$s %2$s Posts by %3$s Feed'),
  2268 		/* translators: 1: blog name, 2: separator(raquo), 3: search phrase */
  2699 		/* translators: 1: blog name, 2: separator(raquo), 3: search phrase */
  2269 		'searchtitle' => __('%1$s %2$s Search Results for &#8220;%3$s&#8221; Feed'),
  2700 		'searchtitle' => __('%1$s %2$s Search Results for &#8220;%3$s&#8221; Feed'),
  2270 		/* translators: 1: blog name, 2: separator(raquo), 3: post type name */
  2701 		/* translators: 1: blog name, 2: separator(raquo), 3: post type name */
  2301 
  2732 
  2302 		if ( $term ) {
  2733 		if ( $term ) {
  2303 			$title = sprintf( $args['tagtitle'], get_bloginfo('name'), $args['separator'], $term->name );
  2734 			$title = sprintf( $args['tagtitle'], get_bloginfo('name'), $args['separator'], $term->name );
  2304 			$href = get_tag_feed_link( $term->term_id );
  2735 			$href = get_tag_feed_link( $term->term_id );
  2305 		}
  2736 		}
       
  2737 	} elseif ( is_tax() ) {
       
  2738  		$term = get_queried_object();
       
  2739  		$tax = get_taxonomy( $term->taxonomy );
       
  2740  		$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 );
  2306 	} elseif ( is_author() ) {
  2742 	} elseif ( is_author() ) {
  2307 		$author_id = intval( get_query_var('author') );
  2743 		$author_id = intval( get_query_var('author') );
  2308 
  2744 
  2309 		$title = sprintf( $args['authortitle'], get_bloginfo('name'), $args['separator'], get_the_author_meta( 'display_name', $author_id ) );
  2745 		$title = sprintf( $args['authortitle'], get_bloginfo('name'), $args['separator'], get_the_author_meta( 'display_name', $author_id ) );
  2310 		$href = get_author_feed_link( $author_id );
  2746 		$href = get_author_feed_link( $author_id );
  2327  *
  2763  *
  2328  * @link http://archipelago.phrasewise.com/rsd
  2764  * @link http://archipelago.phrasewise.com/rsd
  2329  * @since 2.0.0
  2765  * @since 2.0.0
  2330  */
  2766  */
  2331 function rsd_link() {
  2767 function rsd_link() {
  2332 	echo '<link rel="EditURI" type="application/rsd+xml" title="RSD" href="' . get_bloginfo('wpurl') . "/xmlrpc.php?rsd\" />\n";
  2768 	echo '<link rel="EditURI" type="application/rsd+xml" title="RSD" href="' . esc_url( site_url( 'xmlrpc.php?rsd', 'rpc' ) ) . '" />' . "\n";
  2333 }
  2769 }
  2334 
  2770 
  2335 /**
  2771 /**
  2336  * Display the link to the Windows Live Writer manifest file.
  2772  * Display the link to the Windows Live Writer manifest file.
  2337  *
  2773  *
  2338  * @link http://msdn.microsoft.com/en-us/library/bb463265.aspx
  2774  * @link https://msdn.microsoft.com/en-us/library/bb463265.aspx
  2339  * @since 2.3.1
  2775  * @since 2.3.1
  2340  */
  2776  */
  2341 function wlwmanifest_link() {
  2777 function wlwmanifest_link() {
  2342 	echo '<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="',
  2778 	echo '<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="',
  2343 		includes_url( 'wlwmanifest.xml' ), '" /> ', "\n";
  2779 		includes_url( 'wlwmanifest.xml' ), '" /> ', "\n";
  2344 }
  2780 }
  2345 
  2781 
  2346 /**
  2782 /**
  2347  * Display a noindex meta tag if required by the blog configuration.
  2783  * Displays a noindex meta tag if required by the blog configuration.
  2348  *
  2784  *
  2349  * If a blog is marked as not being public then the noindex meta tag will be
  2785  * If a blog is marked as not being public then the noindex meta tag will be
  2350  * output to tell web robots not to index the page content. Add this to the wp_head action.
  2786  * output to tell web robots not to index the page content. Add this to the
  2351  * Typical usage is as a wp_head callback. add_action( 'wp_head', 'noindex' );
  2787  * {@see 'wp_head'} action.
       
  2788  *
       
  2789  * Typical usage is as a {@see 'wp_head'} callback:
       
  2790  *
       
  2791  *     add_action( 'wp_head', 'noindex' );
  2352  *
  2792  *
  2353  * @see wp_no_robots
  2793  * @see wp_no_robots
  2354  *
  2794  *
  2355  * @since 2.1.0
  2795  * @since 2.1.0
  2356  */
  2796  */
  2371 function wp_no_robots() {
  2811 function wp_no_robots() {
  2372 	echo "<meta name='robots' content='noindex,follow' />\n";
  2812 	echo "<meta name='robots' content='noindex,follow' />\n";
  2373 }
  2813 }
  2374 
  2814 
  2375 /**
  2815 /**
  2376  * Whether the user should have a WYSIWIG editor.
  2816  * Display site icon meta tags.
  2377  *
  2817  *
  2378  * Checks that the user requires a WYSIWIG editor and that the editor is
  2818  * @since 4.3.0
  2379  * supported in the users browser.
  2819  *
       
  2820  * @link https://www.whatwg.org/specs/web-apps/current-work/multipage/links.html#rel-icon HTML5 specification link icon.
       
  2821  */
       
  2822 function wp_site_icon() {
       
  2823 	if ( ! has_site_icon() && ! is_customize_preview() ) {
       
  2824 		return;
       
  2825 	}
       
  2826 
       
  2827 	$meta_tags = array();
       
  2828 	$icon_32 = get_site_icon_url( 32 );
       
  2829 	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.
       
  2831 	}
       
  2832 	if ( $icon_32 ) {
       
  2833 		$meta_tags[] = sprintf( '<link rel="icon" href="%s" sizes="32x32" />', esc_url( $icon_32 ) );
       
  2834 	}
       
  2835 	$icon_192 = get_site_icon_url( 192 );
       
  2836 	if ( $icon_192 ) {
       
  2837 		$meta_tags[] = sprintf( '<link rel="icon" href="%s" sizes="192x192" />', esc_url( $icon_192 ) );
       
  2838 	}
       
  2839 	$icon_180 = get_site_icon_url( 180 );
       
  2840 	if ( $icon_180 ) {
       
  2841 		$meta_tags[] = sprintf( '<link rel="apple-touch-icon-precomposed" href="%s" />', esc_url( $icon_180 ) );
       
  2842 	}
       
  2843 	$icon_270 = get_site_icon_url( 270 );
       
  2844 	if ( $icon_270 ) {
       
  2845 		$meta_tags[] = sprintf( '<meta name="msapplication-TileImage" content="%s" />', esc_url( $icon_270 ) );
       
  2846 	}
       
  2847 
       
  2848 	/**
       
  2849 	 * Filters the site icon meta tags, so Plugins can add their own.
       
  2850 	 *
       
  2851 	 * @since 4.3.0
       
  2852 	 *
       
  2853 	 * @param array $meta_tags Site Icon meta elements.
       
  2854 	 */
       
  2855 	$meta_tags = apply_filters( 'site_icon_meta_tags', $meta_tags );
       
  2856 	$meta_tags = array_filter( $meta_tags );
       
  2857 
       
  2858 	foreach ( $meta_tags as $meta_tag ) {
       
  2859 		echo "$meta_tag\n";
       
  2860 	}
       
  2861 }
       
  2862 
       
  2863 /**
       
  2864  * Prints resource hints to browsers for pre-fetching, pre-rendering
       
  2865  * and pre-connecting to web sites.
       
  2866  *
       
  2867  * Gives hints to browsers to prefetch specific pages or render them
       
  2868  * in the background, to perform DNS lookups or to begin the connection
       
  2869  * handshake (DNS, TCP, TLS) in the background.
       
  2870  *
       
  2871  * These performance improving indicators work by using `<link rel"…">`.
       
  2872  *
       
  2873  * @since 4.6.0
       
  2874  */
       
  2875 function wp_resource_hints() {
       
  2876 	$hints = array(
       
  2877 		'dns-prefetch' => wp_dependencies_unique_hosts(),
       
  2878 		'preconnect'   => array(),
       
  2879 		'prefetch'     => array(),
       
  2880 		'prerender'    => array(),
       
  2881 	);
       
  2882 
       
  2883 	/*
       
  2884 	 * Add DNS prefetch for the Emoji CDN.
       
  2885 	 * The path is removed in the foreach loop below.
       
  2886 	 */
       
  2887 	/** 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/' );
       
  2889 
       
  2890 	foreach ( $hints as $relation_type => $urls ) {
       
  2891 		$unique_urls = array();
       
  2892 
       
  2893 		/**
       
  2894 		 * Filters domains and URLs for resource hints of relation type.
       
  2895 		 *
       
  2896 		 * @since 4.6.0
       
  2897 		 *
       
  2898 		 * @param array  $urls          URLs to print for resource hints.
       
  2899 		 * @param string $relation_type The relation type the URLs are printed for, e.g. 'preconnect' or 'prerender'.
       
  2900 		 */
       
  2901 		$urls = apply_filters( 'wp_resource_hints', $urls, $relation_type );
       
  2902 
       
  2903 		foreach ( $urls as $key => $url ) {
       
  2904 			$atts = array();
       
  2905 
       
  2906 			if ( is_array( $url ) ) {
       
  2907 				if ( isset( $url['href'] ) ) {
       
  2908 					$atts = $url;
       
  2909 					$url  = $url['href'];
       
  2910 				} else {
       
  2911 					continue;
       
  2912 				}
       
  2913 			}
       
  2914 
       
  2915 			$url = esc_url( $url, array( 'http', 'https' ) );
       
  2916 
       
  2917 			if ( ! $url ) {
       
  2918 				continue;
       
  2919 			}
       
  2920 
       
  2921 			if ( isset( $unique_urls[ $url ] ) ) {
       
  2922 				continue;
       
  2923 			}
       
  2924 
       
  2925 			if ( in_array( $relation_type, array( 'preconnect', 'dns-prefetch' ) ) ) {
       
  2926 				$parsed = wp_parse_url( $url );
       
  2927 
       
  2928 				if ( empty( $parsed['host'] ) ) {
       
  2929 					continue;
       
  2930 				}
       
  2931 
       
  2932 				if ( 'preconnect' === $relation_type && ! empty( $parsed['scheme'] ) ) {
       
  2933 					$url = $parsed['scheme'] . '://' . $parsed['host'];
       
  2934 				} else {
       
  2935 					// Use protocol-relative URLs for dns-prefetch or if scheme is missing.
       
  2936 					$url = '//' . $parsed['host'];
       
  2937 				}
       
  2938 			}
       
  2939 
       
  2940 			$atts['rel'] = $relation_type;
       
  2941 			$atts['href'] = $url;
       
  2942 
       
  2943 			$unique_urls[ $url ] = $atts;
       
  2944 		}
       
  2945 
       
  2946 		foreach ( $unique_urls as $atts ) {
       
  2947 			$html = '';
       
  2948 
       
  2949 			foreach ( $atts as $attr => $value ) {
       
  2950 				if ( ! is_scalar( $value ) ||
       
  2951 				     ( ! in_array( $attr, array( 'as', 'crossorigin', 'href', 'pr', 'rel', 'type' ), true ) && ! is_numeric( $attr ))
       
  2952 				) {
       
  2953 					continue;
       
  2954 				}
       
  2955 
       
  2956 				$value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value );
       
  2957 
       
  2958 				if ( ! is_string( $attr ) ) {
       
  2959 					$html .= " $value";
       
  2960 				} else {
       
  2961 					$html .= " $attr='$value'";
       
  2962 				}
       
  2963 			}
       
  2964 
       
  2965 			$html = trim( $html );
       
  2966 
       
  2967 			echo "<link $html />\n";
       
  2968 		}
       
  2969 	}
       
  2970 }
       
  2971 
       
  2972 /**
       
  2973  * Retrieves a list of unique hosts of all enqueued scripts and styles.
       
  2974  *
       
  2975  * @since 4.6.0
       
  2976  *
       
  2977  * @return array A list of unique hosts of enqueued scripts and styles.
       
  2978  */
       
  2979 function wp_dependencies_unique_hosts() {
       
  2980 	global $wp_scripts, $wp_styles;
       
  2981 
       
  2982 	$unique_hosts = array();
       
  2983 
       
  2984 	foreach ( array( $wp_scripts, $wp_styles ) as $dependencies ) {
       
  2985 		if ( $dependencies instanceof WP_Dependencies && ! empty( $dependencies->queue ) ) {
       
  2986 			foreach ( $dependencies->queue as $handle ) {
       
  2987 				if ( ! isset( $dependencies->registered[ $handle ] ) ) {
       
  2988 					continue;
       
  2989 				}
       
  2990 
       
  2991 				/* @var _WP_Dependency $dependency */
       
  2992 				$dependency = $dependencies->registered[ $handle ];
       
  2993 				$parsed     = wp_parse_url( $dependency->src );
       
  2994 
       
  2995 				if ( ! empty( $parsed['host'] ) && ! in_array( $parsed['host'], $unique_hosts ) && $parsed['host'] !== $_SERVER['SERVER_NAME'] ) {
       
  2996 					$unique_hosts[] = $parsed['host'];
       
  2997 				}
       
  2998 			}
       
  2999 		}
       
  3000 	}
       
  3001 
       
  3002 	return $unique_hosts;
       
  3003 }
       
  3004 
       
  3005 /**
       
  3006  * Whether the user can access the visual editor.
       
  3007  *
       
  3008  * Checks if the user can access the visual editor and that it's supported by the user's browser.
  2380  *
  3009  *
  2381  * @since 2.0.0
  3010  * @since 2.0.0
  2382  *
  3011  *
  2383  * @return bool
  3012  * @global bool $wp_rich_edit Whether the user can access the visual editor.
       
  3013  * @global bool $is_gecko     Whether the browser is Gecko-based.
       
  3014  * @global bool $is_opera     Whether the browser is Opera.
       
  3015  * @global bool $is_safari    Whether the browser is Safari.
       
  3016  * @global bool $is_chrome    Whether the browser is Chrome.
       
  3017  * @global bool $is_IE        Whether the browser is Internet Explorer.
       
  3018  * @global bool $is_edge      Whether the browser is Microsoft Edge.
       
  3019  *
       
  3020  * @return bool True if the user can access the visual editor, false otherwise.
  2384  */
  3021  */
  2385 function user_can_richedit() {
  3022 function user_can_richedit() {
  2386 	global $wp_rich_edit, $is_gecko, $is_opera, $is_safari, $is_chrome, $is_IE;
  3023 	global $wp_rich_edit, $is_gecko, $is_opera, $is_safari, $is_chrome, $is_IE, $is_edge;
  2387 
  3024 
  2388 	if ( !isset($wp_rich_edit) ) {
  3025 	if ( !isset($wp_rich_edit) ) {
  2389 		$wp_rich_edit = false;
  3026 		$wp_rich_edit = false;
  2390 
  3027 
  2391 		if ( get_user_option( 'rich_editing' ) == 'true' || ! is_user_logged_in() ) { // default to 'true' for logged out users
  3028 		if ( get_user_option( 'rich_editing' ) == 'true' || ! is_user_logged_in() ) { // default to 'true' for logged out users
  2392 			if ( $is_safari ) {
  3029 			if ( $is_safari ) {
  2393 				$wp_rich_edit = ! wp_is_mobile() || ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval( $match[1] ) >= 534 );
  3030 				$wp_rich_edit = ! wp_is_mobile() || ( preg_match( '!AppleWebKit/(\d+)!', $_SERVER['HTTP_USER_AGENT'], $match ) && intval( $match[1] ) >= 534 );
  2394 			} elseif ( $is_gecko || $is_chrome || $is_IE || ( $is_opera && !wp_is_mobile() ) ) {
  3031 			} elseif ( $is_IE ) {
       
  3032 				$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() ) ) {
  2395 				$wp_rich_edit = true;
  3034 				$wp_rich_edit = true;
  2396 			}
  3035 			}
  2397 		}
  3036 		}
  2398 	}
  3037 	}
  2399 
  3038 
  2400 	/**
  3039 	/**
  2401 	 * Filter whether the user can access the rich (Visual) editor.
  3040 	 * Filters whether the user can access the visual editor.
  2402 	 *
  3041 	 *
  2403 	 * @since 2.1.0
  3042 	 * @since 2.1.0
  2404 	 *
  3043 	 *
  2405 	 * @param bool $wp_rich_edit Whether the user can access to the rich (Visual) editor.
  3044 	 * @param bool $wp_rich_edit Whether the user can access the visual editor.
  2406 	 */
  3045 	 */
  2407 	return apply_filters( 'user_can_richedit', $wp_rich_edit );
  3046 	return apply_filters( 'user_can_richedit', $wp_rich_edit );
  2408 }
  3047 }
  2409 
  3048 
  2410 /**
  3049 /**
  2423 		$ed = get_user_setting('editor', 'tinymce');
  3062 		$ed = get_user_setting('editor', 'tinymce');
  2424 		$r = ( in_array($ed, array('tinymce', 'html', 'test') ) ) ? $ed : $r;
  3063 		$r = ( in_array($ed, array('tinymce', 'html', 'test') ) ) ? $ed : $r;
  2425 	}
  3064 	}
  2426 
  3065 
  2427 	/**
  3066 	/**
  2428 	 * Filter which editor should be displayed by default.
  3067 	 * Filters which editor should be displayed by default.
  2429 	 *
  3068 	 *
  2430 	 * @since 2.5.0
  3069 	 * @since 2.5.0
  2431 	 *
  3070 	 *
  2432 	 * @param array $r An array of editors. Accepts 'tinymce', 'html', 'test'.
  3071 	 * @param string $r Which editor should be displayed by default. Either 'tinymce', 'html', or 'test'.
  2433 	 */
  3072 	 */
  2434 	return apply_filters( 'wp_default_editor', $r );
  3073 	return apply_filters( 'wp_default_editor', $r );
  2435 }
  3074 }
  2436 
  3075 
  2437 /**
  3076 /**
  2439  *
  3078  *
  2440  * Using this function is the proper way to output all needed components for both TinyMCE and Quicktags.
  3079  * Using this function is the proper way to output all needed components for both TinyMCE and Quicktags.
  2441  * _WP_Editors should not be used directly. See https://core.trac.wordpress.org/ticket/17144.
  3080  * _WP_Editors should not be used directly. See https://core.trac.wordpress.org/ticket/17144.
  2442  *
  3081  *
  2443  * NOTE: Once initialized the TinyMCE editor cannot be safely moved in the DOM. For that reason
  3082  * NOTE: Once initialized the TinyMCE editor cannot be safely moved in the DOM. For that reason
  2444  * running wp_editor() inside of a metabox is not a good idea unless only Quicktags is used.
  3083  * running wp_editor() inside of a meta box is not a good idea unless only Quicktags is used.
  2445  * On the post edit screen several actions can be used to include additional editors
  3084  * On the post edit screen several actions can be used to include additional editors
  2446  * containing TinyMCE: 'edit_page_form', 'edit_form_advanced' and 'dbx_post_sidebar'.
  3085  * containing TinyMCE: 'edit_page_form', 'edit_form_advanced' and 'dbx_post_sidebar'.
  2447  * See https://core.trac.wordpress.org/ticket/19173 for more information.
  3086  * See https://core.trac.wordpress.org/ticket/19173 for more information.
  2448  *
  3087  *
  2449  * @see wp-includes/class-wp-editor.php
  3088  * @see _WP_Editors::editor()
  2450  * @since 3.3.0
  3089  * @since 3.3.0
  2451  *
  3090  *
  2452  * @param string $content Initial content for the editor.
  3091  * @param string $content   Initial content for the editor.
  2453  * @param string $editor_id HTML ID attribute value for the textarea and TinyMCE. Can only be /[a-z]+/.
  3092  * @param string $editor_id HTML ID attribute value for the textarea and TinyMCE. Can only be /[a-z]+/.
  2454  * @param array $settings See _WP_Editors::editor().
  3093  * @param array  $settings  See _WP_Editors::editor().
  2455  */
  3094  */
  2456 function wp_editor( $content, $editor_id, $settings = array() ) {
  3095 function wp_editor( $content, $editor_id, $settings = array() ) {
  2457 	if ( ! class_exists( '_WP_Editors' ) )
  3096 	if ( ! class_exists( '_WP_Editors', false ) )
  2458 		require( ABSPATH . WPINC . '/class-wp-editor.php' );
  3097 		require( ABSPATH . WPINC . '/class-wp-editor.php' );
  2459 
       
  2460 	_WP_Editors::editor($content, $editor_id, $settings);
  3098 	_WP_Editors::editor($content, $editor_id, $settings);
  2461 }
  3099 }
  2462 
  3100 
  2463 /**
  3101 /**
  2464  * Retrieve the contents of the search WordPress query variable.
  3102  * Outputs the editor scripts, stylesheets, and default settings.
  2465  *
  3103  *
  2466  * The search query string is passed through {@link esc_attr()}
  3104  * The editor can be initialized when needed after page load.
  2467  * to ensure that it is safe for placing in an html attribute.
  3105  * See wp.editor.initialize() in wp-admin/js/editor.js for initialization options.
       
  3106  *
       
  3107  * @uses _WP_Editors
       
  3108  * @since 4.8.0
       
  3109  */
       
  3110 function wp_enqueue_editor() {
       
  3111 	if ( ! class_exists( '_WP_Editors', false ) ) {
       
  3112 		require( ABSPATH . WPINC . '/class-wp-editor.php' );
       
  3113 	}
       
  3114 
       
  3115 	_WP_Editors::enqueue_default_editor();
       
  3116 }
       
  3117 
       
  3118 /**
       
  3119  * Enqueue assets needed by the code editor for the given settings.
       
  3120  *
       
  3121  * @since 4.9.0
       
  3122  *
       
  3123  * @see wp_enqueue_editor()
       
  3124  * @see _WP_Editors::parse_settings()
       
  3125  * @param array $args {
       
  3126  *     Args.
       
  3127  *
       
  3128  *     @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.
       
  3130  *     @type WP_Theme $theme      Theme being edited when on theme editor.
       
  3131  *     @type string   $plugin     Plugin being edited when on plugin editor.
       
  3132  *     @type array    $codemirror Additional CodeMirror setting overrides.
       
  3133  *     @type array    $csslint    CSSLint rule overrides.
       
  3134  *     @type array    $jshint     JSHint rule overrides.
       
  3135  *     @type array    $htmlhint   JSHint rule overrides.
       
  3136  * }
       
  3137  * @returns array|false Settings for the enqueued code editor, or false if the editor was not enqueued .
       
  3138  */
       
  3139 function wp_enqueue_code_editor( $args ) {
       
  3140 	if ( is_user_logged_in() && 'false' === wp_get_current_user()->syntax_highlighting ) {
       
  3141 		return false;
       
  3142 	}
       
  3143 
       
  3144 	$settings = array(
       
  3145 		'codemirror' => array(
       
  3146 			'indentUnit' => 4,
       
  3147 			'indentWithTabs' => true,
       
  3148 			'inputStyle' => 'contenteditable',
       
  3149 			'lineNumbers' => true,
       
  3150 			'lineWrapping' => true,
       
  3151 			'styleActiveLine' => true,
       
  3152 			'continueComments' => true,
       
  3153 			'extraKeys' => array(
       
  3154 				'Ctrl-Space' => 'autocomplete',
       
  3155 				'Ctrl-/' => 'toggleComment',
       
  3156 				'Cmd-/' => 'toggleComment',
       
  3157 				'Alt-F' => 'findPersistent',
       
  3158 				'Ctrl-F'     => 'findPersistent',
       
  3159 				'Cmd-F'      => 'findPersistent',
       
  3160 			),
       
  3161 			'direction' => 'ltr', // Code is shown in LTR even in RTL languages.
       
  3162 			'gutters' => array(),
       
  3163 		),
       
  3164 		'csslint' => array(
       
  3165 			'errors' => true, // Parsing errors.
       
  3166 			'box-model' => true,
       
  3167 			'display-property-grouping' => true,
       
  3168 			'duplicate-properties' => true,
       
  3169 			'known-properties' => true,
       
  3170 			'outline-none' => true,
       
  3171 		),
       
  3172 		'jshint' => array(
       
  3173 			// The following are copied from <https://github.com/WordPress/wordpress-develop/blob/4.8.1/.jshintrc>.
       
  3174 			'boss' => true,
       
  3175 			'curly' => true,
       
  3176 			'eqeqeq' => true,
       
  3177 			'eqnull' => true,
       
  3178 			'es3' => true,
       
  3179 			'expr' => true,
       
  3180 			'immed' => true,
       
  3181 			'noarg' => true,
       
  3182 			'nonbsp' => true,
       
  3183 			'onevar' => true,
       
  3184 			'quotmark' => 'single',
       
  3185 			'trailing' => true,
       
  3186 			'undef' => true,
       
  3187 			'unused' => true,
       
  3188 
       
  3189 			'browser' => true,
       
  3190 
       
  3191 			'globals' => array(
       
  3192 				'_' => false,
       
  3193 				'Backbone' => false,
       
  3194 				'jQuery' => false,
       
  3195 				'JSON' => false,
       
  3196 				'wp' => false,
       
  3197 			),
       
  3198 		),
       
  3199 		'htmlhint' => array(
       
  3200 			'tagname-lowercase' => true,
       
  3201 			'attr-lowercase' => true,
       
  3202 			'attr-value-double-quotes' => false,
       
  3203 			'doctype-first' => false,
       
  3204 			'tag-pair' => true,
       
  3205 			'spec-char-escape' => true,
       
  3206 			'id-unique' => true,
       
  3207 			'src-not-empty' => true,
       
  3208 			'attr-no-duplication' => true,
       
  3209 			'alt-require' => true,
       
  3210 			'space-tab-mixed-disabled' => 'tab',
       
  3211 			'attr-unsafe-chars' => true,
       
  3212 		),
       
  3213 	);
       
  3214 
       
  3215 	$type = '';
       
  3216 	if ( isset( $args['type'] ) ) {
       
  3217 		$type = $args['type'];
       
  3218 
       
  3219 		// Remap MIME types to ones that CodeMirror modes will recognize.
       
  3220 		if ( 'application/x-patch' === $type || 'text/x-patch' === $type ) {
       
  3221 			$type = 'text/x-diff';
       
  3222 		}
       
  3223 	} elseif ( isset( $args['file'] ) && false !== strpos( basename( $args['file'] ), '.' ) ) {
       
  3224 		$extension = strtolower( pathinfo( $args['file'], PATHINFO_EXTENSION ) );
       
  3225 		foreach ( wp_get_mime_types() as $exts => $mime ) {
       
  3226 			if ( preg_match( '!^(' . $exts . ')$!i', $extension ) ) {
       
  3227 				$type = $mime;
       
  3228 				break;
       
  3229 			}
       
  3230 		}
       
  3231 
       
  3232 		// Supply any types that are not matched by wp_get_mime_types().
       
  3233 		if ( empty( $type ) ) {
       
  3234 			switch ( $extension ) {
       
  3235 				case 'conf':
       
  3236 					$type = 'text/nginx';
       
  3237 					break;
       
  3238 				case 'css':
       
  3239 					$type = 'text/css';
       
  3240 					break;
       
  3241 				case 'diff':
       
  3242 				case 'patch':
       
  3243 					$type = 'text/x-diff';
       
  3244 					break;
       
  3245 				case 'html':
       
  3246 				case 'htm':
       
  3247 					$type = 'text/html';
       
  3248 					break;
       
  3249 				case 'http':
       
  3250 					$type = 'message/http';
       
  3251 					break;
       
  3252 				case 'js':
       
  3253 					$type = 'text/javascript';
       
  3254 					break;
       
  3255 				case 'json':
       
  3256 					$type = 'application/json';
       
  3257 					break;
       
  3258 				case 'jsx':
       
  3259 					$type = 'text/jsx';
       
  3260 					break;
       
  3261 				case 'less':
       
  3262 					$type = 'text/x-less';
       
  3263 					break;
       
  3264 				case 'md':
       
  3265 					$type = 'text/x-gfm';
       
  3266 					break;
       
  3267 				case 'php':
       
  3268 				case 'phtml':
       
  3269 				case 'php3':
       
  3270 				case 'php4':
       
  3271 				case 'php5':
       
  3272 				case 'php7':
       
  3273 				case 'phps':
       
  3274 					$type = 'application/x-httpd-php';
       
  3275 					break;
       
  3276 				case 'scss':
       
  3277 					$type = 'text/x-scss';
       
  3278 					break;
       
  3279 				case 'sass':
       
  3280 					$type = 'text/x-sass';
       
  3281 					break;
       
  3282 				case 'sh':
       
  3283 				case 'bash':
       
  3284 					$type = 'text/x-sh';
       
  3285 					break;
       
  3286 				case 'sql':
       
  3287 					$type = 'text/x-sql';
       
  3288 					break;
       
  3289 				case 'svg':
       
  3290 					$type = 'application/svg+xml';
       
  3291 					break;
       
  3292 				case 'xml':
       
  3293 					$type = 'text/xml';
       
  3294 					break;
       
  3295 				case 'yml':
       
  3296 				case 'yaml':
       
  3297 					$type = 'text/x-yaml';
       
  3298 					break;
       
  3299 				case 'txt':
       
  3300 				default:
       
  3301 					$type = 'text/plain';
       
  3302 					break;
       
  3303 			}
       
  3304 		}
       
  3305 	}
       
  3306 
       
  3307 	if ( 'text/css' === $type ) {
       
  3308 		$settings['codemirror'] = array_merge( $settings['codemirror'], array(
       
  3309 			'mode' => 'css',
       
  3310 			'lint' => true,
       
  3311 			'autoCloseBrackets' => true,
       
  3312 			'matchBrackets' => true,
       
  3313 		) );
       
  3314 	} elseif ( 'text/x-scss' === $type || 'text/x-less' === $type || 'text/x-sass' === $type ) {
       
  3315 		$settings['codemirror'] = array_merge( $settings['codemirror'], array(
       
  3316 			'mode' => $type,
       
  3317 			'lint' => false,
       
  3318 			'autoCloseBrackets' => true,
       
  3319 			'matchBrackets' => true,
       
  3320 		) );
       
  3321 	} elseif ( 'text/x-diff' === $type ) {
       
  3322 		$settings['codemirror'] = array_merge( $settings['codemirror'], array(
       
  3323 			'mode' => 'diff',
       
  3324 		) );
       
  3325 	} elseif ( 'text/html' === $type ) {
       
  3326 		$settings['codemirror'] = array_merge( $settings['codemirror'], array(
       
  3327 			'mode' => 'htmlmixed',
       
  3328 			'lint' => true,
       
  3329 			'autoCloseBrackets' => true,
       
  3330 			'autoCloseTags' => true,
       
  3331 			'matchTags' => array(
       
  3332 				'bothTags' => true,
       
  3333 			),
       
  3334 		) );
       
  3335 
       
  3336 		if ( ! current_user_can( 'unfiltered_html' ) ) {
       
  3337 			$settings['htmlhint']['kses'] = wp_kses_allowed_html( 'post' );
       
  3338 		}
       
  3339 	} elseif ( 'text/x-gfm' === $type ) {
       
  3340 		$settings['codemirror'] = array_merge( $settings['codemirror'], array(
       
  3341 			'mode' => 'gfm',
       
  3342 			'highlightFormatting' => true,
       
  3343 		) );
       
  3344 	} elseif ( 'application/javascript' === $type || 'text/javascript' === $type ) {
       
  3345 		$settings['codemirror'] = array_merge( $settings['codemirror'], array(
       
  3346 			'mode' => 'javascript',
       
  3347 			'lint' => true,
       
  3348 			'autoCloseBrackets' => true,
       
  3349 			'matchBrackets' => true,
       
  3350 		) );
       
  3351 	} elseif ( false !== strpos( $type, 'json' ) ) {
       
  3352 		$settings['codemirror'] = array_merge( $settings['codemirror'], array(
       
  3353 			'mode' => array(
       
  3354 				'name' => 'javascript',
       
  3355 			),
       
  3356 			'lint' => true,
       
  3357 			'autoCloseBrackets' => true,
       
  3358 			'matchBrackets' => true,
       
  3359 		) );
       
  3360 		if ( 'application/ld+json' === $type ) {
       
  3361 			$settings['codemirror']['mode']['jsonld'] = true;
       
  3362 		} else {
       
  3363 			$settings['codemirror']['mode']['json'] = true;
       
  3364 		}
       
  3365 	} elseif ( false !== strpos( $type, 'jsx' ) ) {
       
  3366 		$settings['codemirror'] = array_merge( $settings['codemirror'], array(
       
  3367 			'mode' => 'jsx',
       
  3368 			'autoCloseBrackets' => true,
       
  3369 			'matchBrackets' => true,
       
  3370 		) );
       
  3371 	} elseif ( 'text/x-markdown' === $type ) {
       
  3372 		$settings['codemirror'] = array_merge( $settings['codemirror'], array(
       
  3373 			'mode' => 'markdown',
       
  3374 			'highlightFormatting' => true,
       
  3375 		) );
       
  3376 	} elseif ( 'text/nginx' === $type ) {
       
  3377 		$settings['codemirror'] = array_merge( $settings['codemirror'], array(
       
  3378 			'mode' => 'nginx',
       
  3379 		) );
       
  3380 	} elseif ( 'application/x-httpd-php' === $type ) {
       
  3381 		$settings['codemirror'] = array_merge( $settings['codemirror'], array(
       
  3382 			'mode' => 'php',
       
  3383 			'autoCloseBrackets' => true,
       
  3384 			'autoCloseTags' => true,
       
  3385 			'matchBrackets' => true,
       
  3386 			'matchTags' => array(
       
  3387 				'bothTags' => true,
       
  3388 			),
       
  3389 		) );
       
  3390 	} elseif ( 'text/x-sql' === $type || 'text/x-mysql' === $type ) {
       
  3391 		$settings['codemirror'] = array_merge( $settings['codemirror'], array(
       
  3392 			'mode' => 'sql',
       
  3393 			'autoCloseBrackets' => true,
       
  3394 			'matchBrackets' => true,
       
  3395 		) );
       
  3396 	} elseif ( false !== strpos( $type, 'xml' ) ) {
       
  3397 		$settings['codemirror'] = array_merge( $settings['codemirror'], array(
       
  3398 			'mode' => 'xml',
       
  3399 			'autoCloseBrackets' => true,
       
  3400 			'autoCloseTags' => true,
       
  3401 			'matchTags' => array(
       
  3402 				'bothTags' => true,
       
  3403 			),
       
  3404 		) );
       
  3405 	} elseif ( 'text/x-yaml' === $type ) {
       
  3406 		$settings['codemirror'] = array_merge( $settings['codemirror'], array(
       
  3407 			'mode' => 'yaml',
       
  3408 		) );
       
  3409 	} else {
       
  3410 		$settings['codemirror']['mode'] = $type;
       
  3411 	}
       
  3412 
       
  3413 	if ( ! empty( $settings['codemirror']['lint'] ) ) {
       
  3414 		$settings['codemirror']['gutters'][] = 'CodeMirror-lint-markers';
       
  3415 	}
       
  3416 
       
  3417 	// Let settings supplied via args override any defaults.
       
  3418 	foreach ( wp_array_slice_assoc( $args, array( 'codemirror', 'csslint', 'jshint', 'htmlhint' ) ) as $key => $value ) {
       
  3419 		$settings[ $key ] = array_merge(
       
  3420 			$settings[ $key ],
       
  3421 			$value
       
  3422 		);
       
  3423 	}
       
  3424 
       
  3425 	/**
       
  3426 	 * Filters settings that are passed into the code editor.
       
  3427 	 *
       
  3428 	 * Returning a falsey value will disable the syntax-highlighting code editor.
       
  3429 	 *
       
  3430 	 * @since 4.9.0
       
  3431 	 *
       
  3432 	 * @param array $settings The array of settings passed to the code editor. A falsey value disables the editor.
       
  3433 	 * @param array $args {
       
  3434 	 *     Args passed when calling `wp_enqueue_code_editor()`.
       
  3435 	 *
       
  3436 	 *     @type string   $type       The MIME type of the file to be edited.
       
  3437 	 *     @type string   $file       Filename being edited.
       
  3438 	 *     @type WP_Theme $theme      Theme being edited when on theme editor.
       
  3439 	 *     @type string   $plugin     Plugin being edited when on plugin editor.
       
  3440 	 *     @type array    $codemirror Additional CodeMirror setting overrides.
       
  3441 	 *     @type array    $csslint    CSSLint rule overrides.
       
  3442 	 *     @type array    $jshint     JSHint rule overrides.
       
  3443 	 *     @type array    $htmlhint   JSHint rule overrides.
       
  3444 	 * }
       
  3445 	 */
       
  3446 	$settings = 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 }
       
  3510 
       
  3511 /**
       
  3512  * Retrieves the contents of the search WordPress query variable.
       
  3513  *
       
  3514  * The search query string is passed through esc_attr() to ensure that it is safe
       
  3515  * for placing in an html attribute.
  2468  *
  3516  *
  2469  * @since 2.3.0
  3517  * @since 2.3.0
  2470  *
  3518  *
  2471  * @param bool $escaped Whether the result is escaped. Default true.
  3519  * @param bool $escaped Whether the result is escaped. Default true.
  2472  * 	Only use when you are later escaping it. Do not use unescaped.
  3520  * 	                    Only use when you are later escaping it. Do not use unescaped.
  2473  * @return string
  3521  * @return string
  2474  */
  3522  */
  2475 function get_search_query( $escaped = true ) {
  3523 function get_search_query( $escaped = true ) {
  2476 	/**
  3524 	/**
  2477 	 * Filter the contents of the search query variable.
  3525 	 * Filters the contents of the search query variable.
  2478 	 *
  3526 	 *
  2479 	 * @since 2.3.0
  3527 	 * @since 2.3.0
  2480 	 *
  3528 	 *
  2481 	 * @param mixed $search Contents of the search query variable.
  3529 	 * @param mixed $search Contents of the search query variable.
  2482 	 */
  3530 	 */
  2486 		$query = esc_attr( $query );
  3534 		$query = esc_attr( $query );
  2487 	return $query;
  3535 	return $query;
  2488 }
  3536 }
  2489 
  3537 
  2490 /**
  3538 /**
  2491  * Display the contents of the search query variable.
  3539  * Displays the contents of the search query variable.
  2492  *
  3540  *
  2493  * The search query string is passed through {@link esc_attr()}
  3541  * The search query string is passed through esc_attr() to ensure that it is safe
  2494  * to ensure that it is safe for placing in an html attribute.
  3542  * for placing in an html attribute.
  2495  *
  3543  *
  2496  * @since 2.1.0
  3544  * @since 2.1.0
  2497  */
  3545  */
  2498 function the_search_query() {
  3546 function the_search_query() {
  2499 	/**
  3547 	/**
  2500 	 * Filter the contents of the search query variable for display.
  3548 	 * Filters the contents of the search query variable for display.
  2501 	 *
  3549 	 *
  2502 	 * @since 2.3.0
  3550 	 * @since 2.3.0
  2503 	 *
  3551 	 *
  2504 	 * @param mixed $search Contents of the search query variable.
  3552 	 * @param mixed $search Contents of the search query variable.
  2505 	 */
  3553 	 */
  2506 	echo esc_attr( apply_filters( 'the_search_query', get_search_query( false ) ) );
  3554 	echo esc_attr( apply_filters( 'the_search_query', get_search_query( false ) ) );
  2507 }
  3555 }
  2508 
  3556 
  2509 /**
  3557 /**
  2510  * Display the language attributes for the html tag.
  3558  * Gets the language attributes for the html tag.
  2511  *
  3559  *
  2512  * Builds up a set of html attributes containing the text direction and language
  3560  * Builds up a set of html attributes containing the text direction and language
  2513  * information for the page.
  3561  * information for the page.
  2514  *
  3562  *
  2515  * @since 2.1.0
  3563  * @since 4.3.0
  2516  *
  3564  *
  2517  * @param string $doctype The type of html document (xhtml|html).
  3565  * @param string $doctype Optional. The type of html document. Accepts 'xhtml' or 'html'. Default 'html'.
  2518  */
  3566  */
  2519 function language_attributes($doctype = 'html') {
  3567 function get_language_attributes( $doctype = 'html' ) {
  2520 	$attributes = array();
  3568 	$attributes = array();
  2521 
  3569 
  2522 	if ( function_exists( 'is_rtl' ) && is_rtl() )
  3570 	if ( function_exists( 'is_rtl' ) && is_rtl() )
  2523 		$attributes[] = 'dir="rtl"';
  3571 		$attributes[] = 'dir="rtl"';
  2524 
  3572 
  2525 	if ( $lang = get_bloginfo('language') ) {
  3573 	if ( $lang = get_bloginfo( 'language' ) ) {
  2526 		if ( get_option('html_type') == 'text/html' || $doctype == 'html' )
  3574 		if ( get_option( 'html_type' ) == 'text/html' || $doctype == 'html' ) {
  2527 			$attributes[] = "lang=\"$lang\"";
  3575 			$attributes[] = 'lang="' . esc_attr( $lang ) . '"';
  2528 
  3576 		}
  2529 		if ( get_option('html_type') != 'text/html' || $doctype == 'xhtml' )
  3577 
  2530 			$attributes[] = "xml:lang=\"$lang\"";
  3578 		if ( get_option( 'html_type' ) != 'text/html' || $doctype == 'xhtml' ) {
       
  3579 			$attributes[] = 'xml:lang="' . esc_attr( $lang ) . '"';
       
  3580 		}
  2531 	}
  3581 	}
  2532 
  3582 
  2533 	$output = implode(' ', $attributes);
  3583 	$output = implode(' ', $attributes);
  2534 
  3584 
  2535 	/**
  3585 	/**
  2536 	 * Filter the language attributes for display in the html tag.
  3586 	 * Filters the language attributes for display in the html tag.
  2537 	 *
  3587 	 *
  2538 	 * @since 2.5.0
  3588 	 * @since 2.5.0
       
  3589 	 * @since 4.3.0 Added the `$doctype` parameter.
  2539 	 *
  3590 	 *
  2540 	 * @param string $output A space-separated list of language attributes.
  3591 	 * @param string $output A space-separated list of language attributes.
  2541 	 */
  3592 	 * @param string $doctype The type of html document (xhtml|html).
  2542 	echo apply_filters( 'language_attributes', $output );
  3593 	 */
       
  3594 	return apply_filters( 'language_attributes', $output, $doctype );
       
  3595 }
       
  3596 
       
  3597 /**
       
  3598  * Displays the language attributes for the html tag.
       
  3599  *
       
  3600  * Builds up a set of html attributes containing the text direction and language
       
  3601  * information for the page.
       
  3602  *
       
  3603  * @since 2.1.0
       
  3604  * @since 4.3.0 Converted into a wrapper for get_language_attributes().
       
  3605  *
       
  3606  * @param string $doctype Optional. The type of html document. Accepts 'xhtml' or 'html'. Default 'html'.
       
  3607  */
       
  3608 function language_attributes( $doctype = 'html' ) {
       
  3609 	echo get_language_attributes( $doctype );
  2543 }
  3610 }
  2544 
  3611 
  2545 /**
  3612 /**
  2546  * Retrieve paginated link for archive post pages.
  3613  * Retrieve paginated link for archive post pages.
  2547  *
  3614  *
  2578  * arguments. The 'end_size' argument is how many numbers on either the start
  3645  * arguments. The 'end_size' argument is how many numbers on either the start
  2579  * and the end list edges, by default is 1. The 'mid_size' argument is how many
  3646  * and the end list edges, by default is 1. The 'mid_size' argument is how many
  2580  * numbers to either side of current page, but not including current page.
  3647  * numbers to either side of current page, but not including current page.
  2581  *
  3648  *
  2582  * It is possible to add query vars to the link by using the 'add_args' argument
  3649  * It is possible to add query vars to the link by using the 'add_args' argument
  2583  * and see {@link add_query_arg()} for more information.
  3650  * and see add_query_arg() for more information.
  2584  *
  3651  *
  2585  * The 'before_page_number' and 'after_page_number' arguments allow users to
  3652  * The 'before_page_number' and 'after_page_number' arguments allow users to
  2586  * augment the links themselves. Typically this might be to add context to the
  3653  * augment the links themselves. Typically this might be to add context to the
  2587  * numbered links so that screen reader users understand what the links are for.
  3654  * numbered links so that screen reader users understand what the links are for.
  2588  * The text strings are added before and after the page number - within the
  3655  * The text strings are added before and after the page number - within the
  2589  * anchor tag.
  3656  * anchor tag.
  2590  *
  3657  *
  2591  * @since 2.1.0
  3658  * @since 2.1.0
       
  3659  * @since 4.9.0 Added the `aria_current` argument.
       
  3660  *
       
  3661  * @global WP_Query   $wp_query
       
  3662  * @global WP_Rewrite $wp_rewrite
  2592  *
  3663  *
  2593  * @param string|array $args {
  3664  * @param string|array $args {
  2594  *     Optional. Array or string of arguments for generating paginated links for archives.
  3665  *     Optional. Array or string of arguments for generating paginated links for archives.
  2595  *
  3666  *
  2596  *     @type string $base               Base of the paginated url. Default empty.
  3667  *     @type string $base               Base of the paginated url. Default empty.
  2597  *     @type string $format             Format for the pagination structure. Default empty.
  3668  *     @type string $format             Format for the pagination structure. Default empty.
  2598  *     @type int    $total              The total amount of pages. Default is the value WP_Query's
  3669  *     @type int    $total              The total amount of pages. Default is the value WP_Query's
  2599  *                                      `max_num_pages` or 1.
  3670  *                                      `max_num_pages` or 1.
  2600  *     @type int    $current            The current page number. Default is 'paged' query var or 1.
  3671  *     @type int    $current            The current page number. Default is 'paged' query var or 1.
       
  3672  *     @type string $aria_current       The value for the aria-current attribute. Possible values are 'page',
       
  3673  *                                      'step', 'location', 'date', 'time', 'true', 'false'. Default is 'page'.
  2601  *     @type bool   $show_all           Whether to show all pages. Default false.
  3674  *     @type bool   $show_all           Whether to show all pages. Default false.
  2602  *     @type int    $end_size           How many numbers on either the start and the end list edges.
  3675  *     @type int    $end_size           How many numbers on either the start and the end list edges.
  2603  *                                      Default 1.
  3676  *                                      Default 1.
  2604  *     @type int    $mid_size           How many numbers to either side of the current pages. Default 2.
  3677  *     @type int    $mid_size           How many numbers to either side of the current pages. Default 2.
  2605  *     @type bool   $prev_next          Whether to include the previous and next links in the list. Default true.
  3678  *     @type bool   $prev_next          Whether to include the previous and next links in the list. Default true.
  2606  *     @type bool   $prev_text          The previous page text. Default '« Previous'.
  3679  *     @type bool   $prev_text          The previous page text. Default '&laquo; Previous'.
  2607  *     @type bool   $next_text          The next page text. Default '« Previous'.
  3680  *     @type bool   $next_text          The next page text. Default 'Next &raquo;'.
  2608  *     @type string $type               Controls format of the returned value. Possible values are 'plain',
  3681  *     @type string $type               Controls format of the returned value. Possible values are 'plain',
  2609  *                                      'array' and 'list'. Default is 'plain'.
  3682  *                                      'array' and 'list'. Default is 'plain'.
  2610  *     @type array  $add_args           An array of query args to add. Default false.
  3683  *     @type array  $add_args           An array of query args to add. Default false.
  2611  *     @type string $add_fragment       A string to append to each link. Default empty.
  3684  *     @type string $add_fragment       A string to append to each link. Default empty.
  2612  *     @type string $before_page_number A string to appear before the page number. Default empty.
  3685  *     @type string $before_page_number A string to appear before the page number. Default empty.
  2613  *     @type string $after_page_number  A string to append after the page number. Default empty.
  3686  *     @type string $after_page_number  A string to append after the page number. Default empty.
  2614  * }
  3687  * }
  2615  * @return array|string String of page links or array of page links.
  3688  * @return array|string|void String of page links or array of page links.
  2616  */
  3689  */
  2617 function paginate_links( $args = '' ) {
  3690 function paginate_links( $args = '' ) {
  2618 	global $wp_query, $wp_rewrite;
  3691 	global $wp_query, $wp_rewrite;
  2619 
  3692 
  2620 	// Setting up default values based on the current URL.
  3693 	// Setting up default values based on the current URL.
  2631 	// URL base depends on permalink settings.
  3704 	// URL base depends on permalink settings.
  2632 	$format  = $wp_rewrite->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : '';
  3705 	$format  = $wp_rewrite->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : '';
  2633 	$format .= $wp_rewrite->using_permalinks() ? user_trailingslashit( $wp_rewrite->pagination_base . '/%#%', 'paged' ) : '?paged=%#%';
  3706 	$format .= $wp_rewrite->using_permalinks() ? user_trailingslashit( $wp_rewrite->pagination_base . '/%#%', 'paged' ) : '?paged=%#%';
  2634 
  3707 
  2635 	$defaults = array(
  3708 	$defaults = array(
  2636 		'base' => $pagenum_link, // http://example.com/all_posts.php%_% : %_% is replaced by format (below)
  3709 		'base'               => $pagenum_link, // http://example.com/all_posts.php%_% : %_% is replaced by format (below)
  2637 		'format' => $format, // ?page=%#% : %#% is replaced by the page number
  3710 		'format'             => $format, // ?page=%#% : %#% is replaced by the page number
  2638 		'total' => $total,
  3711 		'total'              => $total,
  2639 		'current' => $current,
  3712 		'current'            => $current,
  2640 		'show_all' => false,
  3713 		'aria_current'       => 'page',
  2641 		'prev_next' => true,
  3714 		'show_all'           => false,
  2642 		'prev_text' => __('&laquo; Previous'),
  3715 		'prev_next'          => true,
  2643 		'next_text' => __('Next &raquo;'),
  3716 		'prev_text'          => __( '&laquo; Previous' ),
  2644 		'end_size' => 1,
  3717 		'next_text'          => __( 'Next &raquo;' ),
  2645 		'mid_size' => 2,
  3718 		'end_size'           => 1,
  2646 		'type' => 'plain',
  3719 		'mid_size'           => 2,
  2647 		'add_args' => array(), // array of query args to add
  3720 		'type'               => 'plain',
  2648 		'add_fragment' => '',
  3721 		'add_args'           => array(), // array of query args to add
       
  3722 		'add_fragment'       => '',
  2649 		'before_page_number' => '',
  3723 		'before_page_number' => '',
  2650 		'after_page_number' => ''
  3724 		'after_page_number'  => '',
  2651 	);
  3725 	);
  2652 
  3726 
  2653 	$args = wp_parse_args( $args, $defaults );
  3727 	$args = wp_parse_args( $args, $defaults );
  2654 
  3728 
  2655 	if ( ! is_array( $args['add_args'] ) ) {
  3729 	if ( ! is_array( $args['add_args'] ) ) {
  2657 	}
  3731 	}
  2658 
  3732 
  2659 	// Merge additional query vars found in the original URL into 'add_args' array.
  3733 	// Merge additional query vars found in the original URL into 'add_args' array.
  2660 	if ( isset( $url_parts[1] ) ) {
  3734 	if ( isset( $url_parts[1] ) ) {
  2661 		// Find the format argument.
  3735 		// Find the format argument.
  2662 		$format_query = parse_url( str_replace( '%_%', $args['format'], $args['base'] ), PHP_URL_QUERY );
  3736 		$format = explode( '?', str_replace( '%_%', $args['format'], $args['base'] ) );
  2663 		wp_parse_str( $format_query, $format_arg );
  3737 		$format_query = isset( $format[1] ) ? $format[1] : '';
       
  3738 		wp_parse_str( $format_query, $format_args );
       
  3739 
       
  3740 		// Find the query args of the requested URL.
       
  3741 		wp_parse_str( $url_parts[1], $url_query_args );
  2664 
  3742 
  2665 		// Remove the format argument from the array of query arguments, to avoid overwriting custom format.
  3743 		// Remove the format argument from the array of query arguments, to avoid overwriting custom format.
  2666 		wp_parse_str( remove_query_arg( array_keys( $format_arg ), $url_parts[1] ), $query_args );
  3744 		foreach ( $format_args as $format_arg => $format_arg_value ) {
  2667 		$args['add_args'] = array_merge( $args['add_args'], urlencode_deep( $query_args ) );
  3745 			unset( $url_query_args[ $format_arg ] );
       
  3746 		}
       
  3747 
       
  3748 		$args['add_args'] = array_merge( $args['add_args'], urlencode_deep( $url_query_args ) );
  2668 	}
  3749 	}
  2669 
  3750 
  2670 	// Who knows what else people pass in $args
  3751 	// Who knows what else people pass in $args
  2671 	$total = (int) $args['total'];
  3752 	$total = (int) $args['total'];
  2672 	if ( $total < 2 ) {
  3753 	if ( $total < 2 ) {
  2692 		if ( $add_args )
  3773 		if ( $add_args )
  2693 			$link = add_query_arg( $add_args, $link );
  3774 			$link = add_query_arg( $add_args, $link );
  2694 		$link .= $args['add_fragment'];
  3775 		$link .= $args['add_fragment'];
  2695 
  3776 
  2696 		/**
  3777 		/**
  2697 		 * Filter the paginated links for the given archive pages.
  3778 		 * Filters the paginated links for the given archive pages.
  2698 		 *
  3779 		 *
  2699 		 * @since 3.0.0
  3780 		 * @since 3.0.0
  2700 		 *
  3781 		 *
  2701 		 * @param string $link The paginated link URL.
  3782 		 * @param string $link The paginated link URL.
  2702 		 */
  3783 		 */
  2703 		$page_links[] = '<a class="prev page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $args['prev_text'] . '</a>';
  3784 		$page_links[] = '<a class="prev page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $args['prev_text'] . '</a>';
  2704 	endif;
  3785 	endif;
  2705 	for ( $n = 1; $n <= $total; $n++ ) :
  3786 	for ( $n = 1; $n <= $total; $n++ ) :
  2706 		if ( $n == $current ) :
  3787 		if ( $n == $current ) :
  2707 			$page_links[] = "<span class='page-numbers current'>" . $args['before_page_number'] . number_format_i18n( $n ) . $args['after_page_number'] . "</span>";
  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>";
  2708 			$dots = true;
  3789 			$dots = true;
  2709 		else :
  3790 		else :
  2710 			if ( $args['show_all'] || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) :
  3791 			if ( $args['show_all'] || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) :
  2711 				$link = str_replace( '%_%', 1 == $n ? '' : $args['format'], $args['base'] );
  3792 				$link = str_replace( '%_%', 1 == $n ? '' : $args['format'], $args['base'] );
  2712 				$link = str_replace( '%#%', $n, $link );
  3793 				$link = str_replace( '%#%', $n, $link );
  2721 				$page_links[] = '<span class="page-numbers dots">' . __( '&hellip;' ) . '</span>';
  3802 				$page_links[] = '<span class="page-numbers dots">' . __( '&hellip;' ) . '</span>';
  2722 				$dots = false;
  3803 				$dots = false;
  2723 			endif;
  3804 			endif;
  2724 		endif;
  3805 		endif;
  2725 	endfor;
  3806 	endfor;
  2726 	if ( $args['prev_next'] && $current && ( $current < $total || -1 == $total ) ) :
  3807 	if ( $args['prev_next'] && $current && $current < $total ) :
  2727 		$link = str_replace( '%_%', $args['format'], $args['base'] );
  3808 		$link = str_replace( '%_%', $args['format'], $args['base'] );
  2728 		$link = str_replace( '%#%', $current + 1, $link );
  3809 		$link = str_replace( '%#%', $current + 1, $link );
  2729 		if ( $add_args )
  3810 		if ( $add_args )
  2730 			$link = add_query_arg( $add_args, $link );
  3811 			$link = add_query_arg( $add_args, $link );
  2731 		$link .= $args['add_fragment'];
  3812 		$link .= $args['add_fragment'];
  2759  *         '#07273E', '#14568A', '#D54E21', '#2683AE'
  3840  *         '#07273E', '#14568A', '#D54E21', '#2683AE'
  2760  *     ) );
  3841  *     ) );
  2761  *
  3842  *
  2762  * @since 2.5.0
  3843  * @since 2.5.0
  2763  *
  3844  *
  2764  * @todo Properly document optional arguments as such
  3845  * @global array $_wp_admin_css_colors
  2765  *
  3846  *
  2766  * @param string $key The unique key for this theme.
  3847  * @param string $key    The unique key for this theme.
  2767  * @param string $name The name of the theme.
  3848  * @param string $name   The name of the theme.
  2768  * @param string $url The url of the css file containing the colour scheme.
  3849  * @param string $url    The URL of the CSS file containing the color scheme.
  2769  * @param array $colors Optional An array of CSS color definitions which are used to give the user a feel for the theme.
  3850  * @param array  $colors Optional. An array of CSS color definition strings which are used
  2770  * @param array $icons Optional An array of CSS color definitions used to color any SVG icons
  3851  *                       to give the user a feel for the theme.
       
  3852  * @param array  $icons {
       
  3853  *     Optional. CSS color definitions used to color any SVG icons.
       
  3854  *
       
  3855  *     @type string $base    SVG icon base color.
       
  3856  *     @type string $focus   SVG icon color on focus.
       
  3857  *     @type string $current SVG icon color of current admin menu link.
       
  3858  * }
  2771  */
  3859  */
  2772 function wp_admin_css_color( $key, $name, $url, $colors = array(), $icons = array() ) {
  3860 function wp_admin_css_color( $key, $name, $url, $colors = array(), $icons = array() ) {
  2773 	global $_wp_admin_css_colors;
  3861 	global $_wp_admin_css_colors;
  2774 
  3862 
  2775 	if ( !isset($_wp_admin_css_colors) )
  3863 	if ( !isset($_wp_admin_css_colors) )
  2788  *
  3876  *
  2789  * @since 3.0.0
  3877  * @since 3.0.0
  2790  */
  3878  */
  2791 function register_admin_color_schemes() {
  3879 function register_admin_color_schemes() {
  2792 	$suffix = is_rtl() ? '-rtl' : '';
  3880 	$suffix = is_rtl() ? '-rtl' : '';
  2793 	$suffix .= defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
  3881 	$suffix .= SCRIPT_DEBUG ? '' : '.min';
  2794 
  3882 
  2795 	wp_admin_css_color( 'fresh', _x( 'Default', 'admin color scheme' ),
  3883 	wp_admin_css_color( 'fresh', _x( 'Default', 'admin color scheme' ),
  2796 		false,
  3884 		false,
  2797 		array( '#222', '#333', '#0073aa', '#00a0d2' ),
  3885 		array( '#222', '#333', '#0073aa', '#00a0d2' ),
  2798 		array( 'base' => '#999', 'focus' => '#00a0d2', 'current' => '#fff' )
  3886 		array( 'base' => '#82878c', 'focus' => '#00a0d2', 'current' => '#fff' )
  2799 	);
  3887 	);
  2800 
  3888 
  2801 	// Other color schemes are not available when running out of src
  3889 	// Other color schemes are not available when running out of src
  2802 	if ( false !== strpos( $GLOBALS['wp_version'], '-src' ) )
  3890 	if ( false !== strpos( get_bloginfo( 'version' ), '-src' ) ) {
  2803 		return;
  3891 		return;
       
  3892 	}
  2804 
  3893 
  2805 	wp_admin_css_color( 'light', _x( 'Light', 'admin color scheme' ),
  3894 	wp_admin_css_color( 'light', _x( 'Light', 'admin color scheme' ),
  2806 		admin_url( "css/colors/light/colors$suffix.css" ),
  3895 		admin_url( "css/colors/light/colors$suffix.css" ),
  2807 		array( '#e5e5e5', '#999', '#d64e07', '#04a4cc' ),
  3896 		array( '#e5e5e5', '#999', '#d64e07', '#04a4cc' ),
  2808 		array( 'base' => '#999', 'focus' => '#ccc', 'current' => '#ccc' )
  3897 		array( 'base' => '#999', 'focus' => '#ccc', 'current' => '#ccc' )
  2845 	);
  3934 	);
  2846 
  3935 
  2847 }
  3936 }
  2848 
  3937 
  2849 /**
  3938 /**
  2850  * Display the URL of a WordPress admin CSS file.
  3939  * Displays the URL of a WordPress admin CSS file.
  2851  *
  3940  *
  2852  * @see WP_Styles::_css_href and its style_loader_src filter.
  3941  * @see WP_Styles::_css_href and its {@see 'style_loader_src'} filter.
  2853  *
  3942  *
  2854  * @since 2.3.0
  3943  * @since 2.3.0
  2855  *
  3944  *
  2856  * @param string $file file relative to wp-admin/ without its ".css" extension.
  3945  * @param string $file file relative to wp-admin/ without its ".css" extension.
       
  3946  * @return string
  2857  */
  3947  */
  2858 function wp_admin_css_uri( $file = 'wp-admin' ) {
  3948 function wp_admin_css_uri( $file = 'wp-admin' ) {
  2859 	if ( defined('WP_INSTALLING') ) {
  3949 	if ( defined('WP_INSTALLING') ) {
  2860 		$_file = "./$file.css";
  3950 		$_file = "./$file.css";
  2861 	} else {
  3951 	} else {
  2862 		$_file = admin_url("$file.css");
  3952 		$_file = admin_url("$file.css");
  2863 	}
  3953 	}
  2864 	$_file = add_query_arg( 'version', get_bloginfo( 'version' ),  $_file );
  3954 	$_file = add_query_arg( 'version', get_bloginfo( 'version' ),  $_file );
  2865 
  3955 
  2866 	/**
  3956 	/**
  2867 	 * Filter the URI of a WordPress admin CSS file.
  3957 	 * Filters the URI of a WordPress admin CSS file.
  2868 	 *
  3958 	 *
  2869 	 * @since 2.3.0
  3959 	 * @since 2.3.0
  2870 	 *
  3960 	 *
  2871 	 * @param string $_file Relative path to the file with query arguments attached.
  3961 	 * @param string $_file Relative path to the file with query arguments attached.
  2872 	 * @param string $file  Relative path to the file, minus its ".css" extension.
  3962 	 * @param string $file  Relative path to the file, minus its ".css" extension.
  2876 
  3966 
  2877 /**
  3967 /**
  2878  * Enqueues or directly prints a stylesheet link to the specified CSS file.
  3968  * Enqueues or directly prints a stylesheet link to the specified CSS file.
  2879  *
  3969  *
  2880  * "Intelligently" decides to enqueue or to print the CSS file. If the
  3970  * "Intelligently" decides to enqueue or to print the CSS file. If the
  2881  * 'wp_print_styles' action has *not* yet been called, the CSS file will be
  3971  * {@see 'wp_print_styles'} action has *not* yet been called, the CSS file will be
  2882  * enqueued. If the wp_print_styles action *has* been called, the CSS link will
  3972  * enqueued. If the {@see 'wp_print_styles'} action has been called, the CSS link will
  2883  * be printed. Printing may be forced by passing true as the $force_echo
  3973  * be printed. Printing may be forced by passing true as the $force_echo
  2884  * (second) parameter.
  3974  * (second) parameter.
  2885  *
  3975  *
  2886  * For backward compatibility with WordPress 2.3 calling method: If the $file
  3976  * For backward compatibility with WordPress 2.3 calling method: If the $file
  2887  * (first) parameter does not correspond to a registered CSS file, we assume
  3977  * (first) parameter does not correspond to a registered CSS file, we assume
  2888  * $file is a file relative to wp-admin/ without its ".css" extension. A
  3978  * $file is a file relative to wp-admin/ without its ".css" extension. A
  2889  * stylesheet link to that generated URL is printed.
  3979  * stylesheet link to that generated URL is printed.
  2890  *
  3980  *
  2891  * @since 2.3.0
  3981  * @since 2.3.0
  2892  * @uses $wp_styles WordPress Styles Object
  3982  *
  2893  *
  3983  * @param string $file       Optional. Style handle name or file name (without ".css" extension) relative
  2894  * @param string $file Optional. Style handle name or file name (without ".css" extension) relative
  3984  * 	                         to wp-admin/. Defaults to 'wp-admin'.
  2895  * 	 to wp-admin/. Defaults to 'wp-admin'.
  3985  * @param bool   $force_echo Optional. Force the stylesheet link to be printed rather than enqueued.
  2896  * @param bool $force_echo Optional. Force the stylesheet link to be printed rather than enqueued.
       
  2897  */
  3986  */
  2898 function wp_admin_css( $file = 'wp-admin', $force_echo = false ) {
  3987 function wp_admin_css( $file = 'wp-admin', $force_echo = false ) {
  2899 	global $wp_styles;
       
  2900 	if ( ! ( $wp_styles instanceof WP_Styles ) ) {
       
  2901 		$wp_styles = new WP_Styles();
       
  2902 	}
       
  2903 
       
  2904 	// For backward compatibility
  3988 	// For backward compatibility
  2905 	$handle = 0 === strpos( $file, 'css/' ) ? substr( $file, 4 ) : $file;
  3989 	$handle = 0 === strpos( $file, 'css/' ) ? substr( $file, 4 ) : $file;
  2906 
  3990 
  2907 	if ( $wp_styles->query( $handle ) ) {
  3991 	if ( wp_styles()->query( $handle ) ) {
  2908 		if ( $force_echo || did_action( 'wp_print_styles' ) ) // we already printed the style queue. Print this one immediately
  3992 		if ( $force_echo || did_action( 'wp_print_styles' ) ) // we already printed the style queue. Print this one immediately
  2909 			wp_print_styles( $handle );
  3993 			wp_print_styles( $handle );
  2910 		else // Add to style queue
  3994 		else // Add to style queue
  2911 			wp_enqueue_style( $handle );
  3995 			wp_enqueue_style( $handle );
  2912 		return;
  3996 		return;
  2913 	}
  3997 	}
  2914 
  3998 
  2915 	/**
  3999 	/**
  2916 	 * Filter the stylesheet link to the specified CSS file.
  4000 	 * Filters the stylesheet link to the specified CSS file.
  2917 	 *
  4001 	 *
  2918 	 * If the site is set to display right-to-left, the RTL stylesheet link
  4002 	 * If the site is set to display right-to-left, the RTL stylesheet link
  2919 	 * will be used instead.
  4003 	 * will be used instead.
  2920 	 *
  4004 	 *
  2921 	 * @since 2.3.0
  4005 	 * @since 2.3.0
  2922 	 *
  4006 	 * @param string $stylesheet_link HTML link element for the stylesheet.
  2923 	 * @param string $file Style handle name or filename (without ".css" extension)
  4007 	 * @param string $file            Style handle name or filename (without ".css" extension)
  2924 	 *                     relative to wp-admin/. Defaults to 'wp-admin'.
  4008 	 *                                relative to wp-admin/. Defaults to 'wp-admin'.
  2925 	 */
  4009 	 */
  2926 	echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . esc_url( wp_admin_css_uri( $file ) ) . "' type='text/css' />\n", $file );
  4010 	echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . esc_url( wp_admin_css_uri( $file ) ) . "' type='text/css' />\n", $file );
  2927 
  4011 
  2928 	if ( function_exists( 'is_rtl' ) && is_rtl() ) {
  4012 	if ( function_exists( 'is_rtl' ) && is_rtl() ) {
  2929 		/** This filter is documented in wp-includes/general-template.php */
  4013 		/** This filter is documented in wp-includes/general-template.php */
  2947 	if ( is_network_admin() )
  4031 	if ( is_network_admin() )
  2948 		add_action( 'admin_head', '_thickbox_path_admin_subfolder' );
  4032 		add_action( 'admin_head', '_thickbox_path_admin_subfolder' );
  2949 }
  4033 }
  2950 
  4034 
  2951 /**
  4035 /**
  2952  * Display the XHTML generator that is generated on the wp_head hook.
  4036  * Displays the XHTML generator that is generated on the wp_head hook.
       
  4037  *
       
  4038  * See {@see 'wp_head'}.
  2953  *
  4039  *
  2954  * @since 2.5.0
  4040  * @since 2.5.0
  2955  */
  4041  */
  2956 function wp_generator() {
  4042 function wp_generator() {
  2957 	/**
  4043 	/**
  2958 	 * Filter the output of the XHTML generator tag.
  4044 	 * Filters the output of the XHTML generator tag.
  2959 	 *
  4045 	 *
  2960 	 * @since 2.5.0
  4046 	 * @since 2.5.0
  2961 	 *
  4047 	 *
  2962 	 * @param string $generator_type The XHTML generator.
  4048 	 * @param string $generator_type The XHTML generator.
  2963 	 */
  4049 	 */
  2966 
  4052 
  2967 /**
  4053 /**
  2968  * Display the generator XML or Comment for RSS, ATOM, etc.
  4054  * Display the generator XML or Comment for RSS, ATOM, etc.
  2969  *
  4055  *
  2970  * Returns the correct generator type for the requested output format. Allows
  4056  * Returns the correct generator type for the requested output format. Allows
  2971  * for a plugin to filter generators overall the the_generator filter.
  4057  * for a plugin to filter generators overall the {@see 'the_generator'} filter.
  2972  *
  4058  *
  2973  * @since 2.5.0
  4059  * @since 2.5.0
  2974  *
  4060  *
  2975  * @param string $type The type of generator to output - (html|xhtml|atom|rss2|rdf|comment|export).
  4061  * @param string $type The type of generator to output - (html|xhtml|atom|rss2|rdf|comment|export).
  2976  */
  4062  */
  2977 function the_generator( $type ) {
  4063 function the_generator( $type ) {
  2978 	/**
  4064 	/**
  2979 	 * Filter the output of the XHTML generator tag for display.
  4065 	 * Filters the output of the XHTML generator tag for display.
  2980 	 *
  4066 	 *
  2981 	 * @since 2.5.0
  4067 	 * @since 2.5.0
  2982 	 *
  4068 	 *
  2983 	 * @param string $generator_type The generator output.
  4069 	 * @param string $generator_type The generator output.
  2984 	 * @param string $type           The type of generator to output. Accepts 'html',
  4070 	 * @param string $type           The type of generator to output. Accepts 'html',
  2990 /**
  4076 /**
  2991  * Creates the generator XML or Comment for RSS, ATOM, etc.
  4077  * Creates the generator XML or Comment for RSS, ATOM, etc.
  2992  *
  4078  *
  2993  * Returns the correct generator type for the requested output format. Allows
  4079  * Returns the correct generator type for the requested output format. Allows
  2994  * for a plugin to filter generators on an individual basis using the
  4080  * for a plugin to filter generators on an individual basis using the
  2995  * 'get_the_generator_{$type}' filter.
  4081  * {@see 'get_the_generator_$type'} filter.
  2996  *
  4082  *
  2997  * @since 2.5.0
  4083  * @since 2.5.0
  2998  *
  4084  *
  2999  * @param string $type The type of generator to return - (html|xhtml|atom|rss2|rdf|comment|export).
  4085  * @param string $type The type of generator to return - (html|xhtml|atom|rss2|rdf|comment|export).
  3000  * @return string The HTML content for the generator.
  4086  * @return string|void The HTML content for the generator.
  3001  */
  4087  */
  3002 function get_the_generator( $type = '' ) {
  4088 function get_the_generator( $type = '' ) {
  3003 	if ( empty( $type ) ) {
  4089 	if ( empty( $type ) ) {
  3004 
  4090 
  3005 		$current_filter = current_filter();
  4091 		$current_filter = current_filter();
  3026 		}
  4112 		}
  3027 	}
  4113 	}
  3028 
  4114 
  3029 	switch ( $type ) {
  4115 	switch ( $type ) {
  3030 		case 'html':
  4116 		case 'html':
  3031 			$gen = '<meta name="generator" content="WordPress ' . get_bloginfo( 'version' ) . '">';
  4117 			$gen = '<meta name="generator" content="WordPress ' . esc_attr( get_bloginfo( 'version' ) ) . '">';
  3032 			break;
  4118 			break;
  3033 		case 'xhtml':
  4119 		case 'xhtml':
  3034 			$gen = '<meta name="generator" content="WordPress ' . get_bloginfo( 'version' ) . '" />';
  4120 			$gen = '<meta name="generator" content="WordPress ' . esc_attr( get_bloginfo( 'version' ) ) . '" />';
  3035 			break;
  4121 			break;
  3036 		case 'atom':
  4122 		case 'atom':
  3037 			$gen = '<generator uri="http://wordpress.org/" version="' . get_bloginfo_rss( 'version' ) . '">WordPress</generator>';
  4123 			$gen = '<generator uri="https://wordpress.org/" version="' . esc_attr( get_bloginfo_rss( 'version' ) ) . '">WordPress</generator>';
  3038 			break;
  4124 			break;
  3039 		case 'rss2':
  4125 		case 'rss2':
  3040 			$gen = '<generator>http://wordpress.org/?v=' . get_bloginfo_rss( 'version' ) . '</generator>';
  4126 			$gen = '<generator>' . esc_url_raw( 'https://wordpress.org/?v=' . get_bloginfo_rss( 'version' ) ) . '</generator>';
  3041 			break;
  4127 			break;
  3042 		case 'rdf':
  4128 		case 'rdf':
  3043 			$gen = '<admin:generatorAgent rdf:resource="http://wordpress.org/?v=' . get_bloginfo_rss( 'version' ) . '" />';
  4129 			$gen = '<admin:generatorAgent rdf:resource="' . esc_url_raw( 'https://wordpress.org/?v=' . get_bloginfo_rss( 'version' ) ) . '" />';
  3044 			break;
  4130 			break;
  3045 		case 'comment':
  4131 		case 'comment':
  3046 			$gen = '<!-- generator="WordPress/' . get_bloginfo( 'version' ) . '" -->';
  4132 			$gen = '<!-- generator="WordPress/' . esc_attr( get_bloginfo( 'version' ) ) . '" -->';
  3047 			break;
  4133 			break;
  3048 		case 'export':
  4134 		case 'export':
  3049 			$gen = '<!-- generator="WordPress/' . get_bloginfo_rss('version') . '" created="'. date('Y-m-d H:i') . '" -->';
  4135 			$gen = '<!-- generator="WordPress/' . esc_attr( get_bloginfo_rss( 'version' ) ) . '" created="' . date( 'Y-m-d H:i' ) . '" -->';
  3050 			break;
  4136 			break;
  3051 	}
  4137 	}
  3052 
  4138 
  3053 	/**
  4139 	/**
  3054 	 * Filter the HTML for the retrieved generator type.
  4140 	 * Filters the HTML for the retrieved generator type.
  3055 	 *
  4141 	 *
  3056 	 * The dynamic portion of the hook name, `$type`, refers to the generator type.
  4142 	 * The dynamic portion of the hook name, `$type`, refers to the generator type.
  3057 	 *
  4143 	 *
  3058 	 * @since 2.5.0
  4144 	 * @since 2.5.0
  3059 	 *
  4145 	 *
  3060 	 * @param string $gen  The HTML markup output to {@see wp_head()}.
  4146 	 * @param string $gen  The HTML markup output to wp_head().
  3061 	 * @param string $type The type of generator. Accepts 'html', 'xhtml', 'atom',
  4147 	 * @param string $type The type of generator. Accepts 'html', 'xhtml', 'atom',
  3062 	 *                     'rss2', 'rdf', 'comment', 'export'.
  4148 	 *                     'rss2', 'rdf', 'comment', 'export'.
  3063 	 */
  4149 	 */
  3064 	return apply_filters( "get_the_generator_{$type}", $gen, $type );
  4150 	return apply_filters( "get_the_generator_{$type}", $gen, $type );
  3065 }
  4151 }
  3071  *
  4157  *
  3072  * @since 1.0.0
  4158  * @since 1.0.0
  3073  *
  4159  *
  3074  * @param mixed $checked One of the values to compare
  4160  * @param mixed $checked One of the values to compare
  3075  * @param mixed $current (true) The other value to compare if not just true
  4161  * @param mixed $current (true) The other value to compare if not just true
  3076  * @param bool $echo Whether to echo or just return the string
  4162  * @param bool  $echo    Whether to echo or just return the string
  3077  * @return string html attribute or empty string
  4163  * @return string html attribute or empty string
  3078  */
  4164  */
  3079 function checked( $checked, $current = true, $echo = true ) {
  4165 function checked( $checked, $current = true, $echo = true ) {
  3080 	return __checked_selected_helper( $checked, $current, $echo, 'checked' );
  4166 	return __checked_selected_helper( $checked, $current, $echo, 'checked' );
  3081 }
  4167 }
  3086  * Compares the first two arguments and if identical marks as selected
  4172  * Compares the first two arguments and if identical marks as selected
  3087  *
  4173  *
  3088  * @since 1.0.0
  4174  * @since 1.0.0
  3089  *
  4175  *
  3090  * @param mixed $selected One of the values to compare
  4176  * @param mixed $selected One of the values to compare
  3091  * @param mixed $current (true) The other value to compare if not just true
  4177  * @param mixed $current  (true) The other value to compare if not just true
  3092  * @param bool $echo Whether to echo or just return the string
  4178  * @param bool  $echo     Whether to echo or just return the string
  3093  * @return string html attribute or empty string
  4179  * @return string html attribute or empty string
  3094  */
  4180  */
  3095 function selected( $selected, $current = true, $echo = true ) {
  4181 function selected( $selected, $current = true, $echo = true ) {
  3096 	return __checked_selected_helper( $selected, $current, $echo, 'selected' );
  4182 	return __checked_selected_helper( $selected, $current, $echo, 'selected' );
  3097 }
  4183 }
  3102  * Compares the first two arguments and if identical marks as disabled
  4188  * Compares the first two arguments and if identical marks as disabled
  3103  *
  4189  *
  3104  * @since 3.0.0
  4190  * @since 3.0.0
  3105  *
  4191  *
  3106  * @param mixed $disabled One of the values to compare
  4192  * @param mixed $disabled One of the values to compare
  3107  * @param mixed $current (true) The other value to compare if not just true
  4193  * @param mixed $current  (true) The other value to compare if not just true
  3108  * @param bool $echo Whether to echo or just return the string
  4194  * @param bool  $echo     Whether to echo or just return the string
  3109  * @return string html attribute or empty string
  4195  * @return string html attribute or empty string
  3110  */
  4196  */
  3111 function disabled( $disabled, $current = true, $echo = true ) {
  4197 function disabled( $disabled, $current = true, $echo = true ) {
  3112 	return __checked_selected_helper( $disabled, $current, $echo, 'disabled' );
  4198 	return __checked_selected_helper( $disabled, $current, $echo, 'disabled' );
  3113 }
  4199 }
  3114 
  4200 
  3115 /**
  4201 /**
  3116  * Private helper function for checked, selected, and disabled.
  4202  * Outputs the html readonly attribute.
       
  4203  *
       
  4204  * Compares the first two arguments and if identical marks as readonly
       
  4205  *
       
  4206  * @since 4.9.0
       
  4207  *
       
  4208  * @param mixed $readonly One of the values to compare
       
  4209  * @param mixed $current  (true) The other value to compare if not just true
       
  4210  * @param bool  $echo     Whether to echo or just return the string
       
  4211  * @return string html attribute or empty string
       
  4212  */
       
  4213 function readonly( $readonly, $current = true, $echo = true ) {
       
  4214 	return __checked_selected_helper( $readonly, $current, $echo, 'readonly' );
       
  4215 }
       
  4216 
       
  4217 /**
       
  4218  * Private helper function for checked, selected, disabled and readonly.
  3117  *
  4219  *
  3118  * Compares the first two arguments and if identical marks as $type
  4220  * Compares the first two arguments and if identical marks as $type
  3119  *
  4221  *
  3120  * @since 2.8.0
  4222  * @since 2.8.0
  3121  * @access private
  4223  * @access private
  3122  *
  4224  *
  3123  * @param mixed $helper One of the values to compare
  4225  * @param mixed  $helper  One of the values to compare
  3124  * @param mixed $current (true) The other value to compare if not just true
  4226  * @param mixed  $current (true) The other value to compare if not just true
  3125  * @param bool $echo Whether to echo or just return the string
  4227  * @param bool   $echo    Whether to echo or just return the string
  3126  * @param string $type The type of checked|selected|disabled we are doing
  4228  * @param string $type    The type of checked|selected|disabled|readonly we are doing
  3127  * @return string html attribute or empty string
  4229  * @return string html attribute or empty string
  3128  */
  4230  */
  3129 function __checked_selected_helper( $helper, $current, $echo, $type ) {
  4231 function __checked_selected_helper( $helper, $current, $echo, $type ) {
  3130 	if ( (string) $helper === (string) $current )
  4232 	if ( (string) $helper === (string) $current )
  3131 		$result = " $type='$type'";
  4233 		$result = " $type='$type'";