get_block_theme_folders() – For backward compatibility reasons, block themes might be using block-templates or block-template-parts, this function ensures we fallback to these folders properly.

You appear to be a bot. Output may be restricted

Description

For backward compatibility reasons, block themes might be using block-templates or block-template-parts, this function ensures we fallback to these folders properly.

Usage

$string[] = get_block_theme_folders( $theme_stylesheet );

Parameters

$theme_stylesheet
( string ) optional – The stylesheet. Default is to leverage the main theme root.
$wp_template
( string ) optional – Theme-relative directory name for block templates.
$wp_template_part
( string ) optional – Theme-relative directory name for block template parts. }

Returns

string[] { Folder names used by block themes.

Source

File name: wordpress/wp-includes/block-template-utils.php
Lines:

1 to 17 of 17
function get_block_theme_folders( $theme_stylesheet = null ) {
  $theme_name = null === $theme_stylesheet ? get_stylesheet() : $theme_stylesheet;
  $root_dir   = get_theme_root( $theme_name );
  $theme_dir  = "$root_dir/$theme_name";

  if ( file_exists( $theme_dir . '/block-templates' ) || file_exists( $theme_dir . '/block-template-parts' ) ) {
    return array(
      'wp_template'      => 'block-templates',
      'wp_template_part' => 'block-template-parts',
    );
  }

  return array(
    'wp_template'      => 'templates',
    'wp_template_part' => 'parts',
  );
}
 

 View on GitHub View on Trac