Changeset 2205807
- Timestamp:
- 12/04/2019 10:10:28 AM (5 years ago)
- Location:
- mollie-payments-for-woocommerce/trunk
- Files:
-
- 360 added
- 3 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
mollie-payments-for-woocommerce/trunk/license.txt
r1511599 r2205807 1 1 Mollie Payments for WooCommerce plugin 2 Copyright (C) 2014-201 6, Mollie B.V. <info@mollie.com>2 Copyright (C) 2014-201, Mollie B.V. <info@mollie.com> 3 3 4 4 This program is free software; you can redistribute it and/or modify -
mollie-payments-for-woocommerce/trunk/mollie-payments-for-woocommerce.php
r2185682 r2205807 4 4 * Plugin URI: https://www.mollie.com 5 5 * Description: Accept payments in WooCommerce with the official Mollie plugin 6 * Version: 5. 3.26 * Version: 5. 7 7 * Author: Mollie 8 8 * Author URI: https://www.mollie.com 9 9 * Requires at least: 3.8 10 * Tested up to: 5. 210 * Tested up to: 5. 11 11 * Text Domain: mollie-payments-for-woocommerce 12 12 * Domain Path: /i18n/languages/ 13 13 * License: GPLv2 or later 14 14 * WC requires at least: 2.2.0 15 * WC tested up to: 3. 715 * WC tested up to: 3. 16 16 */ 17 17 18 // Exit if accessed directly. 19 if ( ! defined( 'ABSPATH' ) ) { 20 exit; 21 } 22 23 require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); 24 require_once 'includes/mollie/wc/autoload.php'; 25 require_once 'includes/mollie-api-php/vendor/autoload.php'; 18 use Mollie\Api\CompatibilityChecker; 19 20 require_once(ABSPATH . 'wp-admin/includes/plugin.php'); 21 22 define('M4W_FILE', __FILE__); 23 define('M4W_PLUGIN_DIR', dirname(M4W_FILE)); 26 24 27 25 // Plugin folder URL. 28 if ( ! defined( 'M4W_PLUGIN_URL' ) ) { 29 define( 'M4W_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); 30 } 31 32 // Plugin directory 33 if ( ! defined( 'M4W_PLUGIN_DIR' ) ) { 34 define( 'M4W_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); 35 } 36 37 /** 38 * Pro-actively check for required PHP JSON extension 39 */ 40 function mollie_wc_check_json_extension() { 41 if ( function_exists( 'extension_loaded' ) && ! extension_loaded( 'json' ) ) { 42 remove_action( 'init', 'mollie_wc_plugin_init' ); 43 add_action( 'admin_notices', 'mollie_wc_plugin_inactive_json_extension' ); 44 return; 45 } 46 } 47 add_action( 'plugins_loaded', 'mollie_wc_check_json_extension' ); 48 49 /** 50 * Pro-actively check and communicate PHP version incompatibility for Mollie Payments for WooCommerce 4.0 51 */ 52 function mollie_wc_check_php_version() { 53 if ( ! version_compare( PHP_VERSION, '5.6.0', ">=" ) ) { 54 remove_action( 'init', 'mollie_wc_plugin_init' ); 55 add_action( 'admin_notices', 'mollie_wc_plugin_inactive_php' ); 56 return; 57 } 58 } 59 add_action( 'plugins_loaded', 'mollie_wc_check_php_version' ); 60 61 /** 62 * Check if WooCommerce is active and of a supported version 63 */ 64 function mollie_wc_check_woocommerce_status() { 65 if ( ! class_exists( 'WooCommerce' ) || version_compare( get_option( 'woocommerce_version' ), '2.2', '<' ) ) { 66 remove_action('init', 'mollie_wc_plugin_init'); 67 add_action( 'admin_notices', 'mollie_wc_plugin_inactive' ); 68 return; 69 } 70 } 71 add_action( 'plugins_loaded', 'mollie_wc_check_woocommerce_status' ); 72 73 /** 74 * Called when plugin is loaded 75 */ 76 function mollie_wc_plugin_init() { 77 78 $pluginDir = untrailingslashit(plugin_dir_path(__FILE__)); 79 80 require_once $pluginDir . '/includes/mollie/OrderLineStatus.php'; 81 require_once $pluginDir . '/includes/mollie/wc/payment/OrderItemsRefunder.php'; 82 require_once $pluginDir . '/includes/mollie/wc/payment/PartialRefundException.php'; 83 require_once $pluginDir . '/includes/mollie/wc/payment/RefundLineItemsBuilder.php'; 84 85 // Register Mollie autoloader 86 Mollie_WC_Autoload::register(); 87 88 // Setup and start plugin 89 Mollie_WC_Plugin::init(); 26 if (!defined('M4W_PLUGIN_URL')) { 27 define('M4W_PLUGIN_URL', plugin_dir_url(M4W_FILE)); 90 28 } 91 29 … … 93 31 * Called when plugin is activated 94 32 */ 95 function mollie_wc_plugin_activation_hook () 96 { 97 98 if ( ! class_exists( 'WooCommerce' ) || version_compare( get_option( 'woocommerce_version' ), '2.2', '<' ) ) { 99 remove_action('init', 'mollie_wc_plugin_init'); 100 add_action( 'admin_notices', 'mollie_wc_plugin_inactive' ); 101 return; 102 } 103 104 // Register Mollie autoloader 105 Mollie_WC_Autoload::register(); 33 function mollie_wc_plugin_activation_hook() 34 { 35 require_once __DIR__ . '/inc/functions.php'; 36 require_once __DIR__ . '/src/subscriptions_status_check_functions.php'; 37 38 if (!autoload()) { 39 return; 40 } 41 42 if (!isWooCommerceCompatible()) { 43 add_action('admin_notices', 'mollie_wc_plugin_inactive'); 44 return; 45 } 106 46 107 47 $status_helper = Mollie_WC_Plugin::getStatusHelper(); 108 48 109 if (!$status_helper->isCompatible()) 110 { 111 $title = 'Could not activate plugin ' . Mollie_WC_Plugin::PLUGIN_TITLE; 49 if (!$status_helper->isCompatible()) { 50 $title = 'Could not activate plugin ' . Mollie_WC_Plugin::PLUGIN_TITLE; 112 51 $message = '<h1><strong>Could not activate plugin ' . Mollie_WC_Plugin::PLUGIN_TITLE . '</strong></h1><br/>' 113 52 . implode('<br/>', $status_helper->getErrors()); 114 53 115 54 wp_die($message, $title, array('back_link' => true)); … … 118 57 } 119 58 120 register_activation_hook(__FILE__, 'mollie_wc_plugin_activation_hook'); 121 122 function mollie_wc_plugin_inactive_json_extension() { 123 124 $nextScheduledTime = wp_next_scheduled( 'pending_payment_confirmation_check' ); 125 if ( $nextScheduledTime ) { 126 wp_unschedule_event( $nextScheduledTime, 'pending_payment_confirmation_check' ); 127 } 128 129 if ( ! is_admin() ) { 130 return false; 131 } 132 133 echo '<div class="error"><p>'; 134 echo esc_html__( 'Mollie Payments for WooCommerce requires the JSON extension for PHP. Enable it in your server or ask your webhoster to enable it for you.', 'mollie-payments-for-woocommerce' ); 135 echo '</p></div>'; 136 137 return false; 138 139 } 140 141 function mollie_wc_plugin_inactive_php() { 142 143 $nextScheduledTime = wp_next_scheduled( 'pending_payment_confirmation_check' ); 144 if ( $nextScheduledTime ) { 145 wp_unschedule_event( $nextScheduledTime, 'pending_payment_confirmation_check' ); 146 } 147 148 if ( ! is_admin() ) { 149 return false; 150 } 151 152 echo '<div class="error"><p>'; 153 echo sprintf( esc_html__( 'Mollie Payments for WooCommerce 4.0 requires PHP 5.6 or higher. Your PHP version is outdated. Upgrade your PHP version and view %sthis FAQ%s.', 'mollie-payments-for-woocommerce' ), '<a href="https://github.com/mollie/WooCommerce/wiki/PHP-&-Mollie-API-v2" target="_blank">', '</a>' ); 154 echo '</p></div>'; 155 156 return false; 157 158 } 159 160 function mollie_wc_plugin_inactive() { 161 162 $nextScheduledTime = wp_next_scheduled( 'pending_payment_confirmation_check' ); 163 if ( $nextScheduledTime ) { 164 wp_unschedule_event( $nextScheduledTime, 'pending_payment_confirmation_check' ); 165 } 166 167 if ( ! is_admin() ) { 168 return false; 169 } 170 171 if ( ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) { 172 173 echo '<div class="error"><p>'; 174 echo sprintf( esc_html__( '%1$sMollie Payments for WooCommerce is inactive.%2$s The %3$sWooCommerce plugin%4$s must be active for it to work. Please %5$sinstall & activate WooCommerce »%6$s', 'mollie-payments-for-woocommerce' ), '<strong>', '</strong>', '<a href="https://wordpress.org/plugins/woocommerce/">', '</a>', '<a href="' . esc_url( admin_url( 'plugins.php' ) ) . '">', '</a>' ); 175 echo '</p></div>'; 176 return false; 177 } 178 179 if ( version_compare( get_option( 'woocommerce_version' ), '2.2', '<' ) ) { 180 181 echo '<div class="error"><p>'; 182 echo sprintf( esc_html__( '%1$sMollie Payments for WooCommerce is inactive.%2$s This version requires WooCommerce 2.2 or newer. Please %3$supdate WooCommerce to version 2.2 or newer »%4$s', 'mollie-payments-for-woocommerce' ), '<strong>', '</strong>', '<a href="' . esc_url( admin_url( 'plugins.php' ) ) . '">', '</a>' ); 183 echo '</p></div>'; 184 return false; 185 186 } 187 } 188 189 add_action('init', 'mollie_wc_plugin_init'); 190 191 /** 192 * Load the plugin text domain for translations. 193 */ 194 function mollie_add_plugin_textdomain() { 195 196 load_plugin_textdomain( 'mollie-payments-for-woocommerce', false, M4W_PLUGIN_DIR . 'i18n/languages/' ); 197 198 } 199 200 add_action( 'plugins_loaded', 'mollie_add_plugin_textdomain' ); 59 function isWooCommerceCompatible() 60 { 61 $wooCommerceVersion = get_option('woocommerce_version'); 62 $isWooCommerceVersionCompatible = version_compare( 63 $wooCommerceVersion, 64 Mollie_WC_Helper_Status::MIN_WOOCOMMERCE_VERSION, 65 '>=' 66 ); 67 68 return class_exists('WooCommerce') && $isWooCommerceVersionCompatible; 69 } 70 71 function mollie_wc_plugin_inactive_json_extension() 72 { 73 $nextScheduledTime = wp_next_scheduled('pending_payment_confirmation_check'); 74 if ($nextScheduledTime) { 75 wp_unschedule_event($nextScheduledTime, 'pending_payment_confirmation_check'); 76 } 77 78 if (!is_admin()) { 79 return false; 80 } 81 82 echo '<div class="error"><p>'; 83 echo esc_html__( 84 'Mollie Payments for WooCommerce requires the JSON extension for PHP. Enable it in your server or ask your webhoster to enable it for you.', 85 'mollie-payments-for-woocommerce' 86 ); 87 echo '</p></div>'; 88 89 return false; 90 } 91 92 function mollie_wc_plugin_inactive_php() 93 { 94 $nextScheduledTime = wp_next_scheduled('pending_payment_confirmation_check'); 95 if ($nextScheduledTime) { 96 wp_unschedule_event($nextScheduledTime, 'pending_payment_confirmation_check'); 97 } 98 99 if (!is_admin()) { 100 return false; 101 } 102 103 echo '<div class="error"><p>'; 104 echo sprintf( 105 esc_html__( 106 'Mollie Payments for WooCommerce 4.0 requires PHP 5.6 or higher. Your PHP version is outdated. Upgrade your PHP version and view %sthis FAQ%s.', 107 'mollie-payments-for-woocommerce' 108 ), 109 '<a href="https://github.com/mollie/WooCommerce/wiki/PHP-&-Mollie-API-v2" target="_blank">', 110 '</a>' 111 ); 112 echo '</p></div>'; 113 114 return false; 115 } 116 117 function mollie_wc_plugin_inactive() 118 { 119 $nextScheduledTime = wp_next_scheduled('pending_payment_confirmation_check'); 120 if ($nextScheduledTime) { 121 wp_unschedule_event($nextScheduledTime, 'pending_payment_confirmation_check'); 122 } 123 124 if (!is_admin()) { 125 return false; 126 } 127 128 if (!is_plugin_active('woocommerce/woocommerce.php')) { 129 echo '<div class="error"><p>'; 130 echo sprintf( 131 esc_html__( 132 '%1$sMollie Payments for WooCommerce is inactive.%2$s The %3$sWooCommerce plugin%4$s must be active for it to work. Please %5$sinstall & activate WooCommerce »%6$s', 133 'mollie-payments-for-woocommerce' 134 ), 135 '<strong>', 136 '</strong>', 137 '<a href="https://wordpress.org/plugins/woocommerce/">', 138 '</a>', 139 '<a href="' . esc_url(admin_url('plugins.php')) . '">', 140 '</a>' 141 ); 142 echo '</p></div>'; 143 return false; 144 } 145 146 if (version_compare(get_option('woocommerce_version'), '2.2', '<')) { 147 echo '<div class="error"><p>'; 148 echo sprintf( 149 esc_html__( 150 '%1$sMollie Payments for WooCommerce is inactive.%2$s This version requires WooCommerce 2.2 or newer. Please %3$supdate WooCommerce to version 2.2 or newer »%4$s', 151 'mollie-payments-for-woocommerce' 152 ), 153 '<strong>', 154 '</strong>', 155 '<a href="' . esc_url(admin_url('plugins.php')) . '">', 156 '</a>' 157 ); 158 echo '</p></div>'; 159 return false; 160 } 161 } 162 163 function autoload() 164 { 165 $autoloader = __DIR__ . '/vendor/autoload.php'; 166 if (file_exists($autoloader)) { 167 /** @noinspection PhpIncludeInspection */ 168 require $autoloader; 169 } 170 171 return class_exists(Mollie_WC_Plugin::class); 172 } 173 174 $bootstrap = Closure::bind( 175 function () { 176 add_action( 177 'plugins_loaded', 178 function () { 179 require_once __DIR__ . '/inc/functions.php'; 180 require_once __DIR__ . '/src/subscriptions_status_check_functions.php'; 181 182 if (!autoload()) { 183 return; 184 } 185 186 if (function_exists('extension_loaded') && !extension_loaded('json')) { 187 add_action('admin_notices', 'mollie_wc_plugin_inactive_json_extension'); 188 return; 189 } 190 191 if (version_compare(PHP_VERSION, CompatibilityChecker::MIN_PHP_VERSION, '<')) { 192 add_action('admin_notices', 'mollie_wc_plugin_inactive_php'); 193 return; 194 } 195 196 if (!isWooCommerceCompatible()) { 197 add_action('admin_notices', 'mollie_wc_plugin_inactive'); 198 return; 199 } 200 } 201 ); 202 203 add_action( 204 'init', 205 function () { 206 load_plugin_textdomain('mollie-payments-for-woocommerce'); 207 Mollie_WC_Plugin::init(); 208 } 209 ); 210 }, 211 null 212 ); 213 214 $bootstrap(); 215 216 register_activation_hook(M4W_FILE, 'mollie_wc_plugin_activation_hook'); -
mollie-payments-for-woocommerce/trunk/readme.txt
r2185682 r2205807 3 3 Tags: mollie, payments, payment gateway, woocommerce, credit card, ideal, bancontact, klarna, sofort, giropay, woocommerce subscriptions 4 4 Requires at least: 3.8 5 Tested up to: 5. 26 Stable tag: 5. 3.25 Tested up to: 5. 6 Stable tag: 5. 7 7 Requires PHP: 5.6 8 8 License: GPLv2 or later … … 182 182 == Changelog == 183 183 184 185 186 187 188 189 184 190 = 5.3.2 - 04-11-2019 = 185 191
Note: See TracChangeset
for help on using the changeset viewer.