WordPress.org

Make WordPress Core

Opened 20 months ago

Closed 20 months ago

Last modified 19 months ago

#25104 closed defect (bug) (invalid)

is_admin() conditional tag is not true on the Customizer page

Reported by: ScottSmith Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.4
Component: Customize Keywords:
Focuses: Cc:

Description

Steps to Reproduce:

  1. Add the following code or similar to any page of the theme to test whether the is_admin() conditional tag is true or false.
<?php if ( ! is_admin() ) {
     echo "You are viewing the theme";
} else {
     echo "You are viewing the WordPress Administration Panels";
}?>
  1. Open theme customizer

Expected: Text should read "You are viewing the WordPress Administration Panels" because the theme customizer is an admin panel.

Result: Text reads "You are viewing the theme," when in fact, you are in an admin panel.

Change History (4)

comment:1 @SergeyBiryukov20 months ago

  • Component changed from General to Appearance
  • Keywords reporter-feedback removed

Related: #23509

comment:2 @johnbillion20 months ago

Suggesting close as wontfix, and in favour of introducing a new conditional in #23509. If we start returning true for is_admin() on the front end then it'll mess with plugins that control access to the admin area and we'll get all sorts of code being executed when it shouldn't be.

comment:3 @SergeyBiryukov20 months ago

  • Keywords dev-feedback removed
  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed
  • Version changed from 3.6 to 3.4

comment:4 @nacin19 months ago

  • Resolution changed from wontfix to invalid

This is also by design, to make sure themes checking is_admin() were either loading or not loading the proper stuff in the controls panel (considered the admin here) and in the preview frame (considered the frontend). This was designed to work with all themes without modification, which was quite a bit of a feat in itself.

Note: See TracTickets for help on using tickets.