PluginProbe ʕ •ᴥ•ʔ
Kubio AI Page Builder / 2.8.3
Kubio AI Page Builder v2.8.3
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 / third-party-themes / frontend-hooks.php
kubio / lib / integrations / third-party-themes Last commit date
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
frontend-hooks.php
138 lines
1 <?php
2
3 use IlluminateAgnostic\Arr\Support\Arr;
4
5 function kubio_hybdrid_theme_classic_content_frontend_style( $content ) {
6
7 if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
8 return $content;
9 }
10
11 if ( is_admin() ) {
12 return $content;
13 }
14
15 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
16 if ( kubio_is_hybdrid_theme_iframe_preview() || isset( $_REQUEST['__kubio-rendered-content'] ) ) {
17 return $content;
18 }
19 if ( ! kubio_is_block_template() || ( kubio_is_page_preview() && kubio_3rd_party_theme_is_previewing_theme_template() ) ) {
20 return sprintf(
21 '<!-- content style : start -->%s<!-- content style : end -->%s',
22 kubio_render_page_css(),
23 $content
24 );
25 }
26
27 return $content;
28 }
29
30 add_filter( 'the_content', 'kubio_hybdrid_theme_classic_content_frontend_style', PHP_INT_MAX );
31
32 add_filter(
33 'language_attributes',
34 function ( $html_attrs ) {
35 $html_attrs .= ' id="kubio"';
36
37 return $html_attrs;
38 }
39 );
40
41
42 function kubio_3rd_party_theme_is_previewing_theme_template() {
43 if ( kubio_is_page_preview() ) {
44 global $kubio_preview_located_template_data;
45 $template = Arr::get( $kubio_preview_located_template_data, 'template', null );
46 if ( $template && strpos( $template, '.php' ) !== false && strpos( wp_normalize_path( $template ), '/template-canvas.php' ) === false ) {
47 return true;
48 }
49 }
50
51 return false;
52 }
53
54 function kubio_dequeue_theme_styles() {
55
56
57 if ( kubio_theme_has_kubio_block_support() ) {
58 return;
59 }
60
61 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
62 if ( kubio_is_hybdrid_theme_iframe_preview() && Arr::get( $_REQUEST, '__kubio-site-edit-iframe-classic-template' ) ) {
63 return;
64 }
65
66 if ( kubio_3rd_party_theme_is_previewing_theme_template() ) {
67 return;
68 }
69
70 $stylesheet_uri = get_stylesheet_directory_uri();
71 $template_style_uri = get_template_directory_uri();
72 $wp_styles = wp_styles();
73 $registered = $wp_styles->registered;
74
75 // add a normalize and reset style
76 $wp_styles->add( 'kubio-3rd-party-theme-template-base', kubio_url( '/lib/integrations/third-party-themes/styles/base.css' ), array(), KUBIO_VERSION );
77 // $wp_styles->enqueue( 'kubio-3rd-party-theme-template-base' );
78 array_unshift( $wp_styles->queue, 'kubio-3rd-party-theme-template-base' );
79
80 foreach ( $wp_styles->registered as $registered ) {
81 $src = $registered->src;
82 $handle = $registered->handle;
83 if ( $src && $handle ) {
84 if ( strpos( $src, $stylesheet_uri ) === 0 || strpos( $src, $template_style_uri ) === 0 ) {
85 $wp_styles->dequeue( $handle );
86 }
87 }
88 }
89
90 do_action( 'kubio/dequeue-theme-styles' );
91 }
92
93
94 function kubio_maybe_dequeue_theme_styles() {
95
96 if ( is_admin() || ( defined( 'REST_REQUEST' ) && REST_REQUEST ) ) {
97 return;
98 }
99
100 global $kubio_located_template_data;
101 global $_wp_current_template_content;
102
103
104 //If current template is non fse template we skip the logic bellow as it will only work if the list of templates contains
105 //some fse templates. resolve_block_template can't detect non fse templates;
106 $is_fse_template = !empty($_wp_current_template_content);
107 if(!$is_fse_template) {
108 return;
109 }
110
111 if ( is_array( $kubio_located_template_data ) ) {
112 $template = Arr::get( $kubio_located_template_data, 'template', null );
113 $type = Arr::get( $kubio_located_template_data, 'type', null );
114 $templates = Arr::get( $kubio_located_template_data, 'templates', null );
115
116 if ( $template !== null && $type !== null && $templates !== null ) {
117 $block_template = resolve_block_template( $type, $templates, $template );
118 if ( $block_template && $block_template->wp_id ) {
119 $source = get_post_meta( $block_template->wp_id, '_kubio_template_source', true );
120
121 if ( $source === 'kubio' || $source === 'kubio-custom' ) {
122 kubio_dequeue_theme_styles();
123 }
124 }
125 }
126 }
127 }
128
129 // safari mobile do not transform phone noumbers to link automatically
130 add_action(
131 'wp_head',
132 function () {
133 echo '<meta name="format-detection" content="telephone=no">';
134 }
135 );
136
137 add_action( 'wp_print_styles', 'kubio_maybe_dequeue_theme_styles', PHP_INT_MAX );
138