mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Merge pull request #1254 from woocommerce/PCP-234-page-builder-hooks
Improve Divi and Elementor Pro compatibility
This commit is contained in:
commit
9c96dfd8bc
1 changed files with 48 additions and 0 deletions
|
@ -21,6 +21,7 @@ use WooCommerce\PayPalCommerce\Compat\Assets\CompatAssets;
|
||||||
use WooCommerce\PayPalCommerce\OrderTracking\Endpoint\OrderTrackingEndpoint;
|
use WooCommerce\PayPalCommerce\OrderTracking\Endpoint\OrderTrackingEndpoint;
|
||||||
use WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException;
|
use WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException;
|
||||||
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
||||||
|
use WP_Theme;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class CompatModule
|
* Class CompatModule
|
||||||
|
@ -57,6 +58,8 @@ class CompatModule implements ModuleInterface {
|
||||||
|
|
||||||
$this->migrate_pay_later_settings( $c );
|
$this->migrate_pay_later_settings( $c );
|
||||||
$this->migrate_smart_button_settings( $c );
|
$this->migrate_smart_button_settings( $c );
|
||||||
|
|
||||||
|
$this->fix_page_builders();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -320,4 +323,49 @@ class CompatModule implements ModuleInterface {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Changes the button rendering place for page builders
|
||||||
|
* that do not work well with our default places.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function fix_page_builders(): void {
|
||||||
|
if ( $this->is_elementor_pro_active() || $this->is_divi_theme_active() ) {
|
||||||
|
add_filter(
|
||||||
|
'woocommerce_paypal_payments_single_product_renderer_hook',
|
||||||
|
function(): string {
|
||||||
|
return 'woocommerce_after_add_to_cart_form';
|
||||||
|
},
|
||||||
|
5
|
||||||
|
);
|
||||||
|
|
||||||
|
add_filter(
|
||||||
|
'woocommerce_paypal_payments_checkout_button_renderer_hook',
|
||||||
|
function(): string {
|
||||||
|
return 'woocommerce_review_order_after_submit';
|
||||||
|
},
|
||||||
|
5
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the Elementor Pro plugins (allowing integrations with WC) is active.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function is_elementor_pro_active(): bool {
|
||||||
|
return is_plugin_active( 'elementor-pro/elementor-pro.php' );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the Divi theme is currently used.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function is_divi_theme_active(): bool {
|
||||||
|
$theme = wp_get_theme();
|
||||||
|
return $theme->get( 'Name' ) === 'Divi';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue