[wp-trac] [WordPress Trac] #56400: Rename is_admin() and related functions for clarity

WordPress Trac noreply at wordpress.org
Wed Aug 17 22:24:26 UTC 2022


#56400: Rename is_admin() and related functions for clarity
----------------------------+-----------------------------
 Reporter:  SergeyBiryukov  |      Owner:  (none)
     Type:  enhancement     |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Administration  |    Version:
 Severity:  normal          |   Keywords:
  Focuses:                  |
----------------------------+-----------------------------
 Background: #16490, #19898, #41090.

 Following the introduction of `is_login_screen()` in [53884], I would like
 to propose reconsidering the `is_*_admin()` functions family:

 * `is_admin()`
  * Determines whether the current request is for an administrative
 interface page.
 * `is_blog_admin()`
  * Whether the current request is for a site's administrative interface,
 e.g. `/wp-admin/`.
 * `is_network_admin()`
  * Whether the current request is for the network administrative
 interface, e.g. `/wp-admin/network/`.
 * `is_user_admin()`
  * Whether the current request is for a user admin screen, e.g. `/wp-
 admin/user/`.

 For someone new to WordPress, these names can be quite confusing,
 especially the last one. When using these functions, one always needs to
 remember or read the documentation to find out that they don't actually
 check if the current user is a site administrator.

 To complicate things further, there is one more similarly named function
 that does exactly the latter:
 * `is_super_admin()`
  * Determines whether user is a site admin.

 With the above in mind, I think these names would better describe the
 functionality and match `is_login_screen()`:

 * `is_admin()` → `is_admin_screen()`
 * `is_blog_admin()` → `is_blog_admin_screen()` or `is_site_admin_screen()`
 * `is_network_admin()` → `is_network_admin_screen()`
 * `is_user_admin()` → `is_user_admin_screen()`

 The problem with deprecating the current names is that they are used in a
 huge number of [https://wpdirectory.net/search/01GAPWXPC63DA6WKVGD5CFBX16
 plugins] and [https://wpdirectory.net/search/01GAPX1W63TBQYPDS81NS4X0PZ
 themes], but I still believe changing them would have a beneficial effect
 on the project and is feasible in the long run:
 1. As a first step, we could add these aliases and adjust the
 documentation to recommend using the newer names and note that the older
 names are going to be deprecated in the near future.
 2. After a few major releases, we could add deprecation notices to the
 older functions. By that time, plugins and themes should be able to safely
 switch to the newer names even if they support multiple WordPress
 versions.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/56400>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list