| 1 |
<?php |
| 2 |
namespace ABlocks; |
| 3 |
|
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; |
| 6 |
} |
| 7 |
|
| 8 |
use ABlocks\Admin\Settings; |
| 9 |
use ABlocks\Helper; |
| 10 |
|
| 11 |
class Migration { |
| 12 |
|
| 13 |
public static function init() { |
| 14 |
$self = new self(); |
| 15 |
$self->run_migration(); |
| 16 |
add_filter( 'render_block_data', array( $self, 'update_attributes_backward_compatibility' ) ); |
| 17 |
} |
| 18 |
|
| 19 |
public function run_migration() { |
| 20 |
$this->migrate_font_stack(); |
| 21 |
// Must run BEFORE Settings::save_settings() so the raw option still |
| 22 |
// shows which keys were never persisted (old "missing = enabled" sites). |
| 23 |
$this->migrate_integration_block_defaults(); |
| 24 |
|
| 25 |
$ablocks_version = get_option( 'ablocks_version' ); |
| 26 |
// Save Version Number, flash role management and save permalink |
| 27 |
if ( ABLOCKS_VERSION !== $ablocks_version ) { |
| 28 |
Settings::save_settings(); |
| 29 |
$this->migrate_1_6_3( $ablocks_version ); |
| 30 |
$this->migrate_1_8_0( $ablocks_version ); |
| 31 |
update_option( 'ablocks_version', ABLOCKS_VERSION ); |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* Academy LMS, StoreEngine and ECM blocks used to default to enabled, and |
| 37 |
* old versions only persisted the "off" state — a block without an entry in |
| 38 |
* the visibility option was treated as enabled by the reader. The reader |
| 39 |
* now treats missing keys as disabled, so an old sparse save would silently |
| 40 |
* turn integration blocks off after upgrade. |
| 41 |
* |
| 42 |
* Once per integration: for every block without an explicit entry, write |
| 43 |
* `true` when the companion plugin is active (preserve the old on-by- |
| 44 |
* default behavior for sites that actually use the integration) and |
| 45 |
* `false` otherwise (new installs and sites that never had the plugin). |
| 46 |
* Blocks that already have an explicit value are the user's choice and are |
| 47 |
* left alone. No post_content scan — this is O(number of blocks). |
| 48 |
*/ |
| 49 |
public function migrate_integration_block_defaults() { |
| 50 |
$integrations = [ |
| 51 |
'academy' => 'academy/academy.php', |
| 52 |
'storeengine' => 'storeengine/storeengine.php', |
| 53 |
'ecm' => 'easy-content-manager/easy-content-manager.php', |
| 54 |
]; |
| 55 |
// _v2: an earlier version of this migration treated any `true` already |
| 56 |
// in the option as a user choice and left stale installer defaults in |
| 57 |
// place. Bump the tracker so sites that ran the old pass re-migrate. |
| 58 |
$option_key = 'ablocks_integration_blocks_migrated_v2'; |
| 59 |
$done = (array) get_option( $option_key, [] ); |
| 60 |
if ( ! array_diff( array_keys( $integrations ), $done ) ) { |
| 61 |
return; |
| 62 |
} |
| 63 |
|
| 64 |
$raw = get_option( ABLOCKS_BLOCKS_VISIBILITY_SETTINGS_NAME ); |
| 65 |
$saved_blocks = $raw ? (array) json_decode( $raw, true ) : []; |
| 66 |
$block_names = array_keys( Settings\Blocks::get_default_data() ); |
| 67 |
$changed = false; |
| 68 |
|
| 69 |
foreach ( $integrations as $prefix => $plugin_file ) { |
| 70 |
if ( in_array( $prefix, $done, true ) ) { |
| 71 |
continue; |
| 72 |
} |
| 73 |
$done[] = $prefix; |
| 74 |
$plugin_active = Helper::is_plugin_active( $plugin_file ); |
| 75 |
$names = array_filter( $block_names, function ( $name ) use ( $prefix ) { |
| 76 |
return 0 === strpos( $name, $prefix . '-' ); |
| 77 |
} ); |
| 78 |
foreach ( $names as $name ) { |
| 79 |
if ( $plugin_active ) { |
| 80 |
// Preserve the user's choice when they have the companion |
| 81 |
// plugin. Missing keys mean the old "missing = enabled" |
| 82 |
// behavior, so write true to keep those blocks on. |
| 83 |
if ( ! array_key_exists( $name, $saved_blocks ) ) { |
| 84 |
$saved_blocks[ $name ] = true; |
| 85 |
$changed = true; |
| 86 |
} |
| 87 |
continue; |
| 88 |
} |
| 89 |
// Companion plugin not active → the blocks cannot render. |
| 90 |
// Force-disable, including any `true` left behind by the old |
| 91 |
// installer which saved on-by-default values into the option. |
| 92 |
if ( ! array_key_exists( $name, $saved_blocks ) || $saved_blocks[ $name ] ) { |
| 93 |
$saved_blocks[ $name ] = false; |
| 94 |
$changed = true; |
| 95 |
} |
| 96 |
} |
| 97 |
} |
| 98 |
|
| 99 |
if ( $changed ) { |
| 100 |
update_option( ABLOCKS_BLOCKS_VISIBILITY_SETTINGS_NAME, wp_json_encode( $saved_blocks ) ); |
| 101 |
// Block classes read this global when they're constructed later in the request. |
| 102 |
$existing = isset( $GLOBALS['ablocks_blocks'] ) ? (array) $GLOBALS['ablocks_blocks'] : []; |
| 103 |
$GLOBALS['ablocks_blocks'] = (object) array_merge( $existing, $saved_blocks ); |
| 104 |
} |
| 105 |
update_option( $option_key, $done ); |
| 106 |
} |
| 107 |
|
| 108 |
/** |
| 109 |
* font-family declarations are now emitted as full stacks (quoted family + |
| 110 |
* metric fallback + generic) instead of a bare family name. |
| 111 |
* |
| 112 |
* Block CSS is cached in generated files and the global CSS variables live in |
| 113 |
* a transient, so both hold the old single-name output until something forces |
| 114 |
* a rebuild. Clear them once so existing pages pick up the new stacks without |
| 115 |
* anyone having to re-save every page. |
| 116 |
*/ |
| 117 |
public function migrate_font_stack() { |
| 118 |
if ( get_option( 'ablocks_font_stack_migrated' ) ) { |
| 119 |
return; |
| 120 |
} |
| 121 |
|
| 122 |
// Deleting generated files needs WP_Filesystem; keep that out of visitor |
| 123 |
// requests. The first admin page load after the update does the work. |
| 124 |
if ( ! is_admin() && ! ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
| 125 |
return; |
| 126 |
} |
| 127 |
|
| 128 |
( new \ABlocks\Classes\FileUpload() )->delete_files(); |
| 129 |
delete_transient( 'ablocks_global_css_vars' ); |
| 130 |
// Force a rebuild of the template/part/theme-builder font set, which did |
| 131 |
// not exist before this release. |
| 132 |
\ABlocks\Classes\FontCollector::flush_site_fonts(); |
| 133 |
|
| 134 |
update_option( 'ablocks_font_stack_migrated', '1' ); |
| 135 |
} |
| 136 |
|
| 137 |
public function migrate_1_6_3( $version ) { |
| 138 |
if ( version_compare( $version, '1.6.3', '<=' ) ) { |
| 139 |
add_option( 'ablocks_has_required_block_attribute_migration', '1.6.3' ); |
| 140 |
// Delete Old Table |
| 141 |
global $wpdb; |
| 142 |
$prefix = $wpdb->prefix; |
| 143 |
Database\CreateFormTable::down( $prefix ); |
| 144 |
// Crate New database table |
| 145 |
Database::create_initial_custom_table(); |
| 146 |
} |
| 147 |
} |
| 148 |
public function migrate_1_8_0( $version ) { |
| 149 |
if ( version_compare( $version, '1.8.0', '<=' ) ) { |
| 150 |
global $wpdb; |
| 151 |
$table_name = $wpdb->prefix . ABLOCKS_PLUGIN_SLUG . '_form_entries'; |
| 152 |
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.SchemaChange |
| 153 |
$wpdb->query( "ALTER TABLE `{$table_name}` MODIFY `post_id` VARCHAR(100) NULL" ); |
| 154 |
} |
| 155 |
} |
| 156 |
|
| 157 |
public function update_attributes_backward_compatibility( $block ) { |
| 158 |
if ( get_option( 'ablocks_has_required_block_attribute_migration' ) === '1.6.3' ) { |
| 159 |
|
| 160 |
$attributes = ! empty( $block['attrs'] ) ? $block['attrs'] : []; |
| 161 |
switch ( $block['blockName'] ) { |
| 162 |
case 'ablocks/container': |
| 163 |
$has_old_direction_value = ! empty( $block['attrs']['direction'] ); |
| 164 |
if ( empty( $block['attrs']['dir']['value'] ) || $has_old_direction_value ) { |
| 165 |
$block['attrs']['dir']['value'] = $has_old_direction_value ? $attributes['direction'] : 'column'; |
| 166 |
$block['attrs']['direction'] = ''; |
| 167 |
} |
| 168 |
|
| 169 |
if ( ! empty( $attributes['directionTablet'] ) ) { |
| 170 |
$block['attrs']['dir']['valueTablet'] = $attributes['directionTablet']; |
| 171 |
$block['attrs']['directionTablet'] = ''; |
| 172 |
} |
| 173 |
|
| 174 |
if ( ! empty( $attributes['directionMobile'] ) ) { |
| 175 |
$block['attrs']['dir']['valueMobile'] = $attributes['directionMobile']; |
| 176 |
$block['attrs']['directionMobile'] = ''; |
| 177 |
} |
| 178 |
|
| 179 |
if ( ! empty( $attributes['justify'] ) ) { |
| 180 |
$block['attrs']['justification']['value'] = $attributes['justify']; |
| 181 |
$block['attrs']['justify'] = ''; |
| 182 |
} |
| 183 |
|
| 184 |
if ( ! empty( $attributes['justifyTablet'] ) ) { |
| 185 |
$block['attrs']['justification']['valueTablet'] = $attributes['justifyTablet']; |
| 186 |
$block['attrs']['justifyTablet'] = ''; |
| 187 |
} |
| 188 |
|
| 189 |
if ( ! empty( $attributes['justifyMobile'] ) ) { |
| 190 |
$block['attrs']['justification']['valueMobile'] = $attributes['justifyMobile']; |
| 191 |
$block['attrs']['justifyMobile'] = ''; |
| 192 |
} |
| 193 |
|
| 194 |
if ( ! empty( $attributes['align'] ) ) { |
| 195 |
$block['attrs']['alignment']['value'] = $attributes['align']; |
| 196 |
$block['attrs']['align'] = ''; |
| 197 |
} |
| 198 |
|
| 199 |
if ( ! empty( $attributes['alignTablet'] ) ) { |
| 200 |
$block['attrs']['alignment']['valueTablet'] = $attributes['alignTablet']; |
| 201 |
$block['attrs']['alignTablet'] = ''; |
| 202 |
} |
| 203 |
|
| 204 |
if ( ! empty( $attributes['alignMobile'] ) ) { |
| 205 |
$block['attrs']['alignment']['valueMobile'] = $attributes['alignMobile']; |
| 206 |
$block['attrs']['alignMobile'] = ''; |
| 207 |
} |
| 208 |
|
| 209 |
if ( ! empty( $attributes['wrap'] ) ) { |
| 210 |
$block['attrs']['wrapping']['value'] = $attributes['wrap']; |
| 211 |
$block['attrs']['wrap'] = ''; |
| 212 |
} |
| 213 |
|
| 214 |
if ( ! empty( $attributes['wrapTablet'] ) ) { |
| 215 |
$block['attrs']['wrapping']['valueTablet'] = $attributes['wrapTablet']; |
| 216 |
$block['attrs']['wrapTablet'] = ''; |
| 217 |
} |
| 218 |
|
| 219 |
if ( ! empty( $attributes['wrapMobile'] ) ) { |
| 220 |
$block['attrs']['wrapping']['valueMobile'] = $attributes['wrapMobile']; |
| 221 |
$block['attrs']['wrapMobile'] = ''; |
| 222 |
} |
| 223 |
break; |
| 224 |
case 'ablocks/counter': |
| 225 |
case 'ablocks/coupon': |
| 226 |
case 'ablocks/icon': |
| 227 |
case 'ablocks/notice': |
| 228 |
case 'ablocks/paypal-button': |
| 229 |
case 'ablocks/price-menu-item': |
| 230 |
case 'ablocks/star-ratings': |
| 231 |
case 'ablocks/stripe-button': |
| 232 |
case 'ablocks/svg-draw': |
| 233 |
case 'ablocks/tabs': |
| 234 |
if ( ! empty( $attributes['iconSize'] ) ) { |
| 235 |
$block['attrs']['iconSizing']['value'] = $attributes['iconSize']; |
| 236 |
} |
| 237 |
if ( ! empty( $attributes['iconRotate'] ) ) { |
| 238 |
$block['attrs']['iconRotated']['value'] = $attributes['iconRotate']; |
| 239 |
} |
| 240 |
// button-group control migration start |
| 241 |
$has_old_tabsMenuPosition_value = ! empty( $block['attrs']['tabsMenuPosition'] ); |
| 242 |
if ( empty( $block['attrs']['tabsMenuPositioning']['value'] ) || $has_old_tabsMenuPosition_value ) { |
| 243 |
$block['attrs']['tabsMenuPositioning']['value'] = $has_old_tabsMenuPosition_value ? $attributes['tabsMenuPosition'] : 'left'; |
| 244 |
$block['attrs']['tabsMenuPosition'] = ''; |
| 245 |
} |
| 246 |
if ( ! empty( $attributes['tabsMenuPositionTablet'] ) ) { |
| 247 |
$block['attrs']['tabsMenuPositioning']['valueTablet'] = $attributes['tabsMenuPositionTablet']; |
| 248 |
$block['attrs']['tabsMenuPositionTablet'] = ''; |
| 249 |
} |
| 250 |
if ( ! empty( $attributes['tabsMenuPositionMobile'] ) ) { |
| 251 |
$block['attrs']['tabsMenuPositioning']['valueMobile'] = $attributes['tabsMenuPositionMobile']; |
| 252 |
$block['attrs']['tabsMenuPositionMobile'] = ''; |
| 253 |
} |
| 254 |
if ( ! empty( $attributes['tabMenuAlign'] ) ) { |
| 255 |
$block['attrs']['tabMenuAlignment']['value'] = $attributes['tabMenuAlign']; |
| 256 |
$block['attrs']['tabMenuAlign'] = ''; |
| 257 |
} |
| 258 |
if ( ! empty( $attributes['tabMenuAlignTablet'] ) ) { |
| 259 |
$block['attrs']['tabMenuAlignment']['valueTablet'] = $attributes['tabMenuAlignTablet']; |
| 260 |
$block['attrs']['tabMenuAlignTablet'] = ''; |
| 261 |
} |
| 262 |
if ( ! empty( $attributes['tabMenuAlignMobile'] ) ) { |
| 263 |
$block['attrs']['tabMenuAlignment']['valueMobile'] = $attributes['tabMenuAlignMobile']; |
| 264 |
$block['attrs']['tabMenuAlignMobile'] = ''; |
| 265 |
} |
| 266 |
$has_old_menuContentAlign_value = ! empty( $block['attrs']['menuContentAlign'] ); |
| 267 |
if ( empty( $block['attrs']['menuContentAlignment']['value'] ) || $has_old_menuContentAlign_value ) { |
| 268 |
$block['attrs']['menuContentAlignment']['value'] = $has_old_menuContentAlign_value ? $attributes['menuContentAlign'] : 'center'; |
| 269 |
$block['attrs']['menuContentAlign'] = ''; |
| 270 |
} |
| 271 |
if ( ! empty( $attributes['menuContentAlignTablet'] ) ) { |
| 272 |
$block['attrs']['menuContentAlignment']['valueTablet'] = $attributes['menuContentAlignTablet']; |
| 273 |
$block['attrs']['menuContentAlignTablet'] = ''; |
| 274 |
} |
| 275 |
if ( ! empty( $attributes['menuContentAlignMobile'] ) ) { |
| 276 |
$block['attrs']['menuContentAlignment']['valueMobile'] = $attributes['menuContentAlignMobile']; |
| 277 |
$block['attrs']['menuContentAlignMobile'] = ''; |
| 278 |
} |
| 279 |
|
| 280 |
// button-group control migration end |
| 281 |
|
| 282 |
break; |
| 283 |
|
| 284 |
case 'ablocks/button': |
| 285 |
if ( ! empty( $attributes['iconSize'] ) ) { |
| 286 |
$iconSize = intval( $attributes['iconSize'] ); |
| 287 |
if ( $iconSize !== 16 ) { |
| 288 |
$block['attrs']['iconSizing']['value'] = $iconSize; |
| 289 |
} |
| 290 |
} |
| 291 |
if ( ! empty( $attributes['iconRotate'] ) ) { |
| 292 |
$block['attrs']['iconRotated']['value'] = $attributes['iconRotate']; |
| 293 |
} |
| 294 |
break; |
| 295 |
|
| 296 |
case 'ablocks/form-input': |
| 297 |
if ( ! empty( $attributes['iconSize'] ) ) { |
| 298 |
$block['attrs']['iconSizing']['value'] = $attributes['iconSize']; |
| 299 |
} |
| 300 |
if ( ! empty( $attributes['iconRotate'] ) ) { |
| 301 |
$block['attrs']['iconRotated']['value'] = $attributes['iconRotate']; |
| 302 |
} |
| 303 |
break; |
| 304 |
|
| 305 |
case 'ablocks/form-password': |
| 306 |
if ( ! empty( $attributes['iconSize'] ) ) { |
| 307 |
$block['attrs']['iconSizing']['value'] = $attributes['iconSize']; |
| 308 |
} |
| 309 |
if ( ! empty( $attributes['iconRotate'] ) ) { |
| 310 |
$block['attrs']['iconRotated']['value'] = $attributes['iconRotate']; |
| 311 |
} |
| 312 |
|
| 313 |
if ( ! empty( $attributes['passwordShowSize'] ) ) { |
| 314 |
$block['attrs']['passwordShowSizing']['value'] = $attributes['passwordShowSize']; |
| 315 |
} |
| 316 |
if ( ! empty( $attributes['passwordShowRotate'] ) ) { |
| 317 |
$block['attrs']['passwordShowRotated']['value'] = $attributes['passwordShowRotate']; |
| 318 |
} |
| 319 |
if ( ! empty( $attributes['passwordHideSize'] ) ) { |
| 320 |
$block['attrs']['passwordHideSizing']['value'] = $attributes['passwordHideSize']; |
| 321 |
} |
| 322 |
if ( ! empty( $attributes['passwordHideRotate'] ) ) { |
| 323 |
$block['attrs']['passwordHideRotated']['value'] = $attributes['passwordHideRotate']; |
| 324 |
} |
| 325 |
|
| 326 |
break; |
| 327 |
|
| 328 |
case 'ablocks/carousel': |
| 329 |
if ( ! empty( $attributes['leftIconSize'] ) ) { |
| 330 |
$block['attrs']['leftIconSizing']['value'] = $attributes['leftIconSize']; |
| 331 |
} |
| 332 |
if ( ! empty( $attributes['leftIconRotate'] ) ) { |
| 333 |
$block['attrs']['leftIconRotated']['value'] = $attributes['leftIconRotate']; |
| 334 |
} |
| 335 |
if ( ! empty( $attributes['rightIconSize'] ) ) { |
| 336 |
$block['attrs']['rightIconSizing']['value'] = $attributes['rightIconSize']; |
| 337 |
} |
| 338 |
if ( ! empty( $attributes['rightIconRotate'] ) ) { |
| 339 |
$block['attrs']['rightIconRotated']['value'] = $attributes['rightIconRotate']; |
| 340 |
} |
| 341 |
break; |
| 342 |
case 'ablocks/content-timeline': |
| 343 |
break; |
| 344 |
case 'ablocks/content-timeline-child': |
| 345 |
if ( ! empty( $attributes['iconSize'] ) ) { |
| 346 |
$block['attrs']['iconSizing']['value'] = $attributes['iconSize']; |
| 347 |
} |
| 348 |
if ( ! empty( $attributes['iconRotate'] ) ) { |
| 349 |
$block['attrs']['iconRotated']['value'] = $attributes['iconRotate']; |
| 350 |
} |
| 351 |
|
| 352 |
if ( ! empty( $attributes['contentTimeLineIconSize'] ) ) { |
| 353 |
$block['attrs']['contentTimeLineIconSizing']['value'] = $attributes['contentTimeLineIconSize']; |
| 354 |
} |
| 355 |
if ( ! empty( $attributes['contentTimeLineIconRotate'] ) ) { |
| 356 |
$block['attrs']['contentTimeLineIconRotated']['value'] = $attributes['contentTimeLineIconRotate']; |
| 357 |
} |
| 358 |
break; |
| 359 |
|
| 360 |
case 'ablocks/divider': |
| 361 |
if ( ! empty( $attributes['iconSize'] ) ) { |
| 362 |
$block['attrs']['iconSizing']['value'] = $attributes['iconSize']; |
| 363 |
} |
| 364 |
if ( ! empty( $attributes['iconRotate'] ) ) { |
| 365 |
$block['attrs']['iconRotated']['value'] = $attributes['iconRotate']; |
| 366 |
} |
| 367 |
break; |
| 368 |
|
| 369 |
case 'ablocks/single-accordion': |
| 370 |
if ( ! empty( $attributes['leftActiveIconSize'] ) ) { |
| 371 |
$block['attrs']['leftActiveIconSizing']['value'] = $attributes['leftActiveIconSize']; |
| 372 |
} |
| 373 |
if ( ! empty( $attributes['leftActiveIconRotate'] ) ) { |
| 374 |
$block['attrs']['leftActiveIconRotated']['value'] = $attributes['leftActiveIconRotate']; |
| 375 |
} |
| 376 |
if ( ! empty( $attributes['leftCloseIconSize'] ) ) { |
| 377 |
$block['attrs']['leftCloseIconSizing']['value'] = $attributes['leftCloseIconSize']; |
| 378 |
} |
| 379 |
if ( ! empty( $attributes['leftCloseIconRotate'] ) ) { |
| 380 |
$block['attrs']['leftCloseIconRotated']['value'] = $attributes['leftCloseIconRotate']; |
| 381 |
} |
| 382 |
if ( ! empty( $attributes['rightActiveIconSize'] ) ) { |
| 383 |
$block['attrs']['rightActiveIconSizing']['value'] = $attributes['rightActiveIconSize']; |
| 384 |
} |
| 385 |
if ( ! empty( $attributes['rightActiveIconRotate'] ) ) { |
| 386 |
$block['attrs']['rightActiveIconRotated']['value'] = $attributes['rightActiveIconRotate']; |
| 387 |
} |
| 388 |
if ( ! empty( $attributes['rightCloseIconSize'] ) ) { |
| 389 |
$block['attrs']['rightCloseIconSizing']['value'] = $attributes['rightCloseIconSize']; |
| 390 |
} |
| 391 |
if ( ! empty( $attributes['rightCloseIconRotate'] ) ) { |
| 392 |
$block['attrs']['rightCloseIconRotated']['value'] = $attributes['rightCloseIconRotate']; |
| 393 |
} |
| 394 |
break; |
| 395 |
|
| 396 |
case 'ablocks/table-of-content': |
| 397 |
if ( ! empty( $attributes['iconSize'] ) ) { |
| 398 |
$block['attrs']['iconSizing']['value'] = $attributes['iconSize']; |
| 399 |
} |
| 400 |
if ( ! empty( $attributes['iconRotate'] ) ) { |
| 401 |
$block['attrs']['iconRotated']['value'] = $attributes['iconRotate']; |
| 402 |
} |
| 403 |
|
| 404 |
if ( ! empty( $attributes['closeIconSize'] ) ) { |
| 405 |
$block['attrs']['closeIconSizing']['value'] = $attributes['closeIconSize']; |
| 406 |
} |
| 407 |
if ( ! empty( $attributes['closeIconRotate'] ) ) { |
| 408 |
$block['attrs']['closeIconRotated']['value'] = $attributes['closeIconRotate']; |
| 409 |
} |
| 410 |
if ( ! empty( $attributes['openIconSize'] ) ) { |
| 411 |
$block['attrs']['openIconSizing']['value'] = $attributes['openIconSize']; |
| 412 |
} |
| 413 |
if ( ! empty( $attributes['openIconRotate'] ) ) { |
| 414 |
$block['attrs']['openIconRotated']['value'] = $attributes['openIconRotate']; |
| 415 |
} |
| 416 |
break; |
| 417 |
|
| 418 |
case 'ablocks/info-box': |
| 419 |
if ( ! empty( $attributes['iconSize'] ) ) { |
| 420 |
$block['attrs']['iconSizing']['value'] = $attributes['iconSize']; |
| 421 |
} |
| 422 |
if ( ! empty( $attributes['iconRotate'] ) ) { |
| 423 |
$block['attrs']['iconRotated']['value'] = $attributes['iconRotate']; |
| 424 |
} |
| 425 |
if ( ! empty( $attributes['btnIconSize'] ) ) { |
| 426 |
$block['attrs']['btnIconSizing']['value'] = $attributes['btnIconSize']; |
| 427 |
} |
| 428 |
if ( ! empty( $attributes['btnIconRotate'] ) ) { |
| 429 |
$block['attrs']['btnIconRotated']['value'] = $attributes['btnIconRotate']; |
| 430 |
} |
| 431 |
if ( ! empty( $attributes['starIconSize'] ) ) { |
| 432 |
$block['attrs']['starIconSizing']['value'] = $attributes['starIconSize']; |
| 433 |
} |
| 434 |
if ( ! empty( $attributes['starIconRotate'] ) ) { |
| 435 |
$block['attrs']['starIconRotated']['value'] = $attributes['starIconRotate']; |
| 436 |
} |
| 437 |
break; |
| 438 |
|
| 439 |
case 'ablocks/lists': |
| 440 |
break; |
| 441 |
|
| 442 |
case 'ablocks/modal': |
| 443 |
break; |
| 444 |
case 'ablocks/progress-tracker': |
| 445 |
break; |
| 446 |
case 'ablocks/social-shares': |
| 447 |
break; |
| 448 |
case 'ablocks/toggle': |
| 449 |
break; |
| 450 |
case 'ablocks/flip-box': |
| 451 |
break; |
| 452 |
|
| 453 |
case 'ablocks/countdown': |
| 454 |
// button-group control migration start |
| 455 |
$has_old_direction_value = ! empty( $block['attrs']['direction'] ); |
| 456 |
if ( empty( $attributes['orient'] ) || $has_old_direction_value ) { |
| 457 |
$block['attrs']['orient']['value'] = $has_old_direction_value ? $attributes['direction'] : 'row'; |
| 458 |
$block['attrs']['direction'] = ''; |
| 459 |
} |
| 460 |
if ( ! empty( $attributes['directionTablet'] ) ) { |
| 461 |
$block['attrs']['orient']['valueTablet'] = $attributes['directionTablet']; |
| 462 |
$block['attrs']['directionTablet'] = ''; |
| 463 |
} |
| 464 |
if ( ! empty( $attributes['directionMobile'] ) ) { |
| 465 |
$block['attrs']['orient']['valueMobile'] = $attributes['directionMobile']; |
| 466 |
$block['attrs']['directionMobile'] = ''; |
| 467 |
} |
| 468 |
$has_old_justifyAlign_value = ! empty( $block['attrs']['justifyAlign'] ); |
| 469 |
if ( empty( $attributes['justificationAlign'] ) || $has_old_justifyAlign_value ) { |
| 470 |
$block['attrs']['justificationAlign']['value'] = $has_old_justifyAlign_value ? $attributes['justifyAlign'] : 'center'; |
| 471 |
$block['attrs']['justifyAlign'] = ''; |
| 472 |
} |
| 473 |
if ( ! empty( $attributes['justifyAlignTablet'] ) ) { |
| 474 |
$block['attrs']['justificationAlign']['valueTablet'] = $attributes['justifyAlignTablet']; |
| 475 |
$block['attrs']['justifyAlignTablet'] = ''; |
| 476 |
} |
| 477 |
if ( ! empty( $attributes['justifyAlignMobile'] ) ) { |
| 478 |
$block['attrs']['justificationAlign']['valueMobile'] = $attributes['justifyAlignMobile']; |
| 479 |
$block['attrs']['justifyAlignMobile'] = ''; |
| 480 |
} |
| 481 |
$has_old_align_value = ! empty( $block['attrs']['align'] ); |
| 482 |
if ( empty( $attributes['alignment'] ) || $has_old_align_value ) { |
| 483 |
$block['attrs']['alignment']['value'] = $has_old_align_value ? $attributes['align'] : 'stretch'; |
| 484 |
$block['attrs']['align'] = ''; |
| 485 |
} |
| 486 |
if ( ! empty( $attributes['alignTablet'] ) ) { |
| 487 |
$block['attrs']['alignment']['valueTablet'] = $attributes['alignTablet']; |
| 488 |
$block['attrs']['alignTablet'] = ''; |
| 489 |
} |
| 490 |
if ( ! empty( $attributes['alignMobile'] ) ) { |
| 491 |
$block['attrs']['alignment']['valueMobile'] = $attributes['alignMobile']; |
| 492 |
$block['attrs']['alignMobile'] = ''; |
| 493 |
} |
| 494 |
$has_old_wrap_value = ! empty( $block['attrs']['wrap'] ); |
| 495 |
if ( empty( $attributes['wrapping'] ) || $has_old_wrap_value ) { |
| 496 |
$block['attrs']['wrapping']['value'] = $has_old_wrap_value ? $attributes['wrap'] : 'wrap'; |
| 497 |
$block['attrs']['wrap'] = ''; |
| 498 |
} |
| 499 |
if ( ! empty( $attributes['wrapTablet'] ) ) { |
| 500 |
$block['attrs']['wrapping']['valueTablet'] = $attributes['wrapTablet']; |
| 501 |
$block['attrs']['wrapTablet'] = ''; |
| 502 |
} |
| 503 |
if ( ! empty( $attributes['wrapMobile'] ) ) { |
| 504 |
$block['attrs']['wrapping']['valueMobile'] = $attributes['wrapMobile']; |
| 505 |
$block['attrs']['wrapMobile'] = ''; |
| 506 |
} |
| 507 |
// button-group control migration end |
| 508 |
break; |
| 509 |
}//end switch |
| 510 |
}//end if |
| 511 |
return $block; |
| 512 |
} |
| 513 |
|
| 514 |
|
| 515 |
} |
| 516 |
|