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

Patterns: provide a way to opt-out of Gutenberg patterns and core patterns updates #31924

Closed

Conversation

ramonjd
Copy link
Member

@ramonjd ramonjd commented May 18, 2021

Description

This PR is a proof of concept (POC) to test a feature proposal.

This PR provides filters to opt out of:

  1. removing core patterns, in case Gutenberg users want to use Core patterns
  2. adding Gutenberg patterns
  3. loading core patterns from remote source

See the issue for more context: #31922

How has this been tested?

By default all Gutenberg patterns should be available in the inserter.

To test the filters add the following block to the end of lib/init.php

/* TEST CODE START - DELETE ME */

function should_register_gutenberg_patterns() {
	return false;
}
add_filter( 'register_gutenberg_patterns', 'should_register_gutenberg_patterns' );

function should_remove_core_patterns() {
	return false;
}
add_filter( 'remove_core_patterns', 'should_remove_core_patterns' );

function should_load_remote_patterns() {
	return false;
}
add_filter( 'load_remote_patterns', 'should_load_remote_patterns' );

/* TEST CODE END - DELETE ME */

Returning false from should_register_gutenberg_patterns() should remove Gutenberg patterns.

With Gutenberg patterns Without
Screen Shot 2021-05-18 at 2 46 48 pm Screen Shot 2021-05-18 at 2 47 32 pm

Returning false from should_update_core_patterns() should not replace/update core patterns

With updated core patterns Without updated core patterns
Screen Shot 2021-05-18 at 2 49 31 pm Screen Shot 2021-05-18 at 2 49 09 pm

Types of changes

Non-breaking additional functionality.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR (please manually search all *.native.js files for terms that need renaming or removal).

… to patterns directory to fetch and then register patterns.

This commit provides filters to opt out of:
1. removing core patterns, in case Gutenberg users want to use Core patterns
2. adding Gutenberg patterns
3. loading core patterns from remote source
@ramonjd
Copy link
Member Author

ramonjd commented Jul 21, 2021

Closing this for now as it's a bit stale and there might be more profitable ways of doing this independent of Gutenberg now that 5.8 is released.

@ramonjd ramonjd closed this Jul 21, 2021
@ramonjd ramonjd deleted the try/opt-out-of-gutenberg-patterns branch July 21, 2021 00:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant