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

Extend Block Metadata PHP Cache to Third-Party Blocks #7303

Closed
wants to merge 58 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
5f5fbd2
add WP_Block_Metadata_Registry, allow blocks to bypass block.json par…
mreishus Sep 5, 2024
8a28294
update
mreishus Sep 5, 2024
8ca134d
add metadata_source
mreishus Sep 5, 2024
270d784
formatting fixes
mreishus Sep 6, 2024
9376059
add trailing comma
mreishus Sep 6, 2024
d503724
horizontal align
mreishus Sep 6, 2024
c5b81f5
remove namespace
mreishus Sep 13, 2024
a914dee
remove third parameter
mreishus Sep 13, 2024
a25c643
make static
mreishus Sep 13, 2024
bb6fec3
allow metadata source to be passed to register_block_type
mreishus Sep 13, 2024
c7cb99a
fix alignment
mreishus Sep 13, 2024
14b1c56
undo everything
mreishus Sep 23, 2024
f75c4fd
new implementation
mreishus Sep 23, 2024
12c01b8
add tests
mreishus Sep 23, 2024
ae81aa6
align equals
mreishus Sep 23, 2024
9779e78
fix broken test
mreishus Sep 24, 2024
15c51a6
move the collection and block identification logic to the WP_Block_Me…
mreishus Sep 24, 2024
2c3630b
lint fix
mreishus Sep 24, 2024
1fa5877
guard against incorrect paths
mreishus Sep 24, 2024
a4c1455
indent fix
mreishus Sep 24, 2024
26c6b0c
lint fix
mreishus Sep 24, 2024
191c553
Call into WP_Block_Metadata_Registry:: looking for metadata only once…
mreishus Sep 24, 2024
43915a8
add $last_matched_collection
mreishus Sep 24, 2024
abbf5d5
align equals
mreishus Sep 24, 2024
8d7badc
update comments
mreishus Sep 24, 2024
0ca6c93
variable rename
mreishus Sep 25, 2024
70431b2
update comment
mreishus Sep 25, 2024
504e09c
remove private constructor
mreishus Sep 25, 2024
db5dee2
add _doing_it_wrong calls
mreishus Sep 25, 2024
61acb57
fix broken tests
mreishus Sep 25, 2024
4cd8fcc
Remove $identifier_callback option
mreishus Sep 25, 2024
3b13d45
comment updates
mreishus Sep 26, 2024
396e6c9
make default_identifier_callback private
mreishus Sep 26, 2024
78a46fb
standardize _doing_it_wrong messages
mreishus Sep 26, 2024
d948dde
reorganize top of register_block_type_from_metadata
mreishus Sep 26, 2024
15353f4
fix one more since tag
mreishus Sep 26, 2024
a3b73f3
update comment
mreishus Sep 26, 2024
3a5ad69
fix elseif
mreishus Sep 26, 2024
3b70192
default_identifier_callback: Use str_ends_with and return early if empty
mreishus Sep 26, 2024
166ed80
Update src/wp-includes/blocks.php
mreishus Sep 26, 2024
63772f1
Add Tests_Blocks_RegisterBlockTypeFromMetadataWithRegistry
mreishus Sep 26, 2024
b069b60
retab
mreishus Sep 26, 2024
2e44638
add trailing commas
mreishus Sep 26, 2024
779a2e8
align arrows and equals
mreishus Sep 26, 2024
a9d6eb9
let core blocks skip the file_exists check
mreishus Sep 27, 2024
a257e6f
minor change to force test rerun
mreishus Sep 27, 2024
3e4d5b6
Revert "minor change to force test rerun"
mreishus Sep 27, 2024
3a55080
register_collection: Use static variables to reduce calls to wp_norma…
mreishus Sep 28, 2024
6584762
extract to get_include_path and get_plugin_dir functions
mreishus Sep 30, 2024
f2e31d7
allow registering for themes
mreishus Sep 30, 2024
2d7533b
stop someone from registering the entire themes directory
mreishus Sep 30, 2024
498bbba
get_include_path -> get_wpinc_dir
mreishus Sep 30, 2024
c23cf0a
Revert "stop someone from registering the entire themes directory"
mreishus Sep 30, 2024
7fd96b4
Revert "allow registering for themes"
mreishus Sep 30, 2024
9aa134d
Merge branch 'trunk' into add/metadata-register
felixarntz Sep 30, 2024
a323758
Rename wpinc_path to wpinc_dir and clarify docs.
felixarntz Sep 30, 2024
6467b31
Use isset instead of empty.
felixarntz Sep 30, 2024
31809da
Make conditional logic more intuitive.
felixarntz Sep 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix one more since tag
  • Loading branch information
mreishus committed Sep 30, 2024
commit 15353f42c3fd84f6f0f47556dfce51624611bb77
2 changes: 1 addition & 1 deletion src/wp-includes/blocks/index.php
Original file line number Diff line number Diff line change
@@ -168,7 +168,7 @@ function register_core_block_types_from_metadata() {
* ensuring that the core block metadata is registered before the regular
* block initialization that happens at priority 10.
*
* @since 6.X.0
* @since 6.7.0
*/
function wp_register_core_block_metadata_collection() {
wp_register_block_metadata_collection(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So my hope for the future is the following to be possible in Gutenberg:

function gutenberg_register_core_block_metadata_collection() {
	wp_register_block_metadata_collection(
		BLOCKS_PATH,
		GUTENBERG_BLOCKS_PATH . 'blocks-json.php'
	);
}
remove_action( 'init', 'wp_register_core_block_metadata_collection' );
add_action( 'init', 'gutenberg_register_core_block_metadata_collection', 9 );

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right! I think technically that already should be possible once this PR lands? 🤔