Plugin Directory

Changeset 2205807

Timestamp:
12/04/2019 10:10:28 AM (5 years ago)
Author:
wido
Message:

bump 5.4.0

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  
    11Mollie Payments for WooCommerce plugin
    2 Copyright (C) 2014-2016, Mollie B.V. <info@mollie.com>
     2Copyright (C) 2014-201, Mollie B.V. <info@mollie.com>
    33
    44This program is free software; you can redistribute it and/or modify
  • mollie-payments-for-woocommerce/trunk/mollie-payments-for-woocommerce.php

    r2185682 r2205807  
    44 * Plugin URI: https://www.mollie.com
    55 * Description: Accept payments in WooCommerce with the official Mollie plugin
    6  * Version: 5.3.2
     6 * Version: 5.
    77 * Author: Mollie
    88 * Author URI: https://www.mollie.com
    99 * Requires at least: 3.8
    10  * Tested up to: 5.2
     10 * Tested up to: 5.
    1111 * Text Domain: mollie-payments-for-woocommerce
    1212 * Domain Path: /i18n/languages/
    1313 * License: GPLv2 or later
    1414 * WC requires at least: 2.2.0
    15  * WC tested up to: 3.7
     15 * WC tested up to: 3.
    1616 */
    1717
    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';
     18use Mollie\Api\CompatibilityChecker;
     19
     20require_once(ABSPATH . 'wp-admin/includes/plugin.php');
     21
     22define('M4W_FILE', __FILE__);
     23define('M4W_PLUGIN_DIR', dirname(M4W_FILE));
    2624
    2725// 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();
     26if (!defined('M4W_PLUGIN_URL')) {
     27    define('M4W_PLUGIN_URL', plugin_dir_url(M4W_FILE));
    9028}
    9129
     
    9331 * Called when plugin is activated
    9432 */
    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();
     33function 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    }
    10646
    10747    $status_helper = Mollie_WC_Plugin::getStatusHelper();
    10848
    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;
    11251        $message = '<h1><strong>Could not activate plugin ' . Mollie_WC_Plugin::PLUGIN_TITLE . '</strong></h1><br/>'
    113                  . implode('<br/>', $status_helper->getErrors());
     52            . implode('<br/>', $status_helper->getErrors());
    11453
    11554        wp_die($message, $title, array('back_link' => true));
     
    11857}
    11958
    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 &raquo;%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 &raquo;%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' );
     59function 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
     71function 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
     92function 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
     117function 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 &raquo;%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 &raquo;%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
     163function 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
     216register_activation_hook(M4W_FILE, 'mollie_wc_plugin_activation_hook');
  • mollie-payments-for-woocommerce/trunk/readme.txt

    r2185682 r2205807  
    33Tags: mollie, payments, payment gateway, woocommerce, credit card, ideal, bancontact, klarna, sofort, giropay, woocommerce subscriptions
    44Requires at least: 3.8
    5 Tested up to: 5.2
    6 Stable tag: 5.3.2
     5Tested up to: 5.
     6Stable tag: 5.
    77Requires PHP: 5.6
    88License: GPLv2 or later
     
    182182== Changelog ==
    183183
     184
     185
     186
     187
     188
     189
    184190= 5.3.2 - 04-11-2019 =
    185191
Note: See TracChangeset for help on using the changeset viewer.