PluginProbe ʕ •ᴥ•ʔ
Kubio AI Page Builder / 2.6.3
Kubio AI Page Builder v2.6.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 year ago utils.php 2 years ago woocommerce-basic.php 2 years ago
templates-filters.php
85 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 $pathinfo = pathinfo( $template );
21 $default_file = isset( $pathinfo['filename'] ) ? $pathinfo['filename'] : null;
22
23 if ( ! $default_file ) {
24 return $template;
25 }
26
27 $templates = is_archive() ? array( "$default_file.php", 'archive-product.php', 'archive.php' ) : array( "$default_file.php", 'single-product.php', 'single.php' );
28
29 if ( is_tax() ) {
30 $templates = array( 'archive-product.php', 'archive.php' );
31 }
32
33 $templates = array_unique( $templates );
34 $template = locate_block_template( "$default_file.php", 'wp_template', $templates );
35
36 global $_wp_current_template_content;
37
38 if ( ! empty( $_wp_current_template_content ) ) {
39
40 $content = kubio_get_woocommerce_content();
41 // escape the dollar sign so preg_replace will not think it's a backreference
42 $content = addcslashes( $content, '$' );
43
44 if ( is_single() ) {
45 add_theme_support( 'wc-product-gallery-zoom' );
46 add_theme_support( 'wc-product-gallery-lightbox' );
47 add_theme_support( 'wc-product-gallery-slider' );
48 }
49
50 // replace the 'post-content' block with the <!-- wp:html --> block to display the woocommerce content
51 $_wp_current_template_content = preg_replace(
52 '#<!-- wp:post-content(.*)/-->#',
53 '<!-- wp:html -->' . $content . '<!-- /wp:html -->',
54 $_wp_current_template_content
55 );
56 }
57 }
58
59 return $template;
60 }
61
62 function kubio_woocommerce_support_rendered_content( $content ) {
63 $post_type = get_post_type();
64 $is_displaying_products = is_archive() || is_single();
65
66 if ( $post_type === 'product' && $is_displaying_products ) {
67 $content = kubio_get_woocommerce_content();
68 }
69
70 return $content;
71 }
72
73 add_filter( 'template_include', 'kubio_woocommerce_support_template_include', 20, 1 );
74
75 add_filter( 'kubio/editor/rendered-content', 'kubio_woocommerce_support_rendered_content' );
76
77
78 function kubio_woocommerce_achive_page_title() {
79 if ( function_exists( 'is_shop' ) && is_shop() && wc_get_page_id( 'shop' ) ) {
80 return get_the_title( wc_get_page_id( 'shop' ) );
81 }
82 }
83
84 add_filter( 'post_type_archive_title', 'kubio_woocommerce_achive_page_title' );
85