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

WordPress Trac noreply at wordpress.org
Wed Sep 21 16:10:03 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:  needs-dev-note 2nd-opinion  |     Focuses:
----------------------------------------+-----------------------------

Comment (by SergeyBiryukov):

 Replying to [comment:8 azaozz]:
 > Hmmm, I'm a bit unsure if these are good changes/renames/aliases. Adding
 `_screen` doesn't really make them clearer imho. Even the new
 `is_login_screen()` is not any clearer by having `screen` in there. Seems
 `is_login()` or even `is_login_request()` would be more accurate :)
 > ...
 > Same for the other `is_*_screen` functions. They may or may not load an
 admin screen, but the important part is that the requests were made by
 appropriately authenticated users, imho. Perhaps instead of `_screen` it
 should be `_request`? Seems a bit better and more "truthful", maybe.

 Thanks for flagging this! With these considerations, I agree `_request`
 makes more sense.

 `is_login()` was discussed in comment:6:ticket:19898 and ruled out as too
 confusing, similar to the existing functions.

 [attachment:"56400.diff"] renames the new functions to `is_*_request()`,
 along with `is_login_screen()` from #19898.

 > The more important part here (imho) seems to be to add better
 descriptions in the docblocks for the `is_*` functions. That would
 probably be way more helpful that the aliases as the docblocks are
 displayed in most IDEs.

 This change is aimed and those who are new to WordPress and perhaps new to
 web development as well (and may not use an IDE), rather than experienced
 software engineers, so while I'm all for better descriptions, I don't
 think they would solve the issue of confusing function names.

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


More information about the wp-trac mailing list