| 1 |
<?php |
| 2 |
defined( 'ABSPATH' ) || exit; |
| 3 |
|
| 4 |
// phpcs:disable WordPress.Files.FileName |
| 5 |
|
| 6 |
define( 'WC_VIPPS_RECURRING_VERSION', '2.2.18' ); |
| 7 |
|
| 8 |
/** |
| 9 |
* Polyfills |
| 10 |
*/ |
| 11 |
if ( ! function_exists( 'array_key_first' ) ) { |
| 12 |
function array_key_first( array $arr ) { |
| 13 |
foreach ( $arr as $key => $unused ) { |
| 14 |
return $key; |
| 15 |
} |
| 16 |
|
| 17 |
return null; |
| 18 |
} |
| 19 |
} |
| 20 |
|
| 21 |
if ( ! function_exists( 'array_key_last' ) ) { |
| 22 |
function array_key_last( array $array ) { |
| 23 |
end( $array ); |
| 24 |
|
| 25 |
return key( $array ); |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
require_once __DIR__ . '/includes/wc-vipps-recurring-helper.php'; |
| 30 |
require_once __DIR__ . '/includes/wc-vipps-recurring-logger.php'; |
| 31 |
require_once __DIR__ . '/includes/wc-vipps-recurring-admin-notices.php'; |
| 32 |
require_once __DIR__ . '/includes/wc-vipps-recurring.php'; |
| 33 |
|
| 34 |
/* |
| 35 |
* Required minimums and constants |
| 36 |
*/ |
| 37 |
define( 'WC_VIPPS_RECURRING_MIN_PHP_VER', '7.4.0' ); |
| 38 |
define( 'WC_VIPPS_RECURRING_MIN_WC_VER', '3.0.0' ); |
| 39 |
define( 'WC_VIPPS_RECURRING_MAIN_FILE', __FILE__ ); |
| 40 |
#define( 'WC_VIPPS_RECURRING_PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) ); |
| 41 |
define( 'WC_VIPPS_RECURRING_PLUGIN_URL', plugins_url("", __FILE__)); |
| 42 |
define( 'WC_VIPPS_RECURRING_PLUGIN_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) ); |
| 43 |
|
| 44 |
/* Note that this is the integrated version of the plugin IOK 2025-01-06*/ |
| 45 |
define( 'WC_VIPPS_RECURRING_INTEGRATED', true); |
| 46 |
|
| 47 |
/* |
| 48 |
* Amount of days to retry a payment when creating a charge in the Vipps/MobilePay API |
| 49 |
*/ |
| 50 |
if ( ! defined( 'WC_VIPPS_RECURRING_RETRY_DAYS' ) ) { |
| 51 |
$wc_vipps_recurring_retry_days = 2; |
| 52 |
$wc_vipps_recurring_wcs_retries_enabled = 'yes' === get_option( 'woocommerce_subscriptions_enable_retry', 'no' ); |
| 53 |
|
| 54 |
if ( apply_filters( 'wcs_is_retry_enabled', $wc_vipps_recurring_wcs_retries_enabled ) ) { |
| 55 |
$wc_vipps_recurring_retry_days = 0; |
| 56 |
} |
| 57 |
|
| 58 |
define( 'WC_VIPPS_RECURRING_RETRY_DAYS', $wc_vipps_recurring_retry_days ); |
| 59 |
unset( $wc_vipps_recurring_retry_days ); |
| 60 |
unset( $wc_vipps_recurring_wcs_retries_enabled ); |
| 61 |
} |
| 62 |
|
| 63 |
/* |
| 64 |
* Whether to put the plugin into test mode. This is only useful for developers. |
| 65 |
*/ |
| 66 |
if ( ! defined( 'WC_VIPPS_RECURRING_TEST_MODE' ) ) { |
| 67 |
define( 'WC_VIPPS_RECURRING_TEST_MODE', false ); |
| 68 |
} |
| 69 |
|
| 70 |
if ( ! defined( 'WC_VIPPS_RECURRING_ALLOW_CHECKOUT_OPTION' ) ) { |
| 71 |
define( 'WC_VIPPS_RECURRING_ALLOW_CHECKOUT_OPTION', false ); |
| 72 |
} |
| 73 |
|
| 74 |
WC_Vipps_Recurring::register_hooks(); |
| 75 |
if ( get_option( WC_Vipps_Recurring_Helper::OPTION_CHECKOUT_ENABLED, false ) ) { |
| 76 |
require_once __DIR__ . '/includes/wc-vipps-recurring-checkout.php'; |
| 77 |
WC_Vipps_Recurring_Checkout::register_hooks(); |
| 78 |
} |
| 79 |
|
| 80 |
require_once __DIR__ . '/includes/wc-vipps-recurring-compatibility.php'; |
| 81 |
|