PluginProbe
BlockArt Blocks – Gutenberg Blocks, Page Builder Blocks ,WordPress Block Plugin, Sections & Template Library / trunk
BlockArt Blocks – Gutenberg Blocks, Page Builder Blocks ,WordPress Block Plugin, Sections & Template Library vtrunk
2.4.1 2.0.0 2.0.0.1 2.0.1 2.0.10 2.0.11 2.0.2 2.0.3 2.0.4 2.0.5 2.0.5.1 2.0.5.2 2.0.6 2.0.7 2.0.7.1 2.0.7.2 2.0.7.3 2.0.7.4 2.0.7.5 2.0.8 2.0.9 2.0.9.1 2.1.0 2.1.1 2.1.2 All 69 releases
blockart-blocks / includes / Update.php

Update.php in BlockArt Blocks – Gutenberg Blocks, Page Builder Blocks ,WordPress Block Plugin, Sections & Template Library trunk, at includes/Update.php

144 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 * Update class.
4 *
5 * @package BlockArt
6 */
7
8 namespace BlockArt;
9
10 defined( 'ABSPATH' ) || exit;
11
12 use BlockArt\Traits\Singleton;
13
14 /**
15 * Update class.
16 */
17 class Update {
18
19 use Singleton;
20
21 /**
22 * {@inheritDoc}
23 */
24 protected function __construct() {
25 add_action( 'blockart_version_update', array( $this, 'on_update' ), 10, 2 );
26 }
27
28 /**
29 * On update.
30 *
31 * @param string $new_version Current version.
32 * @param string $old_version Old version.
33 * d previous version.
34 *
35 * @return void
36 */
37 public function on_update( string $new_version, string $old_version ) {
38 if ( version_compare( $old_version, '2.0.0', '<' ) ) {
39 $this->update_to_2_0_0();
40 }
41 if ( version_compare( $old_version, '2.0.0.1', '<' ) ) {
42 $this->update_to_2_0_0_1();
43 }
44 if ( version_compare( $old_version, '2.0.7', '<' ) ) {
45 $this->update_to_2_0_7();
46 }
47 if ( version_compare( $old_version, '2.0.9', '<' ) ) {
48 $this->update_to_2_0_9();
49 }
50 if ( version_compare( $old_version, '2.2.10', '<' ) ) {
51 $this->update_to_2_2_10();
52 }
53
54 if ( version_compare( $old_version, '2.2.11', '<' ) ) {
55 $this->update_to_2_2_11();
56 }
57
58 }
59
60 /**
61 * Update to version 2.0.0.
62 *
63 * @return void
64 */
65 private function update_to_2_0_0() {
66 global $wpdb;
67
68 // Delete old meta keys.
69 $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_key = '_blockart_css' OR meta_key = '_blockart_active'" );
70
71 // Delete old options.
72 delete_option( '_blockart_widget_css' );
73 }
74
75 /**
76 * Update to version 2.0.0.1.
77 *
78 * @return void
79 */
80 private function update_to_2_0_0_1() {
81 global $wpdb;
82 $wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_key = '_blockart_blocks_css'" );
83 delete_option( '_blockart_blocks_css' );
84 }
85
86 /**
87 * Update to version 2.0.7.
88 *
89 * @return void
90 */
91 private function update_to_2_0_7() {
92 $setting = blockart_get_setting();
93 $old_css_print_method = get_option( '_blockart_dynamic_css_print_method', 'internal-css' );
94 if ( 'external-css-file' === $old_css_print_method ) {
95 $setting->set( 'asset-generation.external-file', true );
96 $setting->save();
97 }
98 delete_option( '_blockart_dynamic_css_print_method' );
99 }
100
101 /**
102 * Update to version 2.0.9.
103 *
104 * @return void
105 */
106 private function update_to_2_0_9() {
107 Setting::read();
108
109 foreach ( [ 'modal', 'icon', 'icon-list' ] as $block ) {
110 if ( ! Setting::get( "blocks.$block", true ) ) {
111 Setting::set( "blocks.$block", true );
112 }
113 }
114 Setting::save();
115 }
116
117 /**
118 * Update to 2.1.0.
119 *
120 * @return void
121 */
122 private function update_to_2_1_0() {
123 delete_transient( '_blockart_library_data' );
124 }
125
126 /**
127 * Update to 2.2.10.
128 *
129 * @return void
130 */
131 private function update_to_2_2_10() {
132 delete_transient( '_blockart_library_data' );
133 }
134
135 /**
136 * Update to 2.2.11.
137 *
138 * @return void
139 */
140 private function update_to_2_2_11() {
141 delete_transient( '_blockart_library_data' );
142 }
143 }
144