kubio-block-footer-template-part.php
1 year ago
kubio-block-header-template-part.php
1 year ago
supported-theme-block-partials.php
1 year ago
supported-theme-block-partials.php
55 lines
| 1 | <?php |
| 2 | |
| 3 | function kubio_prepare_classic_theme_block_template_parts() { |
| 4 | require_once __DIR__ . '/kubio-block-header-template-part.php'; |
| 5 | require_once __DIR__ . '/kubio-block-footer-template-part.php'; |
| 6 | } |
| 7 | |
| 8 | add_action( |
| 9 | 'after_setup_theme', |
| 10 | 'kubio_prepare_classic_theme_block_template_parts', |
| 11 | 20 |
| 12 | ); |
| 13 | |
| 14 | add_filter( |
| 15 | str_replace( '-', '_', get_template() ) . '_theme_components', |
| 16 | function ( $components ) { |
| 17 | |
| 18 | if ( class_exists( 'KubioBlockBasedHeaderTemplatePart' ) ) { |
| 19 | $components['header'] = KubioBlockBasedHeaderTemplatePart::class; |
| 20 | } |
| 21 | |
| 22 | if ( class_exists( 'KubioBlockBasedFooterTemplatePart' ) ) { |
| 23 | $components['footer'] = KubioBlockBasedFooterTemplatePart::class; |
| 24 | } |
| 25 | |
| 26 | add_action( |
| 27 | 'wp_footer', |
| 28 | function () { |
| 29 | global $kubio_force_render_partials_style; |
| 30 | if ( $kubio_force_render_partials_style ) { |
| 31 | kubio_enqueue_frontend_scripts(); |
| 32 | wp_enqueue_style( 'kubio-block-library' ); |
| 33 | |
| 34 | $style = array( |
| 35 | // shapes |
| 36 | kubio_get_shapes_css(), |
| 37 | // colors |
| 38 | kubio_render_global_colors(), |
| 39 | // global |
| 40 | kubio_get_global_data( 'additional_css' ), |
| 41 | // page css |
| 42 | kubio_get_page_css(), |
| 43 | ); |
| 44 | |
| 45 | // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 46 | echo '<style>' . implode( "\n", $style ) . '</style>'; |
| 47 | } |
| 48 | } |
| 49 | ); |
| 50 | |
| 51 | return $components; |
| 52 | }, |
| 53 | 100 |
| 54 | ); |
| 55 |