Changeset 39427 for branches/4.7/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php
- Timestamp:
- 12/02/2016 06:58:36 AM (8 years ago)
- Location:
- branches/4.7
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.7
-
branches/4.7/src/wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php
r39401 r39427 93 93 'type' => 'integer', 94 94 'description' => __( 'Reassign the deleted user\'s posts and links to this user ID.' ), 95 'required' => true, 96 'sanitize_callback' => array( $this, 'check_reassign' ), 95 97 ), 96 98 ), … … 126 128 'type' => 'integer', 127 129 'description' => __( 'Reassign the deleted user\'s posts and links to this user ID.' ), 130 'required' => true, 131 'sanitize_callback' => array( $this, 'check_reassign' ), 128 132 ), 129 133 ), … … 131 135 'schema' => array( $this, 'get_public_item_schema' ), 132 136 )); 137 } 138 139 /** 140 * Checks for a valid value for the reassign parameter when deleting users. 141 * 142 * The value can be an integer, 'false', false, or ''. 143 * 144 * @since 4.7.0 145 * 146 * @param int|bool $value The value passed to the reassign parameter. 147 * @param WP_REST_Request $request Full details about the request. 148 * @param string $param The parameter that is being sanitized. 149 * 150 * @return int|bool|WP_Error 151 */ 152 public function check_reassign( $value, $request, $param ) { 153 if ( is_numeric( $value ) ) { 154 return $value; 155 } 156 157 if ( empty( $value ) || false === $value || 'false' === $value ) { 158 return false; 159 } 160 161 return new WP_Error( 'rest_invalid_param', __( 'Invalid user parameter(s).' ), array( 'status' => 400 ) ); 133 162 } 134 163 … … 674 703 public function delete_item( $request ) { 675 704 $id = (int) $request['id']; 676 $reassign = isset( $request['reassign'] ) ? absint( $request['reassign'] ) : null;705 $reassign = false === $request['reassign'] ? null : absint( $request['reassign'] ); 677 706 $force = isset( $request['force'] ) ? (bool) $request['force'] : false; 678 707
Note: See TracChangeset
for help on using the changeset viewer.