' . sprintf( esc_html__( 'WooCommerce PayPal Payments requires WooCommerce to be installed and active. You can download %s here.', 'woocommerce-paypal-payments' ), 'WooCommerce' ) . '
';
}
);
return;
}
if ( version_compare( PHP_VERSION, '7.1', '<' ) ) {
add_action(
'admin_notices',
function() {
echo '' . esc_html__( 'WooCommerce PayPal Payments requires PHP 7.1 or above.', 'woocommerce-paypal-payments' ), '
';
}
);
return;
}
static $initialized;
if ( ! $initialized ) {
$modules = array( new PluginModule() );
foreach ( glob( plugin_dir_path( __FILE__ ) . 'modules/*/module.php' ) as $module_file ) {
$modules[] = ( require $module_file )();
}
$providers = array();
// Use this filter to add custom module or remove some of existing ones.
// Modules able to access container, add services and modify existing ones.
$modules = apply_filters( 'woocommerce_paypal_payments_modules', $modules );
foreach ( $modules as $module ) {
/* @var $module ModuleInterface module */
$providers[] = $module->setup();
}
$proxy = new ProxyContainer();
$provider = new CompositeCachingServiceProvider( $providers );
$container = new CachingContainer( new DelegatingContainer( $provider ) );
$proxy->setInnerContainer( $container );
foreach ( $modules as $module ) {
/* @var $module ModuleInterface module */
$module->run( $container );
}
$initialized = true;
do_action( 'woocommerce_paypal_payments_built_container', $proxy );
}
}
add_action(
'plugins_loaded',
function () {
init();
}
);
register_activation_hook(
__FILE__,
function () {
init();
do_action( 'woocommerce_paypal_payments_gateway_activate' );
}
);
register_deactivation_hook(
__FILE__,
function () {
init();
do_action( 'woocommerce_paypal_payments_gateway_deactivate' );
}
);
// Add "Settings" link to Plugins screen.
add_filter(
'plugin_action_links_' . plugin_basename( __FILE__ ),
function( $links ) {
if ( ! function_exists( 'is_plugin_active' ) ) {
require_once ABSPATH . '/wp-admin/includes/plugin.php';
}
if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
return $links;
}
array_unshift(
$links,
sprintf(
'%2$s',
admin_url( 'admin.php?page=wc-settings&tab=checkout§ion=ppcp-gateway' ),
__( 'Settings', 'woocommerce-paypal-payments' )
)
);
return $links;
}
);
} )();