1+ <?php
2+ class wp_slack_woocommerce_testmode extends wp_slack_woocommerce
3+ {
4+ public function init ()
5+ {
6+ $ plugin_path = 'woocommerce-click-pledge-gateway/gateway-clickandpledge.php ' ;
7+ if (
8+ (is_plugin_active ($ plugin_path ) || is_plugin_inactive ($ plugin_path ))
9+ && file_exists (ABSPATH . '/wp-content/plugins/ ' . $ plugin_path )
10+ ) {
11+ add_action ('deactivate_ ' . $ plugin_path , array ($ this , 'clickandpledge_deactivate ' ));
12+ add_action ('activate_ ' . $ plugin_path , array ($ this , 'clickandpledge_activate ' ));
13+ }
14+
15+ $ plugin_path = 'woocommerce-gateway-firstdata/woocommerce-gateway-first-data.php ' ;
16+ if (
17+ (is_plugin_active ($ plugin_path ) || is_plugin_inactive ($ plugin_path ))
18+ && file_exists (ABSPATH . '/wp-content/plugins/ ' . $ plugin_path )
19+ ) {
20+ add_action ('deactivate_ ' . $ plugin_path , array ($ this , 'payeezy_deactivate ' ));
21+ add_action ('activate_ ' . $ plugin_path , array ($ this , 'payeezy_activate ' ));
22+ }
23+
24+ add_action ('woocommerce_update_options ' , array ($ this , 'testmode_check ' ), 10 , 1 );
25+ add_action ('testmode_check ' , array ($ this , 'testmode_check ' ));
26+ }
27+
28+ /**
29+ * Checks the test mode status of Payeezy and Click and Pledge gateways.
30+ *
31+ * This function checks if the specified WooCommerce gateways (Payeezy and Click and Pledge)
32+ * are active or inactive and whether their respective plugin files exist. If the conditions
33+ * are met, it calls respective functions to check the test mode status of these gateways.
34+ */
35+ public function testmode_check ()
36+ {
37+ $ plugin_path = 'woocommerce-gateway-firstdata/woocommerce-gateway-first-data.php ' ;
38+ if (
39+ (is_plugin_active ($ plugin_path ) || is_plugin_inactive ($ plugin_path ))
40+ && file_exists (ABSPATH . '/wp-content/plugins/ ' . $ plugin_path )
41+ ) {
42+ $ this ->payeezy_testmode_check ();
43+ }
44+
45+ $ plugin_path = 'woocommerce-click-pledge-gateway/gateway-clickandpledge.php ' ;
46+ if (
47+ (is_plugin_active ($ plugin_path ) || is_plugin_inactive ($ plugin_path ))
48+ && file_exists (ABSPATH . '/wp-content/plugins/ ' . $ plugin_path )
49+ ) {
50+ $ this ->clickandpledge_testmode_check ();
51+ }
52+ }
53+
54+ public function payeezy_activate ()
55+ {
56+ $ message = " Production website's Production website's Payeezy Gateway is active! " ;
57+ $ icon = ":heavy_check_mark: " ;
58+ $ channel = get_option ('wc_settings_tab_slack_woocommerce_channel ' );
59+ $ this ->slack_message ($ message , "Payeezy Gateway Plugin Active " , $ channel , $ icon );
60+ }
61+ public function payeezy_deactivate ()
62+ {
63+ $ message = "WARNING: Production website's Production website's Payeezy Gateway is in not active! " ;
64+ $ icon = ":warning: " ;
65+ $ channel = get_option ('wc_settings_tab_slack_woocommerce_channel ' );
66+ $ this ->slack_message ($ message , "Payeezy Gateway Plugin Inactive " , $ channel , $ icon );
67+ }
68+ public function payeezy_testmode_check ()
69+ {
70+ // Don't check for WPEngine yet, need to test first
71+ $ settings = get_option ('woocommerce_first_data_payeezy_gateway_credit_card_settings ' );
72+ if ($ settings ['environment ' ] == 'demo ' && get_option ('woocommerce_pe_testmode ' ) != 'true ' ) {
73+ update_option ('woocommerce_pe_testmode ' , 'true ' );
74+ $ message = "WARNING: Production website's Payeezy Gateway Environment is set to Demo " ;
75+ $ icon = ":warning: " ;
76+ $ channel = get_option ('wc_settings_tab_slack_woocommerce_channel ' );
77+ $ this ->slack_message ($ message , "Payeezy Gateway Environment set to Demo " , $ channel , $ icon );
78+ } else if ($ settings ['environment ' ] == 'production ' ) {
79+ if (get_option ('woocommerce_pe_testmode ' ) == 'true ' ) {
80+ $ message = "Production website's Payeezy Gateway Environment is set to Production " ;
81+ $ icon = ":heavy_check_mark: " ;
82+ $ channel = get_option ('wc_settings_tab_slack_woocommerce_channel ' );
83+ $ this ->slack_message ($ message , "Payeezy Environment set to Production " , $ channel , $ icon );
84+ }
85+ update_option ('woocommerce_pe_testmode ' , 'false ' );
86+ }
87+
88+ if ($ settings ['enabled ' ] == 'no ' && get_option ('woocommerce_pe_enabled ' ) != 'false ' ) {
89+ update_option ('woocommerce_pe_enabled ' , 'false ' );
90+ $ message = "WARNING: Production website's Payeezy Gateway is not enabled " ;
91+ $ icon = ":warning: " ;
92+ $ channel = get_option ('wc_settings_tab_slack_woocommerce_channel ' );
93+ $ this ->slack_message ($ message , "Payeezy disabled " , $ channel , $ icon );
94+ } else if ($ settings ['enabled ' ] == 'yes ' ) {
95+ if (get_option ('woocommerce_pe_enabled ' ) == 'false ' ) {
96+ $ message = "Production website's Payeezy Gateway is enabled " ;
97+ $ icon = ":heavy_check_mark: " ;
98+ $ channel = get_option ('wc_settings_tab_slack_woocommerce_channel ' );
99+ $ this ->slack_message ($ message , "Payeezy Gateway enabled " , $ channel , $ icon );
100+ }
101+ update_option ('woocommerce_pe_enabled ' , 'true ' );
102+ }
103+ }
104+ public function clickandpledge_activate ()
105+ {
106+ $ message = " Production website's Click and Pledge Gateway is active! " ;
107+ $ icon = ":heavy_check_mark: " ;
108+ $ channel = get_option ('wc_settings_tab_slack_woocommerce_channel ' );
109+ $ this ->slack_message ($ message , "Click and Pledge Active " , $ channel , $ icon );
110+ }
111+ public function clickandpledge_deactivate ()
112+ {
113+ $ message = "WARNING: Production website's Click and Pledge Gateway is in not active! " ;
114+ $ icon = ":warning: " ;
115+ $ channel = get_option ('wc_settings_tab_slack_woocommerce_channel ' );
116+ $ this ->slack_message ($ message , "Click and Pledge Inactive " , $ channel , $ icon );
117+ }
118+ public function clickandpledge_testmode_check ()
119+ {
120+ if (is_wpe ()) {
121+ $ settings = get_option ('woocommerce_clickandpledge_settings ' );
122+ $ p_settings = get_option ('woocommerce_clickandpledge_paymentsettings ' );
123+
124+ if ($ p_settings ['testmode ' ] == 'yes ' ) {
125+ update_option ('woocommerce_cp_testmode ' , 'true ' );
126+ $ message = "WARNING: Production website's Click and Pledge Gateway is in Testmode " ;
127+ $ icon = ":warning: " ;
128+ $ channel = get_option ('wc_settings_tab_slack_woocommerce_channel ' );
129+ $ this ->slack_message ($ message , "Click and Pledge in Testmode " , $ channel , $ icon );
130+ } else {
131+ if (get_option ('woocommerce_cp_testmode ' ) == 'true ' ) {
132+ $ message = "Production website's Click and Pledge Gateway is in Production " ;
133+ $ icon = ":heavy_check_mark: " ;
134+ $ channel = get_option ('wc_settings_tab_slack_woocommerce_channel ' );
135+ $ this ->slack_message ($ message , "Click and Pledge in Production " , $ channel , $ icon );
136+ }
137+ update_option ('woocommerce_cp_testmode ' , 'false ' );
138+ }
139+
140+ if ($ p_settings ['enabled ' ] == 'yes ' ) {
141+ if (get_option ('woocommerce_cp_enabled ' ) == 'false ' ) {
142+ $ message = "Production website's Click and Pledge Gateway is enabled " ;
143+ $ icon = ":heavy_check_mark: " ;
144+ $ channel = get_option ('wc_settings_tab_slack_woocommerce_channel ' );
145+ $ this ->slack_message ($ message , "Click and Pledge enabled " , $ channel , $ icon );
146+ }
147+ update_option ('woocommerce_cp_enabled ' , 'true ' );
148+
149+ } else {
150+ update_option ('woocommerce_cp_enabled ' , 'false ' );
151+ $ message = "WARNING: Production website's Click and Pledge Gateway is not enabled " ;
152+ $ icon = ":warning: " ;
153+ $ channel = get_option ('wc_settings_tab_slack_woocommerce_channel ' );
154+ $ this ->slack_message ($ message , "Click and Pledge disabled " , $ channel , $ icon );
155+ }
156+
157+ }
158+
159+ }
160+
161+ }
0 commit comments