first commit

This commit is contained in:
2026-03-05 13:07:40 +01:00
commit 64ba0721ee
25709 changed files with 4691006 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
<?php
namespace DgoraWcas\Integrations\Plugins\Brizy;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Integration with Brizy - Page Builder
*
* Plugin URL: https://brizy.io/
* Author: Brizy.io
*/
class Brizy {
public function init() {
if ( ! defined( 'BRIZY_PRO_VERSION' ) ) {
return;
}
add_filter( 'brizy_post_loop_args', array( $this, 'overwriteSearchResults' ), 1000 );
add_filter( 'dgwt/wcas/helpers/is_search_query', array( $this, 'markQueryToProcess' ), 10, 2 );
/**
* Brizy creates several WP_Query objects, and we need to remove the restriction that only one is hooked.
*/
add_filter( 'dgwt/wcas/native/hook_query_once', '__return_false' );
}
public function overwriteSearchResults( $params ) {
$phrase = '';
if ( ! empty( $_GET['dgwt_wcas_s'] ) ) {
$phrase = $_GET['dgwt_wcas_s'];
}
if ( ! empty( $_GET['s'] ) ) {
$phrase = $_GET['s'];
}
if (
isset( $_GET['dgwt_wcas'] ) && $_GET['dgwt_wcas'] === '1' &&
isset( $_GET['post_type'] ) && $_GET['post_type'] === 'product' &&
! empty( $phrase )
) {
if ( empty( $_GET['orderby'] ) ) {
$params['orderby'] = 'relevance';
$params['order'] = 'DESC';
}
$params['s'] = $phrase;
$params['brizy_fibosearch'] = true;
}
return $params;
}
public function markQueryToProcess( $enabled, $query ) {
if ( $query->get( 'brizy_fibosearch' ) ) {
$enabled = true;
}
return $enabled;
}
}

View File

@@ -0,0 +1,90 @@
<?php
namespace DgoraWcas\Integrations\Plugins\EANForWooCommerce;
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) {
exit;
}
/**
* Integration with EAN for WooCommerce
*
* Plugin URL: https://wordpress.org/plugins/ean-for-woocommerce/
* Author: WPFactory
*/
class EANForWooCommerce
{
public function init()
{
if ( !defined( 'ALG_WC_EAN_VERSION' ) ) {
return;
}
if ( version_compare( ALG_WC_EAN_VERSION, '4.3' ) < 0 ) {
return;
}
if ( !function_exists( 'alg_wc_ean' ) ) {
return;
}
// Disable plugin hook on WP_Query.
if ( !is_admin() ) {
if ( isset( alg_wc_ean()->core->search ) && get_option( 'alg_wc_ean_frontend_search', 'no' ) === 'yes' ) {
remove_action( 'pre_get_posts', array( alg_wc_ean()->core->search, 'search' ), 10 );
if ( !dgoraAsfwFs()->is_premium() ) {
add_filter( 'dgwt/wcas/native/search_query/join', array( $this, 'searchQueryJoin' ) );
add_filter(
'dgwt/wcas/native/search_query/search_or',
array( $this, 'searchQueryOr' ),
10,
2
);
}
}
}
}
/**
* Prepare join for EAN lookup
*
* @param string $join
*
* @return string
*/
public function searchQueryJoin( $join )
{
global $wpdb ;
if ( !strpos( $join, 'dgwt_wcasmsku' ) !== false ) {
$join .= " INNER JOIN {$wpdb->postmeta} AS dgwt_wcasmean ON ( {$wpdb->posts}.ID = dgwt_wcasmean.post_id )";
}
return $join;
}
/**
* Inject EAN lookup into search query
*
* @param string $search
* @param string $like
*
* @return string
*/
public function searchQueryOr( $search, $like )
{
global $wpdb ;
$field = alg_wc_ean()->core->ean_key ?? '';
if ( empty($field) ) {
return $search;
}
if ( strpos( $search, 'dgwt_wcasmsku' ) !== false ) {
$search .= $wpdb->prepare( " OR (dgwt_wcasmsku.meta_key=%s AND dgwt_wcasmsku.meta_value LIKE %s)", $field, $like );
} else {
$search .= $wpdb->prepare( " OR (dgwt_wcasmean.meta_key=%s AND dgwt_wcasmean.meta_value LIKE %s)", $field, $like );
}
return $search;
}
}

View File

@@ -0,0 +1,49 @@
<?php
namespace DgoraWcas\Integrations\Plugins\Elementor;
use Elementor\Elements_Manager ;
use Elementor\Widgets_Manager ;
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) {
exit;
}
class Elementor
{
public function init()
{
if ( !defined( 'ELEMENTOR_PRO_VERSION' ) ) {
return;
}
if ( version_compare( ELEMENTOR_PRO_VERSION, '3.6.0' ) < 0 ) {
return;
}
add_action( 'elementor/widgets/register', [ $this, 'registerWidgets' ], 20 );
add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'editorEnqueueScripts' ] );
}
/**
* @param Widgets_Manager $widgets_manager
*
* @return void
*/
public function registerWidgets( $widgets_manager )
{
// Register "FiboSearch" widget.
$widgets_manager->register( new FiboSearchWidget() );
}
/**
* @return void
*/
public function editorEnqueueScripts()
{
wp_enqueue_style(
'fibosearch-elementor-fibosearchicon',
DGWT_WCAS_URL . 'assets/elementor-icons/style.css',
[],
DGWT_WCAS_VERSION
);
}
}

View File

