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

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