PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 3.4.2
ShopBuilder – WooCommerce Builder For Elementor v3.4.2
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 3.4.2, at app/Controllers/Admin/Notice/Review.php

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