PluginProbe
PayPlug for WooCommerce (Official) / 2.4.1
PayPlug for WooCommerce (Official) v2.4.1
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 / Admin / Notices.php

Notices.php in PayPlug for WooCommerce (Official) 2.4.1, at src/Admin/Notices.php

119 lines 4.1 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\Admin;
4
5 // Exit if accessed directly
6 if ( ! defined( 'ABSPATH' ) ) {
7 exit;
8 }
9
10 use Payplug\PayplugWoocommerce\PayplugWoocommerceHelper;
11
12 /**
13 * Handle admin notices.
14 *
15 * @package Payplug\PayplugWoocommerce\Admin
16 */
17 class Notices {
18
19 public function __construct() {
20 //add_action( 'admin_notices', [ $this, 'admin_notices' ] );
21 //add_action( 'admin_enqueue_scripts', [ $this, 'admin_enqueue_scripts' ] );
22 }
23
24 /**
25 * Enqueue PayPlug notice style.
26 *
27 * @return void
28 */
29 public function admin_enqueue_scripts() {
30 $options = get_option( 'woocommerce_payplug_settings' );
31 $payplug_test_key = ! empty( $options['payplug_test_key'] ) ? $options['payplug_test_key'] : '';
32 $payplug_live_key = ! empty( $options['payplug_live_key'] ) ? $options['payplug_live_key'] : '';
33 if ( empty( $payplug_test_key ) && empty( $payplug_live_key ) ) {
34 wp_enqueue_style(
35 'payplug-notice',
36 PAYPLUG_GATEWAY_PLUGIN_URL . 'assets/css/notice.css',
37 [],
38 PAYPLUG_GATEWAY_VERSION
39 );
40 }
41 }
42
43 /**
44 * Display admin notices.
45 *
46 * @return void
47 */
48 public function admin_notices() {
49 if ( ! current_user_can( 'manage_woocommerce' ) ) {
50 return;
51 }
52
53 /*
54 * Before Woocommerce 3.2.x, settings were saved just before displaying the page
55 * which cause the admin_notice to display old data.
56 *
57 * This condition check if we are on the PayPlug gateway settings page and if we
58 * have new settings to save. If true we hook the notice to a hook which will run after the new
59 * settings have been saved.
60 */
61 $screen = get_current_screen();
62 $wc = function_exists( 'WC' ) ? WC() : $GLOBALS['woocommerce'];
63
64 if (
65 version_compare( $wc->version, '3.2.0', '<' )
66 && ! empty( $_POST )
67 && 'woocommerce_page_wc-settings' === $screen->id
68 && isset( $_GET['section'] )
69 && 'payplug' === $_GET['section']
70 ) {
71 add_action( 'woocommerce_settings_saved', [ $this, 'display_notice' ] );
72
73 return;
74 }
75
76 $this->display_notice();
77 }
78
79 public function display_notice() {
80 $options = get_option( 'woocommerce_payplug_settings' );
81 $testmode = ( isset( $options['mode'] ) && 'no' === $options['mode'] ) ? true : false;
82 $payplug_test_key = ! empty( $options['payplug_test_key'] ) ? $options['payplug_test_key'] : '';
83 $payplug_live_key = ! empty( $options['payplug_live_key'] ) ? $options['payplug_live_key'] : '';
84
85 if ( empty( $payplug_test_key ) && empty( $payplug_live_key ) ) {
86 ?>
87 <div class="notice notice--start">
88 <div class="inside">
89 <div class="main">
90 <h2 class="notice__title"><?php _e( 'Thank you for installing PayPlug as your online payment solution.', 'payplug' ); ?>
91 <br>
92 <strong><?php _e( 'Only one step left to activate the plugin on your site !', 'payplug' ); ?></strong>
93 </h2>
94 <a href="<?php echo esc_url( PayplugWoocommerceHelper::get_setting_link() ); ?>"
95 class="button button-hero"><?php _e( 'Login', 'payplug' ); ?></a>
96 <img class="notice__img"
97 src="<?php echo esc_url( PAYPLUG_GATEWAY_PLUGIN_URL . 'assets/images/PAYPLUG_LOGO_blanc.svg' ); ?>"
98 alt="PayPlug logo">
99 </div>
100 </div>
101 </div>
102 <?php
103 } elseif ( ! empty( $payplug_test_key ) && empty( $payplug_live_key ) ) {
104 ?>
105 <div class="notice notice-warning">
106 <p><strong><?php _e( 'PayPlug is in TEST mode', 'payplug' ); ?></strong></p>
107 <p><?php _e( 'Once your PayPlug account has been validated, please log out and log in again from the configuration page in order to activate LIVE mode.', 'payplug' ); ?></p>
108 </div>
109 <?php
110 } elseif ( ! empty( $payplug_live_key ) && $testmode ) {
111 ?>
112 <div class="notice notice-info">
113 <p><?php _e( 'Payments in TEST mode will be simulations and will not generate real transactions.', 'payplug' ); ?></p>
114 </div>
115 <?php
116 }
117 }
118 }
119