[wp-trac] [WordPress Trac] #34608: Add role display name to WP_Role object

WordPress Trac noreply at wordpress.org
Thu Nov 10 01:00:02 UTC 2016


#34608: Add role display name to WP_Role object
-----------------------------+------------------------------
 Reporter:  jdgrimes         |       Owner:
     Type:  enhancement      |      Status:  new
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  Role/Capability  |     Version:
 Severity:  normal           |  Resolution:
 Keywords:  needs-patch      |     Focuses:
-----------------------------+------------------------------

Comment (by johnjamesjacoby):

 In order for this to work in 4.7 and on, it will likely need to be via a
 magic getter.

 If the translated string is set as a property of the class, it wouldn't
 get updated if the locale changes.

 There is also some conflation between what `$name` means compared to the
 `$role_id`. I'm not sure any other named variable we could use later would
 be any better, but clearing this up would be nice.

 ----

 I think all we can do is pass in the non-translated role name to the
 `__construct()` method, and magically pass it through
 `translate_user_role()` every time it's requested.

 The non-translated role name is always saved in the database in English,
 and there is no guarantee that custom roles will match the same way the
 core roles do. bbPress, for example, uses a `bbp_` namespace on the role
 ID's, even though the names saved in the database do not include it.

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


More information about the wp-trac mailing list