Changeset 47034 for trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php
- Timestamp:
- 01/03/2020 02:26:36 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php
r46823 r47034 82 82 public function get_items_permissions_check( $request ) { 83 83 if ( 'edit' === $request['context'] ) { 84 foreach ( get_post_types( array(), 'object' ) as $post_type ) { 85 if ( ! empty( $post_type->show_in_rest ) && current_user_can( $post_type->cap->edit_posts ) ) { 84 $types = get_post_types( array( 'show_in_rest' => true ), 'objects' ); 85 86 foreach ( $types as $type ) { 87 if ( current_user_can( $type->cap->edit_posts ) ) { 86 88 return true; 87 89 } … … 103 105 */ 104 106 public function get_items( $request ) { 105 $data = array(); 106 107 foreach ( get_post_types( array(), 'object' ) as $obj ) { 108 if ( empty( $obj->show_in_rest ) || ( 'edit' === $request['context'] && ! current_user_can( $obj->cap->edit_posts ) ) ) { 107 $data = array(); 108 $types = get_post_types( array( 'show_in_rest' => true ), 'objects' ); 109 110 foreach ( $types as $type ) { 111 if ( 'edit' === $request['context'] && ! current_user_can( $type->cap->edit_posts ) ) { 109 112 continue; 110 113 } 111 114 112 $post_type = $this->prepare_item_for_response( $obj, $request );113 $data[ $ obj->name ] = $this->prepare_response_for_collection( $post_type );115 $post_type = $this->prepare_item_for_response( $type, $request ); 116 $data[ $type->name ] = $this->prepare_response_for_collection( $post_type ); 114 117 } 115 118
Note: See TracChangeset
for help on using the changeset viewer.