This repository was archived by the owner on Feb 23, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,7 @@ public function __construct( ExtendRestApi $extend ) {
3636 protected function init () {
3737 add_action ( 'rest_api_init ' , array ( $ this , 'register_rest_routes ' ), 10 );
3838 add_filter ( 'rest_authentication_errors ' , array ( $ this , 'store_api_authentication ' ) );
39+ add_action ( 'set_logged_in_cookie ' , array ( $ this , 'store_api_logged_in_cookie ' ) );
3940 }
4041
4142 /**
@@ -81,6 +82,19 @@ public function store_api_authentication( $result ) {
8182 return true ;
8283 }
8384
85+ /**
86+ * When the login cookies are set, they are not available until the next page reload. For the Store API, specifically
87+ * for returning updated nonces, we need this to be available immediately.
88+ *
89+ * @param string $logged_in_cookie The value for the logged in cookie.
90+ */
91+ public function store_api_logged_in_cookie ( $ logged_in_cookie ) {
92+ if ( ! defined ( 'LOGGED_IN_COOKIE ' ) || ! self ::is_request_to_store_api () ) {
93+ return ;
94+ }
95+ $ _COOKIE [ LOGGED_IN_COOKIE ] = $ logged_in_cookie ;
96+ }
97+
8498 /**
8599 * Check if is request to the Store API.
86100 *
You can’t perform that action at this time.
0 commit comments