wp/wp-includes/class-wp.php
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
equal deleted inserted replaced
17:34716fd837a4 18:be944660c56a
    81 	 * @var bool
    81 	 * @var bool
    82 	 */
    82 	 */
    83 	public $did_permalink = false;
    83 	public $did_permalink = false;
    84 
    84 
    85 	/**
    85 	/**
    86 	 * Add name to list of public query variables.
    86 	 * Adds a query variable to the list of public query variables.
    87 	 *
    87 	 *
    88 	 * @since 2.1.0
    88 	 * @since 2.1.0
    89 	 *
    89 	 *
    90 	 * @param string $qv Query variable name.
    90 	 * @param string $qv Query variable name.
    91 	 */
    91 	 */
   105 	public function remove_query_var( $name ) {
   105 	public function remove_query_var( $name ) {
   106 		$this->public_query_vars = array_diff( $this->public_query_vars, array( $name ) );
   106 		$this->public_query_vars = array_diff( $this->public_query_vars, array( $name ) );
   107 	}
   107 	}
   108 
   108 
   109 	/**
   109 	/**
   110 	 * Set the value of a query variable.
   110 	 * Sets the value of a query variable.
   111 	 *
   111 	 *
   112 	 * @since 2.3.0
   112 	 * @since 2.3.0
   113 	 *
   113 	 *
   114 	 * @param string $key   Query variable name.
   114 	 * @param string $key   Query variable name.
   115 	 * @param mixed  $value Query variable value.
   115 	 * @param mixed  $value Query variable value.
   117 	public function set_query_var( $key, $value ) {
   117 	public function set_query_var( $key, $value ) {
   118 		$this->query_vars[ $key ] = $value;
   118 		$this->query_vars[ $key ] = $value;
   119 	}
   119 	}
   120 
   120 
   121 	/**
   121 	/**
   122 	 * Parse request to find correct WordPress query.
   122 	 * Parses the request to find the correct WordPress query.
   123 	 *
   123 	 *
   124 	 * Sets up the query variables based on the request. There are also many
   124 	 * Sets up the query variables based on the request. There are also many
   125 	 * filters and actions that can be used to further manipulate the result.
   125 	 * filters and actions that can be used to further manipulate the result.
   126 	 *
   126 	 *
   127 	 * @since 2.0.0
   127 	 * @since 2.0.0
   403 		$exit_required = false;
   403 		$exit_required = false;
   404 
   404 
   405 		if ( is_user_logged_in() ) {
   405 		if ( is_user_logged_in() ) {
   406 			$headers = array_merge( $headers, wp_get_nocache_headers() );
   406 			$headers = array_merge( $headers, wp_get_nocache_headers() );
   407 		} elseif ( ! empty( $_GET['unapproved'] ) && ! empty( $_GET['moderation-hash'] ) ) {
   407 		} elseif ( ! empty( $_GET['unapproved'] ) && ! empty( $_GET['moderation-hash'] ) ) {
   408 			// Unmoderated comments are only visible for one minute via the moderation hash.
   408 			// Unmoderated comments are only visible for 10 minutes via the moderation hash.
   409 			$headers['Expires']       = gmdate( 'D, d M Y H:i:s', time() + MINUTE_IN_SECONDS );
   409 			$expires = 10 * MINUTE_IN_SECONDS;
   410 			$headers['Cache-Control'] = 'max-age=60, must-revalidate';
   410 
       
   411 			$headers['Expires']       = gmdate( 'D, d M Y H:i:s', time() + $expires );
       
   412 			$headers['Cache-Control'] = sprintf(
       
   413 				'max-age=%d, must-revalidate',
       
   414 				$expires
       
   415 			);
   411 		}
   416 		}
   412 		if ( ! empty( $this->query_vars['error'] ) ) {
   417 		if ( ! empty( $this->query_vars['error'] ) ) {
   413 			$status = (int) $this->query_vars['error'];
   418 			$status = (int) $this->query_vars['error'];
   414 			if ( 404 === $status ) {
   419 			if ( 404 === $status ) {
   415 				if ( ! is_user_logged_in() ) {
   420 				if ( ! is_user_logged_in() ) {
   483 		 * Filters the HTTP headers before they're sent to the browser.
   488 		 * Filters the HTTP headers before they're sent to the browser.
   484 		 *
   489 		 *
   485 		 * @since 2.8.0
   490 		 * @since 2.8.0
   486 		 *
   491 		 *
   487 		 * @param string[] $headers Associative array of headers to be sent.
   492 		 * @param string[] $headers Associative array of headers to be sent.
   488 		 * @param WP       $this    Current WordPress environment instance.
   493 		 * @param WP       $wp      Current WordPress environment instance.
   489 		 */
   494 		 */
   490 		$headers = apply_filters( 'wp_headers', $headers, $this );
   495 		$headers = apply_filters( 'wp_headers', $headers, $this );
   491 
   496 
   492 		if ( ! empty( $status ) ) {
   497 		if ( ! empty( $status ) ) {
   493 			status_header( $status );
   498 			status_header( $status );
   595 		if ( $wp_query->is_single() || $wp_query->is_page() ) {
   600 		if ( $wp_query->is_single() || $wp_query->is_page() ) {
   596 			$GLOBALS['more']   = 1;
   601 			$GLOBALS['more']   = 1;
   597 			$GLOBALS['single'] = 1;
   602 			$GLOBALS['single'] = 1;
   598 		}
   603 		}
   599 
   604 
   600 		if ( $wp_query->is_author() && isset( $wp_query->post ) ) {
   605 		if ( $wp_query->is_author() ) {
   601 			$GLOBALS['authordata'] = get_userdata( $wp_query->post->post_author );
   606 			$GLOBALS['authordata'] = get_userdata( get_queried_object_id() );
   602 		}
   607 		}
   603 	}
   608 	}
   604 
   609 
   605 	/**
   610 	/**
   606 	 * Set up the current user.
   611 	 * Set up the current user.