| 1 |
<?php |
| 2 |
/** |
| 3 |
* Plugin Name: PayPlug pour WooCommerce (Officiel) |
| 4 |
* Plugin URI: https://www.payplug.com/modules/woocommerce |
| 5 |
* Description: The online payment solution combining simplicity and first-rate support to boost your sales. |
| 6 |
* Author: PayPlug |
| 7 |
* Author URI: https://www.payplug.com/ |
| 8 |
* Text Domain: payplug |
| 9 |
* Domain Path: /languages |
| 10 |
* Version: 2.1.2 |
| 11 |
* WC tested up to: 7.3.0 |
| 12 |
* License: GPLv3 or later |
| 13 |
* License URI: https://www.gnu.org/licenses/gpl-3.0.html |
| 14 |
*/ |
| 15 |
|
| 16 |
|
| 17 |
namespace Payplug\PayplugWoocommerce; |
| 18 |
|
| 19 |
// Exit if accessed directly |
| 20 |
if ( ! defined( 'ABSPATH' ) ) { |
| 21 |
exit; |
| 22 |
} |
| 23 |
|
| 24 |
|
| 25 |
define( 'PAYPLUG_GATEWAY_VERSION', '2.1.2' ); |
| 26 |
define( 'PAYPLUG_GATEWAY_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); |
| 27 |
define( 'PAYPLUG_GATEWAY_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
| 28 |
define( 'PAYPLUG_GATEWAY_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); |
| 29 |
|
| 30 |
/** |
| 31 |
* Plugin bootstrap function. |
| 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 |
|
| 42 |
function init() { |
| 43 |
if ( file_exists( plugin_dir_path( __FILE__ ) . '/vendor/autoload.php' ) ) { |
| 44 |
require_once plugin_dir_path( __FILE__ ) . '/vendor/autoload.php'; |
| 45 |
} |
| 46 |
PayplugWoocommerceHelper::load_plugin_textdomain( plugin_basename( dirname( __FILE__ ) ) . '/languages' ); |
| 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); |
| 52 |
} |
| 53 |
|
| 54 |
add_action( 'plugins_loaded', __NAMESPACE__ . '\\init' ); |
| 55 |
|
| 56 |
/** |
| 57 |
* A fail-safe in case a transltion does not exist shows the default translation (English) |
| 58 |
* |
| 59 |
* @param $msgstr string Translated text (Usually starts with "payplug_") |
| 60 |
* @param $msgid string Text to translate (irrelevant because it is equal to $msgstr in this case) |
| 61 |
* @param $domain string the domain is always = "payplug" (filter "gettext_payplug" is only for payplug translation domain) |
| 62 |
* |
| 63 |
* @return string |
| 64 |
*/ |
| 65 |
function wpdocs_translate_text($msgstr, $msgid, $domain) |
| 66 |
{ |
| 67 |
$pattern = '/^payplug_.+/'; |
| 68 |
|
| 69 |
if (preg_match($pattern, $msgstr) === 1) { |
| 70 |
if(isset($GLOBALS["mo"]->entries[$msgstr])) |
| 71 |
return $GLOBALS["mo"]->entries[$msgstr]->translations[0]; |
| 72 |
} |
| 73 |
|
| 74 |
return $msgstr; |
| 75 |
} |
| 76 |
add_filter('gettext_payplug', __NAMESPACE__ . '\\wpdocs_translate_text', 10, 3); |
| 77 |
|