Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#45727 closed defect (bug) (fixed)

is_admin_bar_showing() is true in REST API requests

Reported by: rarst's profile Rarst Owned by: pento's profile pento
Milestone: 5.1 Priority: low
Severity: minor Version: 5.1
Component: Toolbar Keywords: good-first-bug has-patch
Focuses: Cc:

Description (last modified by Rarst)

is_admin_bar_showing() returns true if logged in and looking at REST API request.

This is inconsistent with it being explicitly false for XML RPC and Ajax requests.

Attachments (1)

45727-5.patch (586 bytes) - added by ayeshrajans 7 years ago.
Attaching a patch inspired by changeset 43730.

Download all attachments as: .zip

Change History (8)

#1 @Rarst
7 years ago

  • Description modified (diff)

#2 @SergeyBiryukov
7 years ago

  • Keywords good-first-bug added
  • Milestone changed from Awaiting Review to 5.1

It already checks for XMLRPC_REQUEST, DOING_AJAX, and IFRAME_REQUEST.

Just need to add a check for REST_REQUEST, by the looks of it.

#3 @Rarst
7 years ago

I remember having issues with REST_REQUEST being defined relatively late, so it's not as reliable as DOING_AJAX (which is hardcoded right on top of its endpoint). Timing needs to be checked out there against what the check is doing.

#4 @SergeyBiryukov
7 years ago

Right, REST_REQUEST is not defined until parse_request runs.

wp_is_json_request() should be used then, see [43730] for #44534.

@ayeshrajans
7 years ago

Attaching a patch inspired by changeset 43730.

#5 @ayeshrajans
7 years ago

  • Keywords has-patch added; needs-patch removed

#6 @pento
7 years ago

  • Owner set to pento
  • Status changed from new to accepted

#7 @pento
7 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 44608:

Admin Bar: Set the Admin Bar to not be showing on REST API requests.

Props ayeshrajans.
Fixes #45727.

Note: See TracTickets for help on using tickets.