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
woocommerce-basic.php
81 lines
| 1 | <?php |
| 2 | |
| 3 | use IlluminateAgnostic\Arr\Support\Arr; |
| 4 | |
| 5 | require_once __DIR__ . '/utils.php'; |
| 6 | require_once __DIR__ . '/sidebar.php'; |
| 7 | |
| 8 | function kubio_enqueue_woocommerce_style() { |
| 9 | |
| 10 | wp_enqueue_style( |
| 11 | 'kubio-woocommerce', |
| 12 | kubio_url( 'build/woocommerce-styles/style.css' ), |
| 13 | array( 'woocommerce-general' ), |
| 14 | KUBIO_VERSION |
| 15 | ); |
| 16 | } |
| 17 | |
| 18 | function kubio_woocommerce_support_editor_assets() { |
| 19 | wp_enqueue_style( 'kubio-woocommerce-styles' ); |
| 20 | wp_enqueue_script( 'kubio-woocommerce-styles' ); |
| 21 | } |
| 22 | |
| 23 | |
| 24 | function kubio_add_woocommerce_support() { |
| 25 | |
| 26 | if ( ! class_exists( 'WooCommerce' ) ) { |
| 27 | return; |
| 28 | } |
| 29 | |
| 30 | require_once __DIR__ . '/block-editor-settings.php'; |
| 31 | |
| 32 | if ( kubio_has_kubio_woocommerce_support() ) { |
| 33 | add_action( 'wp_enqueue_scripts', 'kubio_enqueue_woocommerce_style' ); |
| 34 | add_action( 'kubio/editor/enqueue_assets', 'kubio_woocommerce_support_editor_assets' ); |
| 35 | |
| 36 | require_once __DIR__ . '/templates-filters.php'; |
| 37 | |
| 38 | if ( kubio_is_hybdrid_theme_iframe_preview() ) { |
| 39 | add_filter( 'woocommerce_checkout_redirect_empty_cart', '__return_false' ); |
| 40 | } |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | |
| 45 | function kubio_woocommerce_products_page_edit( $args ) { |
| 46 | if ( function_exists( 'is_shop' ) && is_shop() && wc_get_page_id( 'shop' ) ) { |
| 47 | $args = array( |
| 48 | 'postId' => wc_get_page_id( 'shop' ), |
| 49 | 'postType' => 'page', |
| 50 | ); |
| 51 | } |
| 52 | |
| 53 | return $args; |
| 54 | } |
| 55 | |
| 56 | |
| 57 | function kubio_add_woocommerce_global_style_types( $types ) { |
| 58 | $style_types = json_decode( file_get_contents( KUBIO_BUILD_DIR . '/woocommerce-styles/style-types.json' ), true ); |
| 59 | |
| 60 | $global_style_root_path = 'definitions.globalStyle'; |
| 61 | $styles_enum = array_merge( |
| 62 | Arr::get( $types, "{$global_style_root_path}.elementsEnum", array() ), |
| 63 | Arr::get( $style_types, 'elementsEnum', array() ) |
| 64 | ); |
| 65 | |
| 66 | $styles_by_name = array_merge( |
| 67 | Arr::get( $types, "{$global_style_root_path}.elementsByName", array() ), |
| 68 | Arr::get( $style_types, 'elementsByName', array() ) |
| 69 | ); |
| 70 | |
| 71 | Arr::set( $types, "{$global_style_root_path}.elementsEnum", $styles_enum ); |
| 72 | Arr::set( $types, "{$global_style_root_path}.elementsByName", $styles_by_name ); |
| 73 | |
| 74 | return $types; |
| 75 | } |
| 76 | |
| 77 | add_action( 'init', 'kubio_add_woocommerce_support' ); |
| 78 | |
| 79 | add_filter( 'kubio/frontend/edit-in-kubio-args', 'kubio_woocommerce_products_page_edit' ); |
| 80 | add_filter( 'kubio/style-types', 'kubio_add_woocommerce_global_style_types' ); |
| 81 |