admin-pages
4 years ago
api
4 years ago
blog
4 years ago
full-site-editing
4 years ago
importer
4 years ago
integrations
4 years ago
menu
4 years ago
polyfills
4 years ago
preview
4 years ago
shapes
4 years ago
shortcodes
4 years ago
src
4 years ago
add-edit-in-kubio.php
4 years ago
editor-assets.php
4 years ago
env.php
4 years ago
filters.php
4 years ago
frontend.php
4 years ago
global-data.php
4 years ago
kubio-block-library.php
4 years ago
kubio-editor.php
4 years ago
load.php
4 years ago
shared-style.php
4 years ago
frontend.php
57 lines
| 1 | <?php |
| 2 | |
| 3 | function kubio_enqueue_frontend_assets() { |
| 4 | wp_enqueue_script( 'kubio-frontend' ); |
| 5 | wp_enqueue_style( 'kubio-block-library' ); |
| 6 | |
| 7 | $style = array( |
| 8 | // shapes |
| 9 | kubio_get_shapes_css(), |
| 10 | // colors |
| 11 | kubio_render_global_colors(), |
| 12 | // global |
| 13 | kubio_get_global_data( 'additional_css' ), |
| 14 | // page css |
| 15 | kubio_get_page_css(), |
| 16 | ); |
| 17 | |
| 18 | wp_add_inline_style( 'kubio-block-library', implode( "\n\n", $style ) ); |
| 19 | } |
| 20 | |
| 21 | add_action( 'wp_enqueue_scripts', 'kubio_enqueue_frontend_assets' ); |
| 22 | |
| 23 | function kubio_get_page_css() { |
| 24 | return Kubio\Core\StyleManager\StyleManager::getInstance()->render(); |
| 25 | } |
| 26 | |
| 27 | function kubio_render_page_css() { |
| 28 | |
| 29 | if ( wp_doing_ajax() || defined( 'REST_REQUEST' ) ) { |
| 30 | return; |
| 31 | } |
| 32 | |
| 33 | $content = '<style type="text/css" data-name="kubio-style">' . kubio_get_page_css() . '</style>'; |
| 34 | |
| 35 | return $content; |
| 36 | |
| 37 | } |
| 38 | |
| 39 | add_filter( |
| 40 | 'style_loader_tag', |
| 41 | function( $tag, $handle ) { |
| 42 | $asynced_styles = array( 'kubio-google-fonts' ); |
| 43 | |
| 44 | if ( in_array( $handle, $asynced_styles, true ) ) { |
| 45 | if ( strpos( $tag, ' async' ) === false ) { |
| 46 | $tag = str_replace( '<link', '<link async', $tag ); |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | return $tag; |
| 51 | }, |
| 52 | PHP_INT_MAX, |
| 53 | 4 |
| 54 | ); |
| 55 | |
| 56 | require_once __DIR__ . '/polyfills/polyfills.php'; |
| 57 |