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

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