PluginProbe
PayPlug for WooCommerce (Official) / 1.0.3
PayPlug for WooCommerce (Official) v1.0.3
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) 1.0.3, at src/Admin/Notices.php

175 lines 5.9 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 }
22
23 /**
24 * Display admin notices.
25 *
26 * @return void
27 */
28 public function admin_notices() {
29 if ( ! current_user_can( 'manage_woocommerce' ) ) {
30 return;
31 }
32
33 /*
34 * Before Woocommerce 3.2.x, settings were saved just before displaying the page
35 * which cause the admin_notice to display old data.
36 *
37 * This condition check if we are on the PayPlug gateway settings page and if we
38 * have new settings to save. If true we hook the notice to a hook which will run after the new
39 * settings have been saved.
40 */
41 $screen = get_current_screen();
42 $wc = function_exists( 'WC' ) ? WC() : $GLOBALS['woocommerce'];
43
44 if (
45 version_compare( $wc->version, '3.2.0', '<' )
46 && ! empty( $_POST )
47 && 'woocommerce_page_wc-settings' === $screen->id
48 && isset( $_GET['section'] )
49 && 'payplug' === $_GET['section']
50 ) {
51 add_action( 'woocommerce_settings_saved', [ $this, 'display_notice' ] );
52
53 return;
54 }
55
56 $this->display_notice();
57 }
58
59 public function display_notice() {
60 $options = get_option( 'woocommerce_payplug_settings' );
61 $testmode = ( isset( $options['mode'] ) && 'no' === $options['mode'] ) ? true : false;
62 $payplug_test_key = ! empty( $options['payplug_test_key'] ) ? $options['payplug_test_key'] : '';
63 $payplug_live_key = ! empty( $options['payplug_live_key'] ) ? $options['payplug_live_key'] : '';
64
65 if ( empty( $payplug_test_key ) && empty( $payplug_live_key ) ) {
66 ?>
67 <style>
68 .notice--start {
69 position: relative;
70 border: 0;
71 padding: 30px 40px;
72 background: url(<?php echo esc_url( PAYPLUG_GATEWAY_PLUGIN_URL . 'assets/images/bg_notice--start.jpg' ); ?>) no-repeat 50% 50%;
73 background-size: cover;
74 }
75
76 .notice--start:before {
77 content: "";
78 display: block;
79 z-index: 1;
80 position: absolute;
81 top: 0;
82 right: 0;
83 bottom: 0;
84 left: 0;
85 background-color: #49829f;
86 opacity: .28;
87 }
88
89 .notice--start .main {
90 position: relative;
91 z-index: 2;
92 }
93
94 .notice--start .notice__title {
95 margin-top: 0;
96 color: #fff;
97 font-size: 16px;
98 font-weight: 400;
99 line-height: 1.55;
100 }
101
102 .notice--start .notice__title strong {
103 font-size: 20px;
104 font-weight: 700;
105 }
106
107 .notice--start .button.button-hero {
108 font-weight: 400;
109 font-size: 16px;
110 height: 46px;
111 box-shadow: none;
112 color: #fff;
113 border-color: #55bf9c;
114 background-color: #55bf9c;
115 }
116
117 .notice--start .button:hover,
118 .notice--start .button:focus,
119 .notice--start .button:active {
120 color: #fff;
121 border-color: #4a977d;
122 background-color: #4a977d;
123 }
124
125 .notice--start .notice__img {
126 display: block;
127 margin: auto;
128 }
129
130 @media screen and (min-width: 48em) {
131 .notice--start .main {
132 padding-right: 250px;
133 }
134
135 .notice--start .notice__img {
136 margin: 0;
137 position: absolute;
138 right: 0;
139 top: 50%;
140 transform: translateY(-50%);
141 }
142 }
143 </style>
144 <div class="notice notice--start">
145 <div class="inside">
146 <div class="main">
147 <h2 class="notice__title"><?php _e( 'Thank you for installing PayPlug as your online payment solution.', 'payplug' ); ?>
148 <br>
149 <strong><?php _e( 'Only one step left to activate the plugin on your site !', 'payplug' ); ?></strong>
150 </h2>
151 <a href="<?php echo esc_url( PayplugWoocommerceHelper::get_setting_link() ); ?>"
152 class="button button-hero"><?php _e( 'Login', 'payplug' ); ?></a>
153 <img class="notice__img"
154 src="<?php echo esc_url( PAYPLUG_GATEWAY_PLUGIN_URL . 'assets/images/Payplug_logoWhite.png' ); ?>"
155 alt="PayPlug logo">
156 </div>
157 </div>
158 </div>
159 <?php
160 } elseif ( ! empty( $payplug_test_key ) && empty( $payplug_live_key ) ) {
161 ?>
162 <div class="notice notice-warning">
163 <p><strong><?php _e( 'PayPlug is in TEST mode', 'payplug' ); ?></strong></p>
164 <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>
165 </div>
166 <?php
167 } elseif ( ! empty( $payplug_live_key ) && $testmode ) {
168 ?>
169 <div class="notice notice-info">
170 <p><?php _e( 'Payments in TEST mode will be simulations and will not generate real transactions.', 'payplug' ); ?></p>
171 </div>
172 <?php
173 }
174 }
175 }