Skip to content

Commit

Permalink
Modify WPCOM specific check to pass WPCOM linting
Browse files Browse the repository at this point in the history
  • Loading branch information
mreishus committed Sep 22, 2021
1 parent 19d9796 commit 097a12e
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -765,8 +765,11 @@ public static function filter_widget( $instance ) {
return $instance;
}
// WordPress.com specific check - here, referer ends in /rest-proxy/ and doesn't tell us what's requesting.
if ( true === isset( $_REQUEST['_gutenberg_nonce'] ) && wp_verify_nonce( $_REQUEST['_gutenberg_nonce'], 'gutenberg_request' ) &&
1 === preg_match( '~^/wp/v2/sites/\d+/(sidebars|widgets)~', $_SERVER['REQUEST_URI'] ) && 'edit' === $_REQUEST['context'] ) {
$current_url = ! empty( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
$nonce = ! empty( $_REQUEST['_gutenberg_nonce'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['_gutenberg_nonce'] ) ) : '';
$context = ! empty( $_REQUEST['context'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['context'] ) ) : '';
if ( wp_verify_nonce( $nonce, 'gutenberg_request' ) &&
1 === preg_match( '~^/wp/v2/sites/\d+/(sidebars|widgets)~', $current_url ) && 'edit' === $context ) {
return $instance;
}

Expand Down

0 comments on commit 097a12e

Please sign in to comment.