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. Reviewed by audrasjb. Merges [60142] to the 6.8 branch Props webmandesign, joemcgill, jorbin, poena. Fixes #63212. Built from https://develop.svn.wordpress.org/branches/6.8@60144 git-svn-id: http://core.svn.wordpress.org/branches/6.8@59480 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -1860,6 +1860,16 @@ final class WP_Theme implements ArrayAccess {
|
||||
|
||||
$files = (array) self::scandir( $dirpath, 'php', -1 );
|
||||
|
||||
/**
|
||||
* Filters list of block pattern files for a theme.
|
||||
*
|
||||
* @since 6.8.0
|
||||
*
|
||||
* @param array $files Array of theme files found within `patterns` directory.
|
||||
* @param string $dirpath Path of theme `patterns` directory being scanned.
|
||||
*/
|
||||
$files = apply_filters( 'theme_block_pattern_files', $files, $dirpath );
|
||||
|
||||
$dirpath = trailingslashit( $dirpath );
|
||||
|
||||
if ( ! $files ) {
|
||||
|
||||
Reference in New Issue
Block a user