Skip to content

Commit 84fa8dc

Browse files
authored
feat: granular plugin setting (#3319)
* feat: allow enabling, disabling and hiding of blocks * feat: add enable settings to toolbar features * feat: add settings store for tracking changes * feat: settings content organizaiont * feat: style for sidenav * feat: sidenav, organization, disabling blocks, and save changes * fix: change blockstate from 0-2 to 1-3 to avoid nfalsy 0 * feat: add min height to sidenav * feat: remove template since we will use react instead * feat: use react approach for cleaner and more efficient code * feat: admin notice when settings are saved * feat: integrate pro-related settings * fix: conditional lazy loading of pro settings * feat: integrate missing settings such as icon, pro notice, tooltip * feat: add stackable global settings * fix: indentation from merge conflict * feat: apply global settings by conditional registering * feat: search functionality integration * feat: application of search highlight through conditional classes * feat: search highlight style * feat: admin toolbar setting * feat: util function for substituting to disabled blocks * fix: disabling and hiding block variations * feat: disable/enable confirmation, disable/enable/hide all blocks * feat: removeChildIfDisabled * feat: first batch of core substitution and removal integration * fix: blockname typo * Revert "feat: first batch of core substitution and removal integration" This reverts commit 56551e1. * feat: piggyback on the filter instead of manual change in variations, finish all integrations * feat: special integration for blocks with no variation/neet to remove * feat: integrate card default-2 with social-links * fix: styles and media queries, spinner on saved * adjusted styling, removed javascript for fixed position * fade out the non-highlighted tabs * additional settings tweaking * fix: grayed out button when there are unsaved changes * chore: remove emojis fom headings * fix: line separator only between settings group * feat: resturcture with settings group, created a centralized search tree for single check (remaining heading fix) * feat: migration from from disabled blocks array to block states object * fix: run the migration script, old disabled block represents hidden * fix: typo on accessing search tree * fix: typo on setting name * feat: integrate v2 settings to new settings * feat: change block name to title in dialog * fix: disallow disabling of columns block * feat: add popup on unsaved changes * style tweaks * Fixed issue where blocks do not appear in the editor * enhanced styling of block toggle * simplified modal * updated text and buttons * tweaked subtitles * inverted box shadows * tweaked wording * fix: restucture block dependencies, storing them on individual block.json * fix: restructure substitition whitelist to individual blocks * fix: added additional blocks to substitute * fix: remove substituteIfDisabledFunction * fix: change content of save button after saving * feat: if no settings in current tab, display message * fix: only show dependent children/parents when needed * chore: rename block dependecies to stk-required-blocks * fix: restructure block dependency * chore: rename to required blocks * fix: move disabling of block outside the registration * moved deprecated code to new file in deprecated folder * added missing file * fix: if a block cannot be disabled, default to hidden when disabling all * feat: restructured substitute transform to separate files per block * fix: import substitution rules and apply * fix: access substitutionRules directly for blocks that uses TEMPLATE * fix: ensure there are default blocks if not disabled * fix: remove removeIfDisabled, make icon required for notification * feat: allow substitution of core blocks, console error for blocks with no substitution * fix: add alignment attribute to heading, text substitute * fix: UI changes * fix: FontAwesome notice alignment in free version * feat: warn what disabled blocks are needed in design library * align the font awesome notice with the field label * fix: use stk-available-states instead, if cannot be change into a state, retain previous value * fixed alignment of custom fields and role manager settings * updated font awesome field styles * added price and icon label substitution * disallow disabling of design library block * substitute divider with separator + allow no transform function * updated some substitutions * added fix for blocks undefined when inserting new design library entry * added more substitutions * added accordion and cta * added card substitute * added substitutions * added more substitutions * fix old design library entries will encounter an error when being added if the color string value is undefined * fix: cascade by repeatedly checking if disabled * fix: refactor, fix some substitutions * fix: do a preorder traversal to ensure parent is processed first * feat: add alert when substitution has been made * fix: substitute from the root, fixes CTA and feature design * fix: refactor, add oldAttributes to mimic previous design (batch 1) * substitute: hero, icon, imageBox, pricingBox * substitute: spacer, toc, testimonial, videoPopup * substitute: icon-box, transform to column then let it cascade * substitute: icon-list, generic for now since issue with the design * fix: change dummy text for iconlist * substitute(non-design): separator, tabs, timeline * fix old issue with migrating old colors * after saving, the substituted image blocks encounter an error --------- Co-authored-by: [email protected] <>
1 parent 558247b commit 84fa8dc

File tree

109 files changed

+2936
-800
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+2936
-800
lines changed

plugin.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ function is_frontend() {
278278
}
279279

280280
// Deprecated.
281+
require_once( plugin_dir_path( __FILE__ ) . 'src/deprecated/editor-settings.php' );
281282
require_once( plugin_dir_path( __FILE__ ) . 'src/deprecated/native-global-colors.php' );
282283
require_once( plugin_dir_path( __FILE__ ) . 'src/deprecated/navigation-panel-pre-enabled.php' );
283284
require_once( plugin_dir_path( __FILE__ ) . 'src/deprecated/font-awesome-version.php' );

src/block/accordion/block.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,13 @@
1111
],
1212
"textdomain": "stackable-ultimate-gutenberg-blocks",
1313
"stk-type": "special",
14-
"stk-demo": "https://wpstackable.com/accordion-block/?utm_source=welcome&utm_medium=settings&utm_campaign=view_demo&utm_content=demolink"
14+
"stk-demo": "https://wpstackable.com/accordion-block/?utm_source=welcome&utm_medium=settings&utm_campaign=view_demo&utm_content=demolink",
15+
"stk-required-blocks": [
16+
"stackable/icon-label",
17+
"stackable/heading",
18+
"stackable/icon"
19+
],
20+
"stk-substitution-blocks": [
21+
"stackable/text"
22+
]
1523
}