@@ -0,0 +1,98 @@
<?php
namespace DgoraWcas\Integrations\Plugins\Elementor;
use Elementor\Controls_Manager;
use Elementor\Widget_Base;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* FiboSearchWidget Class
*/
class FiboSearchWidget extends Widget_Base {
public function get_name(): string {
return 'fibosearch';
}
public function get_title(): string {
return esc_html__( 'FiboSearch', 'ajax-search-for-woocommerce' );
}
public function get_icon(): string {
return 'fibosearchicon-fibosearch';
}
public function get_categories(): array {
return [ 'woocommerce-elements' ];
}
public function get_keywords(): array {
return [ 'fibo', 'search', 'fibosearch' ];
}
public function get_custom_help_url(): string {
// TODO Sprecyzować link do strony z opisem dla Elementora.
return 'https://fibosearch.com/documentation/';
}
protected function register_controls() {
$this->start_controls_section(
'content_section',
[
'label' => esc_html__( 'Appearance', 'ajax-search-for-woocommerce' ),
'tab' => Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'layout',
[
'type' => Controls_Manager::SELECT,
'label' => esc_html__( 'Layout', 'ajax-search-for-woocommerce' ),
'options' => [
'default' => esc_html__( 'Default', 'ajax-search-for-woocommerce' ),
'classic' => esc_html__( 'Search bar', 'ajax-search-for-woocommerce' ),
'icon' => esc_html__( 'Search icon', 'ajax-search-for-woocommerce' ),
'icon-flexible' => esc_html__( 'Icon on mobile, search bar on desktop', 'ajax-search-for-woocommerce' ),
'icon-flexible-inv' => esc_html__( 'Icon on desktop, search bar on mobile', 'ajax-search-for-woocommerce' ),
],
'default' => 'default',
]
);
$this->add_control(
'mobile_overlay',
[
'type' => Controls_Manager::SWITCHER,
'label' => esc_html__( 'Overlay on mobile', 'ajax-search-for-woocommerce' ),
]
);
$this->end_controls_section();
}
/**
* @return void
*/
protected function render() {
$params = '';
// Layout.
$layout = $this->get_settings_for_display( 'layout' );
if ( in_array( $layout, [ 'classic', 'icon', 'icon-flexible', 'icon-flexible-inv' ] ) ) {
$params .= ' layout="' . $layout . '"';
}
// Overlay on mobile.
$mobile_overlay = $this->get_settings_for_display( 'mobile_overlay' );
if ( $mobile_overlay === 'yes' ) {
$params .= ' mobile_overlay="1"';
}
echo do_shortcode( '[fibosearch' . $params . ']' );
}
}

View File

@@ -0,0 +1,129 @@
<?php
namespace DgoraWcas\Integrations\Plugins\FacetWP;
use DgoraWcas\Helpers ;
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) {
exit;
}
/**
* Integration with FacetWP
*
* Plugin URL: https://facetwp.com/
* Author: FacetWP, LLC
*/
class FacetWP
{
private static $engine = 'dgwt_wcas' ;
public $search_terms ;
public function init()
{
if ( !defined( 'FACETWP_VERSION' ) ) {
return;
}
if ( version_compare( FACETWP_VERSION, '3.5.5' ) < 0 ) {
return;
}
// Search page
add_filter(
'facetwp_query_args',
array( $this, 'query_args' ),
10,
2
);
add_filter(
'dgwt/wcas/search_bar/value',
array( $this, 'restore_search_phrase' ),
10,
2
);
// Search facet
add_filter( 'facetwp_facet_search_engines', array( $this, 'search_engines' ) );
add_filter(
'facetwp_facet_filter_posts',
array( $this, 'search_facet' ),
10,
2
);
}
/**
* Prevent the default WP search from running when our plugin is enabled
*/
function query_args( $args, $class )
{
if ( $class->is_search && isset( $class->http_params['get']['dgwt_wcas'] ) ) {
$this->search_terms = $args['s'];
if ( !dgoraAsfwFs()->is_premium() ) {
$products_ids = Helpers::searchProducts( $this->search_terms );
}
// Set "post__in" based on our plugin results
if ( empty($args['post__in']) ) {
$post_ids = $products_ids;
} else {
$post_ids = [];
$haystack = array_flip( $args['post__in'] );
foreach ( $products_ids as $post_id ) {
if ( isset( $haystack[$post_id] ) ) {
$post_ids[] = $post_id;
}
}
}
$args['post__in'] = ( empty($post_ids) ? [ 0 ] : $post_ids );
$args['orderby'] = 'post__in';
$args['dgwt_wcas'] = $args['s'];
unset( $args['s'] );
}
return $args;
}
/**
* Restore search phrase in search input
*
* @return string
*/
public function restore_search_phrase( $phrase, $searchInstances )
{
if ( !empty($this->search_terms) ) {
$phrase = esc_attr( $this->search_terms );
}
return $phrase;
}
/**
* Add our engine to the search facet
*/
public function search_engines( $engines )
{
$engines[self::$engine] = DGWT_WCAS_FULL_NAME;
return $engines;
}
/**
* Intercept search facets using our engine
*/
public function search_facet( $return, $params )
{
$facet = $params['facet'];
$selected_values = $params['selected_values'];
$selected_values = ( is_array( $selected_values ) ? $selected_values[0] : $selected_values );
$search_engine = ( isset( $facet['search_engine'] ) ? $facet['search_engine'] : '' );
if ( 'search' == $facet['type'] && $search_engine === self::$engine ) {
if ( empty($selected_values) ) {
return 'continue';
}
if ( !dgoraAsfwFs()->is_premium() ) {
$return = Helpers::searchProducts( $selected_values );
}
}
return $return;
}
}

View File

