2020-09-17 16:50:04 -03:00
< ? php
2020-03-19 16:47:08 +01:00
/**
2020-10-08 20:03:07 -03:00
* Plugin Name : WooCommerce PayPal Payments
2020-10-13 09:42:34 +03:00
* Plugin URI : https :// woocommerce . com / products / woocommerce - paypal - payments /
2021-03-09 13:43:24 +02:00
* Description : PayPal ' s latest complete payments processing solution . Accept PayPal , Pay Later , credit / debit cards , alternative digital wallets local payment types and bank accounts . Turn on only PayPal options or process a full suite of payment methods . Enable global transaction with extensive currency and country coverage .
2021-09-16 17:12:46 +02:00
* Version : 1.6 . 0
2020-09-11 10:14:00 +03:00
* Author : WooCommerce
2020-10-13 09:42:34 +03:00
* Author URI : https :// woocommerce . com /
2020-03-19 16:47:08 +01:00
* License : GPL - 2.0
2021-04-20 15:29:59 +02:00
* Requires PHP : 7.1
2021-01-15 11:00:24 +01:00
* WC requires at least : 3.9
2021-08-18 15:24:38 +02:00
* WC tested up to : 5.6
2020-10-08 20:03:07 -03:00
* Text Domain : woocommerce - paypal - payments
2020-09-17 16:50:04 -03:00
*
* @ package WooCommerce\PayPalCommerce
2020-03-19 16:47:08 +01:00
*/
2020-09-17 16:50:04 -03:00
declare ( strict_types = 1 );
2020-06-15 11:48:37 +03:00
2020-09-11 14:11:10 +03:00
namespace WooCommerce\PayPalCommerce ;
2020-04-02 08:38:00 +03:00
2020-10-01 08:53:44 +03:00
define ( 'PAYPAL_API_URL' , 'https://api.paypal.com' );
define ( 'PAYPAL_SANDBOX_API_URL' , 'https://api.sandbox.paypal.com' );
2021-09-17 10:14:33 +02:00
define ( 'PAYPAL_INTEGRATION_DATE' , '2021-09-17' );
2020-10-01 08:53:44 +03:00
2021-02-15 13:54:42 +01:00
define ( 'PPCP_FLAG_SUBSCRIPTION' , true );
2020-10-13 09:42:34 +03:00
! defined ( 'CONNECT_WOO_CLIENT_ID' ) && define ( 'CONNECT_WOO_CLIENT_ID' , 'AcCAsWta_JTL__OfpjspNyH7c1GGHH332fLwonA5CwX4Y10mhybRZmHLA0GdRbwKwjQIhpDQy0pluX_P' );
! defined ( 'CONNECT_WOO_SANDBOX_CLIENT_ID' ) && define ( 'CONNECT_WOO_SANDBOX_CLIENT_ID' , 'AYmOHbt1VHg-OZ_oihPdzKEVbU3qg0qXonBcAztuzniQRaKE0w1Hr762cSFwd4n8wxOl-TCWohEa0XM_' );
! defined ( 'CONNECT_WOO_MERCHANT_ID' ) && define ( 'CONNECT_WOO_MERCHANT_ID' , 'K8SKZ36LQBWXJ' );
! defined ( 'CONNECT_WOO_SANDBOX_MERCHANT_ID' ) && define ( 'CONNECT_WOO_SANDBOX_MERCHANT_ID' , 'MPMFHQTVMBZ6G' );
! defined ( 'CONNECT_WOO_URL' ) && define ( 'CONNECT_WOO_URL' , 'https://connect.woocommerce.com/ppc' );
! defined ( 'CONNECT_WOO_SANDBOX_URL' ) && define ( 'CONNECT_WOO_SANDBOX_URL' , 'https://connect.woocommerce.com/ppcsandbox' );
2020-10-01 08:53:44 +03:00
2020-09-17 16:50:04 -03:00
( function () {
2020-09-01 15:27:18 +03:00
include __DIR__ . '/vendor/autoload.php' ;
2020-04-02 08:38:00 +03:00
2020-09-17 16:50:04 -03:00
/**
* Initialize the plugin and its modules .
*/
function init () {
2021-08-27 20:40:09 +03:00
$root_dir = __DIR__ ;
2021-01-13 14:48:19 +01:00
if ( ! function_exists ( 'is_plugin_active' ) ) {
require_once ABSPATH . '/wp-admin/includes/plugin.php' ;
}
if ( ! is_plugin_active ( 'woocommerce/woocommerce.php' ) ) {
add_action (
'admin_notices' ,
function () {
/* translators: 1. URL link. */
echo '<div class="error"><p><strong>' . sprintf ( esc_html__ ( 'WooCommerce PayPal Payments requires WooCommerce to be installed and active. You can download %s here.' , 'woocommerce-paypal-payments' ), '<a href="https://woocommerce.com/" target="_blank">WooCommerce</a>' ) . '</strong></p></div>' ;
}
);
return ;
}
2021-04-20 15:36:44 +02:00
if ( version_compare ( PHP_VERSION , '7.1' , '<' ) ) {
add_action (
'admin_notices' ,
function () {
echo '<div class="error"><p>' . esc_html__ ( 'WooCommerce PayPal Payments requires PHP 7.1 or above.' , 'woocommerce-paypal-payments' ), '</p></div>' ;
}
);
return ;
}
2021-01-13 14:48:19 +01:00
2020-09-17 16:50:04 -03:00
static $initialized ;
if ( ! $initialized ) {
2021-08-27 20:40:09 +03:00
$bootstrap = require " $root_dir /bootstrap.php " ;
2021-07-26 20:13:05 +03:00
2021-08-27 20:40:09 +03:00
$app_container = $bootstrap ( $root_dir );
2021-07-26 20:13:05 +03:00
2020-09-17 16:50:04 -03:00
$initialized = true ;
2021-08-27 20:40:09 +03:00
do_action ( 'woocommerce_paypal_payments_built_container' , $app_container );
2020-09-17 16:50:04 -03:00
}
}
2020-04-02 08:38:00 +03:00
2020-09-17 16:50:04 -03:00
add_action (
'plugins_loaded' ,
function () {
init ();
}
);
register_activation_hook (
__FILE__ ,
function () {
init ();
2020-10-09 19:55:28 -03:00
do_action ( 'woocommerce_paypal_payments_gateway_activate' );
2021-09-23 17:25:36 +02:00
flush_rewrite_rules ();
2020-09-17 16:50:04 -03:00
}
);
register_deactivation_hook (
__FILE__ ,
function () {
init ();
2020-10-09 19:55:28 -03:00
do_action ( 'woocommerce_paypal_payments_gateway_deactivate' );
2020-09-17 16:50:04 -03:00
}
);
2020-04-06 10:51:56 +03:00
2020-10-14 16:50:52 -03:00
// Add "Settings" link to Plugins screen.
add_filter (
'plugin_action_links_' . plugin_basename ( __FILE__ ),
function ( $links ) {
2021-01-13 14:48:19 +01:00
if ( ! function_exists ( 'is_plugin_active' ) ) {
require_once ABSPATH . '/wp-admin/includes/plugin.php' ;
}
if ( ! is_plugin_active ( 'woocommerce/woocommerce.php' ) ) {
return $links ;
}
2020-10-14 16:50:52 -03:00
array_unshift (
$links ,
sprintf (
'<a href="%1$s">%2$s</a>' ,
admin_url ( 'admin.php?page=wc-settings&tab=checkout§ion=ppcp-gateway' ),
__ ( 'Settings' , 'woocommerce-paypal-payments' )
)
);
return $links ;
}
);
2020-09-17 16:50:04 -03:00
} )();