PluginProbe
WDesignKit – AI Templates, Widget Builder & MCP Workflow / 2.5.1
WDesignKit – AI Templates, Widget Builder & MCP Workflow v2.5.1
2.6.6 2.6.5 2.6.4 2.6.3 2.6.2 2.6.1 2.6.0 2.5.5 2.5.4 2.5.3 2.5.2 2.5.1 2.5.0 2.4.0 2.3.3 2.3.2 2.3.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 All 128 releases
wdesignkit / includes / admin / notices / class-wdkit-rating.php

class-wdkit-rating.php in WDesignKit – AI Templates, Widget Builder & MCP Workflow 2.5.1, at includes/admin/notices/class-wdkit-rating.php

355 lines 9.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Exit if accessed directly.
4 *
5 * @link https://posimyth.com/
6 * @since 1.0.17
7 *
8 * @package Wdesignkit
9 * @subpackage Wdesignkit/includes
10 * */
11
12 /**
13 * Exit if accessed directly.
14 * */
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit;
17 }
18
19 if ( ! class_exists( 'Wdkit_Rating' ) ) {
20
21 /**
22 * This class used for only load widget notice
23 *
24 * @since 1.0.17
25 */
26 class Wdkit_Rating {
27
28 /**
29 * Instance
30 *
31 * @since 1.0.17
32 * @var instance of the class.
33 */
34 private static $instance = null;
35
36 /**
37 * Current User Id
38 *
39 * @since 1.0.17
40 * @var user_id
41 */
42 public $user_id = '';
43
44 /**
45 * Rating Banner start time Store
46 *
47 * @since 1.0.17
48 * @var rb_start_date
49 */
50 public $rb_start_date = 'wdkit_rating_banner_start_date';
51
52 /**
53 * Instance
54 *
55 * Ensures only one instance of the class is loaded or can be loaded.
56 *
57 * @since 1.0.17
58 * @return instance of the class.
59 */
60 public static function instance() {
61 if ( is_null( self::$instance ) ) {
62 self::$instance = new self();
63 }
64
65 return self::$instance;
66 }
67
68 /**
69 * Constructor
70 *
71 * Perform some compatibility checks to make sure basic requirements are meet.
72 *
73 * @since 1.0.17
74 */
75 public function __construct() {
76 $this->wdkit_rating_banner_settime();
77 }
78
79 /**
80 * New widget demos link notice
81 *
82 * @since 1.0.17
83 */
84 public function wdkit_rating_banner_settime() {
85 $this->user_id = get_current_user_id();
86
87 $wdkit_rating_banner_start_date = get_user_meta( $this->user_id, $this->rb_start_date, true );
88
89 if ( false === $wdkit_rating_banner_start_date || empty($wdkit_rating_banner_start_date)) {
90 $start_date = new DateTime();
91 $start_date->modify( '+3 days' );
92 $new_date = $start_date->format( 'Y-m-d' );
93
94 add_user_meta( $this->user_id, $this->rb_start_date, $new_date, true );
95 }
96
97 if ( !empty( $wdkit_rating_banner_start_date ) ) {
98 $current_datetime = new DateTime();
99 $current_date = $current_datetime->format( 'Y-m-d' );
100
101 if ( $current_date > $wdkit_rating_banner_start_date ) {
102 add_action( 'admin_notices', array( $this, 'Wdkit_rating_banner' ) );
103
104 /**Rating Close Notice*/
105 add_action( 'wp_ajax_wdkit_rating_banner_dismiss_notice', array( $this, 'wdkit_rating_banner_dismiss_notice' ) );
106 }
107 }
108 }
109
110 /**
111 * New widget demos link notice
112 *
113 * @since 1.0.17
114 */
115 public function wdkit_rating_banner() {
116 $current_screen_id = get_current_screen()->id;
117
118 $nonce = wp_create_nonce( 'wdkit-rating-banner' );
119
120 $slugs = array(
121 'toplevel_page_wdesign-kit',
122
123 'toplevel_page_uichemy-welcome',
124 'uichemy_page_uichemy-settings',
125
126 'toplevel_page_theplus_welcome_page',
127 'theplus-settings_page_theplus_options',
128 'theplus-settings_page_theplus_import_data',
129 'theplus-settings_page_theplus_api_connection_data',
130 'theplus-settings_page_theplus_performance',
131 'theplus-settings_page_theplus_styling_data',
132 'theplus-settings_page_theplus_purchase_code',
133 'theplus-settings_page_theplus_white_label',
134
135 'toplevel_page_tpgb_welcome_page',
136 'the-plus-settings_page_tpgb_normal_blocks_opts',
137 'the-plus-settings_page_tpgb_connection_data',
138 'the-plus-settings_page_tpgb_performance',
139 'the-plus-settings_page_tpgb_custom_css_js',
140 'the-plus-settings_page_tpgb_activate',
141 'the-plus-settings_page_tpgb_white_label',
142 'edit-plus-mega-menu',
143
144 'plugins',
145 'dashboard',
146 );
147
148 if ( ! in_array( $current_screen_id, $slugs, true ) ) {
149 return false;
150 }
151
152 ?>
153 <style>
154 .wkit-review-container{
155 /* position: relative; */
156 font-family: 'Plus Jakarta Sans', sans-serif;
157 margin-left: -20px;
158 padding: 15px 15px 0px;
159 background: #f8f8f8;
160 }
161
162 .wkit-review-container .wkit-main-header {
163 position: relative;
164 display: flex;
165 flex-wrap: wrap;
166 justify-content: space-between;
167 padding: 20px;
168 align-items: center;
169 background: linear-gradient(#040483, #040483, #000044);
170 gap: 20px;
171 border-radius: 10px;
172 }
173
174 .wkit-review-container .wkit-main-header .wkit-notice-left-container{
175 display: flex;
176 justify-content: center;
177 align-items: center;
178 gap: 20px;
179 }
180
181 .wkit-review-container .wkit-review-text {
182 color: white;
183 display: flex;
184 flex-direction: column;
185 gap: 10px;
186 }
187
188 .wkit-review-container .wkit-review-text .wkit-experience-text {
189 font-size: 20px;
190 font-weight: 600;
191 line-height: 25px
192 }
193
194 .wkit-review-container .wkit-review-text .wkit-ratings {
195 font-size: 14px;
196 }
197
198 .wkit-review-container .wkit-btns {
199 display: flex;
200 gap: 15px;
201 }
202
203 .wkit-review-container .wkit-btns a {
204 font-size: 14px;
205 border-radius: 6px;
206 color: #FFFFFF;
207 padding: 12px 14px;
208 transition: 0.3s linear;
209 cursor: pointer;
210 white-space: nowrap;
211 text-decoration: none;
212 }
213
214 .wkit-review-container .wkit-btns .wkit-review-btn {
215 background: #C22076;
216 border: 1px solid #C22076;
217 }
218
219 .wkit-review-container .wkit-btns .wkit-review-btn:focus{
220 box-shadow: none;
221 outline: none;
222 }
223
224 .wkit-review-container .wkit-btns .wkit-help-btn:focus{
225 box-shadow: none;
226 outline: none;
227 }
228
229 .wkit-review-container .wkit-btns .wkit-review-btn:hover {
230 background: #9B1A5E;
231 border-color: #9B1A5E;
232 }
233
234 .wkit-review-container .wkit-btns .wkit-help-btn {
235 background: transparent;
236 border: 1px solid #FFFFFF;
237 }
238
239 .wkit-review-container .wkit-btns .wkit-help-btn:hover {
240 background: #ffffff08;
241
242 }
243
244 .wkit-review-container .wkit-close {
245 position: absolute;
246 top: -15px;
247 right: -15px;
248 cursor: pointer;
249 background: #fff;
250 padding: 2px;
251 border: 3px solid #efefef;
252 border-radius: 50px;
253 display: flex;
254 width: 20px;
255 height: 20px;
256 align-items: center;
257 justify-content: center;
258 }
259
260 @media(max-width:782px){
261
262 .wkit-review-container {
263 margin-left: -9px;
264 }
265 }
266
267 @media(max-width:768px) {
268 .wkit-main-header .wkit-review-text .wkit-experience-text {
269 font-size: 18px;
270 font-weight: 600;
271 }
272 }
273 </style>
274
275 <?php
276
277 echo '<div class="wkit-review-container">';
278 echo '<div class="wkit-main-header">';
279 echo '<div class="wkit-notice-left-container">';
280 echo '<img class="wkit-notice" draggable="false" src="' . esc_url(WDKIT_ASSETS . 'images/jpg/review-banner-image.png') . '">';
281 echo '<div class="wkit-review-text">';
282 echo '<span class="wkit-experience-text">' . esc_html__('Rate your Experience with WDesignKit', 'wdesignkit') . '</span>';
283 echo '<span class="wkit-ratings">' . esc_html__('Your feedback is important to us and helps us improve WDesignKit further.', 'wdesignkit') . '</span>';
284 echo '</div>';
285 echo '</div>';
286 echo '<div class="wkit-btns">';
287 echo '<a class="wkit-review-btn" href="' . esc_url('https://wordpress.org/support/plugin/wdesignkit/reviews/#new-post') . '" target="_blank">' . esc_html__('Give Review', 'wdesignkit') . '</a>';
288 echo '<a class="wkit-help-btn" href="' . esc_url('https://wordpress.org/support/plugin/wdesignkit/') . '" target="_blank">' . esc_html__('Need Help?', 'wdesignkit') . '</a>';
289 echo '</div>';
290 echo '<span class="wkit-close">';
291 echo '<svg width="10" height="10" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1.40091 15.2558C1.66182 15.5169 2.01481 15.6637 2.38274 15.6637C2.75067 15.6637 3.10366 15.5169 3.36456 15.2558L8.29499 10.2193L13.2254 15.2558C13.5884 15.6217 14.118 15.7645 14.6141 15.6306C15.1103 15.4967 15.4981 15.1062 15.6309 14.6064C15.7639 14.1067 15.6221 13.5733 15.2588 13.2076L10.2587 8.24141L15.2588 3.27521C15.5659 2.91424 15.6703 2.42082 15.5365 1.96497C15.4027 1.50913 15.0485 1.15236 14.5959 1.01757C14.1431 0.882762 13.6535 0.987976 13.2949 1.29727L8.29499 6.26348L3.36455 1.29727C3.00619 0.987976 2.51632 0.882762 2.06375 1.01757C1.61119 1.15237 1.257 1.50911 1.12317 1.96497C0.989339 2.42082 1.0938 2.91424 1.40087 3.27521L6.3313 8.24141L1.40087 13.2076C1.11968 13.4728 0.959961 13.8436 0.959961 14.2316C0.959961 14.6198 1.11968 14.9904 1.40087 15.2557L1.40091 15.2558Z" fill="black"></path></svg>';
292 echo '</span>';
293 echo '</div>';
294 echo '</div>';
295
296 ?>
297
298 <script>
299 jQuery('.wkit-review-container .wkit-close').on('click', function() {
300 jQuery.ajax({
301 url: ajaxurl,
302 type: 'POST',
303 data: {
304 action: 'wdkit_rating_banner_dismiss_notice',
305 security: "<?php echo esc_html( $nonce ); ?>",
306 },
307 dataType: 'json',
308 cache: false,
309 success: function(response) {
310 jQuery('.wkit-review-container').hide();
311 },
312 error: function(xhr, status, error) {
313 console.log('AJAX Error: ' + status + error);
314 }
315 });
316 });
317 </script>
318
319 <?php
320 }
321
322 /**
323 * It's is use for Save key in database Rating Notice Dismisse
324 *
325 * @since 1.0.17
326 */
327 public function wdkit_rating_banner_dismiss_notice() {
328
329 check_ajax_referer( 'wdkit-rating-banner', 'security' );
330
331 $send_json = array();
332 if ( ! current_user_can( 'manage_options' ) ) {
333 $send_json['message'] = __( 'You are not allowed to do this action', 'wdesignkit' );
334 $send_json['success'] = 0;
335
336 wp_send_json( $send_json );
337 }
338
339 $start_date = new DateTime();
340 $start_date->modify( '+14 days' );
341 $new_date = $start_date->format( 'Y-m-d' );
342
343 update_user_meta( $this->user_id, $this->rb_start_date, $new_date );
344
345 $send_json['message'] = __( 'Successfully Closed Rating Notice', 'wdesignkit' );
346 $send_json['success'] = 1;
347 $send_json['date'] = $new_date;
348
349 wp_send_json( $send_json );
350 wp_die();
351 }
352 }
353
354 Wdkit_Rating::instance();
355 }