@@ -0,0 +1,178 @@
<?php
namespace DgoraWcas\Integrations\Plugins\JetSmartFilters;
use DgoraWcas\Helpers ;
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) {
exit;
}
/**
* Integration with JetSmartFilters
*
* Plugin URL: https://crocoblock.com/plugins/jetsmartfilters/
* Author: Crocoblock
*/
class JetSmartFilters
{
public function init()
{
if ( !function_exists( 'jet_smart_filters' ) ) {
return;
}
if ( version_compare( jet_smart_filters()->get_version(), '1.8.3' ) < 0 ) {
return;
}
// Widget: Elementor Pro Archive Products
add_filter( 'jet-smart-filters/query/final-query', array( $this, 'filter_query' ) );
add_filter(
'dgwt/wcas/helpers/is_search_query',
array( $this, 'allow_to_process_search_query' ),
10,
2
);
// Widget: JetWooBuilder Products Grid
add_filter( 'jet-woo-builder/shortcodes/jet-woo-products/final-query-args', array( $this, 'filter_query_builder_grid' ), 10 );
// Widget: JetWooBuilder Products List
add_filter(
'jet-woo-builder/shortcodes/jet-woo-products-list/query-args',
array( $this, 'filter_query_builder_list' ),
10,
2
);
add_filter( 'jet-smart-filters/filters/localized-data', array( $this, 'jet_smart_filter_settings' ), 10 );
}
/**
* Mark query arguments if they relate to product search initiated by the integrated plugin
* Widget: Elementor Pro Archive Products (epro-archive-products)
*
* @param array $query
*
* @return array
*/
public function filter_query( $query )
{
if ( isset( $_POST['action'] ) && $_POST['action'] === 'jet_smart_filters' && isset( $_POST['provider'] ) && $_POST['provider'] === 'epro-archive-products/default' && !empty($_POST['defaults']['s']) ) {
$query['run_wcas_search'] = true;
}
return $query;
}
/**
* Filter search results if the query was marked in the filter above
* Widget: Elementor Pro Archive Products (epro-archive-products)
*
* OR
*
* Filter WP_Query used by plugin to determine counters for filter values.
*
* @param bool $enable
* @param \WP_Query $query
*
* @return bool
*/
public function allow_to_process_search_query( $enable, $query )
{
if ( is_object( $query ) && is_a( $query, 'WP_Query' ) && isset( $query->query_vars['run_wcas_search'] ) ) {
$enable = true;
}
// @since 1.26.0.
if ( is_object( $query ) && is_a( $query, 'WP_Query' ) && $query->get( 'wc_query' ) === 'product_query' && isset( $query->query_vars['s'] ) && Helpers::is_running_inside_class( 'Jet_Smart_Filters_Indexer_Data', 20 ) && Helpers::isRunningInsideFunction( 'get_queried_ids', 20 ) ) {
$enable = true;
}
return $enable;
}
/**
* Filter arguments of builder's own query
* Widget: JetWooBuilder Products Grid (jet-woo-products-grid)
*
* @param $query_args
*
* @return mixed
*/
public function filter_query_builder_grid( $query_args )
{
$phrase = false;
if ( $this->is_jet_woo_products_query( $query_args, 'jet-woo-products-grid/default' ) ) {
$phrase = $_GET['s'];
} else {
if ( $this->is_jet_woo_products_ajax_query( $query_args, 'jet-woo-products-grid/default' ) ) {
$phrase = $_POST['settings']['dgwt_wcas_s'];
}
}
if ( $phrase ) {
if ( !dgoraAsfwFs()->is_premium() ) {
$query_args['post__in'] = Helpers::searchProducts( $phrase );
}
}
return $query_args;
}
/**
* Filter arguments of builder's own query
* Widget: JetWooBuilder Products List (jet-woo-products-list)
*
* @param $query_args
*
* @return mixed
*/
public function filter_query_builder_list( $query_args, $products_list_shortcode )
{
$phrase = false;
if ( $this->is_jet_woo_products_query( $query_args, 'jet-woo-products-list/default' ) ) {
$phrase = $_GET['s'];
} else {
if ( $this->is_jet_woo_products_ajax_query( $query_args, 'jet-woo-products-list/default' ) ) {
$phrase = $_POST['settings']['dgwt_wcas_s'];
}
}
if ( $phrase ) {
if ( !dgoraAsfwFs()->is_premium() ) {
$query_args['post__in'] = Helpers::searchProducts( $phrase );
}
}
return $query_args;
}
/**
* Passing the search phrase to the plugin settings
*
* Widget: JetWooBuilder Products Grid (jet-woo-products-grid)
* Widget: JetWooBuilder Products List (jet-woo-products-list)
*
* @param array $settings
*
* @return array
*/
public function jet_smart_filter_settings( $settings )
{
if ( Helpers::isProductSearchPage() ) {
if ( isset( $settings['settings']['jet-woo-products-grid']['default'] ) && !empty($_GET['s']) ) {
$settings['settings']['jet-woo-products-grid']['default']['dgwt_wcas_s'] = $_GET['s'];
}
if ( isset( $settings['settings']['jet-woo-products-list']['default'] ) && !empty($_GET['s']) ) {
$settings['settings']['jet-woo-products-list']['default']['dgwt_wcas_s'] = $_GET['s'];
}
}
return $settings;
}
private function is_jet_woo_products_query( $query_args, $type )
{
return Helpers::isProductSearchPage() && isset( $query_args['jet_smart_filters'] ) && $query_args['jet_smart_filters'] === $type;
}
private function is_jet_woo_products_ajax_query( $query_args, $type )
{
return isset( $_POST['settings']['dgwt_wcas_s'] ) && !empty($_POST['settings']['dgwt_wcas_s']) && isset( $query_args['jet_smart_filters'] ) && $query_args['jet_smart_filters'] === $type;
}
}

View File

