芝麻web文件管理V1.00
编辑当前文件:/home/royashxg/www/wp-content/plugins/elementor-pro/modules/notes/data/endpoints/users-endpoint.php
register_items_route( \WP_REST_Server::READABLE, [ 'limit' => [ 'type' => 'integer', 'description' => 'Limit the results.', 'required' => false, ], 'order_by' => [ 'type' => 'string', 'description' => 'A column to order the results by.', 'required' => false, 'default' => 'display_name', 'enum' => [ 'user_nicename', 'display_name', 'user_registered', ], ], 'order' => [ 'type' => 'string', 'description' => 'Results order direction.', 'required' => false, 'default' => 'asc', 'enum' => [ 'asc', 'desc', ], ], 'search' => [ 'type' => 'string', 'description' => 'Filter users by a search term.', 'required' => false, 'sanitize_callback' => function ( $value ) { return wp_strip_all_tags( $value, true ); }, ], ] ); } /** * Index route. * * GET `/notes/users` * * @param \WP_REST_Request $request * * @return array */ protected function get_items( $request ) { $users = User::query() ->order_by( $request->get_param( 'order_by' ), $request->get_param( 'order' ) ); foreach ( $this->get_filters() as $param => $callback ) { if ( $request->has_param( $param ) ) { call_user_func( $callback, $users, $request->get_param( $param ) ); } } $transformer = new User_Transformer(); $transform_dependencies = []; if ( ! empty( $_GET['post_id'] ) ) { $transform_dependencies['post_id'] = (int) $_GET['post_id']; } return [ 'data' => $users->get()->map( function ( User $user ) use ( $transformer, $transform_dependencies ) { return $transformer->transform( $user, $transform_dependencies ); } ), 'meta' => [], ]; } /** * @inheritDoc */ public function get_permission_callback( $request ) { return current_user_can( Capabilities::CREATE_NOTES ); } /** * Get the Users filters. * * @return array */ protected function get_filters() { return [ 'limit' => function ( User_Query_Builder $q, $limit ) { $q->limit( $limit ); }, 'search' => function ( User_Query_Builder $q, $search ) { $q->where( 'user_nicename', 'LIKE', '%' . $search . '%' ) ->or_where( 'user_email', 'LIKE', '%' . $search . '%' ) ->or_where( 'display_name', 'LIKE', '%' . $search . '%' ); }, ]; } }