PluginProbe
PayPlug for WooCommerce (Official) / 1.2.2
PayPlug for WooCommerce (Official) v1.2.2
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
payplug / src / PayplugWoocommerce.php

PayplugWoocommerce.php in PayPlug for WooCommerce (Official) 1.2.2, at src/PayplugWoocommerce.php

144 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Payplug\PayplugWoocommerce;
4
5 // Exit if accessed directly
6 if ( ! defined( 'ABSPATH' ) ) {
7 exit;
8 }
9
10 use Payplug\PayplugWoocommerce\Admin\Ajax;
11 use Payplug\PayplugWoocommerce\Admin\Metabox;
12 use Payplug\PayplugWoocommerce\Admin\Notices;
13 use Payplug\PayplugWoocommerce\Admin\WoocommerceActions;
14 use Payplug\PayplugWoocommerce\Front\PayplugOneyDetail;
15
16 class PayplugWoocommerce {
17
18 /**
19 * @var PayplugWoocommerce
20 */
21 private static $instance;
22
23 /**
24 * PayPlug admin notices
25 *
26 * @var Notices
27 */
28 public $notices;
29
30 /**
31 * PayPlug metabox
32 *
33 * @var Metabox
34 */
35 public $metabox;
36
37 /**
38 * Custom woocommerce actions
39 *
40 * @var WoocommerceActions
41 */
42 public $actions;
43
44 /**
45 * @var PayplugWoocommerceRequest
46 */
47 public $requests;
48
49 /**
50 * Ajax actions handler
51 *
52 * @var Ajax
53 */
54 public $ajax;
55
56 /**
57 * Get the singleton instance.
58 *
59 * @return PayplugWoocommerce
60 */
61 public static function get_instance() {
62 if ( is_null( self::$instance ) ) {
63 self::$instance = new static();
64 }
65
66 return self::$instance;
67 }
68
69 /**
70 * Singleton instance can't be cloned.
71 */
72 private function __clone() {
73 }
74
75 /**
76 * Singleton instance can't be serialized.
77 */
78 private function __wakeup() {
79 }
80
81 /**
82 * PayplugWoocommerce constructor.
83 */
84 private function __construct() {
85
86 // Bail early if WooCommerce is not activated
87 if ( ! defined( 'WC_VERSION' ) ) {
88 add_action( 'admin_notices', function () {
89 ?>
90 <div id="message" class="notice notice-error">
91 <p><?php _e( 'PayPlug requires an active version of WooCommerce', 'payplug' ); ?></p>
92 </div>
93 <?php
94 } );
95
96 return;
97 }
98
99 if ( PayplugWoocommerceHelper::is_pre_30() ) {
100 require_once PAYPLUG_GATEWAY_PLUGIN_DIR . '/woocommerce-compat.php';
101 }
102
103 $this->notices = new Notices();
104 $this->metabox = new Metabox();
105 $this->actions = new WoocommerceActions();
106 $this->requests = new PayplugWoocommerceRequest();
107 $this->ajax = new Ajax();
108 new PayplugOneyDetail();
109
110 add_action( 'woocommerce_payment_gateways', [ $this, 'register_payplug_gateway' ] );
111 add_filter( 'plugin_action_links_' . PAYPLUG_GATEWAY_PLUGIN_BASENAME, [ $this, 'plugin_action_links' ] );
112 }
113
114 /**
115 * Register PayPlug gateway.
116 *
117 * @param $methods
118 *
119 * @return array
120 */
121 public function register_payplug_gateway( $methods ) {
122 $methods[] = __NAMESPACE__ . '\\Gateway\\PayplugGateway';
123 $methods[] = __NAMESPACE__ . '\\Gateway\\PayplugGatewayOney3x';
124 $methods[] = __NAMESPACE__ . '\\Gateway\\PayplugGatewayOney4x';
125
126 return $methods;
127 }
128
129 /**
130 * Add additional action links.
131 *
132 * @param array $links
133 *
134 * @return array
135 */
136 public function plugin_action_links( $links = [] ) {
137 $plugin_links = [
138 '<a href="' . esc_url( PayplugWoocommerceHelper::get_setting_link() ) . '">' . esc_html__( 'Settings', 'payplug' ) . '</a>',
139 ];
140
141 return array_merge( $plugin_links, $links );
142 }
143 }
144