Skip to content

Commit

Permalink
Use dot notation for block variation isActive() checks.
Browse files Browse the repository at this point in the history
Supported in WordPress 6.6: WordPress/gutenberg#62088
  • Loading branch information
justintadlock committed Jun 10, 2024
1 parent eaece2a commit 84550a5
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 15 deletions.
2 changes: 1 addition & 1 deletion public/js/editor.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-dom-ready', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-primitives', 'wp-rich-text', 'wp-token-list'), 'version' => '96d2d124a7ee6c4c832a');
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-dom-ready', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-primitives', 'wp-rich-text', 'wp-token-list'), 'version' => 'f1da93ef82ff57921557');
4 changes: 2 additions & 2 deletions public/js/editor.js

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions resources/js/block-variations/comment-parent-link/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ export default {
},
placeholder: __('In reply to Comment Author', 'x3p0-ideas')
},
isActive: (blockAttributes) =>
'x3p0/theme' === blockAttributes?.metadata?.bindings?.content?.source
&& 'commentParentLink' === blockAttributes?.metadata?.bindings?.content?.args?.key
isActive: [
'metadata.bindings.content.source',
'metadata.bindings.content.args.key'
]
}
};
7 changes: 4 additions & 3 deletions resources/js/block-variations/pagination-label/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ export default {
placeholder: sprintf(__('Page %1$s / %2$s:', 'x3p0-ideas'), 3, 7),
className: "pagination-label"
},
isActive: (blockAttributes) =>
'x3p0/theme' === blockAttributes?.metadata?.bindings?.content?.source
&& 'paginationLabel' === blockAttributes?.metadata?.bindings?.content?.args?.key
isActive: [
'metadata.bindings.content.source',
'metadata.bindings.content.args.key'
]
}
};
7 changes: 4 additions & 3 deletions resources/js/block-variations/reading-time/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ export default {
placeholder: __('Reading Time', 'x3p0-ideas')
},
example: {},
isActive: (blockAttributes) =>
'x3p0/post' === blockAttributes?.metadata?.bindings?.content?.source
&& 'readingTime' === blockAttributes?.metadata?.bindings?.content?.args?.key
isActive: [
'metadata.bindings.content.source',
'metadata.bindings.content.args.key'
]
}
};
7 changes: 4 additions & 3 deletions resources/js/block-variations/site-copyright/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ export default {
new Date().getFullYear()
)
},
isActive: (blockAttributes) =>
'x3p0/site' === blockAttributes?.metadata?.bindings?.content?.source
&& 'copyright' === blockAttributes?.metadata?.bindings?.content?.args?.key
isActive: [
'metadata.bindings.content.source',
'metadata.bindings.content.args.key'
]
}
};

0 comments on commit 84550a5

Please sign in to comment.