PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.5.3
ShopBuilder – WooCommerce Builder For Elementor v2.5.3
3.4.2 3.4.1 3.4.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 All 63 releases
shopbuilder / app / Controllers / Admin / Notice / Review.php

Review.php in ShopBuilder – WooCommerce Builder For Elementor 2.5.3, at app/Controllers/Admin/Notice/Review.php

306 lines 8.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Review class.
4 *
5 * @package RadiusTheme\SB
6 */
7
8 namespace RadiusTheme\SB\Controllers\Admin\Notice;
9
10 use RadiusTheme\SB\Models\ExtraSettings;
11 use RadiusTheme\SB\Traits\SingletonTrait;
12
13 /**
14 * Review class.
15 */
16 class Review {
17 /**
18 * Singleton
19 */
20 use SingletonTrait;
21
22 /**
23 * Class constructor.
24 */
25 private function __construct() {
26 add_action( 'admin_init', [ $this, 'check_installation_time' ], 10 );
27 add_action( 'admin_init', [ $this, 'notice_actions' ], 5 );
28 }
29
30 /**
31 * Check if review notice should be shown or not
32 *
33 * @return void
34 */
35 public function check_installation_time() {
36
37 $nobug = get_option( 'rtsb_admin_review_spare_me' );
38 $rated = get_option( 'rtsb_admin_review_rated' );
39
40 if ( '1' == $nobug || 'yes' == $rated ) {
41 return;
42 }
43
44 $now = strtotime( 'now' );
45
46 $install_date = ExtraSettings::instance()->get_option( 'rtsb_plugin_activation_time', false );
47 $showing_date = strtotime( '+15 days', $install_date );
48 $remind_time = get_option( 'rtsb_admin_review_remind_me' );
49
50 if ( ! $remind_time ) {
51 $remind_time = $install_date;
52 }
53
54 $remind_due = strtotime( '+20 days', $remind_time );
55
56 if ( ! $now > $showing_date || $now < $remind_due ) {
57 return;
58 }
59
60 add_action( 'admin_notices', [ $this, 'display_admin_notice' ] );
61 }
62
63 /**
64 * Remove the notice for the user if review already done or if the user does not want to
65 *
66 * @return void
67 */
68 public function notice_actions() {
69 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash
70 if ( ! isset( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'rtsb_notice_nonce' ) ) {
71 return;
72 }
73
74 if ( ! empty( $_GET['rtsb_admin_review_spare_me'] ) ) {
75 $spare_me = absint( $_GET['rtsb_admin_review_spare_me'] );
76
77 if ( 1 == $spare_me ) {
78 update_option( 'rtsb_admin_review_spare_me', '1' );
79 }
80 }
81
82 if ( ! empty( $_GET['rtsb_admin_review_remind_me'] ) ) {
83 $remind_me = absint( $_GET['rtsb_admin_review_remind_me'] );
84
85 if ( 1 == $remind_me ) {
86 $get_activation_time = strtotime( 'now' );
87
88 update_option( 'rtsb_admin_review_remind_me', $get_activation_time );
89 }
90 }
91
92 if ( ! empty( $_GET['rtsb_admin_review_rated'] ) ) {
93 $rtsb_admin_review_rated = absint( $_GET['rtsb_admin_review_rated'] );
94
95 if ( 1 == $rtsb_admin_review_rated ) {
96 update_option( 'rtsb_admin_review_rated', 'yes' );
97 }
98 }
99 }
100
101 /**
102 * @return false|string
103 */
104 protected function rtsb_current_admin_url() {
105 $uri = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
106 $uri = preg_replace( '|^.*/wp-admin/|i', '', $uri );
107
108 if ( ! $uri ) {
109 return '';
110 }
111
112 return remove_query_arg(
113 [
114 '_wpnonce',
115 '_wc_notice_nonce',
116 'wc_db_update',
117 'wc_db_update_nonce',
118 'wc-hide-notice',
119 'rtsb_admin_review_spare_me',
120 'rtsb_admin_review_remind_me',
121 'rtsb_admin_review_rated',
122 ],
123 admin_url( $uri )
124 );
125 }
126 /**
127 * Display Admin Notice, asking for a review
128 **/
129 public function display_admin_notice() {
130 if ( isset( $GLOBALS['woobundle_notice'] ) || isset( $GLOBALS['rtsb__notice'] ) ) {
131 return;
132 }
133 global $pagenow;
134
135 $exclude = [
136 'themes.php',
137 'users.php',
138 'tools.php',
139 'options-general.php',
140 'options-writing.php',
141 'options-reading.php',
142 'options-discussion.php',
143 'options-media.php',
144 'options-permalink.php',
145 'options-privacy.php',
146 'admin.php',
147 'import.php',
148 'export.php',
149 'site-health.php',
150 'export-personal-data.php',
151 'erase-personal-data.php',
152 ];
153
154 if ( ! in_array( $pagenow, $exclude, true ) ) {
155 $args = [ '_wpnonce' => wp_create_nonce( 'rtsb_notice_nonce' ) ];
156 $dont_disturb = add_query_arg( $args + [ 'rtsb_admin_review_spare_me' => '1' ], $this->rtsb_current_admin_url() );
157 $remind_me = add_query_arg( $args + [ 'rtsb_admin_review_remind_me' => '1' ], $this->rtsb_current_admin_url() );
158 $rated = add_query_arg( $args + [ 'rtsb_admin_review_rated' => '1' ], $this->rtsb_current_admin_url() );
159 $reviewurl = 'https://wordpress.org/support/plugin/shopbuilder/reviews/?filter=5#new-post';
160 $plugin_name = 'ShopBuilder – Elementor WooCommerce Builder Addons';
161 ?>
162 <div class="notice rtsb-review-notice rtsb-review-notice--extended">
163 <div class="rtsb-review-notice_content">
164 <h3>Enjoying <?php echo esc_html( $plugin_name ); ?>? </h3>
165 <p>Thank you for choosing <strong>ShopBuilder</strong>. If you have found our plugin useful and makes you smile, please consider giving us a 5-star rating on WordPress.org. It will help us to grow.</p>
166 <div class="rtsb-review-notice_actions">
167 <a href="<?php echo esc_url( $reviewurl ); ?>"
168 class="rtsb-review-button rtsb-review-button--cta" target="_blank"><span> Yes, You Deserve It!</span></a>
169 <a href="<?php echo esc_url( $rated ); ?>"
170 class="rtsb-review-button rtsb-review-button--cta rtsb-review-button--outline"><span>😀 Already Rated!</span></a>
171 <a href="<?php echo esc_url( $remind_me ); ?>"
172 class="rtsb-review-button rtsb-review-button--cta rtsb-review-button--outline"><span>🔔 Remind Me Later</span></a>
173 <a href="<?php echo esc_url( $dont_disturb ); ?>"
174 class="rtsb-review-button rtsb-review-button--cta rtsb-review-button--error rtsb-review-button--outline"><span>😐 No Thanks </span></a>
175 </div>
176 </div>
177 </div>
178 <style>
179 .rtsb-review-button--cta {
180 --e-button-context-color: #4360ef;
181 --e-button-context-color-dark: #1f3edc;
182 --e-button-context-tint: rgb(75 47 157/4%);
183 --e-focus-color: rgb(75 47 157/40%);
184 }
185
186 .rtsb-review-notice {
187 position: relative;
188 margin: 5px 20px 5px 2px;
189 border: 1px solid #ccd0d4;
190 background: #fff;
191 box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
192 font-family: Roboto, Arial, Helvetica, Verdana, sans-serif;
193 border-inline-start-width: 4px;
194 }
195 .rtsb-review-notice.notice {
196 padding: 0;
197 }
198 .rtsb-review-notice:before {
199 position: absolute;
200 top: -1px;
201 bottom: -1px;
202 left: -4px;
203 display: block;
204 width: 4px;
205 background: -webkit-linear-gradient(0deg, #5d3dfd 0%, #6939c6 100%);
206 background: linear-gradient(0deg, #5d3dfd 0%, #6939c6 100%);
207 content: "";
208 }
209
210 .rtsb-review-notice_content {
211 padding: 20px;
212 }
213
214 .rtsb-review-notice_actions > * + * {
215 margin-inline-start: 8px;
216 -webkit-margin-start: 8px;
217 -moz-margin-start: 8px;
218 }
219
220 .rtsb-review-notice p {
221 margin: 0;
222 padding: 0;
223 line-height: 1.5;
224 }
225
226 p + .rtsb-review-notice_actions {
227 margin-top: 1rem;
228 }
229
230 .rtsb-review-notice h3 {
231 margin: 0;
232 font-size: 1.0625rem;
233 line-height: 1.2;
234 }
235
236 .rtsb-review-notice h3 + p {
237 margin-top: 8px;
238 }
239
240 .rtsb-review-button {
241 display: inline-block;
242 padding: 0.4375rem 0.75rem;
243 border: 0;
244 border-radius: 3px;;
245 background: var(--e-button-context-color);
246 color: #fff;
247 vertical-align: middle;
248 text-align: center;
249 text-decoration: none;
250 white-space: nowrap;
251 }
252
253 .rtsb-review-button:active {
254 background: var(--e-button-context-color-dark);
255 color: #fff;
256 text-decoration: none;
257 }
258
259 .rtsb-review-button:focus {
260 outline: 0;
261 background: var(--e-button-context-color-dark);
262 box-shadow: 0 0 0 2px var(--e-focus-color);
263 color: #fff;
264 text-decoration: none;
265 }
266
267 .rtsb-review-button:hover {
268 background: var(--e-button-context-color-dark);
269 color: #fff;
270 text-decoration: none;
271 }
272
273 .rtsb-review-button.focus {
274 outline: 0;
275 box-shadow: 0 0 0 2px var(--e-focus-color);
276 }
277
278 .rtsb-review-button--error {
279 --e-button-context-color: #d72b3f;
280 --e-button-context-color-dark: #ae2131;
281 --e-button-context-tint: rgba(215, 43, 63, 0.04);
282 --e-focus-color: rgba(215, 43, 63, 0.4);
283 }
284
285 .rtsb-review-button.rtsb-review-button--outline {
286 border: 1px solid;
287 background: 0 0;
288 color: var(--e-button-context-color);
289 }
290
291 .rtsb-review-button.rtsb-review-button--outline:focus {
292 background: var(--e-button-context-tint);
293 color: var(--e-button-context-color-dark);
294 }
295
296 .rtsb-review-button.rtsb-review-button--outline:hover {
297 background: var(--e-button-context-tint);
298 color: var(--e-button-context-color-dark);
299 }
300 </style>
301 <?php
302 }
303 }
304
305 }
306