PluginProbe
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) / 1.5.1
Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) v1.5.1
2.1.2 2.1.1 2.1.0 2.0.4 2.0.3 2.0.2 2.0.1 2.0.0 1.5.5 1.5.4 1.5.3 1.5.2 1.5.1 1.5.0 trunk 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.0 1.3.1 All 56 releases
darkify / src / Admin / DBUpdates.php

DBUpdates.php in Darkify – Dark Mode & Night Mode for Website & Admin (Dark Theme Included) 1.5.1, at src/Admin/DBUpdates.php

89 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * The admin-facing functionality of the plugin.
5 *
6 * @link https://themeatelier.net
7 * @since 1.0.0
8 *
9 * @package darkify
10 * @subpackage darkify/Admin
11 * @author ThemeAtelier<themeatelierbd@gmail.com>
12 */
13
14 namespace ThemeAtelier\Darkify\Admin;
15
16 /**
17 * The admin class
18 */
19 class DBUpdates
20 {
21 /**
22 * DB updates that need to be run
23 *
24 * @var array
25 */
26 private static $updates = array(
27 '1.4.5' => 'updates/update-1.4.5.php',
28 );
29
30 /**
31 * The class constructor.
32 *
33 */
34 function __construct()
35 {
36 add_action('plugins_loaded', array($this, 'darkify_updates'));
37 }
38
39
40
41 /**
42 * Check if an update is needed.
43 *
44 * @return bool
45 */
46 public function is_needs_update() {
47 $installed_version = get_option('darkify_version');
48 $first_version = get_option('darkify_first_version');
49 $activation_date = get_option('darkify_activation_date');
50
51 if (false === $installed_version) {
52 update_option('darkify_version', '1.4.5');
53 update_option('darkify_db_version', '1.4.5');
54 }
55 if (false === $first_version) {
56 update_option('darkify_first_version', DARKIFY_VERSION);
57 }
58 if (false === $activation_date) {
59 update_option('darkify_activation_date', current_time('timestamp'));
60 }
61
62 if (version_compare($installed_version, DARKIFY_VERSION, '<')) {
63 return true;
64 }
65 return false;
66 }
67
68 /**
69 * Perform all updates.
70 *
71 */
72 public function darkify_updates() {
73 if (!$this->is_needs_update()) {
74 return;
75 }
76
77 $installed_version = get_option('darkify_version');
78
79 foreach (self::$updates as $version => $path) {
80 if (version_compare($installed_version, $version, '<')) {
81 include $path;
82 update_option('darkify_version', $version);
83 }
84 }
85
86 update_option('darkify_version', DARKIFY_VERSION);
87 }
88 }
89