[wp-trac] [WordPress Trac] #40878: Adding menus route

WordPress Trac noreply at wordpress.org
Mon Nov 8 00:38:34 UTC 2021


#40878: Adding menus route
-------------------------------------------------+-------------------------
 Reporter:  dingo_d                              |       Owner:
                                                 |  spacedmonkey
     Type:  task (blessed)                       |      Status:  assigned
 Priority:  high                                 |   Milestone:  5.9
Component:  REST API                             |     Version:  4.7
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-unit-tests needs-dev-  |     Focuses:  rest-api
  note                                           |
-------------------------------------------------+-------------------------

Comment (by peterwilsoncc):

 (You may need to read this a couple of times: `map_meta_cap` can refer to
 a post type registration option, a function name and a filter)

 ----

 I've been rubber ducking this with @TimothyBlynJacobs.

 Including `map_meta_cap` in the post registration (this gist contains my
 original
 [https://gist.github.com/peterwilsoncc/34817da940ca26244c816d69f54d56a2
 suggestion for how to change the post type and taxonomy registrations])
 introduces a minor BC break.

 Developers using the `map_meta_cap` filter to change the permissions
 required for `edit_theme_options` will no longer affect the ability to
 edit menu items. For example the following code would no longer prevent
 editing menu items as `$cap` would change to `edit_post`:

 {{{#!php
 <?php
 add_filter( 'map_meta_cap', function( $caps, $cap ) {
   if ( $cap === 'edit_theme_options' ) {
     $caps[] = 'do_not_allow';
   }
   return $caps;
 }, 10, 2 );
 }}}


 Were `map_meta_cap` set to `false` in the post registration, then the
 function `map_meta_cap()` would change the value of `$cap` to
 `edit_theme_options` before it is passed to the `map_meta_cap` filter.

 The question for people on this ticket are: is maintaining backward
 compatibility preferable despite losing some of the flexibility mapping
 meta capabilities provides?

 Unfortunately, searching the plugin repository to determine the effect of
 the BC change is difficult as many plugins use the `edit_theme_options`
 string appears for a number of capability checks. The two searches I
 attempted returned no results:

 * [https://wpdirectory.net/search/01FKYFF2WAPHGWF8ZPWE66T981 yoda
 condition]
 * [https://wpdirectory.net/search/01FKYFE91M6XGYVWT1EY2GH1CG no yoda
 condition]

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


More information about the wp-trac mailing list