archive.php
1 year ago
base-content.php
2 years ago
base.php
3 years ago
cart.php
2 years ago
checkout.php
2 years ago
shop.php
4 years ago
single.php
1 year ago
archive.php
90 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 | |
| 43 | public function enqueue_css_with_conflicts_removed() { |
| 44 | |
| 45 | wp_dequeue_style('oceanwp-woocommerce'); |
| 46 | |
| 47 | |
| 48 | if(!wp_style_is('woocommerce-general', 'registered')) { |
| 49 | |
| 50 | $styles = \WC_Frontend_Scripts::get_styles(); |
| 51 | |
| 52 | if($styles) { |
| 53 | foreach($styles as $handle => $args) { |
| 54 | |
| 55 | wp_register_style($handle, $args['src'], $args['deps'], $args['version'], $args['media']); |
| 56 | } |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | wp_enqueue_style('woocommerce-general'); |
| 61 | wp_enqueue_style('woocommerce-layout'); |
| 62 | |
| 63 | //Eduma Theme Conflict Issue |
| 64 | $themeName = get_template(); |
| 65 | if ( $themeName == 'eduma' ) { |
| 66 | wp_dequeue_script('thim-main'); |
| 67 | wp_dequeue_script('thim-custom-script'); |
| 68 | } |
| 69 | |
| 70 | if (function_exists('wp_get_theme')) { |
| 71 | $theme = wp_get_theme(); |
| 72 | $active_theme = $theme->get('Name'); |
| 73 | |
| 74 | if($active_theme === 'PHOX' || $active_theme === 'PHOX Child') { |
| 75 | wp_dequeue_style('wdes-woocommerce'); |
| 76 | wp_dequeue_script('bootstrap'); |
| 77 | |
| 78 | } |
| 79 | |
| 80 | } |
| 81 | |
| 82 | } |
| 83 | |
| 84 | |
| 85 | protected function template_include_pre_condition(): bool { |
| 86 | //phpcs:ignore WordPress.Security.NonceVerification.Recommended -- It's a fronted user part, not possible to verify nonce here |
| 87 | return is_product_category() || is_product_tag() || is_tax(get_object_taxonomies('product')) || (is_search() && !empty($_REQUEST['post_type']) && $_REQUEST['post_type'] == 'product'); |
| 88 | } |
| 89 | } |
| 90 |