wp/wp-includes/class-wp-theme.php
changeset 22 8c2e4d02f4ef
parent 21 48c4eec2b7e6
equal deleted inserted replaced
21:48c4eec2b7e6 22:8c2e4d02f4ef
    58 	 * @since 5.3.0 Added the Twenty Twenty theme.
    58 	 * @since 5.3.0 Added the Twenty Twenty theme.
    59 	 * @since 5.6.0 Added the Twenty Twenty-One theme.
    59 	 * @since 5.6.0 Added the Twenty Twenty-One theme.
    60 	 * @since 5.9.0 Added the Twenty Twenty-Two theme.
    60 	 * @since 5.9.0 Added the Twenty Twenty-Two theme.
    61 	 * @since 6.1.0 Added the Twenty Twenty-Three theme.
    61 	 * @since 6.1.0 Added the Twenty Twenty-Three theme.
    62 	 * @since 6.4.0 Added the Twenty Twenty-Four theme.
    62 	 * @since 6.4.0 Added the Twenty Twenty-Four theme.
       
    63 	 * @since 6.7.0 Added the Twenty Twenty-Five theme.
    63 	 * @var string[]
    64 	 * @var string[]
    64 	 */
    65 	 */
    65 	private static $default_themes = array(
    66 	private static $default_themes = array(
    66 		'classic'           => 'WordPress Classic',
    67 		'classic'           => 'WordPress Classic',
    67 		'default'           => 'WordPress Default',
    68 		'default'           => 'WordPress Default',
    77 		'twentytwenty'      => 'Twenty Twenty',
    78 		'twentytwenty'      => 'Twenty Twenty',
    78 		'twentytwentyone'   => 'Twenty Twenty-One',
    79 		'twentytwentyone'   => 'Twenty Twenty-One',
    79 		'twentytwentytwo'   => 'Twenty Twenty-Two',
    80 		'twentytwentytwo'   => 'Twenty Twenty-Two',
    80 		'twentytwentythree' => 'Twenty Twenty-Three',
    81 		'twentytwentythree' => 'Twenty Twenty-Three',
    81 		'twentytwentyfour'  => 'Twenty Twenty-Four',
    82 		'twentytwentyfour'  => 'Twenty Twenty-Four',
       
    83 		'twentytwentyfive'  => 'Twenty Twenty-Five',
    82 	);
    84 	);
    83 
    85 
    84 	/**
    86 	/**
    85 	 * Renamed theme tags.
    87 	 * Renamed theme tags.
    86 	 *
    88 	 *
   238 	/**
   240 	/**
   239 	 * Constructor for WP_Theme.
   241 	 * Constructor for WP_Theme.
   240 	 *
   242 	 *
   241 	 * @since 3.4.0
   243 	 * @since 3.4.0
   242 	 *
   244 	 *
   243 	 * @global array $wp_theme_directories
   245 	 * @global string[] $wp_theme_directories
   244 	 *
   246 	 *
   245 	 * @param string        $theme_dir  Directory of the theme within the theme_root.
   247 	 * @param string        $theme_dir  Directory of the theme within the theme_root.
   246 	 * @param string        $theme_root Theme root.
   248 	 * @param string        $theme_root Theme root.
   247 	 * @param WP_Theme|null $_child If this theme is a parent theme, the child may be passed for validation purposes.
   249 	 * @param WP_Theme|null $_child If this theme is a parent theme, the child may be passed for validation purposes.
   248 	 */
   250 	 */
  1755 				$allowed_themes[ $blog_id ] = $converted;
  1757 				$allowed_themes[ $blog_id ] = $converted;
  1756 			}
  1758 			}
  1757 			// Set the option so we never have to go through this pain again.
  1759 			// Set the option so we never have to go through this pain again.
  1758 			if ( is_admin() && $allowed_themes[ $blog_id ] ) {
  1760 			if ( is_admin() && $allowed_themes[ $blog_id ] ) {
  1759 				if ( $current ) {
  1761 				if ( $current ) {
  1760 					update_option( 'allowedthemes', $allowed_themes[ $blog_id ] );
  1762 					update_option( 'allowedthemes', $allowed_themes[ $blog_id ], false );
  1761 					delete_option( 'allowed_themes' );
  1763 					delete_option( 'allowed_themes' );
  1762 				} else {
  1764 				} else {
  1763 					switch_to_blog( $blog_id );
  1765 					switch_to_blog( $blog_id );
  1764 					update_option( 'allowedthemes', $allowed_themes[ $blog_id ] );
  1766 					update_option( 'allowedthemes', $allowed_themes[ $blog_id ], false );
  1765 					delete_option( 'allowed_themes' );
  1767 					delete_option( 'allowed_themes' );
  1766 					restore_current_blog();
  1768 					restore_current_blog();
  1767 				}
  1769 				}
  1768 			}
  1770 			}
  1769 		}
  1771 		}
  1844 			}
  1846 			}
  1845 			// If in development mode, clear pattern cache.
  1847 			// If in development mode, clear pattern cache.
  1846 			$this->delete_pattern_cache();
  1848 			$this->delete_pattern_cache();
  1847 		}
  1849 		}
  1848 
  1850 
  1849 		$dirpath      = $this->get_stylesheet_directory() . '/patterns/';
  1851 		$dirpath      = $this->get_stylesheet_directory() . '/patterns';
  1850 		$pattern_data = array();
  1852 		$pattern_data = array();
  1851 
  1853 
  1852 		if ( ! file_exists( $dirpath ) ) {
  1854 		if ( ! file_exists( $dirpath ) ) {
  1853 			if ( $can_use_cached ) {
  1855 			if ( $can_use_cached ) {
  1854 				$this->set_pattern_cache( $pattern_data );
  1856 				$this->set_pattern_cache( $pattern_data );
  1855 			}
  1857 			}
  1856 			return $pattern_data;
  1858 			return $pattern_data;
  1857 		}
  1859 		}
  1858 		$files = glob( $dirpath . '*.php' );
  1860 
       
  1861 		$files = (array) self::scandir( $dirpath, 'php', -1 );
       
  1862 
       
  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 
       
  1873 		$dirpath = trailingslashit( $dirpath );
       
  1874 
  1859 		if ( ! $files ) {
  1875 		if ( ! $files ) {
  1860 			if ( $can_use_cached ) {
  1876 			if ( $can_use_cached ) {
  1861 				$this->set_pattern_cache( $pattern_data );
  1877 				$this->set_pattern_cache( $pattern_data );
  1862 			}
  1878 			}
  1863 			return $pattern_data;
  1879 			return $pattern_data;