- Timestamp:
- 11/02/2016 06:52:30 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php
r39090 r39092 96 96 97 97 register_rest_route( $this->namespace, '/' . $this->rest_base . '/me', array( 98 'methods' => WP_REST_Server::READABLE, 99 'callback' => array( $this, 'get_current_item' ), 100 'args' => array( 101 'context' => array(), 98 array( 99 'methods' => WP_REST_Server::READABLE, 100 'callback' => array( $this, 'get_current_item' ), 101 'args' => array( 102 'context' => array(), 103 ), 104 ), 105 array( 106 'methods' => WP_REST_Server::EDITABLE, 107 'callback' => array( $this, 'update_current_item' ), 108 'permission_callback' => array( $this, 'update_current_item_permissions_check' ), 109 'args' => $this->get_endpoint_args_for_item_schema( WP_REST_Server::EDITABLE ), 110 ), 111 array( 112 'methods' => WP_REST_Server::DELETABLE, 113 'callback' => array( $this, 'delete_current_item' ), 114 'permission_callback' => array( $this, 'delete_current_item_permissions_check' ), 115 'args' => array( 116 'force' => array( 117 'default' => false, 118 'description' => __( 'Required to be true, as resource does not support trashing.' ), 119 ), 120 'reassign' => array(), 121 ), 102 122 ), 103 123 'schema' => array( $this, 'get_public_item_schema' ), … … 569 589 570 590 /** 591 * Checks if a given request has access to update the current user. 592 * 593 * @since 4.7.0 594 * @access public 595 * 596 * @param WP_REST_Request $request Full details about the request. 597 * @return true|WP_Error True if the request has access to update the item, WP_Error object otherwise. 598 */ 599 public function update_current_item_permissions_check( $request ) { 600 $request['id'] = get_current_user_id(); 601 602 return $this->update_item_permissions_check( $request ); 603 } 604 605 /** 606 * Updates the current user. 607 * 608 * @since 4.7.0 609 * @access public 610 * 611 * @param WP_REST_Request $request Full details about the request. 612 * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. 613 */ 614 function update_current_item( $request ) { 615 $request['id'] = get_current_user_id(); 616 617 return $this->update_item( $request ); 618 } 619 620 /** 571 621 * Checks if a given request has access delete a user. 572 622 * … … 644 694 645 695 return $response; 696 } 697 698 /** 699 * Checks if a given request has access to delete the current user. 700 * 701 * @since 4.7.0 702 * @access public 703 * 704 * @param WP_REST_Request $request Full details about the request. 705 * @return true|WP_Error True if the request has access to delete the item, WP_Error object otherwise. 706 */ 707 public function delete_current_item_permissions_check( $request ) { 708 $request['id'] = get_current_user_id(); 709 710 return $this->delete_item_permissions_check( $request ); 711 } 712 713 /** 714 * Deletes the current user. 715 * 716 * @since 4.7.0 717 * @access public 718 * 719 * @param WP_REST_Request $request Full details about the request. 720 * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. 721 */ 722 function delete_current_item( $request ) { 723 $request['id'] = get_current_user_id(); 724 725 return $this->delete_item( $request ); 646 726 } 647 727
Note: See TracChangeset
for help on using the changeset viewer.