src/block/accordion/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import metadata from './block.json'
1717
import variations from './variations'
1818
import example from './example'
1919
import deprecated from './deprecated'
20+
import substitute from './substitute'
2021

2122
/**
2223
* WordPress dependencies
@@ -39,4 +40,5 @@ export const settings = {
3940
variations,
4041
edit,
4142
save,
43+
substitute,
4244
}

src/block/accordion/substitute.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
export const substitute = {
2+
from: 'stackable/accordion',
3+
transform: ( oldAttributes, innerBlocks ) => {
4+
// Get the heading
5+
const heading = innerBlocks[ 0 ][ 2 ][ 0 ][ 2 ][ 0 ][ 1 ].text
6+
const insideBlocks = innerBlocks[ 1 ][ 2 ]
7+
8+
return [
9+
'core/details',
10+
{
11+
open: false,
12+
summary: heading,
13+
},
14+
insideBlocks,
15+
]
16+
},
17+
}
18+
19+
export default substitute

src/block/blockquote/block.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,11 @@
77
"usesContext": [ "postId", "postType", "queryId" , "stackable/innerBlockOrientation" ],
88
"textdomain": "stackable-ultimate-gutenberg-blocks",
99
"stk-type": "section",
10-
"stk-demo": "https://wpstackable.com/blockquote-block/?utm_source=welcome&utm_medium=settings&utm_campaign=view_demo&utm_content=demolink"
10+
"stk-demo": "https://wpstackable.com/blockquote-block/?utm_source=welcome&utm_medium=settings&utm_campaign=view_demo&utm_content=demolink",
11+
"stk-required-blocks": [
12+
"stackable/icon"
13+
],
14+
"stk-substitution-blocks": [
15+
"stackable/text"
16+
]
1117
}

src/block/blockquote/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import save from './save'
1111
import schema from './schema'
1212
import example from './example'
1313
import deprecated from './deprecated'
14+
import substitute from './substitute'
1415

1516
/**
1617
* External dependencies
@@ -40,4 +41,5 @@ export const settings = {
4041
variations,
4142
edit,
4243
save,
44+
substitute,
4345
}

src/block/blockquote/substitute.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export const substitute = {
2+
from: 'stackable/blockquote',
3+
transform: ( oldAttributes, innerBlocks ) => {
4+
return [
5+
'core/pullquote',
6+
{
7+
value: innerBlocks[ 1 ][ 1 ].text,
8+
align: oldAttributes.contentAlign,
9+
},
10+
]
11+
},
12+
}
13+
14+
export default substitute

src/block/button-group/block.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,13 @@
3131
"description": "Add social buttons.",
3232
"category": "stackable",
3333
"stk-type": "special",
34-
"stk-demo": "https://wpstackable.com/social-buttons-block/?utm_source=welcome&utm_medium=settings&utm_campaign=view_demo&utm_content=demolink"
34+
"stk-demo": "https://wpstackable.com/social-buttons-block/?utm_source=welcome&utm_medium=settings&utm_campaign=view_demo&utm_content=demolink",
35+
"stk-required-blocks": [
36+
"stackable/button-group|icon-button"
37+
]
3538
}
3639
],
3740
"textdomain": "stackable-ultimate-gutenberg-blocks",
3841
"stk-type": "hidden"
42+
3943
}

src/block/button-group/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import metadata from './block.json'
1616
import variations from './variations'
1717
import deprecated from './deprecated'
1818
import { buttonExample } from './example'
19+
import substitute from './substitute'
1920

2021
/**
2122
* WordPress dependencies
@@ -40,4 +41,5 @@ export const settings = {
4041
example: buttonExample,
4142
edit,
4243
save,
44+
substitute,
4345
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { BLOCK_STATE } from '~stackable/util'
2+
3+
export const substitute = {
4+
from: 'stackable/button-group',
5+
variants: [ 'stackable/button-group|icon-button', 'stackable/button-group|button' ],
6+
to: [ 'core/buttons', 'core/social-links' ],
7+
transform: ( oldAttributes, innerBlocks, disabledBlocks ) => {
8+
if ( 'stackable/button-group|icon-button' in disabledBlocks && disabledBlocks[ 'stackable/button-group|icon-button' ] === BLOCK_STATE.DISABLED && // eslint-disable-line camelcase
9+
innerBlocks.length &&
10+
innerBlocks[ 0 ][ 0 ] === 'stackable/icon-button'
11+
) {
12+
return [ 'core/social-links',
13+
{ align: oldAttributes.contentAlign },
14+
[
15+
[ 'core/social-link', { service: 'facebook' } ],
16+
[ 'core/social-link', { service: 'twitter' } ],
17+
],
18+
]
19+
}
20+
if ( 'stackable/button-group|button' in disabledBlocks && disabledBlocks[ 'stackable/button-group|button' ] === BLOCK_STATE.DISABLED ) { // eslint-disable-line camelcase
21+
return [ 'core/buttons', {}, innerBlocks ]
22+
}
23+
return [ 'stackable/button-group', oldAttributes, innerBlocks ]
24+
},
25+
}
26+
27+
export default substitute

0 commit comments

Comments
 (0)