| 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.14.1 |
| 11 |
* WC tested up to: 10.2.2 |
| 12 |
* Requires plugins: woocommerce |
| 13 |
* License: GPLv3 or later |
| 14 |
* License URI: https://www.gnu.org/licenses/gpl-3.0.html |
| 15 |
*/ |
| 16 |
|
| 17 |
|
| 18 |
namespace Payplug\PayplugWoocommerce; |
| 19 |
|
| 20 |
// Exit if accessed directly |
| 21 |
if ( ! defined( 'ABSPATH' ) ) { |
| 22 |
exit; |
| 23 |
} |
| 24 |
|
| 25 |
|
| 26 |
define( 'PAYPLUG_GATEWAY_VERSION', '2.14.1' ); |
| 27 |
define( 'PAYPLUG_GATEWAY_PLUGIN_DIR', plugin_dir_path( __FILE__ ) ); |
| 28 |
define( 'PAYPLUG_GATEWAY_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); |
| 29 |
define( 'PAYPLUG_GATEWAY_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); |
| 30 |
|
| 31 |
/** |
| 32 |
* Plugin bootstrap function. |
| 33 |
*/ |
| 34 |
|
| 35 |
/** |
| 36 |
* $mo is the Mo object used to parse the English translations |
| 37 |
* |
| 38 |
* @var \MO |
| 39 |
*/ |
| 40 |
global $mo; |
| 41 |
$mo = new \MO(); |
| 42 |
|
| 43 |
function init() { |
| 44 |
if ( file_exists( plugin_dir_path( __FILE__ ) . '/vendor/autoload.php' ) ) { |
| 45 |
require_once plugin_dir_path( __FILE__ ) . '/vendor/autoload.php'; |
| 46 |
} |
| 47 |
|
| 48 |
if ( file_exists( plugin_dir_path( __FILE__ ) . DIRECTORY_SEPARATOR . 'payplug-config.php' ) ) { |
| 49 |
require_once plugin_dir_path( __FILE__ ) . DIRECTORY_SEPARATOR . 'payplug-config.php'; |
| 50 |
} |
| 51 |
|
| 52 |
PayplugWoocommerceHelper::load_plugin_textdomain( plugin_basename( dirname( __FILE__ ) ) . '/languages' ); |
| 53 |
PayplugWoocommerce::get_instance(); |
| 54 |
|
| 55 |
// parse the English translation file |
| 56 |
$path = WP_PLUGIN_DIR . '/' . plugin_basename( dirname( __FILE__ ) ) . '/languages/payplug-en_US.mo'; |
| 57 |
$GLOBALS["mo"]->import_from_file($path); |
| 58 |
} |
| 59 |
|
| 60 |
function create_lock_table(){ |
| 61 |
init(); |
| 62 |
\Payplug\PayplugWoocommerce\Model\Lock::create_lock_table(); |
| 63 |
} |
| 64 |
|
| 65 |
add_action( 'upgrader_process_complete', __NAMESPACE__ . '\\create_lock_table', 10, 2 ); |
| 66 |
add_action( 'activated_plugin', __NAMESPACE__ . '\\create_lock_table', 10, 2 ); |
| 67 |
add_action( 'plugins_loaded', __NAMESPACE__ . '\\init' ); |
| 68 |
|
| 69 |
add_action( 'before_woocommerce_init', function() { |
| 70 |
if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) { |
| 71 |
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); |
| 72 |
} |
| 73 |
} ); |
| 74 |
|
| 75 |
register_deactivation_hook( __FILE__, __NAMESPACE__ .'\\PayplugWoocommerceHelper::plugin_deactivation' ); |
| 76 |
|
| 77 |
/** |
| 78 |
* A fail-safe in case a transltion does not exist shows the default translation (English) |
| 79 |
* |
| 80 |
* @param $msgstr string Translated text (Usually starts with "payplug_") |
| 81 |
* @param $msgid string Text to translate (irrelevant because it is equal to $msgstr in this case) |
| 82 |
* @param $domain string the domain is always = "payplug" (filter "gettext_payplug" is only for payplug translation domain) |
| 83 |
* |
| 84 |
* @return string |
| 85 |
*/ |
| 86 |
function wpdocs_translate_text($msgstr, $msgid, $domain) |
| 87 |
{ |
| 88 |
$pattern = '/^payplug_.+/'; |
| 89 |
|
| 90 |
if (preg_match($pattern, $msgstr) === 1) { |
| 91 |
if(isset($GLOBALS["mo"]->entries[$msgstr])) |
| 92 |
return $GLOBALS["mo"]->entries[$msgstr]->translations[0]; |
| 93 |
} |
| 94 |
|
| 95 |
return $msgstr; |
| 96 |
} |
| 97 |
add_filter('gettext_payplug', __NAMESPACE__ . '\\wpdocs_translate_text', 10, 3); |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|