@@ -0,0 +1,43 @@
<?php
namespace DgoraWcas\Integrations\Plugins;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
class PluginsCompatibility {
public function __construct() {
$this->loadCompatibilities();
}
/**
* Load class with compatibilities logic for current theme
*
* @return void
*/
private function loadCompatibilities() {
$directories = glob( DGWT_WCAS_DIR . 'includes/Integrations/Plugins/*', GLOB_ONLYDIR );
$directories = apply_filters('dgwt/wcas/plugins_compatibility/directories', $directories);
if ( ! empty( $directories ) && is_array( $directories ) ) {
foreach ( $directories as $dir ) {
$name = str_replace( DGWT_WCAS_DIR . 'includes/Integrations/Plugins/', '', $dir );
$filename = $name . '.php';
$file = $dir . '/' . $filename;
$class = '\\DgoraWcas\\Integrations\\Plugins\\' . $name . "\\" . $name;
if ( file_exists( $file ) && class_exists( $class ) ) {
$tmp = new $class;
$tmp->init();
}
}
}
}
}

View File

@@ -0,0 +1,90 @@
<?php
namespace DgoraWcas\Integrations\Plugins\ProductGTINForWooCommerce;
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) {
exit;
}
/**
* Integration with Product GTIN (EAN, UPC, ISBN) for WooCommerce
*
* Plugin URL: https://wordpress.org/plugins/product-gtin-ean-upc-isbn-for-woocommerce/
* Author: Emanuela Castorina
*/
class ProductGTINForWooCommerce
{
/**
* @var string EAN field key
*/
private $eanField = '_wpm_gtin_code' ;
public function init()
{
if ( !defined( 'WPM_PRODUCT_GTIN_WC_VERSION' ) ) {
return;
}
if ( version_compare( WPM_PRODUCT_GTIN_WC_VERSION, '1.1' ) < 0 ) {
return;
}
if ( !function_exists( 'wpm_product_gtin_wc' ) ) {
return;
}
// Disable plugin hook on WP_Query.
if ( !is_admin() ) {
if ( isset( wpm_product_gtin_wc()->frontend ) && get_option( 'wpm_pgw_search_by_code', 'no' ) === 'yes' ) {
remove_action( 'pre_get_posts', array( wpm_product_gtin_wc()->frontend, 'extend_product_search' ), 10 );
if ( !dgoraAsfwFs()->is_premium() ) {
add_filter( 'dgwt/wcas/native/search_query/join', array( $this, 'searchQueryJoin' ) );
add_filter(
'dgwt/wcas/native/search_query/search_or',
array( $this, 'searchQueryOr' ),
10,
2
);
}
}
}
}
/**
* Prepare join for EAN lookup
*
* @param string $join
*
* @return string
*/
public function searchQueryJoin( $join )
{
global $wpdb ;
if ( !strpos( $join, 'dgwt_wcasmsku' ) !== false ) {
$join .= " INNER JOIN {$wpdb->postmeta} AS dgwt_wcasmean ON ( {$wpdb->posts}.ID = dgwt_wcasmean.post_id )";
}
return $join;
}
/**
* Inject EAN lookup into search query
*
* @param string $search
* @param string $like
*
* @return string
*/
public function searchQueryOr( $search, $like )
{
global $wpdb ;
if ( strpos( $search, 'dgwt_wcasmsku' ) !== false ) {
$search .= $wpdb->prepare( " OR (dgwt_wcasmsku.meta_key=%s AND dgwt_wcasmsku.meta_value LIKE %s)", $this->eanField, $like );
} else {
$search .= $wpdb->prepare( " OR (dgwt_wcasmean.meta_key=%s AND dgwt_wcasmean.meta_value LIKE %s)", $this->eanField, $like );
}
return $search;
}
}

View File

@@ -0,0 +1,57 @@
<?php
namespace DgoraWcas\Integrations\Plugins\WPRocket;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Integration with WP Rocket
*
* Plugin URL: https://wp-rocket.me/
* Author: WP Media
*/
class WPRocket {
public function init() {
if ( ! defined( 'WP_ROCKET_VERSION' ) ) {
return;
}
if ( version_compare( WP_ROCKET_VERSION, '3.7' ) < 0 ) {
return;
}
add_filter( 'rocket_delay_js_exclusions', array( $this, 'excludedJs' ) );
add_filter( 'rocket_rucss_inline_content_exclusions', array( $this, 'addRucssContentExcluded' ) );
}
/**
* Adding our scripts to the list of excluded from delay loading
*
* @param array $excluded
*
* @return array
*/
public function excludedJs( $excluded ) {
$excluded[] = 'jquery-migrate-js';
$excluded[] = 'jquery-core-js';
$excluded[] = 'dgwt-wcas';
$excluded[] = 'wcasThemeSearch';
return $excluded;
}
/**
* Adding our inline styles to the list of excluded from remove from content.
*
* @param array $excluded
*
* @return array
*/
public function addRucssContentExcluded( $inlineExclusions ) {
$inlineExclusions [] = '.dgwt-wcas';
return $inlineExclusions;
}
}

View File

