]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/rest-api.php
WordPress 4.6.3-scripts
[autoinstalls/wordpress.git] / wp-includes / rest-api.php
index 2375676c043bc95febb3b53d52bb187387170d16..13bfa596ece1714567ff3a90a0882985fb1460e4 100644 (file)
@@ -159,7 +159,7 @@ function rest_api_loaded() {
  */
 function rest_get_url_prefix() {
        /**
-        * Filter the REST URL prefix.
+        * Filters the REST URL prefix.
         *
         * @since 4.4.0
         *
@@ -206,9 +206,9 @@ function get_rest_url( $blog_id = null, $path = '/', $scheme = 'rest' ) {
        }
 
        /**
-        * Filter the REST URL.
+        * Filters the REST URL.
         *
-        * Use this filter to adjust the url returned by the `get_rest_url` function.
+        * Use this filter to adjust the url returned by the get_rest_url() function.
         *
         * @since 4.4.0
         *
@@ -269,7 +269,7 @@ function rest_get_server() {
 
        if ( empty( $wp_rest_server ) ) {
                /**
-                * Filter the REST Server Class.
+                * Filters the REST Server Class.
                 *
                 * This filter allows you to adjust the server class used by the API, using a
                 * different class to handle requests.
@@ -548,10 +548,12 @@ function rest_output_link_header() {
  *
  * @since 4.4.0
  *
- * @global mixed $wp_rest_auth_cookie
+ * @global mixed          $wp_rest_auth_cookie
+ * @global WP_REST_Server $wp_rest_server      REST server instance.
  *
- * @param WP_Error|mixed $result Error from another authentication handler, null if we should handle it,
- *                               or another value if not.
+ * @param WP_Error|mixed $result Error from another authentication handler,
+ *                               null if we should handle it, or another value
+ *                               if not.
  * @return WP_Error|mixed|bool WP_Error if the cookie is invalid, the $result, otherwise true.
  */
 function rest_cookie_check_errors( $result ) {
@@ -559,7 +561,7 @@ function rest_cookie_check_errors( $result ) {
                return $result;
        }
 
-       global $wp_rest_auth_cookie;
+       global $wp_rest_auth_cookie, $wp_rest_server;
 
        /*
         * Is cookie authentication being used? (If we get an auth
@@ -592,6 +594,9 @@ function rest_cookie_check_errors( $result ) {
                return new WP_Error( 'rest_cookie_invalid_nonce', __( 'Cookie nonce is invalid' ), array( 'status' => 403 ) );
        }
 
+       // Send a refreshed nonce in header.
+       $wp_rest_server->send_header( 'X-WP-Nonce', wp_create_nonce( 'wp_rest' ) );
+
        return true;
 }