mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
78 lines
1.6 KiB
PHP
78 lines
1.6 KiB
PHP
|
<?php
|
||
|
/**
|
||
|
* The Googlepay module.
|
||
|
*
|
||
|
* @package WooCommerce\PayPalCommerce\Googlepay
|
||
|
*/
|
||
|
|
||
|
declare(strict_types=1);
|
||
|
|
||
|
namespace WooCommerce\PayPalCommerce\Googlepay;
|
||
|
|
||
|
use WooCommerce\PayPalCommerce\Button\Assets\SmartButtonInterface;
|
||
|
use WooCommerce\PayPalCommerce\Googlepay\Assets\ButtonInterface;
|
||
|
use WooCommerce\PayPalCommerce\Onboarding\Environment;
|
||
|
use WooCommerce\PayPalCommerce\Vendor\Dhii\Container\ServiceProvider;
|
||
|
use WooCommerce\PayPalCommerce\Vendor\Dhii\Modular\Module\ModuleInterface;
|
||
|
use WooCommerce\PayPalCommerce\Vendor\Interop\Container\ServiceProviderInterface;
|
||
|
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
|
||
|
|
||
|
/**
|
||
|
* Class GooglepayModule
|
||
|
*/
|
||
|
class GooglepayModule implements ModuleInterface {
|
||
|
/**
|
||
|
* {@inheritDoc}
|
||
|
*/
|
||
|
public function setup(): ServiceProviderInterface {
|
||
|
return new ServiceProvider(
|
||
|
require __DIR__ . '/../services.php',
|
||
|
require __DIR__ . '/../extensions.php'
|
||
|
);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* {@inheritDoc}
|
||
|
*/
|
||
|
public function run( ContainerInterface $c ): void {
|
||
|
|
||
|
add_action(
|
||
|
'wp',
|
||
|
static function () use ( $c ) {
|
||
|
if ( is_admin() ) {
|
||
|
return;
|
||
|
}
|
||
|
$button = $c->get( 'googlepay.button' );
|
||
|
|
||
|
/**
|
||
|
* The Button.
|
||
|
*
|
||
|
* @var ButtonInterface $button
|
||
|
*/
|
||
|
$button->render_buttons();
|
||
|
}
|
||
|
);
|
||
|
|
||
|
add_action(
|
||
|
'wp_enqueue_scripts',
|
||
|
static function () use ( $c ) {
|
||
|
$button = $c->get( 'googlepay.button' );
|
||
|
assert( $button instanceof ButtonInterface );
|
||
|
|
||
|
if ( $button->should_load_script() ) {
|
||
|
$button->enqueue();
|
||
|
}
|
||
|
}
|
||
|
);
|
||
|
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Returns the key for the module.
|
||
|
*
|
||
|
* @return string|void
|
||
|
*/
|
||
|
public function getKey() {
|
||
|
}
|
||
|
}
|