@@ -0,0 +1,151 @@
<?php
namespace DgoraWcas\Integrations\Plugins\WooCommerce;
use \DgoraWcas\Helpers;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Integration with native WooCommerce filters
*/
class WooCommerce {
public function init() {
add_filter( 'woocommerce_layered_nav_link', array( $this, 'add_search_param_to_link' ) );
add_filter( 'woocommerce_widget_get_current_page_url', array( $this, 'add_search_param_to_link' ) );
if ( Helpers::isProductSearchPage() ) {
add_filter( 'woocommerce_price_filter_sql', array( $this, 'filter_price_sql' ) );
add_filter( 'get_terms_args', array( $this, 'narrow_term_filters' ), 10, 2 );
add_filter( 'woocommerce_get_filtered_term_product_counts_query', array( $this, 'filter_counts_query' ) );
}
$this->syncWithOutOfStockVisibility();
add_action( 'before_woocommerce_init', array( $this, 'declare_compatibility' ) );
}
/**
* Sync with WooCommerce >> Settings >> Products >> Inventory >> "Out of stock visibility"
*/
private function syncWithOutOfStockVisibility() {
if ( get_option( 'woocommerce_hide_out_of_stock_items' ) === 'yes' ) {
// Hide "Exclude “out of stock” products" option
add_filter( 'dgwt/wcas/settings', function ( $settingsFields ) {
if ( is_array( $settingsFields['dgwt_wcas_search'] ) ) {
foreach ( $settingsFields['dgwt_wcas_search'] as $index => $field ) {
if ( $field['name'] === 'exclude_out_of_stock' ) {
unset( $settingsFields['dgwt_wcas_search'][ $index ] );
break;
}
}
}
return $settingsFields;
}, PHP_INT_MAX - 10 );
// Force value of "Exclude “out of stock” products" option as "on"
add_filter( 'dgwt/wcas/settings/load_value/key=exclude_out_of_stock', function ( $value ) {
return 'on';
}, PHP_INT_MAX - 10 );
}
}
/**
* Add &dgwt_wcas=1 to the link
*
* @return string
*/
public function add_search_param_to_link( $link ) {
if ( isset( $_GET['s'] ) ) {
$link = add_query_arg( array( 'dgwt_wcas' => '1' ), $link );
}
return $link;
}
/**
* Narrowing the list of products to those from our search engine
*
* @param string $sql
*
* @return string
*/
public function filter_price_sql( $sql ) {
if ( ! Helpers::is_running_inside_class( 'WC_Widget_Price_Filter' ) ) {
return $sql;
}
$post_ids = apply_filters( 'dgwt/wcas/search_page/result_post_ids', array() );
if ( $post_ids ) {
$sql .= " AND product_id IN(" . implode( ',', $post_ids ) . ")";
}
return $sql;
}
/**
* Passing our search results to plugin's terms filters
*
* The plugin will use our products IDs to determine terms in the displayed filters.
*
* @param array $args An array of get_terms() arguments.
* @param string[] $taxonomies An array of taxonomy names.
*
* @return array
*/
public function narrow_term_filters( $args, $taxonomies ) {
if ( ! Helpers::is_running_inside_class( 'WC_Widget_Layered_Nav' ) ) {
return $args;
}
$post_ids = apply_filters( 'dgwt/wcas/search_page/result_post_ids', array() );
if ( $post_ids ) {
$args['object_ids'] = $post_ids;
}
return $args;
}
/**
* Including products from our search engine in the term count display
*
* @param $query
*
* @return mixed
*/
public function filter_counts_query( $query ) {
global $wpdb;
$post_ids = apply_filters( 'dgwt/wcas/search_page/result_post_ids', array() );
if ( $post_ids ) {
$query['where'] .= " AND $wpdb->posts.ID IN(" . implode( ',', $post_ids ) . ")";
}
return $query;
}
/**
* Declare compatibility with WooCommerce features
*
* @return void
*/
public function declare_compatibility() {
// https://github.com/woocommerce/woocommerce/wiki/High-Performance-Order-Storage-Upgrade-Recipe-Book#declaring-extension-incompatibility
if ( class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) ) {
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', DGWT_WCAS_FILE, true );
}
}
}

View File

@@ -0,0 +1,52 @@
<?php
namespace DgoraWcas\Integrations\Plugins\WooCommerceAJAXFilters;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Integration with Advanced AJAX Product Filters
*
* Plugin URL: https://wordpress.org/plugins/woocommerce-ajax-filters/
* Author: BeRocket
*/
class WooCommerceAJAXFilters {
public function init() {
if ( ! defined( 'BeRocket_AJAX_filters_version' ) ) {
return;
}
if ( version_compare( BeRocket_AJAX_filters_version, '1.4.1.8' ) <= 0 ) {
return;
}
add_filter( 'berocket_aapf_get_attribute_values_post__in_outside', array( $this, 'filterPostInIds' ), 20 );
}
/**
* Passing our search results to plugin
*
* The plugin uses our products IDs to determine the values in the displayed filters.
*
* @param boolean|integer[] $post__in
*
* @return boolean|integer[]
*/
public function filterPostInIds( $post__in ) {
global $wp_query;
if ( $wp_query->get( 'dgwt_wcas', false ) === false ) {
return $post__in;
}
$posts_ids = apply_filters( 'dgwt/wcas/search_page/result_post_ids', array() );
if ( ! empty( $posts_ids ) ) {
return $posts_ids;
}
return $post__in;
}
}

View File

@@ -0,0 +1,92 @@
<?php
/**
* @dgwt_wcas_premium_only
*/
namespace DgoraWcas\Integrations\Plugins\WooCommercePrivateStore;
use DgoraWcas\Helpers ;
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) {
exit;
}
/**
* Integration with WooCommerce Private Store
*
* Plugin URL: https://barn2.co.uk/wordpress-plugins/woocommerce-private-store/
* Author: Barn2 Plugins
*/
class WooCommercePrivateStore
{
public function init()
{
if ( !defined( '\\Barn2\\Plugin\\WC_Private_Store\\PLUGIN_VERSION' ) ) {
return;
}
if ( version_compare( \Barn2\Plugin\WC_Private_Store\PLUGIN_VERSION, '1.6.3' ) < 0 ) {
return;
}
if ( !dgoraAsfwFs()->is_premium() ) {
add_filter(
'http_request_args',
array( $this, 'httpRequestArgs' ),
10,
2
);
add_filter( 'dgwt/wcas/search_results/output', array( $this, 'hideSearchResults' ) );
}
}
/**
* Pass Private Store cookie to search request on search page
*
* @param $args
* @param $url
*
* @return mixed
*/
public function httpRequestArgs( $args, $url )
{
if ( defined( 'DGWT_WCAS_SEARCH_ACTION' ) && defined( 'WCPS_COOKIE_PREFIX' ) && strpos( $url, \WC_AJAX::get_endpoint( \DGWT_WCAS_SEARCH_ACTION ) ) !== false ) {
$cookie = \filter_input( \INPUT_COOKIE, \WCPS_COOKIE_PREFIX . \COOKIEHASH );
if ( !empty($cookie) ) {
$args['cookies'] = array(
\WCPS_COOKIE_PREFIX . \COOKIEHASH => $cookie,
);
}
}
return $args;
}
/**
* Return empty results if store is locked
*
* @param $output
*
* @return array
*/
public function hideSearchResults( $output )
{
if ( !apply_filters( 'dgwt/wcas/integrations/woocommerce-private-store/hide-search-results', true ) ) {
return $output;
}
if ( is_callable( '\\Barn2\\Plugin\\WC_Private_Store\\Util::store_locked' ) ) {
if ( \Barn2\Plugin\WC_Private_Store\Util::store_locked() ) {
$output['total'] = 0;
$output['suggestions'] = array( array(
'value' => '',
'type' => 'no-results',
) );
$output['time'] = '0 sec';
}
}
return $output;
}
}

