--- a/wp/wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php Fri Sep 05 18:40:08 2025 +0200
+++ b/wp/wp-includes/rest-api/endpoints/class-wp-rest-menu-items-controller.php Fri Sep 05 18:52:52 2025 +0200
@@ -80,6 +80,21 @@
* @return true|WP_Error True if the request has read access for the item, WP_Error object otherwise.
*/
protected function check_has_read_only_access( $request ) {
+ /**
+ * Filters whether the current user has read access to menu items via the REST API.
+ *
+ * @since 6.8.0
+ *
+ * @param bool $read_only_access Whether the current user has read access to menu items
+ * via the REST API.
+ * @param WP_REST_Request $request Full details about the request.
+ * @param WP_REST_Controller $this The current instance of the controller.
+ */
+ $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;
}
@@ -102,7 +117,7 @@
}
/**
- * Creates a single post.
+ * Creates a single nav menu item.
*
* @since 5.9.0
*
@@ -267,7 +282,7 @@
}
/**
- * Deletes a single menu item.
+ * Deletes a single nav menu item.
*
* @since 5.9.0
*
@@ -317,7 +332,7 @@
}
/**
- * Prepares a single post for create or update.
+ * Prepares a single nav menu item for create or update.
*
* @since 5.9.0
*
@@ -482,7 +497,7 @@
}
/**
- * Prepares a single post output for response.
+ * Prepares a single nav menu item output for response.
*
* @since 5.9.0
*
@@ -510,6 +525,7 @@
if ( rest_is_field_included( 'title.rendered', $fields ) ) {
add_filter( 'protected_title_format', array( $this, 'protected_title_format' ) );
+ add_filter( 'private_title_format', array( $this, 'protected_title_format' ) );
/** This filter is documented in wp-includes/post-template.php */
$title = apply_filters( 'the_title', $menu_item->title, $menu_item->ID );
@@ -517,6 +533,7 @@
$data['title']['rendered'] = $title;
remove_filter( 'protected_title_format', array( $this, 'protected_title_format' ) );
+ remove_filter( 'private_title_format', array( $this, 'protected_title_format' ) );
}
if ( rest_is_field_included( 'status', $fields ) ) {
@@ -676,7 +693,7 @@
}
/**
- * Retrieves Link Description Objects that should be added to the Schema for the posts collection.
+ * Retrieves Link Description Objects that should be added to the Schema for the nav menu items collection.
*
* @since 5.9.0
*
@@ -703,7 +720,7 @@
}
/**
- * Retrieves the term's schema, conforming to JSON Schema.
+ * Retrieves the nav menu item's schema, conforming to JSON Schema.
*
* @since 5.9.0
*
@@ -924,7 +941,7 @@
}
/**
- * Retrieves the query params for the posts collection.
+ * Retrieves the query params for the nav menu items collection.
*
* @since 5.9.0
*