| @@ -4,17 +4,48 @@ | ||
| 4 | 4 | * |
| 5 | 5 | * @package twentig |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | -// Exit if accessed directly. | |
| 9 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 10 | - exit; | |
| 11 | -} | |
| 8 | +defined( 'ABSPATH' ) || exit; | |
| 12 | 9 | |
| 10 | +require TWENTIG_PATH . 'inc/dashboard/class-twentig-dashboard.php'; | |
| 11 | +require TWENTIG_PATH . 'inc/dashboard/theme-notice.php'; | |
| 12 | +require TWENTIG_PATH . 'inc/utilities.php'; | |
| 13 | +require TWENTIG_PATH . 'inc/blocks.php'; | |
| 14 | +require TWENTIG_PATH . 'inc/block-styles.php'; | |
| 15 | +require TWENTIG_PATH . 'inc/block-presets.php'; | |
| 16 | +require TWENTIG_PATH . 'inc/block-patterns.php'; | |
| 17 | +require TWENTIG_PATH . 'inc/icon-library.php'; | |
| 18 | +require TWENTIG_PATH . 'inc/twentig_portfolio.php'; | |
| 19 | + | |
| 13 | 20 | /** |
| 14 | - * Include Twenty Twenty specific files. | |
| 21 | + * Loads theme-specific compatibility files. | |
| 22 | + * | |
| 23 | + * Conditionally includes files based on whether the active theme | |
| 24 | + * is a block theme or classic theme, and includes theme-specific | |
| 25 | + * compatibility layers for Twenty Twenty-series themes. | |
| 15 | 26 | */ |
| 16 | -if ( 'twentytwenty' === get_template() ) { | |
| 17 | - require_once TWENTIG_PATH . 'inc/twenty-twenty.php'; | |
| 18 | - require_once TWENTIG_PATH . 'inc/font.php'; | |
| 19 | - require_once TWENTIG_PATH . 'inc/page-templater.php'; | |
| 27 | +function twentig_theme_support_includes() { | |
| 28 | + $template = get_template(); | |
| 29 | + | |
| 30 | + if ( wp_is_block_theme() ) { | |
| 31 | + if ( ! str_starts_with( $template, 'twentytwenty' ) ) { | |
| 32 | + return; | |
| 33 | + } | |
| 34 | + | |
| 35 | + $file_path = TWENTIG_PATH . "inc/compat/{$template}.php"; | |
| 36 | + if ( file_exists( $file_path ) ) { | |
| 37 | + require_once $file_path; | |
| 38 | + } | |
| 39 | + if ( in_array( $template, array( 'twentytwentyfour', 'twentytwentythree', 'twentytwentytwo' ), true ) ) { | |
| 40 | + require_once TWENTIG_PATH . 'inc/compat/blocks.php'; | |
| 41 | + require_once TWENTIG_PATH . 'inc/compat/block-styles.php'; | |
| 42 | + } | |
| 43 | + } else { | |
| 44 | + require_once TWENTIG_PATH . 'inc/compat/blocks.php'; | |
| 45 | + require_once TWENTIG_PATH . 'inc/compat/block-styles.php'; | |
| 46 | + if ( 'twentytwentyone' === $template || 'twentytwenty' === $template ) { | |
| 47 | + require_once TWENTIG_PATH . "inc/classic/{$template}/{$template}.php"; | |
| 48 | + } | |
| 49 | + } | |
| 20 | 50 | } |
| 51 | +add_action( 'plugins_loaded', 'twentig_theme_support_includes' ); | |