PluginProbe
PayPlug for WooCommerce (Official) / 2.9.0
PayPlug for WooCommerce (Official) v2.9.0
3.0.0 2.18.0 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 1.0.22 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.1.0 1.10.0 1.10.1 1.2.1 1.2.10 1.2.11 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 All 101 releases
← All changes | payplug.php +58 -3 1.2.22.9.0 View file →
@@ -6,10 +6,10 @@
6 6 * Author: PayPlug
7 7 * Author URI: https://www.payplug.com/
8 8 * Text Domain: payplug
9 9 * Domain Path: /languages
10 - * Version: 1.2.2
11 - * WC tested up to: 4.0
10 + * Version: 2.9.0
11 + * WC tested up to: 9.3.3
12 12 * License: GPLv3 or later
13 13 * License URI: https://www.gnu.org/licenses/gpl-3.0.html
14 14 */
15 15
@@ -20,9 +20,10 @@
20 20 if ( ! defined( 'ABSPATH' ) ) {
21 21 exit;
22 22 }
23 23
24 -define( 'PAYPLUG_GATEWAY_VERSION', '1.2.2' );
24 +
25 +define( 'PAYPLUG_GATEWAY_VERSION', '2.9.0' );
25 26 define( 'PAYPLUG_GATEWAY_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
26 27 define( 'PAYPLUG_GATEWAY_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
27 28 define( 'PAYPLUG_GATEWAY_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
28 29
@@ -28,8 +29,17 @@
28 29
29 30 /**
30 31 * Plugin bootstrap function.
31 32 */
33 +
34 +/**
35 + * $mo is the Mo object used to parse the English translations
36 + *
37 + * @var \MO
38 + */
39 +global $mo;
40 +$mo = new \MO();
41 +
32 42 function init() {
33 43 if ( file_exists( plugin_dir_path( __FILE__ ) . '/vendor/autoload.php' ) ) {
34 44 require_once plugin_dir_path( __FILE__ ) . '/vendor/autoload.php';
35 45 }
@@ -34,6 +44,51 @@
34 44 require_once plugin_dir_path( __FILE__ ) . '/vendor/autoload.php';
35 45 }
36 46 PayplugWoocommerceHelper::load_plugin_textdomain( plugin_basename( dirname( __FILE__ ) ) . '/languages' );
37 47 PayplugWoocommerce::get_instance();
48 +
49 + // parse the English translation file
50 + $path = WP_PLUGIN_DIR . '/' . plugin_basename( dirname( __FILE__ ) ) . '/languages/payplug-en_US.mo';
51 + $GLOBALS["mo"]->import_from_file($path);
38 52 }
53 +
54 +function create_lock_table(){
55 + init();
56 + \Payplug\PayplugWoocommerce\Model\Lock::create_lock_table();
57 +}
58 +
59 +add_action( 'upgrader_process_complete', __NAMESPACE__ . '\\create_lock_table', 10, 2 );
60 +add_action( 'activated_plugin', __NAMESPACE__ . '\\create_lock_table', 10, 2 );
39 61 add_action( 'plugins_loaded', __NAMESPACE__ . '\\init' );
62 +
63 +add_action( 'before_woocommerce_init', function() {
64 + if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
65 + \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
66 + }
67 +} );
68 +
69 +register_deactivation_hook( __FILE__, __NAMESPACE__ .'\\PayplugWoocommerceHelper::plugin_deactivation' );
70 +
71 +/**
72 + * A fail-safe in case a transltion does not exist shows the default translation (English)
73 + *
74 + * @param $msgstr string Translated text (Usually starts with "payplug_")
75 + * @param $msgid string Text to translate (irrelevant because it is equal to $msgstr in this case)
76 + * @param $domain string the domain is always = "payplug" (filter "gettext_payplug" is only for payplug translation domain)
77 + *
78 + * @return string
79 + */
80 +function wpdocs_translate_text($msgstr, $msgid, $domain)
81 +{
82 + $pattern = '/^payplug_.+/';
83 +
84 + if (preg_match($pattern, $msgstr) === 1) {
85 + if(isset($GLOBALS["mo"]->entries[$msgstr]))
86 + return $GLOBALS["mo"]->entries[$msgstr]->translations[0];
87 + }
88 +
89 + return $msgstr;
90 +}
91 +add_filter('gettext_payplug', __NAMESPACE__ . '\\wpdocs_translate_text', 10, 3);
92 +
93 +
94 +