Skip to content

Commit

Permalink
[not verified] filter-widget: Add a WPCOM specific check
Browse files Browse the repository at this point in the history
  • Loading branch information
mreishus committed Sep 21, 2021
1 parent 20690dc commit 19d9796
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,11 @@ public static function filter_widget( $instance ) {
if ( strpos( wp_get_raw_referer(), '/wp-admin/widgets.php' ) && false !== strpos( $_SERVER['REQUEST_URI'], '/wp-json/' ) ) {
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'] ) {
return $instance;
}

if ( ! empty( $instance['conditions']['rules'] ) ) {
// Legacy widgets: visibility found.
Expand Down

0 comments on commit 19d9796

Please sign in to comment.