File tree Expand file tree Collapse file tree 4 files changed +8
-15
lines changed
Expand file tree Collapse file tree 4 files changed +8
-15
lines changed Original file line number Diff line number Diff line change 1313 ],
1414 "textdomain" : " stackable-ultimate-gutenberg-blocks" ,
1515 "stk-type" : " hidden" ,
16- "stk-demo" : " https://wpstackable.com/button-block/?utm_source=welcome&utm_medium=settings&utm_campaign=view_demo&utm_content=demolink"
16+ "stk-demo" : " https://wpstackable.com/button-block/?utm_source=welcome&utm_medium=settings&utm_campaign=view_demo&utm_content=demolink" ,
17+ "stk-block-dependency" : " stackable/button-group|button"
1718}
Original file line number Diff line number Diff line change 1313 ],
1414 "textdomain" : " stackable-ultimate-gutenberg-blocks" ,
1515 "stk-type" : " hidden" ,
16- "stk-demo" : " https://wpstackable.com/icon-button-block/?utm_source=welcome&utm_medium=settings&utm_campaign=view_demo&utm_content=demolink"
16+ "stk-demo" : " https://wpstackable.com/icon-button-block/?utm_source=welcome&utm_medium=settings&utm_campaign=view_demo&utm_content=demolink" ,
17+ "stk-block-dependency" : " stackable/button-group|icon-button"
1718}
Original file line number Diff line number Diff line change @@ -6,7 +6,6 @@ import { settings } from 'stackable'
66import { addFilter } from '@wordpress/hooks'
77import {
88 BLOCK_STATE ,
9- BLOCK_DEPENDENCIES ,
109 substituteCoreIfDisabled ,
1110} from '~stackable/util'
1211import _ from 'lodash'
@@ -55,8 +54,8 @@ const applySettingsToMeta = metadata => {
5554 }
5655
5756 // Check if this block is dependent on another variation being enabled.
58- if ( BLOCK_DEPENDENCIES [ metadata . name ] && BLOCK_DEPENDENCIES [ metadata . name ] in disabledBlocks ) {
59- inserter = ! disabledBlocks [ BLOCK_DEPENDENCIES [ metadata . name ] ] === BLOCK_STATE . HIDDEN
57+ if ( metadata [ 'stk-block-dependency' ] && metadata [ 'stk-block-dependency' ] in disabledBlocks ) {
58+ inserter = ! disabledBlocks [ metadata [ 'stk-block-dependency' ] ] === BLOCK_STATE . HIDDEN
6059 }
6160
6261 const variationsToRemove = getVariationsToRemove ( disabledBlocks , metadata . name )
Original file line number Diff line number Diff line change @@ -46,14 +46,6 @@ export const BLOCK_STATE = Object.freeze( {
4646 DISABLED : 3 ,
4747} )
4848
49- /**
50- * Block dependencies. If a block is hidden/disabled, the block it depends on will also be one.
51- */
52- export const BLOCK_DEPENDENCIES = {
53- 'stackable/icon-button' : 'stackable/button-group|icon-button' ,
54- 'stackable/button' : 'stackable/button-group|button' ,
55- }
56-
5749/**
5850 * Converts the registered block name into a block name string that can be used in hook names or ids.
5951 *
@@ -498,8 +490,8 @@ export const addStackableBlockCategory = () => {
498490 */
499491export const registerBlockType = ( name , _settings ) => {
500492 // Do not register the block if the block is disabled.
501- if ( ( BLOCK_DEPENDENCIES [ name ] in stackableSettings . stackable_block_states &&
502- stackableSettings . stackable_block_states [ BLOCK_DEPENDENCIES [ name ] ] === BLOCK_STATE . DISABLED ) ||
493+ if ( ( _settings [ 'stk-block-dependency' ] in stackableSettings . stackable_block_states &&
494+ stackableSettings . stackable_block_states [ _settings [ 'stk-block-dependency' ] ] === BLOCK_STATE . DISABLED ) ||
503495 stackableSettings . stackable_block_states [ name ] === BLOCK_STATE . DISABLED
504496 ) {
505497 return
You can’t perform that action at this time.
0 commit comments