From 37000cde6f16baf8466dc9fb10fd4cdc56e3945a Mon Sep 17 00:00:00 2001 From: Joe McGill Date: Tue, 8 Apr 2025 14:18:28 +0000 Subject: [PATCH] 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 --- wp-includes/class-wp-theme.php | 10 ++++++++++ wp-includes/version.php | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/wp-includes/class-wp-theme.php b/wp-includes/class-wp-theme.php index ee74099766..49020d5e96 100644 --- a/wp-includes/class-wp-theme.php +++ b/wp-includes/class-wp-theme.php @@ -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 ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index 070731d23b..7cd7ce3a4e 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.8-RC2-60143'; +$wp_version = '6.8-RC2-60144'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.