2021-07-15 06:51:37 -05:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* The compatibility module.
|
|
|
|
*
|
|
|
|
* @package WooCommerce\PayPalCommerce\Compat
|
|
|
|
*/
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace WooCommerce\PayPalCommerce\Compat;
|
|
|
|
|
|
|
|
use Dhii\Container\ServiceProvider;
|
|
|
|
use Dhii\Modular\Module\ModuleInterface;
|
|
|
|
use Interop\Container\ServiceProviderInterface;
|
|
|
|
use Psr\Container\ContainerInterface;
|
2021-08-26 17:17:28 +02:00
|
|
|
use WooCommerce\PayPalCommerce\Compat\PPEC\PpecHelper;
|
2021-07-15 06:51:37 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class CompatModule
|
|
|
|
*/
|
|
|
|
class CompatModule implements ModuleInterface {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Setup the compatibility module.
|
|
|
|
*
|
|
|
|
* @return ServiceProviderInterface
|
|
|
|
*/
|
|
|
|
public function setup(): ServiceProviderInterface {
|
|
|
|
return new ServiceProvider(
|
|
|
|
require __DIR__ . '/../services.php',
|
|
|
|
require __DIR__ . '/../extensions.php'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Run the compatibility module.
|
|
|
|
*
|
|
|
|
* @param ContainerInterface|null $container The Container.
|
|
|
|
*/
|
2021-07-16 09:26:52 +02:00
|
|
|
public function run( ContainerInterface $container ): void {
|
2021-07-27 15:08:25 -05:00
|
|
|
$this->initialize_ppec_compat_layer( $container );
|
2021-07-15 06:51:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the key for the module.
|
|
|
|
*
|
|
|
|
* @return string|void
|
|
|
|
*/
|
|
|
|
public function getKey() {
|
|
|
|
}
|
2021-07-27 15:08:25 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets up the PayPal Express Checkout compatibility layer.
|
|
|
|
*
|
|
|
|
* @param ContainerInterface|null $container The Container.
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
private function initialize_ppec_compat_layer( $container ): void {
|
2021-07-16 14:00:01 -05:00
|
|
|
// Process PPEC subscription renewals through PayPal Payments.
|
|
|
|
$handler = $container->get( 'compat.ppec.subscriptions-handler' );
|
|
|
|
$handler->maybe_hook();
|
2021-07-14 15:06:32 -05:00
|
|
|
|
|
|
|
// Settings.
|
|
|
|
$ppec_import = $container->get( 'compat.ppec.settings_importer' );
|
|
|
|
$ppec_import->maybe_hook();
|
2021-07-29 16:07:12 -05:00
|
|
|
|
|
|
|
// Inbox note inviting merchant to disable PayPal Express Checkout.
|
|
|
|
add_action(
|
|
|
|
'woocommerce_init',
|
|
|
|
function() {
|
2021-08-09 19:16:44 -07:00
|
|
|
if ( is_callable( array( WC(), 'is_wc_admin_active' ) ) && WC()->is_wc_admin_active() && class_exists( 'Automattic\WooCommerce\Admin\Notes\Notes' ) ) {
|
2021-07-29 16:07:12 -05:00
|
|
|
PPEC\DeactivateNote::init();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2021-07-27 15:08:25 -05:00
|
|
|
}
|
|
|
|
|
2021-07-15 06:51:37 -05:00
|
|
|
}
|