Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit WooCommerce integration with ability to allow it #2914

Closed
wants to merge 13 commits into from
Prev Previous commit
Next Next commit
Add check for ep_integrate
  • Loading branch information
Mohammed Razzaq authored and Mohammed Razzaq committed Aug 10, 2022
commit 26ceda65c3ea82063b8e7cb1bd62e3b6ee2b9733
7 changes: 5 additions & 2 deletions includes/classes/Feature/WooCommerce/WooCommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -1117,11 +1117,14 @@ protected function should_integrate_with_query( $query ) {
* @param {WP_Query} $query WP Query to evaluate
* @return {bool} New skip value
*/
if ( apply_filters( 'ep_skip_query_integration', false, $query ) ||
( isset( $query->query_vars['ep_integrate'] ) && ! filter_var( $query->query_vars['ep_integrate'], FILTER_VALIDATE_BOOLEAN ) ) ) {
if ( apply_filters( 'ep_skip_query_integration', false, $query ) ) {
return false;
}

if ( isset( $query->query_vars['ep_integrate'] ) && filter_var( $query->query_vars['ep_integrate'], FILTER_VALIDATE_BOOLEAN ) ) {
return true;
}

if ( ! Utils\is_integrated_request( $this->slug ) ) {
return false;
}
Expand Down
6 changes: 0 additions & 6 deletions tests/php/features/TestWooCommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ public function testProductsPostTypeQueryOn() {

add_action( 'ep_wp_query_search', array( $this, 'action_wp_query_search' ), 10, 0 );

// Pretend that we've enabled the WooCommerce integration.
add_filter( 'ep_woocommerce_integration', '__return_true' );

$args = array(
'post_type' => 'product',
'ep_integrate' => true,
Expand Down Expand Up @@ -109,9 +106,6 @@ public function testProductsPostTypeQueryProductCatTax() {

add_action( 'ep_wp_query_search', array( $this, 'action_wp_query_search' ), 10, 0 );

// Pretend that we've enabled the WooCommerce integration.
add_filter( 'ep_woocommerce_integration', '__return_true' );

$args = array(
'ep_integrate' => true,
'tax_query' => array(
Expand Down