esc_html__( 'Identifier of the feature demo that has been watched.', 'code-snippets' ), 'type' => 'string', 'enum' => self::DEMOS, 'required' => true, ]; } /** * Retrieve the demos watched so far as a REST response. * * @return WP_REST_Response */ public function get_option_value_callback(): WP_REST_Response { return new WP_REST_Response( [ self::RESPONSE_KEY => $this->get_option_value() ] ); } /** * Record that a feature demo has been watched through to the end. * * @param WP_REST_Request $request Full data about the request. * * @return WP_REST_Response */ public function update_option_value_callback( WP_REST_Request $request ): WP_REST_Response { $demos = self::get_demos_seen(); $demos[] = $request->get_param( self::PREFERENCE_KEY ); $demos = array_values( array_intersect( self::DEMOS, array_unique( $demos ) ) ); update_option( self::OPTION_NAME, $demos ); return new WP_REST_Response( [ self::RESPONSE_KEY => $demos ] ); } }