Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#45727 closed defect (bug) (fixed)

is_admin_bar_showing() is true in REST API requests

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

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 8 years ago.
Attaching a patch inspired by changeset 43730.

Download all attachments as: .zip

Change History (8)

#1 @Rarst
8 years ago

  • Description modified (diff)

#2 @SergeyBiryukov
8 years ago

  • Keywords good-first-bug added
  • Milestone Awaiting Review → 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
8 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
8 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
8 years ago

Attaching a patch inspired by changeset 43730.

#5 @ayeshrajans
8 years ago

  • Keywords has-patch added; needs-patch removed

#6 @pento
8 years ago

  • Owner set to pento
  • Status new → accepted

#7 @pento
8 years ago

  • Resolution → fixed
  • Status accepted → 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.