Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expanded instructions for disabling Block Directory #24830

Closed
MarcinKilarski opened this issue Aug 26, 2020 · 2 comments
Closed

Expanded instructions for disabling Block Directory #24830

MarcinKilarski opened this issue Aug 26, 2020 · 2 comments
Labels
[Type] Developer Documentation Documentation for developers

Comments

@MarcinKilarski
Copy link

Could we add to instructions both examples of how to disable the Block Directory from a plugin and a theme? Otherwise, people might not know that they should use a different hook than 'plugins_loaded' when disabling the Block Directory from a theme. Thank you.

From a plugin:
/**

  • Disable Block Directory
    */
    add_action('plugins_loaded', 'myplugin_disable_block_directory');
    function myplugin_disable_block_directory()
    {
    remove_action( 'enqueue_block_editor_assets', 'wp_enqueue_editor_block_directory_assets' );
    remove_action( 'enqueue_block_editor_assets', 'gutenberg_enqueue_block_editor_assets_block_directory' );
    };

From a theme:
/**

  • Disable Block Directory
    */
    add_action('admin_init', 'mytheme_disable_block_directory');
    function mytheme_disable_block_directory()
    {
    remove_action( 'enqueue_block_editor_assets', 'wp_enqueue_editor_block_directory_assets' );
    remove_action( 'enqueue_block_editor_assets', 'gutenberg_enqueue_block_editor_assets_block_directory' );
    };
@Soean Soean added the [Type] Developer Documentation Documentation for developers label Aug 26, 2020
@JustinyAhin
Copy link
Member

Hi @MarcinKilarski
Thanks for opening the issue.

There is already some documentation about how to disable the block directory through plugin here https://developer.wordpress.org/block-editor/developers/filters/editor-filters/#block-directory.

It has been added in this PR #24357.

IMO, it makes more sense to disable this feature in a plugin (MU Plugin) rather than directly in the theme.

@JustinyAhin
Copy link
Member

I am going to close this issue.
Feel free to open a new one if needed :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Developer Documentation Documentation for developers
Projects
None yet
Development

No branches or pull requests

3 participants