account-address
5 years ago
account-dashboard
5 years ago
account-details
5 years ago
account-downloads
5 years ago
account-form-login
5 years ago
account-form-register
5 years ago
account-logout
5 years ago
account-navigation
5 years ago
account-order-details
5 years ago
account-orders
5 years ago
add-to-cart
5 years ago
additional-information
5 years ago
advanced-search
5 years ago
archive-description
5 years ago
archive-products
5 years ago
archive-result-count
5 years ago
archive-title
5 years ago
archive-view-mode
5 years ago
breadcrumbs
5 years ago
cart-table
5 years ago
cart-totals
5 years ago
categories
5 years ago
checkout-coupon-form
5 years ago
checkout-form-additional
5 years ago
checkout-form-billing
5 years ago
checkout-form-login
5 years ago
checkout-form-shipping
5 years ago
checkout-payment
5 years ago
checkout-review-order
5 years ago
checkout-shipping-methods
5 years ago
cross-sells
5 years ago
deal-products
5 years ago
empty-cart-message
5 years ago
filter-orderby
5 years ago
filter-products-per-page
5 years ago
filterable-product-list
5 years ago
init
5 years ago
product-categories
5 years ago
product-category-lists
5 years ago
product-description
5 years ago
product-excerpt
5 years ago
product-filters
5 years ago
product-image
5 years ago
product-list
5 years ago
product-meta
5 years ago
product-price
5 years ago
product-rating
5 years ago
product-review
5 years ago
product-share
5 years ago
product-sku
5 years ago
product-stock
5 years ago
product-tabs
5 years ago
product-tags
5 years ago
product-title
5 years ago
recently-viewed-products
5 years ago
related
5 years ago
return-to-shop
5 years ago
thankyou-address-details
5 years ago
thankyou-order-confirm
5 years ago
thankyou-order-details
5 years ago
thankyou-thankyou
5 years ago
up-sells
5 years ago
lazy-cache.php
5 years ago
manifest.php
5 years ago
prod-short-code.php
5 years ago
products.php
5 years ago
shop.php
5 years ago
widget-helper.php
5 years ago
widget-helper.php
187 lines
| 1 | <?php |
| 2 | |
| 3 | namespace ShopEngine\Widgets; |
| 4 | |
| 5 | use ShopEngine\Traits\Singleton; |
| 6 | |
| 7 | class Widget_Helper { |
| 8 | |
| 9 | use Singleton; |
| 10 | |
| 11 | public function wc_template_filter_by_match($match, $replace_with) { |
| 12 | |
| 13 | add_filter( |
| 14 | 'wc_get_template', |
| 15 | function ( |
| 16 | $template, |
| 17 | $template_name = '', |
| 18 | $args = '', |
| 19 | $template_path = '', |
| 20 | $default_path = '' |
| 21 | ) use ($match, $replace_with) { |
| 22 | |
| 23 | if(strpos($template, $match) !== false) { |
| 24 | |
| 25 | $template = WC_ABSPATH . $replace_with; |
| 26 | |
| 27 | return $template; |
| 28 | } |
| 29 | |
| 30 | return $template; |
| 31 | } |
| 32 | ); |
| 33 | } |
| 34 | |
| 35 | public function wc_template_part_filter_by_match($match, $replace_with) { |
| 36 | |
| 37 | add_filter('wc_get_template_part', function ($template, $slug = '', $name = '') use ($match, $replace_with) { |
| 38 | |
| 39 | if(strpos($template, $match) !== false) { |
| 40 | |
| 41 | $template = WC_ABSPATH . $replace_with; |
| 42 | } |
| 43 | |
| 44 | return $template; |
| 45 | }); |
| 46 | } |
| 47 | |
| 48 | public function wc_template_part_filter() { |
| 49 | |
| 50 | add_filter('wc_get_template_part', function ($template, $slug = '', $name = '') { |
| 51 | |
| 52 | if(strpos($template, 'woocommerce/content-product.php') !== false) { |
| 53 | |
| 54 | $template = WC_ABSPATH . 'templates/content-product.php'; |
| 55 | |
| 56 | }elseif(strpos($template, 'woocommerce/content-product-base.php') !== false) { |
| 57 | |
| 58 | //$template = WC_ABSPATH . 'templates/content-product.php'; |
| 59 | |
| 60 | } |
| 61 | |
| 62 | return $template; |
| 63 | |
| 64 | }, 999); |
| 65 | } |
| 66 | |
| 67 | |
| 68 | public function wc_template_filter() { |
| 69 | |
| 70 | add_filter('wc_get_template', function ($template, $template_name = '', $args = '', $template_path = '', $default_path = '') { |
| 71 | |
| 72 | if(strpos($template, 'woocommerce/global/breadcrumb.php') !== false) { |
| 73 | |
| 74 | $template = WC_ABSPATH . 'templates/global/breadcrumb.php'; |
| 75 | |
| 76 | }elseif(strpos($template, 'single-product/up-sells.php') !== false) { |
| 77 | |
| 78 | $template = WC_ABSPATH . 'templates/single-product/up-sells.php'; |
| 79 | |
| 80 | } elseif(strpos($template, 'woocommerce/loop/loop-start.php') !== false) { |
| 81 | |
| 82 | $template = WC_ABSPATH . 'templates/loop/loop-start.php'; |
| 83 | |
| 84 | } elseif(strpos($template, 'woocommerce/loop/loop-end.php') !== false) { |
| 85 | |
| 86 | $template = WC_ABSPATH . 'templates/loop/loop-end.php'; |
| 87 | |
| 88 | } elseif(strpos($template, 'woocommerce/global/wrapper-end.php') !== false) { |
| 89 | |
| 90 | $template = WC_ABSPATH . 'templates/global/wrapper-end.php'; |
| 91 | |
| 92 | } elseif(strpos($template, 'woocommerce/global/wrapper-start.php') !== false) { |
| 93 | |
| 94 | $template = WC_ABSPATH . 'templates/global/wrapper-start.php'; |
| 95 | |
| 96 | } elseif(strpos($template, 'woocommerce/loop/sale-flash.php') !== false) { |
| 97 | |
| 98 | $template = WC_ABSPATH . 'templates/loop/sale-flash.php'; |
| 99 | |
| 100 | } elseif(strpos($template, 'woocommerce/single-product/product-image.php') !== false) { |
| 101 | |
| 102 | $template = WC_ABSPATH.'templates/single-product/product-image.php'; |
| 103 | |
| 104 | } elseif(strpos($template, 'woocommerce/single-product/product-thumbnails.php') !== false) { |
| 105 | |
| 106 | $template = WC_ABSPATH.'templates/single-product/product-thumbnails.php'; |
| 107 | |
| 108 | } elseif(strpos($template, 'woocommerce/global/wrapper-end.php') !== false) { |
| 109 | |
| 110 | $template = WC_ABSPATH.'templates/global/wrapper-end.php'; |
| 111 | |
| 112 | } elseif(strpos($template, 'woocommerce/global/wrapper-start.php') !== false) { |
| 113 | |
| 114 | $template = WC_ABSPATH.'templates/global/wrapper-start.php'; |
| 115 | |
| 116 | } elseif(strpos($template, 'woocommerce/loop/result-count.php') !== false) { |
| 117 | |
| 118 | $template = WC_ABSPATH.'templates/loop/result-count.php'; |
| 119 | |
| 120 | } elseif(strpos($template, 'woocommerce/loop/rating.php') !== false) { |
| 121 | |
| 122 | $template = WC_ABSPATH.'templates/loop/rating.php'; |
| 123 | |
| 124 | } elseif(strpos($template, 'woocommerce/loop/add-to-cart.php') !== false) { |
| 125 | |
| 126 | $template = WC_ABSPATH.'templates/loop/add-to-cart.php'; |
| 127 | |
| 128 | } elseif(strpos($template, 'woocommerce/single-product/product-thumbnails.php') !== false) { |
| 129 | |
| 130 | $template = WC_ABSPATH.'templates/single-product/product-thumbnails.php'; |
| 131 | |
| 132 | } elseif(strpos($template, 'woocommerce/single-product/product-image.php') !== false) { |
| 133 | |
| 134 | $template = WC_ABSPATH.'templates/single-product/product-image.php'; |
| 135 | |
| 136 | } elseif(strpos($template, 'woocommerce/single-product/related.php') !== false) { |
| 137 | |
| 138 | $template = WC_ABSPATH.'templates/single-product/related.php'; |
| 139 | |
| 140 | } elseif(strpos($template, 'woocommerce/single-product/up-sells.php') !== false) { |
| 141 | |
| 142 | $template = WC_ABSPATH.'templates/single-product/up-sells.php'; |
| 143 | } |
| 144 | |
| 145 | return $template; |
| 146 | }, 999); |
| 147 | } |
| 148 | |
| 149 | |
| 150 | public function wc_breadcrumb_default_filter($iconClass) { |
| 151 | |
| 152 | add_filter('woocommerce_breadcrumb_defaults', function ($param) use ($iconClass) { |
| 153 | |
| 154 | $param['delimiter'] = '<i class="' . $iconClass . '" aria-hidden="true"></i>'; |
| 155 | $param['wrap_before'] = '<nav class="woocommerce-breadcrumb">'; |
| 156 | $param['wrap_after'] = '</nav>'; |
| 157 | |
| 158 | return $param; |
| 159 | }, 999); |
| 160 | } |
| 161 | |
| 162 | public function comment_template_filter_checker() { |
| 163 | |
| 164 | add_filter('comments_template', function ($template) { |
| 165 | |
| 166 | if(strpos($template, '/single-product-advanced-reviews.php') !== false) { |
| 167 | |
| 168 | /** |
| 169 | * Fix for electro theme................. |
| 170 | */ |
| 171 | |
| 172 | $template = WC_ABSPATH . 'templates/single-product-reviews.php'; |
| 173 | |
| 174 | } elseif(strpos($template, '/woocommerce/single-product-reviews.php') !== false) { |
| 175 | |
| 176 | /** |
| 177 | * Fix for all other theme................. |
| 178 | */ |
| 179 | |
| 180 | $template = WC_ABSPATH . 'templates/single-product-reviews.php'; |
| 181 | } |
| 182 | |
| 183 | return $template; |
| 184 | }, 999); |
| 185 | } |
| 186 | } |
| 187 |