get_results( "SELECT webhook_id FROM {$wpdb->prefix}wc_webhooks WHERE `topic` LIKE 'subscription.%' AND `api_version` = 3" ); if ( ! empty( $results ) && is_array( $results ) ) { WCS_Upgrade_Logger::add( sprintf( '3.1.0 - Updating %d subscription webhooks to use API Version 1 when building the payload to preserve backwards compatibility.', count( $results ) ) ); foreach ( $results as $result ) { $webhook = ! empty( $result->webhook_id ) ? wc_get_webhook( $result->webhook_id ) : null; if ( $webhook ) { $webhook->set_api_version( 1 ); $webhook->save(); WCS_Upgrade_Logger::add( sprintf( 'Updated webhook: %s (#%d).', $webhook->get_name(), $webhook->get_id() ) ); } else { WCS_Upgrade_Logger::add( sprintf( 'Warning! Couldn\'t find and update webhook: %s', print_r( $result, true ) ) ); } } } else { WCS_Upgrade_Logger::add( '3.1.0 - No subscription webhooks found using API version 3. No updates needed.' ); } } }