PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.13.1
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.13.1
2.13.0 2.13.1 2.12.0 2.11.1 2.11.0 2.10.0 2.9.0 2.7.4 2.7.5 2.7.6 2.7.7 2.8.0 2.8.1 2.9.1 trunk 1.0 1.0-beta1 1.0-beta2 1.0-beta3 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 All 80 releases
← All changes | includes/migration.php +438 -0 1.02.13.1 View file →
@@ -1,0 +1,438 @@
1 +<?php
2 +namespace ABlocks;
3 +
4 +if ( ! defined( 'ABSPATH' ) ) {
5 + exit;
6 +}
7 +
8 +use ABlocks\Admin\Settings;
9 +
10 +class Migration {
11 +
12 + public static function init() {
13 + $self = new self();
14 + $self->run_migration();
15 + add_filter( 'render_block_data', array( $self, 'update_attributes_backward_compatibility' ) );
16 + }
17 +
18 + public function run_migration() {
19 + $this->migrate_font_stack();
20 +
21 + $ablocks_version = get_option( 'ablocks_version' );
22 + // Save Version Number, flash role management and save permalink
23 + if ( ABLOCKS_VERSION !== $ablocks_version ) {
24 + Settings::save_settings();
25 + $this->migrate_1_6_3( $ablocks_version );
26 + $this->migrate_1_8_0( $ablocks_version );
27 + update_option( 'ablocks_version', ABLOCKS_VERSION );
28 + }
29 + }
30 +
31 + /**
32 + * font-family declarations are now emitted as full stacks (quoted family +
33 + * metric fallback + generic) instead of a bare family name.
34 + *
35 + * Block CSS is cached in generated files and the global CSS variables live in
36 + * a transient, so both hold the old single-name output until something forces
37 + * a rebuild. Clear them once so existing pages pick up the new stacks without
38 + * anyone having to re-save every page.
39 + */
40 + public function migrate_font_stack() {
41 + if ( get_option( 'ablocks_font_stack_migrated' ) ) {
42 + return;
43 + }
44 +
45 + // Deleting generated files needs WP_Filesystem; keep that out of visitor
46 + // requests. The first admin page load after the update does the work.
47 + if ( ! is_admin() && ! ( defined( 'WP_CLI' ) && WP_CLI ) ) {
48 + return;
49 + }
50 +
51 + ( new \ABlocks\Classes\FileUpload() )->delete_files();
52 + delete_transient( 'ablocks_global_css_vars' );
53 + // Force a rebuild of the template/part/theme-builder font set, which did
54 + // not exist before this release.
55 + \ABlocks\Classes\FontCollector::flush_site_fonts();
56 +
57 + update_option( 'ablocks_font_stack_migrated', '1' );
58 + }
59 +
60 + public function migrate_1_6_3( $version ) {
61 + if ( version_compare( $version, '1.6.3', '<=' ) ) {
62 + add_option( 'ablocks_has_required_block_attribute_migration', '1.6.3' );
63 + // Delete Old Table
64 + global $wpdb;
65 + $prefix = $wpdb->prefix;
66 + Database\CreateFormTable::down( $prefix );
67 + // Crate New database table
68 + Database::create_initial_custom_table();
69 + }
70 + }
71 + public function migrate_1_8_0( $version ) {
72 + if ( version_compare( $version, '1.8.0', '<=' ) ) {
73 + global $wpdb;
74 + $table_name = $wpdb->prefix . ABLOCKS_PLUGIN_SLUG . '_form_entries';
75 + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.SchemaChange
76 + $wpdb->query( "ALTER TABLE `{$table_name}` MODIFY `post_id` VARCHAR(100) NULL" );
77 + }
78 + }
79 +
80 + public function update_attributes_backward_compatibility( $block ) {
81 + if ( get_option( 'ablocks_has_required_block_attribute_migration' ) === '1.6.3' ) {
82 +
83 + $attributes = ! empty( $block['attrs'] ) ? $block['attrs'] : [];
84 + switch ( $block['blockName'] ) {
85 + case 'ablocks/container':
86 + $has_old_direction_value = ! empty( $block['attrs']['direction'] );
87 + if ( empty( $block['attrs']['dir']['value'] ) || $has_old_direction_value ) {
88 + $block['attrs']['dir']['value'] = $has_old_direction_value ? $attributes['direction'] : 'column';
89 + $block['attrs']['direction'] = '';
90 + }
91 +
92 + if ( ! empty( $attributes['directionTablet'] ) ) {
93 + $block['attrs']['dir']['valueTablet'] = $attributes['directionTablet'];
94 + $block['attrs']['directionTablet'] = '';
95 + }
96 +
97 + if ( ! empty( $attributes['directionMobile'] ) ) {
98 + $block['attrs']['dir']['valueMobile'] = $attributes['directionMobile'];
99 + $block['attrs']['directionMobile'] = '';
100 + }
101 +
102 + if ( ! empty( $attributes['justify'] ) ) {
103 + $block['attrs']['justification']['value'] = $attributes['justify'];
104 + $block['attrs']['justify'] = '';
105 + }
106 +
107 + if ( ! empty( $attributes['justifyTablet'] ) ) {
108 + $block['attrs']['justification']['valueTablet'] = $attributes['justifyTablet'];
109 + $block['attrs']['justifyTablet'] = '';
110 + }
111 +
112 + if ( ! empty( $attributes['justifyMobile'] ) ) {
113 + $block['attrs']['justification']['valueMobile'] = $attributes['justifyMobile'];
114 + $block['attrs']['justifyMobile'] = '';
115 + }
116 +
117 + if ( ! empty( $attributes['align'] ) ) {
118 + $block['attrs']['alignment']['value'] = $attributes['align'];
119 + $block['attrs']['align'] = '';
120 + }
121 +
122 + if ( ! empty( $attributes['alignTablet'] ) ) {
123 + $block['attrs']['alignment']['valueTablet'] = $attributes['alignTablet'];
124 + $block['attrs']['alignTablet'] = '';
125 + }
126 +
127 + if ( ! empty( $attributes['alignMobile'] ) ) {
128 + $block['attrs']['alignment']['valueMobile'] = $attributes['alignMobile'];
129 + $block['attrs']['alignMobile'] = '';
130 + }
131 +
132 + if ( ! empty( $attributes['wrap'] ) ) {
133 + $block['attrs']['wrapping']['value'] = $attributes['wrap'];
134 + $block['attrs']['wrap'] = '';
135 + }
136 +
137 + if ( ! empty( $attributes['wrapTablet'] ) ) {
138 + $block['attrs']['wrapping']['valueTablet'] = $attributes['wrapTablet'];
139 + $block['attrs']['wrapTablet'] = '';
140 + }
141 +
142 + if ( ! empty( $attributes['wrapMobile'] ) ) {
143 + $block['attrs']['wrapping']['valueMobile'] = $attributes['wrapMobile'];
144 + $block['attrs']['wrapMobile'] = '';
145 + }
146 + break;
147 + case 'ablocks/counter':
148 + case 'ablocks/coupon':
149 + case 'ablocks/icon':
150 + case 'ablocks/notice':
151 + case 'ablocks/paypal-button':
152 + case 'ablocks/price-menu-item':
153 + case 'ablocks/star-ratings':
154 + case 'ablocks/stripe-button':
155 + case 'ablocks/svg-draw':
156 + case 'ablocks/tabs':
157 + if ( ! empty( $attributes['iconSize'] ) ) {
158 + $block['attrs']['iconSizing']['value'] = $attributes['iconSize'];
159 + }
160 + if ( ! empty( $attributes['iconRotate'] ) ) {
161 + $block['attrs']['iconRotated']['value'] = $attributes['iconRotate'];
162 + }
163 + // button-group control migration start
164 + $has_old_tabsMenuPosition_value = ! empty( $block['attrs']['tabsMenuPosition'] );
165 + if ( empty( $block['attrs']['tabsMenuPositioning']['value'] ) || $has_old_tabsMenuPosition_value ) {
166 + $block['attrs']['tabsMenuPositioning']['value'] = $has_old_tabsMenuPosition_value ? $attributes['tabsMenuPosition'] : 'left';
167 + $block['attrs']['tabsMenuPosition'] = '';
168 + }
169 + if ( ! empty( $attributes['tabsMenuPositionTablet'] ) ) {
170 + $block['attrs']['tabsMenuPositioning']['valueTablet'] = $attributes['tabsMenuPositionTablet'];
171 + $block['attrs']['tabsMenuPositionTablet'] = '';
172 + }
173 + if ( ! empty( $attributes['tabsMenuPositionMobile'] ) ) {
174 + $block['attrs']['tabsMenuPositioning']['valueMobile'] = $attributes['tabsMenuPositionMobile'];
175 + $block['attrs']['tabsMenuPositionMobile'] = '';
176 + }
177 + if ( ! empty( $attributes['tabMenuAlign'] ) ) {
178 + $block['attrs']['tabMenuAlignment']['value'] = $attributes['tabMenuAlign'];
179 + $block['attrs']['tabMenuAlign'] = '';
180 + }
181 + if ( ! empty( $attributes['tabMenuAlignTablet'] ) ) {
182 + $block['attrs']['tabMenuAlignment']['valueTablet'] = $attributes['tabMenuAlignTablet'];
183 + $block['attrs']['tabMenuAlignTablet'] = '';
184 + }
185 + if ( ! empty( $attributes['tabMenuAlignMobile'] ) ) {
186 + $block['attrs']['tabMenuAlignment']['valueMobile'] = $attributes['tabMenuAlignMobile'];
187 + $block['attrs']['tabMenuAlignMobile'] = '';
188 + }
189 + $has_old_menuContentAlign_value = ! empty( $block['attrs']['menuContentAlign'] );
190 + if ( empty( $block['attrs']['menuContentAlignment']['value'] ) || $has_old_menuContentAlign_value ) {
191 + $block['attrs']['menuContentAlignment']['value'] = $has_old_menuContentAlign_value ? $attributes['menuContentAlign'] : 'center';
192 + $block['attrs']['menuContentAlign'] = '';
193 + }
194 + if ( ! empty( $attributes['menuContentAlignTablet'] ) ) {
195 + $block['attrs']['menuContentAlignment']['valueTablet'] = $attributes['menuContentAlignTablet'];
196 + $block['attrs']['menuContentAlignTablet'] = '';
197 + }
198 + if ( ! empty( $attributes['menuContentAlignMobile'] ) ) {
199 + $block['attrs']['menuContentAlignment']['valueMobile'] = $attributes['menuContentAlignMobile'];
200 + $block['attrs']['menuContentAlignMobile'] = '';
201 + }
202 +
203 + // button-group control migration end
204 +
205 + break;
206 +
207 + case 'ablocks/button':
208 + if ( ! empty( $attributes['iconSize'] ) ) {
209 + $iconSize = intval( $attributes['iconSize'] );
210 + if ( $iconSize !== 16 ) {
211 + $block['attrs']['iconSizing']['value'] = $iconSize;
212 + }
213 + }
214 + if ( ! empty( $attributes['iconRotate'] ) ) {
215 + $block['attrs']['iconRotated']['value'] = $attributes['iconRotate'];
216 + }
217 + break;
218 +
219 + case 'ablocks/form-input':
220 + if ( ! empty( $attributes['iconSize'] ) ) {
221 + $block['attrs']['iconSizing']['value'] = $attributes['iconSize'];
222 + }
223 + if ( ! empty( $attributes['iconRotate'] ) ) {
224 + $block['attrs']['iconRotated']['value'] = $attributes['iconRotate'];
225 + }
226 + break;
227 +
228 + case 'ablocks/form-password':
229 + if ( ! empty( $attributes['iconSize'] ) ) {
230 + $block['attrs']['iconSizing']['value'] = $attributes['iconSize'];
231 + }
232 + if ( ! empty( $attributes['iconRotate'] ) ) {
233 + $block['attrs']['iconRotated']['value'] = $attributes['iconRotate'];
234 + }
235 +
236 + if ( ! empty( $attributes['passwordShowSize'] ) ) {
237 + $block['attrs']['passwordShowSizing']['value'] = $attributes['passwordShowSize'];
238 + }
239 + if ( ! empty( $attributes['passwordShowRotate'] ) ) {
240 + $block['attrs']['passwordShowRotated']['value'] = $attributes['passwordShowRotate'];
241 + }
242 + if ( ! empty( $attributes['passwordHideSize'] ) ) {
243 + $block['attrs']['passwordHideSizing']['value'] = $attributes['passwordHideSize'];
244 + }
245 + if ( ! empty( $attributes['passwordHideRotate'] ) ) {
246 + $block['attrs']['passwordHideRotated']['value'] = $attributes['passwordHideRotate'];
247 + }
248 +
249 + break;
250 +
251 + case 'ablocks/carousel':
252 + if ( ! empty( $attributes['leftIconSize'] ) ) {
253 + $block['attrs']['leftIconSizing']['value'] = $attributes['leftIconSize'];
254 + }
255 + if ( ! empty( $attributes['leftIconRotate'] ) ) {
256 + $block['attrs']['leftIconRotated']['value'] = $attributes['leftIconRotate'];
257 + }
258 + if ( ! empty( $attributes['rightIconSize'] ) ) {
259 + $block['attrs']['rightIconSizing']['value'] = $attributes['rightIconSize'];
260 + }
261 + if ( ! empty( $attributes['rightIconRotate'] ) ) {
262 + $block['attrs']['rightIconRotated']['value'] = $attributes['rightIconRotate'];
263 + }
264 + break;
265 + case 'ablocks/content-timeline':
266 + break;
267 + case 'ablocks/content-timeline-child':
268 + if ( ! empty( $attributes['iconSize'] ) ) {
269 + $block['attrs']['iconSizing']['value'] = $attributes['iconSize'];
270 + }
271 + if ( ! empty( $attributes['iconRotate'] ) ) {
272 + $block['attrs']['iconRotated']['value'] = $attributes['iconRotate'];
273 + }
274 +
275 + if ( ! empty( $attributes['contentTimeLineIconSize'] ) ) {
276 + $block['attrs']['contentTimeLineIconSizing']['value'] = $attributes['contentTimeLineIconSize'];
277 + }
278 + if ( ! empty( $attributes['contentTimeLineIconRotate'] ) ) {
279 + $block['attrs']['contentTimeLineIconRotated']['value'] = $attributes['contentTimeLineIconRotate'];
280 + }
281 + break;
282 +
283 + case 'ablocks/divider':
284 + if ( ! empty( $attributes['iconSize'] ) ) {
285 + $block['attrs']['iconSizing']['value'] = $attributes['iconSize'];
286 + }
287 + if ( ! empty( $attributes['iconRotate'] ) ) {
288 + $block['attrs']['iconRotated']['value'] = $attributes['iconRotate'];
289 + }
290 + break;
291 +
292 + case 'ablocks/single-accordion':
293 + if ( ! empty( $attributes['leftActiveIconSize'] ) ) {
294 + $block['attrs']['leftActiveIconSizing']['value'] = $attributes['leftActiveIconSize'];
295 + }
296 + if ( ! empty( $attributes['leftActiveIconRotate'] ) ) {
297 + $block['attrs']['leftActiveIconRotated']['value'] = $attributes['leftActiveIconRotate'];
298 + }
299 + if ( ! empty( $attributes['leftCloseIconSize'] ) ) {
300 + $block['attrs']['leftCloseIconSizing']['value'] = $attributes['leftCloseIconSize'];
301 + }
302 + if ( ! empty( $attributes['leftCloseIconRotate'] ) ) {
303 + $block['attrs']['leftCloseIconRotated']['value'] = $attributes['leftCloseIconRotate'];
304 + }
305 + if ( ! empty( $attributes['rightActiveIconSize'] ) ) {
306 + $block['attrs']['rightActiveIconSizing']['value'] = $attributes['rightActiveIconSize'];
307 + }
308 + if ( ! empty( $attributes['rightActiveIconRotate'] ) ) {
309 + $block['attrs']['rightActiveIconRotated']['value'] = $attributes['rightActiveIconRotate'];
310 + }
311 + if ( ! empty( $attributes['rightCloseIconSize'] ) ) {
312 + $block['attrs']['rightCloseIconSizing']['value'] = $attributes['rightCloseIconSize'];
313 + }
314 + if ( ! empty( $attributes['rightCloseIconRotate'] ) ) {
315 + $block['attrs']['rightCloseIconRotated']['value'] = $attributes['rightCloseIconRotate'];
316 + }
317 + break;
318 +
319 + case 'ablocks/table-of-content':
320 + if ( ! empty( $attributes['iconSize'] ) ) {
321 + $block['attrs']['iconSizing']['value'] = $attributes['iconSize'];
322 + }
323 + if ( ! empty( $attributes['iconRotate'] ) ) {
324 + $block['attrs']['iconRotated']['value'] = $attributes['iconRotate'];
325 + }
326 +
327 + if ( ! empty( $attributes['closeIconSize'] ) ) {
328 + $block['attrs']['closeIconSizing']['value'] = $attributes['closeIconSize'];
329 + }
330 + if ( ! empty( $attributes['closeIconRotate'] ) ) {
331 + $block['attrs']['closeIconRotated']['value'] = $attributes['closeIconRotate'];
332 + }
333 + if ( ! empty( $attributes['openIconSize'] ) ) {
334 + $block['attrs']['openIconSizing']['value'] = $attributes['openIconSize'];
335 + }
336 + if ( ! empty( $attributes['openIconRotate'] ) ) {
337 + $block['attrs']['openIconRotated']['value'] = $attributes['openIconRotate'];
338 + }
339 + break;
340 +
341 + case 'ablocks/info-box':
342 + if ( ! empty( $attributes['iconSize'] ) ) {
343 + $block['attrs']['iconSizing']['value'] = $attributes['iconSize'];
344 + }
345 + if ( ! empty( $attributes['iconRotate'] ) ) {
346 + $block['attrs']['iconRotated']['value'] = $attributes['iconRotate'];
347 + }
348 + if ( ! empty( $attributes['btnIconSize'] ) ) {
349 + $block['attrs']['btnIconSizing']['value'] = $attributes['btnIconSize'];
350 + }
351 + if ( ! empty( $attributes['btnIconRotate'] ) ) {
352 + $block['attrs']['btnIconRotated']['value'] = $attributes['btnIconRotate'];
353 + }
354 + if ( ! empty( $attributes['starIconSize'] ) ) {
355 + $block['attrs']['starIconSizing']['value'] = $attributes['starIconSize'];
356 + }
357 + if ( ! empty( $attributes['starIconRotate'] ) ) {
358 + $block['attrs']['starIconRotated']['value'] = $attributes['starIconRotate'];
359 + }
360 + break;
361 +
362 + case 'ablocks/lists':
363 + break;
364 +
365 + case 'ablocks/modal':
366 + break;
367 + case 'ablocks/progress-tracker':
368 + break;
369 + case 'ablocks/social-shares':
370 + break;
371 + case 'ablocks/toggle':
372 + break;
373 + case 'ablocks/flip-box':
374 + break;
375 +
376 + case 'ablocks/countdown':
377 + // button-group control migration start
378 + $has_old_direction_value = ! empty( $block['attrs']['direction'] );
379 + if ( empty( $attributes['orient'] ) || $has_old_direction_value ) {
380 + $block['attrs']['orient']['value'] = $has_old_direction_value ? $attributes['direction'] : 'row';
381 + $block['attrs']['direction'] = '';
382 + }
383 + if ( ! empty( $attributes['directionTablet'] ) ) {
384 + $block['attrs']['orient']['valueTablet'] = $attributes['directionTablet'];
385 + $block['attrs']['directionTablet'] = '';
386 + }
387 + if ( ! empty( $attributes['directionMobile'] ) ) {
388 + $block['attrs']['orient']['valueMobile'] = $attributes['directionMobile'];
389 + $block['attrs']['directionMobile'] = '';
390 + }
391 + $has_old_justifyAlign_value = ! empty( $block['attrs']['justifyAlign'] );
392 + if ( empty( $attributes['justificationAlign'] ) || $has_old_justifyAlign_value ) {
393 + $block['attrs']['justificationAlign']['value'] = $has_old_justifyAlign_value ? $attributes['justifyAlign'] : 'center';
394 + $block['attrs']['justifyAlign'] = '';
395 + }
396 + if ( ! empty( $attributes['justifyAlignTablet'] ) ) {
397 + $block['attrs']['justificationAlign']['valueTablet'] = $attributes['justifyAlignTablet'];
398 + $block['attrs']['justifyAlignTablet'] = '';
399 + }
400 + if ( ! empty( $attributes['justifyAlignMobile'] ) ) {
401 + $block['attrs']['justificationAlign']['valueMobile'] = $attributes['justifyAlignMobile'];
402 + $block['attrs']['justifyAlignMobile'] = '';
403 + }
404 + $has_old_align_value = ! empty( $block['attrs']['align'] );
405 + if ( empty( $attributes['alignment'] ) || $has_old_align_value ) {
406 + $block['attrs']['alignment']['value'] = $has_old_align_value ? $attributes['align'] : 'stretch';
407 + $block['attrs']['align'] = '';
408 + }
409 + if ( ! empty( $attributes['alignTablet'] ) ) {
410 + $block['attrs']['alignment']['valueTablet'] = $attributes['alignTablet'];
411 + $block['attrs']['alignTablet'] = '';
412 + }
413 + if ( ! empty( $attributes['alignMobile'] ) ) {
414 + $block['attrs']['alignment']['valueMobile'] = $attributes['alignMobile'];
415 + $block['attrs']['alignMobile'] = '';
416 + }
417 + $has_old_wrap_value = ! empty( $block['attrs']['wrap'] );
418 + if ( empty( $attributes['wrapping'] ) || $has_old_wrap_value ) {
419 + $block['attrs']['wrapping']['value'] = $has_old_wrap_value ? $attributes['wrap'] : 'wrap';
420 + $block['attrs']['wrap'] = '';
421 + }
422 + if ( ! empty( $attributes['wrapTablet'] ) ) {
423 + $block['attrs']['wrapping']['valueTablet'] = $attributes['wrapTablet'];
424 + $block['attrs']['wrapTablet'] = '';
425 + }
426 + if ( ! empty( $attributes['wrapMobile'] ) ) {
427 + $block['attrs']['wrapping']['valueMobile'] = $attributes['wrapMobile'];
428 + $block['attrs']['wrapMobile'] = '';
429 + }
430 + // button-group control migration end
431 + break;
432 + }//end switch
433 + }//end if
434 + return $block;
435 + }
436 +
437 +
438 +}