PluginProbe ʕ •ᴥ•ʔ
Kubio AI Page Builder / 1.6.4
Kubio AI Page Builder v1.6.4
2.8.4 2.8.3 2.8.2 2.8.1 trunk 1.0.0 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.9.0 2.0.0 2.1.1 2.1.2 2.1.3 2.2.0 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.5 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.6.1 2.6.2 2.6.3 2.6.5 2.6.6 2.6.7 2.7.0 2.7.1 2.7.2 2.7.3 2.8.0
kubio / lib / integrations / child-themes / child-themes.php
kubio / lib / integrations / child-themes Last commit date
child-themes.php 4 years ago
child-themes.php
52 lines
1 <?php
2
3 use Kubio\Core\Activation;
4 use Kubio\Core\Importer;
5
6 function kubio_sync_child_theme_templates_and_parts() {
7 $stylesheet = get_stylesheet();
8 $template = get_template();
9
10 if ( $stylesheet !== $template ) {
11
12 $parent_templates = kubio_get_block_templates( array( 'theme' => $template ), 'wp_template' );
13 foreach ( $parent_templates as $parent_template ) {
14 $source = kubio_retrieve_template_source( $parent_template );
15 $blocks = parse_blocks( $parent_template->content );
16 $blocks = kubio_blocks_update_template_parts_theme( $blocks, $stylesheet );
17 Importer::createTemplate( $parent_template->slug, kubio_serialize_blocks( $blocks ), false, $source );
18 }
19
20 $parent_templates = kubio_get_block_templates( array( 'theme' => $template ), 'wp_template_part' );
21 foreach ( $parent_templates as $parent_template ) {
22 $source = kubio_retrieve_template_source( $parent_template );
23 Importer::createTemplatePart( $parent_template->slug, $parent_template->content, false, $source );
24 }
25 }
26
27 }
28
29
30 function kubio_sync_child_theme_global_data() {
31 $stylesheet = get_stylesheet();
32 $template = get_template();
33
34 if ( $stylesheet !== $template ) {
35 $has_global_data = kubio_has_global_data( $stylesheet );
36
37 if ( ! $has_global_data ) {
38 $global_data = kubio_get_theme_global_data_content( $template );
39 if ( $global_data ) {
40 Activation::skipAfterSwitchTheme();
41 kubio_replace_global_data_content( $global_data );
42 }
43 }
44 }
45
46 }
47
48 add_action( 'admin_init', 'kubio_sync_child_theme_templates_and_parts', 10 );
49
50 add_action( 'switch_theme', 'kubio_sync_child_theme_global_data', 5 ); // priority should be less than 10 to execute earlyear
51 add_action( 'switch_theme', 'kubio_sync_child_theme_templates_and_parts', 5 ); // priority should be less than 10 to execute earlyear
52