| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
if (!defined('ABSPATH')) { |
| 6 |
exit; |
| 7 |
} |
| 8 |
|
| 9 |
use Metricool\Interfaces\MigrationInterface; |
| 10 |
|
| 11 |
return new class () implements MigrationInterface |
| 12 |
{ |
| 13 |
public function version(): string |
| 14 |
{ |
| 15 |
return '2.0.0'; // first version in the 2.x series |
| 16 |
} |
| 17 |
|
| 18 |
/** |
| 19 |
* Perform schema/data changes required for this migration. |
| 20 |
* @uses add_option to avoid changing existing values. |
| 21 |
*/ |
| 22 |
public function up(): void |
| 23 |
{ |
| 24 |
if (!function_exists('get_option')) { |
| 25 |
require_once ABSPATH . WPINC . DIRECTORY_SEPARATOR . 'option.php'; |
| 26 |
} |
| 27 |
|
| 28 |
// migrate tracking script |
| 29 |
$profileId = trim(get_option('metricool_profile_id', '')); |
| 30 |
|
| 31 |
if (!empty($profileId)) { |
| 32 |
add_option('metricool_tracking_script_hash', $profileId, '', true); |
| 33 |
add_option('metricool_tracking_script_active', true, '', true); |
| 34 |
} |
| 35 |
|
| 36 |
delete_option('metricool_profile_id'); |
| 37 |
} |
| 38 |
}; |
| 39 |
|