current_theme = $theme->get( 'Name' ); $this->child_theme = $theme->get( 'Name' ); if ( $theme->parent() ) { $this->current_theme = $theme->parent()->get( 'Name' ); } } $this->includes(); //add_action('woocommerce_product_query', array( $this, 'woocommerce_product_query' ) ); if ( class_exists( 'BM' ) ) { add_action( 'aws_search_start', array( $this, 'b2b_set_filter' ) ); } // Protected categories if ( class_exists( 'WC_PPC_Util' ) && method_exists( 'WC_PPC_Util', 'showing_protected_categories' ) && method_exists( 'WC_PPC_Util', 'to_category_visibilities' ) && method_exists( 'WC_PPC_Util', 'get_product_categories' ) ) { add_action( 'aws_search_start', array( $this, 'wc_ppc_set_filter' ) ); } if ( function_exists( 'dfrapi_currency_code_to_sign' ) ) { add_filter( 'woocommerce_currency_symbol', array( $this, 'dfrapi_set_currency_symbol_filter' ), 10, 2 ); } // WC Marketplace - https://wc-marketplace.com/ if ( defined( 'WCMp_PLUGIN_VERSION' ) ) { add_filter( 'aws_search_data_params', array( $this, 'wc_marketplace_filter' ), 10, 3 ); add_filter( 'aws_search_pre_filter_products', array( $this, 'wc_marketplace_products_filter' ), 10, 2 ); } // Maya shop theme if ( defined( 'YIW_THEME_PATH' ) ) { add_action( 'wp_head', array( $this, 'myashop_head_action' ) ); } add_filter( 'aws_terms_exclude_product_cat', array( $this, 'filter_protected_cats_term_exclude' ) ); add_filter( 'aws_exclude_products', array( $this, 'filter_products_exclude' ) ); // Seamless integration if ( AWS()->get_settings( 'seamless' ) === 'true' ) { add_filter( 'aws_js_seamless_selectors', array( $this, 'js_seamless_selectors' ) ); add_filter( 'et_html_main_header', array( $this, 'et_html_main_header' ) ); add_filter( 'et_html_slide_header', array( $this, 'et_html_main_header' ) ); add_filter( 'generate_navigation_search_output', array( $this, 'generate_navigation_search_output' ) ); add_filter( 'et_pb_search_shortcode_output', array( $this, 'divi_builder_search_module' ) ); add_filter( 'et_pb_menu_shortcode_output', array( $this, 'divi_builder_search_module' ) ); add_filter( 'et_pb_fullwidth_menu_shortcode_output', array( $this, 'divi_builder_search_module' ) ); // Ocean wp theme if ( class_exists( 'OCEANWP_Theme_Class' ) ) { add_action( 'wp_head', array( $this, 'oceanwp_head_action' ) ); } // Avada theme if ( class_exists( 'Avada' ) ) { add_action( 'wp_head', array( $this, 'avada_head_action' ) ); } // Twenty Twenty theme if ( function_exists( 'twentytwenty_theme_support' ) ) { add_action( 'wp_head', array( $this, 'twenty_twenty_head_action' ) ); } if ( 'Jupiter' === $this->current_theme ) { add_action( 'wp_head', array( $this, 'jupiter_head_action' ) ); } if ( 'Woodmart' === $this->current_theme ) { add_action( 'wp_head', array( $this, 'woodmart_head_action' ) ); } if ( 'Astra' === $this->current_theme ) { add_filter( 'astra_get_search_form', array( $this, 'astra_markup' ), 999999 ); add_action( 'wp_head', array( $this, 'astra_head_action' ) ); } if ( 'Storefront' === $this->current_theme ) { add_action( 'wp_footer', array( $this, 'storefront_footer_action' ) ); } if ( 'Elessi Theme' === $this->current_theme ) { add_action( 'wp_head', array( $this, 'elessi_head_action' ) ); } if ( 'Walker' === $this->current_theme ) { add_action( 'wp_head', array( $this, 'walker_head_action' ) ); } if ( 'Porto' === $this->current_theme ) { add_filter( 'porto_search_form_content', array( $this, 'porto_search_form_content_filter' ) ); add_action( 'wp_head', array( $this, 'porto_head_action' ) ); } if ( 'BoxShop' === $this->current_theme ) { add_action( 'wp_head', array( $this, 'boxshop_head_action' ) ); } if ( 'Aurum' === $this->current_theme ) { add_filter( 'aurum_show_search_field_on_mobile', '__return_false' ); add_filter( 'wp_nav_menu', array( $this, 'aurum_mobile_menu' ), 10, 2 ); } if ( 'Fury' === $this->current_theme ) { add_filter( 'aws_searchbox_markup', array( $this, 'fury_searchbox_markup' ) ); add_action( 'wp_head', array( $this, 'fury_wp_head' ) ); } if ( 'Bazar' === $this->current_theme ) { add_action( 'yit_header-cart-search_after', array( $this, 'bazar_add_header_form' ) ); add_action( 'wp_head', array( $this, 'bazar_wp_head' ) ); } if ( 'Claue' === $this->current_theme ) { add_filter( 'jas_claue_header', array( $this, 'claue_header' ) ); add_action( 'wp_head', array( $this, 'claue_wp_head' ) ); } if ( 'Salient' === $this->current_theme ) { add_action( 'wp_head', array( $this, 'salient_wp_head' ) ); } } add_action( 'wp_head', array( $this, 'head_js_integration' ) ); // Wholesale plugin hide certain products if ( class_exists( 'WooCommerceWholeSalePrices' ) ) { add_filter( 'aws_search_results_products', array( $this, 'wholesale_hide_products' ) ); } // Ultimate Member plugin hide certain products if ( class_exists( 'UM_Functions' ) ) { add_filter( 'aws_search_results_products', array( $this, 'um_hide_products' ) ); } // Search Exclude plugin if ( class_exists( 'SearchExclude' ) ) { add_filter( 'aws_index_product_ids', array( $this, 'search_exclude_filter' ) ); } // WooCommerce Product Table plugin if ( class_exists( 'WC_Product_Table_Plugin' ) ) { add_filter( 'wc_product_table_data_config', array( $this, 'wc_product_table_data_config' ) ); add_filter( 'aws_posts_per_page', array( $this, 'wc_product_table_posts_per_page' ) ); } // Flatsome theme remove search page blocl if ( isset( $_GET['type_aws'] ) && function_exists( 'flatsome_pages_in_search_results' ) ) { remove_action('woocommerce_after_main_content','flatsome_pages_in_search_results', 10); } // Divi builder dynamic text shortcodes if ( defined( 'ET_BUILDER_PLUGIN_DIR' ) ) { add_filter( 'aws_before_strip_shortcodes', array( $this, 'divi_builder_strip_shortcodes' ) ); } // WP all import finish add_action( 'pmxi_after_xml_import', array( $this, 'pmxi_after_xml_import' ) ); // BeRocket WooCommerce AJAX Products Filter if ( defined( 'BeRocket_AJAX_filters_version' ) ) { add_filter( 'aws_search_page_filters', array( $this, 'berocket_search_page_filters' ) ); } // Product Sort and Display for WooCommerce plugin if ( defined( 'WC_PSAD_NAME' ) ) { add_filter( "option_psad_shop_page_enable", array( $this, 'psad_filter' ) ); } if ( 'Avada' === $this->current_theme ) { add_filter( 'aws_posts_per_page', array( $this, 'avada_posts_per_page' ), 1 ); add_filter( 'aws_products_order_by', array( $this, 'avada_aws_products_order_by' ), 1 ); add_filter( 'post_class', array( $this, 'avada_post_class' ) ); } if ( 'Electro' === $this->current_theme ) { add_filter( 'aws_searchbox_markup', array( $this, 'electro_searchbox_markup' ), 1, 2 ); } // FacetWP plugin if ( class_exists( 'FacetWP' ) ) { add_filter( 'facetwp_filtered_post_ids', array( $this, 'facetwp_filtered_post_ids' ), 1 ); add_filter( 'aws_searchpage_enabled', array( $this, 'facetwp_aws_searchpage_enabled' ), 1 ); } // Product Visibility by User Role for WooCommerce plugin if ( class_exists( 'Alg_WC_PVBUR' ) ) { add_filter( 'aws_search_results_products', array( $this, 'pvbur_aws_search_results_products' ), 1 ); } // WooCommerce Product Filter by WooBeWoo if ( defined( 'WPF_PLUG_NAME' ) ) { add_filter( 'wpf_addHtmlBeforeFilter', array( $this, 'wpf_add_html_before_filter' ) ); add_filter( 'aws_search_page_custom_data', array( $this, 'wpf_search_page_custom_data' ) ); add_filter( 'aws_search_page_filters', array( $this, 'wpf_search_page_filters' ) ); } // ATUM Inventory Management for WooCommerce plugin ( Product level addon ) if ( class_exists( 'AtumProductLevelsAddon' ) ) { add_filter( 'aws_indexed_data', array( $this, 'atum_index_data' ), 10, 2 ); } // Popups for Divi plugin if ( defined( 'DIVI_POPUP_PLUGIN' ) ) { add_action( 'wp_enqueue_scripts', array( $this, 'divi_popups_enqueue_scripts' ), 999 ); } // WooCommerce Catalog Visibility Options plugin if ( class_exists( 'WC_Catalog_Restrictions_Query' ) ) { add_filter( 'aws_exclude_products', array( $this, 'wcvo_exclude_products' ), 1 ); } } /** * Include files */ public function includes() { // Getenberg block if ( function_exists( 'register_block_type' ) ) { include_once( AWS_DIR . '/includes/modules/gutenberg/class-aws-gutenberg-init.php' ); } // Elementor plugin widget if ( defined( 'ELEMENTOR_VERSION' ) || defined( 'ELEMENTOR_PRO_VERSION' ) ) { include_once( AWS_DIR . '/includes/modules/elementor-widget/class-elementor-aws-init.php' ); } // Divi module if ( defined( 'ET_BUILDER_PLUGIN_DIR' ) || function_exists( 'et_setup_theme' ) ) { include_once( AWS_DIR . '/includes/modules/divi/class-divi-aws-module.php' ); } // Beaver builder module if ( class_exists( 'FLBuilder' ) ) { include_once( AWS_DIR . '/includes/modules/bb-aws-search/class-aws-bb-module.php' ); } // WCFM - WooCommerce Multivendor Marketplace if ( class_exists( 'WCFMmp' ) ) { include_once( AWS_DIR . '/includes/modules/class-aws-wcfm.php' ); AWS_WCFM::instance(); } // WOOF - WooCommerce Products Filter if ( defined( 'WOOF_PLUGIN_NAME' ) ) { include_once( AWS_DIR . '/includes/modules/class-aws-woof-filter.php' ); } } /* * B2B market plugin */ public function b2b_set_filter() { $args = array( 'posts_per_page' => - 1, 'post_type' => 'customer_groups', 'post_status' => 'publish', ); $posts = get_posts( $args ); $customer_groups = array(); $user_role = ''; foreach ( $posts as $customer_group ) { $customer_groups[$customer_group->post_name] = $customer_group->ID; } if ( is_user_logged_in() ) { $user = wp_get_current_user(); $role = ( array ) $user->roles; $user_role = $role[0]; } else { $guest_slugs = array( 'Gast', 'Gäste', 'Guest', 'Guests', 'gast', 'gäste', 'guest', 'guests' ); foreach( $customer_groups as $customer_group_key => $customer_group_id ) { if ( in_array( $customer_group_key, $guest_slugs ) ) { $user_role = $customer_group_key; } } } if ( $user_role ) { if ( isset( $customer_groups[$user_role] ) ) { $curret_customer_group_id = $customer_groups[$user_role]; $whitelist = get_post_meta( $curret_customer_group_id, 'bm_conditional_all_products', true ); if ( $whitelist && $whitelist === 'off' ) { $products_to_exclude = get_post_meta( $curret_customer_group_id, 'bm_conditional_products', false ); $cats_to_exclude = get_post_meta( $curret_customer_group_id, 'bm_conditional_categories', false ); if ( $products_to_exclude && ! empty( $products_to_exclude ) ) { foreach( $products_to_exclude as $product_to_exclude ) { $this->data['exclude_products'][] = trim( $product_to_exclude, ',' ); } } if ( $cats_to_exclude && ! empty( $cats_to_exclude ) ) { foreach( $cats_to_exclude as $cat_to_exclude ) { $this->data['exclude_categories'][] = trim( $cat_to_exclude, ',' ); } } } } } } /* * Protected categories plugin */ public function wc_ppc_set_filter() { $hidden_categories = array(); $show_protected = WC_PPC_Util::showing_protected_categories(); // Get all the product categories, and check which are hidden. foreach ( WC_PPC_Util::to_category_visibilities( WC_PPC_Util::get_product_categories() ) as $category ) { if ( $category->is_private() || ( ! $show_protected && $category->is_protected() ) ) { $hidden_categories[] = $category->term_id; } } if ( $hidden_categories && ! empty( $hidden_categories ) ) { foreach( $hidden_categories as $hidden_category ) { $this->data['exclude_categories'][] = $hidden_category; } $args = array( 'posts_per_page' => -1, 'fields' => 'ids', 'post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => true, 'suppress_filters' => true, 'tax_query' => array( array( 'taxonomy' => 'product_cat', 'field' => 'id', 'terms' => $hidden_categories ) ) ); $exclude_products = get_posts( $args ); if ( $exclude_products && count( $exclude_products ) > 0 ) { foreach( $exclude_products as $exclude_product ) { $this->data['exclude_products'][] = $exclude_product; } } } } /* * Datafeedr WooCommerce Importer plugin */ public function dfrapi_set_currency_symbol_filter( $currency_symbol, $currency ) { global $product; if ( ! is_object( $product ) || ! isset( $product ) ) { return $currency_symbol; } $fields = get_post_meta( $product->get_id(), '_dfrps_product', true ); if ( empty( $fields ) ) { return $currency_symbol; } if ( ! isset( $fields['currency'] ) ) { return $currency_symbol; } $currency_symbol = dfrapi_currency_code_to_sign( $fields['currency'] ); return $currency_symbol; } /* * WC Marketplace plugin support */ public function wc_marketplace_filter( $data, $post_id, $product ) { $wcmp_spmv_map_id = get_post_meta( $post_id, '_wcmp_spmv_map_id', true ); if ( $wcmp_spmv_map_id ) { if ( isset( $data['wcmp_price'] ) && isset( $data['wcmp_price'][$wcmp_spmv_map_id] ) ) { if ( $product->get_price() < $data['wcmp_price'][$wcmp_spmv_map_id] ) { $data['wcmp_price'][$wcmp_spmv_map_id] = $product->get_price(); $data['wcmp_lowest_price_id'][$wcmp_spmv_map_id] = $post_id; } } else { $data['wcmp_price'][$wcmp_spmv_map_id] = $product->get_price(); } $data['wcmp_spmv_product_id'][$wcmp_spmv_map_id][] = $post_id; } return $data; } /* * WC Marketplace plugin products filter */ public function wc_marketplace_products_filter( $products_array, $data ) { $wcmp_spmv_exclude_ids = array(); if ( isset( $data['wcmp_spmv_product_id'] ) ) { foreach( $data['wcmp_spmv_product_id'] as $wcmp_spmv_map_id => $wcmp_spmv_product_id ) { if ( count( $wcmp_spmv_product_id ) > 1 ) { if ( isset( $data['wcmp_lowest_price_id'] ) && isset( $data['wcmp_lowest_price_id'][$wcmp_spmv_map_id] ) ) { foreach ( $wcmp_spmv_product_id as $wcmp_spmv_product_id_n ) { if ( $wcmp_spmv_product_id_n === $data['wcmp_lowest_price_id'][$wcmp_spmv_map_id] ) { continue; } $wcmp_spmv_exclude_ids[] = $wcmp_spmv_product_id_n; } } else { foreach ( $wcmp_spmv_product_id as $key => $wcmp_spmv_product_id_n ) { if ( $key === 0 ) { continue; } $wcmp_spmv_exclude_ids[] = $wcmp_spmv_product_id_n; } } } } } $new_product_array = array(); foreach( $products_array as $key => $pr_arr ) { if ( ! in_array( $pr_arr['id'], $wcmp_spmv_exclude_ids ) ) { $new_product_array[] = $pr_arr; } } return $new_product_array; } /* * Maya shop theme support */ public function myashop_head_action() { ?> )/i'; $form = aws_get_search_form(false); if ( strpos( $output, 'aws-container' ) !== false ) { $pattern = '/(