PluginProbe
Content Control – The Ultimate Content Restriction Plugin! Restrict Content, Create Conditional Blocks & More / 2.6.1
Content Control – The Ultimate Content Restriction Plugin! Restrict Content, Create Conditional Blocks & More v2.6.1
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.10 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 47 releases
content-control / classes / Upgrades / PluginMeta_2.php

PluginMeta_2.php in Content Control – The Ultimate Content Restriction Plugin! Restrict Content, Create Conditional Blocks & More 2.6.1, at classes/Upgrades/PluginMeta_2.php

93 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Content Control Migrations
4 *
5 * @package ContentControl\Plugin
6 */
7
8 namespace ContentControl\Upgrades;
9
10 defined( 'ABSPATH' ) || exit;
11
12 /**
13 * Version 2 migration.
14 */
15 class PluginMeta_2 extends \ContentControl\Base\Upgrade {
16
17 const TYPE = 'plugin_meta';
18 const VERSION = 2;
19
20 /**
21 * Get the label for the upgrade.
22 *
23 * @return string
24 */
25 public function label() {
26 return __( 'Update plugin meta', 'content-control' );
27 }
28
29 /**
30 * Get the dependencies for this upgrade.
31 *
32 * @return string[]
33 */
34 public function get_dependencies() {
35 return [
36 'backup-2',
37 ];
38 }
39
40 /**
41 * Get the remaps for this upgrade.
42 *
43 * @var array<string,string>
44 */
45 private $remaps = [
46 'jp_cc_reviews_installed_on' => 'content_control_installed_on',
47 ];
48
49 /**
50 * Check if the upgrade is required.
51 *
52 * @return bool
53 */
54 public function is_required() {
55 $remaps = $this->remaps;
56
57 foreach ( $remaps as $key => $new_key ) {
58 $value = \get_option( $key, null );
59
60 if ( null !== $value ) {
61 return true;
62 }
63 }
64
65 return false;
66 }
67
68 /**
69 * Run the upgrade.
70 *
71 * @return void
72 */
73 public function run() {
74 // Gets a stream or mock stream for sending events.
75 $stream = $this->stream();
76
77 $stream->start_task( __( 'Migrating plugin meta', 'content-control' ) );
78
79 $remaps = $this->remaps;
80
81 foreach ( $remaps as $key => $new_key ) {
82 $value = \get_option( $key, null );
83
84 if ( null !== $value ) {
85 \update_option( $new_key, $value );
86 \delete_option( $key );
87 }
88 }
89
90 $stream->complete_task( __( 'Plugin meta migrated', 'content-control' ) );
91 }
92 }
93