Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
2a31ff4
pass $args earlier
aristath Oct 20, 2022
7daab55
Add empty string as default value for $file_or_folder
aristath Oct 20, 2022
51f6083
$metadata is an array
aristath Oct 20, 2022
ef39e83
fix for translations conditions
aristath Oct 20, 2022
392b8ae
Return false if name is not defined
aristath Oct 20, 2022
b236265
removed default value
aristath Oct 20, 2022
92ac48a
simplify condition
aristath Oct 20, 2022
c5edb5b
fix for core blocks caches
aristath Oct 20, 2022
b5ecea7
move render_callback calculations before parsing the $args
aristath Oct 20, 2022
000ef58
more WIP
aristath Oct 20, 2022
35e526e
more render callback a bit earlier
aristath Oct 20, 2022
14cad2c
tweak the check
aristath Oct 20, 2022
6d426b5
minor tweak
aristath Oct 20, 2022
d2f4977
Add PHPUnit tests & fix discovered bug
aristath Mar 2, 2023
39c2c0d
Update src/wp-includes/blocks.php
aristath Mar 2, 2023
536666e
docs fix (copy/paste error)
aristath Mar 2, 2023
9400e13
Merge remote-tracking branch 'aristath/fix/block-registration' into f…
aristath Mar 2, 2023
45d3229
Update tests/phpunit/tests/blocks/register.php
aristath Mar 2, 2023
910df65
Update tests/phpunit/tests/blocks/register.php
aristath Mar 2, 2023
fe37d14
copy/paste
aristath Mar 2, 2023
b0913e1
wording improvement
aristath Mar 2, 2023
7df228e
Add messages to tests
aristath Mar 2, 2023
927a6a4
typo fix
aristath Mar 3, 2023
8e3a1e7
Merge branch 'trunk' into fix/block-registration
aristath Jul 4, 2023
d5dfea3
fix failing test from merge conflict
aristath Jul 4, 2023
a45eac6
Merge branch 'trunk' into fix/block-registration
aristath Jul 5, 2023
d1d47bc
Add more tests
aristath Jul 6, 2023
eccbf70
Merge branch 'trunk' into fix/block-registration
aristath Jul 6, 2023
fd2f493
Merge branch 'trunk' into fix/block-registration
aristath Jul 10, 2023
614a522
Update tests/phpunit/tests/blocks/register.php
aristath Jul 10, 2023
0ffe03a
Merge remote-tracking branch 'aristath/fix/block-registration' into f…
aristath Jul 10, 2023
69c8372
Update tests/phpunit/tests/blocks/register.php
aristath Jul 10, 2023
75e814b
Merge remote-tracking branch 'aristath/fix/block-registration' into f…
aristath Jul 10, 2023
3b5fb15
Move dataProvider function
aristath Jul 10, 2023
4a6136b
Update tests/phpunit/tests/blocks/register.php
aristath Jul 10, 2023
9174edd
Merge branch 'trunk' into fix/block-registration
aristath Jul 11, 2023
2c32ffa
Merge branch 'trunk' into fix/block-registration
aristath Jul 18, 2023
47586a9
Don't check if file exists for core blocks
aristath Jul 18, 2023
280992d
resolve rebase conflicts
aristath Jul 19, 2023
a898362
Update src/wp-includes/blocks.php
aristath Jul 19, 2023
551f3f4
Merge branch 'trunk' into fix/block-registration
aristath Jul 19, 2023
6ab5c1f
Merge branch 'trunk' into fix/block-registration
aristath Jul 25, 2023
50f0346
Merge branch 'trunk' into fix/block-registration
aristath Sep 13, 2023
3f96fd8
Merge branch 'trunk' into fix/block-registration
spacedmonkey Sep 26, 2023
f2feb9f
Merge branch 'trunk' into fix/block-registration
aristath Oct 17, 2023
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 for translations conditions
  • Loading branch information
aristath committed Mar 2, 2023
commit ef39e83206f705d9effa26a611af2961c1335aa9
54 changes: 26 additions & 28 deletions src/wp-includes/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -370,34 +370,32 @@ function register_block_type_from_metadata( $file_or_folder = '', $args = array(
}
}

$settings = array();
if ( $metadata_file_exists ) {
$property_mappings = array(
'apiVersion' => 'api_version',
'title' => 'title',
'category' => 'category',
'parent' => 'parent',
'ancestor' => 'ancestor',
'icon' => 'icon',
'description' => 'description',
'keywords' => 'keywords',
'attributes' => 'attributes',
'providesContext' => 'provides_context',
'usesContext' => 'uses_context',
'supports' => 'supports',
'styles' => 'styles',
'variations' => 'variations',
'example' => 'example',
);
$textdomain = ! empty( $metadata['textdomain'] ) ? $metadata['textdomain'] : null;
$i18n_schema = get_block_metadata_i18n_schema();

foreach ( $property_mappings as $key => $mapped_key ) {
if ( isset( $metadata[ $key ] ) ) {
$settings[ $mapped_key ] = $metadata[ $key ];
if ( $textdomain && isset( $i18n_schema->$key ) ) {
$settings[ $mapped_key ] = translate_settings_using_i18n_schema( $i18n_schema->$key, $settings[ $key ], $textdomain );
}
$settings = array();
$property_mappings = array(
'apiVersion' => 'api_version',
'title' => 'title',
'category' => 'category',
'parent' => 'parent',
'ancestor' => 'ancestor',
'icon' => 'icon',
'description' => 'description',
'keywords' => 'keywords',
'attributes' => 'attributes',
'providesContext' => 'provides_context',
'usesContext' => 'uses_context',
'supports' => 'supports',
'styles' => 'styles',
'variations' => 'variations',
'example' => 'example',
);
$textdomain = ! empty( $metadata['textdomain'] ) ? $metadata['textdomain'] : null;
$i18n_schema = get_block_metadata_i18n_schema();

foreach ( $property_mappings as $key => $mapped_key ) {
if ( isset( $metadata[ $key ] ) ) {
$settings[ $mapped_key ] = $metadata[ $key ];
if ( $metadata_file_exists && $textdomain && isset( $i18n_schema->$key ) ) {
$settings[ $mapped_key ] = translate_settings_using_i18n_schema( $i18n_schema->$key, $settings[ $key ], $textdomain );
}
}
}
Expand Down