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

Gutenberg "opt in" mode #61543

Open
mikeybinns opened this issue May 9, 2024 · 0 comments
Open

Gutenberg "opt in" mode #61543

mikeybinns opened this issue May 9, 2024 · 0 comments
Labels
[Type] Enhancement A suggestion for improvement.

Comments

@mikeybinns
Copy link
Contributor

mikeybinns commented May 9, 2024

What problem does this address?

Currently, when you install the gutenberg plugin, you get (almost) everything. Some things are disabled, but this tends to be the really experimental stuff which is more likely to be broken. It would be good if you could specifically opt into the features you want to add, rather than being required to load everything at once.

What is your proposed solution?

My solution would be to add a mode called "opt in" mode. When enabled, everything added by gutenberg is not loaded by default, including new blocks, altered blocks and editor changes. Then the user can "opt in" either via a filter for a code solution or a settings page for a GUI solution.

This way, if I only wanted to add a specific block, I could opt in without needing to allow everything at once.

There also could be pre-defined stability levels for things added via gutenberg. I'm imagining each level would be an array of features which would be fed into the code filter previously mentioned, which could also be edited by a user for "Everything this level except blah" use cases.

  • experimental: stuff where you're almost guaranteed to have issues, what is currently behind experimental checkboxes
  • unstable: Things still in development, but are relatively stable
  • testing: Things that are feature complete and in final /RC testing
  • stable: Things ready to be merged into core, which are just waiting for a WP release
  • core: Things in Gutenberg which are already a part of core, and haven't been changed since.
    • This is not really so useful for if using opt in mode, as core blocks would still be available, however, this could be used to migrate the 'non-opt-in' mode to the same filter system as opt in, just with a pre-defined array with every value already there. If this is how it worked, it would require each new feature to be added to the array, guaranteeing that opt in would work for every feature as expected (If it's not in the array, it wouldn't load the feature).

Potential code example:

// functions.php
$levels = get_gutenberg_stability_levels();
/*
$levels === array(
  'experimental' => array(
    'feature1' => true,
    'core/new-block' => true,
  ),
  'stable' => array(
    'feature2' => true,
    'feature3' => true,
  ),
  'core' => array(
    'core/gallery' => true,
  ),
);
*/
define( 'GUTENBERG_OPT_IN_MODE', true ); // Enable opt in mode, use GUI
// OR
define( 'GUTENBERG_OPT_IN_MODE', array( ...$levels['stable'], ...$levels['core'], 'core/new-block' => true ) ); // Enable opt in mode, use values provided, disable GUI.

Things worthy of note:

  • I have had a brief look at how gutenberg loads things, and I'm not expecting this feature to be something that is easily added. Currently all core blocks are disabled and replaced by gutenberg's build in one fell swoop, where as this would require individual block deregistering/re-registration.
  • I also expect this would add a bit of maintenance time on each new feature added, and again as those features become more stable.
@mikeybinns mikeybinns added the [Type] Enhancement A suggestion for improvement. label May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

1 participant