AI
9 months ago
admin-pages
1 year ago
api
7 months ago
blog
1 year ago
customizer
1 year ago
filters
9 months ago
full-site-editing
6 months ago
importer
1 year ago
integrations
9 months ago
menu
1 year ago
polyfills
1 year ago
preview
7 months ago
recommendations
9 months ago
shapes
2 years ago
shortcodes
1 year ago
src
9 months ago
add-edit-in-kubio.php
11 months ago
editor-assets.php
9 months ago
filters.php
1 year ago
frontend.php
1 year ago
global-data.php
1 year ago
init.php
1 year ago
kubio-block-library.php
1 year ago
kubio-editor.php
9 months ago
load.php
11 months ago
frontend.php
70 lines
| 1 | <?php |
| 2 | |
| 3 | use IlluminateAgnostic\Arr\Support\Arr; |
| 4 | |
| 5 | function kubio_enqueue_frontend_assets() { |
| 6 | |
| 7 | if ( kubio_is_hybdrid_theme_iframe_preview() ) { |
| 8 | return; |
| 9 | } |
| 10 | |
| 11 | kubio_enqueue_frontend_scripts(); |
| 12 | wp_enqueue_style( 'kubio-block-library' ); |
| 13 | |
| 14 | $style = array(); |
| 15 | |
| 16 | //when we are inside the editor and render the content inside a post or a woo product. We don't want to add a new instance |
| 17 | //of global colors or aditional css. Because it will overwrite the css from the editor |
| 18 | // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 19 | if ( ! Arr::has( $_REQUEST, '__kubio-rendered-styles' ) ) { |
| 20 | $style = array( |
| 21 | // shapes |
| 22 | kubio_get_shapes_css(), |
| 23 | // colors |
| 24 | kubio_render_global_colors(), |
| 25 | // global |
| 26 | kubio_get_global_data( 'additional_css' ), |
| 27 | ); |
| 28 | } |
| 29 | //page css |
| 30 | $style[] = kubio_get_page_css(); |
| 31 | |
| 32 | wp_add_inline_style( 'kubio-block-library', implode( "\n\n", $style ) ); |
| 33 | } |
| 34 | |
| 35 | add_action( 'wp_enqueue_scripts', 'kubio_enqueue_frontend_assets' ); |
| 36 | |
| 37 | function kubio_get_page_css() { |
| 38 | return Kubio\Core\StyleManager\StyleManager::getInstance()->render(); |
| 39 | } |
| 40 | |
| 41 | function kubio_render_page_css() { |
| 42 | |
| 43 | if ( wp_doing_ajax() || defined( 'REST_REQUEST' ) ) { |
| 44 | return; |
| 45 | } |
| 46 | |
| 47 | $content = '<style type="text/css" data-name="kubio-style">' . kubio_get_page_css() . '</style>'; |
| 48 | |
| 49 | return $content; |
| 50 | } |
| 51 | |
| 52 | add_filter( |
| 53 | 'style_loader_tag', |
| 54 | function ( $tag, $handle ) { |
| 55 | $asynced_styles = array( 'kubio-google-fonts' ); |
| 56 | |
| 57 | if ( in_array( $handle, $asynced_styles, true ) ) { |
| 58 | if ( strpos( $tag, ' async' ) === false ) { |
| 59 | $tag = str_replace( '<link', '<link async', $tag ); |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | return $tag; |
| 64 | }, |
| 65 | PHP_INT_MAX, |
| 66 | 4 |
| 67 | ); |
| 68 | |
| 69 | require_once __DIR__ . '/polyfills/polyfills.php'; |
| 70 |