File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments