-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Call variation through callback so it's only loaded when needed - in support of trac 59969 #56952
Merged
spacedmonkey
merged 14 commits into
WordPress:trunk
from
kt-12:enhancement/block-variation-jit-approach
Jan 16, 2024
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
8e0718d
call variation through callback so it's only loaded when needed.
kt-12 e57d8ae
move gutenberg_add_hooked_blocks from 6.4 to 6.5
kt-12 4e9f747
cs fixes
kt-12 d4d12ea
fix version number
kt-12 665e087
Merge branch 'trunk' into enhancement/block-variation-jit-approach
kt-12 06df7be
revert some code
kt-12 63f8744
adapting to variation_calback
kt-12 1ed9873
B/C for plugin
kt-12 e29e6bd
cs fixes
kt-12 ca658e2
cs fixes
kt-12 7e7edd3
cs fixes
kt-12 87a5982
shims to support block variation changes for WP < 6.5
kt-12 6088464
Merge branch 'trunk' into enhancement/block-variation-jit-approach
kt-12 69ebf38
EOL for PHPCS
kt-12 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
/** | ||
* Temporary compatibility shims for block APIs present in Gutenberg. | ||
* | ||
* @package gutenberg | ||
*/ | ||
|
||
/** | ||
* Shim for the `variation_callback` block type argument. | ||
* | ||
* @param array $args The block type arguments. | ||
* @return array The updated block type arguments. | ||
*/ | ||
function gutenberg_register_block_type_args_shim( $args ) { | ||
if ( isset( $args['variation_callback'] ) && is_callable( $args['variation_callback'] ) ) { | ||
$args['variations'] = call_user_func( $args['variation_callback'] ); | ||
unset( $args['variation_callback'] ); | ||
} | ||
return $args; | ||
} | ||
|
||
if ( ! method_exists( 'WP_Block_Type', 'get_variations' ) ) { | ||
add_filter( 'register_block_type_args', 'gutenberg_register_block_type_args_shim' ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kt-12, I appreciate your efforts with the ignore list. However, these functions weren't part of the initial setup and don't pose any backward compatibility issues if we stick to the naming conventions enforced by the sniff.
For example, they could be renamed to
block_core_template_part_build_area_variations()
andblock_core_post_terms_build_variations()
respectively. Could you please rename them?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the follow-up #58538.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The names I suggested for these functions were not exactly correct, but the idea was to adhere to the coding standard. Thanks for fixing it, @Mamaduka.
I have approved your PR.