PluginProbe
Metricool – Social media and site statistics / 2.1.1
Metricool – Social media and site statistics v2.1.1
2.1.1 2.1.0 2.0.2 2.0.1 2.0.0 1.27 trunk
metricool / migrations / version-2-0-0.php

version-2-0-0.php in Metricool – Social media and site statistics 2.1.1, at migrations/version-2-0-0.php

39 lines 953 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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