Skip to content

Commit 6511cc0

Browse files
committed
Themes: Allow files in a block theme's 'patterns' directory to be filterable.
Since [59872] all PHP files in the 'patterns' directory or subdirectories are auto registered. Adding a filter prior to autoregistration allows theme developers to modify the list of files before the auto registration. Props webmandesign, joemcgill, jorbin, poena. Fixes #63212. git-svn-id: https://develop.svn.wordpress.org/trunk@60142 602fd350-edb4-49c9-b593-d223f7449a82
1 parent bb55de7 commit 6511cc0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/wp-includes/class-wp-theme.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,6 +1860,16 @@ public function get_block_patterns() {
18601860

18611861
$files = (array) self::scandir( $dirpath, 'php', -1 );
18621862

1863+
/**
1864+
* Filters list of block pattern files for a theme.
1865+
*
1866+
* @since 6.8.0
1867+
*
1868+
* @param array $files Array of theme files found within `patterns` directory.
1869+
* @param string $dirpath Path of theme `patterns` directory being scanned.
1870+
*/
1871+
$files = apply_filters( 'theme_block_pattern_files', $files, $dirpath );
1872+
18631873
$dirpath = trailingslashit( $dirpath );
18641874

18651875
if ( ! $files ) {

0 commit comments

Comments
 (0)