WP_REST_Server::READABLE, 'callback' => array( $this, 'show' ), 'permission_callback' => array( $this, 'can_manage' ), ), array( 'methods' => WP_REST_Server::EDITABLE, 'callback' => array( $this, 'update' ), 'permission_callback' => array( $this, 'can_manage' ), ), ) ); } /** * GET /settings. * * @return \WP_REST_Response */ public function show() { return rest_ensure_response( Settings::all() ); } /** * PUT /settings. * * @param WP_REST_Request $request Request. * @return \WP_REST_Response */ public function update( WP_REST_Request $request ) { $params = (array) $request->get_json_params(); $allowed = array_intersect_key( $params, Settings::defaults() ); return rest_ensure_response( Settings::save( $allowed ) ); } }