PluginProbe
WP-Stateless – Google Cloud Storage / 1.9.0
WP-Stateless – Google Cloud Storage v1.9.0
4.4.3 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.3.0 2.3.1 2.3.2 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.2.0 3.2.1 3.2.2 All 62 releases
wp-stateless / lib / classes / class-upgrader.php

class-upgrader.php in WP-Stateless – Google Cloud Storage 1.9.0, at lib/classes/class-upgrader.php

109 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Upgrader
4 *
5 * @since 1.2.0
6 */
7 namespace wpCloud\StatelessMedia {
8
9 if( !class_exists( 'wpCloud\StatelessMedia\Upgrader' ) ) {
10
11 final class Upgrader {
12
13 /**
14 * Upgrades data if needed.
15 *
16 */
17 public static function call() {
18 /* Maybe upgrade blog ( single site ) */
19 self::upgrade();
20 /* Maybe upgrade network options */
21 if( ud_get_stateless_media()->is_network_detected() ) {
22 self::upgrade_network();
23 }
24
25 }
26
27 /**
28 * Upgrade current blog ( or single site )
29 *
30 */
31 private static function upgrade() {
32
33 $version = get_option( 'wp_sm_version', false );
34
35 /**
36 * Upgrade to v.1.2.0 requirements
37 */
38 if ( !$version || version_compare( $version, '1.2.0', '<' ) ) {
39
40 if( $v = get_option( 'sm.mode' ) ) {
41 update_option( 'sm_mode', $v );
42 delete_option( 'sm.mode' );
43 }
44
45 $v = get_option( 'sm_mode' );
46 if( $v == '0' ) update_option( 'sm_mode', 'disabled' );
47 elseif( $v == '1' ) update_option( 'sm_mode', 'backup' );
48 elseif( $v == '2' ) update_option( 'sm_mode', 'cdn' );
49
50 if( $v = get_option( 'sm.service_account_name' ) ) {
51 update_option( 'sm_service_account_name', $v );
52 delete_option( 'sm.service_account_name' );
53 }
54
55 if( $v = get_option( 'sm.key_file_path' ) ) {
56 update_option( 'sm_key_file_path', $v );
57 delete_option( 'sm.key_file_path' );
58 }
59
60 if( $v = get_option( 'sm.bucket' ) ) {
61 update_option( 'sm_bucket', $v );
62 delete_option( 'sm.bucket' );
63 }
64
65 delete_option( 'sm.app_name' );
66 delete_option( 'sm.body_rewrite' );
67 delete_option( 'sm.bucket_url_path' );
68 delete_option( 'sm.post_content_rewrite' );
69
70 }
71
72 update_option( 'wp_sm_version', ud_get_stateless_media()->args[ 'version' ] );
73
74 }
75
76 /**
77 * Upgrade Network Enabled
78 *
79 */
80 private static function upgrade_network() {
81
82 $version = get_site_option( 'wp_sm_version', false );
83
84 /**
85 * Upgrade to v.1.2.0 requirements
86 */
87 if ( !$version || version_compare( $version, '1.2.0', '<' ) ) {
88
89 if( $v = get_site_option( 'sm.key_file_path' ) ) {
90 update_site_option( 'sm_key_file_path', $v );
91 delete_site_option( 'sm.key_file_path' );
92 }
93
94 if( $v = get_option( 'sm.service_account_name' ) ) {
95 update_site_option( 'sm_service_account_name', $v );
96 delete_site_option( 'sm.service_account_name' );
97 }
98
99 }
100
101 update_site_option( 'wp_sm_version', ud_get_stateless_media()->args[ 'version' ] );
102
103 }
104
105 }
106
107 }
108
109 }