theme-hooks.php
766 lines
| 1 | <?php |
| 2 | |
| 3 | namespace ShopEngine\Compatibility\Conflicts; |
| 4 | |
| 5 | |
| 6 | use ShopEngine\Traits\Singleton; |
| 7 | |
| 8 | class Theme_Hooks { |
| 9 | |
| 10 | use Singleton; |
| 11 | |
| 12 | public function force_load_woocommerce_css($styles) { |
| 13 | |
| 14 | if(!isset($styles['woocommerce-layout'])) { |
| 15 | |
| 16 | $styles['woocommerce-layout'] = [ |
| 17 | 'src' => WC()->plugin_url() . '/assets/css/woocommerce-layout.css', |
| 18 | 'deps' => '', |
| 19 | 'version' => \Automattic\Jetpack\Constants::get_constant('WC_VERSION'), |
| 20 | 'media' => 'all', |
| 21 | 'has_rtl' => true, |
| 22 | ]; |
| 23 | } |
| 24 | |
| 25 | |
| 26 | if(!isset($styles['woocommerce-general'])) { |
| 27 | |
| 28 | $styles['woocommerce-general'] = [ |
| 29 | 'src' => WC()->plugin_url() . '/assets/css/woocommerce.css', |
| 30 | 'deps' => '', |
| 31 | 'version' => \Automattic\Jetpack\Constants::get_constant('WC_VERSION'), |
| 32 | 'media' => 'all', |
| 33 | 'has_rtl' => true, |
| 34 | ]; |
| 35 | } |
| 36 | |
| 37 | |
| 38 | return $styles; |
| 39 | } |
| 40 | |
| 41 | |
| 42 | public function theme__conflicts__shop_and_archive() { |
| 43 | |
| 44 | /******************************************************* |
| 45 | * Astra theme hook reverting... |
| 46 | * |
| 47 | ******************************************************/ |
| 48 | |
| 49 | if(has_action('woocommerce_before_main_content', 'woocommerce_output_content_wrapper') === false) { |
| 50 | add_action('woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10); |
| 51 | } |
| 52 | |
| 53 | if(has_action('woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end') === false) { |
| 54 | add_action('woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10); |
| 55 | } |
| 56 | |
| 57 | if(has_action('woocommerce_sidebar', 'woocommerce_get_sidebar') === false) { |
| 58 | add_action('woocommerce_sidebar', 'woocommerce_get_sidebar', 10); |
| 59 | } |
| 60 | |
| 61 | if(has_action('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating') === false) { |
| 62 | add_action('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5); |
| 63 | } |
| 64 | |
| 65 | if(has_action('woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title') === false) { |
| 66 | add_action('woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10); |
| 67 | } |
| 68 | |
| 69 | if(has_action('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price') === false) { |
| 70 | add_action('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10); |
| 71 | } |
| 72 | |
| 73 | if(has_action('woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash') === false) { |
| 74 | add_action('woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10); |
| 75 | } |
| 76 | |
| 77 | if(has_action('woocommerce_before_shop_loop_item', 'astra_woo_shop_thumbnail_wrap_start') !== false) { |
| 78 | remove_action('woocommerce_before_shop_loop_item', 'astra_woo_shop_thumbnail_wrap_start', 6); |
| 79 | } |
| 80 | |
| 81 | if(has_action('woocommerce_before_shop_loop_item', 'woocommerce_show_product_loop_sale_flash') !== false) { |
| 82 | remove_action('woocommerce_before_shop_loop_item', 'woocommerce_show_product_loop_sale_flash', 9); |
| 83 | } |
| 84 | |
| 85 | if(has_action('woocommerce_after_shop_loop_item', 'astra_woo_shop_thumbnail_wrap_end') !== false) { |
| 86 | remove_action('woocommerce_after_shop_loop_item', 'astra_woo_shop_thumbnail_wrap_end', 8); |
| 87 | } |
| 88 | |
| 89 | if(has_action('woocommerce_shop_loop_item_title', 'astra_woo_shop_out_of_stock') !== false) { |
| 90 | remove_action('woocommerce_shop_loop_item_title', 'astra_woo_shop_out_of_stock', 8); |
| 91 | } |
| 92 | |
| 93 | if(has_action('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart') === false) { |
| 94 | add_action('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10); |
| 95 | } |
| 96 | |
| 97 | if(has_action('woocommerce_after_shop_loop_item', 'astra_woo_woocommerce_shop_product_content') !== false) { |
| 98 | remove_action('woocommerce_after_shop_loop_item', 'astra_woo_woocommerce_shop_product_content'); |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * End of astra theme hook reverting |
| 103 | ******************************************************/ |
| 104 | |
| 105 | |
| 106 | /******************************************************* |
| 107 | * Hestia theme hook reverting... |
| 108 | * |
| 109 | ******************************************************/ |
| 110 | $this->remove_action_if_exists('woocommerce_before_shop_loop_item_title', 'hestia_woocommerce_template_loop_product_thumbnail', 10); |
| 111 | $this->remove_action_if_exists('woocommerce_before_shop_loop_item', 'hestia_woocommerce_before_shop_loop_item', 10); |
| 112 | $this->remove_action_if_exists('woocommerce_after_shop_loop_item', 'hestia_woocommerce_after_shop_loop_item', 20); |
| 113 | $this->remove_action_if_exists('woocommerce_shop_loop_item_title', 'hestia_woocommerce_template_loop_product_title', 10); |
| 114 | |
| 115 | |
| 116 | if(has_action('woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail') === false) { |
| 117 | add_action('woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10); |
| 118 | } |
| 119 | |
| 120 | if(has_action('woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open') === false) { |
| 121 | add_action('woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open', 10); |
| 122 | } |
| 123 | |
| 124 | if(has_action('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_product_link_close') === false) { |
| 125 | add_action('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_product_link_close', 5); |
| 126 | } |
| 127 | |
| 128 | if(has_action('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart') === false) { |
| 129 | add_action('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10); |
| 130 | } |
| 131 | |
| 132 | if(has_action('woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title') === false) { |
| 133 | add_action('woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10); |
| 134 | } |
| 135 | |
| 136 | if(has_action('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating') === false) { |
| 137 | add_action('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5); |
| 138 | } |
| 139 | |
| 140 | if(has_action('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price') === false) { |
| 141 | add_action('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10); |
| 142 | } |
| 143 | |
| 144 | /** |
| 145 | * End of hestia theme hook reverting |
| 146 | ******************************************************/ |
| 147 | |
| 148 | |
| 149 | /******************************************************* |
| 150 | * Flatsome theme hook reverting... |
| 151 | * |
| 152 | ******************************************************/ |
| 153 | |
| 154 | if(has_action('woocommerce_shop_loop_item_title', 'flatsome_woocommerce_shop_loop_category') !== false) { |
| 155 | remove_action('woocommerce_shop_loop_item_title', 'flatsome_woocommerce_shop_loop_category', 0); |
| 156 | } |
| 157 | |
| 158 | /** |
| 159 | * End of Flatsome theme hook reverting |
| 160 | ******************************************************/ |
| 161 | |
| 162 | |
| 163 | /******************************************************* |
| 164 | * Woodmart theme hook reverting... |
| 165 | * |
| 166 | ******************************************************/ |
| 167 | |
| 168 | if(has_action('woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail') === false) { |
| 169 | add_action('woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail'); |
| 170 | } |
| 171 | |
| 172 | if(has_action('woocommerce_before_shop_loop_item_title', 'woodmart_template_loop_product_thumbnail') !== false) { |
| 173 | remove_action('woocommerce_before_shop_loop_item_title', 'woodmart_template_loop_product_thumbnail', 10); |
| 174 | } |
| 175 | |
| 176 | /** |
| 177 | * End of Woodmart theme hook reverting |
| 178 | ******************************************************/ |
| 179 | |
| 180 | |
| 181 | /******************************************************* |
| 182 | * OceanWP theme hook reverting... |
| 183 | * |
| 184 | ******************************************************/ |
| 185 | |
| 186 | $this->remove_action_if_found_14('woocommerce_before_shop_loop', '\OceanWP_WooCommerce_Config', 'add_shop_loop_div'); |
| 187 | $this->remove_action_if_found_14('woocommerce_before_shop_loop', '\OceanWP_WooCommerce_Config', 'close_shop_loop_div'); |
| 188 | $this->remove_action_if_found_14('woocommerce_before_shop_loop', '\OceanWP_WooCommerce_Config', 'grid_list_buttons'); |
| 189 | $this->remove_action_if_found_14('woocommerce_before_shop_loop', '\OceanWP_WooCommerce_Config', 'result_count'); |
| 190 | |
| 191 | $this->add_action_if_not_exists('woocommerce_before_shop_loop', 'woocommerce_result_count'); |
| 192 | |
| 193 | $this->remove_action_if_found_14('woocommerce_before_shop_loop_item', '\OceanWP_WooCommerce_Config', 'add_shop_loop_item_inner_div'); |
| 194 | $this->remove_action_if_found_14('woocommerce_after_shop_loop_item', '\OceanWP_WooCommerce_Config', 'close_shop_loop_item_inner_div'); |
| 195 | $this->remove_action_if_found_14('woocommerce_before_shop_loop_item_title', '\OceanWP_WooCommerce_Config', 'loop_product_thumbnail'); |
| 196 | $this->remove_action_if_found_14('woocommerce_after_shop_loop_item', '\OceanWP_WooCommerce_Config', 'archive_product_content'); |
| 197 | |
| 198 | /** |
| 199 | * End of OceanWP theme hook reverting |
| 200 | ******************************************************/ |
| 201 | |
| 202 | |
| 203 | /******************************************************* |
| 204 | * Porto theme hook reverting... |
| 205 | * |
| 206 | ******************************************************/ |
| 207 | |
| 208 | if(has_action('woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail') !== false) { |
| 209 | remove_action('woocommerce_before_shop_loop_item_title', 'porto_loop_product_thumbnail', 10); |
| 210 | } |
| 211 | |
| 212 | if(has_action('woocommerce_shop_loop_item_title', 'porto_woocommerce_shop_loop_item_title_open') !== false) { |
| 213 | remove_action('woocommerce_shop_loop_item_title', 'porto_woocommerce_shop_loop_item_title_open', 1); |
| 214 | |
| 215 | } |
| 216 | |
| 217 | if(has_action('woocommerce_shop_loop_item_title', 'porto_woocommerce_shop_loop_item_title_close') !== false) { |
| 218 | remove_action('woocommerce_shop_loop_item_title', 'porto_woocommerce_shop_loop_item_title_close', 100); |
| 219 | } |
| 220 | |
| 221 | if(has_action('woocommerce_shop_loop_item_title', 'porto_woocommerce_shop_loop_item_title') !== false) { |
| 222 | remove_action('woocommerce_shop_loop_item_title', 'porto_woocommerce_shop_loop_item_title'); |
| 223 | } |
| 224 | |
| 225 | if(has_action('woocommerce_before_shop_loop', 'woocommerce_pagination') !== false) { |
| 226 | remove_action('woocommerce_before_shop_loop', 'woocommerce_pagination', 50); |
| 227 | } |
| 228 | |
| 229 | if(has_action('woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail') === false) { |
| 230 | add_action('woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10); |
| 231 | } |
| 232 | } |
| 233 | |
| 234 | |
| 235 | public function theme__conflicts__single_page() { |
| 236 | |
| 237 | |
| 238 | /** |
| 239 | * Woodmart theme dequeueing this so we are enqueueing again. |
| 240 | */ |
| 241 | wp_enqueue_script('flexslider'); |
| 242 | |
| 243 | |
| 244 | /******************************************************* |
| 245 | * Woodmart theme hook reverting... |
| 246 | * |
| 247 | ******************************************************/ |
| 248 | |
| 249 | if(has_action('woocommerce_before_shop_loop_item_title', 'woodmart_template_loop_product_thumbnail') !== false) { |
| 250 | remove_action('woocommerce_before_shop_loop_item_title', 'woodmart_template_loop_product_thumbnail', 10); |
| 251 | } |
| 252 | |
| 253 | if(has_action('woocommerce_sale_flash', 'woodmart_product_label') !== false) { |
| 254 | remove_filter('woocommerce_sale_flash', 'woodmart_product_label', 10); |
| 255 | } |
| 256 | |
| 257 | $this->add_action_if_not_exists('woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail'); |
| 258 | |
| 259 | /** |
| 260 | * End of Woodmart theme hook reverting |
| 261 | ******************************************************/ |
| 262 | |
| 263 | /******************************************************* |
| 264 | * Astra theme hook reverting... |
| 265 | * |
| 266 | ******************************************************/ |
| 267 | |
| 268 | if(has_action('woocommerce_before_shop_loop_item', 'astra_woo_shop_thumbnail_wrap_start') !== false) { |
| 269 | remove_action('woocommerce_before_shop_loop_item', 'astra_woo_shop_thumbnail_wrap_start', 6); |
| 270 | } |
| 271 | |
| 272 | if(has_action('woocommerce_after_shop_loop_item', 'astra_woo_shop_thumbnail_wrap_end') !== false) { |
| 273 | remove_action('woocommerce_after_shop_loop_item', 'astra_woo_shop_thumbnail_wrap_end', 8); |
| 274 | } |
| 275 | |
| 276 | if(has_action('woocommerce_after_shop_loop_item', 'astra_woo_woocommerce_shop_product_content') !== false) { |
| 277 | remove_action('woocommerce_after_shop_loop_item', 'astra_woo_woocommerce_shop_product_content'); |
| 278 | } |
| 279 | |
| 280 | if(has_action('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart') === false) { |
| 281 | |
| 282 | add_action('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart'); |
| 283 | } |
| 284 | |
| 285 | if(has_action('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating') === false) { |
| 286 | |
| 287 | add_action('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5); |
| 288 | } |
| 289 | |
| 290 | if(has_action('woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title') === false) { |
| 291 | |
| 292 | add_action('woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10); |
| 293 | } |
| 294 | |
| 295 | if(has_action('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price') === false) { |
| 296 | |
| 297 | add_action('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10); |
| 298 | } |
| 299 | |
| 300 | if(has_action('woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash') === false) { |
| 301 | |
| 302 | add_action('woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10); |
| 303 | } |
| 304 | |
| 305 | if(has_action('woocommerce_before_shop_loop_item', 'woocommerce_show_product_loop_sale_flash') !== false) { |
| 306 | |
| 307 | remove_action('woocommerce_before_shop_loop_item', 'woocommerce_show_product_loop_sale_flash', 9); |
| 308 | } |
| 309 | |
| 310 | /** |
| 311 | * End of Astra theme hook reverting |
| 312 | ******************************************************/ |
| 313 | |
| 314 | /******************************************************* |
| 315 | * Electro theme hook reverting... |
| 316 | * |
| 317 | ******************************************************/ |
| 318 | |
| 319 | if(has_filter('woocommerce_sale_flash', 'electro_get_sale_flash') !== false) { |
| 320 | remove_filter('woocommerce_sale_flash', 'electro_get_sale_flash', 20); |
| 321 | } |
| 322 | |
| 323 | if(has_filter('woocommerce_loop_add_to_cart_link', 'electro_wrap_add_to_cart_link') !== false) { |
| 324 | remove_filter('woocommerce_loop_add_to_cart_link', 'electro_wrap_add_to_cart_link', 90); |
| 325 | } |
| 326 | |
| 327 | $this->add_action_if_not_exists('woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open', 10); |
| 328 | |
| 329 | $this->remove_action_if_exists('woocommerce_before_shop_loop_item', 'electro_wrap_product_inner'); |
| 330 | |
| 331 | $this->add_action_if_not_exists('woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open', 10); |
| 332 | $this->add_action_if_not_exists('woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10); |
| 333 | $this->add_action_if_not_exists('woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10); |
| 334 | $this->add_action_if_not_exists('woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10); |
| 335 | $this->add_action_if_not_exists('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5); |
| 336 | $this->add_action_if_not_exists('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10); |
| 337 | $this->add_action_if_not_exists('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_product_link_close', 5); |
| 338 | $this->add_action_if_not_exists('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10); |
| 339 | |
| 340 | $this->remove_action_if_exists('electro_product_item_hover_area', 'electro_loop_action_buttons', 10); |
| 341 | $this->remove_action_if_exists('woocommerce_before_shop_loop_item', 'electro_wrap_product_outer', 0); |
| 342 | $this->remove_action_if_exists('woocommerce_before_shop_loop_item', 'electro_wrap_product_inner', 10); |
| 343 | $this->remove_action_if_exists('woocommerce_before_shop_loop_item_title', 'electro_template_loop_header_open', 15); |
| 344 | $this->remove_action_if_exists('woocommerce_before_shop_loop_item_title', 'electro_template_loop_categories', 20); |
| 345 | $this->remove_action_if_exists('woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_link_open', 25); |
| 346 | $this->remove_action_if_exists('woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 30); |
| 347 | $this->remove_action_if_exists('woocommerce_shop_loop_item_title', 'electro_template_loop_product_thumbnail', 40); |
| 348 | $this->remove_action_if_exists('woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_link_close', 45); |
| 349 | $this->remove_action_if_exists('woocommerce_shop_loop_item_title', 'electro_template_loop_header_close', 46); |
| 350 | $this->remove_action_if_exists('woocommerce_shop_loop_item_title', 'electro_template_loop_body_open', 47); |
| 351 | $this->remove_action_if_exists('woocommerce_shop_loop_item_title', 'electro_template_loop_categories', 50); |
| 352 | $this->remove_action_if_exists('woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_link_open', 55); |
| 353 | $this->remove_action_if_exists('woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 60); |
| 354 | $this->remove_action_if_exists('woocommerce_after_shop_loop_item_title', 'electro_template_loop_rating', 70); |
| 355 | $this->remove_action_if_exists('woocommerce_after_shop_loop_item_title', 'electro_template_loop_product_excerpt', 80); |
| 356 | $this->remove_action_if_exists('woocommerce_after_shop_loop_item_title', 'electro_template_loop_product_sku', 90); |
| 357 | $this->remove_action_if_exists('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_product_link_close', 95); |
| 358 | $this->remove_action_if_exists('woocommerce_after_shop_loop_item_title', 'electro_template_loop_body_close', 96); |
| 359 | $this->remove_action_if_exists('woocommerce_after_shop_loop_item_title', 'electro_template_loop_footer_open', 98); |
| 360 | $this->remove_action_if_exists('woocommerce_after_shop_loop_item_title', 'electro_wrap_price_and_add_to_cart', 100); |
| 361 | $this->remove_action_if_exists('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 110); |
| 362 | $this->remove_action_if_exists('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_add_to_cart', 120); |
| 363 | $this->remove_action_if_exists('woocommerce_after_shop_loop_item_title', 'electro_wrap_price_and_add_to_cart_close', 130); |
| 364 | $this->remove_action_if_exists('woocommerce_after_shop_loop_item', 'electro_template_loop_hover', 140); |
| 365 | $this->remove_action_if_exists('woocommerce_after_shop_loop_item', 'electro_template_loop_footer_close', 145); |
| 366 | $this->remove_action_if_exists('woocommerce_after_shop_loop_item', 'electro_wrap_product_inner_close', 150); |
| 367 | $this->remove_action_if_exists('woocommerce_after_shop_loop_item', 'electro_wrap_product_outer_close', 160); |
| 368 | $this->remove_action_if_exists('woocommerce_after_shop_loop_item', 'electro_wrap_product_outer_close', 160); |
| 369 | |
| 370 | /** |
| 371 | * End of Electro theme hook reverting |
| 372 | ******************************************************/ |
| 373 | |
| 374 | |
| 375 | /******************************************************* |
| 376 | * flatsome theme hook reverting... |
| 377 | * |
| 378 | ******************************************************/ |
| 379 | |
| 380 | $this->remove_action_if_exists('woocommerce_shop_loop_item_title', 'flatsome_woocommerce_shop_loop_category', 0); |
| 381 | $this->remove_action_if_exists('woocommerce_before_shop_loop_item', 'woocommerce_show_product_loop_sale_flash'); |
| 382 | |
| 383 | $this->add_action_if_not_exists('woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open'); |
| 384 | $this->add_action_if_not_exists('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_product_link_close'); |
| 385 | $this->add_action_if_not_exists('woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash'); |
| 386 | |
| 387 | |
| 388 | /** |
| 389 | * End of flatsome theme hook reverting |
| 390 | ******************************************************/ |
| 391 | |
| 392 | |
| 393 | /******************************************************* |
| 394 | * Porto theme hook reverting... |
| 395 | * |
| 396 | ******************************************************/ |
| 397 | |
| 398 | if(has_action('woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail') !== false) { |
| 399 | remove_action('woocommerce_before_shop_loop_item_title', 'porto_loop_product_thumbnail', 10); |
| 400 | } |
| 401 | |
| 402 | if(has_action('woocommerce_shop_loop_item_title', 'porto_woocommerce_shop_loop_item_title_open') !== false) { |
| 403 | remove_action('woocommerce_shop_loop_item_title', 'porto_woocommerce_shop_loop_item_title_open', 1); |
| 404 | |
| 405 | } |
| 406 | |
| 407 | if(has_action('woocommerce_shop_loop_item_title', 'porto_woocommerce_shop_loop_item_title_close') !== false) { |
| 408 | remove_action('woocommerce_shop_loop_item_title', 'porto_woocommerce_shop_loop_item_title_close', 100); |
| 409 | } |
| 410 | |
| 411 | if(has_action('woocommerce_shop_loop_item_title', 'porto_woocommerce_shop_loop_item_title') !== false) { |
| 412 | remove_action('woocommerce_shop_loop_item_title', 'porto_woocommerce_shop_loop_item_title'); |
| 413 | } |
| 414 | |
| 415 | if(has_action('woocommerce_before_shop_loop', 'woocommerce_pagination') !== false) { |
| 416 | remove_action('woocommerce_before_shop_loop', 'woocommerce_pagination', 50); |
| 417 | } |
| 418 | |
| 419 | if(has_action('woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail') === false) { |
| 420 | add_action('woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10); |
| 421 | } |
| 422 | |
| 423 | /** |
| 424 | * End of porto theme hook reverting |
| 425 | ******************************************************/ |
| 426 | |
| 427 | |
| 428 | /******************************************************* |
| 429 | * Neve theme hook reverting... |
| 430 | * |
| 431 | ******************************************************/ |
| 432 | |
| 433 | $this->remove_action_if_found_14('woocommerce_before_shop_loop_item', '\Neve\Views\Product_Layout', 'card_content_wrapper'); |
| 434 | $this->remove_action_if_found_14('woocommerce_after_shop_loop_item', '\Neve\Views\Product_Layout', 'wrapper_close_div'); |
| 435 | |
| 436 | $this->remove_action_if_found_14('woocommerce_before_shop_loop_item_title', '\Neve\Views\Product_Layout', 'product_image_wrap'); |
| 437 | $this->remove_action_if_found_14('woocommerce_before_shop_loop_item_title', '\Neve\Views\Product_Layout', 'out_of_stock_badge'); |
| 438 | $this->remove_action_if_found_14('woocommerce_before_shop_loop_item_title', '\Neve\Views\Product_Layout', 'wrapper_close_div'); |
| 439 | |
| 440 | |
| 441 | /** |
| 442 | * End of Neve theme hook reverting |
| 443 | ******************************************************/ |
| 444 | |
| 445 | |
| 446 | /******************************************************* |
| 447 | * xStore theme hook reverting... |
| 448 | * |
| 449 | ******************************************************/ |
| 450 | |
| 451 | if(has_filter('woocommerce_sale_flash', 'etheme_woocommerce_sale_flash') !== false) { |
| 452 | remove_filter('woocommerce_sale_flash', 'etheme_woocommerce_sale_flash', 20); |
| 453 | } |
| 454 | |
| 455 | /** |
| 456 | * End of xStore theme hook reverting |
| 457 | ******************************************************/ |
| 458 | |
| 459 | |
| 460 | /******************************************************* |
| 461 | * Storefront theme hook reverting... |
| 462 | * |
| 463 | ******************************************************/ |
| 464 | |
| 465 | $this->add_action_if_not_exists('woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10); |
| 466 | $this->remove_action_if_exists('woocommerce_after_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 6); |
| 467 | |
| 468 | /** |
| 469 | * End of Storefront theme hook reverting |
| 470 | ******************************************************/ |
| 471 | |
| 472 | |
| 473 | /******************************************************* |
| 474 | * Hestia theme hook reverting... |
| 475 | * |
| 476 | ******************************************************/ |
| 477 | |
| 478 | $this->add_action_if_not_exists('woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10); |
| 479 | $this->remove_action_if_exists('woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 20); |
| 480 | $this->remove_action_if_exists('woocommerce_before_shop_loop_item_title', 'hestia_woocommerce_template_loop_product_thumbnail', 10); |
| 481 | $this->remove_action_if_exists('woocommerce_before_shop_loop_item', 'hestia_woocommerce_before_shop_loop_item', 10); |
| 482 | $this->remove_action_if_exists('woocommerce_after_shop_loop_item', 'hestia_woocommerce_after_shop_loop_item', 20); |
| 483 | $this->remove_action_if_exists('woocommerce_shop_loop_item_title', 'hestia_woocommerce_template_loop_product_title', 10); |
| 484 | $this->add_action_if_not_exists('woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10); |
| 485 | $this->add_action_if_not_exists('woocommerce_before_shop_loop_item', 'woocommerce_template_loop_product_link_open', 10); |
| 486 | $this->add_action_if_not_exists('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_product_link_close', 5); |
| 487 | $this->add_action_if_not_exists('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10); |
| 488 | $this->add_action_if_not_exists('woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10); |
| 489 | $this->add_action_if_not_exists('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5); |
| 490 | $this->add_action_if_not_exists('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10); |
| 491 | $this->add_action_if_not_exists('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10); |
| 492 | |
| 493 | /** |
| 494 | * End of hestia theme hook reverting |
| 495 | ******************************************************/ |
| 496 | |
| 497 | /******************************************************* |
| 498 | * OceanWP theme hook reverting... |
| 499 | * |
| 500 | ******************************************************/ |
| 501 | |
| 502 | $this->remove_action_if_found_14('woocommerce_before_shop_loop_item_title', '\OceanWP_WooCommerce_Config', 'loop_product_thumbnail'); |
| 503 | $this->remove_action_if_found_14('woocommerce_before_shop_loop_item', '\OceanWP_WooCommerce_Config', 'add_shop_loop_item_inner_div'); |
| 504 | $this->remove_action_if_found_14('woocommerce_after_shop_loop_item', '\OceanWP_WooCommerce_Config', 'archive_product_content'); |
| 505 | $this->remove_action_if_found_14('woocommerce_after_shop_loop_item', '\OceanWP_WooCommerce_Config', 'close_shop_loop_item_inner_div'); |
| 506 | |
| 507 | /** |
| 508 | * End of hestia theme hook reverting |
| 509 | ******************************************************/ |
| 510 | |
| 511 | } |
| 512 | |
| 513 | |
| 514 | public function theme_conflicts_cart_page(){ |
| 515 | // common |
| 516 | $this->add_action_if_not_exists( 'woocommerce_before_shop_loop_item','woocommerce_template_loop_product_link_open', 10); |
| 517 | $this->add_action_if_not_exists( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10); |
| 518 | $this->add_action_if_not_exists( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10); |
| 519 | $this->add_action_if_not_exists( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10); |
| 520 | $this->add_action_if_not_exists( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10); |
| 521 | |
| 522 | /******************************************************* |
| 523 | * OceanWP theme cart page hook for cross-sell reverting... |
| 524 | * |
| 525 | ******************************************************/ |
| 526 | |
| 527 | $this->remove_action_if_found_14('ocean_after_product_entry_slider', '\OceanWP_WooCommerce_Config', 'quick_view_button'); |
| 528 | $this->remove_action_if_found_14('ocean_after_product_entry_image', '\OceanWP_WooCommerce_Config', 'quick_view_button'); |
| 529 | $this->remove_action_if_found_14('woocommerce_before_shop_loop_item_title', '\OceanWP_WooCommerce_Config', 'loop_product_thumbnail'); |
| 530 | $this->remove_action_if_found_14('woocommerce_after_shop_loop_item', '\OceanWP_WooCommerce_Config', 'archive_product_content'); |
| 531 | $this->remove_action_if_found_14('woocommerce_before_shop_loop_item', '\OceanWP_WooCommerce_Config', 'add_shop_loop_item_inner_div'); |
| 532 | $this->remove_action_if_found_14('woocommerce_after_shop_loop_item', '\OceanWP_WooCommerce_Config', 'close_shop_loop_item_inner_div'); |
| 533 | |
| 534 | |
| 535 | /** |
| 536 | * End of OceanWP theme hook reverting |
| 537 | ******************************************************/ |
| 538 | |
| 539 | /******************************************************* |
| 540 | * Astra theme cart page hook for cross-sell reverting... |
| 541 | *******************************************************/ |
| 542 | |
| 543 | $this->remove_action_if_exists( 'woocommerce_before_shop_loop_item', 'astra_woo_shop_thumbnail_wrap_start', 6); |
| 544 | $this->remove_action_if_exists( 'woocommerce_after_shop_loop_item', 'astra_woo_shop_thumbnail_wrap_end', 8); |
| 545 | $this->remove_action_if_exists( 'woocommerce_after_shop_loop_item', 'astra_woo_woocommerce_shop_product_content' ); |
| 546 | |
| 547 | /** |
| 548 | * End of Astra theme hook reverting |
| 549 | ******************************************************/ |
| 550 | |
| 551 | /******************************************************* |
| 552 | * Hestia theme cart page hook for cross-sell reverting... |
| 553 | *******************************************************/ |
| 554 | |
| 555 | $this->remove_action_if_exists( 'woocommerce_before_shop_loop_item_title', 'hestia_woocommerce_template_loop_product_thumbnail', 10 ); |
| 556 | $this->remove_action_if_exists( 'woocommerce_before_shop_loop_item', 'hestia_woocommerce_before_shop_loop_item', 10 ); |
| 557 | $this->remove_action_if_exists( 'woocommerce_after_shop_loop_item', 'hestia_woocommerce_after_shop_loop_item', 20 ); |
| 558 | $this->remove_action_if_exists( 'woocommerce_shop_loop_item_title', 'hestia_woocommerce_template_loop_product_title', 10 ); |
| 559 | |
| 560 | /** |
| 561 | * End of Hestia theme hook reverting |
| 562 | ******************************************************/ |
| 563 | |
| 564 | } |
| 565 | |
| 566 | |
| 567 | |
| 568 | public function theme_conflicts_in_elementor_editor(){ |
| 569 | |
| 570 | /******************************************************* |
| 571 | * OceanWP theme cart page hook for cross-sell reverting... |
| 572 | * |
| 573 | ******************************************************/ |
| 574 | |
| 575 | |
| 576 | $this->add_action_if_not_exists( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 ); |
| 577 | $this->add_action_if_not_exists( 'woocommerce_after_single_product_summary', 'woocommerce_upsell_display', 15 ); |
| 578 | |
| 579 | $this->remove_action_if_found_14( 'woocommerce_before_shop_loop_item','\OceanWP_WooCommerce_Config', 'add_shop_loop_item_inner_div' ); |
| 580 | |
| 581 | $this->remove_action_if_found_14( 'woocommerce_before_shop_loop_item_title', '\OceanWP_WooCommerce_Config', 'loop_product_thumbnail'); |
| 582 | |
| 583 | $this->remove_action_if_found_14( 'woocommerce_cart_collaterals', '\OceanWP_WooCommerce_Config', 'cross_sell_display'); |
| 584 | $this->remove_action_if_found_14( 'woocommerce_after_single_product_summary', '\OceanWP_WooCommerce_Config', 'upsell_display'); |
| 585 | $this->remove_action_if_found_14( 'ocean_after_product_entry_image', '\OceanWP_WooCommerce_Config', 'quick_view_button'); |
| 586 | $this->remove_action_if_found_14( 'ocean_after_product_entry_slider', '\OceanWP_WooCommerce_Config', 'quick_view_button'); |
| 587 | |
| 588 | $this->remove_action_if_found_14( 'woocommerce_after_shop_loop_item', '\OceanWP_WooCommerce_Config', 'archive_product_content'); |
| 589 | $this->remove_action_if_found_14( 'woocommerce_after_shop_loop_item', '\OceanWP_WooCommerce_Config', 'close_shop_loop_item_inner_div'); |
| 590 | $this->remove_action_if_found_14( 'woocommerce_before_template_part', '\OceanWP_WooCommerce_Config', 'before_template_part'); |
| 591 | |
| 592 | // Add product thumbnail |
| 593 | //remove_action( 'woocommerce_before_shop_loop_item_title', array( \OceanWP_WooCommerce_Config::class, 'loop_product_thumbnail' ), 10 ); |
| 594 | |
| 595 | $this->add_action_if_not_exists( 'woocommerce_cart_collaterals', 'woocommerce_cross_sell_display'); |
| 596 | $this->add_action_if_not_exists( 'woocommerce_before_shop_loop_item','woocommerce_template_loop_product_link_open', 10); |
| 597 | $this->add_action_if_not_exists( 'woocommerce_after_shop_loop_item','woocommerce_template_loop_product_link_close', 5); |
| 598 | $this->add_action_if_not_exists( 'woocommerce_before_shop_loop_item_title', 'woocommerce_show_product_loop_sale_flash', 10 ); |
| 599 | $this->add_action_if_not_exists( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 ); |
| 600 | $this->add_action_if_not_exists( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10 ); |
| 601 | $this->add_action_if_not_exists( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5 ); |
| 602 | $this->add_action_if_not_exists( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 ); |
| 603 | $this->add_action_if_not_exists( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 ); |
| 604 | |
| 605 | |
| 606 | /** |
| 607 | * End of OceanWP theme hook reverting |
| 608 | ******************************************************/ |
| 609 | |
| 610 | } |
| 611 | |
| 612 | public function theme_conflicts_in_specific_footer_area() { |
| 613 | |
| 614 | $this->remove_action_if_found_14('wp_footer', '\OceanWP_WooCommerce_Config', 'get_mini_cart_sidebar'); |
| 615 | } |
| 616 | |
| 617 | /** |
| 618 | * This is a code of 14th class for some very tricky position we are |
| 619 | * It is totally possible to get wrong instance priority with this function, hence the wrong action removed but practically highly unlikely :fingercross |
| 620 | * |
| 621 | * |
| 622 | * @param $tag |
| 623 | * @param $class_name - must a full qualified class name |
| 624 | * @param $instance_method |
| 625 | * @param int $spl_hash_length - this is 32 right now [https://github.com/php/php-src/blob/82ccd47d397314d82feeb90b055625f0fcc9bde4/ext/spl/php_spl.c], or $ln = strlen(spl_object_hash( new stdClass())) |
| 626 | * @return bool|int|string |
| 627 | */ |
| 628 | private function has_filter_14($tag, $class_name, $instance_method, $spl_hash_length = 32) { |
| 629 | |
| 630 | if(has_action($tag)) { |
| 631 | |
| 632 | global $wp_filter; |
| 633 | |
| 634 | $callbacks = $wp_filter[$tag]->callbacks; |
| 635 | |
| 636 | if(!empty($callbacks)) { |
| 637 | |
| 638 | foreach($callbacks as $priority => $arr) { |
| 639 | |
| 640 | foreach($arr as $ky => $conf) { |
| 641 | |
| 642 | if(strpos($ky, $instance_method) !== false) { |
| 643 | |
| 644 | if($ky == $class_name . '::' . $instance_method) { |
| 645 | return true; |
| 646 | } |
| 647 | |
| 648 | if(isset($conf['function'][0]) && $conf['function'][0] instanceof $class_name) { |
| 649 | |
| 650 | $rem = str_replace($instance_method, '', $ky); |
| 651 | |
| 652 | return strlen($rem) == $spl_hash_length ? $priority : false; |
| 653 | } |
| 654 | } |
| 655 | } |
| 656 | } |
| 657 | } |
| 658 | } |
| 659 | |
| 660 | return false; |
| 661 | } |
| 662 | |
| 663 | /** |
| 664 | * @param $tag |
| 665 | * @param $class_name |
| 666 | * @param $instance_method |
| 667 | * @param $priority |
| 668 | * @param int $spl_hash_length |
| 669 | * @return bool |
| 670 | */ |
| 671 | private function remove_action_14($tag, $class_name, $instance_method, $priority, $spl_hash_length = 32) { |
| 672 | |
| 673 | if($priority === false) { |
| 674 | return false; |
| 675 | } |
| 676 | |
| 677 | global $wp_filter; |
| 678 | |
| 679 | if(!empty($wp_filter[$tag]->callbacks[$priority])) { |
| 680 | |
| 681 | foreach($wp_filter[$tag]->callbacks[$priority] as $ky => $conf) { |
| 682 | |
| 683 | if(strpos($ky, $instance_method) !== false) { |
| 684 | |
| 685 | if($ky == $class_name . '::' . $instance_method) { |
| 686 | |
| 687 | unset($wp_filter[$tag]->callbacks[$priority][$ky]); |
| 688 | |
| 689 | return true; |
| 690 | } |
| 691 | |
| 692 | $rem = str_replace($instance_method, '', $ky); |
| 693 | |
| 694 | if(strlen($rem) == $spl_hash_length) { |
| 695 | |
| 696 | unset($wp_filter[$tag]->callbacks[$priority][$ky]); |
| 697 | |
| 698 | return true; |
| 699 | } |
| 700 | } |
| 701 | } |
| 702 | } |
| 703 | |
| 704 | return false; |
| 705 | } |
| 706 | |
| 707 | /** |
| 708 | * Are you wandering about the number 14? :D, why?? |
| 709 | * Still nosy? - because this is a hacky solution for an awkward situation we are in! |
| 710 | * |
| 711 | * @param $tag |
| 712 | * @param $class_name - full qualified class name |
| 713 | * @param $instance_method |
| 714 | * @return bool |
| 715 | */ |
| 716 | private function remove_action_if_found_14($tag, $class_name, $instance_method) { |
| 717 | |
| 718 | $priority = $this->has_filter_14($tag, $class_name, $instance_method); |
| 719 | |
| 720 | |
| 721 | return $this->remove_action_14($tag, $class_name, $instance_method, $priority); |
| 722 | } |
| 723 | |
| 724 | |
| 725 | private function remove_action_if_exists($tag, $func, $priority = null) { |
| 726 | |
| 727 | if($priority === null) { |
| 728 | |
| 729 | if(has_action($tag, $func) !== false) { |
| 730 | |
| 731 | remove_action($tag, $func); |
| 732 | } |
| 733 | |
| 734 | return; |
| 735 | } |
| 736 | |
| 737 | if(has_action($tag, $func) !== false) { |
| 738 | |
| 739 | remove_action($tag, $func, intval($priority)); |
| 740 | } |
| 741 | |
| 742 | return; |
| 743 | } |
| 744 | |
| 745 | |
| 746 | private function add_action_if_not_exists($tag, $func, $priority = null) { |
| 747 | |
| 748 | if($priority === null) { |
| 749 | |
| 750 | if(has_action($tag, $func) === false) { |
| 751 | |
| 752 | add_action($tag, $func); |
| 753 | } |
| 754 | |
| 755 | return; |
| 756 | } |
| 757 | |
| 758 | if(has_action($tag, $func) === false) { |
| 759 | |
| 760 | add_action($tag, $func, intval($priority)); |
| 761 | } |
| 762 | |
| 763 | return; |
| 764 | } |
| 765 | } |
| 766 |