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 / woocommerce-basic / templates-filters.php
kubio / lib / integrations / woocommerce-basic Last commit date
block-editor-settings.php 4 years ago sidebar.php 1 year ago templates-filters.php 1 month ago utils.php 2 years ago woocommerce-basic.php 2 years ago
templates-filters.php
89 lines
1 <?php
2
3
4 /**
5 * Override the default woocommerce templates with block templates
6 *
7 * @param string $template
8 *
9 * @return string
10 */
11 function kubio_woocommerce_support_template_include( $template ) {
12
13 $post_type = get_post_type();
14 $is_displaying_products = is_archive() || is_single() || is_tax();
15
16 // This theme doesn't have a traditional sidebar.
17 remove_action( 'woocommerce_sidebar', 'woocommerce_get_sidebar', 10 );
18
19 if ( $post_type === 'product' && $is_displaying_products ) {
20
21 if ( !empty($template) && strpos( $template, 'template-canvas' ) === false ) {
22 $pathinfo = pathinfo( $template );
23 $default_file = isset( $pathinfo['filename'] ) ? $pathinfo['filename'] : null;
24
25 if ( ! $default_file ) {
26 return $template;
27 }
28
29 $default_file_with_extension = "$default_file.php";
30 $templates = is_archive() ? array( $default_file_with_extension, 'archive-product.php', 'archive.php' ) : array( $default_file_with_extension, 'single-product.php', 'single.php' );
31
32 if ( is_tax() ) {
33 $templates = array( 'archive-product.php', 'archive.php' );
34 }
35
36 $templates = array_unique( $templates );
37 $template = locate_block_template( $default_file_with_extension, 'wp_template', $templates );
38 }
39
40 global $_wp_current_template_content;
41
42 if ( ! empty( $_wp_current_template_content ) ) {
43
44 $content = kubio_get_woocommerce_content();
45 // escape the dollar sign so preg_replace will not think it's a backreference
46 $content = addcslashes( $content, '$' );
47
48 if ( is_single() ) {
49 add_theme_support( 'wc-product-gallery-zoom' );
50 add_theme_support( 'wc-product-gallery-lightbox' );
51 add_theme_support( 'wc-product-gallery-slider' );
52 }
53
54 // replace the 'post-content' block with the <!-- wp:html --> block to display the woocommerce content
55 $_wp_current_template_content = preg_replace(
56 '#<!-- wp:post-content(.*)/-->#',
57 '<!-- wp:html -->' . $content . '<!-- /wp:html -->',
58 $_wp_current_template_content
59 );
60 }
61 }
62
63 return $template;
64 }
65
66 function kubio_woocommerce_support_rendered_content( $content ) {
67 $post_type = get_post_type();
68 $is_displaying_products = is_archive() || is_single();
69
70 if ( $post_type === 'product' && $is_displaying_products ) {
71 $content = kubio_get_woocommerce_content();
72 }
73
74 return $content;
75 }
76
77 add_filter( 'template_include', 'kubio_woocommerce_support_template_include', 20, 1 );
78
79 add_filter( 'kubio/editor/rendered-content', 'kubio_woocommerce_support_rendered_content' );
80
81
82 function kubio_woocommerce_achive_page_title() {
83 if ( function_exists( 'is_shop' ) && is_shop() && wc_get_page_id( 'shop' ) ) {
84 return get_the_title( wc_get_page_id( 'shop' ) );
85 }
86 }
87
88 add_filter( 'post_type_archive_title', 'kubio_woocommerce_achive_page_title' );
89