View File

@@ -0,0 +1,73 @@
<?php
namespace DgoraWcas\Integrations\Plugins\WooCommerceProductTable;
use \DgoraWcas\Helpers;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Integration with WooCommerce Product Table
*
* Plugin URL: https://barn2.co.uk/wordpress-plugins/woocommerce-product-table/
* Author: Barn2 Plugins
*/
class WooCommerceProductTable {
public function init() {
if ( ! defined( '\Barn2\Plugin\WC_Product_Table\PLUGIN_VERSION' ) ) {
return;
}
if ( version_compare( \Barn2\Plugin\WC_Product_Table\PLUGIN_VERSION, '2.6.2' ) < 0 ) {
return;
}
add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
}
/**
* Overwrite the search results in the table
*
* @param \WP_Query $query
*/
public function pre_get_posts( $query ) {
if ( ! Helpers::isProductSearchPage() ) {
return;
}
if ( ! Helpers::is_running_inside_class( 'Barn2\Plugin\WC_Product_Table\Table_Query', 10 ) && ! Helpers::is_running_inside_class( 'WC_Product_Table_Query' ) ) {
return;
}
$post_ids = apply_filters( 'dgwt/wcas/search_page/result_post_ids', array() );
if ( $post_ids ) {
// We set a variable to make our filters work for WP_Query
$query->set( 'dgwt_wcas', $query->query_vars['s'] );
$query->set( 'post__in', $post_ids );
$query->set( 'orderby', 'post__in' );
add_action( 'wp_footer', array( $this, 'add_js' ), 5 );
}
}
/**
* Reset search value in search input and hide the search box above/below the table
*/
public function add_js() {
?>
<script>
(function ($) {
$(document).ready(function () {
$('.wc-product-table').on('init.wcpt', function (e, table) {
table.$table.prev('.wc-product-table-controls').find('.dataTables_filter input').val('').trigger('keyup');
table.$table.prev('.wc-product-table-controls').find('.dataTables_filter label').hide();
table.$table.next('.wc-product-table-controls').find('.dataTables_filter label').hide();
});
});
})(jQuery);
</script>
<?php
}
}

View File

@@ -0,0 +1,172 @@
<?php
namespace DgoraWcas\Integrations\Plugins\WooCommerceProductsFilter;
use DgoraWcas\Helpers;
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Integration with WOOF Products Filter for WooCommerce
*
* Plugin URL: https://wordpress.org/plugins/woocommerce-products-filter/
* Author: realmag777
*/
class WooCommerceProductsFilter {
public function init() {
if ( ! defined( 'WOOF_VERSION' ) ) {
return;
}
if ( version_compare( WOOF_VERSION, '1.2.3' ) < 0 ) {
return;
}
if ( ! $this->is_search() ) {
return;
}
add_action( 'pre_get_posts', array( $this, 'search_products' ), 900000 );
add_action( 'woof_before_draw_filter', array( $this, 'inject_search_filter' ), 10, 2 );
add_filter( 'woof_get_filtered_price_query', array( $this, 'get_filtered_price_query' ) );
add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
add_filter( 'woof_dynamic_count_attr', array( $this, 'dynamic_count_attr' ), 10, 2 );
}
/**
* Set search query var if our custom search param is present
*
* @param \WP_Query $query
*/
public function search_products( $query ) {
if ( Helpers::is_running_inside_class( 'WP_QueryWoofCounter' ) ) {
return;
}
if ( ! $query->is_main_query() ) {
return;
}
$dgwt_wcas_s = isset( $_GET['dgwt_wcas_s'] ) && ! empty( trim( $_GET['dgwt_wcas_s'] ) ) ? trim( $_GET['dgwt_wcas_s'] ) : '';
if ( ! empty( $dgwt_wcas_s ) ) {
$query->set( 's', $dgwt_wcas_s );
$query->is_search = true;
}
}
/**
* Inject our custom search param to object with plugin's filters
*
* @param string $key
* @param array $shortcode_atts
*
* @return void
*/
public function inject_search_filter() {
global $dgwtWcasWoofInjected;
if ( $dgwtWcasWoofInjected ) {
return;
}
?>
<script>
function dgwt_wcas_s_init() {
setTimeout(function () {
woof_current_values.dgwt_wcas_s = '<?php echo esc_js( get_search_query() ) ?>';
}, 100);
}
if (document.readyState !== 'loading') {
dgwt_wcas_s_init();
} else {
document.addEventListener('DOMContentLoaded', dgwt_wcas_s_init);
}
</script>
<?php
$dgwtWcasWoofInjected = true;
}
/**
* Passing our search results to plugin's price filter
*
* The plugin will use our products IDs to determine the values in the displayed filters.
*
* @param string $sql
*
* @return string
*/
public function get_filtered_price_query( $sql ) {
global $wpdb;
$post_ids = apply_filters( 'dgwt/wcas/search_page/result_post_ids', array() );
if ( $post_ids ) {
$sql .= " AND $wpdb->posts.ID IN(" . implode( ',', $post_ids ) . ")";
}
return $sql;
}
/**
* Check if it's search page
*
* @return bool
*/
private function is_search() {
if (
isset( $_GET['dgwt_wcas'] ) && $_GET['dgwt_wcas'] === '1' &&
isset( $_GET['post_type'] ) && $_GET['post_type'] === 'product' &&
(
( isset( $_GET['s'] ) && ! empty( $_GET['s'] ) ) ||
( isset( $_GET['dgwt_wcas_s'] ) && ! empty( $_GET['dgwt_wcas_s'] ) )
)
) {
return true;
}
return false;
}
/**
* Filter posts used to show counters next to the filters
*
* @param \WP_Query $query
*
* @return mixed
*/
public function pre_get_posts( $query ) {
if ( $this->is_search() && Helpers::is_running_inside_class( 'WP_QueryWoofCounter', 15 ) ) {
$post_ids = apply_filters( 'dgwt/wcas/search_page/result_post_ids', array() );
$query->set( 'post__in', $post_ids );
}
return $query;
}
/**
* Including search results in the query used to determine the counters for the filters
*
* @param array $args
* @param string $custom_type
*
* @return array
*/
public function dynamic_count_attr( $args, $custom_type ) {
if ( ! empty( $custom_type ) ) {
return $args;
}
$post_ids = apply_filters( 'dgwt/wcas/search_page/result_post_ids', array() );
if ( $post_ids ) {
$args['post__in'] = $post_ids;
}
return $args;
}
}

