Conditional visibility controls for all WordPress blocks.
visibility_preset
post type.__experimentalGetSettings
function with the stable __getSettings
version.enqueue_block_assets
.This release is exactly the same as version 3.1.0, but was required to stay in line with the WordPress.org repo. Two folders were missing when the plugin was synced to the plugin repo. To fix the issue, the version had to be bumped to 3.1.1.
getEntityRecord
(#77).hide_on_restricted_users
variable (#64).blockVisibility.contextualIndicatorClasses
filter to include more variables, which allows for more customization. Example usage below:/**
* Modifies the indicator classes based on active controls. In this
* case, add a class if the block has been hidden on medium screens.
*
* @param {string} classes - The original classes of the indicator.
* @param {Array} activeControls - The active controls.
* @param {object} controls - The controls object.
*
* @returns {string} - The modified classes of the indicator.
*/
function modifyIndicatorClasses( classes, activeControls, controls ) {
if ( activeControls.includes( 'screen-size' ) ) {
const screenSize = controls?.screenSize;
const hiddenOnMedium = screenSize?.hideOnScreenSize?.medium ?? false;
if ( hiddenOnMedium ) {
return classes + ' hidden-on-medium';
}
}
return classes;
}
wp.hooks.addFilter(
'blockVisibility.contextualIndicatorClasses',
'example-plugin/modify-indicator-classes',
modifyIndicatorClasses
);