Skip to content

Commit 2e0604d

Browse files
committed
- add the uri field to the MenuItem type (since the interface was removed)
- run composer fix-cs
1 parent 0a01432 commit 2e0604d

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

src/Mutation/MediaItemUpdate.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,15 @@ public static function mutate_and_get_payload() {
121121
* Check to see if the existing_media_item author matches the current user,
122122
* if not they need to be able to edit others posts to proceed
123123
*/
124-
if ( get_current_user_id() !== $author_id && ( ! isset( $post_type_object->cap->edit_others_posts ) || ! current_user_can( $post_type_object->cap->edit_others_posts ) ) ) {
124+
if ( get_current_user_id() !== $author_id && ( ! isset( $post_type_object->cap->edit_others_posts ) || ! current_user_can( $post_type_object->cap->edit_others_posts ) ) ) {
125125
throw new UserError( __( 'Sorry, you are not allowed to update mediaItems as this user.', 'wp-graphql' ) );
126126
}
127127

128128
/**
129129
* Insert the post object and get the ID
130130
*/
131-
$post_args = MediaItemMutation::prepare_media_item( $input, $post_type_object, $mutation_name, false );
132-
$post_args['ID'] = $media_item_id;
131+
$post_args = MediaItemMutation::prepare_media_item( $input, $post_type_object, $mutation_name, false );
132+
$post_args['ID'] = $media_item_id;
133133

134134
$clean_args = wp_slash( (array) $post_args );
135135

src/Type/ObjectType/MenuItem.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ public static function register_type() {
118118
'type' => 'String',
119119
'description' => __( 'URL or destination of the menu item.', 'wp-graphql' ),
120120
],
121+
// Note: this field is added to the MenuItem type instead of applied by the "UniformResourceIdentifiable" interface
122+
// because a MenuItem is not identifiable by a uri, the connected resource is identifiable by the uri.
123+
'uri' => [
124+
'type' => 'String',
125+
'description' => __( 'The uri of the resource the menu item links to', 'wp-graphql' ),
126+
],
121127
'path' => [
122128
'type' => 'String',
123129
'description' => __( 'Path for the resource. Relative path for internal resources. Absolute path for external resources.', 'wp-graphql' ),

0 commit comments

Comments
 (0)