[wp-trac] [WordPress Trac] #39677: Introduce capabilities for managing translations
WordPress Trac
noreply at wordpress.org
Mon Apr 24 14:36:03 UTC 2017
#39677: Introduce capabilities for managing translations
-------------------------------------------------+-------------------------
Reporter: flixos90 | Owner: flixos90
Type: enhancement | Status: assigned
Priority: normal | Milestone: 4.8
Component: Role/Capability | Version:
Severity: normal | Resolution:
Keywords: has-unit-tests needs-dev-note has- | Focuses:
patch |
-------------------------------------------------+-------------------------
Changes (by flixos90):
* keywords: has-unit-tests needs-dev-note needs-patch => has-unit-tests
needs-dev-note has-patch
Comment:
[attachment:39677.3.diff] takes @ocean90's notes into account.
Improvements over the previous patch:
* `wp_can_install_language_pack()` is now included in the `map_meta_cap()`
clause for the two new capabilities. This ensures that no-one has the
capability in case the filesystem does not allow such changes. Something
to be particularly careful about is that the clause may require `wp-
admin/includes/translation-install.php` now. I don't think this will cause
problems, but it's a change to be aware of. This theoretically makes some
require statements in other files unnecessary, but I left them in there
for clarity at this point.
* In order to "map" the capability correctly, we cannot use
`map_meta_cap()` efficiently because it always checks whether ''all''
capabilities are met. Therefore I used the `user_has_cap` filter to grant
anyone the `install_languages` capability that has at least one out of the
`update_core`, `install_plugins` and `install_themes` capabilities,
basically as if this was a regular capability that was part of a the
administrator role in the DB. `map_meta_cap()` is used for the more
detailed handling of the capability and to map `update_languages` to
`install_languages`.
* All related function calls have been adjusted to solely rely on
`current_user_can( 'install/update_languages' )` now.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/39677#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list