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

WordPress Trac noreply at wordpress.org
Fri Sep 23 20:27:21 UTC 2022


#56400: Rename is_admin() and related functions for clarity
--------------------------------+-----------------------------
 Reporter:  SergeyBiryukov      |       Owner:  SergeyBiryukov
     Type:  enhancement         |      Status:  accepted
 Priority:  normal              |   Milestone:  6.1
Component:  Bootstrap/Load      |     Version:
 Severity:  normal              |  Resolution:
 Keywords:  2nd-opinion revert  |     Focuses:
--------------------------------+-----------------------------

Comment (by azaozz):

 Replying to [comment:19 jrf]:
 > but I also agree with @SergeyBiryukov that that confusion already exists

 Yes, at first look I also thought the aliases were a good idea and would
 improve things. But then started thinking what the impact will be for
 existing code and references to the old names, for existing contributors
 (that know the old names but not the new) and for new contributors that
 are likely to find many references to the old names but then be told to
 use the new names. More chances for confusion.

 > Updating the docs IMO is not a solution

 I don't agree here. The (inline) comments and the docblocks are the best
 source of knowledge about the code. Even better when combined with reading
 through it. This is the case not only for WordPress but for any open
 source project. They are super useful imho, and should be expanded and
 enhanced as much as possible with every WP release. For example I started
 contributing to WP in 2006. 16 years later I still refer to the inline
 docs many times every day, even for code I've written (can't remember
 everything).

 So if the existing, and especially the new contributors are not checking
 the docblocks they are DOING-IT-WRONG (yes, in capital letters) :)

 > You mention the low adoption of the new name in
 [https://core.trac.wordpress.org/ticket/55883#comment:21].

 Yes. Looking there again I'm starting to think that the alias name is
 actually worse than the original. That function actually replaces the
 shortcode string(s) with string(s) provided by the plugin/theme. In
 English you do not say to "apply a replacement", the proper way to say is
 to "do a replacement". But lets keep the discussion there.

 > So, what about this ?
 > * Revert most of the changes in this ticket, except for the adding of
 the alias `is_super_admin_user()`.

 Yes, this seems like a good change. On the other hand I don't think
 `is_super_admin()` is that confusing as logically only a user can be
 "superadmin" (but perhaps that comes with experience). Considering all the
 broken references (in code and on the net), and the possible confusion
 they will be causing for years, I'm starting to think it would probably be
 better to keep the old name and update the inline docs.

 Looking at usage in plugins and themes (as you suggested),
 `is_super_admin` seems to be used a total of 15,200 times
 (https://wpdirectory.net/search/01GDNZ8HP5Q5G89FEX84KR3N5M and
 https://wpdirectory.net/search/01GDNZ9CRH01N8D3FWMWZHRM2K). Doing a quick
 search on Google returns about 8,000 results. That is a lot of references.

 So I'm currently "undecided" on whether the `is_super_admin_user()` alias
 is a good idea or not. Would really appreciate another opinion :)

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


More information about the wp-trac mailing list