Skip to content

Commit 33f1774

Browse files
committed
[N/A] Remove Block automatic pattern registration for wp.org release
1 parent a021f37 commit 33f1774

File tree

1 file changed

+0
-92
lines changed

1 file changed

+0
-92
lines changed

src/classes/BlockRegistration.php

-92
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ public static function init(): void {
5353
// Allow for core block variation de-registration.
5454
self::unregister_block_variations();
5555

56-
// Register block patterns within block folders.
57-
self::register_block_patterns();
58-
5956
// Reset block IDs on a new request.
6057
self::reset_block_ids();
6158

@@ -378,95 +375,6 @@ public static function render_twig_block( string $template, array $block = [], s
378375
Timber::render( $template, $context );
379376
}
380377

381-
/**
382-
* Register Custom Block Patterns
383-
*
384-
* @return void
385-
*/
386-
public static function register_block_patterns(): void {
387-
add_action(
388-
'init',
389-
function () {
390-
$blocks = self::get_all_blocks();
391-
$registry = \WP_Block_Patterns_Registry::get_instance();
392-
$text_domain = wp_get_theme()->get( 'TextDomain' );
393-
394-
$default_headers = [
395-
'title' => 'Title',
396-
'slug' => 'Slug',
397-
'description' => 'Description',
398-
'viewportWidth' => 'Viewport Width',
399-
'inserter' => 'Inserter',
400-
'categories' => 'Categories',
401-
'keywords' => 'Keywords',
402-
'blockTypes' => 'Block Types',
403-
'postTypes' => 'Post Types',
404-
'templateTypes' => 'Template Types',
405-
];
406-
$properties_to_parse = [
407-
'categories',
408-
'keywords',
409-
'blockTypes',
410-
'postTypes',
411-
'templateTypes',
412-
];
413-
414-
foreach ( $blocks as $block ) {
415-
$patterns = glob( $block['path'] . '/patterns/*.php' );
416-
417-
if ( empty( $patterns ) ) {
418-
continue;
419-
}
420-
421-
foreach ( $patterns as $pattern_path ) {
422-
$pattern = get_file_data( $pattern_path, $default_headers );
423-
424-
if ( $registry->is_registered( $pattern['slug'] ) ) {
425-
continue;
426-
}
427-
428-
foreach ( $properties_to_parse as $property ) {
429-
if ( ! empty( $pattern[ $property ] ) ) {
430-
$pattern[ $property ] = array_filter( wp_parse_list( (string) $pattern[ $property ] ) );
431-
} else {
432-
unset( $pattern[ $property ] );
433-
}
434-
}
435-
436-
// Parse properties of type int.
437-
$property = 'viewportWidth';
438-
if ( ! empty( $pattern[ $property ] ) ) {
439-
$pattern[ $property ] = (int) $pattern[ $property ];
440-
} else {
441-
unset( $pattern[ $property ] );
442-
}
443-
444-
// Parse properties of type bool.
445-
$property = 'inserter';
446-
if ( ! empty( $pattern[ $property ] ) ) {
447-
$pattern[ $property ] = in_array(
448-
strtolower( $pattern[ $property ] ),
449-
[ 'yes', 'true' ],
450-
true
451-
);
452-
} else {
453-
unset( $pattern[ $property ] );
454-
}
455-
456-
$pattern['filePath'] = $pattern_path;
457-
$pattern['title'] = translate_with_gettext_context( $pattern['title'], 'Pattern title', $text_domain );
458-
if ( ! empty( $pattern['description'] ) ) {
459-
$pattern['description'] = translate_with_gettext_context( $pattern['description'], 'Pattern description', $text_domain );
460-
}
461-
462-
register_block_pattern( $pattern['slug'], $pattern );
463-
}
464-
}
465-
},
466-
11
467-
);
468-
}
469-
470378
/**
471379
* Generate a unique block ID for each ACF block
472380
*

0 commit comments

Comments
 (0)