Skip to content

Plugin: improve bootstrapping #13634

@azaozz

Description

@azaozz

As work on #13569 progresses it would be good to look at the loading/bootstrapping of the Gutenberg plugin.

Currently all add_filter() and add_action() are "sprinkled around" in ~10 different files and executed as the PHP code loads. It would be better to add all hooks to one init/bootstrap function that is (typically) run at plugins_loaded. There are few advantages:

  • That would make it clearer/more structured/easier to see what's running where and when.

  • Would improve interoperability with other plugins. For example: plugins that want to disable Gutenberg (either for debugging or to let users get to Classic Editor) would only need to care about one hook when supporting multiple Gutenberg versions. Other plugins that want to interact only with a specific hook added by Gutenberg can still do that after the bootstrap action runs.

    The "prior art" for this is in core. See https://github.com/WordPress/WordPress/blob/master/wp-includes/default-filters.php.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Gutenberg PluginIssues or PRs related to Gutenberg Plugin management related efforts[Type] EnhancementA suggestion for improvement.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions