How to use the @wordpress/blocks.unregisterBlockType function in @wordpress/blocks

To help you get started, we’ve selected a few @wordpress/blocks examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github WordPress / gutenberg / packages / edit-post / src / index.native.js View on Github external
export function initializeEditor() {
	// register and setup blocks
	registerCoreBlocks();

	// disable Code and More blocks for the release
	// eslint-disable-next-line no-undef
	if ( typeof __DEV__ === 'undefined' || ! __DEV__ ) {
		unregisterBlockType( 'core/code' );
		unregisterBlockType( 'core/more' );
	}
}
github ampproject / amp-wp / assets / src / stories-editor / index.js View on Github external
domReady( () => {
	// Ensure that the default block is page when no block is selected.
	setDefaultBlockName( 'amp/amp-story-page' );

	// Remove all blocks that aren't whitelisted.
	const disallowedBlockTypes = getBlockTypes().filter( ( { name } ) => ! ALLOWED_BLOCKS.includes( name ) );

	for ( const blockType of disallowedBlockTypes ) {
		unregisterBlockType( blockType.name );
	}

	const allBlocks = getBlocksByClientId( getClientIdsWithDescendants() );

	// Set initially shown page.
	const firstPage = allBlocks.find( ( { name } ) => name === 'amp/amp-story-page' );
	setCurrentPage( firstPage ? firstPage.clientId : undefined );

	for ( const block of allBlocks ) {
		// Load all needed fonts.
		if ( block.attributes.ampFontFamily ) {
			maybeEnqueueFontStyle( block.attributes.ampFontFamily );
		}
		maybeRemoveDeprecatedSetting( block );
	}
github WordPress / gutenberg / packages / edit-post / src / index.native.js View on Github external
export function initializeEditor() {
	// register and setup blocks
	registerCoreBlocks();

	// disable Code and More blocks for the release
	// eslint-disable-next-line no-undef
	if ( typeof __DEV__ === 'undefined' || ! __DEV__ ) {
		unregisterBlockType( 'core/code' );
		unregisterBlockType( 'core/more' );
	}
}
github Automattic / wp-calypso / packages / jetpack-blocks / src / utils / refresh-registrations.js View on Github external
}
					} );
				}
			} else if ( ! available && registered ) {
				if ( childBlocks ) {
					childBlocks.forEach( ( { name: childName } ) => {
						const childBlock = getBlockType( `jetpack/${ childName }` );
						const otherParents = without( childBlock.parent, blockName );

						// Are any of the other parents currently registered?
						if ( ! otherParents.some( getBlockType ) ) {
							unregisterBlockType( `jetpack/${ childName }` );
						}
					} );
				}
				unregisterBlockType( blockName );
			}
		}
	} );
}
github kadamwhite / wp-block-hmr-demo / src / index.js View on Github external
	unregister: ( { name } ) => unregisterBlockType( name ),
	before: storeSelectedBlock,
github godaddy-wordpress / coblocks / src / sidebars / block-manager / components / modal.js View on Github external
map( optionSettings, ( visible, block ) => {
						if ( visible && ! block.includes( 'mainCategory-' ) && ! blockNames[ block ] ) {
							unregisterBlockType( block );
						}
					} );
				}
github WordPress / gutenberg / packages / editor / src / components / provider / index.js View on Github external
this.props.downloadableBlocksToUninstall.forEach( ( blockType ) => {
				this.props.uninstallBlock( blockType, noop, () => {
					this.props.createWarningNotice(
						__( 'Block previews can\'t uninstall.' ), {
							id: UNINSTALL_ERROR_NOTICE_ID,
						} );
				} );
				unregisterBlockType( blockType.name );
			} );
		}
github godaddy-wordpress / coblocks / src / sidebars / block-manager / components / options / disable-blocks.js View on Github external
return;
		}

		if ( settingsState[ key ] ) {
			settingsState[ key ] = ! settingsState[ key ];
		} else {
			settingsState[ key ] = true;
		}

		//disable selected block
		if ( settingsState[ key ] ) {
			//return if toggled and already enabled
			if ( all && ! toggle ) {
				settingsState[ key ] = false;
			} else {
				unregisterBlockType( key );
			}
		} else {
			//return if toggled and already disabled
			if ( all && toggle ) {
				settingsState[ key ] = true;
			} else {
				{ map( this.props.allBlocks[ category ].blocks, ( block ) => {
					if ( block.name === key ) {
						registerBlockType( key, block );

						//change toggle off when block enabled
						if ( settingsState[ 'mainCategory-' + category ] ) {
							settingsState[ 'mainCategory-' + category ] = false;
						}
					}
				} ); }
github Automattic / wp-calypso / client / gutenberg / editor / init.js View on Github external
	WPCOM_UNSUPPORTED_CORE_BLOCKS.forEach( blockName => unregisterBlockType( blockName ) );