[wp-trac] [WordPress Trac] #63216: simplify get_role() method in WP_Roles class
WordPress Trac
noreply at wordpress.org
Thu Apr 3 04:46:01 UTC 2025
#63216: simplify get_role() method in WP_Roles class
-----------------------------+------------------------------
Reporter: dilipbheda | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Role/Capability | Version:
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
-----------------------------+------------------------------
Comment (by dilipbheda):
Hello @spacedmonkey,
Thank you for the sharing the document.
**Reason for this changes**
1) When reviewing the `get_role()` function, I noticed an unnecessary
`else` block. Since the `if` statement already returns a value, the `else`
can be removed for cleaner code.
2) The `get_role()` function is used daily and has minimal code,
minimizing the risk of regression. So, I created a ticket and a patch for
it.
**For shorter condition**
Initially, I only removed the `else` block and returned the value
directly. However, based on reviewer feedback, I simplified it with a
shorter condition.
Here: https://github.com/WordPress/wordpress-
develop/pull/8637/commits/7b08649a6402c924fc28c2640e0330d82dba8075
There’s no other reason for this ticket. Feel free to close it if the
changes aren’t needed.
Thanks
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63216#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list