[wp-trac] [WordPress Trac] #54304: Expose menu data public in Menus REST API

WordPress Trac noreply at wordpress.org
Sun Oct 6 19:28:01 UTC 2024


#54304: Expose menu data public in Menus REST API
---------------------------------------------------+-----------------------
 Reporter:  spacedmonkey                           |       Owner:  (none)
     Type:  defect (bug)                           |      Status:  new
 Priority:  normal                                 |   Milestone:  6.7
Component:  REST API                               |     Version:  4.7
 Severity:  normal                                 |  Resolution:
 Keywords:  has-patch needs-testing needs-refresh  |     Focuses:  rest-api
---------------------------------------------------+-----------------------

Comment (by masteradhoc):

 @spacedmonkey Thanks for the feedback and the updated PR!

 Just checked on a fresh WP 6.6.2 with GeneratePress Theme / GeneratePress
 Childtheme installed.
 These Endpoints got checked:
 - /wp-json/wp/v2/menus/
 - /wp-json/wp/v2/menus/5
 - /wp-json/wp/v2/menu-items
 - /wp-json/wp/v2/menu-items/15
 - /wp-json/wp/v2/menu-locations
 - /wp-json/wp/v2/menu-locations/primary


 By default without any change or PR applied i get this. Same also when not
 being loggedin:

 {{{
 {
     "code": "rest_cannot_view",
     "message": "Sorry, you are not allowed to view menu locations.",
     "data": {
         "status": 401
     }
 }
 }}}

 Lets apply the PR and enter the following filter in the functions.php of
 the child theme:

 {{{
 // https://core.trac.wordpress.org/ticket/54304
 add_filter( 'rest_menu_read_access', '__return_true' );
 }}}

 All works fine as i see! All the noted endpoints show up although im not
 logged in.

 Thanks @spacedmonkey!

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


More information about the wp-trac mailing list