[a-z_]+)/dismiss', array( array( 'methods' => \WP_REST_Server::CREATABLE, 'callback' => array( $this, 'dismiss' ), 'permission_callback' => array( Capability::class, 'check' ), 'args' => array( 'id' => array( 'type' => 'string', 'enum' => self::NOTICES, ), ), ), ) ); } /** * Dismisses a notice for the current user. * * @param \WP_REST_Request $request Request. */ public function dismiss( \WP_REST_Request $request ): \WP_REST_Response { $id = sanitize_key( (string) $request['id'] ); update_user_meta( get_current_user_id(), self::meta_key( $id ), 1 ); return rest_ensure_response( array( 'dismissed' => $id ) ); } }