wppaste
WordPress

WP_REST_Menus_Controller

Since
5.9.0
Source
wp-includes/rest-api/endpoints/class-wp-rest-menus-controller.php:17
Core class used to managed menu terms associated via the REST API.

Compatibility

WordPress
since 5.9.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Hooks and filters fired · 8

Every hook that fires from inside WP_REST_Menus_Controller, in the order it appears in the class, grouped by the method that fires it.

Methods · 15

Source code

class WP_REST_Menus_Controller extends WP_REST_Terms_Controller { 	/**	 * Checks if a request has access to read menus.	 *	 * @since 5.9.0	 *	 * @param WP_REST_Request $request Full details about the request.	 * @return bool|WP_Error True if the request has read access, otherwise false or WP_Error object.	 */	public function get_items_permissions_check( $request ) {		$has_permission = parent::get_items_permissions_check( $request ); 		if ( true !== $has_permission ) {			return $has_permission;		} 		return $this->check_has_read_only_access( $request );	} 	/**	 * Checks if a request has access to read or edit the specified menu.	 *	 * @since 5.9.0	 *	 * @param WP_REST_Request $request Full details about the request.	 * @return true|WP_Error True if the request has read access for the item, otherwise WP_Error object.	 */	public function get_item_permissions_check( $request ) {		$has_permission = parent::get_item_permissions_check( $request ); 		if ( true !== $has_permission ) {			return $has_permission;		} 		return $this->check_has_read_only_access( $request );	} 	/**	 * Gets the term, if the ID is valid.	 *	 * @since 5.9.0	 *	 * @param int $id Supplied ID.	 * @return WP_Term|WP_Error Term object if ID is valid, WP_Error otherwise.	 */	protected function get_term( $id ) {		$term = parent::get_term( $id ); 		if ( is_wp_error( $term ) ) {			return $term;		} 		$nav_term           = wp_get_nav_menu_object( $term );		$nav_term->auto_add = $this->get_menu_auto_add( $nav_term->term_id ); 		return $nav_term;	} 	/**	 * Checks whether the current user has read permission for the endpoint.	 *	 * This allows for any user that can `edit_theme_options` or edit any REST API available post type.	 *	 * @since 5.9.0	 *	 * @param WP_REST_Request $request Full details about the request.	 * @return true|WP_Error True if the current user has permission, WP_Error object otherwise.	 */	protected function check_has_read_only_access( $request ) {		/** This filter is documented in wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php */		$read_only_access = apply_filters( 'rest_menu_read_access', false, $request, $this );		if ( $read_only_access ) {			return true;		} 		if ( current_user_can( 'edit_theme_options' ) ) {			return true;		}

Changelog

Introduced in 5.9.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.0.4 tag, from src/wp-includes/rest-api/endpoints/class-wp-rest-menus-controller.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.