-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathpayplug.php
More file actions
99 lines (83 loc) · 3.26 KB
/
payplug.php
File metadata and controls
99 lines (83 loc) · 3.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
/**
* Plugin Name: PayPlug pour WooCommerce (Officiel)
* Plugin URI: https://www.payplug.com/modules/woocommerce
* Description: The online payment solution combining simplicity and first-rate support to boost your sales.
* Author: PayPlug
* Author URI: https://www.payplug.com/
* Text Domain: payplug
* Domain Path: /languages
* Version: 2.17.3
* WC tested up to: 10.6.1
* Requires plugins: woocommerce
* License: GPLv3 or later
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
*/
namespace Payplug\PayplugWoocommerce;
// Exit if accessed directly
if (!defined('ABSPATH')) {
exit;
}
define('PAYPLUG_GATEWAY_VERSION', '2.17.3');
define('PAYPLUG_MAX_VERSION_FOR_UPGRADE', '2.16.1');
define('PAYPLUG_GATEWAY_PLUGIN_DIR', plugin_dir_path(__FILE__));
define('PAYPLUG_GATEWAY_PLUGIN_URL', plugin_dir_url(__FILE__));
define('PAYPLUG_GATEWAY_PLUGIN_BASENAME', plugin_basename(__FILE__));
/**
* Plugin bootstrap function.
*/
/**
* $mo is the Mo object used to parse the English translations
*
* @var \MO
*/
global $mo;
$mo = new \MO();
function init()
{
if (file_exists(plugin_dir_path(__FILE__) . '/vendor/autoload.php')) {
require_once plugin_dir_path(__FILE__) . '/vendor/autoload.php';
}
if (file_exists(plugin_dir_path(__FILE__) . DIRECTORY_SEPARATOR . 'payplug-config.php')) {
require_once plugin_dir_path(__FILE__) . DIRECTORY_SEPARATOR . 'payplug-config.php';
}
PayplugWoocommerceHelper::load_plugin_textdomain(plugin_basename(dirname(__FILE__)) . '/languages');
PayplugWoocommerce::get_instance();
// parse the English translation file
$path = WP_PLUGIN_DIR . '/' . plugin_basename(dirname(__FILE__)) . '/languages/payplug-en_US.mo';
$GLOBALS['mo']->import_from_file($path);
}
function create_lock_table()
{
init();
\Payplug\PayplugWoocommerce\Model\Lock::create_lock_table();
}
add_action('upgrader_process_complete', __NAMESPACE__ . '\\create_lock_table', 10, 2);
add_action('activated_plugin', __NAMESPACE__ . '\\create_lock_table', 10, 2);
add_action('plugins_loaded', __NAMESPACE__ . '\\init');
add_action('before_woocommerce_init', function () {
if (class_exists(\Automattic\WooCommerce\Utilities\FeaturesUtil::class)) {
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility('custom_order_tables', __FILE__, true);
}
});
register_deactivation_hook(__FILE__, __NAMESPACE__ . '\\PayplugWoocommerceHelper::plugin_deactivation');
/**
* A fail-safe in case a transltion does not exist shows the default translation (English)
*
* @param $msgstr string Translated text (Usually starts with "payplug_")
* @param $msgid string Text to translate (irrelevant because it is equal to $msgstr in this case)
* @param $domain string the domain is always = "payplug" (filter "gettext_payplug" is only for payplug translation domain)
*
* @return string
*/
function wpdocs_translate_text($msgstr, $msgid, $domain)
{
$pattern = '/^payplug_.+/';
if (preg_match($pattern, $msgstr) === 1) {
if (isset($GLOBALS['mo']->entries[$msgstr])) {
return $GLOBALS['mo']->entries[$msgstr]->translations[0];
}
}
return $msgstr;
}
add_filter('gettext_payplug', __NAMESPACE__ . '\\wpdocs_translate_text', 10, 3);