33 * Plugin Name: Paystack WooCommerce Payment Gateway
44 * Plugin URI: https://paystack.com
55 * Description: WooCommerce payment gateway for Paystack
6- * Version: 5.7.5
6+ * Version: 5.7.6
77 * Author: Tunbosun Ayinla
88 * Author URI: https://bosun.me
99 * License: GPL-2.0+
1010 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
11- * WC requires at least: 6.1
12- * WC tested up to: 7.7
11+ * WC requires at least: 7.0
12+ * WC tested up to: 7.8
1313 * Text Domain: woo-paystack
1414 * Domain Path: /languages
1515 */
1616
17+ use Automattic \WooCommerce \Admin \Notes \Note ;
18+ use Automattic \WooCommerce \Admin \Notes \Notes ;
19+
1720if ( ! defined ( 'ABSPATH ' ) ) {
1821 exit ;
1922}
2023
2124define ( 'WC_PAYSTACK_MAIN_FILE ' , __FILE__ );
2225define ( 'WC_PAYSTACK_URL ' , untrailingslashit ( plugins_url ( '/ ' , __FILE__ ) ) );
2326
24- define ( 'WC_PAYSTACK_VERSION ' , '5.7.5 ' );
27+ define ( 'WC_PAYSTACK_VERSION ' , '5.7.6 ' );
2528
2629/**
2730 * Initialize Paystack WooCommerce payment gateway.
@@ -35,7 +38,7 @@ function tbz_wc_paystack_init() {
3538 return ;
3639 }
3740
38- add_action ( 'admin_notices ' , 'tbz_wc_paystack_testmode_notice ' );
41+ add_action ( 'admin_init ' , 'tbz_wc_paystack_testmode_notice ' );
3942
4043 require_once dirname ( __FILE__ ) . '/includes/class-wc-gateway-paystack.php ' ;
4144
@@ -145,21 +148,50 @@ function tbz_wc_paystack_wc_missing_notice() {
145148 **/
146149function tbz_wc_paystack_testmode_notice () {
147150
148- if ( ! current_user_can ( 'manage_options ' ) ) {
151+ if ( ! class_exists ( Notes::class ) ) {
152+ return ;
153+ }
154+
155+ if ( ! class_exists ( WC_Data_Store::class ) ) {
156+ return ;
157+ }
158+
159+ if ( ! method_exists ( Notes::class, 'get_note_by_name ' ) ) {
160+ return ;
161+ }
162+
163+ $ test_mode_note = Notes::get_note_by_name ( 'paystack-test-mode ' );
164+
165+ if ( false !== $ test_mode_note ) {
149166 return ;
150167 }
151168
152169 $ paystack_settings = get_option ( 'woocommerce_paystack_settings ' );
153- $ test_mode = isset ( $ paystack_settings ['testmode ' ] ) ? $ paystack_settings ['testmode ' ] : '' ;
170+ $ test_mode = $ paystack_settings ['testmode ' ] ?? '' ;
171+
172+ if ( 'yes ' !== $ test_mode ) {
173+ Notes::delete_notes_with_name ( 'paystack-test-mode ' );
154174
155- if ( 'yes ' === $ test_mode ) {
156- /* translators: 1. Paystack settings page URL link. */
157- echo '<div class="error"><p> ' . sprintf ( __ ( 'Paystack test mode is still enabled, Click <strong><a href="%s">here</a></strong> to disable it when you want to start accepting live payment on your site. ' , 'woo-paystack ' ), esc_url ( admin_url ( 'admin.php?page=wc-settings&tab=checkout§ion=paystack ' ) ) ) . '</p></div> ' ;
175+ return ;
158176 }
177+
178+ $ note = new Note ();
179+ $ note ->set_title ( __ ( 'Paystack test mode enabled ' , 'woo-paystack ' ) );
180+ $ note ->set_content ( __ ( 'Paystack test mode is currently enabled. Remember to disable it when you want to start accepting live payment on your site. ' , 'woo-paystack ' ) );
181+ $ note ->set_type ( Note::E_WC_ADMIN_NOTE_INFORMATIONAL );
182+ $ note ->set_layout ( 'plain ' );
183+ $ note ->set_is_snoozable ( false );
184+ $ note ->set_name ( 'paystack-test-mode ' );
185+ $ note ->set_source ( 'woo-paystack ' );
186+ $ note ->add_action ( 'disable-paystack-test-mode ' , __ ( 'Disable Paystack test mode ' , 'woo-paystack ' ), admin_url ( 'admin.php?page=wc-settings&tab=checkout§ion=paystack ' ) );
187+ $ note ->save ();
159188}
160189
161- add_action ( 'before_woocommerce_init ' , function () {
162- if ( class_exists ( \Automattic \WooCommerce \Utilities \FeaturesUtil::class ) ) {
163- \Automattic \WooCommerce \Utilities \FeaturesUtil::declare_compatibility ( 'custom_order_tables ' , __FILE__ , true );
190+ add_action (
191+ 'before_woocommerce_init ' ,
192+ function () {
193+ if ( class_exists ( \Automattic \WooCommerce \Utilities \FeaturesUtil::class ) ) {
194+ \Automattic \WooCommerce \Utilities \FeaturesUtil::declare_compatibility ( 'custom_order_tables ' , __FILE__ , true );
195+ }
164196 }
165- } );
197+ );
0 commit comments