-
-
Save huubl/5daec72ee086b249f3351be05482bb72 to your computer and use it in GitHub Desktop.
Disable Links in ACF Block-Edit Method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Wrap all ACF Blocks in Disabled block to disable all links in edit view | |
*/ | |
const { createHigherOrderComponent } = wp.compose; | |
const { Fragment } = wp.element; | |
import { Disabled } from '@wordpress/components'; | |
const withDisabledCompontent = createHigherOrderComponent( ( BlockEdit ) => { | |
return ( props ) => { | |
// only wrap block when it's a acf block in preview mode | |
if ( | |
! props.name.startsWith('acf/') | |
|| 'preview' != props.attributes.mode | |
) { | |
return <BlockEdit { ...props } />; | |
}; | |
return ( | |
<Fragment> | |
<Disabled> | |
<BlockEdit { ...props } /> | |
</Disabled> | |
</Fragment> | |
); | |
}; | |
}, "withInspectorControl" ); | |
wp.hooks.addFilter( 'editor.BlockEdit', 'derweili/disabled-acf-blocks', withDisabledCompontent ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment