block-based-templates
1 month ago
styles
4 years ago
customizer-options.php
1 year ago
editor-hooks.php
1 year ago
fallback-compatibility.php
4 years ago
front-page.html
2 years ago
frontend-hooks.php
1 year ago
preview.php
4 years ago
templates-importer.php
1 year ago
templates.php
1 year ago
third-party-themes.php
1 year ago
fallback-compatibility.php
60 lines
| 1 | <?php |
| 2 | |
| 3 | use Kubio\Flags; |
| 4 | |
| 5 | function kubio_mark_supported_themes_templates_fallback() { |
| 6 | |
| 7 | if ( ! kubio_theme_has_kubio_block_support() ) { |
| 8 | return; |
| 9 | } |
| 10 | |
| 11 | if ( ! is_admin() ) { |
| 12 | return; |
| 13 | } |
| 14 | |
| 15 | $kubio_default_templates = array( '404', 'archive-product', 'front-page', 'full-width', 'index', 'page', 'search', 'single-product', 'single' ); |
| 16 | $kubio_default_template_parts = array( 'header', 'sidebar', 'footer', 'front-header' ); |
| 17 | |
| 18 | if ( Flags::get( 'kubio_activation_time' ) !== null ) { |
| 19 | |
| 20 | if ( Flags::get( 'kubio_templates_imported' ) === null ) { |
| 21 | |
| 22 | $templates = get_posts( |
| 23 | array( |
| 24 | 'post_type' => 'wp_template', |
| 25 | 'post_name__in' => $kubio_default_templates, |
| 26 | 'posts_per_page' => -1, |
| 27 | 'fields' => 'ids', |
| 28 | ) |
| 29 | ); |
| 30 | |
| 31 | foreach ( $templates as $template ) { |
| 32 | update_post_meta( intval( $template ), '_kubio_template_source', 'kubio' ); |
| 33 | } |
| 34 | |
| 35 | Flags::touch( 'kubio_templates_imported' ); |
| 36 | |
| 37 | } |
| 38 | |
| 39 | if ( Flags::get( 'kubio_template_parts_imported' ) === null ) { |
| 40 | |
| 41 | $template_parts = get_posts( |
| 42 | array( |
| 43 | 'post_type' => 'wp_template_parts', |
| 44 | 'post_name__in' => $kubio_default_template_parts, |
| 45 | 'posts_per_page' => -1, |
| 46 | 'fields' => 'ids', |
| 47 | ) |
| 48 | ); |
| 49 | |
| 50 | foreach ( $template_parts as $part ) { |
| 51 | update_post_meta( intval( $part ), '_kubio_template_source', 'kubio' ); |
| 52 | } |
| 53 | |
| 54 | Flags::touch( 'kubio_template_parts_imported' ); |
| 55 | } |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | add_action( 'after_setup_theme', 'kubio_mark_supported_themes_templates_fallback' ); |
| 60 |