class-media-library-organizer-install.php
2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
/**
* Plugin installation, upgrade and uninstallation class.
*
* @package Media_Library_Organizer
* @author WP Media Library
*/
/**
* Runs installation, upgrade and uninstallation routines when the Plugin
* is activated, updated and deactivated.
*
* @since 1.0.0
*/
class Media_Library_Organizer_Install {
/**
* Holds the base class object.
*
* @since 1.0.5
*
* @var object
*/
public $base;
/**
* Constructor
*
* @since 1.0.5
*
* @param object $base Base Plugin Class.
*/
public function __construct( $base ) {
// Store base class.
$this->base = $base;
}
/**
* Runs the installation routine on the currently active site
*
* @since 1.0.0
*/
public function install() {
// Update the version number.
update_option( $this->base->plugin->name . '-version', $this->base->plugin->version );
}
/**
* Runs migration routines when the plugin is updated
*
* @since 1.0.0
*/
public function upgrade() {
global $wpdb;
// Get current installed version number (either false or version number e.g. 1.1.7).
$installed_version = get_option( $this->base->plugin->name . '-version' );
// If the version number matches the plugin version, bail.
if ( $installed_version === $this->base->plugin->version ) {
return;
}
/**
* 1.3.2: Migrate general[taxonomy_enabled] to general[mlo-category_enabled]
*/
if ( ! $installed_version || $installed_version < '1.3.2' ) {
$settings = $this->base->get_class( 'settings' )->get_settings( 'general' );
$settings['mlo-category_enabled'] = ( isset( $settings['taxonomy_enabled'] ) ? $settings['taxonomy_enabled'] : 1 );
unset( $settings['taxonomy_enabled'] );
$this->base->get_class( 'settings' )->update_settings( 'general', $settings );
}
// Update the version number.
update_option( $this->base->plugin->name . '-version', $this->base->plugin->version );
}
/**
* Runs the uninstallation routine on the currently active site
*
* @since 1.0.0
*/
public function uninstall() {
}
}