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

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