archive.php
1 week ago
base-content.php
2 years ago
base.php
1 week ago
cart.php
1 week ago
checkout.php
1 week ago
shop.php
4 years ago
single.php
1 week ago
archive.php
144 lines
| 1 | <?php |
| 2 | |
| 3 | namespace ShopEngine\Core\Page_Templates\Hooks; |
| 4 | |
| 5 | use ShopEngine\Compatibility\Conflicts\Theme_Hooks; |
| 6 | |
| 7 | defined('ABSPATH') || exit; |
| 8 | |
| 9 | class Archive extends Base { |
| 10 | |
| 11 | protected $page_type = 'archive'; |
| 12 | protected $template_part = 'content-archive.php'; |
| 13 | |
| 14 | public function init() : void { |
| 15 | |
| 16 | add_action('wp_enqueue_scripts', [$this, 'enqueue_css_with_conflicts_removed'], 9999); |
| 17 | add_filter('woocommerce_enqueue_styles', [Theme_Hooks::instance(), 'force_load_woocommerce_css'], 9998); |
| 18 | |
| 19 | // add_action('woocommerce_before_shop_loop_item', [$this, 'delayed_hook_conflicts'], 9999); |
| 20 | $this->delayed_hook_conflicts(); |
| 21 | } |
| 22 | |
| 23 | public function delayed_hook_conflicts() { |
| 24 | |
| 25 | // add_action('template_include', function ($template) { |
| 26 | |
| 27 | // if($this->tpl_loaded) { |
| 28 | |
| 29 | Theme_Hooks::instance()->theme_conflicts_archive_page_after_wp_loaded(); |
| 30 | Theme_Hooks::instance()->theme_conflicts_in_specific_footer_area(); |
| 31 | // } |
| 32 | |
| 33 | // return $template; |
| 34 | |
| 35 | // }, 9991); |
| 36 | |
| 37 | $themeName = get_template(); |
| 38 | if ( $themeName == 'eduma' ) { |
| 39 | remove_filter('loop_shop_columns', '__return_false'); |
| 40 | } |
| 41 | |
| 42 | if (is_plugin_active('auxin-shop/auxin-shop.php')) { |
| 43 | |
| 44 | remove_filter('wc_get_template', 'auxshp_get_wc_template', 11, 2); |
| 45 | |
| 46 | // Remove Auxin Shop template loader filter |
| 47 | global $wp_filter; |
| 48 | if (isset($wp_filter['woocommerce_locate_template'])) { |
| 49 | foreach ($wp_filter['woocommerce_locate_template']->callbacks as $priority => $callbacks) { |
| 50 | foreach ($callbacks as $key => $callback) { |
| 51 | if (is_array($callback['function']) && |
| 52 | is_object($callback['function'][0]) && |
| 53 | get_class($callback['function'][0]) === 'AUXSHP_Template_Loader' && |
| 54 | $callback['function'][1] === 'load_templates') { |
| 55 | unset($wp_filter['woocommerce_locate_template']->callbacks[$priority][$key]); |
| 56 | } |
| 57 | } |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | // Remove rating hook from AUXSHP_Template_Loader class |
| 62 | global $wp_filter; |
| 63 | if (isset($wp_filter['woocommerce_after_shop_loop_item_title'])) { |
| 64 | foreach ($wp_filter['woocommerce_after_shop_loop_item_title']->callbacks[13] as $key => $callback) { |
| 65 | if (is_array($callback['function']) && |
| 66 | is_object($callback['function'][0]) && |
| 67 | get_class($callback['function'][0]) === 'AUXSHP_Template_Loader' && |
| 68 | $callback['function'][1] === 'auxshp_loop_rating') { |
| 69 | unset($wp_filter['woocommerce_after_shop_loop_item_title']->callbacks[13][$key]); |
| 70 | } |
| 71 | } |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | if ( is_plugin_active('auxin-elements/auxin-elements.php') ) { |
| 76 | |
| 77 | remove_action( 'woocommerce_shop_loop_item_title', 'auxin_woocommerce_template_loop_product_title', 10 ); |
| 78 | } |
| 79 | |
| 80 | |
| 81 | } |
| 82 | |
| 83 | public function enqueue_css_with_conflicts_removed() { |
| 84 | |
| 85 | wp_dequeue_style('oceanwp-woocommerce'); |
| 86 | |
| 87 | |
| 88 | if(!wp_style_is('woocommerce-general', 'registered')) { |
| 89 | |
| 90 | $styles = \WC_Frontend_Scripts::get_styles(); |
| 91 | |
| 92 | if($styles) { |
| 93 | foreach($styles as $handle => $args) { |
| 94 | |
| 95 | wp_register_style($handle, $args['src'], $args['deps'], $args['version'], $args['media']); |
| 96 | } |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | wp_enqueue_style('woocommerce-general'); |
| 101 | wp_enqueue_style('woocommerce-layout'); |
| 102 | |
| 103 | //Eduma Theme Conflict Issue |
| 104 | $themeName = get_template(); |
| 105 | |
| 106 | if ( $themeName == 'eduma' ) { |
| 107 | wp_dequeue_script('thim-main'); |
| 108 | wp_dequeue_script('thim-custom-script'); |
| 109 | } |
| 110 | |
| 111 | // Remove Auxin Shop CSS if Auxin Shop is active |
| 112 | if(is_plugin_active('auxin-shop/auxin-shop.php')) { |
| 113 | |
| 114 | wp_dequeue_style('auxin-shop'); |
| 115 | |
| 116 | } if ($themeName == 'phlox-pro') { |
| 117 | |
| 118 | wp_dequeue_style('auxin-elementor-base'); |
| 119 | } |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | if (function_exists('wp_get_theme')) { |
| 125 | $theme = wp_get_theme(); |
| 126 | $active_theme = $theme->get('Name'); |
| 127 | |
| 128 | if($active_theme === 'PHOX' || $active_theme === 'PHOX Child') { |
| 129 | wp_dequeue_style('wdes-woocommerce'); |
| 130 | wp_dequeue_script('bootstrap'); |
| 131 | |
| 132 | } else if ( $themeName == 'woostify' ) { |
| 133 | wp_dequeue_script('woostify-woocommerce'); |
| 134 | } |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | |
| 139 | protected function template_include_pre_condition(): bool { |
| 140 | //phpcs:ignore WordPress.Security.NonceVerification.Recommended -- It's a fronted user part, not possible to verify nonce here |
| 141 | return is_product_category() || is_product_tag() || is_tax(get_object_taxonomies('product')) || (is_search() && !empty($_REQUEST['post_type']) && $_REQUEST['post_type'] == 'product'); |
| 142 | } |
| 143 | } |
| 144 |