key); 2.0.26 kept * `{ license, status }` rows there. Keys already in the store are skipped. * * @package AdvancedAds * @author Advanced Ads * @since 2.1.0 */ use AdvancedAds\License\License; defined( 'ABSPATH' ) || exit; /** * Store each legacy key as a bare row, then let the sync fill in the rows from the shop. * * A key the shop can't be asked about now keeps its bare row, so the daily license sync retries it. * The legacy option stays: released add-ons still read it. * * @return void */ function advads_upgrade_2_1_0_migrate_legacy_licenses(): void { $legacy = get_option( 'advanced-ads-licenses', [] ); if ( ! is_array( $legacy ) ) { return; } $license = License::get_instance(); $known = array_column( $license->get_licenses(), 'licenseKey' ); $keys = array_map( static fn( $entry ) => is_array( $entry ) ? trim( (string) ( $entry['license'] ?? '' ) ) : ( is_string( $entry ) ? trim( $entry ) : '' ), $legacy ); $keys = array_diff( array_unique( array_filter( $keys ) ), $known ); if ( [] === $keys ) { return; } $license->connect( array_map( static fn( $key ) => [ 'licenseKey' => $key ], array_values( $keys ) ) ); $license->sync(); } advads_upgrade_2_1_0_migrate_legacy_licenses();