mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
REST API: Remove experimental block menu item types.
The menu items REST API controller was added in [52079]. This included functionality to add a "block" menu item type. This functionality is experimental and not currently used in WordPress core, so should be removed. Props noisysocks. See #40878. git-svn-id: https://develop.svn.wordpress.org/trunk@52184 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -339,7 +339,6 @@ class WP_REST_Menu_Items_Controller extends WP_REST_Posts_Controller {
|
||||
'menu-item-title' => $menu_item_obj->title,
|
||||
'menu-item-url' => $menu_item_obj->url,
|
||||
'menu-item-description' => $menu_item_obj->description,
|
||||
'menu-item-content' => $menu_item_obj->menu_item_content,
|
||||
'menu-item-attr-title' => $menu_item_obj->attr_title,
|
||||
'menu-item-target' => $menu_item_obj->target,
|
||||
'menu-item-classes' => $menu_item_obj->classes,
|
||||
@@ -360,7 +359,6 @@ class WP_REST_Menu_Items_Controller extends WP_REST_Posts_Controller {
|
||||
'menu-item-title' => '',
|
||||
'menu-item-url' => '',
|
||||
'menu-item-description' => '',
|
||||
'menu-item-content' => '',
|
||||
'menu-item-attr-title' => '',
|
||||
'menu-item-target' => '',
|
||||
'menu-item-classes' => array(),
|
||||
@@ -409,15 +407,6 @@ class WP_REST_Menu_Items_Controller extends WP_REST_Posts_Controller {
|
||||
}
|
||||
}
|
||||
|
||||
// Nav menu content.
|
||||
if ( ! empty( $schema['properties']['content'] ) && isset( $request['content'] ) ) {
|
||||
if ( is_string( $request['content'] ) ) {
|
||||
$prepared_nav_item['menu-item-content'] = $request['content'];
|
||||
} elseif ( isset( $request['content']['raw'] ) ) {
|
||||
$prepared_nav_item['menu-item-content'] = $request['content']['raw'];
|
||||
}
|
||||
}
|
||||
|
||||
$error = new WP_Error();
|
||||
|
||||
// Check if object id exists before saving.
|
||||
@@ -460,11 +449,6 @@ class WP_REST_Menu_Items_Controller extends WP_REST_Posts_Controller {
|
||||
}
|
||||
}
|
||||
|
||||
// If menu item is type block, then content is required.
|
||||
if ( 'block' === $prepared_nav_item['menu-item-type'] && empty( $prepared_nav_item['menu-item-content'] ) ) {
|
||||
$error->add( 'rest_content_required', __( 'The content is required when using a block menu item type.' ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
if ( $error->has_errors() ) {
|
||||
return $error;
|
||||
}
|
||||
@@ -566,23 +550,6 @@ class WP_REST_Menu_Items_Controller extends WP_REST_Posts_Controller {
|
||||
$data['object_id'] = absint( $menu_item->object_id );
|
||||
}
|
||||
|
||||
if ( rest_is_field_included( 'content', $fields ) ) {
|
||||
$data['content'] = array();
|
||||
}
|
||||
|
||||
if ( rest_is_field_included( 'content.raw', $fields ) ) {
|
||||
$data['content']['raw'] = $menu_item->menu_item_content;
|
||||
}
|
||||
|
||||
if ( rest_is_field_included( 'content.rendered', $fields ) ) {
|
||||
/** This filter is documented in wp-includes/post-template.php */
|
||||
$data['content']['rendered'] = apply_filters( 'the_content', $menu_item->menu_item_content );
|
||||
}
|
||||
|
||||
if ( rest_is_field_included( 'content.block_version', $fields ) ) {
|
||||
$data['content']['block_version'] = block_version( $menu_item->menu_item_content );
|
||||
}
|
||||
|
||||
if ( rest_is_field_included( 'parent', $fields ) ) {
|
||||
// Same as post_parent, exposed as an integer.
|
||||
$data['parent'] = (int) $menu_item->menu_item_parent;
|
||||
@@ -781,7 +748,7 @@ class WP_REST_Menu_Items_Controller extends WP_REST_Posts_Controller {
|
||||
$schema['properties']['type'] = array(
|
||||
'description' => __( 'The family of objects originally represented, such as "post_type" or "taxonomy".' ),
|
||||
'type' => 'string',
|
||||
'enum' => array( 'taxonomy', 'post_type', 'post_type_archive', 'custom', 'block' ),
|
||||
'enum' => array( 'taxonomy', 'post_type', 'post_type_archive', 'custom' ),
|
||||
'context' => array( 'view', 'edit', 'embed' ),
|
||||
'default' => 'custom',
|
||||
);
|
||||
@@ -859,31 +826,6 @@ class WP_REST_Menu_Items_Controller extends WP_REST_Posts_Controller {
|
||||
'default' => 0,
|
||||
);
|
||||
|
||||
$schema['properties']['content'] = array(
|
||||
'description' => __( 'HTML content to display for this block menu item.' ),
|
||||
'context' => array( 'view', 'edit', 'embed' ),
|
||||
'type' => array( 'string', 'object' ),
|
||||
'properties' => array(
|
||||
'raw' => array(
|
||||
'description' => __( 'HTML content, as it exists in the database.' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'edit' ),
|
||||
),
|
||||
'rendered' => array(
|
||||
'description' => __( 'HTML content, transformed for display.' ),
|
||||
'type' => 'string',
|
||||
'context' => array( 'view', 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
'block_version' => array(
|
||||
'description' => __( 'Version of the block format used in the HTML content.' ),
|
||||
'type' => 'integer',
|
||||
'context' => array( 'edit' ),
|
||||
'readonly' => true,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$schema['properties']['target'] = array(
|
||||
'description' => __( 'The target attribute of the link element for this menu item.' ),
|
||||
'type' => 'string',
|
||||
|
||||
Reference in New Issue
Block a user