Make WordPress Core

Changeset 60144


Ignore:
Timestamp:
04/08/2025 02:16:45 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.

Reviewed by audrasjb.
Merges [60142] to the 6.8 branch

Props webmandesign, joemcgill, jorbin, poena.
Fixes #63212.

Location:
branches/6.8
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/6.8

  • branches/6.8/src/wp-includes/class-wp-theme.php

    r60037 r60144  
    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.