Make WordPress Core

Changeset 60142


Ignore:
Timestamp:
04/08/2025 01:53:58 PM (6 weeks ago)
Author:
joemcgill
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-theme.php

    r60037 r60142  
    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
Note: See TracChangeset for help on using the changeset viewer.