\WP_REST_Server::READABLE, 'callback' => [ $this, 'get_response' ], 'permission_callback' => [ Middleware::class, 'is_authorized' ], ], 'schema' => [ $this->schema, 'get_public_item_schema' ], 'allow_batch' => [ 'v1' => true ], ]; } /** * Update the store title powered by AI. * * @param \WP_REST_Request $request Request object. * * @return bool|string|\WP_Error|\WP_REST_Response */ protected function get_route_response( \WP_REST_Request $request ) { $product_updater = new UpdateProducts(); $patterns = PatternsHelper::get_patterns_ai_data_post(); $products = $product_updater->fetch_product_ids( 'dummy' ); if ( empty( $products ) && ! isset( $patterns ) ) { return rest_ensure_response( array( 'is_ai_generated' => false, ) ); } return rest_ensure_response( array( 'is_ai_generated' => true, ) ); } }