PluginProbe
PayPlug for WooCommerce (Official) / 1.0.22
PayPlug for WooCommerce (Official) v1.0.22
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.0.22, at src/PayplugWoocommerce.php

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