wp/wp-includes/general-template.php
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
equal deleted inserted replaced
4:346c88efed21 5:5e2f62d02dcd
    13  * specialised header will be included.
    13  * specialised header will be included.
    14  *
    14  *
    15  * For the parameter, if the file is called "header-special.php" then specify
    15  * For the parameter, if the file is called "header-special.php" then specify
    16  * "special".
    16  * "special".
    17  *
    17  *
    18  * @uses locate_template()
       
    19  * @since 1.5.0
    18  * @since 1.5.0
    20  * @uses do_action() Calls 'get_header' action.
       
    21  *
    19  *
    22  * @param string $name The name of the specialised header.
    20  * @param string $name The name of the specialised header.
    23  */
    21  */
    24 function get_header( $name = null ) {
    22 function get_header( $name = null ) {
       
    23 	/**
       
    24 	 * Fires before the header template file is loaded.
       
    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
       
    31 	 * @since 2.8.0 $name parameter added.
       
    32 	 *
       
    33 	 * @param string $name Name of the specific header file to use.
       
    34 	 */
    25 	do_action( 'get_header', $name );
    35 	do_action( 'get_header', $name );
    26 
    36 
    27 	$templates = array();
    37 	$templates = array();
    28 	$name = (string) $name;
    38 	$name = (string) $name;
    29 	if ( '' !== $name )
    39 	if ( '' !== $name )
    43  * specialised footer will be included.
    53  * specialised footer will be included.
    44  *
    54  *
    45  * For the parameter, if the file is called "footer-special.php" then specify
    55  * For the parameter, if the file is called "footer-special.php" then specify
    46  * "special".
    56  * "special".
    47  *
    57  *
    48  * @uses locate_template()
       
    49  * @since 1.5.0
    58  * @since 1.5.0
    50  * @uses do_action() Calls 'get_footer' action.
       
    51  *
    59  *
    52  * @param string $name The name of the specialised footer.
    60  * @param string $name The name of the specialised footer.
    53  */
    61  */
    54 function get_footer( $name = null ) {
    62 function get_footer( $name = null ) {
       
    63 	/**
       
    64 	 * Fires before the footer template file is loaded.
       
    65 	 *
       
    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
       
    71 	 * @since 2.8.0 $name parameter added.
       
    72 	 *
       
    73 	 * @param string $name Name of the specific footer file to use.
       
    74 	 */
    55 	do_action( 'get_footer', $name );
    75 	do_action( 'get_footer', $name );
    56 
    76 
    57 	$templates = array();
    77 	$templates = array();
    58 	$name = (string) $name;
    78 	$name = (string) $name;
    59 	if ( '' !== $name )
    79 	if ( '' !== $name )
    73  * specialised sidebar will be included.
    93  * specialised sidebar will be included.
    74  *
    94  *
    75  * For the parameter, if the file is called "sidebar-special.php" then specify
    95  * For the parameter, if the file is called "sidebar-special.php" then specify
    76  * "special".
    96  * "special".
    77  *
    97  *
    78  * @uses locate_template()
       
    79  * @since 1.5.0
    98  * @since 1.5.0
    80  * @uses do_action() Calls 'get_sidebar' action.
       
    81  *
    99  *
    82  * @param string $name The name of the specialised sidebar.
   100  * @param string $name The name of the specialised sidebar.
    83  */
   101  */
    84 function get_sidebar( $name = null ) {
   102 function get_sidebar( $name = null ) {
       
   103 	/**
       
   104 	 * Fires before the sidebar template file is loaded.
       
   105 	 *
       
   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
       
   111 	 * @since 2.8.0 $name parameter added.
       
   112 	 *
       
   113 	 * @param string $name Name of the specific sidebar file to use.
       
   114 	 */
    85 	do_action( 'get_sidebar', $name );
   115 	do_action( 'get_sidebar', $name );
    86 
   116 
    87 	$templates = array();
   117 	$templates = array();
    88 	$name = (string) $name;
   118 	$name = (string) $name;
    89 	if ( '' !== $name )
   119 	if ( '' !== $name )
   110  * same template part multiple times.
   140  * same template part multiple times.
   111  *
   141  *
   112  * For the $name parameter, if the file is called "{slug}-special.php" then specify
   142  * For the $name parameter, if the file is called "{slug}-special.php" then specify
   113  * "special".
   143  * "special".
   114  *
   144  *
   115  * @uses locate_template()
       
   116  * @since 3.0.0
   145  * @since 3.0.0
   117  * @uses do_action() Calls 'get_template_part_{$slug}' action.
       
   118  *
   146  *
   119  * @param string $slug The slug name for the generic template.
   147  * @param string $slug The slug name for the generic template.
   120  * @param string $name The name of the specialised template.
   148  * @param string $name The name of the specialised template.
   121  */
   149  */
   122 function get_template_part( $slug, $name = null ) {
   150 function get_template_part( $slug, $name = null ) {
       
   151 	/**
       
   152 	 * Fires before the specified template part file is loaded.
       
   153 	 *
       
   154 	 * The dynamic portion of the hook name, `$slug`, refers to the slug name
       
   155 	 * for the generic template part.
       
   156 	 *
       
   157 	 * @since 3.0.0
       
   158 	 *
       
   159 	 * @param string $slug The slug name for the generic template.
       
   160 	 * @param string $name The name of the specialized template.
       
   161 	 */
   123 	do_action( "get_template_part_{$slug}", $slug, $name );
   162 	do_action( "get_template_part_{$slug}", $slug, $name );
   124 
   163 
   125 	$templates = array();
   164 	$templates = array();
   126 	$name = (string) $name;
   165 	$name = (string) $name;
   127 	if ( '' !== $name )
   166 	if ( '' !== $name )
   148  * 'pre_get_search_form'. This can be useful for outputting JavaScript that the
   187  * 'pre_get_search_form'. This can be useful for outputting JavaScript that the
   149  * search relies on or various formatting that applies to the beginning of the
   188  * search relies on or various formatting that applies to the beginning of the
   150  * search. To give a few examples of what it can be used for.
   189  * search. To give a few examples of what it can be used for.
   151  *
   190  *
   152  * @since 2.7.0
   191  * @since 2.7.0
   153  * @uses apply_filters() Calls 'search_form_format' filter to determine which type to use for the search field.
       
   154  *  If set to 'html5', it changes to search input type and adds placeholder text.
       
   155  *
   192  *
   156  * @param boolean $echo Default to echo and not return the form.
   193  * @param boolean $echo Default to echo and not return the form.
   157  * @return string|null String when retrieving, null when displaying or if searchform.php exists.
   194  * @return string|null String when retrieving, null when displaying or if searchform.php exists.
   158  */
   195  */
   159 function get_search_form( $echo = true ) {
   196 function get_search_form( $echo = true ) {
       
   197 	/**
       
   198 	 * Fires before the search form is retrieved, at the start of get_search_form().
       
   199 	 *
       
   200 	 * @since 2.7.0 as 'get_search_form' action.
       
   201 	 * @since 3.6.0
       
   202 	 *
       
   203 	 * @link https://core.trac.wordpress.org/ticket/19321
       
   204 	 */
   160 	do_action( 'pre_get_search_form' );
   205 	do_action( 'pre_get_search_form' );
   161 
   206 
   162 	$format = current_theme_supports( 'html5', 'search-form' ) ? 'html5' : 'xhtml';
   207 	$format = current_theme_supports( 'html5', 'search-form' ) ? 'html5' : 'xhtml';
       
   208 
       
   209 	/**
       
   210 	 * Filter the HTML format of the search form.
       
   211 	 *
       
   212 	 * @since 3.6.0
       
   213 	 *
       
   214 	 * @param string $format The type of markup to use in the search form.
       
   215 	 *                       Accepts 'html5', 'xhtml'.
       
   216 	 */
   163 	$format = apply_filters( 'search_form_format', $format );
   217 	$format = apply_filters( 'search_form_format', $format );
   164 
   218 
   165 	$search_form_template = locate_template( 'searchform.php' );
   219 	$search_form_template = locate_template( 'searchform.php' );
   166 	if ( '' != $search_form_template ) {
   220 	if ( '' != $search_form_template ) {
   167 		ob_start();
   221 		ob_start();
   185 				</div>
   239 				</div>
   186 			</form>';
   240 			</form>';
   187 		}
   241 		}
   188 	}
   242 	}
   189 
   243 
       
   244 	/**
       
   245 	 * Filter the HTML output of the search form.
       
   246 	 *
       
   247 	 * @since 2.7.0
       
   248 	 *
       
   249 	 * @param string $form The search form HTML output.
       
   250 	 */
   190 	$result = apply_filters( 'get_search_form', $form );
   251 	$result = apply_filters( 'get_search_form', $form );
       
   252 
   191 	if ( null === $result )
   253 	if ( null === $result )
   192 		$result = $form;
   254 		$result = $form;
   193 
   255 
   194 	if ( $echo )
   256 	if ( $echo )
   195 		echo $result;
   257 		echo $result;
   202  *
   264  *
   203  * Displays a link, which allows users to navigate to the Log In page to log in
   265  * Displays a link, which allows users to navigate to the Log In page to log in
   204  * or log out depending on whether they are currently logged in.
   266  * or log out depending on whether they are currently logged in.
   205  *
   267  *
   206  * @since 1.5.0
   268  * @since 1.5.0
   207  * @uses apply_filters() Calls 'loginout' hook on HTML link content.
       
   208  *
   269  *
   209  * @param string $redirect Optional path to redirect to on login/logout.
   270  * @param string $redirect Optional path to redirect to on login/logout.
   210  * @param boolean $echo Default to echo and not return the link.
   271  * @param boolean $echo Default to echo and not return the link.
   211  * @return string|null String when retrieving, null when displaying.
   272  * @return string|null String when retrieving, null when displaying.
   212  */
   273  */
   214 	if ( ! is_user_logged_in() )
   275 	if ( ! is_user_logged_in() )
   215 		$link = '<a href="' . esc_url( wp_login_url($redirect) ) . '">' . __('Log in') . '</a>';
   276 		$link = '<a href="' . esc_url( wp_login_url($redirect) ) . '">' . __('Log in') . '</a>';
   216 	else
   277 	else
   217 		$link = '<a href="' . esc_url( wp_logout_url($redirect) ) . '">' . __('Log out') . '</a>';
   278 		$link = '<a href="' . esc_url( wp_logout_url($redirect) ) . '">' . __('Log out') . '</a>';
   218 
   279 
   219 	if ( $echo )
   280 	if ( $echo ) {
   220 		echo apply_filters('loginout', $link);
   281 		/**
   221 	else
   282 		 * Filter the HTML output for the Log In/Log Out link.
   222 		return apply_filters('loginout', $link);
   283 		 *
       
   284 		 * @since 1.5.0
       
   285 		 *
       
   286 		 * @param string $link The HTML link content.
       
   287 		 */
       
   288 		echo apply_filters( 'loginout', $link );
       
   289 	} else {
       
   290 		/** This filter is documented in wp-includes/general-template.php */
       
   291 		return apply_filters( 'loginout', $link );
       
   292 	}
   223 }
   293 }
   224 
   294 
   225 /**
   295 /**
   226  * Returns the Log Out URL.
   296  * Returns the Log Out URL.
   227  *
   297  *
   228  * Returns the URL that allows the user to log out of the site.
   298  * Returns the URL that allows the user to log out of the site.
   229  *
   299  *
   230  * @since 2.7.0
   300  * @since 2.7.0
   231  * @uses wp_nonce_url() To protect against CSRF.
       
   232  * @uses site_url() To generate the log out URL.
       
   233  * @uses apply_filters() calls 'logout_url' hook on final logout URL.
       
   234  *
   301  *
   235  * @param string $redirect Path to redirect to on logout.
   302  * @param string $redirect Path to redirect to on logout.
   236  * @return string A log out URL.
   303  * @return string A log out URL.
   237  */
   304  */
   238 function wp_logout_url($redirect = '') {
   305 function wp_logout_url($redirect = '') {
   242 	}
   309 	}
   243 
   310 
   244 	$logout_url = add_query_arg($args, site_url('wp-login.php', 'login'));
   311 	$logout_url = add_query_arg($args, site_url('wp-login.php', 'login'));
   245 	$logout_url = wp_nonce_url( $logout_url, 'log-out' );
   312 	$logout_url = wp_nonce_url( $logout_url, 'log-out' );
   246 
   313 
   247 	return apply_filters('logout_url', $logout_url, $redirect);
   314 	/**
       
   315 	 * Filter the logout URL.
       
   316 	 *
       
   317 	 * @since 2.8.0
       
   318 	 *
       
   319 	 * @param string $logout_url The Log Out URL.
       
   320 	 * @param string $redirect   Path to redirect to on logout.
       
   321 	 */
       
   322 	return apply_filters( 'logout_url', $logout_url, $redirect );
   248 }
   323 }
   249 
   324 
   250 /**
   325 /**
   251  * Returns the Log In URL.
   326  * Returns the Log In URL.
   252  *
   327  *
   253  * Returns the URL that allows the user to log in to the site.
   328  * Returns the URL that allows the user to log in to the site.
   254  *
   329  *
   255  * @since 2.7.0
   330  * @since 2.7.0
   256  * @uses site_url() To generate the log in URL.
       
   257  * @uses apply_filters() calls 'login_url' hook on final login URL.
       
   258  *
   331  *
   259  * @param string $redirect Path to redirect to on login.
   332  * @param string $redirect Path to redirect to on login.
   260  * @param bool $force_reauth Whether to force reauthorization, even if a cookie is present. Default is false.
   333  * @param bool $force_reauth Whether to force reauthorization, even if a cookie is present. Default is false.
   261  * @return string A log in URL.
   334  * @return string A log in URL.
   262  */
   335  */
   267 		$login_url = add_query_arg('redirect_to', urlencode($redirect), $login_url);
   340 		$login_url = add_query_arg('redirect_to', urlencode($redirect), $login_url);
   268 
   341 
   269 	if ( $force_reauth )
   342 	if ( $force_reauth )
   270 		$login_url = add_query_arg('reauth', '1', $login_url);
   343 		$login_url = add_query_arg('reauth', '1', $login_url);
   271 
   344 
   272 	return apply_filters('login_url', $login_url, $redirect);
   345 	/**
       
   346 	 * Filter the login URL.
       
   347 	 *
       
   348 	 * @since 2.8.0
       
   349 	 * @since 4.2.0 The `$force_reauth` parameter was added.
       
   350 	 *
       
   351 	 * @param string $login_url    The login URL.
       
   352 	 * @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.
       
   354 	 */
       
   355 	return apply_filters( 'login_url', $login_url, $redirect, $force_reauth );
   273 }
   356 }
   274 
   357 
   275 /**
   358 /**
   276  * Returns the user registration URL.
   359  * Returns the user registration URL.
   277  *
   360  *
   278  * Returns the URL that allows the user to register on the site.
   361  * Returns the URL that allows the user to register on the site.
   279  *
   362  *
   280  * @since 3.6.0
   363  * @since 3.6.0
   281  * @uses site_url() To generate the registration URL.
   364  *
   282  * @uses apply_filters() calls 'register_url' hook on final URL.
   365  * @return string User registration URL.
   283  *
       
   284  * @return string
       
   285  */
   366  */
   286 function wp_registration_url() {
   367 function wp_registration_url() {
       
   368 	/**
       
   369 	 * Filter the user registration URL.
       
   370 	 *
       
   371 	 * @since 3.6.0
       
   372 	 *
       
   373 	 * @param string $register The user registration URL.
       
   374 	 */
   287 	return apply_filters( 'register_url', site_url( 'wp-login.php?action=register', 'login' ) );
   375 	return apply_filters( 'register_url', site_url( 'wp-login.php?action=register', 'login' ) );
   288 }
   376 }
   289 
   377 
   290 /**
   378 /**
   291  * Provides a simple login form for use anywhere within WordPress. By default, it echoes
   379  * Provides a simple login form for use anywhere within WordPress. By default, it echoes
   292  * the HTML immediately. Pass array('echo'=>false) to return the string instead.
   380  * the HTML immediately. Pass array('echo'=>false) to return the string instead.
   293  *
   381  *
   294  * @since 3.0.0
   382  * @since 3.0.0
       
   383  *
   295  * @param array $args Configuration options to modify the form output.
   384  * @param array $args Configuration options to modify the form output.
   296  * @return string|null String when retrieving, null when displaying.
   385  * @return string|null String when retrieving, null when displaying.
   297  */
   386  */
   298 function wp_login_form( $args = array() ) {
   387 function wp_login_form( $args = array() ) {
   299 	$defaults = array(
   388 	$defaults = array(
   310 		'id_submit' => 'wp-submit',
   399 		'id_submit' => 'wp-submit',
   311 		'remember' => true,
   400 		'remember' => true,
   312 		'value_username' => '',
   401 		'value_username' => '',
   313 		'value_remember' => false, // Set this to true to default the "Remember me" checkbox to checked
   402 		'value_remember' => false, // Set this to true to default the "Remember me" checkbox to checked
   314 	);
   403 	);
       
   404 
       
   405 	/**
       
   406 	 * Filter the default login form output arguments.
       
   407 	 *
       
   408 	 * @since 3.0.0
       
   409 	 *
       
   410 	 * @see wp_login_form()
       
   411 	 *
       
   412 	 * @param array $defaults An array of default login form arguments.
       
   413 	 */
   315 	$args = wp_parse_args( $args, apply_filters( 'login_form_defaults', $defaults ) );
   414 	$args = wp_parse_args( $args, apply_filters( 'login_form_defaults', $defaults ) );
       
   415 
       
   416 	/**
       
   417 	 * Filter content to display at the top of the login form.
       
   418 	 *
       
   419 	 * The filter evaluates just following the opening form tag element.
       
   420 	 *
       
   421 	 * @since 3.0.0
       
   422 	 *
       
   423 	 * @param string $content Content to display. Default empty.
       
   424 	 * @param array  $args    Array of login form arguments.
       
   425 	 */
       
   426 	$login_form_top = apply_filters( 'login_form_top', '', $args );
       
   427 
       
   428 	/**
       
   429 	 * Filter content to display in the middle of the login form.
       
   430 	 *
       
   431 	 * The filter evaluates just following the location where the 'login-password'
       
   432 	 * field is displayed.
       
   433 	 *
       
   434 	 * @since 3.0.0
       
   435 	 *
       
   436 	 * @param string $content Content to display. Default empty.
       
   437 	 * @param array  $args    Array of login form arguments.
       
   438 	 */
       
   439 	$login_form_middle = apply_filters( 'login_form_middle', '', $args );
       
   440 
       
   441 	/**
       
   442 	 * Filter content to display at the bottom of the login form.
       
   443 	 *
       
   444 	 * The filter evaluates just preceding the closing form tag element.
       
   445 	 *
       
   446 	 * @since 3.0.0
       
   447 	 *
       
   448 	 * @param string $content Content to display. Default empty.
       
   449 	 * @param array  $args    Array of login form arguments.
       
   450 	 */
       
   451 	$login_form_bottom = apply_filters( 'login_form_bottom', '', $args );
   316 
   452 
   317 	$form = '
   453 	$form = '
   318 		<form name="' . $args['form_id'] . '" id="' . $args['form_id'] . '" action="' . esc_url( site_url( 'wp-login.php', 'login_post' ) ) . '" method="post">
   454 		<form name="' . $args['form_id'] . '" id="' . $args['form_id'] . '" action="' . esc_url( site_url( 'wp-login.php', 'login_post' ) ) . '" method="post">
   319 			' . apply_filters( 'login_form_top', '', $args ) . '
   455 			' . $login_form_top . '
   320 			<p class="login-username">
   456 			<p class="login-username">
   321 				<label for="' . esc_attr( $args['id_username'] ) . '">' . esc_html( $args['label_username'] ) . '</label>
   457 				<label for="' . esc_attr( $args['id_username'] ) . '">' . esc_html( $args['label_username'] ) . '</label>
   322 				<input type="text" name="log" id="' . esc_attr( $args['id_username'] ) . '" class="input" value="' . esc_attr( $args['value_username'] ) . '" size="20" />
   458 				<input type="text" name="log" id="' . esc_attr( $args['id_username'] ) . '" class="input" value="' . esc_attr( $args['value_username'] ) . '" size="20" />
   323 			</p>
   459 			</p>
   324 			<p class="login-password">
   460 			<p class="login-password">
   325 				<label for="' . esc_attr( $args['id_password'] ) . '">' . esc_html( $args['label_password'] ) . '</label>
   461 				<label for="' . esc_attr( $args['id_password'] ) . '">' . esc_html( $args['label_password'] ) . '</label>
   326 				<input type="password" name="pwd" id="' . esc_attr( $args['id_password'] ) . '" class="input" value="" size="20" />
   462 				<input type="password" name="pwd" id="' . esc_attr( $args['id_password'] ) . '" class="input" value="" size="20" />
   327 			</p>
   463 			</p>
   328 			' . apply_filters( 'login_form_middle', '', $args ) . '
   464 			' . $login_form_middle . '
   329 			' . ( $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>' : '' ) . '
   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>' : '' ) . '
   330 			<p class="login-submit">
   466 			<p class="login-submit">
   331 				<input type="submit" name="wp-submit" id="' . esc_attr( $args['id_submit'] ) . '" class="button-primary" value="' . esc_attr( $args['label_log_in'] ) . '" />
   467 				<input type="submit" name="wp-submit" id="' . esc_attr( $args['id_submit'] ) . '" class="button-primary" value="' . esc_attr( $args['label_log_in'] ) . '" />
   332 				<input type="hidden" name="redirect_to" value="' . esc_url( $args['redirect'] ) . '" />
   468 				<input type="hidden" name="redirect_to" value="' . esc_url( $args['redirect'] ) . '" />
   333 			</p>
   469 			</p>
   334 			' . apply_filters( 'login_form_bottom', '', $args ) . '
   470 			' . $login_form_bottom . '
   335 		</form>';
   471 		</form>';
   336 
   472 
   337 	if ( $args['echo'] )
   473 	if ( $args['echo'] )
   338 		echo $form;
   474 		echo $form;
   339 	else
   475 	else
   344  * Returns the Lost Password URL.
   480  * Returns the Lost Password URL.
   345  *
   481  *
   346  * Returns the URL that allows the user to retrieve the lost password
   482  * Returns the URL that allows the user to retrieve the lost password
   347  *
   483  *
   348  * @since 2.8.0
   484  * @since 2.8.0
   349  * @uses site_url() To generate the lost password URL
       
   350  * @uses apply_filters() calls 'lostpassword_url' hook on the lostpassword url
       
   351  *
   485  *
   352  * @param string $redirect Path to redirect to on login.
   486  * @param string $redirect Path to redirect to on login.
   353  * @return string Lost password URL.
   487  * @return string Lost password URL.
   354  */
   488  */
   355 function wp_lostpassword_url( $redirect = '' ) {
   489 function wp_lostpassword_url( $redirect = '' ) {
   357 	if ( !empty($redirect) ) {
   491 	if ( !empty($redirect) ) {
   358 		$args['redirect_to'] = $redirect;
   492 		$args['redirect_to'] = $redirect;
   359 	}
   493 	}
   360 
   494 
   361 	$lostpassword_url = add_query_arg( $args, network_site_url('wp-login.php', 'login') );
   495 	$lostpassword_url = add_query_arg( $args, network_site_url('wp-login.php', 'login') );
       
   496 
       
   497 	/**
       
   498 	 * Filter the Lost Password URL.
       
   499 	 *
       
   500 	 * @since 2.8.0
       
   501 	 *
       
   502 	 * @param string $lostpassword_url The lost password page URL.
       
   503 	 * @param string $redirect         The path to redirect to on login.
       
   504 	 */
   362 	return apply_filters( 'lostpassword_url', $lostpassword_url, $redirect );
   505 	return apply_filters( 'lostpassword_url', $lostpassword_url, $redirect );
   363 }
   506 }
   364 
   507 
   365 /**
   508 /**
   366  * Display the Registration or Admin link.
   509  * Display the Registration or Admin link.
   367  *
   510  *
   368  * Display a link which allows the user to navigate to the registration page if
   511  * Display a link which allows the user to navigate to the registration page if
   369  * not logged in and registration is enabled or to the dashboard if logged in.
   512  * not logged in and registration is enabled or to the dashboard if logged in.
   370  *
   513  *
   371  * @since 1.5.0
   514  * @since 1.5.0
   372  * @uses apply_filters() Calls 'register' hook on register / admin link content.
   515  *
   373  *
   516  * @param string $before Text to output before the link. Default `<li>`.
   374  * @param string $before Text to output before the link (defaults to <li>).
   517  * @param string $after Text to output after the link. Default `</li>`.
   375  * @param string $after Text to output after the link (defaults to </li>).
       
   376  * @param boolean $echo Default to echo and not return the link.
   518  * @param boolean $echo Default to echo and not return the link.
   377  * @return string|null String when retrieving, null when displaying.
   519  * @return string|null String when retrieving, null when displaying.
   378  */
   520  */
   379 function wp_register( $before = '<li>', $after = '</li>', $echo = true ) {
   521 function wp_register( $before = '<li>', $after = '</li>', $echo = true ) {
   380 
   522 
   385 			$link = '';
   527 			$link = '';
   386 	} else {
   528 	} else {
   387 		$link = $before . '<a href="' . admin_url() . '">' . __('Site Admin') . '</a>' . $after;
   529 		$link = $before . '<a href="' . admin_url() . '">' . __('Site Admin') . '</a>' . $after;
   388 	}
   530 	}
   389 
   531 
   390 	if ( $echo )
   532 	/**
   391 		echo apply_filters('register', $link);
   533 	 * Filter the HTML link to the Registration or Admin page.
   392 	else
   534 	 *
   393 		return apply_filters('register', $link);
   535 	 * Users are sent to the admin page if logged-in, or the registration page
       
   536 	 * if enabled and logged-out.
       
   537 	 *
       
   538 	 * @since 1.5.0
       
   539 	 *
       
   540 	 * @param string $link The HTML code for the link to the Registration or Admin page.
       
   541 	 */
       
   542 	$link = apply_filters( 'register', $link );
       
   543 
       
   544 	if ( $echo ) {
       
   545 		echo $link;
       
   546 	} else {
       
   547 		return $link;
       
   548 	}
   394 }
   549 }
   395 
   550 
   396 /**
   551 /**
   397  * Theme container function for the 'wp_meta' action.
   552  * Theme container function for the 'wp_meta' action.
   398  *
   553  *
   399  * The 'wp_meta' action can have several purposes, depending on how you use it,
   554  * The 'wp_meta' action can have several purposes, depending on how you use it,
   400  * but one purpose might have been to allow for theme switching.
   555  * but one purpose might have been to allow for theme switching.
   401  *
   556  *
   402  * @since 1.5.0
   557  * @since 1.5.0
   403  * @link http://trac.wordpress.org/ticket/1458 Explanation of 'wp_meta' action.
   558  *
   404  * @uses do_action() Calls 'wp_meta' hook.
   559  * @link https://core.trac.wordpress.org/ticket/1458 Explanation of 'wp_meta' action.
   405  */
   560  */
   406 function wp_meta() {
   561 function wp_meta() {
   407 	do_action('wp_meta');
   562 	/**
       
   563 	 * Fires before displaying echoed content in the sidebar.
       
   564 	 *
       
   565 	 * @since 1.5.0
       
   566 	 */
       
   567 	do_action( 'wp_meta' );
   408 }
   568 }
   409 
   569 
   410 /**
   570 /**
   411  * Display information about the blog.
   571  * Display information about the blog.
   412  *
   572  *
   421 
   581 
   422 /**
   582 /**
   423  * Retrieve information about the blog.
   583  * Retrieve information about the blog.
   424  *
   584  *
   425  * Some show parameter values are deprecated and will be removed in future
   585  * Some show parameter values are deprecated and will be removed in future
   426  * versions. These options will trigger the _deprecated_argument() function.
   586  * versions. These options will trigger the {@see _deprecated_argument()}
   427  * The deprecated blog info options are listed in the function contents.
   587  * function. The deprecated blog info options are listed in the function
       
   588  * contents.
   428  *
   589  *
   429  * The possible values for the 'show' parameter are listed below.
   590  * The possible values for the 'show' parameter are listed below.
   430  * <ol>
   591  *
   431  * <li><strong>url</strong> - Blog URI to homepage.</li>
   592  * 1. url - Blog URI to homepage.
   432  * <li><strong>wpurl</strong> - Blog URI path to WordPress.</li>
   593  * 2. wpurl - Blog URI path to WordPress.
   433  * <li><strong>description</strong> - Secondary title</li>
   594  * 3. description - Secondary title
   434  * </ol>
       
   435  *
   595  *
   436  * The feed URL options can be retrieved from 'rdf_url' (RSS 0.91),
   596  * The feed URL options can be retrieved from 'rdf_url' (RSS 0.91),
   437  * 'rss_url' (RSS 1.0), 'rss2_url' (RSS 2.0), or 'atom_url' (Atom feed). The
   597  * 'rss_url' (RSS 1.0), 'rss2_url' (RSS 2.0), or 'atom_url' (Atom feed). The
   438  * comment feeds can be retrieved from the 'comments_atom_url' (Atom comment
   598  * comment feeds can be retrieved from the 'comments_atom_url' (Atom comment
   439  * feed) or 'comments_rss2_url' (RSS 2.0 comment feed).
   599  * feed) or 'comments_rss2_url' (RSS 2.0 comment feed).
   447 function get_bloginfo( $show = '', $filter = 'raw' ) {
   607 function get_bloginfo( $show = '', $filter = 'raw' ) {
   448 
   608 
   449 	switch( $show ) {
   609 	switch( $show ) {
   450 		case 'home' : // DEPRECATED
   610 		case 'home' : // DEPRECATED
   451 		case 'siteurl' : // DEPRECATED
   611 		case 'siteurl' : // DEPRECATED
   452 			_deprecated_argument( __FUNCTION__, '2.2', sprintf( __('The <code>%s</code> option is deprecated for the family of <code>bloginfo()</code> functions.' ), $show ) . ' ' . sprintf( __( 'Use the <code>%s</code> option instead.' ), 'url'  ) );
   612 			_deprecated_argument( __FUNCTION__, '2.2', sprintf(
       
   613 				/* 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.' ),
       
   615 				'<code>' . $show . '</code>',
       
   616 				'<code>bloginfo()</code>',
       
   617 				'<code>url</code>'
       
   618 			) );
   453 		case 'url' :
   619 		case 'url' :
   454 			$output = home_url();
   620 			$output = home_url();
   455 			break;
   621 			break;
   456 		case 'wpurl' :
   622 		case 'wpurl' :
   457 			$output = site_url();
   623 			$output = site_url();
   507 		case 'language':
   673 		case 'language':
   508 			$output = get_locale();
   674 			$output = get_locale();
   509 			$output = str_replace('_', '-', $output);
   675 			$output = str_replace('_', '-', $output);
   510 			break;
   676 			break;
   511 		case 'text_direction':
   677 		case 'text_direction':
   512 			//_deprecated_argument( __FUNCTION__, '2.2', sprintf( __('The <code>%s</code> option is deprecated for the family of <code>bloginfo()</code> functions.' ), $show ) . ' ' . sprintf( __( 'Use the <code>%s</code> function instead.' ), 'is_rtl()'  ) );
   678 			_deprecated_argument( __FUNCTION__, '2.2', sprintf(
       
   679 				/* 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.' ),
       
   681 				'<code>' . $show . '</code>',
       
   682 				'<code>bloginfo()</code>',
       
   683 				'<code>is_rtl()</code>'
       
   684 			) );
   513 			if ( function_exists( 'is_rtl' ) ) {
   685 			if ( function_exists( 'is_rtl' ) ) {
   514 				$output = is_rtl() ? 'rtl' : 'ltr';
   686 				$output = is_rtl() ? 'rtl' : 'ltr';
   515 			} else {
   687 			} else {
   516 				$output = 'ltr';
   688 				$output = 'ltr';
   517 			}
   689 			}
   527 		strpos($show, 'directory') === false &&
   699 		strpos($show, 'directory') === false &&
   528 		strpos($show, 'home') === false)
   700 		strpos($show, 'home') === false)
   529 		$url = false;
   701 		$url = false;
   530 
   702 
   531 	if ( 'display' == $filter ) {
   703 	if ( 'display' == $filter ) {
   532 		if ( $url )
   704 		if ( $url ) {
   533 			$output = apply_filters('bloginfo_url', $output, $show);
   705 			/**
   534 		else
   706 			 * Filter the URL returned by get_bloginfo().
   535 			$output = apply_filters('bloginfo', $output, $show);
   707 			 *
       
   708 			 * @since 2.0.5
       
   709 			 *
       
   710 			 * @param mixed $output The URL returned by bloginfo().
       
   711 			 * @param mixed $show   Type of information requested.
       
   712 			 */
       
   713 			$output = apply_filters( 'bloginfo_url', $output, $show );
       
   714 		} else {
       
   715 			/**
       
   716 			 * Filter the site information returned by get_bloginfo().
       
   717 			 *
       
   718 			 * @since 0.71
       
   719 			 *
       
   720 			 * @param mixed $output The requested non-URL site information.
       
   721 			 * @param mixed $show   Type of information requested.
       
   722 			 */
       
   723 			$output = apply_filters( 'bloginfo', $output, $show );
       
   724 		}
   536 	}
   725 	}
   537 
   726 
   538 	return $output;
   727 	return $output;
       
   728 }
       
   729 
       
   730 /**
       
   731  * Display title tag with contents.
       
   732  *
       
   733  * @ignore
       
   734  * @since 4.1.0
       
   735  * @access private
       
   736  *
       
   737  * @see wp_title()
       
   738  */
       
   739 function _wp_render_title_tag() {
       
   740 	if ( ! current_theme_supports( 'title-tag' ) ) {
       
   741 		return;
       
   742 	}
       
   743 
       
   744 	// This can only work internally on wp_head.
       
   745 	if ( ! did_action( 'wp_head' ) && ! doing_action( 'wp_head' ) ) {
       
   746 		return;
       
   747 	}
       
   748 
       
   749 	echo '<title>' . wp_title( '|', false, 'right' ) . "</title>\n";
   539 }
   750 }
   540 
   751 
   541 /**
   752 /**
   542  * Display or retrieve page title for all areas of blog.
   753  * Display or retrieve page title for all areas of blog.
   543  *
   754  *
   559  * @param bool $display Optional, default is true. Whether to display or retrieve title.
   770  * @param bool $display Optional, default is true. Whether to display or retrieve title.
   560  * @param string $seplocation Optional. Direction to display title, 'right'.
   771  * @param string $seplocation Optional. Direction to display title, 'right'.
   561  * @return string|null String on retrieve, null when displaying.
   772  * @return string|null String on retrieve, null when displaying.
   562  */
   773  */
   563 function wp_title($sep = '&raquo;', $display = true, $seplocation = '') {
   774 function wp_title($sep = '&raquo;', $display = true, $seplocation = '') {
   564 	global $wpdb, $wp_locale;
   775 	global $wp_locale, $page, $paged;
   565 
   776 
   566 	$m = get_query_var('m');
   777 	$m = get_query_var('m');
   567 	$year = get_query_var('year');
   778 	$year = get_query_var('year');
   568 	$monthnum = get_query_var('monthnum');
   779 	$monthnum = get_query_var('monthnum');
   569 	$day = get_query_var('day');
   780 	$day = get_query_var('day');
   600 			$title = single_term_title( $tax->labels->name . $t_sep, false );
   811 			$title = single_term_title( $tax->labels->name . $t_sep, false );
   601 		}
   812 		}
   602 	}
   813 	}
   603 
   814 
   604 	// If there's an author
   815 	// If there's an author
   605 	if ( is_author() ) {
   816 	if ( is_author() && ! is_post_type_archive() ) {
   606 		$author = get_queried_object();
   817 		$author = get_queried_object();
   607 		if ( $author )
   818 		if ( $author )
   608 			$title = $author->display_name;
   819 			$title = $author->display_name;
   609 	}
   820 	}
   610 
   821 
   642 
   853 
   643 	$prefix = '';
   854 	$prefix = '';
   644 	if ( !empty($title) )
   855 	if ( !empty($title) )
   645 		$prefix = " $sep ";
   856 		$prefix = " $sep ";
   646 
   857 
       
   858 	/**
       
   859 	 * Filter the parts of the page title.
       
   860 	 *
       
   861 	 * @since 4.0.0
       
   862 	 *
       
   863 	 * @param array $title_array Parts of the page title.
       
   864 	 */
       
   865 	$title_array = apply_filters( 'wp_title_parts', explode( $t_sep, $title ) );
       
   866 
   647  	// Determines position of the separator and direction of the breadcrumb
   867  	// Determines position of the separator and direction of the breadcrumb
   648 	if ( 'right' == $seplocation ) { // sep on right, so reverse the order
   868 	if ( 'right' == $seplocation ) { // sep on right, so reverse the order
   649 		$title_array = explode( $t_sep, $title );
       
   650 		$title_array = array_reverse( $title_array );
   869 		$title_array = array_reverse( $title_array );
   651 		$title = implode( " $sep ", $title_array ) . $prefix;
   870 		$title = implode( " $sep ", $title_array ) . $prefix;
   652 	} else {
   871 	} else {
   653 		$title_array = explode( $t_sep, $title );
       
   654 		$title = $prefix . implode( " $sep ", $title_array );
   872 		$title = $prefix . implode( " $sep ", $title_array );
   655 	}
   873 	}
   656 
   874 
   657 	$title = apply_filters('wp_title', $title, $sep, $seplocation);
   875 	if ( current_theme_supports( 'title-tag' ) && ! is_feed() ) {
       
   876 		$title .= get_bloginfo( 'name', 'display' );
       
   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 	 *
       
   891 	 * @since 2.0.0
       
   892 	 *
       
   893 	 * @param string $title       Page title.
       
   894 	 * @param string $sep         Title separator.
       
   895 	 * @param string $seplocation Location of the separator (left or right).
       
   896 	 */
       
   897 	$title = apply_filters( 'wp_title', $title, $sep, $seplocation );
   658 
   898 
   659 	// Send it out
   899 	// Send it out
   660 	if ( $display )
   900 	if ( $display )
   661 		echo $title;
   901 		echo $title;
   662 	else
   902 	else
   684 	$_post = get_queried_object();
   924 	$_post = get_queried_object();
   685 
   925 
   686 	if ( !isset($_post->post_title) )
   926 	if ( !isset($_post->post_title) )
   687 		return;
   927 		return;
   688 
   928 
   689 	$title = apply_filters('single_post_title', $_post->post_title, $_post);
   929 	/**
       
   930 	 * Filter the page title for a single post.
       
   931 	 *
       
   932 	 * @since 0.71
       
   933 	 *
       
   934 	 * @param string $_post_title The single post page title.
       
   935 	 * @param object $_post       The current queried object as returned by get_queried_object().
       
   936 	 */
       
   937 	$title = apply_filters( 'single_post_title', $_post->post_title, $_post );
   690 	if ( $display )
   938 	if ( $display )
   691 		echo $prefix . $title;
   939 		echo $prefix . $title;
   692 	else
   940 	else
   693 		return $prefix . $title;
   941 		return $prefix . $title;
   694 }
   942 }
   712 	$post_type = get_query_var( 'post_type' );
   960 	$post_type = get_query_var( 'post_type' );
   713 	if ( is_array( $post_type ) )
   961 	if ( is_array( $post_type ) )
   714 		$post_type = reset( $post_type );
   962 		$post_type = reset( $post_type );
   715 
   963 
   716 	$post_type_obj = get_post_type_object( $post_type );
   964 	$post_type_obj = get_post_type_object( $post_type );
   717 	$title = apply_filters('post_type_archive_title', $post_type_obj->labels->name );
   965 
       
   966 	/**
       
   967 	 * Filter the post type archive title.
       
   968 	 *
       
   969 	 * @since 3.1.0
       
   970 	 *
       
   971 	 * @param string $post_type_name Post type 'name' label.
       
   972 	 * @param string $post_type      Post type.
       
   973 	 */
       
   974 	$title = apply_filters( 'post_type_archive_title', $post_type_obj->labels->name, $post_type );
   718 
   975 
   719 	if ( $display )
   976 	if ( $display )
   720 		echo $prefix . $title;
   977 		echo $prefix . $title;
   721 	else
   978 	else
   722 		return $prefix . $title;
   979 		return $prefix . $title;
   785 	$term = get_queried_object();
  1042 	$term = get_queried_object();
   786 
  1043 
   787 	if ( !$term )
  1044 	if ( !$term )
   788 		return;
  1045 		return;
   789 
  1046 
   790 	if ( is_category() )
  1047 	if ( is_category() ) {
       
  1048 		/**
       
  1049 		 * Filter the category archive page title.
       
  1050 		 *
       
  1051 		 * @since 2.0.10
       
  1052 		 *
       
  1053 		 * @param string $term_name Category name for archive being displayed.
       
  1054 		 */
   791 		$term_name = apply_filters( 'single_cat_title', $term->name );
  1055 		$term_name = apply_filters( 'single_cat_title', $term->name );
   792 	elseif ( is_tag() )
  1056 	} elseif ( is_tag() ) {
       
  1057 		/**
       
  1058 		 * Filter the tag archive page title.
       
  1059 		 *
       
  1060 		 * @since 2.3.0
       
  1061 		 *
       
  1062 		 * @param string $term_name Tag name for archive being displayed.
       
  1063 		 */
   793 		$term_name = apply_filters( 'single_tag_title', $term->name );
  1064 		$term_name = apply_filters( 'single_tag_title', $term->name );
   794 	elseif ( is_tax() )
  1065 	} elseif ( is_tax() ) {
       
  1066 		/**
       
  1067 		 * Filter the custom taxonomy archive page title.
       
  1068 		 *
       
  1069 		 * @since 3.1.0
       
  1070 		 *
       
  1071 		 * @param string $term_name Term name for archive being displayed.
       
  1072 		 */
   795 		$term_name = apply_filters( 'single_term_title', $term->name );
  1073 		$term_name = apply_filters( 'single_term_title', $term->name );
   796 	else
  1074 	} else {
   797 		return;
  1075 		return;
       
  1076 	}
   798 
  1077 
   799 	if ( empty( $term_name ) )
  1078 	if ( empty( $term_name ) )
   800 		return;
  1079 		return;
   801 
  1080 
   802 	if ( $display )
  1081 	if ( $display )
   847 		return $result;
  1126 		return $result;
   848 	echo $result;
  1127 	echo $result;
   849 }
  1128 }
   850 
  1129 
   851 /**
  1130 /**
       
  1131  * Display the archive title based on the queried object.
       
  1132  *
       
  1133  * @since 4.1.0
       
  1134  *
       
  1135  * @see get_the_archive_title()
       
  1136  *
       
  1137  * @param string $before Optional. Content to prepend to the title. Default empty.
       
  1138  * @param string $after  Optional. Content to append to the title. Default empty.
       
  1139  */
       
  1140 function the_archive_title( $before = '', $after = '' ) {
       
  1141 	$title = get_the_archive_title();
       
  1142 
       
  1143 	if ( ! empty( $title ) ) {
       
  1144 		echo $before . $title . $after;
       
  1145 	}
       
  1146 }
       
  1147 
       
  1148 /**
       
  1149  * Retrieve the archive title based on the queried object.
       
  1150  *
       
  1151  * @since 4.1.0
       
  1152  *
       
  1153  * @return string Archive title.
       
  1154  */
       
  1155 function get_the_archive_title() {
       
  1156 	if ( is_category() ) {
       
  1157 		$title = sprintf( __( 'Category: %s' ), single_cat_title( '', false ) );
       
  1158 	} elseif ( is_tag() ) {
       
  1159 		$title = sprintf( __( 'Tag: %s' ), single_tag_title( '', false ) );
       
  1160 	} elseif ( is_author() ) {
       
  1161 		$title = sprintf( __( 'Author: %s' ), '<span class="vcard">' . get_the_author() . '</span>' );
       
  1162 	} elseif ( is_year() ) {
       
  1163 		$title = sprintf( __( 'Year: %s' ), get_the_date( _x( 'Y', 'yearly archives date format' ) ) );
       
  1164 	} elseif ( is_month() ) {
       
  1165 		$title = sprintf( __( 'Month: %s' ), get_the_date( _x( 'F Y', 'monthly archives date format' ) ) );
       
  1166 	} elseif ( is_day() ) {
       
  1167 		$title = sprintf( __( 'Day: %s' ), get_the_date( _x( 'F j, Y', 'daily archives date format' ) ) );
       
  1168 	} elseif ( is_tax( 'post_format' ) ) {
       
  1169 		if ( is_tax( 'post_format', 'post-format-aside' ) ) {
       
  1170 			$title = _x( 'Asides', 'post format archive title' );
       
  1171 		} elseif ( is_tax( 'post_format', 'post-format-gallery' ) ) {
       
  1172 			$title = _x( 'Galleries', 'post format archive title' );
       
  1173 		} elseif ( is_tax( 'post_format', 'post-format-image' ) ) {
       
  1174 			$title = _x( 'Images', 'post format archive title' );
       
  1175 		} elseif ( is_tax( 'post_format', 'post-format-video' ) ) {
       
  1176 			$title = _x( 'Videos', 'post format archive title' );
       
  1177 		} elseif ( is_tax( 'post_format', 'post-format-quote' ) ) {
       
  1178 			$title = _x( 'Quotes', 'post format archive title' );
       
  1179 		} elseif ( is_tax( 'post_format', 'post-format-link' ) ) {
       
  1180 			$title = _x( 'Links', 'post format archive title' );
       
  1181 		} elseif ( is_tax( 'post_format', 'post-format-status' ) ) {
       
  1182 			$title = _x( 'Statuses', 'post format archive title' );
       
  1183 		} elseif ( is_tax( 'post_format', 'post-format-audio' ) ) {
       
  1184 			$title = _x( 'Audio', 'post format archive title' );
       
  1185 		} elseif ( is_tax( 'post_format', 'post-format-chat' ) ) {
       
  1186 			$title = _x( 'Chats', 'post format archive title' );
       
  1187 		}
       
  1188 	} elseif ( is_post_type_archive() ) {
       
  1189 		$title = sprintf( __( 'Archives: %s' ), post_type_archive_title( '', false ) );
       
  1190 	} elseif ( is_tax() ) {
       
  1191 		$tax = get_taxonomy( get_queried_object()->taxonomy );
       
  1192 		/* translators: 1: Taxonomy singular name, 2: Current taxonomy term */
       
  1193 		$title = sprintf( __( '%1$s: %2$s' ), $tax->labels->singular_name, single_term_title( '', false ) );
       
  1194 	} else {
       
  1195 		$title = __( 'Archives' );
       
  1196 	}
       
  1197 
       
  1198 	/**
       
  1199 	 * Filter the archive title.
       
  1200 	 *
       
  1201 	 * @since 4.1.0
       
  1202 	 *
       
  1203 	 * @param string $title Archive title to be displayed.
       
  1204 	 */
       
  1205 	return apply_filters( 'get_the_archive_title', $title );
       
  1206 }
       
  1207 
       
  1208 /**
       
  1209  * Display category, tag, or term description.
       
  1210  *
       
  1211  * @since 4.1.0
       
  1212  *
       
  1213  * @see get_the_archive_description()
       
  1214  *
       
  1215  * @param string $before Optional. Content to prepend to the description. Default empty.
       
  1216  * @param string $after  Optional. Content to append to the description. Default empty.
       
  1217  */
       
  1218 function the_archive_description( $before = '', $after = '' ) {
       
  1219 	$description = get_the_archive_description();
       
  1220 	if ( $description ) {
       
  1221 		echo $before . $description . $after;
       
  1222 	}
       
  1223 }
       
  1224 
       
  1225 /**
       
  1226  * Retrieve category, tag, or term description.
       
  1227  *
       
  1228  * @since 4.1.0
       
  1229  *
       
  1230  * @return string Archive description.
       
  1231  */
       
  1232 function get_the_archive_description() {
       
  1233 	/**
       
  1234 	 * Filter the archive description.
       
  1235 	 *
       
  1236 	 * @since 4.1.0
       
  1237 	 *
       
  1238 	 * @see term_description()
       
  1239 	 *
       
  1240 	 * @param string $description Archive description to be displayed.
       
  1241 	 */
       
  1242 	return apply_filters( 'get_the_archive_description', term_description() );
       
  1243 }
       
  1244 
       
  1245 /**
   852  * Retrieve archive link content based on predefined or custom code.
  1246  * Retrieve archive link content based on predefined or custom code.
   853  *
  1247  *
   854  * The format can be one of four styles. The 'link' for head element, 'option'
  1248  * The format can be one of four styles. The 'link' for head element, 'option'
   855  * for use in the select element, 'html' for use in list (either ol or ul HTML
  1249  * for use in the select element, 'html' for use in list (either ol or ul HTML
   856  * elements). Custom content is also supported using the before and after
  1250  * elements). Custom content is also supported using the before and after
   857  * parameters.
  1251  * parameters.
   858  *
  1252  *
   859  * The 'link' format uses the link HTML element with the <em>archives</em>
  1253  * The 'link' format uses the `<link>` HTML element with the **archives**
   860  * relationship. The before and after parameters are not used. The text
  1254  * relationship. The before and after parameters are not used. The text
   861  * parameter is used to describe the link.
  1255  * parameter is used to describe the link.
   862  *
  1256  *
   863  * The 'option' format uses the option HTML element for use in select element.
  1257  * The 'option' format uses the option HTML element for use in select element.
   864  * The value is the url parameter and the before and after parameters are used
  1258  * The value is the url parameter and the before and after parameters are used
   871  * The custom format uses the before parameter before the link ('a' HTML
  1265  * The custom format uses the before parameter before the link ('a' HTML
   872  * element) and the after parameter after the closing link tag. If the above
  1266  * element) and the after parameter after the closing link tag. If the above
   873  * three values for the format are not used, then custom format is assumed.
  1267  * three values for the format are not used, then custom format is assumed.
   874  *
  1268  *
   875  * @since 1.0.0
  1269  * @since 1.0.0
       
  1270  *
       
  1271  * @todo Properly document optional arguments as such
   876  *
  1272  *
   877  * @param string $url URL to archive.
  1273  * @param string $url URL to archive.
   878  * @param string $text Archive text description.
  1274  * @param string $text Archive text description.
   879  * @param string $format Optional, default is 'html'. Can be 'link', 'option', 'html', or custom.
  1275  * @param string $format Optional, default is 'html'. Can be 'link', 'option', 'html', or custom.
   880  * @param string $before Optional.
  1276  * @param string $before Optional.
   892 	elseif ('html' == $format)
  1288 	elseif ('html' == $format)
   893 		$link_html = "\t<li>$before<a href='$url'>$text</a>$after</li>\n";
  1289 		$link_html = "\t<li>$before<a href='$url'>$text</a>$after</li>\n";
   894 	else // custom
  1290 	else // custom
   895 		$link_html = "\t$before<a href='$url'>$text</a>$after\n";
  1291 		$link_html = "\t$before<a href='$url'>$text</a>$after\n";
   896 
  1292 
       
  1293 	/**
       
  1294 	 * Filter the archive link content.
       
  1295 	 *
       
  1296 	 * @since 2.6.0
       
  1297 	 *
       
  1298 	 * @param string $link_html The archive HTML link content.
       
  1299 	 */
   897 	$link_html = apply_filters( 'get_archives_link', $link_html );
  1300 	$link_html = apply_filters( 'get_archives_link', $link_html );
   898 
  1301 
   899 	return $link_html;
  1302 	return $link_html;
   900 }
  1303 }
   901 
  1304 
   902 /**
  1305 /**
   903  * Display archive links based on type and format.
  1306  * Display archive links based on type and format.
   904  *
  1307  *
   905  * The 'type' argument offers a few choices and by default will display monthly
       
   906  * archive links. The other options for values are 'daily', 'weekly', 'monthly',
       
   907  * 'yearly', 'postbypost' or 'alpha'. Both 'postbypost' and 'alpha' display the
       
   908  * same archive link list, the difference between the two is that 'alpha'
       
   909  * will order by post title and 'postbypost' will order by post date.
       
   910  *
       
   911  * The date archives will logically display dates with links to the archive post
       
   912  * page. The 'postbypost' and 'alpha' values for 'type' argument will display
       
   913  * the post titles.
       
   914  *
       
   915  * The 'limit' argument will only display a limited amount of links, specified
       
   916  * by the 'limit' integer value. By default, there is no limit. The
       
   917  * 'show_post_count' argument will show how many posts are within the archive.
       
   918  * By default, the 'show_post_count' argument is set to false.
       
   919  *
       
   920  * For the 'format', 'before', and 'after' arguments, see {@link
       
   921  * get_archives_link()}. The values of these arguments have to do with that
       
   922  * function.
       
   923  *
       
   924  * @since 1.2.0
  1308  * @since 1.2.0
   925  *
  1309  *
   926  * @param string|array $args Optional. Override defaults.
  1310  * @see get_archives_link()
       
  1311  *
       
  1312  * @param string|array $args {
       
  1313  *     Default archive links arguments. Optional.
       
  1314  *
       
  1315  *     @type string     $type            Type of archive to retrieve. Accepts 'daily', 'weekly', 'monthly',
       
  1316  *                                       'yearly', 'postbypost', or 'alpha'. Both 'postbypost' and 'alpha'
       
  1317  *                                       display the same archive link list as well as post titles instead
       
  1318  *                                       of displaying dates. The difference between the two is that 'alpha'
       
  1319  *                                       will order by post title and 'postbypost' will order by post date.
       
  1320  *                                       Default 'monthly'.
       
  1321  *     @type string|int $limit           Number of links to limit the query to. Default empty (no limit).
       
  1322  *     @type string     $format          Format each link should take using the $before and $after args.
       
  1323  *                                       Accepts 'link' (`<link>` tag), 'option' (`<option>` tag), 'html'
       
  1324  *                                       (`<li>` tag), or a custom format, which generates a link anchor
       
  1325  *                                       with $before preceding and $after succeeding. Default 'html'.
       
  1326  *     @type string     $before          Markup to prepend to the beginning of each link. Default empty.
       
  1327  *     @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.
       
  1329  *     @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'.
       
  1331  *                                       Default 'DESC'.
       
  1332  * }
   927  * @return string|null String when retrieving, null when displaying.
  1333  * @return string|null String when retrieving, null when displaying.
   928  */
  1334  */
   929 function wp_get_archives($args = '') {
  1335 function wp_get_archives( $args = '' ) {
   930 	global $wpdb, $wp_locale;
  1336 	global $wpdb, $wp_locale;
   931 
  1337 
   932 	$defaults = array(
  1338 	$defaults = array(
   933 		'type' => 'monthly', 'limit' => '',
  1339 		'type' => 'monthly', 'limit' => '',
   934 		'format' => 'html', 'before' => '',
  1340 		'format' => 'html', 'before' => '',
   935 		'after' => '', 'show_post_count' => false,
  1341 		'after' => '', 'show_post_count' => false,
   936 		'echo' => 1, 'order' => 'DESC',
  1342 		'echo' => 1, 'order' => 'DESC',
   937 	);
  1343 	);
   938 
  1344 
   939 	$r = wp_parse_args( $args, $defaults );
  1345 	$r = wp_parse_args( $args, $defaults );
   940 	extract( $r, EXTR_SKIP );
  1346 
   941 
  1347 	if ( '' == $r['type'] ) {
   942 	if ( '' == $type )
  1348 		$r['type'] = 'monthly';
   943 		$type = 'monthly';
  1349 	}
   944 
  1350 
   945 	if ( '' != $limit ) {
  1351 	if ( ! empty( $r['limit'] ) ) {
   946 		$limit = absint($limit);
  1352 		$r['limit'] = absint( $r['limit'] );
   947 		$limit = ' LIMIT '.$limit;
  1353 		$r['limit'] = ' LIMIT ' . $r['limit'];
   948 	}
  1354 	}
   949 
  1355 
   950 	$order = strtoupper( $order );
  1356 	$order = strtoupper( $r['order'] );
   951 	if ( $order !== 'ASC' )
  1357 	if ( $order !== 'ASC' ) {
   952 		$order = 'DESC';
  1358 		$order = 'DESC';
       
  1359 	}
   953 
  1360 
   954 	// this is what will separate dates on weekly archive links
  1361 	// this is what will separate dates on weekly archive links
   955 	$archive_week_separator = '&#8211;';
  1362 	$archive_week_separator = '&#8211;';
   956 
  1363 
   957 	// over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride
  1364 	// over-ride general date format ? 0 = no: use the date format set in Options, 1 = yes: over-ride
   962 
  1369 
   963 	// options for weekly archive (only if you over-ride the general date format)
  1370 	// options for weekly archive (only if you over-ride the general date format)
   964 	$archive_week_start_date_format = 'Y/m/d';
  1371 	$archive_week_start_date_format = 'Y/m/d';
   965 	$archive_week_end_date_format	= 'Y/m/d';
  1372 	$archive_week_end_date_format	= 'Y/m/d';
   966 
  1373 
   967 	if ( !$archive_date_format_over_ride ) {
  1374 	if ( ! $archive_date_format_over_ride ) {
   968 		$archive_day_date_format = get_option('date_format');
  1375 		$archive_day_date_format = get_option( 'date_format' );
   969 		$archive_week_start_date_format = get_option('date_format');
  1376 		$archive_week_start_date_format = get_option( 'date_format' );
   970 		$archive_week_end_date_format = get_option('date_format');
  1377 		$archive_week_end_date_format = get_option( 'date_format' );
   971 	}
  1378 	}
   972 
  1379 
       
  1380 	/**
       
  1381 	 * Filter the SQL WHERE clause for retrieving archives.
       
  1382 	 *
       
  1383 	 * @since 2.2.0
       
  1384 	 *
       
  1385 	 * @param string $sql_where Portion of SQL query containing the WHERE clause.
       
  1386 	 * @param array  $r         An array of default arguments.
       
  1387 	 */
   973 	$where = apply_filters( 'getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r );
  1388 	$where = apply_filters( 'getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r );
       
  1389 
       
  1390 	/**
       
  1391 	 * Filter the SQL JOIN clause for retrieving archives.
       
  1392 	 *
       
  1393 	 * @since 2.2.0
       
  1394 	 *
       
  1395 	 * @param string $sql_join Portion of SQL query containing JOIN clause.
       
  1396 	 * @param array  $r        An array of default arguments.
       
  1397 	 */
   974 	$join = apply_filters( 'getarchives_join', '', $r );
  1398 	$join = apply_filters( 'getarchives_join', '', $r );
   975 
  1399 
   976 	$output = '';
  1400 	$output = '';
   977 
  1401 
   978 	$last_changed = wp_cache_get( 'last_changed', 'posts' );
  1402 	$last_changed = wp_cache_get( 'last_changed', 'posts' );
   979 	if ( ! $last_changed ) {
  1403 	if ( ! $last_changed ) {
   980 		$last_changed = microtime();
  1404 		$last_changed = microtime();
   981 		wp_cache_set( 'last_changed', $last_changed, 'posts' );
  1405 		wp_cache_set( 'last_changed', $last_changed, 'posts' );
   982 	}
  1406 	}
   983 
  1407 
   984 	if ( 'monthly' == $type ) {
  1408 	$limit = $r['limit'];
       
  1409 
       
  1410 	if ( 'monthly' == $r['type'] ) {
   985 		$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";
  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";
   986 		$key = md5( $query );
  1412 		$key = md5( $query );
   987 		$key = "wp_get_archives:$key:$last_changed";
  1413 		$key = "wp_get_archives:$key:$last_changed";
   988 		if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
  1414 		if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
   989 			$results = $wpdb->get_results( $query );
  1415 			$results = $wpdb->get_results( $query );
   990 			wp_cache_set( $key, $results, 'posts' );
  1416 			wp_cache_set( $key, $results, 'posts' );
   991 		}
  1417 		}
   992 		if ( $results ) {
  1418 		if ( $results ) {
   993 			$afterafter = $after;
  1419 			$after = $r['after'];
   994 			foreach ( (array) $results as $result ) {
  1420 			foreach ( (array) $results as $result ) {
   995 				$url = get_month_link( $result->year, $result->month );
  1421 				$url = get_month_link( $result->year, $result->month );
   996 				/* translators: 1: month name, 2: 4-digit year */
  1422 				/* translators: 1: month name, 2: 4-digit year */
   997 				$text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($result->month), $result->year);
  1423 				$text = sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $result->month ), $result->year );
   998 				if ( $show_post_count )
  1424 				if ( $r['show_post_count'] ) {
   999 					$after = '&nbsp;('.$result->posts.')' . $afterafter;
  1425 					$r['after'] = '&nbsp;(' . $result->posts . ')' . $after;
  1000 				$output .= get_archives_link($url, $text, $format, $before, $after);
  1426 				}
       
  1427 				$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
  1001 			}
  1428 			}
  1002 		}
  1429 		}
  1003 	} elseif ('yearly' == $type) {
  1430 	} elseif ( 'yearly' == $r['type'] ) {
  1004 		$query = "SELECT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date) ORDER BY post_date $order $limit";
  1431 		$query = "SELECT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date) ORDER BY post_date $order $limit";
  1005 		$key = md5( $query );
  1432 		$key = md5( $query );
  1006 		$key = "wp_get_archives:$key:$last_changed";
  1433 		$key = "wp_get_archives:$key:$last_changed";
  1007 		if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
  1434 		if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
  1008 			$results = $wpdb->get_results( $query );
  1435 			$results = $wpdb->get_results( $query );
  1009 			wp_cache_set( $key, $results, 'posts' );
  1436 			wp_cache_set( $key, $results, 'posts' );
  1010 		}
  1437 		}
  1011 		if ( $results ) {
  1438 		if ( $results ) {
  1012 			$afterafter = $after;
  1439 			$after = $r['after'];
  1013 			foreach ( (array) $results as $result) {
  1440 			foreach ( (array) $results as $result) {
  1014 				$url = get_year_link($result->year);
  1441 				$url = get_year_link( $result->year );
  1015 				$text = sprintf('%d', $result->year);
  1442 				$text = sprintf( '%d', $result->year );
  1016 				if ($show_post_count)
  1443 				if ( $r['show_post_count'] ) {
  1017 					$after = '&nbsp;('.$result->posts.')' . $afterafter;
  1444 					$r['after'] = '&nbsp;(' . $result->posts . ')' . $after;
  1018 				$output .= get_archives_link($url, $text, $format, $before, $after);
  1445 				}
       
  1446 				$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
  1019 			}
  1447 			}
  1020 		}
  1448 		}
  1021 	} elseif ( 'daily' == $type ) {
  1449 	} elseif ( 'daily' == $r['type'] ) {
  1022 		$query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date $order $limit";
  1450 		$query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date $order $limit";
  1023 		$key = md5( $query );
  1451 		$key = md5( $query );
  1024 		$key = "wp_get_archives:$key:$last_changed";
  1452 		$key = "wp_get_archives:$key:$last_changed";
  1025 		if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
  1453 		if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
  1026 			$results = $wpdb->get_results( $query );
  1454 			$results = $wpdb->get_results( $query );
  1027 			$cache[ $key ] = $results;
       
  1028 			wp_cache_set( $key, $results, 'posts' );
  1455 			wp_cache_set( $key, $results, 'posts' );
  1029 		}
  1456 		}
  1030 		if ( $results ) {
  1457 		if ( $results ) {
  1031 			$afterafter = $after;
  1458 			$after = $r['after'];
  1032 			foreach ( (array) $results as $result ) {
  1459 			foreach ( (array) $results as $result ) {
  1033 				$url	= get_day_link($result->year, $result->month, $result->dayofmonth);
  1460 				$url  = get_day_link( $result->year, $result->month, $result->dayofmonth );
  1034 				$date = sprintf('%1$d-%2$02d-%3$02d 00:00:00', $result->year, $result->month, $result->dayofmonth);
  1461 				$date = sprintf( '%1$d-%2$02d-%3$02d 00:00:00', $result->year, $result->month, $result->dayofmonth );
  1035 				$text = mysql2date($archive_day_date_format, $date);
  1462 				$text = mysql2date( $archive_day_date_format, $date );
  1036 				if ($show_post_count)
  1463 				if ( $r['show_post_count'] ) {
  1037 					$after = '&nbsp;('.$result->posts.')'.$afterafter;
  1464 					$r['after'] = '&nbsp;(' . $result->posts . ')' . $after;
  1038 				$output .= get_archives_link($url, $text, $format, $before, $after);
  1465 				}
       
  1466 				$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
  1039 			}
  1467 			}
  1040 		}
  1468 		}
  1041 	} elseif ( 'weekly' == $type ) {
  1469 	} elseif ( 'weekly' == $r['type'] ) {
  1042 		$week = _wp_mysql_week( '`post_date`' );
  1470 		$week = _wp_mysql_week( '`post_date`' );
  1043 		$query = "SELECT DISTINCT $week AS `week`, YEAR( `post_date` ) AS `yr`, DATE_FORMAT( `post_date`, '%Y-%m-%d' ) AS `yyyymmdd`, count( `ID` ) AS `posts` FROM `$wpdb->posts` $join $where GROUP BY $week, YEAR( `post_date` ) ORDER BY `post_date` $order $limit";
  1471 		$query = "SELECT DISTINCT $week AS `week`, YEAR( `post_date` ) AS `yr`, DATE_FORMAT( `post_date`, '%Y-%m-%d' ) AS `yyyymmdd`, count( `ID` ) AS `posts` FROM `$wpdb->posts` $join $where GROUP BY $week, YEAR( `post_date` ) ORDER BY `post_date` $order $limit";
  1044 		$key = md5( $query );
  1472 		$key = md5( $query );
  1045 		$key = "wp_get_archives:$key:$last_changed";
  1473 		$key = "wp_get_archives:$key:$last_changed";
  1046 		if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
  1474 		if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
  1047 			$results = $wpdb->get_results( $query );
  1475 			$results = $wpdb->get_results( $query );
  1048 			wp_cache_set( $key, $results, 'posts' );
  1476 			wp_cache_set( $key, $results, 'posts' );
  1049 		}
  1477 		}
  1050 		$arc_w_last = '';
  1478 		$arc_w_last = '';
  1051 		$afterafter = $after;
       
  1052 		if ( $results ) {
  1479 		if ( $results ) {
  1053 				foreach ( (array) $results as $result ) {
  1480 			$after = $r['after'];
  1054 					if ( $result->week != $arc_w_last ) {
  1481 			foreach ( (array) $results as $result ) {
  1055 						$arc_year = $result->yr;
  1482 				if ( $result->week != $arc_w_last ) {
  1056 						$arc_w_last = $result->week;
  1483 					$arc_year       = $result->yr;
  1057 						$arc_week = get_weekstartend($result->yyyymmdd, get_option('start_of_week'));
  1484 					$arc_w_last     = $result->week;
  1058 						$arc_week_start = date_i18n($archive_week_start_date_format, $arc_week['start']);
  1485 					$arc_week       = get_weekstartend( $result->yyyymmdd, get_option( 'start_of_week' ) );
  1059 						$arc_week_end = date_i18n($archive_week_end_date_format, $arc_week['end']);
  1486 					$arc_week_start = date_i18n( $archive_week_start_date_format, $arc_week['start'] );
  1060 						$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);
  1487 					$arc_week_end   = date_i18n( $archive_week_end_date_format, $arc_week['end'] );
  1061 						$text = $arc_week_start . $archive_week_separator . $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 );
  1062 						if ($show_post_count)
  1489 					$text           = $arc_week_start . $archive_week_separator . $arc_week_end;
  1063 							$after = '&nbsp;('.$result->posts.')'.$afterafter;
  1490 					if ( $r['show_post_count'] ) {
  1064 						$output .= get_archives_link($url, $text, $format, $before, $after);
  1491 						$r['after'] = '&nbsp;(' . $result->posts . ')' . $after;
  1065 					}
  1492 					}
       
  1493 					$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
  1066 				}
  1494 				}
       
  1495 			}
  1067 		}
  1496 		}
  1068 	} elseif ( ( 'postbypost' == $type ) || ('alpha' == $type) ) {
  1497 	} elseif ( ( 'postbypost' == $r['type'] ) || ('alpha' == $r['type'] ) ) {
  1069 		$orderby = ('alpha' == $type) ? 'post_title ASC ' : 'post_date DESC ';
  1498 		$orderby = ( 'alpha' == $r['type'] ) ? 'post_title ASC ' : 'post_date DESC, ID DESC ';
  1070 		$query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit";
  1499 		$query = "SELECT * FROM $wpdb->posts $join $where ORDER BY $orderby $limit";
  1071 		$key = md5( $query );
  1500 		$key = md5( $query );
  1072 		$key = "wp_get_archives:$key:$last_changed";
  1501 		$key = "wp_get_archives:$key:$last_changed";
  1073 		if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
  1502 		if ( ! $results = wp_cache_get( $key, 'posts' ) ) {
  1074 			$results = $wpdb->get_results( $query );
  1503 			$results = $wpdb->get_results( $query );
  1075 			wp_cache_set( $key, $results, 'posts' );
  1504 			wp_cache_set( $key, $results, 'posts' );
  1076 		}
  1505 		}
  1077 		if ( $results ) {
  1506 		if ( $results ) {
  1078 			foreach ( (array) $results as $result ) {
  1507 			foreach ( (array) $results as $result ) {
  1079 				if ( $result->post_date != '0000-00-00 00:00:00' ) {
  1508 				if ( $result->post_date != '0000-00-00 00:00:00' ) {
  1080 					$url  = get_permalink( $result );
  1509 					$url = get_permalink( $result );
  1081 					if ( $result->post_title ) {
  1510 					if ( $result->post_title ) {
  1082 						/** This filter is documented in wp-includes/post-template.php */
  1511 						/** This filter is documented in wp-includes/post-template.php */
  1083 						$text = strip_tags( apply_filters( 'the_title', $result->post_title, $result->ID ) );
  1512 						$text = strip_tags( apply_filters( 'the_title', $result->post_title, $result->ID ) );
  1084 					} else {
  1513 					} else {
  1085 						$text = $result->ID;
  1514 						$text = $result->ID;
  1086 					}
  1515 					}
  1087 					$output .= get_archives_link($url, $text, $format, $before, $after);
  1516 					$output .= get_archives_link( $url, $text, $r['format'], $r['before'], $r['after'] );
  1088 				}
  1517 				}
  1089 			}
  1518 			}
  1090 		}
  1519 		}
  1091 	}
  1520 	}
  1092 	if ( $echo )
  1521 	if ( $r['echo'] ) {
  1093 		echo $output;
  1522 		echo $output;
  1094 	else
  1523 	} else {
  1095 		return $output;
  1524 		return $output;
       
  1525 	}
  1096 }
  1526 }
  1097 
  1527 
  1098 /**
  1528 /**
  1099  * Get number of days since the start of the week.
  1529  * Get number of days since the start of the week.
  1100  *
  1530  *
  1113  *
  1543  *
  1114  * The calendar is cached, which will be retrieved, if it exists. If there are
  1544  * The calendar is cached, which will be retrieved, if it exists. If there are
  1115  * no posts for the month, then it will not be displayed.
  1545  * no posts for the month, then it will not be displayed.
  1116  *
  1546  *
  1117  * @since 1.0.0
  1547  * @since 1.0.0
  1118  * @uses calendar_week_mod()
       
  1119  *
  1548  *
  1120  * @param bool $initial Optional, default is true. Use initial calendar names.
  1549  * @param bool $initial Optional, default is true. Use initial calendar names.
  1121  * @param bool $echo Optional, default is true. Set to false for return.
  1550  * @param bool $echo Optional, default is true. Set to false for return.
  1122  * @return string|null String when retrieving, null when displaying.
  1551  * @return string|null String when retrieving, null when displaying.
  1123  */
  1552  */
  1124 function get_calendar($initial = true, $echo = true) {
  1553 function get_calendar($initial = true, $echo = true) {
  1125 	global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
  1554 	global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
  1126 
  1555 
  1127 	$cache = array();
       
  1128 	$key = md5( $m . $monthnum . $year );
  1556 	$key = md5( $m . $monthnum . $year );
  1129 	if ( $cache = wp_cache_get( 'get_calendar', 'calendar' ) ) {
  1557 	if ( $cache = wp_cache_get( 'get_calendar', 'calendar' ) ) {
  1130 		if ( is_array($cache) && isset( $cache[ $key ] ) ) {
  1558 		if ( is_array($cache) && isset( $cache[ $key ] ) ) {
  1131 			if ( $echo ) {
  1559 			if ( $echo ) {
  1132 				echo apply_filters( 'get_calendar',  $cache[$key] );
  1560 				/** This filter is documented in wp-includes/general-template.php */
       
  1561 				echo apply_filters( 'get_calendar', $cache[$key] );
  1133 				return;
  1562 				return;
  1134 			} else {
  1563 			} else {
  1135 				return apply_filters( 'get_calendar',  $cache[$key] );
  1564 				/** This filter is documented in wp-includes/general-template.php */
       
  1565 				return apply_filters( 'get_calendar', $cache[$key] );
  1136 			}
  1566 			}
  1137 		}
  1567 		}
  1138 	}
  1568 	}
  1139 
  1569 
  1140 	if ( !is_array($cache) )
  1570 	if ( !is_array($cache) )
  1218 
  1648 
  1219 	<tfoot>
  1649 	<tfoot>
  1220 	<tr>';
  1650 	<tr>';
  1221 
  1651 
  1222 	if ( $previous ) {
  1652 	if ( $previous ) {
  1223 		$calendar_output .= "\n\t\t".'<td colspan="3" id="prev"><a href="' . get_month_link($previous->year, $previous->month) . '" title="' . esc_attr( sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($previous->month), date('Y', mktime(0, 0 , 0, $previous->month, 1, $previous->year)))) . '">&laquo; ' . $wp_locale->get_month_abbrev($wp_locale->get_month($previous->month)) . '</a></td>';
  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>';
  1224 	} else {
  1654 	} else {
  1225 		$calendar_output .= "\n\t\t".'<td colspan="3" id="prev" class="pad">&nbsp;</td>';
  1655 		$calendar_output .= "\n\t\t".'<td colspan="3" id="prev" class="pad">&nbsp;</td>';
  1226 	}
  1656 	}
  1227 
  1657 
  1228 	$calendar_output .= "\n\t\t".'<td class="pad">&nbsp;</td>';
  1658 	$calendar_output .= "\n\t\t".'<td class="pad">&nbsp;</td>';
  1229 
  1659 
  1230 	if ( $next ) {
  1660 	if ( $next ) {
  1231 		$calendar_output .= "\n\t\t".'<td colspan="3" id="next"><a href="' . get_month_link($next->year, $next->month) . '" title="' . esc_attr( sprintf(__('View posts for %1$s %2$s'), $wp_locale->get_month($next->month), date('Y', mktime(0, 0 , 0, $next->month, 1, $next->year))) ) . '">' . $wp_locale->get_month_abbrev($wp_locale->get_month($next->month)) . ' &raquo;</a></td>';
  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>';
  1232 	} else {
  1662 	} else {
  1233 		$calendar_output .= "\n\t\t".'<td colspan="3" id="next" class="pad">&nbsp;</td>';
  1663 		$calendar_output .= "\n\t\t".'<td colspan="3" id="next" class="pad">&nbsp;</td>';
  1234 	}
  1664 	}
  1235 
  1665 
  1236 	$calendar_output .= '
  1666 	$calendar_output .= '
  1237 	</tr>
  1667 	</tr>
  1238 	</tfoot>
  1668 	</tfoot>
  1239 
  1669 
  1240 	<tbody>
  1670 	<tbody>
  1241 	<tr>';
  1671 	<tr>';
       
  1672 
       
  1673 	$daywithpost = array();
  1242 
  1674 
  1243 	// Get days with posts
  1675 	// Get days with posts
  1244 	$dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
  1676 	$dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
  1245 		FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00'
  1677 		FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00'
  1246 		AND post_type = 'post' AND post_status = 'publish'
  1678 		AND post_type = 'post' AND post_status = 'publish'
  1247 		AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'", ARRAY_N);
  1679 		AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'", ARRAY_N);
  1248 	if ( $dayswithposts ) {
  1680 	if ( $dayswithposts ) {
  1249 		foreach ( (array) $dayswithposts as $daywith ) {
  1681 		foreach ( (array) $dayswithposts as $daywith ) {
  1250 			$daywithpost[] = $daywith[0];
  1682 			$daywithpost[] = $daywith[0];
  1251 		}
  1683 		}
  1252 	} else {
       
  1253 		$daywithpost = array();
       
  1254 	}
  1684 	}
  1255 
  1685 
  1256 	if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'camino') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false)
  1686 	if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'camino') !== false || stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false)
  1257 		$ak_title_separator = "\n";
  1687 		$ak_title_separator = "\n";
  1258 	else
  1688 	else
  1313 	$calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>";
  1743 	$calendar_output .= "\n\t</tr>\n\t</tbody>\n\t</table>";
  1314 
  1744 
  1315 	$cache[ $key ] = $calendar_output;
  1745 	$cache[ $key ] = $calendar_output;
  1316 	wp_cache_set( 'get_calendar', $cache, 'calendar' );
  1746 	wp_cache_set( 'get_calendar', $cache, 'calendar' );
  1317 
  1747 
  1318 	if ( $echo )
  1748 	if ( $echo ) {
  1319 		echo apply_filters( 'get_calendar',  $calendar_output );
  1749 		/**
  1320 	else
  1750 		 * Filter the HTML calendar output.
  1321 		return apply_filters( 'get_calendar',  $calendar_output );
  1751 		 *
       
  1752 		 * @since 3.0.0
       
  1753 		 *
       
  1754 		 * @param string $calendar_output HTML output of the calendar.
       
  1755 		 */
       
  1756 		echo apply_filters( 'get_calendar', $calendar_output );
       
  1757 	} else {
       
  1758 		/** This filter is documented in wp-includes/general-template.php */
       
  1759 		return apply_filters( 'get_calendar', $calendar_output );
       
  1760 	}
  1322 
  1761 
  1323 }
  1762 }
  1324 
  1763 
  1325 /**
  1764 /**
  1326  * Purge the cached results of get_calendar.
  1765  * Purge the cached results of get_calendar.
  1329  * @since 2.1.0
  1768  * @since 2.1.0
  1330  */
  1769  */
  1331 function delete_get_calendar_cache() {
  1770 function delete_get_calendar_cache() {
  1332 	wp_cache_delete( 'get_calendar', 'calendar' );
  1771 	wp_cache_delete( 'get_calendar', 'calendar' );
  1333 }
  1772 }
  1334 add_action( 'save_post', 'delete_get_calendar_cache' );
       
  1335 add_action( 'delete_post', 'delete_get_calendar_cache' );
       
  1336 add_action( 'update_option_start_of_week', 'delete_get_calendar_cache' );
       
  1337 add_action( 'update_option_gmt_offset', 'delete_get_calendar_cache' );
       
  1338 
  1773 
  1339 /**
  1774 /**
  1340  * Display all of the allowed tags in HTML format with attributes.
  1775  * Display all of the allowed tags in HTML format with attributes.
  1341  *
  1776  *
  1342  * This is useful for displaying in the comment area, which elements and
  1777  * This is useful for displaying in the comment area, which elements and
  1372 function the_date_xml() {
  1807 function the_date_xml() {
  1373 	echo mysql2date( 'Y-m-d', get_post()->post_date, false );
  1808 	echo mysql2date( 'Y-m-d', get_post()->post_date, false );
  1374 }
  1809 }
  1375 
  1810 
  1376 /**
  1811 /**
  1377  * Display or Retrieve the date the current $post was written (once per date)
  1812  * Display or Retrieve the date the current post was written (once per date)
  1378  *
  1813  *
  1379  * Will only output the date if the current post's date is different from the
  1814  * Will only output the date if the current post's date is different from the
  1380  * previous one output.
  1815  * previous one output.
  1381  *
  1816  *
  1382  * i.e. Only one date listing will show per day worth of posts shown in the loop, even if the
  1817  * i.e. Only one date listing will show per day worth of posts shown in the loop, even if the
  1384  *
  1819  *
  1385  * HTML output can be filtered with 'the_date'.
  1820  * HTML output can be filtered with 'the_date'.
  1386  * Date string output can be filtered with 'get_the_date'.
  1821  * Date string output can be filtered with 'get_the_date'.
  1387  *
  1822  *
  1388  * @since 0.71
  1823  * @since 0.71
  1389  * @uses get_the_date()
  1824  *
  1390  * @param string $d Optional. PHP date format defaults to the date_format option if not specified.
  1825  * @param string $d Optional. PHP date format defaults to the date_format option if not specified.
  1391  * @param string $before Optional. Output before the date.
  1826  * @param string $before Optional. Output before the date.
  1392  * @param string $after Optional. Output after the date.
  1827  * @param string $after Optional. Output after the date.
  1393  * @param bool $echo Optional, default is display. Whether to echo the date or return it.
  1828  * @param bool $echo Optional, default is display. Whether to echo the date or return it.
  1394  * @return string|null Null if displaying, string if retrieving.
  1829  * @return string|null Null if displaying, string if retrieving.
  1395  */
  1830  */
  1396 function the_date( $d = '', $before = '', $after = '', $echo = true ) {
  1831 function the_date( $d = '', $before = '', $after = '', $echo = true ) {
  1397 	global $currentday, $previousday;
  1832 	global $currentday, $previousday;
  1398 	$the_date = '';
  1833 
  1399 	if ( $currentday != $previousday ) {
  1834 	if ( $currentday != $previousday ) {
  1400 		$the_date .= $before;
  1835 		$the_date = $before . get_the_date( $d ) . $after;
  1401 		$the_date .= get_the_date( $d );
       
  1402 		$the_date .= $after;
       
  1403 		$previousday = $currentday;
  1836 		$previousday = $currentday;
  1404 
  1837 
  1405 		$the_date = apply_filters('the_date', $the_date, $d, $before, $after);
  1838 		/**
       
  1839 		 * Filter the date a post was published for display.
       
  1840 		 *
       
  1841 		 * @since 0.71
       
  1842 		 *
       
  1843 		 * @param string $the_date The formatted date string.
       
  1844 		 * @param string $d        PHP date format. Defaults to 'date_format' option
       
  1845 		 *                         if not specified.
       
  1846 		 * @param string $before   HTML output before the date.
       
  1847 		 * @param string $after    HTML output after the date.
       
  1848 		 */
       
  1849 		$the_date = apply_filters( 'the_date', $the_date, $d, $before, $after );
  1406 
  1850 
  1407 		if ( $echo )
  1851 		if ( $echo )
  1408 			echo $the_date;
  1852 			echo $the_date;
  1409 		else
  1853 		else
  1410 			return $the_date;
  1854 			return $the_date;
  1412 
  1856 
  1413 	return null;
  1857 	return null;
  1414 }
  1858 }
  1415 
  1859 
  1416 /**
  1860 /**
  1417  * Retrieve the date the current $post was written.
  1861  * Retrieve the date on which the post was written.
  1418  *
  1862  *
  1419  * Unlike the_date() this function will always return the date.
  1863  * Unlike the_date() this function will always return the date.
  1420  * Modify output with 'get_the_date' filter.
  1864  * Modify output with 'get_the_date' filter.
  1421  *
  1865  *
  1422  * @since 3.0.0
  1866  * @since 3.0.0
  1423  *
  1867  *
  1424  * @param string $d Optional. PHP date format defaults to the date_format option if not specified.
  1868  * @param  string      $d    Optional. PHP date format defaults to the date_format option if not specified.
  1425  * @return string|null Null if displaying, string if retrieving.
  1869  * @param  int|WP_Post $post Optional. Post ID or WP_Post object. Default current post.
  1426  */
  1870  * @return false|string Date the current post was written. False on failure.
  1427 function get_the_date( $d = '' ) {
  1871  */
  1428 	$post = get_post();
  1872 function get_the_date( $d = '', $post = null ) {
  1429 	$the_date = '';
  1873 	$post = get_post( $post );
  1430 
  1874 
  1431 	if ( '' == $d )
  1875 	if ( ! $post ) {
  1432 		$the_date .= mysql2date(get_option('date_format'), $post->post_date);
  1876 		return false;
  1433 	else
  1877 	}
  1434 		$the_date .= mysql2date($d, $post->post_date);
  1878 
  1435 
  1879 	if ( '' == $d ) {
  1436 	return apply_filters('get_the_date', $the_date, $d);
  1880 		$the_date = mysql2date( get_option( 'date_format' ), $post->post_date );
       
  1881 	} else {
       
  1882 		$the_date = mysql2date( $d, $post->post_date );
       
  1883 	}
       
  1884 
       
  1885 	/**
       
  1886 	 * Filter the date a post was published.
       
  1887 	 *
       
  1888 	 * @since 3.0.0
       
  1889 	 *
       
  1890 	 * @param string      $the_date The formatted date.
       
  1891 	 * @param string      $d        PHP date format. Defaults to 'date_format' option
       
  1892 	 *                              if not specified.
       
  1893 	 * @param int|WP_Post $post     The post object or ID.
       
  1894 	 */
       
  1895 	return apply_filters( 'get_the_date', $the_date, $d, $post );
  1437 }
  1896 }
  1438 
  1897 
  1439 /**
  1898 /**
  1440  * Display the date on which the post was last modified.
  1899  * Display the date on which the post was last modified.
  1441  *
  1900  *
  1448  * @return string|null Null if displaying, string if retrieving.
  1907  * @return string|null Null if displaying, string if retrieving.
  1449  */
  1908  */
  1450 function the_modified_date($d = '', $before='', $after='', $echo = true) {
  1909 function the_modified_date($d = '', $before='', $after='', $echo = true) {
  1451 
  1910 
  1452 	$the_modified_date = $before . get_the_modified_date($d) . $after;
  1911 	$the_modified_date = $before . get_the_modified_date($d) . $after;
  1453 	$the_modified_date = apply_filters('the_modified_date', $the_modified_date, $d, $before, $after);
  1912 
       
  1913 	/**
       
  1914 	 * Filter the date a post was last modified for display.
       
  1915 	 *
       
  1916 	 * @since 2.1.0
       
  1917 	 *
       
  1918 	 * @param string $the_modified_date The last modified date.
       
  1919 	 * @param string $d                 PHP date format. Defaults to 'date_format' option
       
  1920 	 *                                  if not specified.
       
  1921 	 * @param string $before            HTML output before the date.
       
  1922 	 * @param string $after             HTML output after the date.
       
  1923 	 */
       
  1924 	$the_modified_date = apply_filters( 'the_modified_date', $the_modified_date, $d, $before, $after );
  1454 
  1925 
  1455 	if ( $echo )
  1926 	if ( $echo )
  1456 		echo $the_modified_date;
  1927 		echo $the_modified_date;
  1457 	else
  1928 	else
  1458 		return $the_modified_date;
  1929 		return $the_modified_date;
  1470 function get_the_modified_date($d = '') {
  1941 function get_the_modified_date($d = '') {
  1471 	if ( '' == $d )
  1942 	if ( '' == $d )
  1472 		$the_time = get_post_modified_time(get_option('date_format'), null, null, true);
  1943 		$the_time = get_post_modified_time(get_option('date_format'), null, null, true);
  1473 	else
  1944 	else
  1474 		$the_time = get_post_modified_time($d, null, null, true);
  1945 		$the_time = get_post_modified_time($d, null, null, true);
  1475 	return apply_filters('get_the_modified_date', $the_time, $d);
  1946 
       
  1947 	/**
       
  1948 	 * Filter the date a post was last modified.
       
  1949 	 *
       
  1950 	 * @since 2.1.0
       
  1951 	 *
       
  1952 	 * @param string $the_time The formatted date.
       
  1953 	 * @param string $d        PHP date format. Defaults to value specified in
       
  1954 	 *                         'date_format' option.
       
  1955 	 */
       
  1956 	return apply_filters( 'get_the_modified_date', $the_time, $d );
  1476 }
  1957 }
  1477 
  1958 
  1478 /**
  1959 /**
  1479  * Display the time at which the post was written.
  1960  * Display the time at which the post was written.
  1480  *
  1961  *
  1481  * @since 0.71
  1962  * @since 0.71
  1482  *
  1963  *
  1483  * @param string $d Either 'G', 'U', or php date format.
  1964  * @param string $d Either 'G', 'U', or php date format.
  1484  */
  1965  */
  1485 function the_time( $d = '' ) {
  1966 function the_time( $d = '' ) {
  1486 	echo apply_filters('the_time', get_the_time( $d ), $d);
  1967 	/**
       
  1968 	 * Filter the time a post was written for display.
       
  1969 	 *
       
  1970 	 * @since 0.71
       
  1971 	 *
       
  1972 	 * @param string $get_the_time The formatted time.
       
  1973 	 * @param string $d            The time format. Accepts 'G', 'U',
       
  1974 	 *                             or php date format.
       
  1975 	 */
       
  1976 	echo apply_filters( 'the_time', get_the_time( $d ), $d );
  1487 }
  1977 }
  1488 
  1978 
  1489 /**
  1979 /**
  1490  * Retrieve the time at which the post was written.
  1980  * Retrieve the time at which the post was written.
  1491  *
  1981  *
  1492  * @since 1.5.0
  1982  * @since 1.5.0
  1493  *
  1983  *
  1494  * @param string $d Optional Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
  1984  * @param string      $d    Optional. Format to use for retrieving the time the post
  1495  * @param int|object $post Optional post ID or object. Default is global $post object.
  1985  *                          was written. Either 'G', 'U', or php date format defaults
  1496  * @return string
  1986  *                          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.
       
  1988  * @return false|string Formatted date string or Unix timestamp. False on failure.
  1497  */
  1989  */
  1498 function get_the_time( $d = '', $post = null ) {
  1990 function get_the_time( $d = '', $post = null ) {
  1499 	$post = get_post($post);
  1991 	$post = get_post($post);
       
  1992 
       
  1993 	if ( ! $post ) {
       
  1994 		return false;
       
  1995 	}
  1500 
  1996 
  1501 	if ( '' == $d )
  1997 	if ( '' == $d )
  1502 		$the_time = get_post_time(get_option('time_format'), false, $post, true);
  1998 		$the_time = get_post_time(get_option('time_format'), false, $post, true);
  1503 	else
  1999 	else
  1504 		$the_time = get_post_time($d, false, $post, true);
  2000 		$the_time = get_post_time($d, false, $post, true);
  1505 	return apply_filters('get_the_time', $the_time, $d, $post);
  2001 
       
  2002 	/**
       
  2003 	 * Filter the time a post was written.
       
  2004 	 *
       
  2005 	 * @since 1.5.0
       
  2006 	 *
       
  2007 	 * @param string      $the_time The formatted time.
       
  2008 	 * @param string      $d        Format to use for retrieving the time the post was written.
       
  2009 	 *                              Accepts 'G', 'U', or php date format value specified
       
  2010 	 *                              in 'time_format' option. Default empty.
       
  2011 	 * @param int|WP_Post $post     WP_Post object or ID.
       
  2012 	 */
       
  2013 	return apply_filters( 'get_the_time', $the_time, $d, $post );
  1506 }
  2014 }
  1507 
  2015 
  1508 /**
  2016 /**
  1509  * Retrieve the time at which the post was written.
  2017  * Retrieve the time at which the post was written.
  1510  *
  2018  *
  1511  * @since 2.0.0
  2019  * @since 2.0.0
  1512  *
  2020  *
  1513  * @param string $d Optional Either 'G', 'U', or php date format.
  2021  * @param string      $d         Optional. Format to use for retrieving the time the post
  1514  * @param bool $gmt Optional, default is false. Whether to return the gmt time.
  2022  *                               was written. Either 'G', 'U', or php date format. Default 'U'.
  1515  * @param int|object $post Optional post ID or object. Default is global $post object.
  2023  * @param bool        $gmt       Optional. Whether to retrieve the GMT time. Default false.
  1516  * @param bool $translate Whether to translate the time string
  2024  * @param int|WP_Post $post      WP_Post object or ID. Default is global $post object.
  1517  * @return string
  2025  * @param bool        $translate Whether to translate the time string. Default false.
  1518  */
  2026  * @return false|string|int Formatted date string or Unix timestamp. False on failure.
  1519 function get_post_time( $d = 'U', $gmt = false, $post = null, $translate = false ) { // returns timestamp
  2027  */
       
  2028 function get_post_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
  1520 	$post = get_post($post);
  2029 	$post = get_post($post);
       
  2030 
       
  2031 	if ( ! $post ) {
       
  2032 		return false;
       
  2033 	}
  1521 
  2034 
  1522 	if ( $gmt )
  2035 	if ( $gmt )
  1523 		$time = $post->post_date_gmt;
  2036 		$time = $post->post_date_gmt;
  1524 	else
  2037 	else
  1525 		$time = $post->post_date;
  2038 		$time = $post->post_date;
  1526 
  2039 
  1527 	$time = mysql2date($d, $time, $translate);
  2040 	$time = mysql2date($d, $time, $translate);
  1528 	return apply_filters('get_post_time', $time, $d, $gmt);
  2041 
       
  2042 	/**
       
  2043 	 * Filter the localized time a post was written.
       
  2044 	 *
       
  2045 	 * @since 2.6.0
       
  2046 	 *
       
  2047 	 * @param string $time The formatted time.
       
  2048 	 * @param string $d    Format to use for retrieving the time the post was written.
       
  2049 	 *                     Accepts 'G', 'U', or php date format. Default 'U'.
       
  2050 	 * @param bool   $gmt  Whether to retrieve the GMT time. Default false.
       
  2051 	 */
       
  2052 	return apply_filters( 'get_post_time', $time, $d, $gmt );
  1529 }
  2053 }
  1530 
  2054 
  1531 /**
  2055 /**
  1532  * Display the time at which the post was last modified.
  2056  * Display the time at which the post was last modified.
  1533  *
  2057  *
  1534  * @since 2.0.0
  2058  * @since 2.0.0
  1535  *
  2059  *
  1536  * @param string $d Optional Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
  2060  * @param string $d Optional Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
  1537  */
  2061  */
  1538 function the_modified_time($d = '') {
  2062 function the_modified_time($d = '') {
  1539 	echo apply_filters('the_modified_time', get_the_modified_time($d), $d);
  2063 	/**
       
  2064 	 * Filter the localized time a post was last modified, for display.
       
  2065 	 *
       
  2066 	 * @since 2.0.0
       
  2067 	 *
       
  2068 	 * @param string $get_the_modified_time The formatted time.
       
  2069 	 * @param string $d                     The time format. Accepts 'G', 'U',
       
  2070 	 *                                      or php date format. Defaults to value
       
  2071 	 *                                      specified in 'time_format' option.
       
  2072 	 */
       
  2073 	echo apply_filters( 'the_modified_time', get_the_modified_time($d), $d );
  1540 }
  2074 }
  1541 
  2075 
  1542 /**
  2076 /**
  1543  * Retrieve the time at which the post was last modified.
  2077  * Retrieve the time at which the post was last modified.
  1544  *
  2078  *
  1550 function get_the_modified_time($d = '') {
  2084 function get_the_modified_time($d = '') {
  1551 	if ( '' == $d )
  2085 	if ( '' == $d )
  1552 		$the_time = get_post_modified_time(get_option('time_format'), null, null, true);
  2086 		$the_time = get_post_modified_time(get_option('time_format'), null, null, true);
  1553 	else
  2087 	else
  1554 		$the_time = get_post_modified_time($d, null, null, true);
  2088 		$the_time = get_post_modified_time($d, null, null, true);
  1555 	return apply_filters('get_the_modified_time', $the_time, $d);
  2089 
       
  2090 	/**
       
  2091 	 * Filter the localized time a post was last modified.
       
  2092 	 *
       
  2093 	 * @since 2.0.0
       
  2094 	 *
       
  2095 	 * @param string $the_time The formatted time.
       
  2096 	 * @param string $d        Format to use for retrieving the time the post was
       
  2097 	 *                         written. Accepts 'G', 'U', or php date format. Defaults
       
  2098 	 *                         to value specified in 'time_format' option.
       
  2099 	 */
       
  2100 	return apply_filters( 'get_the_modified_time', $the_time, $d );
  1556 }
  2101 }
  1557 
  2102 
  1558 /**
  2103 /**
  1559  * Retrieve the time at which the post was last modified.
  2104  * Retrieve the time at which the post was last modified.
  1560  *
  2105  *
  1561  * @since 2.0.0
  2106  * @since 2.0.0
  1562  *
  2107  *
  1563  * @param string $d Optional, default is 'U'. Either 'G', 'U', or php date format.
  2108  * @param string      $d         Optional. Format to use for retrieving the time the post
  1564  * @param bool $gmt Optional, default is false. Whether to return the gmt time.
  2109  *                               was modified. Either 'G', 'U', or php date format. Default 'U'.
  1565  * @param int|object $post Optional, default is global post object. A post_id or post object
  2110  * @param bool        $gmt       Optional. Whether to retrieve the GMT time. Default false.
  1566  * @param bool $translate Optional, default is false. Whether to translate the result
  2111  * @param int|WP_Post $post      WP_Post object or ID. Default is global $post object.
  1567  * @return string Returns timestamp
  2112  * @param bool        $translate Whether to translate the time string. Default false.
       
  2113  * @return false|string Formatted date string or Unix timestamp. False on failure.
  1568  */
  2114  */
  1569 function get_post_modified_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
  2115 function get_post_modified_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
  1570 	$post = get_post($post);
  2116 	$post = get_post($post);
       
  2117 
       
  2118 	if ( ! $post ) {
       
  2119 		return false;
       
  2120 	}
  1571 
  2121 
  1572 	if ( $gmt )
  2122 	if ( $gmt )
  1573 		$time = $post->post_modified_gmt;
  2123 		$time = $post->post_modified_gmt;
  1574 	else
  2124 	else
  1575 		$time = $post->post_modified;
  2125 		$time = $post->post_modified;
  1576 	$time = mysql2date($d, $time, $translate);
  2126 	$time = mysql2date($d, $time, $translate);
  1577 
  2127 
  1578 	return apply_filters('get_post_modified_time', $time, $d, $gmt);
  2128 	/**
       
  2129 	 * Filter the localized time a post was last modified.
       
  2130 	 *
       
  2131 	 * @since 2.8.0
       
  2132 	 *
       
  2133 	 * @param string $time The formatted time.
       
  2134 	 * @param string $d    The date format. Accepts 'G', 'U', or php date format. Default 'U'.
       
  2135 	 * @param bool   $gmt  Whether to return the GMT time. Default false.
       
  2136 	 */
       
  2137 	return apply_filters( 'get_post_modified_time', $time, $d, $gmt );
  1579 }
  2138 }
  1580 
  2139 
  1581 /**
  2140 /**
  1582  * Display the weekday on which the post was written.
  2141  * Display the weekday on which the post was written.
  1583  *
  2142  *
  1584  * @since 0.71
  2143  * @since 0.71
  1585  * @uses $wp_locale
  2144  * @uses $wp_locale
  1586  * @uses $post
       
  1587  */
  2145  */
  1588 function the_weekday() {
  2146 function the_weekday() {
  1589 	global $wp_locale;
  2147 	global $wp_locale;
  1590 	$the_weekday = $wp_locale->get_weekday( mysql2date( 'w', get_post()->post_date, false ) );
  2148 	$the_weekday = $wp_locale->get_weekday( mysql2date( 'w', get_post()->post_date, false ) );
  1591 	$the_weekday = apply_filters('the_weekday', $the_weekday);
  2149 
       
  2150 	/**
       
  2151 	 * Filter the weekday on which the post was written, for display.
       
  2152 	 *
       
  2153 	 * @since 0.71
       
  2154 	 *
       
  2155 	 * @param string $the_weekday
       
  2156 	 */
       
  2157 	$the_weekday = apply_filters( 'the_weekday', $the_weekday );
  1592 	echo $the_weekday;
  2158 	echo $the_weekday;
  1593 }
  2159 }
  1594 
  2160 
  1595 /**
  2161 /**
  1596  * Display the weekday on which the post was written.
  2162  * Display the weekday on which the post was written.
  1610 		$the_weekday_date .= $before;
  2176 		$the_weekday_date .= $before;
  1611 		$the_weekday_date .= $wp_locale->get_weekday( mysql2date( 'w', get_post()->post_date, false ) );
  2177 		$the_weekday_date .= $wp_locale->get_weekday( mysql2date( 'w', get_post()->post_date, false ) );
  1612 		$the_weekday_date .= $after;
  2178 		$the_weekday_date .= $after;
  1613 		$previousweekday = $currentday;
  2179 		$previousweekday = $currentday;
  1614 	}
  2180 	}
  1615 	$the_weekday_date = apply_filters('the_weekday_date', $the_weekday_date, $before, $after);
  2181 
       
  2182 	/**
       
  2183 	 * Filter the localized date on which the post was written, for display.
       
  2184 	 *
       
  2185 	 * @since 0.71
       
  2186 	 *
       
  2187 	 * @param string $the_weekday_date
       
  2188 	 * @param string $before           The HTML to output before the date.
       
  2189 	 * @param string $after            The HTML to output after the date.
       
  2190 	 */
       
  2191 	$the_weekday_date = apply_filters( 'the_weekday_date', $the_weekday_date, $before, $after );
  1616 	echo $the_weekday_date;
  2192 	echo $the_weekday_date;
  1617 }
  2193 }
  1618 
  2194 
  1619 /**
  2195 /**
  1620  * Fire the wp_head action
  2196  * Fire the wp_head action
  1621  *
  2197  *
  1622  * @since 1.2.0
  2198  * @since 1.2.0
  1623  * @uses do_action() Calls 'wp_head' hook.
       
  1624  */
  2199  */
  1625 function wp_head() {
  2200 function wp_head() {
  1626 	do_action('wp_head');
  2201 	/**
       
  2202 	 * Print scripts or data in the head tag on the front end.
       
  2203 	 *
       
  2204 	 * @since 1.5.0
       
  2205 	 */
       
  2206 	do_action( 'wp_head' );
  1627 }
  2207 }
  1628 
  2208 
  1629 /**
  2209 /**
  1630  * Fire the wp_footer action
  2210  * Fire the wp_footer action
  1631  *
  2211  *
  1632  * @since 1.5.1
  2212  * @since 1.5.1
  1633  * @uses do_action() Calls 'wp_footer' hook.
       
  1634  */
  2213  */
  1635 function wp_footer() {
  2214 function wp_footer() {
  1636 	do_action('wp_footer');
  2215 	/**
       
  2216 	 * Print scripts or data before the closing body tag on the front end.
       
  2217 	 *
       
  2218 	 * @since 1.5.1
       
  2219 	 */
       
  2220 	do_action( 'wp_footer' );
  1637 }
  2221 }
  1638 
  2222 
  1639 /**
  2223 /**
  1640  * Display the links to the general feeds.
  2224  * Display the links to the general feeds.
  1641  *
  2225  *
  1692 	if ( is_singular() ) {
  2276 	if ( is_singular() ) {
  1693 		$id = 0;
  2277 		$id = 0;
  1694 		$post = get_post( $id );
  2278 		$post = get_post( $id );
  1695 
  2279 
  1696 		if ( comments_open() || pings_open() || $post->comment_count > 0 ) {
  2280 		if ( comments_open() || pings_open() || $post->comment_count > 0 ) {
  1697 			$title = sprintf( $args['singletitle'], get_bloginfo('name'), $args['separator'], esc_html( get_the_title() ) );
  2281 			$title = sprintf( $args['singletitle'], get_bloginfo('name'), $args['separator'], the_title_attribute( array( 'echo' => false ) ) );
  1698 			$href = get_post_comments_feed_link( $post->ID );
  2282 			$href = get_post_comments_feed_link( $post->ID );
  1699 		}
  2283 		}
  1700 	} elseif ( is_post_type_archive() ) {
  2284 	} elseif ( is_post_type_archive() ) {
  1701 		$post_type = get_query_var( 'post_type' );
  2285 		$post_type = get_query_var( 'post_type' );
  1702 		if ( is_array( $post_type ) )
  2286 		if ( is_array( $post_type ) )
  1753  *
  2337  *
  1754  * @link http://msdn.microsoft.com/en-us/library/bb463265.aspx
  2338  * @link http://msdn.microsoft.com/en-us/library/bb463265.aspx
  1755  * @since 2.3.1
  2339  * @since 2.3.1
  1756  */
  2340  */
  1757 function wlwmanifest_link() {
  2341 function wlwmanifest_link() {
  1758 	echo '<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="'
  2342 	echo '<link rel="wlwmanifest" type="application/wlwmanifest+xml" href="',
  1759 		. get_bloginfo('wpurl') . '/wp-includes/wlwmanifest.xml" /> ' . "\n";
  2343 		includes_url( 'wlwmanifest.xml' ), '" /> ', "\n";
  1760 }
  2344 }
  1761 
  2345 
  1762 /**
  2346 /**
  1763  * Display a noindex meta tag if required by the blog configuration.
  2347  * Display a noindex meta tag if required by the blog configuration.
  1764  *
  2348  *
  1783  * Typical usage is as a wp_head callback. add_action( 'wp_head', 'wp_no_robots' );
  2367  * Typical usage is as a wp_head callback. add_action( 'wp_head', 'wp_no_robots' );
  1784  *
  2368  *
  1785  * @since 3.3.0
  2369  * @since 3.3.0
  1786  */
  2370  */
  1787 function wp_no_robots() {
  2371 function wp_no_robots() {
  1788 	echo "<meta name='robots' content='noindex,nofollow' />\n";
  2372 	echo "<meta name='robots' content='noindex,follow' />\n";
  1789 }
       
  1790 
       
  1791 /**
       
  1792  * Determine if TinyMCE is available.
       
  1793  *
       
  1794  * Checks to see if the user has deleted the tinymce files to slim down there WordPress install.
       
  1795  *
       
  1796  * @since 2.1.0
       
  1797  *
       
  1798  * @return bool Whether TinyMCE exists.
       
  1799  */
       
  1800 function rich_edit_exists() {
       
  1801 	global $wp_rich_edit_exists;
       
  1802 	if ( !isset($wp_rich_edit_exists) )
       
  1803 		$wp_rich_edit_exists = file_exists(ABSPATH . WPINC . '/js/tinymce/tiny_mce.js');
       
  1804 	return $wp_rich_edit_exists;
       
  1805 }
  2373 }
  1806 
  2374 
  1807 /**
  2375 /**
  1808  * Whether the user should have a WYSIWIG editor.
  2376  * Whether the user should have a WYSIWIG editor.
  1809  *
  2377  *
  1827 				$wp_rich_edit = true;
  2395 				$wp_rich_edit = true;
  1828 			}
  2396 			}
  1829 		}
  2397 		}
  1830 	}
  2398 	}
  1831 
  2399 
  1832 	return apply_filters('user_can_richedit', $wp_rich_edit);
  2400 	/**
       
  2401 	 * Filter whether the user can access the rich (Visual) editor.
       
  2402 	 *
       
  2403 	 * @since 2.1.0
       
  2404 	 *
       
  2405 	 * @param bool $wp_rich_edit Whether the user can access to the rich (Visual) editor.
       
  2406 	 */
       
  2407 	return apply_filters( 'user_can_richedit', $wp_rich_edit );
  1833 }
  2408 }
  1834 
  2409 
  1835 /**
  2410 /**
  1836  * Find out which editor should be displayed by default.
  2411  * Find out which editor should be displayed by default.
  1837  *
  2412  *
  1842  *
  2417  *
  1843  * @return string Either 'tinymce', or 'html', or 'test'
  2418  * @return string Either 'tinymce', or 'html', or 'test'
  1844  */
  2419  */
  1845 function wp_default_editor() {
  2420 function wp_default_editor() {
  1846 	$r = user_can_richedit() ? 'tinymce' : 'html'; // defaults
  2421 	$r = user_can_richedit() ? 'tinymce' : 'html'; // defaults
  1847 	if ( $user = wp_get_current_user() ) { // look for cookie
  2422 	if ( wp_get_current_user() ) { // look for cookie
  1848 		$ed = get_user_setting('editor', 'tinymce');
  2423 		$ed = get_user_setting('editor', 'tinymce');
  1849 		$r = ( in_array($ed, array('tinymce', 'html', 'test') ) ) ? $ed : $r;
  2424 		$r = ( in_array($ed, array('tinymce', 'html', 'test') ) ) ? $ed : $r;
  1850 	}
  2425 	}
  1851 	return apply_filters( 'wp_default_editor', $r ); // filter
  2426 
       
  2427 	/**
       
  2428 	 * Filter which editor should be displayed by default.
       
  2429 	 *
       
  2430 	 * @since 2.5.0
       
  2431 	 *
       
  2432 	 * @param array $r An array of editors. Accepts 'tinymce', 'html', 'test'.
       
  2433 	 */
       
  2434 	return apply_filters( 'wp_default_editor', $r );
  1852 }
  2435 }
  1853 
  2436 
  1854 /**
  2437 /**
  1855  * Renders an editor.
  2438  * Renders an editor.
  1856  *
  2439  *
  1857  * Using this function is the proper way to output all needed components for both TinyMCE and Quicktags.
  2440  * Using this function is the proper way to output all needed components for both TinyMCE and Quicktags.
  1858  * _WP_Editors should not be used directly. See http://core.trac.wordpress.org/ticket/17144.
  2441  * _WP_Editors should not be used directly. See https://core.trac.wordpress.org/ticket/17144.
  1859  *
  2442  *
  1860  * NOTE: Once initialized the TinyMCE editor cannot be safely moved in the DOM. For that reason
  2443  * NOTE: Once initialized the TinyMCE editor cannot be safely moved in the DOM. For that reason
  1861  * running wp_editor() inside of a metabox is not a good idea unless only Quicktags is used.
  2444  * running wp_editor() inside of a metabox is not a good idea unless only Quicktags is used.
  1862  * On the post edit screen several actions can be used to include additional editors
  2445  * On the post edit screen several actions can be used to include additional editors
  1863  * containing TinyMCE: 'edit_page_form', 'edit_form_advanced' and 'dbx_post_sidebar'.
  2446  * containing TinyMCE: 'edit_page_form', 'edit_form_advanced' and 'dbx_post_sidebar'.
  1864  * See http://core.trac.wordpress.org/ticket/19173 for more information.
  2447  * See https://core.trac.wordpress.org/ticket/19173 for more information.
  1865  *
  2448  *
  1866  * @see wp-includes/class-wp-editor.php
  2449  * @see wp-includes/class-wp-editor.php
  1867  * @since 3.3.0
  2450  * @since 3.3.0
  1868  *
  2451  *
  1869  * @param string $content Initial content for the editor.
  2452  * @param string $content Initial content for the editor.
  1882  *
  2465  *
  1883  * The search query string is passed through {@link esc_attr()}
  2466  * The search query string is passed through {@link esc_attr()}
  1884  * to ensure that it is safe for placing in an html attribute.
  2467  * to ensure that it is safe for placing in an html attribute.
  1885  *
  2468  *
  1886  * @since 2.3.0
  2469  * @since 2.3.0
  1887  * @uses esc_attr()
       
  1888  *
  2470  *
  1889  * @param bool $escaped Whether the result is escaped. Default true.
  2471  * @param bool $escaped Whether the result is escaped. Default true.
  1890  * 	Only use when you are later escaping it. Do not use unescaped.
  2472  * 	Only use when you are later escaping it. Do not use unescaped.
  1891  * @return string
  2473  * @return string
  1892  */
  2474  */
  1893 function get_search_query( $escaped = true ) {
  2475 function get_search_query( $escaped = true ) {
       
  2476 	/**
       
  2477 	 * Filter the contents of the search query variable.
       
  2478 	 *
       
  2479 	 * @since 2.3.0
       
  2480 	 *
       
  2481 	 * @param mixed $search Contents of the search query variable.
       
  2482 	 */
  1894 	$query = apply_filters( 'get_search_query', get_query_var( 's' ) );
  2483 	$query = apply_filters( 'get_search_query', get_query_var( 's' ) );
       
  2484 
  1895 	if ( $escaped )
  2485 	if ( $escaped )
  1896 		$query = esc_attr( $query );
  2486 		$query = esc_attr( $query );
  1897 	return $query;
  2487 	return $query;
  1898 }
  2488 }
  1899 
  2489 
  1901  * Display the contents of the search query variable.
  2491  * Display the contents of the search query variable.
  1902  *
  2492  *
  1903  * The search query string is passed through {@link esc_attr()}
  2493  * The search query string is passed through {@link esc_attr()}
  1904  * to ensure that it is safe for placing in an html attribute.
  2494  * to ensure that it is safe for placing in an html attribute.
  1905  *
  2495  *
  1906  * @uses esc_attr()
       
  1907  * @since 2.1.0
  2496  * @since 2.1.0
  1908  */
  2497  */
  1909 function the_search_query() {
  2498 function the_search_query() {
       
  2499 	/**
       
  2500 	 * Filter the contents of the search query variable for display.
       
  2501 	 *
       
  2502 	 * @since 2.3.0
       
  2503 	 *
       
  2504 	 * @param mixed $search Contents of the search query variable.
       
  2505 	 */
  1910 	echo esc_attr( apply_filters( 'the_search_query', get_search_query( false ) ) );
  2506 	echo esc_attr( apply_filters( 'the_search_query', get_search_query( false ) ) );
  1911 }
  2507 }
  1912 
  2508 
  1913 /**
  2509 /**
  1914  * Display the language attributes for the html tag.
  2510  * Display the language attributes for the html tag.
  1920  *
  2516  *
  1921  * @param string $doctype The type of html document (xhtml|html).
  2517  * @param string $doctype The type of html document (xhtml|html).
  1922  */
  2518  */
  1923 function language_attributes($doctype = 'html') {
  2519 function language_attributes($doctype = 'html') {
  1924 	$attributes = array();
  2520 	$attributes = array();
  1925 	$output = '';
       
  1926 
  2521 
  1927 	if ( function_exists( 'is_rtl' ) && is_rtl() )
  2522 	if ( function_exists( 'is_rtl' ) && is_rtl() )
  1928 		$attributes[] = 'dir="rtl"';
  2523 		$attributes[] = 'dir="rtl"';
  1929 
  2524 
  1930 	if ( $lang = get_bloginfo('language') ) {
  2525 	if ( $lang = get_bloginfo('language') ) {
  1934 		if ( get_option('html_type') != 'text/html' || $doctype == 'xhtml' )
  2529 		if ( get_option('html_type') != 'text/html' || $doctype == 'xhtml' )
  1935 			$attributes[] = "xml:lang=\"$lang\"";
  2530 			$attributes[] = "xml:lang=\"$lang\"";
  1936 	}
  2531 	}
  1937 
  2532 
  1938 	$output = implode(' ', $attributes);
  2533 	$output = implode(' ', $attributes);
  1939 	$output = apply_filters('language_attributes', $output);
  2534 
  1940 	echo $output;
  2535 	/**
       
  2536 	 * Filter the language attributes for display in the html tag.
       
  2537 	 *
       
  2538 	 * @since 2.5.0
       
  2539 	 *
       
  2540 	 * @param string $output A space-separated list of language attributes.
       
  2541 	 */
       
  2542 	echo apply_filters( 'language_attributes', $output );
  1941 }
  2543 }
  1942 
  2544 
  1943 /**
  2545 /**
  1944  * Retrieve paginated link for archive post pages.
  2546  * Retrieve paginated link for archive post pages.
  1945  *
  2547  *
  1978  * numbers to either side of current page, but not including current page.
  2580  * numbers to either side of current page, but not including current page.
  1979  *
  2581  *
  1980  * It is possible to add query vars to the link by using the 'add_args' argument
  2582  * It is possible to add query vars to the link by using the 'add_args' argument
  1981  * and see {@link add_query_arg()} for more information.
  2583  * and see {@link add_query_arg()} for more information.
  1982  *
  2584  *
       
  2585  * 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
       
  2587  * 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
       
  2589  * anchor tag.
       
  2590  *
  1983  * @since 2.1.0
  2591  * @since 2.1.0
  1984  *
  2592  *
  1985  * @param string|array $args Optional. Override defaults.
  2593  * @param string|array $args {
       
  2594  *     Optional. Array or string of arguments for generating paginated links for archives.
       
  2595  *
       
  2596  *     @type string $base               Base of the paginated url. Default empty.
       
  2597  *     @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
       
  2599  *                                      `max_num_pages` or 1.
       
  2600  *     @type int    $current            The current page number. Default is 'paged' query var or 1.
       
  2601  *     @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.
       
  2603  *                                      Default 1.
       
  2604  *     @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.
       
  2606  *     @type bool   $prev_text          The previous page text. Default '« Previous'.
       
  2607  *     @type bool   $next_text          The next page text. Default '« Previous'.
       
  2608  *     @type string $type               Controls format of the returned value. Possible values are 'plain',
       
  2609  *                                      'array' and 'list'. Default is 'plain'.
       
  2610  *     @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.
       
  2612  *     @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.
       
  2614  * }
  1986  * @return array|string String of page links or array of page links.
  2615  * @return array|string String of page links or array of page links.
  1987  */
  2616  */
  1988 function paginate_links( $args = '' ) {
  2617 function paginate_links( $args = '' ) {
       
  2618 	global $wp_query, $wp_rewrite;
       
  2619 
       
  2620 	// Setting up default values based on the current URL.
       
  2621 	$pagenum_link = html_entity_decode( get_pagenum_link() );
       
  2622 	$url_parts    = explode( '?', $pagenum_link );
       
  2623 
       
  2624 	// Get max pages and current page out of the current query, if available.
       
  2625 	$total   = isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1;
       
  2626 	$current = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1;
       
  2627 
       
  2628 	// Append the format placeholder to the base URL.
       
  2629 	$pagenum_link = trailingslashit( $url_parts[0] ) . '%_%';
       
  2630 
       
  2631 	// URL base depends on permalink settings.
       
  2632 	$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=%#%';
       
  2634 
  1989 	$defaults = array(
  2635 	$defaults = array(
  1990 		'base' => '%_%', // http://example.com/all_posts.php%_% : %_% is replaced by format (below)
  2636 		'base' => $pagenum_link, // http://example.com/all_posts.php%_% : %_% is replaced by format (below)
  1991 		'format' => '?page=%#%', // ?page=%#% : %#% is replaced by the page number
  2637 		'format' => $format, // ?page=%#% : %#% is replaced by the page number
  1992 		'total' => 1,
  2638 		'total' => $total,
  1993 		'current' => 0,
  2639 		'current' => $current,
  1994 		'show_all' => false,
  2640 		'show_all' => false,
  1995 		'prev_next' => true,
  2641 		'prev_next' => true,
  1996 		'prev_text' => __('&laquo; Previous'),
  2642 		'prev_text' => __('&laquo; Previous'),
  1997 		'next_text' => __('Next &raquo;'),
  2643 		'next_text' => __('Next &raquo;'),
  1998 		'end_size' => 1,
  2644 		'end_size' => 1,
  1999 		'mid_size' => 2,
  2645 		'mid_size' => 2,
  2000 		'type' => 'plain',
  2646 		'type' => 'plain',
  2001 		'add_args' => false, // array of query args to add
  2647 		'add_args' => array(), // array of query args to add
  2002 		'add_fragment' => ''
  2648 		'add_fragment' => '',
       
  2649 		'before_page_number' => '',
       
  2650 		'after_page_number' => ''
  2003 	);
  2651 	);
  2004 
  2652 
  2005 	$args = wp_parse_args( $args, $defaults );
  2653 	$args = wp_parse_args( $args, $defaults );
  2006 	extract($args, EXTR_SKIP);
  2654 
       
  2655 	if ( ! is_array( $args['add_args'] ) ) {
       
  2656 		$args['add_args'] = array();
       
  2657 	}
       
  2658 
       
  2659 	// Merge additional query vars found in the original URL into 'add_args' array.
       
  2660 	if ( isset( $url_parts[1] ) ) {
       
  2661 		// Find the format argument.
       
  2662 		$format_query = parse_url( str_replace( '%_%', $args['format'], $args['base'] ), PHP_URL_QUERY );
       
  2663 		wp_parse_str( $format_query, $format_arg );
       
  2664 
       
  2665 		// 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 );
       
  2667 		$args['add_args'] = array_merge( $args['add_args'], urlencode_deep( $query_args ) );
       
  2668 	}
  2007 
  2669 
  2008 	// Who knows what else people pass in $args
  2670 	// Who knows what else people pass in $args
  2009 	$total = (int) $total;
  2671 	$total = (int) $args['total'];
  2010 	if ( $total < 2 )
  2672 	if ( $total < 2 ) {
  2011 		return;
  2673 		return;
  2012 	$current  = (int) $current;
  2674 	}
  2013 	$end_size = 0  < (int) $end_size ? (int) $end_size : 1; // Out of bounds?  Make it the default.
  2675 	$current  = (int) $args['current'];
  2014 	$mid_size = 0 <= (int) $mid_size ? (int) $mid_size : 2;
  2676 	$end_size = (int) $args['end_size']; // Out of bounds?  Make it the default.
  2015 	$add_args = is_array($add_args) ? $add_args : false;
  2677 	if ( $end_size < 1 ) {
       
  2678 		$end_size = 1;
       
  2679 	}
       
  2680 	$mid_size = (int) $args['mid_size'];
       
  2681 	if ( $mid_size < 0 ) {
       
  2682 		$mid_size = 2;
       
  2683 	}
       
  2684 	$add_args = $args['add_args'];
  2016 	$r = '';
  2685 	$r = '';
  2017 	$page_links = array();
  2686 	$page_links = array();
  2018 	$n = 0;
       
  2019 	$dots = false;
  2687 	$dots = false;
  2020 
  2688 
  2021 	if ( $prev_next && $current && 1 < $current ) :
  2689 	if ( $args['prev_next'] && $current && 1 < $current ) :
  2022 		$link = str_replace('%_%', 2 == $current ? '' : $format, $base);
  2690 		$link = str_replace( '%_%', 2 == $current ? '' : $args['format'], $args['base'] );
  2023 		$link = str_replace('%#%', $current - 1, $link);
  2691 		$link = str_replace( '%#%', $current - 1, $link );
  2024 		if ( $add_args )
  2692 		if ( $add_args )
  2025 			$link = add_query_arg( $add_args, $link );
  2693 			$link = add_query_arg( $add_args, $link );
  2026 		$link .= $add_fragment;
  2694 		$link .= $args['add_fragment'];
  2027 		$page_links[] = '<a class="prev page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $prev_text . '</a>';
  2695 
       
  2696 		/**
       
  2697 		 * Filter the paginated links for the given archive pages.
       
  2698 		 *
       
  2699 		 * @since 3.0.0
       
  2700 		 *
       
  2701 		 * @param string $link The paginated link URL.
       
  2702 		 */
       
  2703 		$page_links[] = '<a class="prev page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $args['prev_text'] . '</a>';
  2028 	endif;
  2704 	endif;
  2029 	for ( $n = 1; $n <= $total; $n++ ) :
  2705 	for ( $n = 1; $n <= $total; $n++ ) :
  2030 		$n_display = number_format_i18n($n);
       
  2031 		if ( $n == $current ) :
  2706 		if ( $n == $current ) :
  2032 			$page_links[] = "<span class='page-numbers current'>$n_display</span>";
  2707 			$page_links[] = "<span class='page-numbers current'>" . $args['before_page_number'] . number_format_i18n( $n ) . $args['after_page_number'] . "</span>";
  2033 			$dots = true;
  2708 			$dots = true;
  2034 		else :
  2709 		else :
  2035 			if ( $show_all || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) :
  2710 			if ( $args['show_all'] || ( $n <= $end_size || ( $current && $n >= $current - $mid_size && $n <= $current + $mid_size ) || $n > $total - $end_size ) ) :
  2036 				$link = str_replace('%_%', 1 == $n ? '' : $format, $base);
  2711 				$link = str_replace( '%_%', 1 == $n ? '' : $args['format'], $args['base'] );
  2037 				$link = str_replace('%#%', $n, $link);
  2712 				$link = str_replace( '%#%', $n, $link );
  2038 				if ( $add_args )
  2713 				if ( $add_args )
  2039 					$link = add_query_arg( $add_args, $link );
  2714 					$link = add_query_arg( $add_args, $link );
  2040 				$link .= $add_fragment;
  2715 				$link .= $args['add_fragment'];
  2041 				$page_links[] = "<a class='page-numbers' href='" . esc_url( apply_filters( 'paginate_links', $link ) ) . "'>$n_display</a>";
  2716 
       
  2717 				/** This filter is documented in wp-includes/general-template.php */
       
  2718 				$page_links[] = "<a class='page-numbers' href='" . esc_url( apply_filters( 'paginate_links', $link ) ) . "'>" . $args['before_page_number'] . number_format_i18n( $n ) . $args['after_page_number'] . "</a>";
  2042 				$dots = true;
  2719 				$dots = true;
  2043 			elseif ( $dots && !$show_all ) :
  2720 			elseif ( $dots && ! $args['show_all'] ) :
  2044 				$page_links[] = '<span class="page-numbers dots">' . __( '&hellip;' ) . '</span>';
  2721 				$page_links[] = '<span class="page-numbers dots">' . __( '&hellip;' ) . '</span>';
  2045 				$dots = false;
  2722 				$dots = false;
  2046 			endif;
  2723 			endif;
  2047 		endif;
  2724 		endif;
  2048 	endfor;
  2725 	endfor;
  2049 	if ( $prev_next && $current && ( $current < $total || -1 == $total ) ) :
  2726 	if ( $args['prev_next'] && $current && ( $current < $total || -1 == $total ) ) :
  2050 		$link = str_replace('%_%', $format, $base);
  2727 		$link = str_replace( '%_%', $args['format'], $args['base'] );
  2051 		$link = str_replace('%#%', $current + 1, $link);
  2728 		$link = str_replace( '%#%', $current + 1, $link );
  2052 		if ( $add_args )
  2729 		if ( $add_args )
  2053 			$link = add_query_arg( $add_args, $link );
  2730 			$link = add_query_arg( $add_args, $link );
  2054 		$link .= $add_fragment;
  2731 		$link .= $args['add_fragment'];
  2055 		$page_links[] = '<a class="next page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $next_text . '</a>';
  2732 
       
  2733 		/** This filter is documented in wp-includes/general-template.php */
       
  2734 		$page_links[] = '<a class="next page-numbers" href="' . esc_url( apply_filters( 'paginate_links', $link ) ) . '">' . $args['next_text'] . '</a>';
  2056 	endif;
  2735 	endif;
  2057 	switch ( $type ) :
  2736 	switch ( $args['type'] ) {
  2058 		case 'array' :
  2737 		case 'array' :
  2059 			return $page_links;
  2738 			return $page_links;
  2060 			break;
  2739 
  2061 		case 'list' :
  2740 		case 'list' :
  2062 			$r .= "<ul class='page-numbers'>\n\t<li>";
  2741 			$r .= "<ul class='page-numbers'>\n\t<li>";
  2063 			$r .= join("</li>\n\t<li>", $page_links);
  2742 			$r .= join("</li>\n\t<li>", $page_links);
  2064 			$r .= "</li>\n</ul>\n";
  2743 			$r .= "</li>\n</ul>\n";
  2065 			break;
  2744 			break;
       
  2745 
  2066 		default :
  2746 		default :
  2067 			$r = join("\n", $page_links);
  2747 			$r = join("\n", $page_links);
  2068 			break;
  2748 			break;
  2069 	endswitch;
  2749 	}
  2070 	return $r;
  2750 	return $r;
  2071 }
  2751 }
  2072 
  2752 
  2073 /**
  2753 /**
  2074  * Registers an admin colour scheme css file.
  2754  * Registers an admin colour scheme css file.
  2075  *
  2755  *
  2076  * Allows a plugin to register a new admin colour scheme. For example:
  2756  * Allows a plugin to register a new admin colour scheme. For example:
  2077  * <code>
  2757  *
  2078  * wp_admin_css_color('classic', __('Classic'), admin_url("css/colors-classic.css"),
  2758  *     wp_admin_css_color( 'classic', __( 'Classic' ), admin_url( "css/colors-classic.css" ), array(
  2079  * array('#07273E', '#14568A', '#D54E21', '#2683AE'));
  2759  *         '#07273E', '#14568A', '#D54E21', '#2683AE'
  2080  * </code>
  2760  *     ) );
  2081  *
  2761  *
  2082  * @since 2.5.0
  2762  * @since 2.5.0
       
  2763  *
       
  2764  * @todo Properly document optional arguments as such
  2083  *
  2765  *
  2084  * @param string $key The unique key for this theme.
  2766  * @param string $key The unique key for this theme.
  2085  * @param string $name The name of the theme.
  2767  * @param string $name The name of the theme.
  2086  * @param string $url The url of the css file containing the colour scheme.
  2768  * @param string $url The url of the css file containing the colour scheme.
  2087  * @param array $colors Optional An array of CSS color definitions which are used to give the user a feel for the theme.
  2769  * @param array $colors Optional An array of CSS color definitions which are used to give the user a feel for the theme.
  2088  */
  2770  * @param array $icons Optional An array of CSS color definitions used to color any SVG icons
  2089 function wp_admin_css_color($key, $name, $url, $colors = array()) {
  2771  */
       
  2772 function wp_admin_css_color( $key, $name, $url, $colors = array(), $icons = array() ) {
  2090 	global $_wp_admin_css_colors;
  2773 	global $_wp_admin_css_colors;
  2091 
  2774 
  2092 	if ( !isset($_wp_admin_css_colors) )
  2775 	if ( !isset($_wp_admin_css_colors) )
  2093 		$_wp_admin_css_colors = array();
  2776 		$_wp_admin_css_colors = array();
  2094 
  2777 
  2095 	$_wp_admin_css_colors[$key] = (object) array('name' => $name, 'url' => $url, 'colors' => $colors);
  2778 	$_wp_admin_css_colors[$key] = (object) array(
       
  2779 		'name' => $name,
       
  2780 		'url' => $url,
       
  2781 		'colors' => $colors,
       
  2782 		'icon_colors' => $icons,
       
  2783 	);
  2096 }
  2784 }
  2097 
  2785 
  2098 /**
  2786 /**
  2099  * Registers the default Admin color schemes
  2787  * Registers the default Admin color schemes
  2100  *
  2788  *
  2101  * @since 3.0.0
  2789  * @since 3.0.0
  2102  */
  2790  */
  2103 function register_admin_color_schemes() {
  2791 function register_admin_color_schemes() {
  2104 	wp_admin_css_color( 'classic', _x( 'Blue', 'admin color scheme' ), admin_url( 'css/colors-classic.min.css' ),
  2792 	$suffix = is_rtl() ? '-rtl' : '';
  2105 		array( '#5589aa', '#cfdfe9', '#d1e5ee', '#eff8ff' ) );
  2793 	$suffix .= defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
  2106 	wp_admin_css_color( 'fresh', _x( 'Gray', 'admin color scheme' ), admin_url( 'css/colors-fresh.min.css' ),
  2794 
  2107 		array( '#555', '#a0a0a0', '#ccc', '#f1f1f1' ) );
  2795 	wp_admin_css_color( 'fresh', _x( 'Default', 'admin color scheme' ),
       
  2796 		false,
       
  2797 		array( '#222', '#333', '#0073aa', '#00a0d2' ),
       
  2798 		array( 'base' => '#999', 'focus' => '#00a0d2', 'current' => '#fff' )
       
  2799 	);
       
  2800 
       
  2801 	// Other color schemes are not available when running out of src
       
  2802 	if ( false !== strpos( $GLOBALS['wp_version'], '-src' ) )
       
  2803 		return;
       
  2804 
       
  2805 	wp_admin_css_color( 'light', _x( 'Light', 'admin color scheme' ),
       
  2806 		admin_url( "css/colors/light/colors$suffix.css" ),
       
  2807 		array( '#e5e5e5', '#999', '#d64e07', '#04a4cc' ),
       
  2808 		array( 'base' => '#999', 'focus' => '#ccc', 'current' => '#ccc' )
       
  2809 	);
       
  2810 
       
  2811 	wp_admin_css_color( 'blue', _x( 'Blue', 'admin color scheme' ),
       
  2812 		admin_url( "css/colors/blue/colors$suffix.css" ),
       
  2813 		array( '#096484', '#4796b3', '#52accc', '#74B6CE' ),
       
  2814 		array( 'base' => '#e5f8ff', 'focus' => '#fff', 'current' => '#fff' )
       
  2815 	);
       
  2816 
       
  2817 	wp_admin_css_color( 'midnight', _x( 'Midnight', 'admin color scheme' ),
       
  2818 		admin_url( "css/colors/midnight/colors$suffix.css" ),
       
  2819 		array( '#25282b', '#363b3f', '#69a8bb', '#e14d43' ),
       
  2820 		array( 'base' => '#f1f2f3', 'focus' => '#fff', 'current' => '#fff' )
       
  2821 	);
       
  2822 
       
  2823 	wp_admin_css_color( 'sunrise', _x( 'Sunrise', 'admin color scheme' ),
       
  2824 		admin_url( "css/colors/sunrise/colors$suffix.css" ),
       
  2825 		array( '#b43c38', '#cf4944', '#dd823b', '#ccaf0b' ),
       
  2826 		array( 'base' => '#f3f1f1', 'focus' => '#fff', 'current' => '#fff' )
       
  2827 	);
       
  2828 
       
  2829 	wp_admin_css_color( 'ectoplasm', _x( 'Ectoplasm', 'admin color scheme' ),
       
  2830 		admin_url( "css/colors/ectoplasm/colors$suffix.css" ),
       
  2831 		array( '#413256', '#523f6d', '#a3b745', '#d46f15' ),
       
  2832 		array( 'base' => '#ece6f6', 'focus' => '#fff', 'current' => '#fff' )
       
  2833 	);
       
  2834 
       
  2835 	wp_admin_css_color( 'ocean', _x( 'Ocean', 'admin color scheme' ),
       
  2836 		admin_url( "css/colors/ocean/colors$suffix.css" ),
       
  2837 		array( '#627c83', '#738e96', '#9ebaa0', '#aa9d88' ),
       
  2838 		array( 'base' => '#f2fcff', 'focus' => '#fff', 'current' => '#fff' )
       
  2839 	);
       
  2840 
       
  2841 	wp_admin_css_color( 'coffee', _x( 'Coffee', 'admin color scheme' ),
       
  2842 		admin_url( "css/colors/coffee/colors$suffix.css" ),
       
  2843 		array( '#46403c', '#59524c', '#c7a589', '#9ea476' ),
       
  2844 		array( 'base' => '#f3f2f1', 'focus' => '#fff', 'current' => '#fff' )
       
  2845 	);
       
  2846 
  2108 }
  2847 }
  2109 
  2848 
  2110 /**
  2849 /**
  2111  * Display the URL of a WordPress admin CSS file.
  2850  * Display the URL of a WordPress admin CSS file.
  2112  *
  2851  *
  2122 	} else {
  2861 	} else {
  2123 		$_file = admin_url("$file.css");
  2862 		$_file = admin_url("$file.css");
  2124 	}
  2863 	}
  2125 	$_file = add_query_arg( 'version', get_bloginfo( 'version' ),  $_file );
  2864 	$_file = add_query_arg( 'version', get_bloginfo( 'version' ),  $_file );
  2126 
  2865 
       
  2866 	/**
       
  2867 	 * Filter the URI of a WordPress admin CSS file.
       
  2868 	 *
       
  2869 	 * @since 2.3.0
       
  2870 	 *
       
  2871 	 * @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.
       
  2873 	 */
  2127 	return apply_filters( 'wp_admin_css_uri', $_file, $file );
  2874 	return apply_filters( 'wp_admin_css_uri', $_file, $file );
  2128 }
  2875 }
  2129 
  2876 
  2130 /**
  2877 /**
  2131  * Enqueues or directly prints a stylesheet link to the specified CSS file.
  2878  * Enqueues or directly prints a stylesheet link to the specified CSS file.
  2139  * For backward compatibility with WordPress 2.3 calling method: If the $file
  2886  * For backward compatibility with WordPress 2.3 calling method: If the $file
  2140  * (first) parameter does not correspond to a registered CSS file, we assume
  2887  * (first) parameter does not correspond to a registered CSS file, we assume
  2141  * $file is a file relative to wp-admin/ without its ".css" extension. A
  2888  * $file is a file relative to wp-admin/ without its ".css" extension. A
  2142  * stylesheet link to that generated URL is printed.
  2889  * stylesheet link to that generated URL is printed.
  2143  *
  2890  *
  2144  * @package WordPress
       
  2145  * @since 2.3.0
  2891  * @since 2.3.0
  2146  * @uses $wp_styles WordPress Styles Object
  2892  * @uses $wp_styles WordPress Styles Object
  2147  *
  2893  *
  2148  * @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
  2149  * 	 to wp-admin/. Defaults to 'wp-admin'.
  2895  * 	 to wp-admin/. Defaults to 'wp-admin'.
  2150  * @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.
  2151  */
  2897  */
  2152 function wp_admin_css( $file = 'wp-admin', $force_echo = false ) {
  2898 function wp_admin_css( $file = 'wp-admin', $force_echo = false ) {
  2153 	global $wp_styles;
  2899 	global $wp_styles;
  2154 	if ( !is_a($wp_styles, 'WP_Styles') )
  2900 	if ( ! ( $wp_styles instanceof WP_Styles ) ) {
  2155 		$wp_styles = new WP_Styles();
  2901 		$wp_styles = new WP_Styles();
       
  2902 	}
  2156 
  2903 
  2157 	// For backward compatibility
  2904 	// For backward compatibility
  2158 	$handle = 0 === strpos( $file, 'css/' ) ? substr( $file, 4 ) : $file;
  2905 	$handle = 0 === strpos( $file, 'css/' ) ? substr( $file, 4 ) : $file;
  2159 
  2906 
  2160 	if ( $wp_styles->query( $handle ) ) {
  2907 	if ( $wp_styles->query( $handle ) ) {
  2163 		else // Add to style queue
  2910 		else // Add to style queue
  2164 			wp_enqueue_style( $handle );
  2911 			wp_enqueue_style( $handle );
  2165 		return;
  2912 		return;
  2166 	}
  2913 	}
  2167 
  2914 
       
  2915 	/**
       
  2916 	 * Filter the stylesheet link to the specified CSS file.
       
  2917 	 *
       
  2918 	 * If the site is set to display right-to-left, the RTL stylesheet link
       
  2919 	 * will be used instead.
       
  2920 	 *
       
  2921 	 * @since 2.3.0
       
  2922 	 *
       
  2923 	 * @param string $file Style handle name or filename (without ".css" extension)
       
  2924 	 *                     relative to wp-admin/. Defaults to 'wp-admin'.
       
  2925 	 */
  2168 	echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . esc_url( wp_admin_css_uri( $file ) ) . "' type='text/css' />\n", $file );
  2926 	echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . esc_url( wp_admin_css_uri( $file ) ) . "' type='text/css' />\n", $file );
  2169 	if ( function_exists( 'is_rtl' ) && is_rtl() )
  2927 
       
  2928 	if ( function_exists( 'is_rtl' ) && is_rtl() ) {
       
  2929 		/** This filter is documented in wp-includes/general-template.php */
  2170 		echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . esc_url( wp_admin_css_uri( "$file-rtl" ) ) . "' type='text/css' />\n", "$file-rtl" );
  2930 		echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . esc_url( wp_admin_css_uri( "$file-rtl" ) ) . "' type='text/css' />\n", "$file-rtl" );
       
  2931 	}
  2171 }
  2932 }
  2172 
  2933 
  2173 /**
  2934 /**
  2174  * Enqueues the default ThickBox js and css.
  2935  * Enqueues the default ThickBox js and css.
  2175  *
  2936  *
  2191  * Display the XHTML generator that is generated on the wp_head hook.
  2952  * Display the XHTML generator that is generated on the wp_head hook.
  2192  *
  2953  *
  2193  * @since 2.5.0
  2954  * @since 2.5.0
  2194  */
  2955  */
  2195 function wp_generator() {
  2956 function wp_generator() {
       
  2957 	/**
       
  2958 	 * Filter the output of the XHTML generator tag.
       
  2959 	 *
       
  2960 	 * @since 2.5.0
       
  2961 	 *
       
  2962 	 * @param string $generator_type The XHTML generator.
       
  2963 	 */
  2196 	the_generator( apply_filters( 'wp_generator_type', 'xhtml' ) );
  2964 	the_generator( apply_filters( 'wp_generator_type', 'xhtml' ) );
  2197 }
  2965 }
  2198 
  2966 
  2199 /**
  2967 /**
  2200  * Display the generator XML or Comment for RSS, ATOM, etc.
  2968  * Display the generator XML or Comment for RSS, ATOM, etc.
  2201  *
  2969  *
  2202  * Returns the correct generator type for the requested output format. Allows
  2970  * Returns the correct generator type for the requested output format. Allows
  2203  * for a plugin to filter generators overall the the_generator filter.
  2971  * for a plugin to filter generators overall the the_generator filter.
  2204  *
  2972  *
  2205  * @since 2.5.0
  2973  * @since 2.5.0
  2206  * @uses apply_filters() Calls 'the_generator' hook.
       
  2207  *
  2974  *
  2208  * @param string $type The type of generator to output - (html|xhtml|atom|rss2|rdf|comment|export).
  2975  * @param string $type The type of generator to output - (html|xhtml|atom|rss2|rdf|comment|export).
  2209  */
  2976  */
  2210 function the_generator( $type ) {
  2977 function the_generator( $type ) {
  2211 	echo apply_filters('the_generator', get_the_generator($type), $type) . "\n";
  2978 	/**
       
  2979 	 * Filter the output of the XHTML generator tag for display.
       
  2980 	 *
       
  2981 	 * @since 2.5.0
       
  2982 	 *
       
  2983 	 * @param string $generator_type The generator output.
       
  2984 	 * @param string $type           The type of generator to output. Accepts 'html',
       
  2985 	 *                               'xhtml', 'atom', 'rss2', 'rdf', 'comment', 'export'.
       
  2986 	 */
       
  2987 	echo apply_filters( 'the_generator', get_the_generator($type), $type ) . "\n";
  2212 }
  2988 }
  2213 
  2989 
  2214 /**
  2990 /**
  2215  * Creates the generator XML or Comment for RSS, ATOM, etc.
  2991  * Creates the generator XML or Comment for RSS, ATOM, etc.
  2216  *
  2992  *
  2217  * Returns the correct generator type for the requested output format. Allows
  2993  * Returns the correct generator type for the requested output format. Allows
  2218  * for a plugin to filter generators on an individual basis using the
  2994  * for a plugin to filter generators on an individual basis using the
  2219  * 'get_the_generator_{$type}' filter.
  2995  * 'get_the_generator_{$type}' filter.
  2220  *
  2996  *
  2221  * @since 2.5.0
  2997  * @since 2.5.0
  2222  * @uses apply_filters() Calls 'get_the_generator_$type' hook.
       
  2223  *
  2998  *
  2224  * @param string $type The type of generator to return - (html|xhtml|atom|rss2|rdf|comment|export).
  2999  * @param string $type The type of generator to return - (html|xhtml|atom|rss2|rdf|comment|export).
  2225  * @return string The HTML content for the generator.
  3000  * @return string The HTML content for the generator.
  2226  */
  3001  */
  2227 function get_the_generator( $type = '' ) {
  3002 function get_the_generator( $type = '' ) {
  2272 			break;
  3047 			break;
  2273 		case 'export':
  3048 		case 'export':
  2274 			$gen = '<!-- generator="WordPress/' . get_bloginfo_rss('version') . '" created="'. date('Y-m-d H:i') . '" -->';
  3049 			$gen = '<!-- generator="WordPress/' . get_bloginfo_rss('version') . '" created="'. date('Y-m-d H:i') . '" -->';
  2275 			break;
  3050 			break;
  2276 	}
  3051 	}
       
  3052 
       
  3053 	/**
       
  3054 	 * Filter the HTML for the retrieved generator type.
       
  3055 	 *
       
  3056 	 * The dynamic portion of the hook name, `$type`, refers to the generator type.
       
  3057 	 *
       
  3058 	 * @since 2.5.0
       
  3059 	 *
       
  3060 	 * @param string $gen  The HTML markup output to {@see wp_head()}.
       
  3061 	 * @param string $type The type of generator. Accepts 'html', 'xhtml', 'atom',
       
  3062 	 *                     'rss2', 'rdf', 'comment', 'export'.
       
  3063 	 */
  2277 	return apply_filters( "get_the_generator_{$type}", $gen, $type );
  3064 	return apply_filters( "get_the_generator_{$type}", $gen, $type );
  2278 }
  3065 }
  2279 
  3066 
  2280 /**
  3067 /**
  2281  * Outputs the html checked attribute.
  3068  * Outputs the html checked attribute.