Make WordPress Core

Changeset 59872


Ignore:
Timestamp:
02/26/2025 04:59:42 PM (2 weeks ago)
Author:
joemcgill
Message:

Themes: Allow pattern files to be organized into sub-folders.

This allows theme pattern files located in a theme's /patterns/ directory to be organized into sub-folders and will automatically be located by WP_Theme::get_block_patterns() method.

Props juanfra, joemcgill, poena, flixos90.
Fixes #62378.

File:
1 edited

Legend:

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

    r59861 r59872  
    18491849        }
    18501850
    1851         $dirpath      = $this->get_stylesheet_directory() . '/patterns/';
     1851        $dirpath      = $this->get_stylesheet_directory() . '/patterns';
    18521852        $pattern_data = array();
    18531853
     
    18581858            return $pattern_data;
    18591859        }
    1860         $files = glob( $dirpath . '*.php' );
     1860
     1861        $files = (array) self::scandir( $dirpath, 'php', -1 );
     1862
     1863        $dirpath = trailingslashit( $dirpath );
     1864
    18611865        if ( ! $files ) {
    18621866            if ( $can_use_cached ) {
Note: See TracChangeset for help on using the changeset viewer.