Skip to content

Commit 6563a0a

Browse files
added missing file
1 parent 79ab801 commit 6563a0a

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/deprecated/editor-settings.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
// Exit if accessed directly.
4+
if ( ! defined( 'ABSPATH' ) ) {
5+
exit;
6+
}
7+
8+
if ( ! function_exists( 'stackable_migrate_block_hidden_states' ) ) {
9+
/**
10+
* Migrate from disabled blocks array to block states object.
11+
*
12+
* @return void
13+
*/
14+
function stackable_migrate_block_hidden_states() {
15+
// Check if the old setting exists and the new setting is empty.
16+
if ( get_option( 'stackable_disabled_blocks' ) !== false && empty( get_option( 'stackable_block_states', [] ) ) ) {
17+
$old_disabled_blocks = get_option( 'stackable_disabled_blocks', [] );
18+
$new_block_states = [];
19+
20+
if ( is_array( $old_disabled_blocks ) ) {
21+
foreach ( $old_disabled_blocks as $block_name ) {
22+
// In the block_states, hidden is 2 and disabled is 3
23+
$new_block_states[ $block_name ] = 2;
24+
}
25+
}
26+
27+
update_option( 'stackable_block_states', $new_block_states );
28+
delete_option( 'stackable_disabled_blocks' );
29+
}
30+
}
31+
32+
// Migrate settings.
33+
add_action( 'admin_init', 'stackable_migrate_block_hidden_states' );
34+
}

0 commit comments

Comments
 (0)