View File

@@ -0,0 +1,101 @@
<?php
namespace DgoraWcas\Integrations\Plugins\WooCommerceWholeSalePricesIntegration;
use DgoraWcas\Helpers ;
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) {
exit;
}
/**
* Integration with WooCommerce Wholesale Prices
*
* Plugin URL: https://wholesalesuiteplugin.com
* Author: Rymera Web Co
*/
class WooCommerceWholeSalePricesIntegration
{
public function init()
{
if ( !class_exists( 'WooCommerceWholeSalePricesPremium' ) ) {
return;
}
if ( version_compare( \WooCommerceWholeSalePricesPremium::VERSION, '1.24.4' ) < 0 ) {
return;
}
add_filter( 'dgwt/wcas/search_query/args', array( $this, 'filterSearchQueryArgs' ) );
add_filter( 'dgwt/wcas/search/product_cat/args', array( $this, 'filterProductCatArgs' ) );
add_filter( 'dgwt/wcas/troubleshooting/renamed_plugins', array( $this, 'getFolderRenameInfo' ) );
}
/**
* Exclude hidden products from search results (native engine)
*
* @param array $args
*
* @return array
*/
public function filterSearchQueryArgs( $args )
{
global $wc_wholesale_prices_premium ;
if ( current_user_can( 'manage_options' ) || current_user_can( 'manage_woocommerce' ) ) {
return $args;
}
return $wc_wholesale_prices_premium->wwpp_query->pre_get_posts_arg( $args );
}
/**
* Exclude hidden categories from search results (native engine)
*
* @param array $args
*
* @return array
*/
public function filterProductCatArgs( $args )
{
global $wc_wholesale_prices_premium ;
if ( current_user_can( 'manage_options' ) || current_user_can( 'manage_woocommerce' ) ) {
return $args;
}
$postsArgs = array(
'tax_query' => array(),
);
$postsArgs = $wc_wholesale_prices_premium->wwpp_query->pre_get_posts_arg( $postsArgs );
if ( !isset( $args['exclude'] ) ) {
$args['exclude'] = array();
}
$args['exclude'] = array_merge( $args['exclude'], $this->getExcludedCategoryIds( $postsArgs ) );
return $args;
}
/**
* Get info about renamed plugin folder
*
* @param array $plugins
*
* @return array
*/
public function getFolderRenameInfo( $plugins )
{
$filters = new Filters();
$result = Helpers::getFolderRenameInfo__premium_only( 'WooCommerce Wholesale Prices Premium', $filters->plugin_names );
if ( $result ) {
$plugins[] = $result;
}
return $plugins;
}
private function getExcludedCategoryIds( $postsArgs )
{
$categoryIds = array();
if ( !empty($postsArgs['tax_query']) ) {
foreach ( $postsArgs['tax_query'] as $taxQuery ) {
if ( isset( $taxQuery['taxonomy'] ) && $taxQuery['taxonomy'] === 'product_cat' && isset( $taxQuery['operator'] ) && $taxQuery['operator'] === 'NOT IN' ) {
$categoryIds = $taxQuery['terms'];
}
}
}
return $categoryIds;
}
}

View File

