How to use the @wordpress/plugins.unregisterPlugin function in @wordpress/plugins

To help you get started, we’ve selected a few @wordpress/plugins 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 Automattic / wp-calypso / packages / jetpack-blocks / src / utils / refresh-registrations.js View on Github external
extensions.forEach( extension => {
		const { childBlocks, name, settings } = extension;
		const { available } = getJetpackExtensionAvailability( name );

		if ( has( settings, [ 'render' ] ) ) {
			// If the extension has a `render` method, it's not a block but a plugin
			const pluginName = `jetpack-${ name }`;
			const registered = getPlugin( pluginName );

			if ( available && ! registered ) {
				registerPlugin( pluginName, settings );
			} else if ( ! available && registered ) {
				unregisterPlugin( pluginName );
			}
		} else {
			const blockName = `jetpack/${ name }`;
			const registered = getBlockType( blockName );

			if ( available && ! registered ) {
				registerBlockType( blockName, settings );
				if ( childBlocks ) {
					childBlocks.forEach( ( { name: childName, settings: childSettings } ) => {
						// This might have been registered by another parent before
						if ( ! getBlockType( `jetpack/${ childName }` ) ) {
							registerBlockType( `jetpack/${ childName }`, childSettings );
						}
					} );
				}
			} else if ( ! available && registered ) {
github DefinitelyTyped / DefinitelyTyped / types / wordpress__plugins / wordpress__plugins-tests.tsx View on Github external
import * as plugins from '@wordpress/plugins';

plugins.registerPlugin('my-plugin', {
    icon: 'welcome-learn-more',
    render: () =&gt; <h1>Hello World</h1>,
});

plugins.getPlugins();

plugins.getPlugin('my-plugin');

plugins.unregisterPlugin('my-plugin');

interface OwnProps {
    foobar: number;
}

interface ContextProps {
    iconName: string;
}

type Props = OwnProps &amp; ContextProps;

const Foo = ({ iconName, foobar }: Props) =&gt; (
    <ul>
        <li>{iconName}</li>
        <li>{foobar}</li>
        </ul>
github kadamwhite / wp-block-hmr-demo / src / index.js View on Github external
	unregister: ( { name } ) => unregisterPlugin( name ),
} );
github zgordon / advanced-gutenberg-course / src / index.js View on Github external
	unregister: ({ name }) => unregisterPlugin(name)
});