Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save huubl/5daec72ee086b249f3351be05482bb72 to your computer and use it in GitHub Desktop.
Save huubl/5daec72ee086b249f3351be05482bb72 to your computer and use it in GitHub Desktop.
Disable Links in ACF Block-Edit Method
/*
* 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