@@ -0,0 +1,108 @@
<?php
namespace DgoraWcas\Integrations\Plugins\WooProductFilter;
use DgoraWcas\Helpers ;
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) {
exit;
}
/**
* Integration with WooCommerce Product Filter by WooBeWoo
*
* Plugin URL: https://wordpress.org/plugins/woo-product-filter/
* Author: WooBeWoo
*/
class WooProductFilter
{
public function init()
{
if ( !defined( 'WPF_VERSION' ) ) {
return;
}
if ( version_compare( WPF_VERSION, '1.2.8' ) < 0 ) {
return;
}
// TODO This filter must be added by the plugin author
add_filter( 'wpf_getFilteredPriceSql', array( $this, 'filter_price_sql' ) );
add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
}
/**
* Narrowing the list of products for determining edge prices to those returned by our search engine
*
* @param string $sql
*
* @return string
*/
public function filter_price_sql( $sql )
{
global $wpdb ;
$post_ids = apply_filters( 'dgwt/wcas/search_page/result_post_ids', array() );
if ( $post_ids ) {
$sql .= " AND {$wpdb->posts}.ID IN(" . implode( ',', $post_ids ) . ")";
}
return $sql;
}
/**
* Narrow the list of products in the AJAX search to those returned by our search engine
*
* Filtered custom WP_Query used by this plugin: wp-content/plugins/woo-product-filter/modules/woofilters/controller.php~152
*
* @param \WP_Query $query
*/
public function pre_get_posts( $query )
{
if ( !defined( 'DOING_AJAX' ) ) {
return;
}
if ( !isset( $_POST['action'] ) || isset( $_POST['action'] ) && $_POST['action'] !== 'filtersFrontend' ) {
return;
}
if ( !isset( $_POST['mod'] ) || isset( $_POST['mod'] ) && $_POST['mod'] !== 'woofilters' ) {
return;
}
if ( !isset( $_POST['currenturl'] ) ) {
return;
}
if ( $query->get( 'wpf_query' ) !== 1 ) {
return;
}
$orderby = 'relevance';
$order = 'desc';
// parse args from url passed as POST var
$url_query = wp_parse_url( $_POST['currenturl'] );
$url_query_args = array();
if ( empty($url_query['query']) ) {
return;
}
wp_parse_str( $url_query['query'], $url_query_args );
if ( !isset( $url_query_args['dgwt_wcas'] ) || !isset( $url_query_args['s'] ) ) {
return;
}
if ( !empty($url_query_args['orderby']) ) {
$orderby = wc_clean( wp_unslash( $url_query_args['orderby'] ) );
}
if ( !empty($url_query_args['order']) ) {
$order = strtolower( wc_clean( wp_unslash( $url_query_args['order'] ) ) );
}
if ( $orderby === 'price' ) {
$order = 'asc';
}
$post_ids = array();
if ( !dgoraAsfwFs()->is_premium() ) {
$post_ids = Helpers::searchProducts( $url_query_args['s'] );
}
if ( $post_ids ) {
if ( version_compare( WPF_VERSION, '1.4.8', '>=' ) ) {
$query->set( 's', '' );
}
$query->set( 'post__in', $post_ids );
$query->set( 'orderby', 'post__in' );
}
}
}

View File

@@ -0,0 +1,116 @@
<?php
/**
* @dgwt_wcas_premium_only
*/
namespace DgoraWcas\Integrations\Plugins\XforWooCommerceFilter;
use DgoraWcas\Helpers ;
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) {
exit;
}
/**
* Integration with Product Filter for WooCommerce
*
* Plugin URL: https://xforwoocommerce.com
* Author: 7VX LLC, USA CA
*/
class XforWooCommerceFilter
{
protected $post_ids = array() ;
public function init()
{
if ( !class_exists( 'XforWC_Product_Filters' ) ) {
return;
}
if ( version_compare( \XforWC_Product_Filters::$version, '7.2.3' ) < 0 ) {
return;
}
add_action( 'prdctfltr_add_inputs', array( $this, 'prdctfltr_add_inputs' ) );
add_action( 'pre_get_posts', array( $this, 'search_products' ), 1000000 );
}
/**
* Adding an input to be submitted during an AJAX query when changing filters
*
* Only on search page or during AJAX query on the search page.
*/
public function prdctfltr_add_inputs()
{
if ( Helpers::isProductSearchPage() || defined( 'DOING_AJAX' ) && isset( $_POST['action'] ) && $_POST['action'] === 'prdctfltr_respond_550' && isset( $_POST['pf_id'] ) && isset( $_POST['pf_filters'][$_POST['pf_id']]['dgwt_wcas'] ) ) {
echo '<input type="hidden" name="dgwt_wcas" value="1" class="pf_added_input" />' ;
echo '<input type="hidden" name="post_type" value="product" class="pf_added_input" />' ;
}
}
/**
* Narrow the list of products in the AJAX search to those returned by our search engine
*
* Filtered custom WP_Query used by this plugin: wp-content/plugins/xforwoocommerce/x-pack/prdctfltr/includes/pf-shortcode.php:1333
*
* @param \WP_Query $query
*/
public function search_products( $query )
{
if ( !$this->is_prdctfltr_ajax_search() ) {
return;
}
if ( $query->get( 'prdctfltr_active' ) !== true ) {
return;
}
$orderby = ( isset( $_POST['pf_filters'][$_POST['pf_id']]['orderby'] ) ? wc_clean( wp_unslash( $_POST['pf_filters'][$_POST['pf_id']]['orderby'] ) ) : 'relevance' );
$order = 'desc';
if ( $orderby === 'price' ) {
$order = 'asc';
}
$phrase = $_POST['pf_filters'][$_POST['pf_id']]['s'];
$post_ids = array();
if ( !dgoraAsfwFs()->is_premium() ) {
$post_ids = Helpers::searchProducts( $phrase );
}
$this->post_ids = $post_ids;
if ( $post_ids ) {
$query->set( 's', '' );
$query->is_search = false;
$query->set( 'post__in', $post_ids );
$query->set( 'orderby', 'post__in' );
}
}
/**
* Checking if we are in the middle of an AJAX query that handles filter and search results refreshing
*
* @return bool
*/
private function is_prdctfltr_ajax_search()
{
if ( !defined( 'DOING_AJAX' ) ) {
return false;
}
if ( !isset( $_POST['action'] ) ) {
return false;
}
if ( $_POST['action'] !== 'prdctfltr_respond_550' ) {
return false;
}
if ( !isset( $_POST['pf_id'] ) ) {
return false;
}
if ( !isset( $_POST['pf_filters'][$_POST['pf_id']] ) ) {
return false;
}
if ( !isset( $_POST['pf_filters'][$_POST['pf_id']]['s'] ) ) {
return false;
}
if ( !isset( $_POST['pf_filters'][$_POST['pf_id']]['dgwt_wcas'] ) ) {
return false;
}
return true;
}
}