PluginProbe
WDesignKit – AI Templates, Widget Builder & MCP Workflow / 1.0.21
WDesignKit – AI Templates, Widget Builder & MCP Workflow v1.0.21
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
← All changes | includes/admin/class-api.php +954 -2864 2.3.31.0.21 View file →
@@ -36,31 +36,15 @@
36 36
37 37 /**
38 38 * Member Variable
39 39 *
40 - * @var staring widgets_with_post_category
41 - */
42 - public $widgets_with_post_category = array(
43 - 'post_category', 'include_products',
44 - );
45 -
46 - /**
47 - * Member Variable
48 - *
49 40 * @var staring $wdkit_api
50 41 */
51 - public $wdkit_api = WDKIT_SERVER_API_URL . 'api/wp/';
42 + public $wdkit_api = WDKIT_SERVER_SITE_URL . 'api/wp/';
52 43
53 44 /**
54 45 * Member Variable
55 46 *
56 - * @var staring $wdkit_api_v2
57 - */
58 - public $wdkit_api_v2 = WDKIT_SERVER_API_URL . 'api/v2/wp/';
59 -
60 - /**
61 - * Member Variable
62 - *
63 47 * @var staring $widget_folder_u_r_l
64 48 */
65 49 public $widget_folder_u_r_l = '';
66 50
@@ -114,10 +98,8 @@
114 98 * Error JSON message
115 99 *
116 100 * @param array $data give array.
117 101 * @param string $status api code number.
118 - *
119 - * @since 1.0.0
120 102 * */
121 103 public function wdkit_error_msg( $data = null, $status = null ) {
122 104 wp_send_json_error( $data );
123 105 wp_die();
@@ -127,10 +109,8 @@
127 109 * Success JSON message
128 110 *
129 111 * @param array $data give array.
130 112 * @param string $status api code number.
131 - *
132 - * @since 1.0.0
133 113 * */
134 114 public function wdkit_success_msg( $data = null, $status = null ) {
135 115 wp_send_json_success( $data, $status );
136 116 wp_die();
@@ -156,40 +136,33 @@
156 136 case 'onboarding_handler':
157 137 $data = $this->wdkit_onboarding_handler();
158 138 break;
159 139 case 'wkit_login':
160 - $data = apply_filters( 'wp_wdkit_login_ajax', 'wkit_login' );
140 + $data = $this->wdkit_login();
161 141 break;
162 142 case 'api_login':
163 - $data = apply_filters( 'wp_wdkit_login_ajax', 'api_login' );
143 + $data = $this->wdkit_api_login();
164 144 break;
165 145 case 'social_login':
166 - $data = apply_filters( 'wp_wdkit_login_ajax', 'social_login' );
146 + $data = $this->wdkit_social_login();
167 147 break;
168 - case 'forgot_password':
169 - $data = apply_filters( 'wp_wdkit_login_ajax', 'forgot_password' );
170 - break;
171 - case 'wdkit_user_signup':
172 - $data = apply_filters( 'wp_wdkit_login_ajax', 'wdkit_user_signup' );
173 - break;
174 148 case 'wkit_meta_data':
175 149 $data = $this->wdkit_meta_data();
176 150 break;
177 151 case 'get_user_info':
152 + $id = isset( $_POST['id'] ) ? strtolower( sanitize_text_field( wp_unslash( $_POST['id'] ) ) ) : false;
178 153 $data = $this->wdkit_get_user_info();
179 154 break;
180 155 case 'browse_page':
181 156 $data = $this->wdkit_browse_page();
182 157 break;
158 + case 'widget_browse_page':
159 + $data = $this->wdkit_widget_browse_page();
160 + break;
183 161 case 'kit_template':
162 + $id = isset( $_POST['id'] ) ? strtolower( sanitize_text_field( wp_unslash( $_POST['id'] ) ) ) : false;
184 163 $data = $this->wdkit_template();
185 164 break;
186 - case 'wkit_preset_template':
187 - $data = apply_filters( 'wp_wdkit_preset_ajax', 'wdkit_preset_template' );
188 - break;
189 - case 'wdkit_preset_dwnld_template':
190 - $data = apply_filters( 'wp_wdkit_preset_ajax', 'wdkit_preset_dwnld_template' );
191 - break;
192 165 case 'template_remove':
193 166 $data = $this->wdkit_template_remove();
194 167 break;
195 168 case 'save_template':
@@ -194,29 +167,8 @@
194 167 break;
195 168 case 'save_template':
196 169 $data = $this->wdkit_put_save_template();
197 170 break;
198 - case 'update_save_temp_image':
199 - $data = $this->wdkit_update_save_temp_image();
200 - break;
201 - case 'save_wp_images':
202 - $data = $this->wdkit_save_wp_images();
203 - break;
204 - case 'get_global_val':
205 - $data = $this->wdkit_get_global_val();
206 - break;
207 - case 'update_global_val':
208 - $data = $this->wdkit_update_global_val();
209 - break;
210 - case 'wdkit_get_site_setting':
211 - $data = $this->wdkit_get_site_setting();
212 - break;
213 - case 'wdkit_update_site_setting':
214 - $data = $this->wdkit_update_site_setting();
215 - break;
216 - case 'update_preset_setting':
217 - $data = $this->wdkit_update_preset();
218 - break;
219 171 case 'find_template':
220 172 $data = $this->wdkit_find_existing_template();
221 173 break;
222 174 case 'update_template':
@@ -230,62 +182,11 @@
230 182 break;
231 183 case 'install_plugins_depends':
232 184 $data = $this->wdkit_install_plugins_depends();
233 185 break;
234 - case 'generate_site_logo':
235 - $data = $this->wkit_generate_site_logo();
236 - break;
237 - case 'generate_ai_content':
238 - $data = apply_filters( 'wp_wdkit_import_temp_ajax', 'generate_ai_content' );
239 - break;
240 - case 'reset_site':
241 - $data = apply_filters( 'wp_wdkit_import_temp_ajax', 'reset_site' );
242 - break;
243 - case 'wdkit_nxt_thembuilder_reset':
244 - $data = $this->wdkit_nxt_thembuilder_reset();
245 - break;
246 - case 'wdkit_check_user_credit':
247 - $data = $this->wdkit_check_user_credit();
248 - break;
249 - case 'wdkit_remove_header_footer':
250 - $data = apply_filters( 'wp_wdkit_import_temp_ajax', 'wdkit_remove_header_footer' );
251 - break;
252 - case 'check_post_count':
253 - $data = apply_filters( 'wp_wdkit_import_temp_ajax', 'check_post_count' );
254 - break;
255 - case 'wkit_check_product_count':
256 - $data = apply_filters( 'wp_wdkit_import_temp_ajax', 'wkit_check_product_count' );
257 - break;
258 - case 'select_team_img':
259 - $data = apply_filters( 'wp_wdkit_import_temp_ajax', 'select_team_img' );
260 - break;
261 - case 'wkit_ai_desc_keyword':
262 - $data = apply_filters( 'wp_wdkit_import_temp_ajax', 'wkit_ai_desc_keyword' );
263 - break;
264 - case 'wkit_ai_credit_update':
265 - $data = apply_filters( 'wp_wdkit_import_temp_ajax', 'wkit_ai_credit_update' );
266 - break;
267 - case 'wkit_generate_post_data':
268 - $data = apply_filters( 'wp_wdkit_import_temp_ajax', 'wkit_generate_post_data' );
269 - break;
270 - case 'wkit_generate_product_data':
271 - $data = apply_filters( 'wp_wdkit_import_temp_ajax', 'wkit_generate_product_data' );
272 - break;
273 - case 'wkit_cteate_product':
274 - $data = apply_filters( 'wp_wdkit_import_temp_ajax', 'wkit_cteate_product' );
275 - break;
276 - case 'wkit_remove_dummy_post':
277 - $data = apply_filters( 'wp_wdkit_import_temp_ajax', 'wkit_remove_dummy_post' );
278 - break;
279 186 case 'update_latest_plugin':
280 187 $data = $this->wdkit_update_latest_plugin();
281 188 break;
282 - case 'activate_container':
283 - $data = $this->wdkit_activate_container();
284 - break;
285 - case 'import_taxonomy':
286 - $data = $this->wdkit_import_taxonomy();
287 - break;
288 189 case 'import_template':
289 190 $data = $this->wdkit_import_template();
290 191 break;
291 192 case 'import_multi_template':
@@ -290,55 +191,11 @@
290 191 break;
291 192 case 'import_multi_template':
292 193 $data = $this->wdkit_import_multi_template();
293 194 break;
294 - case 'import_page_section':
295 - $data = $this->import_page_section_content();
296 - break;
297 - case 'wkit_update_elementor_template':
298 - $data = $this->wkit_update_elementor_template();
299 - break;
300 - case 'update_plugin_setting':
301 - $data = $this->update_plugin_setting();
302 - break;
303 - case 'update_theme_setting':
304 - $data = $this->update_theme_setting();
305 - break;
306 - case 'update_site_setting':
307 - $data = $this->update_site_setting();
308 - break;
309 195 case 'import_kit_template':
310 196 $data = $this->wdkit_import_kit_template();
311 197 break;
312 - case 'enable_template_widgets':
313 - $data = $this->wdkit_enable_template_widgets();
314 - break;
315 - case 'scan_nexter_widgets':
316 - if ( ! empty( $_POST['blockNames'] ) && has_filter( 'nexter_block_list_merge' ) ) {
317 -
318 - $posted_blocks = json_decode( stripslashes( $_POST['blockNames'] ), true );
319 -
320 - if ( is_array( $posted_blocks ) ) {
321 - $blockList = array_map( 'sanitize_text_field', $posted_blocks );
322 -
323 - // अब filter call करो
324 - $result = apply_filters( 'nexter_block_list_merge', $blockList );
325 -
326 - wp_send_json( $result );
327 - wp_die();
328 - }
329 - }
330 -
331 - wp_send_json(
332 - array(
333 - 'success' => false,
334 - 'message' => 'No block names received or filter not found.',
335 - 'description' => 'Ensure blockNames are posted and the filter is attached.',
336 - )
337 - );
338 - wp_die();
339 - $data = '';
340 - break;
341 198 case 'shared_with_me':
342 199 $data = $this->wdkit_shared_with_me();
343 200 break;
344 201 case 'manage_workspace':
@@ -343,29 +200,8 @@
343 200 break;
344 201 case 'manage_workspace':
345 202 $data = $this->wdkit_manage_workspace();
346 203 break;
347 - case 'widget_browse_page':
348 - $data = apply_filters( 'wp_wdkit_widget_ajax', 'widget_browse_page' );
349 - break;
350 - case 'wkit_create_widget':
351 - $data = apply_filters( 'wp_wdkit_widget_ajax', 'wkit_create_widget' );
352 - break;
353 - case 'wkit_import_widget':
354 - $data = apply_filters( 'wp_wdkit_widget_ajax', 'wkit_import_widget' );
355 - break;
356 - case 'wkit_export_widget':
357 - $data = apply_filters( 'wp_wdkit_widget_ajax', 'wkit_export_widget' );
358 - break;
359 - case 'wkit_delete_widget':
360 - $data = apply_filters( 'wp_wdkit_widget_ajax', 'wkit_delete_widget' );
361 - break;
362 - case 'wkit_widget_preview':
363 - $data = apply_filters( 'wp_wdkit_widget_ajax', 'wkit_widget_preview' );
364 - break;
365 - case 'wkit_check_widget_versions':
366 - $data = apply_filters( 'wp_wdkit_widget_ajax', 'wkit_check_widget_versions' );
367 - break;
368 204 case 'wkit_manage_widget_workspace':
369 205 $data = $this->wdkit_manage_widget_workspace();
370 206 break;
371 207 case 'wkit_activate_key':
@@ -373,16 +209,25 @@
373 209 break;
374 210 case 'wkit_manage_widget_category':
375 211 $data = $this->wdkit_manage_widget_category();
376 212 break;
377 - case 'wkit_widget_json':
378 - $data = $this->wkit_widget_json();
213 + case 'wkit_create_widget':
214 + $data = $this->wdkit_create_widget();
379 215 break;
216 + case 'wkit_export_widget':
217 + $data = $this->wdkit_export_widget();
218 + break;
219 + case 'wkit_import_widget':
220 + $data = $this->wdkit_import_widget();
221 + break;
222 + case 'wkit_delete_widget':
223 + $data = $this->wdkit_delete_widget();
224 + break;
380 225 case 'wkit_download_widget':
381 226 $data = $this->wdkit_download_widget();
382 227 break;
383 228 case 'wkit_public_download_widget':
384 - $data = apply_filters( 'wp_wdkit_widget_ajax', 'wkit_public_download_widget' );
229 + $data = $this->wdkit_public_download_widget();
385 230 break;
386 231 case 'wkit_add_widget':
387 232 $data = $this->wdkit_add_widget();
388 233 break;
@@ -403,33 +248,14 @@
403 248 break;
404 249 case 'sync_licence':
405 250 $data = $this->wdkit_sync_licence_key();
406 251 break;
407 - case 'get_wkit_version':
408 - $data = $this->wdkit_prev_version();
409 - break;
410 - case 'rollback_wdkit':
411 - $data = $this->wdkit_rollback_check();
412 - break;
413 252 case 'wkit_logout':
414 253 $data = $this->wdkit_logout();
415 254 break;
416 - case 'wkit_white_label':
417 - $this->wkit_white_label();
418 - break;
419 - case 'wkit_reset_wl':
420 - $data = $this->wkit_reset_wl();
421 - break;
422 - case 'wdkit_dark_mode':
423 - $data = $this->wdkit_dark_mode();
424 - break;
425 - case 'wdkit_get_workspace_data':
426 - $data = $this->wdkit_get_workspace_data();
427 - break;
428 255 }
429 256
430 257 $this->wdkit_success_msg( $data );
431 - // wp_die();
432 258 }
433 259
434 260 /**
435 261 *
@@ -493,9 +319,41 @@
493 319 );
494 320 }
495 321
496 322 /**
323 + * This Function is used for API call
497 324 *
325 + * @since 1.0.0
326 + *
327 + * @param string $user_key Dynamic key.
328 + * @param string $user_email User email.
329 + * @param string $token User token.
330 + */
331 + protected function wdkit_set_time_out( $user_key, $user_email, $token, $login_type = '' ) {
332 +
333 + if ( 'normal' === $login_type ) {
334 + set_transient(
335 + 'wdkit_auth_' . $user_key,
336 + array(
337 + 'user_email' => sanitize_email( $user_email ),
338 + 'token' => $token,
339 + ),
340 + 7776000
341 + );
342 + } else {
343 + set_transient(
344 + 'wdkit_auth_' . $user_key,
345 + array(
346 + 'user_email' => sanitize_email( $user_email ),
347 + 'token' => $token,
348 + ),
349 + 86400
350 + );
351 + }
352 + }
353 +
354 + /**
355 + *
498 356 * It is Use for handle onboarding data.
499 357 *
500 358 * @since 1.0.9
501 359 */
@@ -505,9 +363,8 @@
505 363
506 364 $elementor_plugin = isset( $_POST['elementor_plugin'] ) ? (int) sanitize_text_field( wp_unslash( $_POST['elementor_plugin'] ) ) : 0;
507 365 $tpag_plugin = isset( $_POST['tpag_plugin'] ) ? (int) sanitize_text_field( wp_unslash( $_POST['tpag_plugin'] ) ) : 0;
508 366 $bricks_theme = isset( $_POST['bricks_theme'] ) ? (int) sanitize_text_field( wp_unslash( $_POST['bricks_theme'] ) ) : 0;
509 - $site_info = isset( $_POST['info'] ) ? sanitize_text_field( wp_unslash( $_POST['info'] ) ) : false;
510 367
511 368 $server_software = ! empty( $_SERVER['SERVER_SOFTWARE'] ) ? sanitize_text_field( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) ) : '';
512 369
513 370 $web_server = $server_software;
@@ -546,27 +403,23 @@
546 403 'tpag_install' => $tpag_plugin,
547 404 'bricks_install' => $bricks_theme,
548 405 );
549 406
550 - if ( ! empty( $site_info ) ) {
551 - $final = array(
552 - 'web_server' => $web_server,
553 - 'memory_limit' => $memory_limit,
554 - 'max_execution_time' => $max_execution_time,
555 - 'php_version' => $php_version,
556 - 'wp_version' => $wp_version,
557 - 'email' => $email,
558 - 'site_url' => $siteurl,
559 - 'site_language' => $language,
560 - 'theme' => $theme,
561 - 'plugins' => $act_plugin,
562 - 'basic_requirements' => $basic_requirements,
563 - 'page_template' => $page_template,
564 - 'page_builder' => $page_builder,
565 - );
566 - } else {
567 - $final = array();
568 - }
407 + $final = array(
408 + 'web_server' => $web_server,
409 + 'memory_limit' => $memory_limit,
410 + 'max_execution_time' => $max_execution_time,
411 + 'php_version' => $php_version,
412 + 'wp_version' => $wp_version,
413 + 'email' => $email,
414 + 'site_url' => $siteurl,
415 + 'site_language' => $language,
416 + 'theme' => $theme,
417 + 'plugins' => $act_plugin,
418 + 'basic_requirements' => $basic_requirements,
419 + 'page_template' => $page_template,
420 + 'page_builder' => $page_builder,
421 + );
569 422
570 423 $response = wp_remote_post(
571 424 $this->wdkit_onbording_api,
572 425 array(
@@ -619,11 +472,172 @@
619 472 }
620 473
621 474 /**
622 475 *
476 + * It is Use for user login with email and password.
477 + *
478 + * @since 1.0.0
479 + */
480 + protected function wdkit_login() {
481 + $user_email = isset( $_POST['user_email'] ) ? strtolower( sanitize_email( wp_unslash( $_POST['user_email'] ) ) ) : false;
482 + $user_password = isset( $_POST['user_password'] ) ? sanitize_text_field( wp_unslash( $_POST['user_password'] ) ) : false;
483 + $login_type = isset( $_POST['login_type'] ) ? sanitize_text_field( wp_unslash( $_POST['login_type'] ) ) : false;
484 + $site_url = isset( $_POST['site_url'] ) ? esc_url_raw( wp_unslash( $_POST['site_url'] ) ) : '';
485 +
486 + $user_key = strstr( $user_email, '@', true );
487 + $response = '';
488 +
489 + delete_transient( 'wdkit_auth_' . $user_key );
490 +
491 + $get_login = get_transient( 'wdkit_auth_' . $user_key );
492 +
493 + if ( ! empty( $user_email ) && ! empty( $user_password ) && false === $get_login ) {
494 + $response = WDesignKit_Data_Query::get_data(
495 + 'login',
496 + array(
497 + 'user_email' => $user_email,
498 + 'password' => $user_password,
499 + 'site_url' => $site_url,
500 + )
501 + );
502 +
503 + if ( ! empty( $response ) && ! empty( $response['success'] ) ) {
504 + if ( ! empty( $response['message'] ) && ! empty( $response['token'] ) ) {
505 + if ( false === get_transient( 'wdkit_auth_' . $user_key ) ) {
506 + $this->wdkit_set_time_out( $user_key, $user_email, $response['token'], $login_type );
507 + }
508 + }
509 + }
510 + } elseif ( ! empty( $get_login ) && ! empty( $get_login['token'] ) ) {
511 + $response = array_merge(
512 + array(
513 + 'success' => true,
514 + 'message' => esc_html__( 'Success! Login successful.', 'wdesignkit' ),
515 + 'description' => esc_html__( 'Login successful. Keep it up!', 'wdesignkit' ),
516 + ),
517 + $get_login
518 + );
519 + }
520 +
521 + wp_send_json( $response );
522 + wp_die();
523 + }
524 +
525 + /**
526 + *
527 + * This Function is used for Login with Api (token)
528 + *
529 + * @version 1.0.0
530 + */
531 + protected function wdkit_api_login() {
532 + $user_token = isset( $_POST['token'] ) ? sanitize_text_field( wp_unslash( $_POST['token'] ) ) : '';
533 + $login_type = isset( $_POST['login_type'] ) ? sanitize_text_field( wp_unslash( $_POST['login_type'] ) ) : '';
534 +
535 + $site_url = isset( $_POST['site_url'] ) ? esc_url_raw( wp_unslash( $_POST['site_url'] ) ) : '';
536 +
537 + if ( empty( $user_token ) ) {
538 + $result = array(
539 + 'success' => false,
540 + 'token' => '',
541 + 'data' => array(
542 + 'message' => $this->e_msg_login,
543 + 'description' => $this->e_desc_login,
544 + ),
545 + );
546 +
547 + wp_send_json( $result );
548 + wp_die();
549 + }
550 +
551 + $array_data = array(
552 + 'token' => $user_token,
553 + 'site_url' => $site_url,
554 + );
555 +
556 + $response = $this->wkit_api_call( $array_data, 'login/api' );
557 +
558 + $success = ! empty( $response['success'] ) ? is_bool( $response['success'] ) : false;
559 +
560 + if ( empty( $success ) ) {
561 + $result = array(
562 + 'data' => $response,
563 + 'token' => '',
564 + 'success' => false,
565 + );
566 +
567 + wp_send_json( $result );
568 + wp_die();
569 + }
570 +
571 + $response = json_decode( wp_json_encode( $response['data'] ), true );
572 + $user_email = ! empty( $response['user']['user_email'] ) ? sanitize_email( $response['user']['user_email'] ) : '';
573 + $user_key = strstr( $user_email, '@', true );
574 +
575 + $this->wdkit_set_time_out( $user_key, $user_email, $user_token, $login_type );
576 +
577 + $result = array(
578 + 'success' => true,
579 + 'data' => $response,
580 + 'token' => $user_token,
581 + );
582 +
583 + wp_send_json( $result );
584 + wp_die();
585 + }
586 +
587 + /**
588 + *
589 + * This Function is used for social Login
590 + *
591 + * @version 1.0.0
592 + */
593 + protected function wdkit_social_login() {
594 + $user_state = isset( $_POST['state'] ) ? sanitize_text_field( wp_unslash( $_POST['state'] ) ) : '';
595 + $login_type = isset( $_POST['login_type'] ) ? sanitize_text_field( wp_unslash( $_POST['login_type'] ) ) : '';
596 +
597 + $site_url = isset( $_POST['site_url'] ) ? esc_url_raw( wp_unslash( $_POST['site_url'] ) ) : '';
598 +
599 + $array_data = array(
600 + 'state' => $user_state,
601 + 'site_url' => $site_url,
602 + );
603 +
604 + $response = $this->wkit_api_call( $array_data, 'login/ip' );
605 + $success = ! empty( $response['success'] ) ? $response['success'] : false;
606 +
607 + if ( empty( $success ) ) {
608 + $result = array(
609 + 'data' => $response,
610 + 'success' => false,
611 + );
612 +
613 + wp_send_json( $result );
614 + wp_die();
615 + }
616 +
617 + $response = json_decode( wp_json_encode( $response['data'] ), true );
618 + $user_email = ! empty( $response['user']['user_email'] ) ? sanitize_email( $response['user']['user_email'] ) : '';
619 + $user_token = ! empty( $response['token'] ) ? sanitize_text_field( $response['token'] ) : '';
620 + $user_key = strstr( $user_email, '@', true );
621 +
622 + if ( ! empty( $response ) && ! empty( $user_token ) ) {
623 + $this->wdkit_set_time_out( $user_key, $user_email, $user_token, $login_type );
624 + }
625 +
626 + $result = array(
627 + 'data' => $response,
628 + 'token' => $user_token,
629 + );
630 +
631 + wp_send_json( $result );
632 + wp_die();
633 + }
634 +
635 + /**
636 + *
623 637 * It is Use for get meta data for non login user
624 638 *
625 - * @since 1.0.0
639 + * @since 1.0.0\
626 640 */
627 641 protected function wdkit_meta_data() {
628 642 $type = isset( $_POST['meta_type'] ) ? sanitize_text_field( wp_unslash( $_POST['meta_type'] ) ) : '';
629 643 $data = array( 'type' => $type );
@@ -667,42 +681,13 @@
667 681 }
668 682
669 683 /**
670 684 *
671 - * It is Use for get activate license key data from tpae and nexter blocks.
672 - *
673 - * @since 1.1.6
674 - */
675 - protected function wkit_manage_license_data() {
676 - $manage_licence = array();
677 - $theplus_active_check = is_plugin_active( 'the-plus-addons-for-elementor-page-builder/theplus_elementor_addon.php' );
678 - $nexter_active_check = is_plugin_active( 'the-plus-addons-for-block-editor/the-plus-addons-for-block-editor.php' );
679 -
680 - $theplus_licence = get_option( 'tpaep_licence_data', array() );
681 -
682 - if ( ! empty( $theplus_active_check ) && ! empty( $theplus_licence ) ) {
683 - $manage_licence['tpae'] = $theplus_licence;
684 - }
685 -
686 - $nexter_licence = get_option( 'tpgb_activate', array() );
687 -
688 - if ( ! empty( $nexter_active_check ) && ! empty( $nexter_licence ) && ! empty( $nexter_licence['tpgb_activate_key'] ) ) {
689 - $tpgb_license_status = get_option( 'tpgbp_license_status', array() );
690 - $tpgb_license_status['license_key'] = $nexter_licence['tpgb_activate_key'];
691 - $manage_licence['tpag'] = $tpgb_license_status;
692 - }
693 -
694 - return $manage_licence;
695 - }
696 -
697 - /**
698 - *
699 685 * It is Use for get all info of user.
700 686 *
701 687 * @since 1.0.0
702 688 */
703 689 protected function wdkit_get_user_info() {
704 - $token = isset( $_POST['token'] ) ? wp_unslash( $_POST['token'] ) : false;
705 690 $email = isset( $_POST['email'] ) ? strtolower( sanitize_email( wp_unslash( $_POST['email'] ) ) ) : false;
706 691 $builder = isset( $_POST['builder'] ) ? strtolower( sanitize_text_field( wp_unslash( $_POST['builder'] ) ) ) : '';
707 692
708 693 $site_url = isset( $_POST['site_url'] ) ? esc_url_raw( wp_unslash( $_POST['site_url'] ) ) : '';
@@ -708,9 +693,9 @@
708 693 $site_url = isset( $_POST['site_url'] ) ? esc_url_raw( wp_unslash( $_POST['site_url'] ) ) : '';
709 694
710 695 $response = array();
711 696
712 - if ( empty( $token ) ) {
697 + if ( empty( $email ) ) {
713 698 $response = array(
714 699 'success' => false,
715 700 'message' => $this->e_msg_login,
716 701 'description' => $this->e_desc_login,
@@ -719,10 +704,10 @@
719 704 wp_send_json( $response );
720 705 wp_die();
721 706 }
722 707
723 - // $token = $this->wdkit_login_user_token( $email );
724 - $args = array(
708 + $token = $this->wdkit_login_user_token( $email );
709 + $args = array(
725 710 'token' => $token,
726 711 'builder' => $builder,
727 712 'site_url' => $site_url,
728 713 );
@@ -733,32 +718,13 @@
733 718
734 719 /**Condtion user for user logout & expire token*/
735 720 if ( 'Token is Expired' === $status || 'Authorization Token not found' === $status ) {
736 721 delete_transient( 'wdkit_auth_' . $email );
737 - // Clear stored license data when token expires so banner shows again
738 - delete_option( 'wdkit_licence_data' );
739 722 }
740 723
741 - if ( empty( $response ) ) {
742 - $response['login_reset'] = 'yes';
743 - }
724 + $response['Setting'] = $this->wkit_get_settings_panel();
725 + $response['widget_list'] = $this->wkit_manage_widget_sequence( $response );
744 726
745 - // Store WDesignKit license data locally if present in response
746 - if ( ! empty( $response['credits']['wdkit_licence'] ) && is_array( $response['credits']['wdkit_licence'] ) ) {
747 - $wdkit_licence = $response['credits']['wdkit_licence'];
748 - // Handle serialized data
749 - if ( is_string( $wdkit_licence ) && is_serialized( $wdkit_licence ) ) {
750 - $wdkit_licence = unserialize( $wdkit_licence );
751 - }
752 - if ( ! empty( $wdkit_licence ) && is_array( $wdkit_licence ) ) {
753 - update_option( 'wdkit_licence_data', $wdkit_licence );
754 - }
755 - }
756 -
757 - $response['Setting'] = $this->wkit_get_settings_panel();
758 - $response['widget_list'] = $this->wkit_manage_widget_sequence( $response );
759 - $response['manage_licence'] = $this->wkit_manage_license_data();
760 -
761 727 $response = array(
762 728 'data' => $response,
763 729 'success' => true,
764 730 );
@@ -787,13 +753,13 @@
787 753 $server_w_unique = array_column( $server_list, 'w_unique' );
788 754
789 755 $idx_builder = array();
790 756 foreach ( $db_builder_list as $index => $value ) {
791 - $builder_name = ! empty( $value['builder_slug'] ) ? $value['builder_slug'] : '';
757 + $builder_name = ! empty( $value['builder_name'] ) ? $value['builder_name'] : '';
792 758 $w_id = ! empty( $value['w_id'] ) ? $value['w_id'] : '';
793 759
794 760 if ( ! empty( $builder_name ) ) {
795 - $idx_builder[ $w_id ] = strtolower( str_replace( ' ', '_', trim( $builder_name ) ) );
761 + $idx_builder[ $w_id ] = strtolower( $builder_name );
796 762 }
797 763 }
798 764
799 765 foreach ( $server_list as $index => $value ) {
@@ -805,9 +771,9 @@
805 771
806 772 $count = 0;
807 773
808 774 foreach ( $local_list as $key => $value ) {
809 - $widget_id = ! empty( $value['widgetdata']['widget_id'] ) ? $value['widgetdata']['widget_id'] : '';
775 + $widget_id = ! empty( $value['widgetdata']['widget_id'] ) ? $value['widgetdata']['widget_id'] : '';
810 776 $allow_push = isset( $value['widgetdata']['allow_push'] ) ? $value['widgetdata']['allow_push'] : true;
811 777
812 778 if ( in_array( $widget_id, $server_w_unique ) ) {
813 779
@@ -827,9 +793,9 @@
827 793 unset( $server_list[ $index ] );
828 794 } else {
829 795 $local_list[ $key ]['widgetdata']['builder'] = $local_list[ $key ]['widgetdata']['type'];
830 796 $local_list[ $key ]['widgetdata']['w_unique'] = $local_list[ $key ]['widgetdata']['widget_id'];
831 - $local_list[ $key ]['widgetdata']['allow_push'] = $allow_push;
797 + $local_list[ $key ]['widgetdata']['allow_push'] = $allow_push;
832 798 $local_list[ $key ]['widgetdata']['image'] = ! empty( $local_list[ $key ]['widgetdata']['w_image'] ) ? $local_list[ $key ]['widgetdata']['w_image'] : $placeholderimg;
833 799 $local_list[ $key ]['widgetdata']['is_activated'] = 'active';
834 800
835 801 $local_list[ $key ]['widgetdata']['type'] = 'plugin';
@@ -852,9 +818,9 @@
852 818 if ( 'active' === $is_activated ) {
853 819 ++$count;
854 820 }
855 821
856 - if ( ( $count > $credits ) && ( 'unlimited' !== $credits ) ) {
822 + if ( ($count > $credits) && ('unlimited' !== $credits)) {
857 823 $final[ $key ]['is_activated'] = 'deactive';
858 824 }
859 825
860 826 if ( ! empty( $self['is_activated'] ) && 'active' !== $self['is_activated'] ) {
@@ -886,14 +852,48 @@
886 852 $args = $this->wdkit_parse_args( $_POST );
887 853
888 854 $response = WDesignKit_Data_Query::get_data( 'browse_page', $args );
889 855
890 - $manage_licence = array();
891 - $manage_licence['theplus_elementor_addon'] = ! empty( defined( 'THEPLUS_VERSION' ) ) ? true : false;
892 - $manage_licence['tpag'] = ! empty( defined( 'TPGBP_VERSION' ) ) ? true : false;
893 - $manage_licence['elementor-pro'] = ! empty( defined( 'ELEMENTOR_PRO_VERSION' ) ) ? true : false;
894 - $response['manage_licence'] = $manage_licence;
856 + wp_send_json( $response );
857 + wp_die();
858 + }
895 859
860 + /**
861 + *
862 + * It is Use to get data for widget browse page
863 + *
864 + * @since 1.0.0
865 + */
866 + protected function wdkit_widget_browse_page() {
867 + $array_data = array(
868 + 'CurrentPage' => isset( $_POST['page'] ) ? (int) $_POST['page'] : 1,
869 + 'builder' => isset( $_POST['buildertype'] ) ? wp_unslash( $_POST['buildertype'] ) : '',
870 + 'category' => isset( $_POST['category'] ) ? sanitize_text_field( wp_unslash( $_POST['category'] ) ) : '',
871 + 'ParPage' => isset( $_POST['perpage'] ) ? (int) $_POST['perpage'] : 12,
872 + 'search' => isset( $_POST['search'] ) ? sanitize_text_field( wp_unslash( $_POST['search'] ) ) : '',
873 + 'free_pro' => isset( $_POST['free_pro'] ) ? sanitize_text_field( wp_unslash( $_POST['free_pro'] ) ) : '',
874 + );
875 +
876 + $response = $this->wkit_api_call( $array_data, 'browse_widget' );
877 + $success = ! empty( $response['success'] ) ? $response['success'] : false;
878 +
879 + if ( empty( $success ) ) {
880 + $response = array(
881 + 'success' => false,
882 + 'message' => esc_html__( 'Data Not Found', 'wdesignkit' ),
883 + 'description' => esc_html__( 'Widget List Not Found', 'wdesignkit' ),
884 +
885 + 'widgets' => array(),
886 + 'widgetscount' => 0,
887 + 'showwidgets' => 0,
888 + );
889 +
890 + wp_send_json( $response );
891 + wp_die();
892 + }
893 +
894 + $response = json_decode( wp_json_encode( $response['data'] ), true );
895 +
896 896 wp_send_json( $response );
897 897 wp_die();
898 898 }
899 899
@@ -952,12 +952,9 @@
952 952 *
953 953 * @since 1.0.0
954 954 */
955 955 protected function wdkit_put_save_template() {
956 - $email = isset( $_POST['email'] ) ? strtolower( sanitize_email( wp_unslash( $_POST['email'] ) ) ) : false;
957 - $post_id = isset( $_POST['post_id'] ) ? sanitize_text_field( wp_unslash( $_POST['post_id'] ) ) : '';
958 - $builder = isset( $_POST['builder'] ) ? sanitize_text_field( wp_unslash( $_POST['builder'] ) ) : '';
959 -
956 + $email = isset( $_POST['email'] ) ? strtolower( sanitize_email( wp_unslash( $_POST['email'] ) ) ) : false;
960 957 $response = '';
961 958
962 959 if ( empty( $email ) ) {
963 960 $response = array(
@@ -975,19 +972,14 @@
975 972 $args = $this->wdkit_parse_args( $_POST );
976 973 $args['token'] = $this->wdkit_login_user_token( $email );
977 974 unset( $args['email'] );
978 975
979 - if( 'elementor' === $builder ){
980 - $args['data'] = base64_decode( $args['data'] );
981 - } else if ( 'gutenberg' === $builder ) {
982 - $args['data'] = base64_decode( $args['data'] );
983 - }
984 -
985 976 global $post;
986 977
978 + $post_id = get_the_ID();
987 979 $custom_fields = array();
988 980 if ( ! empty( $post_id ) ) {
989 - $meta_fields = get_post_custom( $post_id );
981 + $meta_fields = get_post_custom( get_the_ID() );
990 982
991 983 foreach ( $meta_fields as $key => $value ) {
992 984 if ( str_contains( $key, 'nxt-' ) ) {
993 985 $custom_fields[ $key ] = $value;
@@ -1008,1065 +1000,8 @@
1008 1000 }
1009 1001
1010 1002 /**
1011 1003 *
1012 - * It is Use for update save template image.
1013 - *
1014 - * @since 2.0.6
1015 - */
1016 - protected function wdkit_update_save_temp_image() {
1017 - $temp_content = isset( $_POST['temp_content'] ) ? esc_url_raw( $_POST['temp_content'] ) : '';
1018 - $content_name = isset( $_POST['content_name'] ) ? sanitize_text_field( $_POST['content_name'] ) : '';
1019 - $token = isset( $_POST['token'] ) ? sanitize_text_field( $_POST['token'] ) : '';
1020 - $user_type = isset( $_POST['user_type'] ) ? sanitize_text_field( $_POST['user_type'] ) : '';
1021 - $type = isset( $_POST['content_type'] ) ? sanitize_text_field( $_POST['content_type'] ) : '';
1022 - $id = isset( $_POST['id'] ) ? sanitize_text_field( $_POST['id'] ) : '';
1023 - if ( empty( $temp_content ) || empty( $user_type ) || empty( $id ) || empty( $token ) ) {
1024 - $response = array(
1025 - 'message' => __( 'Data not found', 'wdesignkit' ),
1026 - 'description' => __( 'Data not found', 'wdesignkit' ),
1027 - 'success' => false,
1028 - );
1029 - } else {
1030 - $temp_content = str_replace( '\\', '', $temp_content );
1031 - $temp_content = wp_remote_get( $temp_content )['body'];
1032 - $temp_content = base64_encode( $temp_content );
1033 -
1034 - $args = array(
1035 - 'token' => $token,
1036 - 'template_id' => $id,
1037 - 'name' => $content_name,
1038 - 'content' => $temp_content,
1039 - 'type' => $type,
1040 - );
1041 -
1042 - $response = $this->wkit_api_call( $args, 'save_images' );
1043 - $success = ! empty( $response['success'] ) ? $response['success'] : false;
1044 -
1045 - if ( $success ) {
1046 - $response = array(
1047 - 'data' => $response['data'],
1048 - 'success' => true,
1049 - );
1050 - } else {
1051 - $response = array(
1052 - 'message' => __( 'API Error', 'wdesignkit' ),
1053 - 'description' => __( 'API Error', 'wdesignkit' ),
1054 - 'data' => $response['data'],
1055 - 'success' => false,
1056 - );
1057 - }
1058 - }
1059 -
1060 - wp_send_json( $response );
1061 - wp_die();
1062 - }
1063 -
1064 - /**
1065 - *
1066 - * It is Use for save image to WordPress Media Library.
1067 - *
1068 - * @since 2.3.3
1069 - */
1070 - protected function wdkit_save_wp_images() {
1071 - $image_url = isset( $_POST['image'] ) ? sanitize_text_field( $_POST['image'] ) : '';
1072 -
1073 - if ( empty( $image_url ) ) {
1074 - $response = array(
1075 - 'message' => __( 'No Image Provided', 'wdesignkit' ),
1076 - 'description' => __( 'No Image URL provided for save.', 'wdesignkit' ),
1077 - 'success' => false,
1078 - );
1079 - } else {
1080 -
1081 - $attachment_id = media_sideload_image( $image_url, 0, null, 'id' );
1082 -
1083 - if ( is_wp_error( $attachment_id ) ) {
1084 - $response = array(
1085 - 'message' => __( 'Upload Failed', 'wdesignkit' ),
1086 - 'description' => $attachment_id->get_error_message(),
1087 - 'success' => false,
1088 - );
1089 - } else {
1090 - $saved_url = wp_get_attachment_url( $attachment_id );
1091 -
1092 - $response = array(
1093 - 'message' => __( 'Image Saved', 'wdesignkit' ),
1094 - 'description' => __( 'Image successfully saved to Media Library.', 'wdesignkit' ),
1095 - 'success' => true,
1096 - 'url' => $saved_url,
1097 - );
1098 - }
1099 -
1100 - }
1101 -
1102 - wp_send_json( $response );
1103 - wp_die();
1104 - }
1105 -
1106 - /**
1107 - *
1108 - * Get Elementor Global color and Typography.
1109 - *
1110 - * @since 1.1.16
1111 - */
1112 - protected function wdkit_get_global_val() {
1113 -
1114 - $builder = isset( $_POST['builder'] ) ? strtolower( sanitize_text_field( $_POST['builder'] ) ) : '';
1115 -
1116 - if ( 'elementor' === $builder ) {
1117 - $kit_id = get_option( 'elementor_active_kit' );
1118 - if ( empty( $kit_id ) ) {
1119 - $response = array(
1120 - 'message' => __( 'Elementor kit not found', 'wdesignkit' ),
1121 - 'description' => __( 'No active Elementor kit found', 'wdesignkit' ),
1122 - 'success' => false,
1123 - );
1124 -
1125 - wp_send_json( $response );
1126 - wp_die();
1127 - }
1128 -
1129 - $kit_meta = get_post_meta( $kit_id, '_elementor_page_settings', true );
1130 - if ( empty( $kit_meta['system_colors'] ) ) {
1131 - $static_meta = array(
1132 - 'system_colors' => array(
1133 - 0 => array(
1134 - '_id' => 'primary',
1135 - 'title' => 'Primary',
1136 - 'color' => '#6EC1E4',
1137 - ),
1138 - 1 => array(
1139 - '_id' => 'secondary',
1140 - 'title' => 'Secondary',
1141 - 'color' => '#54595F',
1142 - ),
1143 - 2 => array(
1144 - '_id' => 'text',
1145 - 'title' => 'Text',
1146 - 'color' => '#7A7A7A',
1147 - ),
1148 - 3 => array(
1149 - '_id' => 'accent',
1150 - 'title' => 'Accent',
1151 - 'color' => '#61CE70',
1152 - ),
1153 - ),
1154 - 'custom_colors' => array(),
1155 - 'system_typography' => array(
1156 - 0 => array(
1157 - '_id' => 'primary',
1158 - 'title' => 'Primary',
1159 - 'typography_typography' => 'custom',
1160 - 'typography_font_family' => 'Roboto',
1161 - 'typography_font_weight' => '600',
1162 - ),
1163 - 1 => array(
1164 - '_id' => 'secondary',
1165 - 'title' => 'Secondary',
1166 - 'typography_typography' => 'custom',
1167 - 'typography_font_family' => 'Roboto Slab',
1168 - 'typography_font_weight' => '400',
1169 - ),
1170 - 2 => array(
1171 - '_id' => 'text',
1172 - 'title' => 'Text',
1173 - 'typography_typography' => 'custom',
1174 - 'typography_font_family' => 'Roboto',
1175 - 'typography_font_weight' => '400',
1176 - ),
1177 - 3 => array(
1178 - '_id' => 'accent',
1179 - 'title' => 'Accent',
1180 - 'typography_typography' => 'custom',
1181 - 'typography_font_family' => 'Roboto',
1182 - 'typography_font_weight' => '500',
1183 - ),
1184 - ),
1185 - 'custom_typography' => array(),
1186 - 'default_generic_fonts' => 'Sans-serif',
1187 - 'site_name' => ! empty( get_bloginfo( 'name' ) ) ? get_bloginfo( 'name' ) : '',
1188 - 'page_title_selector' => 'h1.entry-title',
1189 - 'activeItemIndex' => 1,
1190 - 'viewport_md' => 768,
1191 - 'viewport_lg' => 1025,
1192 - );
1193 -
1194 - $kit_meta = $static_meta;
1195 - update_post_meta( $kit_id, '_elementor_page_settings', $kit_meta );
1196 - }
1197 -
1198 - $system_colors = ! empty( $kit_meta['system_colors'] ) ? $kit_meta['system_colors'] : array();
1199 - $custom_colors = ! empty( $kit_meta['custom_colors'] ) ? $kit_meta['custom_colors'] : array();
1200 - $system_typography = ! empty( $kit_meta['system_typography'] ) ? $kit_meta['system_typography'] : array();
1201 - $custom_typography = ! empty( $kit_meta['custom_typography'] ) ? $kit_meta['custom_typography'] : array();
1202 -
1203 - $color_array = array_merge( $system_colors, $custom_colors );
1204 - $typo_array = array_merge( $system_typography, $custom_typography );
1205 -
1206 - $global_data = array(
1207 - 'color' => $color_array,
1208 - 'typography' => $typo_array,
1209 - );
1210 -
1211 - $response = array(
1212 - 'message' => __( 'Global data Found', 'wdesignkit' ),
1213 - 'description' => __( 'Global Color and Typography found', 'wdesignkit' ),
1214 - 'data' => $global_data,
1215 - 'success' => true,
1216 - );
1217 -
1218 - } elseif ( 'gutenberg' === $builder ) {
1219 -
1220 - $plus_settings = get_option( 'tpgb_global_options', false );
1221 - $plus_settings = ! empty( $plus_settings ) ? json_decode( $plus_settings, true ) : json_decode( '[]' );
1222 -
1223 - if ( empty( $plus_settings ) ) {
1224 -
1225 - $static_meta = array(
1226 - 'active' => 'preset1',
1227 - 'darkMode' => 'none',
1228 - 'presets' => array(
1229 - 'preset1' => array(
1230 - 'name' => 'Preset 1',
1231 - 'key' => 'preset1',
1232 - 'colors' => array(
1233 - array(
1234 - 'label' => 'Primary',
1235 - 'value' => '#8072FC',
1236 - ),
1237 - array(
1238 - 'label' => 'Secondary',
1239 - 'value' => '#6FC784',
1240 - ),
1241 - array(
1242 - 'label' => 'Tertiary',
1243 - 'value' => '#FF5A6E',
1244 - ),
1245 - array(
1246 - 'label' => 'Accent',
1247 - 'value' => '#F3F3F3',
1248 - ),
1249 - array(
1250 - 'label' => 'Background',
1251 - 'value' => '#888888',
1252 - ),
1253 - ),
1254 - 'gradient' => array(
1255 - array(
1256 - 'label' => 'Primary',
1257 - 'value' => 'linear-gradient(135deg,rgb(8,148,229) 0%,rgb(155,81,224) 100%)',
1258 - ),
1259 -
1260 - array(
1261 - 'label' => 'Secondary',
1262 - 'value' => 'linear-gradient(135deg,rgb(8,148,229) 0%,rgb(155,81,224) 100%)',
1263 - ),
1264 -
1265 - array(
1266 - 'label' => 'Tertiary',
1267 - 'value' => 'linear-gradient(135deg,rgb(8,148,229) 0%,rgb(155,81,224) 100%)',
1268 - ),
1269 -
1270 - array(
1271 - 'label' => 'Accent',
1272 - 'value' => 'linear-gradient(135deg,rgb(8,148,229) 0%,rgb(155,81,224) 100%)',
1273 - ),
1274 -
1275 - array(
1276 - 'label' => 'Background',
1277 - 'value' => 'linear-gradient(135deg,rgb(8,148,229) 0%,rgb(155,81,224) 100%)',
1278 - ),
1279 - ),
1280 - 'spacing' => array(
1281 - array(
1282 - 'label' => 'Large',
1283 - 'value' => array(
1284 - 'md' => 70,
1285 - 'unit' => 'px',
1286 - ),
1287 - ),
1288 - array(
1289 - 'label' => 'Medium',
1290 - 'value' => array(
1291 - 'md' => 40,
1292 - 'unit' => 'px',
1293 - ),
1294 - ),
1295 - array(
1296 - 'label' => 'Small',
1297 - 'value' => array(
1298 - 'md' => 20,
1299 - 'unit' => 'px',
1300 - ),
1301 -
1302 - ),
1303 - ),
1304 - 'typography' => array(
1305 - array(
1306 - 'label' => 'Display Text',
1307 - 'value' => array(
1308 - 'openTypography' => 1,
1309 - 'size' => array(
1310 - 'md' => 65,
1311 - 'unit' => 'px',
1312 - ),
1313 - 'height' => array(
1314 - 'md' => 75,
1315 - 'unit' => 'px',
1316 - ),
1317 - 'fontFamily' => array(
1318 - 'family' => 'Roboto',
1319 - 'type' => 'sans-serif',
1320 - 'fontWeight' => 700,
1321 - ),
1322 - 'spacing' => array(
1323 - 'md' => 0,
1324 - 'unit' => 'px',
1325 - ),
1326 - ),
1327 - ),
1328 - array(
1329 - 'label' => 'Headline',
1330 - 'value' => array(
1331 - 'openTypography' => 1,
1332 - 'size' => array(
1333 - 'md' => 45,
1334 - 'unit' => 'px',
1335 - ),
1336 - 'height' => array(
1337 - 'md' => 60,
1338 - 'unit' => 'px',
1339 - ),
1340 - 'fontFamily' => array(
1341 - 'family' => 'Roboto',
1342 - 'type' => 'sans-serif',
1343 - 'fontWeight' => 700,
1344 - ),
1345 - 'spacing' => array(
1346 - 'md' => 0,
1347 - 'unit' => 'px',
1348 - ),
1349 - ),
1350 - ),
1351 - array(
1352 - 'label' => 'Sub Headline',
1353 - 'value' => array(
1354 - 'openTypography' => 1,
1355 - 'size' => array(
1356 - 'md' => 38,
1357 - 'unit' => 'px',
1358 - ),
1359 - 'height' => array(
1360 - 'md' => 45,
1361 - 'unit' => 'px',
1362 - ),
1363 - 'fontFamily' => array(
1364 - 'family' => 'Roboto',
1365 - 'type' => 'sans-serif',
1366 - 'fontWeight' => 500,
1367 - ),
1368 - 'spacing' => array(
1369 - 'md' => 0,
1370 - 'unit' => 'px',
1371 - ),
1372 - ),
1373 - ),
1374 - array(
1375 - 'label' => 'Title 1',
1376 - 'value' => array(
1377 - 'openTypography' => 1,
1378 - 'size' => array(
1379 - 'md' => 30,
1380 - 'unit' => 'px',
1381 - ),
1382 - 'height' => array(
1383 - 'md' => 40,
1384 - 'unit' => 'px',
1385 - ),
1386 - 'fontFamily' => array(
1387 - 'family' => 'Roboto',
1388 - 'type' => 'sans-serif',
1389 - 'fontWeight' => 500,
1390 - ),
1391 - 'spacing' => array(
1392 - 'md' => 0,
1393 - 'unit' => 'px',
1394 - ),
1395 - ),
1396 - ),
1397 - array(
1398 - 'label' => 'Title 2',
1399 - 'value' => array(
1400 - 'openTypography' => 1,
1401 - 'size' => array(
1402 - 'md' => 25,
1403 - 'unit' => 'px',
1404 - ),
1405 - 'height' => array(
1406 - 'md' => 30,
1407 - 'unit' => 'px',
1408 - ),
1409 - 'fontFamily' => array(
1410 - 'family' => 'Roboto',
1411 - 'type' => 'sans-serif',
1412 - 'fontWeight' => 400,
1413 - ),
1414 - 'spacing' => array(
1415 - 'md' => 0,
1416 - 'unit' => 'px',
1417 - ),
1418 - ),
1419 - ),
1420 - array(
1421 - 'label' => 'Body',
1422 - 'value' => array(
1423 - 'openTypography' => 1,
1424 - 'size' => array(
1425 - 'md' => 17,
1426 - 'unit' => 'px',
1427 - ),
1428 - 'height' => array(
1429 - 'md' => 22,
1430 - 'unit' => 'px',
1431 - ),
1432 - 'fontFamily' => array(
1433 - 'family' => 'Roboto',
1434 - 'type' => 'sans-serif',
1435 - 'fontWeight' => 400,
1436 - ),
1437 - 'spacing' => array(
1438 - 'md' => 0,
1439 - 'unit' => 'px',
1440 - ),
1441 - ),
1442 - ),
1443 - array(
1444 - 'label' => 'Captions',
1445 - 'value' => array(
1446 - 'openTypography' => 1,
1447 - 'size' => array(
1448 - 'md' => 13,
1449 - 'unit' => 'px',
1450 - ),
1451 - 'height' => array(
1452 - 'md' => 16,
1453 - 'unit' => 'px',
1454 - ),
1455 - 'fontFamily' => array(
1456 - 'family' => 'Roboto',
1457 - 'type' => 'sans-serif',
1458 - 'fontWeight' => 400,
1459 - ),
1460 - 'spacing' => array(
1461 - 'md' => 0,
1462 - 'unit' => 'px',
1463 - ),
1464 - ),
1465 - ),
1466 - ),
1467 - 'boxshadow' => array(
1468 - array(
1469 - 'label' => 'Normal Shadow',
1470 - 'value' => array(
1471 - 'openShadow' => 1,
1472 - 'inset' => 0,
1473 - 'horizontal' => 2,
1474 - 'vertical' => 6,
1475 - 'blur' => 10,
1476 - 'spread' => 0,
1477 - 'color' => 'rgba(0,0,0,0.15)',
1478 - ),
1479 - ),
1480 - array(
1481 - 'label' => 'Hover Shadow',
1482 - 'value' => array(
1483 - 'openShadow' => 1,
1484 - 'inset' => 0,
1485 - 'horizontal' => 2,
1486 - 'vertical' => 5,
1487 - 'blur' => 14,
1488 - 'spread' => 3,
1489 - 'color' => 'rgba(0,0,0,0.2)',
1490 - ),
1491 - ),
1492 - ),
1493 - ),
1494 - 'preset2' => array(
1495 - 'name' => 'Preset 2',
1496 - 'key' => 'preset2',
1497 - 'colors' => array(
1498 - array(
1499 - 'label' => 'Primary',
1500 - 'value' => '#8072FC',
1501 - ),
1502 - array(
1503 - 'label' => 'Secondary',
1504 - 'value' => '#6FC784',
1505 - ),
1506 - array(
1507 - 'label' => 'Tertiary',
1508 - 'value' => '#FF5A6E',
1509 - ),
1510 - array(
1511 - 'label' => 'Accent',
1512 - 'value' => '#F3F3F3',
1513 - ),
1514 - array(
1515 - 'label' => 'Background',
1516 - 'value' => '#888888',
1517 - ),
1518 - ),
1519 - 'gradient' => array(
1520 - array(
1521 - 'label' => 'Primary',
1522 - 'value' => 'linear-gradient(135deg,rgb(8,148,229) 0%,rgb(155,81,224) 100%)',
1523 - ),
1524 -
1525 - array(
1526 - 'label' => 'Secondary',
1527 - 'value' => 'linear-gradient(135deg,rgb(8,148,229) 0%,rgb(155,81,224) 100%)',
1528 - ),
1529 -
1530 - array(
1531 - 'label' => 'Tertiary',
1532 - 'value' => 'linear-gradient(135deg,rgb(8,148,229) 0%,rgb(155,81,224) 100%)',
1533 - ),
1534 -
1535 - array(
1536 - 'label' => 'Accent',
1537 - 'value' => 'linear-gradient(135deg,rgb(8,148,229) 0%,rgb(155,81,224) 100%)',
1538 - ),
1539 -
1540 - array(
1541 - 'label' => 'Background',
1542 - 'value' => 'linear-gradient(135deg,rgb(8,148,229) 0%,rgb(155,81,224) 100%)',
1543 - ),
1544 - ),
1545 - 'spacing' => array(
1546 - array(
1547 - 'label' => 'Large',
1548 - 'value' => array(
1549 - 'md' => 70,
1550 - 'unit' => 'px',
1551 - ),
1552 - ),
1553 - array(
1554 - 'label' => 'Medium',
1555 - 'value' => array(
1556 - 'md' => 40,
1557 - 'unit' => 'px',
1558 - ),
1559 - ),
1560 - array(
1561 - 'label' => 'Small',
1562 - 'value' => array(
1563 - 'md' => 20,
1564 - 'unit' => 'px',
1565 - ),
1566 -
1567 - ),
1568 - ),
1569 - 'typography' => array(
1570 - array(
1571 - 'label' => 'Display Text',
1572 - 'value' => array(
1573 - 'openTypography' => 1,
1574 - 'size' => array(
1575 - 'md' => 65,
1576 - 'unit' => 'px',
1577 - ),
1578 - 'height' => array(
1579 - 'md' => 75,
1580 - 'unit' => 'px',
1581 - ),
1582 - 'fontFamily' => array(
1583 - 'family' => 'Roboto',
1584 - 'type' => 'sans-serif',
1585 - 'fontWeight' => 700,
1586 - ),
1587 - 'spacing' => array(
1588 - 'md' => 0,
1589 - 'unit' => 'px',
1590 - ),
1591 - ),
1592 - ),
1593 - array(
1594 - 'label' => 'Headline',
1595 - 'value' => array(
1596 - 'openTypography' => 1,
1597 - 'size' => array(
1598 - 'md' => 45,
1599 - 'unit' => 'px',
1600 - ),
1601 - 'height' => array(
1602 - 'md' => 60,
1603 - 'unit' => 'px',
1604 - ),
1605 - 'fontFamily' => array(
1606 - 'family' => 'Roboto',
1607 - 'type' => 'sans-serif',
1608 - 'fontWeight' => 700,
1609 - ),
1610 - 'spacing' => array(
1611 - 'md' => 0,
1612 - 'unit' => 'px',
1613 - ),
1614 - ),
1615 - ),
1616 - array(
1617 - 'label' => 'Sub Headline',
1618 - 'value' => array(
1619 - 'openTypography' => 1,
1620 - 'size' => array(
1621 - 'md' => 38,
1622 - 'unit' => 'px',
1623 - ),
1624 - 'height' => array(
1625 - 'md' => 45,
1626 - 'unit' => 'px',
1627 - ),
1628 - 'fontFamily' => array(
1629 - 'family' => 'Roboto',
1630 - 'type' => 'sans-serif',
1631 - 'fontWeight' => 500,
1632 - ),
1633 - 'spacing' => array(
1634 - 'md' => 0,
1635 - 'unit' => 'px',
1636 - ),
1637 - ),
1638 - ),
1639 - array(
1640 - 'label' => 'Title 1',
1641 - 'value' => array(
1642 - 'openTypography' => 1,
1643 - 'size' => array(
1644 - 'md' => 30,
1645 - 'unit' => 'px',
1646 - ),
1647 - 'height' => array(
1648 - 'md' => 40,
1649 - 'unit' => 'px',
1650 - ),
1651 - 'fontFamily' => array(
1652 - 'family' => 'Roboto',
1653 - 'type' => 'sans-serif',
1654 - 'fontWeight' => 500,
1655 - ),
1656 - 'spacing' => array(
1657 - 'md' => 0,
1658 - 'unit' => 'px',
1659 - ),
1660 - ),
1661 - ),
1662 - array(
1663 - 'label' => 'Title 2',
1664 - 'value' => array(
1665 - 'openTypography' => 1,
1666 - 'size' => array(
1667 - 'md' => 25,
1668 - 'unit' => 'px',
1669 - ),
1670 - 'height' => array(
1671 - 'md' => 30,
1672 - 'unit' => 'px',
1673 - ),
1674 - 'fontFamily' => array(
1675 - 'family' => 'Roboto',
1676 - 'type' => 'sans-serif',
1677 - 'fontWeight' => 400,
1678 - ),
1679 - 'spacing' => array(
1680 - 'md' => 0,
1681 - 'unit' => 'px',
1682 - ),
1683 - ),
1684 - ),
1685 - array(
1686 - 'label' => 'Body',
1687 - 'value' => array(
1688 - 'openTypography' => 1,
1689 - 'size' => array(
1690 - 'md' => 17,
1691 - 'unit' => 'px',
1692 - ),
1693 - 'height' => array(
1694 - 'md' => 22,
1695 - 'unit' => 'px',
1696 - ),
1697 - 'fontFamily' => array(
1698 - 'family' => 'Roboto',
1699 - 'type' => 'sans-serif',
1700 - 'fontWeight' => 400,
1701 - ),
1702 - 'spacing' => array(
1703 - 'md' => 0,
1704 - 'unit' => 'px',
1705 - ),
1706 - ),
1707 - ),
1708 - array(
1709 - 'label' => 'Captions',
1710 - 'value' => array(
1711 - 'openTypography' => 1,
1712 - 'size' => array(
1713 - 'md' => 13,
1714 - 'unit' => 'px',
1715 - ),
1716 - 'height' => array(
1717 - 'md' => 16,
1718 - 'unit' => 'px',
1719 - ),
1720 - 'fontFamily' => array(
1721 - 'family' => 'Roboto',
1722 - 'type' => 'sans-serif',
1723 - 'fontWeight' => 400,
1724 - ),
1725 - 'spacing' => array(
1726 - 'md' => 0,
1727 - 'unit' => 'px',
1728 - ),
1729 - ),
1730 - ),
1731 - ),
1732 - 'boxshadow' => array(
1733 - array(
1734 - 'label' => 'Normal Shadow',
1735 - 'value' => array(
1736 - 'openShadow' => 1,
1737 - 'inset' => 0,
1738 - 'horizontal' => 2,
1739 - 'vertical' => 6,
1740 - 'blur' => 10,
1741 - 'spread' => 0,
1742 - 'color' => 'rgba(0,0,0,0.15)',
1743 - ),
1744 - ),
1745 - array(
1746 - 'label' => 'Hover Shadow',
1747 - 'value' => array(
1748 - 'openShadow' => 1,
1749 - 'inset' => 0,
1750 - 'horizontal' => 2,
1751 - 'vertical' => 5,
1752 - 'blur' => 14,
1753 - 'spread' => 3,
1754 - 'color' => 'rgba(0,0,0,0.2)',
1755 - ),
1756 - ),
1757 - ),
1758 - ),
1759 - ),
1760 - 'globalContainer' => array(
1761 - 'md' => '',
1762 - 'unit' => 'px',
1763 - ),
1764 - );
1765 -
1766 - update_option( 'tpgb_global_options', json_encode( $static_meta ) );
1767 - $plus_settings = $static_meta;
1768 - }
1769 -
1770 - $active_id = ! empty( $plus_settings['active'] ) ? $plus_settings['active'] : '';
1771 - $preset_array = ! empty( $plus_settings['presets'] ) ? $plus_settings['presets'] : array();
1772 - $act_preset = ! empty( $plus_settings['presets'][ $active_id ] ) ? $plus_settings['presets'][ $active_id ] : array();
1773 -
1774 - foreach ( $act_preset['colors'] as $index => &$item ) {
1775 - $item['id'] = $index + 1;
1776 - }
1777 - unset( $item );
1778 -
1779 - foreach ( $act_preset['typography'] as $index => &$item ) {
1780 - $item['id'] = $index + 1;
1781 - }
1782 - unset( $item );
1783 -
1784 - $act_preset['color'] = $act_preset['colors'];
1785 - unset( $act_preset['colors'] );
1786 -
1787 - $response = array(
1788 - 'message' => __( 'Global data Found', 'wdesignkit' ),
1789 - 'description' => __( 'Global Color and Typography found', 'wdesignkit' ),
1790 - 'data' => $act_preset,
1791 - 'success' => true,
1792 - );
1793 - }
1794 -
1795 - wp_send_json( $response );
1796 - wp_die();
1797 - }
1798 -
1799 - /**
1800 - *
1801 - * Get site settings.
1802 - *
1803 - * @since 2.1.3
1804 - */
1805 - protected function wdkit_get_site_setting() {
1806 -
1807 - $kit_id = get_option( 'elementor_active_kit' );
1808 - if ( empty( $kit_id ) ) {
1809 - $response = array(
1810 - 'message' => __( 'Elementor kit not found', 'wdesignkit' ),
1811 - 'description' => __( 'No active Elementor kit found', 'wdesignkit' ),
1812 - 'success' => false,
1813 - );
1814 -
1815 - wp_send_json( $response );
1816 - wp_die();
1817 - }
1818 -
1819 - $kit_meta = get_post_meta( $kit_id, '_elementor_page_settings', true );
1820 -
1821 - $container_width = ! empty( $kit_meta['container_width'] ) ? $kit_meta['container_width'] : array();
1822 - $globals = ! empty( $kit_meta['__globals__'] ) ? $kit_meta['__globals__'] : array();
1823 - $body_background_color = ! empty( $kit_meta['body_background_color'] ) ? $kit_meta['body_background_color'] : array();
1824 -
1825 - $site_globals = array(
1826 - 'body_background_color' => $body_background_color,
1827 - 'container_width' => $container_width,
1828 - 'globals' => $globals,
1829 - );
1830 -
1831 - $response = array(
1832 - 'message' => __( 'Global data Found', 'wdesignkit' ),
1833 - 'description' => __( 'Global Color and Typography found', 'wdesignkit' ),
1834 - 'data' => $site_globals,
1835 - 'success' => true,
1836 - );
1837 -
1838 - wp_send_json( $response );
1839 - wp_die();
1840 - }
1841 -
1842 - /**
1843 - *
1844 - * update site settings.
1845 - *
1846 - * @since 2.1.3
1847 - */
1848 - protected function wdkit_update_site_setting() {
1849 -
1850 - $builder = ! empty( $_POST['builder'] ) ? sanitize_text_field( $_POST['builder'] ) : '';
1851 - $site_data = ! empty( $_POST['site_data'] ) ? json_decode( sanitize_text_field( wp_unslash( $_POST['site_data'] ) ), true ) : array();
1852 -
1853 - if ( 'elementor' == $builder ) {
1854 - $kit_id = get_option( 'elementor_active_kit' );
1855 - if ( ! $kit_id ) {
1856 - $response = array(
1857 - 'message' => __( 'Elementor kit not found', 'wdesignkit' ),
1858 - 'description' => __( 'No active Elementor kit found', 'wdesignkit' ),
1859 - 'success' => false,
1860 - );
1861 -
1862 - wp_send_json( $response );
1863 - wp_die();
1864 - }
1865 -
1866 - $kit_meta = get_post_meta( $kit_id, '_elementor_page_settings', true );
1867 - if ( empty( $kit_meta ) ) {
1868 - $response = array(
1869 - 'message' => __( 'Data Not Found', 'wdesignkit' ),
1870 - 'description' => __( 'No site data found in kit', 'wdesignkit' ),
1871 - 'success' => false,
1872 - );
1873 -
1874 - wp_send_json( $response );
1875 - wp_die();
1876 - }
1877 -
1878 - $kit_meta['container_width'] = ! empty( $site_data['container_width'] ) ? $site_data['container_width'] : array();
1879 - $kit_meta['__globals__'] = ! empty( $site_data['globals'] ) ? $site_data['globals'] : array();
1880 - $kit_meta['body_background_color'] = ! empty( $site_data['body_background_color'] ) ? $site_data['body_background_color'] : array();
1881 -
1882 - update_post_meta( $kit_id, '_elementor_page_settings', $kit_meta );
1883 -
1884 - $response = array(
1885 - 'message' => __( 'Site data Updated', 'wdesignkit' ),
1886 - 'description' => __( 'Site Globals Updated', 'wdesignkit' ),
1887 - 'success' => true,
1888 - );
1889 -
1890 - } elseif ( 'gutenberg' == $builder ) {
1891 - $plus_settings = get_option( 'tpgb_global_options' );
1892 -
1893 - $site_preset = json_decode( $plus_settings, true );
1894 - $site_preset['globalContainer'] = $site_data;
1895 -
1896 - update_option( 'tpgb_global_options', json_encode( $site_preset ) );
1897 -
1898 - $response = array(
1899 - 'message' => __( 'Site data Updated', 'wdesignkit' ),
1900 - 'description' => __( 'Site Globals Updated', 'wdesignkit' ),
1901 - 'success' => true,
1902 - );
1903 -
1904 - } else {
1905 - $response = array(
1906 - 'message' => __( 'Builder Not Found !', 'wdesignkit' ),
1907 - 'description' => __( 'Template Builder not Found', 'wdesignkit' ),
1908 - 'success' => true,
1909 - );
1910 - }
1911 -
1912 - wp_send_json( $response );
1913 - wp_die();
1914 - }
1915 -
1916 - /**
1917 - *
1918 - * Update Elementor Global color and Typography.
1919 - *
1920 - * @since 1.1.20
1921 - */
1922 - protected function wdkit_update_global_val() {
1923 -
1924 - $builder = ! empty( $_POST['builder'] ) ? sanitize_text_field( $_POST['builder'] ) : '';
1925 -
1926 - if ( 'elementor' == $builder ) {
1927 -
1928 - $g_color = ! empty( $_POST['g_color'] ) ? json_decode( sanitize_text_field( wp_unslash( $_POST['g_color'] ) ), true ) : array();
1929 - $g_typo = ! empty( $_POST['g_typography'] ) ? json_decode( sanitize_text_field( wp_unslash( $_POST['g_typography'] ) ), true ) : array();
1930 -
1931 - // Get colors from Elementor Site Kit
1932 - $kit_id = get_option( 'elementor_active_kit' );
1933 - if ( ! $kit_id ) {
1934 - $response = array(
1935 - 'message' => __( 'Elementor kit not found', 'wdesignkit' ),
1936 - 'description' => __( 'No active Elementor kit found', 'wdesignkit' ),
1937 - 'success' => false,
1938 - );
1939 -
1940 - wp_send_json( $response );
1941 - wp_die();
1942 - }
1943 -
1944 - $kit_meta = get_post_meta( $kit_id, '_elementor_page_settings', true );
1945 - if ( empty( $kit_meta ) ) {
1946 - $response = array(
1947 - 'message' => __( 'Data Not Found', 'wdesignkit' ),
1948 - 'description' => __( 'No meta data found in kit', 'wdesignkit' ),
1949 - 'success' => false,
1950 - );
1951 -
1952 - wp_send_json( $response );
1953 - wp_die();
1954 - }
1955 -
1956 - $kit_meta['custom_colors'] = array_merge( $g_color, $kit_meta['custom_colors'] );
1957 - $kit_meta['custom_typography'] = array_merge( $g_typo, $kit_meta['custom_typography'] );
1958 -
1959 - update_post_meta( $kit_id, '_elementor_page_settings', $kit_meta );
1960 -
1961 - $response = array(
1962 - 'message' => __( 'Global data Updated', 'wdesignkit' ),
1963 - 'description' => __( 'Global Color and Typography Updated', 'wdesignkit' ),
1964 - 'success' => true,
1965 - );
1966 -
1967 - } elseif ( 'gutenberg' == $builder ) {
1968 - $new_preset = ! empty( $_POST['new_preset'] ) ? json_decode( sanitize_text_field( wp_unslash( $_POST['new_preset'] ) ), true ) : array();
1969 - $new_preset_id = ! empty( $new_preset['key'] ) ? $new_preset['key'] : '';
1970 - $plus_settings = get_option( 'tpgb_global_options' );
1971 - $site_preset = json_decode( $plus_settings, true );
1972 -
1973 - $site_preset['presets'][ $new_preset_id ] = $new_preset;
1974 - $site_preset['active'] = $new_preset_id;
1975 -
1976 - update_option( 'tpgb_global_options', json_encode( $site_preset ) );
1977 -
1978 - $response = array(
1979 - 'message' => __( 'Global data Updated', 'wdesignkit' ),
1980 - 'description' => __( 'Global Color and Typography Updated', 'wdesignkit' ),
1981 - 'success' => true,
1982 - );
1983 -
1984 - } else {
1985 - $response = array(
1986 - 'message' => __( 'Builder Not Found !', 'wdesignkit' ),
1987 - 'description' => __( 'Template Builder not Found', 'wdesignkit' ),
1988 - 'success' => true,
1989 - );
1990 - }
1991 -
1992 - wp_send_json( $response );
1993 - wp_die();
1994 - }
1995 -
1996 - /**
1997 - *
1998 - * Create Gutenberg page and save for re-generate css file.
1999 - *
2000 - * @since 1.2.3
2001 - */
2002 - protected function wdkit_update_preset() {
2003 -
2004 - $act_type = ! empty( $_POST['act_type'] ) ? sanitize_text_field( $_POST['act_type'] ) : '';
2005 - $post_id = ! empty( $_POST['post_id'] ) ? sanitize_text_field( $_POST['post_id'] ) : '';
2006 -
2007 - if ( 'create' == $act_type ) {
2008 -
2009 - $page_id = wp_insert_post(
2010 - array(
2011 - 'post_title' => 'WDesignKit Gutenberg',
2012 - 'post_status' => 'publish',
2013 - 'post_type' => 'post',
2014 - 'post_name' => sanitize_title( 'wdesignkit' ),
2015 - 'post_content' => '<!-- wp:heading --><h2 class="wp-block-heading">Add Your Heading Text Here<h2><!-- /wp:heading -->',
2016 - 'meta_input' => array(
2017 - 'gutenberg_preview' => true,
2018 - '_wp_page_template' => 'default',
2019 - ),
2020 - )
2021 - );
2022 -
2023 - if ( is_wp_error( $page_id ) || ! $page_id ) {
2024 - $response = array(
2025 - 'success' => true,
2026 - 'message' => esc_html__( 'Page Not Found!', 'wdesignkit' ),
2027 - 'description' => esc_html__( 'Page Not Found!', 'wdesignkit' ),
2028 - );
2029 -
2030 - wp_send_json( $response );
2031 - wp_die();
2032 - }
2033 -
2034 - update_post_meta( $page_id, '_edit_lock', time() . ':1' );
2035 - update_post_meta( $page_id, '_edit_last', get_current_user_id() );
2036 -
2037 - $preview_url = admin_url( 'post.php?post=' . $page_id . '&action=edit' );
2038 -
2039 - $response = array(
2040 - 'success' => true,
2041 - 'post_id' => $page_id,
2042 - 'preview_url' => $preview_url,
2043 - 'message' => esc_html__( 'Page Created', 'wdesignkit' ),
2044 - 'description' => esc_html__( 'Page Created', 'wdesignkit' ),
2045 - );
2046 -
2047 - wp_send_json( $response );
2048 - wp_die();
2049 -
2050 - }
2051 -
2052 - if ( ! empty( $post_id ) && ( $act_type == 'remove' ) ) {
2053 -
2054 - wp_delete_post( $post_id, true );
2055 -
2056 - $response = array(
2057 - 'success' => true,
2058 - 'message' => esc_html__( 'post deleted', 'wdesignkit' ),
2059 - 'description' => esc_html__( 'post deleted', 'wdesignkit' ),
2060 - );
2061 -
2062 - wp_send_json( $response );
2063 - wp_die();
2064 - }
2065 - }
2066 -
2067 - /**
2068 - *
2069 1004 * It is For Find User Existing template List.
2070 1005 *
2071 1006 * @since 1.0.6
2072 1007 */
@@ -2093,39 +1028,16 @@
2093 1028 * @since 1.0.6
2094 1029 */
2095 1030 protected function wdkit_update_template() {
2096 1031 $array_data = array(
2097 - 'data' => isset( $_POST['data'] ) ? wp_unslash( $_POST['data'] ) : '',
2098 - 'post_id' => isset( $_POST['post_id'] ) ? sanitize_text_field( wp_unslash( $_POST['post_id'] ) ) : '',
2099 - 'token' => isset( $_POST['token'] ) ? sanitize_text_field( wp_unslash( $_POST['token'] ) ) : '',
2100 - 'type' => isset( $_POST['type'] ) ? sanitize_text_field( wp_unslash( $_POST['type'] ) ) : '',
2101 - 'id' => isset( $_POST['id'] ) ? sanitize_text_field( wp_unslash( $_POST['id'] ) ) : '',
2102 - 'global_data' => isset( $_POST['global_data'] ) ? wp_unslash( $_POST['global_data'] ) : array(),
2103 - // 'global_font_family' => isset( $_POST['global_font_family'] ) ? wp_unslash( $_POST['global_font_family'] ) : array(),
2104 - // 'global_color' => isset( $_POST['global_color'] ) ? wp_unslash( $_POST['global_color'] ) : array(),
1032 + 'data' => isset( $_POST['data'] ) ? wp_unslash( $_POST['data'] ) : '',
1033 + 'token' => isset( $_POST['token'] ) ? sanitize_text_field( wp_unslash( $_POST['token'] ) ) : '',
1034 + 'type' => isset( $_POST['type'] ) ? sanitize_text_field( wp_unslash( $_POST['type'] ) ) : '',
1035 + 'id' => isset( $_POST['id'] ) ? sanitize_text_field( wp_unslash( $_POST['id'] ) ) : '',
2105 1036 );
2106 1037
2107 - if ( ! empty( $array_data['post_id'] ) ) {
2108 - $custom_fields = array();
2109 - $post_id = $array_data['post_id'];
1038 + $response = $this->wkit_api_call( $array_data, 'existing_template' );
2110 1039
2111 - $meta_fields = get_post_custom( $post_id );
2112 -
2113 - foreach ( $meta_fields as $key => $value ) {
2114 - if ( str_contains( $key, 'nxt-' ) ) {
2115 - $custom_fields[ $key ] = $value;
2116 - }
2117 - }
2118 -
2119 - if ( ! empty( $custom_fields ) ) {
2120 - $data = json_decode( $array_data['data'], true );
2121 - $data['custom_meta'] = $custom_fields;
2122 - $array_data['data'] = wp_json_encode( $data );
2123 - }
2124 - }
2125 -
2126 - $array_data['remove'] = 'yes';
2127 - $response = $this->wkit_api_call( $array_data, 'existing_template' );
2128 1040 wp_send_json( $response );
2129 1041 wp_die();
2130 1042 }
2131 1043
@@ -2169,9 +1081,8 @@
2169 1081 */
2170 1082 protected function wdkit_check_plugins_depends() {
2171 1083 $plugins = isset( $_POST['plugins'] ) ? json_decode( sanitize_text_field( wp_unslash( $_POST['plugins'] ) ) ) : array();
2172 1084 $update_plugin = array();
2173 - $update_theme = array();
2174 1085
2175 1086 if ( empty( $plugins ) || ! is_array( $plugins ) ) {
2176 1087 $this->wdkit_error_msg( array( 'plugins' => 'No Plugins' ) );
2177 1088 }
@@ -2184,9 +1095,8 @@
2184 1095
2185 1096 if ( is_null( $pluginslug ) ) {
2186 1097 $plugin->status = 'warning';
2187 1098 $update_plugin[] = $plugin;
2188 - $update_theme[] = $plugin;
2189 1099
2190 1100 continue;
2191 1101 }
2192 1102
@@ -2207,13 +1117,12 @@
2207 1117 $plugin->status = 'active';
2208 1118 $update_plugin[] = $plugin;
2209 1119 }
2210 1120 } elseif ( 'theme' === $type ) {
2211 - $theme_array = array_keys( wp_get_themes() );
2212 - $theme_slug = get_stylesheet();
2213 - $parent_theme_slug = get_template();
1121 + $theme_array = array_keys( wp_get_themes() );
1122 + $theme_slug = get_stylesheet();
2214 1123
2215 - if ( $theme_slug === $plugin->original_slug || $parent_theme_slug === $plugin->original_slug ) {
1124 + if ( $theme_slug === $plugin->original_slug ) {
2216 1125
2217 1126 $plugin->status = 'active';
2218 1127 } else {
2219 1128 $theme_name = $plugin->original_slug;
@@ -2227,19 +1136,13 @@
2227 1136 $plugin->status = 'inactive';
2228 1137 }
2229 1138 }
2230 1139
2231 - $update_theme[] = $plugin;
1140 + $update_plugin[] = $plugin;
2232 1141 }
2233 1142 }
2234 1143
2235 - $response = array(
2236 - 'plugins' => $update_plugin,
2237 - 'theme' => $update_theme,
2238 - 'ele_container' => get_option( 'elementor_experiment-container', false ),
2239 - );
2240 -
2241 - $this->wdkit_success_msg( $response );
1144 + $this->wdkit_success_msg( array( 'plugins' => $update_plugin ) );
2242 1145 }
2243 1146
2244 1147 /**
2245 1148 *
@@ -2250,9 +1153,8 @@
2250 1153 */
2251 1154 protected function wdkit_install_plugins_depends() {
2252 1155 $plugins = isset( $_POST['plugins'] ) ? json_decode( sanitize_text_field( wp_unslash( $_POST['plugins'] ) ), true ) : array();
2253 1156 $type = ! empty( $plugins['type'] ) ? $plugins['type'] : 'plugin';
2254 - $p_id = ! empty( $plugins['p_id'] ) ? $plugins['p_id'] : 'plugin';
2255 1157
2256 1158 $responce = '';
2257 1159 if ( 'plugin' === $type ) {
2258 1160 $responce = Wdkit_Depends_Installer::get_instance()->wdkit_install_plugin( $plugins );
@@ -2259,46 +1161,24 @@
2259 1161 } elseif ( 'theme' === $type ) {
2260 1162 $theme_name = ! empty( $plugins['original_slug'] ) ? $plugins['original_slug'] : '';
2261 1163 if ( ! empty( $theme_name ) ) {
2262 1164
2263 - $theme_array = array_keys( wp_get_themes() );
2264 - $theme_slug = get_stylesheet();
1165 + $activate_result = switch_theme( $theme_name );
2265 1166
2266 - if ( in_array( $theme_name, $theme_array ) ) {
2267 - $activate_result = switch_theme( $theme_name );
2268 -
2269 - if ( ! is_wp_error( $activate_result ) ) {
2270 - $responce = array(
2271 - 'message' => esc_html__( 'Theme activated successfully', 'wdesignkit' ),
2272 - 'description' => esc_html__( 'Theme successfully activated', 'wdesignkit' ),
2273 - 'slug' => 'nexter',
2274 - 'p_id' => $p_id,
2275 - 'status' => 'active',
2276 - 'success' => true,
2277 - );
2278 - } else {
2279 - $responce = array(
2280 - 'message' => esc_html__( 'Theme Not Activated !', 'wdesignkit' ),
2281 - 'description' => $activate_result->get_error_message(),
2282 - 'status' => 'inactive',
2283 - 'p_id' => $p_id,
2284 - 'success' => false,
2285 - );
2286 - }
1167 + if ( ! is_wp_error( $activate_result ) ) {
1168 + $responce = array(
1169 + 'message' => esc_html__( 'Theme activated successfully', 'wdesignkit' ),
1170 + 'description' => esc_html__( 'Theme successfully activated', 'wdesignkit' ),
1171 + 'slug' => 'the-plus-addons-for-block-editor',
1172 + 'status' => 'active',
1173 + 'success' => true,
1174 + );
2287 1175 } else {
2288 - $result = $this->wdkit_install_theme_depends( $theme_name );
2289 -
2290 - $message = ! empty( $result['message'] ) ? $result['message'] : esc_html__( 'Somthing Wrong', 'wdesignkit' );
2291 - $description = ! empty( $result['description'] ) ? $result['description'] : esc_html__( 'Error Somthing Wrong', 'wdesignkit' );
2292 - $status = ! empty( $result['status'] ) ? $result['status'] : esc_html__( 'inactive', 'wdesignkit' );
2293 - $success = ! empty( $result['success'] ) ? $result['success'] : false;
2294 -
2295 1176 $responce = array(
2296 - 'message' => $message,
2297 - 'description' => $description,
2298 - 'p_id' => $p_id,
2299 - 'status' => $status,
2300 - 'success' => $success,
1177 + 'message' => esc_html__( 'Theme Not Activated !', 'wdesignkit' ),
1178 + 'description' => $activate_result->get_error_message(),
1179 + 'status' => 'inactive',
1180 + 'success' => false,
2301 1181 );
2302 1182 }
2303 1183 } else {
2304 1184 $responce = array(
@@ -2303,9 +1183,9 @@
2303 1183 } else {
2304 1184 $responce = array(
2305 1185 'message' => esc_html__( 'Theme Name not Found', 'wdesignkit' ),
2306 1186 'description' => esc_html__( 'Can Not Found Theme Name you Enterd.', 'wdesignkit' ),
2307 - 'success' => false,
1187 + 'success' => true,
2308 1188 );
2309 1189 }
2310 1190 }
2311 1191
@@ -2312,103 +1192,8 @@
2312 1192 wp_send_json( $responce );
2313 1193 wp_die();
2314 1194 }
2315 1195
2316 - protected function wdkit_install_theme_depends( $name = 'nexter' ) {
2317 -
2318 - if ( ! current_user_can( 'install_themes' ) ) {
2319 - $response = $this->tpae_set_response( false, 'Invalid nonce.', 'The security check failed. Please refresh the page and try again.' );
2320 - return $response;
2321 - }
2322 -
2323 - $theme_slug = $name;
2324 - $theme_api_url = 'https://api.wordpress.org/themes/info/1.0/';
2325 -
2326 - // Parameters for the request
2327 - $args = array(
2328 - 'body' => array(
2329 - 'action' => 'theme_information',
2330 - 'request' => serialize(
2331 - (object) array(
2332 - 'slug' => $name,
2333 - 'fields' => array(
2334 - 'description' => false,
2335 - 'sections' => false,
2336 - 'rating' => true,
2337 - 'ratings' => false,
2338 - 'downloaded' => true,
2339 - 'download_link' => true,
2340 - 'last_updated' => true,
2341 - 'homepage' => true,
2342 - 'tags' => true,
2343 - 'template' => true,
2344 - 'active_installs' => false,
2345 - 'parent' => false,
2346 - 'versions' => false,
2347 - 'screenshot_url' => true,
2348 - 'active_installs' => false,
2349 - ),
2350 - )
2351 - ),
2352 - ),
2353 - );
2354 -
2355 - // Make the request
2356 - $response = wp_remote_post( $theme_api_url, $args );
2357 - // Check for errors
2358 - if ( is_wp_error( $response ) ) {
2359 - $error_message = $response->get_error_message();
2360 -
2361 - $result = $this->tpae_set_response( false, 'oops', 'oops', '' );
2362 - } else {
2363 - $theme_info = unserialize( $response['body'] );
2364 - $theme_name = $theme_info->name;
2365 - $theme_zip_url = $theme_info->download_link;
2366 -
2367 - global $wp_filesystem;
2368 - // Install the theme
2369 - $theme = wp_remote_get( $theme_zip_url, array( 'timeout' => 30 ) );
2370 -
2371 - if ( ! function_exists( 'WP_Filesystem' ) ) {
2372 - require_once wp_normalize_path( ABSPATH . '/wp-admin/includes/file.php' );
2373 - }
2374 -
2375 - WP_Filesystem();
2376 -
2377 - $active_theme = wp_get_theme();
2378 - $theme_name = $active_theme->get( 'Name' );
2379 -
2380 - $wp_filesystem->put_contents( WP_CONTENT_DIR . '/themes/' . $theme_slug . '.zip', $theme['body'] );
2381 - $zip = new ZipArchive();
2382 - if ( $zip->open( WP_CONTENT_DIR . '/themes/' . $theme_slug . '.zip' ) === true ) {
2383 - $zip->extractTo( WP_CONTENT_DIR . '/themes/' );
2384 - $zip->close();
2385 - }
2386 -
2387 - $wp_filesystem->delete( WP_CONTENT_DIR . '/themes/' . $theme_slug . '.zip' );
2388 -
2389 - $activate_result = switch_theme( $name );
2390 -
2391 - if ( ! is_wp_error( $activate_result ) ) {
2392 - $response = array(
2393 - 'message' => esc_html__( 'Theme activated successfully', 'wdesignkit' ),
2394 - 'description' => esc_html__( 'Theme successfully activated', 'wdesignkit' ),
2395 - 'status' => 'active',
2396 - 'success' => true,
2397 - );
2398 - } else {
2399 - $response = array(
2400 - 'message' => esc_html__( 'Theme Not Activated !', 'wdesignkit' ),
2401 - 'description' => $activate_result->get_error_message(),
2402 - 'status' => 'inactive',
2403 - 'success' => false,
2404 - );
2405 - }
2406 - }
2407 -
2408 - return $response;
2409 - }
2410 -
2411 1196 /**
2412 1197 *
2413 1198 * It is Use Update WDesignKit plugin latest version.
2414 1199 *
@@ -2437,118 +1222,25 @@
2437 1222 * Get Download Template Content
2438 1223 *
2439 1224 * @since 1.0.0
2440 1225 */
2441 - protected function wdkit_activate_container() {
1226 + protected function wdkit_import_template() {
1227 + $args = $this->wdkit_parse_args( $_POST );
2442 1228
2443 - $option_value = get_option( 'elementor_experiment-container', false );
1229 + if ( empty( $args['email'] ) ) {
1230 + $response = array(
1231 + 'content' => '',
1232 + 'message' => esc_html__( 'Invalid import', 'wdesignkit' ),
1233 + 'description' => esc_html__( 'Invalid import: Check your details and try again.', 'wdesignkit' ),
1234 + 'success' => true,
1235 + );
2444 1236
2445 - if ( $option_value === false ) {
2446 - add_option( 'elementor_experiment-container', 'active' );
2447 - } else {
2448 - update_option( 'elementor_experiment-container', 'active' );
1237 + wp_send_json( $response );
1238 + wp_die();
2449 1239 }
2450 1240
2451 - $result = array(
2452 - 'message' => esc_html__( 'Container Activated Successfully', 'wdesignkit' ),
2453 - 'description' => esc_html__( 'Elementor Container Activated Successfully.', 'wdesignkit' ),
2454 - 'success' => true,
2455 - );
2456 -
2457 - wp_send_json( $response );
2458 - wp_die();
2459 - }
2460 -
2461 - /**
2462 - * import category and tags for post
2463 - *
2464 - * @since 2.0.0
2465 - */
2466 - protected function wdkit_import_taxonomy() {
2467 - $category = isset( $_POST['category'] ) ? json_decode( wp_unslash( $_POST['category'] ) ) : array();
2468 - $tags = isset( $_POST['tags'] ) ? json_decode( wp_unslash( $_POST['tags'] ) ) : array();
2469 -
2470 - $response = array(
2471 - 'success' => false,
2472 - 'categories' => array(),
2473 - 'tags' => array(),
2474 - );
2475 -
2476 - if ( ! empty( $category ) && count( $category ) > 0 ) {
2477 - foreach ( $category as $category_name ) {
2478 - $category_name = sanitize_text_field( $category_name );
2479 -
2480 - $term_exists = term_exists( $category_name, 'category' );
2481 - if ( ! $term_exists ) {
2482 - $result = wp_insert_term( $category_name, 'category' );
2483 - if ( ! is_wp_error( $result ) ) {
2484 - $response['categories'][] = array(
2485 - 'name' => $category_name,
2486 - 'term_id' => $result['term_id'],
2487 - );
2488 - } else {
2489 - $response['categories'][] = array(
2490 - 'name' => $category_name,
2491 - 'error' => $result->get_error_message(),
2492 - );
2493 - }
2494 - } else {
2495 - $term_id = is_array( $term_exists ) ? $term_exists['term_id'] : $term_exists;
2496 - $response['categories'][] = array(
2497 - 'name' => $category_name,
2498 - 'term_id' => $term_id,
2499 - );
2500 - }
2501 - }
2502 -
2503 - $response['success'] = true;
2504 - }
2505 -
2506 - if ( ! empty( $tags ) && count( $tags ) > 0 ) {
2507 - foreach ( $tags as $tags_name ) {
2508 - $tags_name = sanitize_text_field( $tags_name );
2509 -
2510 - $term_exists = term_exists( $tags_name, 'post_tag' );
2511 - if ( ! $term_exists ) {
2512 - $result = wp_insert_term( $tags_name, 'post_tag' );
2513 - if ( ! is_wp_error( $result ) ) {
2514 - $response['tags'][] = array(
2515 - 'name' => $tags_name,
2516 - 'term_id' => $result['term_id'],
2517 - );
2518 - } else {
2519 - $response['tags'][] = array(
2520 - 'name' => $tags_name,
2521 - 'error' => $result->get_error_message(),
2522 - );
2523 - }
2524 - } else {
2525 - $term_id = is_array( $term_exists ) ? $term_exists['term_id'] : $term_exists;
2526 - $response['tags'][] = array(
2527 - 'name' => $tags_name,
2528 - 'term_id' => $term_id,
2529 - );
2530 - }
2531 - }
2532 -
2533 - $response['success'] = true;
2534 - }
2535 -
2536 - wp_send_json( $response );
2537 - wp_die();
2538 - }
2539 -
2540 - /**
2541 - * Get Download Template Content
2542 - *
2543 - * @since 1.0.0
2544 - */
2545 - protected function wdkit_import_template() {
2546 - $args = $this->wdkit_parse_args( $_POST );
2547 - $api_type = isset( $_POST['api_type'] ) ? sanitize_text_field( wp_unslash( $_POST['api_type'] ) ) : 'import_template';
2548 -
2549 1241 $response = '';
2550 - if ( empty( $args['template_id'] ) ) {
1242 + if ( empty( $args['email'] ) || empty( $args['template_id'] ) ) {
2551 1243 $result = array(
2552 1244 'content' => '',
2553 1245 'message' => esc_html__( 'Invalid import', 'wdesignkit' ),
2554 1246 'description' => esc_html__( 'Invalid import: Check your details and try again.', 'wdesignkit' ),
@@ -2561,10 +1253,9 @@
2561 1253
2562 1254 $args['token'] = $this->wdkit_login_user_token( $args['email'] );
2563 1255
2564 1256 unset( $args['email'] );
2565 - $args['unique_id'] = get_option( 'wdkit_unique_id' ) ?? '';
2566 - $response = WDesignKit_Data_Query::get_data( $api_type, $args );
1257 + $response = WDesignKit_Data_Query::get_data( 'import_template', $args );
2567 1258 $custom_meta = isset( $_POST['custom_meta'] ) ? sanitize_text_field( wp_unslash( $_POST['custom_meta'] ) ) : false;
2568 1259
2569 1260 /** Custom meta Field */
2570 1261 if ( ! empty( $custom_meta ) && 'true' === $custom_meta && ! empty( $response ) && ! empty( $response['content'] ) ) {
@@ -2800,15 +1491,10 @@
2800 1491 $blocks_attr[ $block_key ][ $key ] = $new_media;
2801 1492 } else {
2802 1493 foreach ( $val as $sub_key => $sub_val ) {
2803 1494 if ( isset( $sub_val['url'] ) && ( isset( $sub_val['Id'] ) || isset( $sub_val['id'] ) ) && ! empty( $sub_val['url'] ) ) {
2804 - $new_media = Wdkit_Import_Images::wdkit_Import_media( $sub_val );
2805 -
2806 - if ( is_array( $sub_val ) && is_array( $new_media ) ) {
2807 - $blocks_attr[ $block_key ][ $key ][ $sub_key ] = array_merge( $sub_val, $new_media );
2808 - } else {
2809 - $blocks_attr[ $block_key ][ $key ][ $sub_key ] = $new_media;
2810 - }
1495 + $new_media = Wdkit_Import_Images::wdkit_Import_media( $sub_val );
1496 + $blocks_attr[ $block_key ][ $key ][ $sub_key ] = $new_media;
2811 1497 } elseif ( isset( $sub_val['url'] ) && ! empty( $sub_val['url'] ) && preg_match( '/\.(jpg|png|jpeg|gif|svg|webp)$/', $sub_val['url'] ) ) {
2812 1498 $new_media = Wdkit_Import_Images::wdkit_Import_media( $sub_val );
2813 1499 $blocks_attr[ $block_key ][ $key ][ $sub_key ] = $new_media;
2814 1500 } elseif ( is_array( $sub_val ) && ! empty( $sub_val ) ) {
@@ -2814,14 +1500,9 @@
2814 1500 } elseif ( is_array( $sub_val ) && ! empty( $sub_val ) ) {
2815 1501 foreach ( $sub_val as $sub_key1 => $sub_val1 ) {
2816 1502 if ( isset( $sub_val1['url'] ) && ( isset( $sub_val1['Id'] ) || isset( $sub_val1['id'] ) ) && ! empty( $sub_val1['url'] ) ) {
2817 1503 $new_media = Wdkit_Import_Images::wdkit_Import_media( $sub_val1 );
2818 -
2819 - if ( is_array( $sub_val1 ) && is_array( $new_media ) ) {
2820 - $blocks_attr[ $block_key ][ $key ][ $sub_key ][ $sub_key1 ] = array_merge( $sub_val1, $new_media );
2821 - } else {
2822 - $blocks_attr[ $block_key ][ $key ][ $sub_key ][ $sub_key1 ] = $new_media;
2823 - }
1504 + $blocks_attr[ $block_key ][ $key ][ $sub_key ][ $sub_key1 ] = $new_media;
2824 1505 } elseif ( isset( $sub_val1['url'] ) && ! empty( $sub_val1['url'] ) && preg_match( '/\.(jpg|png|jpeg|gif|svg|webp)$/', $sub_val1['url'] ) ) {
2825 1506 $new_media = Wdkit_Import_Images::wdkit_Import_media( $sub_val1 );
2826 1507 $blocks_attr[ $block_key ][ $key ][ $sub_key ][ $sub_key1 ] = $new_media;
2827 1508 }
@@ -2854,10 +1535,8 @@
2854 1535 if ( ! current_user_can( 'manage_options' ) ) {
2855 1536 return false;
2856 1537 }
2857 1538
2858 - $builder = isset( $_POST['builder'] ) ? sanitize_text_field( wp_unslash( $_POST['builder'] ) ) : '';
2859 -
2860 1539 $page_section = ! empty( $_POST['page_section'] ) ? sanitize_text_field( wp_unslash( $_POST['page_section'] ) ) : '';
2861 1540
2862 1541 if ( isset( $page_section ) ) {
2863 1542 $args['page_section'] = ! empty( $page_section ) ? sanitize_text_field( wp_unslash( $page_section ) ) : '';
@@ -2862,16 +1541,14 @@
2862 1541 if ( isset( $page_section ) ) {
2863 1542 $args['page_section'] = ! empty( $page_section ) ? sanitize_text_field( wp_unslash( $page_section ) ) : '';
2864 1543 }
2865 1544
2866 - $template_ids = ! empty( $_POST['template_ids'] ) ? json_decode( sanitize_text_field( wp_unslash( $_POST['template_ids'] ) ), true ) : array();
2867 - $email = ! empty( $_POST['email'] ) ? strtolower( sanitize_email( wp_unslash( $_POST['email'] ) ) ) : '';
2868 - $editor = isset( $_POST['editor'] ) ? sanitize_text_field( wp_unslash( $_POST['editor'] ) ) : '';
2869 - $website_kit = isset( $_POST['website_kit'] ) ? sanitize_text_field( wp_unslash( $_POST['website_kit'] ) ) : '';
2870 - $api_type = isset( $_POST['api_type'] ) ? sanitize_text_field( wp_unslash( $_POST['api_type'] ) ) : 'import_template';
2871 - $ai_compitible = isset( $_POST['ai_compitible'] ) ? sanitize_text_field( wp_unslash( $_POST['ai_compitible'] ) ) : false;
1545 + $template_ids = ! empty( $_POST['template_ids'] ) ? json_decode( sanitize_text_field( wp_unslash( $_POST['template_ids'] ) ), true ) : array();
1546 + $email = ! empty( $_POST['email'] ) ? strtolower( sanitize_email( wp_unslash( $_POST['email'] ) ) ) : '';
1547 + $editor = isset( $_POST['editor'] ) ? sanitize_text_field( wp_unslash( $_POST['editor'] ) ) : '';
1548 + $website_kit = isset( $_POST['website_kit'] ) ? sanitize_text_field( wp_unslash( $_POST['website_kit'] ) ) : '';
2872 1549
2873 - if ( empty( $template_ids ) ) {
1550 + if ( empty( $email ) || empty( $template_ids ) ) {
2874 1551 $output = array(
2875 1552 'message' => esc_html__( 'Invalid import', 'wdesignkit' ),
2876 1553 'description' => esc_html__( 'Invalid import: Check your details and try again.', 'wdesignkit' ),
2877 1554 'success' => false,
@@ -2895,100 +1572,32 @@
2895 1572 'token' => $token,
2896 1573 'template_id' => $template_ids['id'],
2897 1574 'editor' => $editor,
2898 1575 'website_kit' => $website_kit,
2899 - 'unique_id' => get_option( 'wdkit_unique_id' ) ?? '',
2900 1576 );
2901 1577
2902 - $response = WDesignKit_Data_Query::get_data( $api_type, $temp_args );
1578 + $response = WDesignKit_Data_Query::get_data( 'import_template', $temp_args );
2903 1579 $output = array();
2904 1580
2905 - if ( is_wp_error( $response ) ) {
2906 -
1581 + if ( 'error' === $response['content'] ) {
2907 1582 wp_send_json( $response );
2908 1583 wp_die();
1584 + } else {
1585 + $output[ $template_ids['id'] ] = $this->import_page_section_content( $args, $template_ids['id'], $response, $template_ids );
1586 + $output['message'] = $response['message'];
1587 + $output['description'] = $response['description'];
1588 + $output['success'] = $response['success'];
2909 1589 }
2910 1590
2911 - if ( isset( $response['content'] ) && 'error' === $response['content'] ) {
2912 - wp_send_json( $response );
2913 - wp_die();
2914 - }
2915 -
2916 - $result = array(
2917 - 'response' => $response,
2918 - 'args' => $args,
2919 - 'id' => $template_ids['id'],
2920 - 'temp_data' => $template_ids,
2921 - );
2922 -
2923 - $output['message'] = $response['message'];
2924 - $output['description'] = $response['description'];
2925 - $output['data'] = $result;
2926 - $output['success'] = $response['success'];
2927 -
2928 1591 wp_send_json( $output );
2929 1592 wp_die();
2930 1593 }
2931 1594
2932 - public function wdkit_enable_template_widgets() {
2933 - $widget_list = ! empty( $_POST['widget_list'] ) ? json_decode( wp_unslash( $_POST['widget_list'] ), true ) : array();
2934 - $extensions_list = ! empty( $_POST['extensions_list'] ) ? json_decode( wp_unslash( $_POST['extensions_list'] ), true ) : array();
2935 -
2936 - if ( empty( $widget_list ) && empty( $extensions_list ) ) {
2937 - $res = array(
2938 - 'massage' => __( 'Widget array not found', 'wdesignkit' ),
2939 - 'description' => __( 'Widget array not found', 'wdesignkit' ),
2940 - 'success' => false,
2941 - );
2942 - wp_send_json( $res );
2943 - wp_die();
2944 - }
2945 -
2946 - if ( ! has_filter( 'tpae_enable_selected_widgets' ) ) {
2947 - $res = array(
2948 - 'massage' => __( 'Relevant Plugin not Activated', 'wdesignkit' ),
2949 - 'description' => __( 'Relevant Plugin not Installed / Activated', 'wdesignkit' ),
2950 - 'success' => false,
2951 - );
2952 - wp_send_json( $res );
2953 - wp_die();
2954 - }
2955 -
2956 - $w_list = array(
2957 - 'widgets' => $widget_list,
2958 - 'extensions' => $extensions_list,
2959 - );
2960 -
2961 - $result = apply_filters( 'tpae_enable_selected_widgets', $w_list );
2962 -
2963 - if ( ! empty( $result['success'] ) ) {
2964 - $res = array(
2965 - 'massage' => __( 'Enabled widgets successfully', 'wdesignkit' ),
2966 - 'description' => __( 'Used widgets have been enabled successfully', 'wdesignkit' ),
2967 - 'success' => true,
2968 - );
2969 - } else {
2970 -
2971 - $message = isset( $result['message'] ) ? $result['message'] : __( 'Failed to enable widgets', 'wdesignkit' );
2972 - $description = isset( $result['description'] ) ? $result['description'] : __( 'Failed to enable widgets', 'wdesignkit' );
2973 -
2974 - $res = array(
2975 - 'massage' => $message,
2976 - 'description' => $description,
2977 - 'success' => false,
2978 - );
2979 - }
2980 -
2981 - wp_send_json( $res );
2982 - wp_die();
2983 - }
2984 -
2985 1595 /**
2986 1596 * Import single template and section from plugin only
2987 1597 * */
2988 1598 protected function wdkit_import_multi_template() {
2989 - $args = $this->wdkit_parse_args( $_POST );
2990 - $api_type = isset( $_POST['api_type'] ) ? sanitize_text_field( wp_unslash( $_POST['api_type'] ) ) : 'import_template';
1599 + $args = $this->wdkit_parse_args( $_POST );
2991 1600
2992 1601 if ( ! current_user_can( 'manage_options' ) ) {
2993 1602 return false;
2994 1603 }
@@ -3017,42 +1626,56 @@
3017 1626 $args['post_type'] = ! empty( $_POST['select'] ) ? sanitize_text_field( wp_unslash( $_POST['select'] ) ) : '';
3018 1627 }
3019 1628
3020 1629 $args['custom_meta'] = isset( $_POST['custom_meta'] ) ? sanitize_text_field( wp_unslash( $_POST['custom_meta'] ) ) : false;
3021 -
3022 1630 if ( ! empty( $args['template_ids'] ) && ! empty( $args['page_section'] ) ) {
3023 1631 $output = array();
3024 - if ( ! empty( $args['template_ids']['id'] ) ) {
1632 + if ( is_array( $args['template_ids'] ) ) {
1633 + foreach ( $args['template_ids'] as $key => $value ) {
1634 + if ( ! empty( $value['id'] ) ) {
1635 + $token = $this->wdkit_login_user_token( $args['email'] );
1636 + $temp_args = array(
1637 + 'token' => $token,
1638 + 'template_id' => $value['id'],
1639 + 'editor' => $args['editor'],
1640 + );
1641 +
1642 + $response = WDesignKit_Data_Query::get_data( 'import_template', $temp_args );
1643 +
1644 + if ( 'error' === $response['content'] ) {
1645 + wp_send_json( $response );
1646 + wp_die();
1647 + } else {
1648 + $output[ $value['id'] ] = $this->import_page_section_content( $args, $value['id'], $response, $value );
1649 + $output['message'] = $response['message'];
1650 + $output['description'] = $response['description'];
1651 + $output['success'] = $response['success'];
1652 + }
1653 + }
1654 + }
1655 + } else {
3025 1656 $token = $this->wdkit_login_user_token( $args['email'] );
3026 -
3027 1657 $temp_args = array(
3028 1658 'token' => $token,
3029 - 'template_id' => $args['template_ids']['id'],
1659 + 'template_id' => $args['template_ids'],
3030 1660 'editor' => $args['editor'],
3031 - 'unique_id' => get_option( 'wdkit_unique_id' ) ?? '',
3032 1661 );
3033 1662
3034 - $response = WDesignKit_Data_Query::get_data( $api_type, $temp_args );
1663 + $response = WDesignKit_Data_Query::get_data( 'import_template', $temp_args );
3035 1664
3036 1665 if ( 'error' === $response['content'] ) {
3037 1666 wp_send_json( $response );
3038 1667 wp_die();
1668 + } else {
1669 + $output[ $args['template_ids'] ] = $this->import_page_section_content( $args, $args['template_ids'], $response );
1670 + $output['message'] = $response['message'];
1671 + $output['description'] = $response['description'];
1672 + $output['success'] = $response['success'];
3039 1673 }
1674 + }
3040 1675
3041 - $result = array(
3042 - 'response' => $response,
3043 - 'args' => $args,
3044 - 'id' => $args['template_ids'],
3045 - 'value' => $args['template_ids'],
3046 - );
1676 + $output['success'] = true;
3047 1677
3048 - $output['message'] = $response['message'];
3049 - $output['description'] = $response['description'];
3050 - $output['data'] = $result;
3051 - $output['success'] = true;
3052 -
3053 - }
3054 -
3055 1678 wp_send_json( $output );
3056 1679 wp_die();
3057 1680 }
3058 1681 }
@@ -3057,59 +1680,8 @@
3057 1680 }
3058 1681 }
3059 1682
3060 1683 /**
3061 - * It is Use for remove selected category from content.
3062 - *
3063 - * @since 2.0.5
3064 - */
3065 - public function wdkit_content_remover( &$data ) {
3066 -
3067 - if ( is_array( $data ) ) {
3068 -
3069 - foreach ( $data as $key => &$value ) {
3070 - if ( $key === 'post_category' ) {
3071 - $data[ $key ] = array();
3072 - } else if ($key === 'include_products'){
3073 - $data[ $key ] = "";
3074 - } else {
3075 - $this->wdkit_content_remover( $value );
3076 - }
3077 - }
3078 - } elseif ( is_object( $data ) ) {
3079 -
3080 - foreach ( $data as $key => &$value ) {
3081 - if ( $key === 'post_category' ) {
3082 - $data->$key = array();
3083 - } else if ($key === 'include_products'){
3084 - $data->$key = "";
3085 - } else {
3086 - $this->wdkit_content_remover( $value );
3087 - }
3088 - }
3089 - }
3090 -
3091 - return $data;
3092 - }
3093 -
3094 - protected function wkit_update_elementor_template(){
3095 -
3096 - if ( isset( $_POST['data'] ) ) {
3097 - $content = ! empty( $_POST['data'] ) ? json_decode( wp_unslash( $_POST['data'] ), true ) : '';
3098 - }
3099 -
3100 - if ( isset( $_POST['template_id'] ) ) {
3101 - $template_id = ! empty( $_POST['template_id'] ) ? json_decode( sanitize_text_field( wp_unslash( $_POST['template_id'] ), true ) ) : '';
3102 - }
3103 -
3104 - $document = \Elementor\Plugin::$instance->documents->get($template_id);
3105 -
3106 - $document->save([
3107 - 'elements' => $content
3108 - ]);
3109 - }
3110 -
3111 - /**
3112 1684 * Import single template and section from plugin only
3113 1685 *
3114 1686 * @param array $args store data.
3115 1687 * @param array $template_id store data.
@@ -3115,42 +1687,9 @@
3115 1687 * @param array $template_id store data.
3116 1688 * @param array $data store data.
3117 1689 * @param array $temp_data store data.
3118 1690 * */
3119 - protected function import_page_section_content() {
3120 -
3121 - if ( isset( $_POST['args'] ) ) {
3122 - $args = ! empty( $_POST['args'] ) ? json_decode( sanitize_text_field( wp_unslash( $_POST['args'] ) ), true ) : array();
3123 - }
3124 -
3125 - if ( isset( $_POST['temp_data'] ) ) {
3126 - $temp_data = ! empty( $_POST['temp_data'] ) ? json_decode( sanitize_text_field( wp_unslash( $_POST['temp_data'] ) ), true ) : array();
3127 - }
3128 -
3129 - if ( isset( $_POST['category_list'] ) ) {
3130 - $category_list = ! empty( $_POST['category_list'] ) ? json_decode( wp_unslash( $_POST['category_list'] ), true ) : '';
3131 - }
3132 -
3133 - if ( isset( $_POST['tag_list'] ) ) {
3134 - $tag_list = ! empty( $_POST['tag_list'] ) ? json_decode( wp_unslash( $_POST['tag_list'] ), true ) : '';
3135 - }
3136 -
3137 - if ( isset( $_POST['thumb_image'] ) ) {
3138 - $thumb_image = ! empty( $_POST['thumb_image'] ) ? esc_url_raw( $_POST['thumb_image'] ) : '';
3139 - }
3140 -
3141 - if ( isset( $_POST['template_id'] ) ) {
3142 - $template_id = ! empty( $_POST['template_id'] ) ? json_decode( sanitize_text_field( wp_unslash( $_POST['template_id'] ), true ) ) : '';
3143 - }
3144 -
3145 - if ( isset( $_POST['temp_type'] ) ) {
3146 - $temp_type = isset( $_POST['temp_type'] ) ? sanitize_text_field( wp_unslash( $_POST['temp_type'] ) ) : 'normal';
3147 - }
3148 -
3149 - if ( isset( $_POST['data'] ) ) {
3150 - $data = ! empty( $_POST['data'] ) ? json_decode( wp_unslash( $_POST['data'] ) ) : '';
3151 - }
3152 -
1691 + private function import_page_section_content( $args, $template_id, $data, $temp_data = array() ) {
3153 1692 $enqueue_instance = new Wdkit_Enqueue();
3154 1693 $get_post_type = $enqueue_instance->wdkit_get_post_type_list();
3155 1694
3156 1695 $post_type = ! empty( $temp_data['type'] ) ? sanitize_text_field( wp_unslash( $temp_data['type'] ) ) : 'page';
@@ -3156,10 +1695,8 @@
3156 1695 $post_type = ! empty( $temp_data['type'] ) ? sanitize_text_field( wp_unslash( $temp_data['type'] ) ) : 'page';
3157 1696
3158 1697 if ( 'section' === $post_type ) {
3159 1698 $post_type = $temp_data['wp_post_type'];
3160 - } else {
3161 - $post_type = $temp_data['wp_post_type'];
3162 1699 }
3163 1700
3164 1701 if ( ! array_key_exists( $post_type, $get_post_type ) ) {
3165 1702 $post_type = 'page';
@@ -3164,15 +1701,13 @@
3164 1701 if ( ! array_key_exists( $post_type, $get_post_type ) ) {
3165 1702 $post_type = 'page';
3166 1703 }
3167 1704
3168 - if ( ! empty( $data ) && ! empty( $template_id ) && ! empty( $post_type ) && current_user_can( 'manage_options' ) ) {
3169 - $post_content = $data;
1705 + if ( ! empty( $data ) && ! empty( $data['content'] ) && ! empty( $template_id ) && ! empty( $post_type ) && current_user_can( 'manage_options' ) ) {
1706 + $post_content = json_decode( $data['content'] );
3170 1707 $post_title = isset( $post_content->title ) ? sanitize_text_field( $post_content->title ) : '';
3171 - $post_slug = isset( $post_content->slug ) ? sanitize_text_field( $post_content->slug ) : '';
3172 1708 $file_type = isset( $post_content->file_type ) ? sanitize_text_field( $post_content->file_type ) : '';
3173 1709 $content = isset( $post_content->content ) ? wp_slash( $post_content->content ) : '';
3174 - $temp_con = '';
3175 1710
3176 1711 if ( 'gutenberg' === $args['editor'] || ( 'wdkit' === $args['editor'] && ! empty( $file_type ) && 'wp_block' === $file_type ) ) {
3177 1712 if ( empty( $content ) ) {
3178 1713 wp_send_json(
@@ -3182,36 +1717,19 @@
3182 1717 )
3183 1718 );
3184 1719 wp_die();
3185 1720 } elseif ( ! empty( $content ) && ! empty( $file_type ) && 'wp_block' === $file_type ) {
1721 + $parse_blocks = parse_blocks( stripslashes( $content ) );
3186 1722
3187 1723 $editor = ( 'wdkit' === $args['editor'] ) ? 'gutenberg' : $args['editor'];
3188 - $blocks = parse_blocks( stripslashes( $content ) );
3189 -
3190 - $blocks = $this->wdkit_media_import( $blocks, $editor );
1724 + $content = $this->wdkit_media_import( $parse_blocks, $editor );
1725 + $content = addslashes( serialize_blocks( $content ) );
3191 1726
3192 - $processor = new WDKIT_Nexter_Block_Processor();
3193 - $blocks = $processor->run( $blocks );
3194 - $content = serialize_blocks( $blocks );
3195 -
3196 - $content = $this->replace_unicode_glitch( serialize_blocks( $blocks ) );
3197 -
3198 - if ( ! empty( $category_list ) && is_array( $category_list ) ) {
3199 - $category_ids = array_map( 'intval', $category_list );
3200 - wp_set_post_terms( $inserted_id, $category_ids, 'category' );
3201 - }
3202 -
3203 - if ( ! empty( $tag_list ) && is_array( $tag_list ) ) {
3204 - $tag_ids = array_map( 'intval', $tag_list );
3205 - wp_set_post_terms( $inserted_id, $tag_ids, 'post_tag' );
3206 - }
3207 -
3208 1727 $inserted_post = wp_insert_post(
3209 1728 array(
3210 1729 'post_status' => 'publish',
3211 1730 'post_type' => $post_type,
3212 1731 'post_title' => $post_title,
3213 - 'post_name' => $post_slug,
3214 1732 'post_content' => $content,
3215 1733 )
3216 1734 );
3217 1735
@@ -3224,41 +1742,8 @@
3224 1742 );
3225 1743 wp_die();
3226 1744 }
3227 1745
3228 - if ( ! empty( $thumb_image ) ) {
3229 - // $featured_image_url = esc_url_raw( $thumb_image );
3230 - $tmp = download_url( $thumb_image );
3231 - if ( is_wp_error( $tmp ) ) {
3232 - error_log( 'Image download failed: ' . esc_html( $tmp->get_error_message() ) );
3233 - } else {
3234 - $file_array = array(
3235 - 'name' => wp_basename( $thumb_image ),
3236 - 'tmp_name' => $tmp,
3237 - );
3238 -
3239 - $image_id = media_handle_sideload( $file_array, $inserted_post );
3240 -
3241 - if ( is_wp_error( $image_id ) ) {
3242 - error_log( 'Image sideload failed: ' . esc_html( $image_id->get_error_message() ) );
3243 - } else {
3244 - set_post_thumbnail( $inserted_post, $image_id );
3245 - }
3246 -
3247 - @unlink( $tmp );
3248 - }
3249 - }
3250 -
3251 - if ( ! empty( $category_list ) && is_array( $category_list ) ) {
3252 - $category_ids = array_map( 'intval', $category_list );
3253 - wp_set_post_terms( $inserted_post, $category_ids, 'category' );
3254 - }
3255 -
3256 - if ( ! empty( $tag_list ) && is_array( $tag_list ) ) {
3257 - $tag_ids = array_map( 'intval', $tag_list );
3258 - wp_set_post_terms( $inserted_post, $tag_ids, 'post_tag' );
3259 - }
3260 -
3261 1746 if ( ! empty( $args['custom_meta'] ) && 'true' == $args['custom_meta'] ) {
3262 1747 $custom_meta = isset( $post_content->custom_meta ) ? json_decode( wp_json_encode( $post_content->custom_meta ), true ) : '';
3263 1748 if ( ! empty( $custom_meta ) ) {
3264 1749 foreach ( $custom_meta as $meta_key => $meta_val ) {
@@ -3272,42 +1757,13 @@
3272 1757 }
3273 1758 }
3274 1759 }
3275 1760
3276 - $temp_detail = array(
1761 + return array(
3277 1762 'title' => get_the_title( $inserted_post ),
3278 1763 'edit_link' => get_edit_post_link( $inserted_post, 'internal' ),
3279 1764 'view' => get_permalink( $inserted_post ),
3280 - 'id' => $inserted_post,
3281 1765 );
3282 -
3283 - if ( ! empty( $template_id->id ) ) {
3284 - $temp_id = $template_id->id;
3285 - } elseif ( ! empty( $template_id ) ) {
3286 - $temp_id = $template_id;
3287 - } else {
3288 - $temp_id = '';
3289 - }
3290 -
3291 - wp_update_post([
3292 - 'ID' => $inserted_post,
3293 - ]);
3294 -
3295 - if (class_exists('Tpgb_Library') && method_exists('Tpgb_Library', 'remove_backend_dir_files')) {
3296 - Tpgb_Library()->remove_backend_dir_files();
3297 - }
3298 -
3299 - clean_post_cache( $inserted_post );
3300 - wp_send_json(
3301 - array(
3302 - $temp_id => $temp_detail,
3303 - 'description' => 'Yay! Your Section has been Successfully Imported.',
3304 - 'message' => 'Successfully Imported.',
3305 - 'inserted_id' => $inserted_post,
3306 - 'success' => true,
3307 - )
3308 - );
3309 - wp_die();
3310 1766 }
3311 1767 } elseif ( 'elementor' === $args['editor'] || ( 'wdkit' === $args['editor'] && ! empty( $file_type ) && 'elementor' === $file_type ) ) {
3312 1768 if ( did_action( 'elementor/loaded' ) ) {
3313 1769 if ( empty( $content ) ) {
@@ -3318,16 +1774,12 @@
3318 1774 )
3319 1775 );
3320 1776 wp_die();
3321 1777 } elseif ( ! empty( $content ) && ! empty( $file_type ) && 'elementor' === $file_type ) {
3322 -
3323 - $content = $this->wdkit_content_remover( $content );
3324 -
3325 1778 $post_attributes = array(
3326 1779 'post_title' => $post_title,
3327 1780 'post_type' => $post_type,
3328 1781 'post_status' => 'publish',
3329 - 'post_name' => $post_slug,
3330 1782 );
3331 1783
3332 1784 if ( 'elementor_library' === $post_type ) {
3333 1785 $el_type = ( isset( $post_content->el_type ) && ! empty( $post_content->el_type ) ) ? sanitize_text_field( $post_content->el_type ) : 'page';
@@ -3351,43 +1803,8 @@
3351 1803 );
3352 1804 wp_die();
3353 1805 }
3354 1806
3355 - $inserted_id = $new_document->get_main_id();
3356 -
3357 - if ( ! empty( $thumb_image ) ) {
3358 - // $featured_image_url = esc_url_raw( $thumb_image );
3359 - $tmp = download_url( $thumb_image );
3360 - if ( is_wp_error( $tmp ) ) {
3361 - error_log( 'Image download failed: ' . esc_html( $tmp->get_error_message() ) );
3362 - } else {
3363 - $file_array = array(
3364 - 'name' => wp_basename( $thumb_image ),
3365 - 'tmp_name' => $tmp,
3366 - );
3367 -
3368 - $image_id = media_handle_sideload( $file_array, $inserted_id );
3369 -
3370 - if ( is_wp_error( $image_id ) ) {
3371 - error_log( 'Image sideload failed: ' . esc_html( $image_id->get_error_message() ) );
3372 - } else {
3373 - set_post_thumbnail( $inserted_id, $image_id );
3374 - }
3375 -
3376 - @unlink( $tmp );
3377 - }
3378 - }
3379 -
3380 - if ( ! empty( $category_list ) && is_array( $category_list ) ) {
3381 - $category_ids = array_map( 'intval', $category_list );
3382 - wp_set_post_terms( $inserted_id, $category_ids, 'category' );
3383 - }
3384 -
3385 - if ( ! empty( $tag_list ) && is_array( $tag_list ) ) {
3386 - $tag_ids = array_map( 'intval', $tag_list );
3387 - wp_set_post_terms( $inserted_id, $tag_ids, 'post_tag' );
3388 - }
3389 -
3390 1807 $settings = ( isset( $post_content->settings ) && ! empty( $post_content->settings ) ) ? json_decode( wp_json_encode( $post_content->settings ), true ) : array();
3391 1808
3392 1809 $content = wp_json_encode( $content );
3393 1810 $content = $this->wdkit_media_import( $content, $file_type );
@@ -3400,12 +1817,8 @@
3400 1817 );
3401 1818
3402 1819 $inserted_id = $new_document->get_main_id();
3403 1820
3404 - if( $temp_type == 'navigation' ){
3405 - $temp_con = $content;
3406 - }
3407 -
3408 1821 if ( ! empty( $args['custom_meta'] ) && 'true' == $args['custom_meta'] ) {
3409 1822 $custom_meta = isset( $post_content->custom_meta ) ? json_decode( wp_json_encode( $post_content->custom_meta ), true ) : '';
3410 1823 if ( ! empty( $custom_meta ) ) {
3411 1824 foreach ( $custom_meta as $meta_key => $meta_val ) {
@@ -3418,36 +1831,13 @@
3418 1831 }
3419 1832 }
3420 1833 }
3421 1834
3422 - $temp_detail = array(
1835 + return array(
3423 1836 'title' => get_the_title( $inserted_id ),
3424 1837 'edit_link' => get_edit_post_link( $inserted_id, 'internal' ),
3425 1838 'view' => get_permalink( $inserted_id ),
3426 - 'id' => $inserted_id,
3427 1839 );
3428 -
3429 - if ( ! empty( $template_id->id ) ) {
3430 - $temp_id = $template_id->id;
3431 - } elseif ( ! empty( $template_id ) ) {
3432 - $temp_id = $template_id;
3433 - } else {
3434 - $temp_id = '';
3435 - }
3436 -
3437 - \Elementor\Plugin::$instance->files_manager->clear_cache();
3438 -
3439 - wp_send_json(
3440 - array(
3441 - $temp_id => $temp_detail,
3442 - 'content' => $temp_con,
3443 - 'description' => 'Yay! Your Section has been Successfully Imported.',
3444 - 'message' => 'Successfully Imported.',
3445 - 'inserted_id' => $inserted_id,
3446 - 'success' => true,
3447 - )
3448 - );
3449 - wp_die();
3450 1840 }
3451 1841 } else {
3452 1842 wp_send_json(
3453 1843 array(
@@ -3458,528 +1848,11 @@
3458 1848 wp_die();
3459 1849 }
3460 1850 }
3461 1851 }
3462 -
3463 - wp_send_json(
3464 - array(
3465 - 'success' => false,
3466 - 'message' => esc_html__( 'Something went wrong', 'wdesignkit' ),
3467 - )
3468 - );
3469 - wp_die();
3470 1852 }
3471 1853
3472 1854 /**
3473 - * Replace unicode glitch
3474 - *
3475 - * @since 2.0.0
3476 - */
3477 - private function replace_unicode_glitch( $content ) {
3478 -
3479 - // Fix escaped unicode like \u003c → <
3480 - $content = preg_replace_callback(
3481 - '/\\\\u([0-9a-fA-F]{4})/',
3482 - function ( $match ) {
3483 - return html_entity_decode(
3484 - mb_convert_encoding(
3485 - pack('H*', $match[1]),
3486 - 'UTF-8',
3487 - 'UCS-2BE'
3488 - ),
3489 - ENT_QUOTES,
3490 - 'UTF-8'
3491 - );
3492 - },
3493 - $content
3494 - );
3495 -
3496 - return $content;
3497 - }
3498 -
3499 -
3500 - /**
3501 - * change plugins setting for import kit
3502 - *
3503 - * @since 2.0.0
3504 - */
3505 - protected function update_plugin_setting() {
3506 - $temp_id = isset( $_POST['plugin_type'] ) ? sanitize_text_field( $_POST['plugin_type'] ) : '';
3507 -
3508 - if ( $temp_id == 'elementor' ) {
3509 - $unfiltered_files = get_option( 'elementor_unfiltered_files_upload', false );
3510 - $load_fa4 = get_option( 'elementor_load_fa4_shim', false );
3511 - $Inline_font_icons = get_option( 'elementor_experiment-e_font_icon_svg', false );
3512 - $container = get_option( 'elementor_experiment-container', false );
3513 -
3514 - if ( isset( $unfiltered_files ) ) {
3515 - update_option( 'elementor_unfiltered_files_upload', 1 );
3516 - } else {
3517 - add_option( 'elementor_unfiltered_files_upload', 1 );
3518 - }
3519 -
3520 - if ( isset( $load_fa4 ) ) {
3521 - update_option( 'elementor_load_fa4_shim', 'yes' );
3522 - } else {
3523 - add_option( 'elementor_load_fa4_shim', 'yes' );
3524 - }
3525 -
3526 - if ( isset( $container ) ) {
3527 - update_option( 'elementor_experiment-container', 'active' );
3528 - } else {
3529 - add_option( 'elementor_experiment-container', 'active' );
3530 - }
3531 -
3532 - if ( isset( $Inline_font_icons ) ) {
3533 - update_option( 'elementor_experiment-e_font_icon_svg', 'inactive' );
3534 - } else {
3535 - add_option( 'elementor_experiment-e_font_icon_svg', 'inactive' );
3536 - }
3537 -
3538 - $response = array(
3539 - 'message' => esc_html__( 'Plugin Setting updated', 'wdesignkit' ),
3540 - 'description' => esc_html__( 'Plugin Setting updated', 'wdesignkit' ),
3541 - 'success' => true,
3542 - );
3543 - } else {
3544 - $response = array(
3545 - 'message' => esc_html__( 'Plugin not found', 'wdesignkit' ),
3546 - 'description' => esc_html__( 'Plugin not found', 'wdesignkit' ),
3547 - 'success' => false,
3548 - );
3549 - }
3550 -
3551 - wp_send_json( $response );
3552 - wp_die();
3553 - }
3554 -
3555 - /**
3556 - * generate different color logo
3557 - *
3558 - * @since 2.0.0
3559 - */
3560 - protected function wkit_generate_site_logo() {
3561 -
3562 - if ( empty( $_POST['image_url'] ) ) {
3563 - wp_send_json_error( 'Image URL not provided.' );
3564 - }
3565 -
3566 - if ( isset( $_POST['colors'] ) ) {
3567 - $img_colors = ! empty( $_POST['colors'] ) ? json_decode( sanitize_text_field( wp_unslash( $_POST['colors'] ) ), true ) : array();
3568 - }
3569 -
3570 - if ( empty( $img_colors ) ) {
3571 - wp_send_json_error( 'Image color not provided.' );
3572 - }
3573 -
3574 - $image_url = esc_url_raw( $_POST['image_url'] );
3575 -
3576 - $tmp_file = download_url( $image_url );
3577 - if ( is_wp_error( $tmp_file ) ) {
3578 - wp_send_json_error( 'Image could not be downloaded.' );
3579 - }
3580 -
3581 - if ( mime_content_type( $tmp_file ) !== 'image/png' ) {
3582 - unlink( $tmp_file );
3583 - wp_send_json_error( 'Not a PNG file.' );
3584 - }
3585 -
3586 - $src = imagecreatefrompng( $tmp_file );
3587 - imagesavealpha( $src, true );
3588 -
3589 - $width = imagesx( $src );
3590 - $height = imagesy( $src );
3591 -
3592 - $hasTransparency = false;
3593 - for ( $x = 0; $x < $width; $x++ ) {
3594 - for ( $y = 0; $y < $height; $y++ ) {
3595 - $rgba = imagecolorat( $src, $x, $y );
3596 - $alpha = ( $rgba & 0x7F000000 ) >> 24;
3597 -
3598 - if ( $alpha > 0 ) {
3599 - $hasTransparency = true;
3600 - break 2;
3601 - }
3602 - }
3603 - }
3604 -
3605 - if ( ! $hasTransparency ) {
3606 - unlink( $tmp_file );
3607 - wp_send_json_error( 'PNG has no transparent pixels.' );
3608 - }
3609 -
3610 - $upload_dir = wp_upload_dir();
3611 - $result_urls = array();
3612 -
3613 - foreach ( $img_colors as $name => $rgb ) {
3614 - $new = imagecreatetruecolor( $width, $height );
3615 - imagesavealpha( $new, true );
3616 - imagealphablending( $new, false );
3617 -
3618 - $transparent = imagecolorallocatealpha( $new, 0, 0, 0, 127 );
3619 - imagefill( $new, 0, 0, $transparent );
3620 -
3621 - for ( $x = 0; $x < $width; $x++ ) {
3622 - for ( $y = 0; $y < $height; $y++ ) {
3623 - $rgba = imagecolorat( $src, $x, $y );
3624 - $alpha = ( $rgba & 0x7F000000 ) >> 24;
3625 -
3626 - // Skip fully transparent pixels
3627 - if ( $alpha === 127 ) {
3628 - continue;
3629 - }
3630 -
3631 - // Replace pixel color directly
3632 - $new_r = $rgb[0];
3633 - $new_g = $rgb[1];
3634 - $new_b = $rgb[2];
3635 -
3636 - $color = imagecolorallocatealpha( $new, $new_r, $new_g, $new_b, $alpha );
3637 - imagesetpixel( $new, $x, $y, $color );
3638 - }
3639 - }
3640 -
3641 - $filename = 'colored-' . $name . '-' . time() . '.png';
3642 - $filepath = $upload_dir['path'] . '/' . $filename;
3643 -
3644 - imagepng( $new, $filepath );
3645 - imagedestroy( $new );
3646 -
3647 - $attachment = array(
3648 - 'post_mime_type' => 'image/png',
3649 - 'post_title' => sanitize_file_name( $filename ),
3650 - 'post_content' => '',
3651 - 'post_status' => 'inherit',
3652 - );
3653 -
3654 - $attach_id = wp_insert_attachment( $attachment, $filepath );
3655 - require_once ABSPATH . 'wp-admin/includes/image.php';
3656 - $attach_data = wp_generate_attachment_metadata( $attach_id, $filepath );
3657 - wp_update_attachment_metadata( $attach_id, $attach_data );
3658 -
3659 - $result_urls[ $name ] = wp_get_attachment_url( $attach_id );
3660 - }
3661 -
3662 - imagedestroy( $src );
3663 - unlink( $tmp_file );
3664 -
3665 - wp_send_json_success( $result_urls );
3666 - }
3667 -
3668 - /**
3669 - * change theme setting for import kit
3670 - *
3671 - * @since 2.0.0
3672 - */
3673 - protected function update_theme_setting() {
3674 - $theme_db = get_option( 'nxt-theme-options', false );
3675 -
3676 - $container_type = 'container-fluid';
3677 - $fluid_spacing = array(
3678 - 'md' => array(
3679 - 'left' => '0',
3680 - 'right' => '0',
3681 - ),
3682 - 'sm' => array(
3683 - 'left' => '',
3684 - 'right' => '',
3685 - ),
3686 - 'xs' => array(
3687 - 'left' => '',
3688 - 'right' => '',
3689 - ),
3690 - 'md-unit' => 'px',
3691 - 'sm-unit' => 'px',
3692 - 'xs-unit' => 'px',
3693 - );
3694 -
3695 - if ( isset( $theme_db ) ) {
3696 - $nexter_setting = $theme_db;
3697 - $nexter_setting['site-header-container'] = $container_type;
3698 - $nexter_setting['site-footer-container'] = $container_type;
3699 - $nexter_setting['site-layout-container'] = $container_type;
3700 - $nexter_setting['site-page-container'] = $container_type;
3701 -
3702 - $nexter_setting['header-fluid-spacing'] = $fluid_spacing;
3703 - $nexter_setting['footer-fluid-spacing'] = $fluid_spacing;
3704 - $nexter_setting['site-fluid-spacing'] = $fluid_spacing;
3705 - $nexter_setting['page-fluid-spacing'] = $fluid_spacing;
3706 -
3707 - update_option( 'nxt-theme-options', $nexter_setting );
3708 - } else {
3709 - $nexter_setting = array(
3710 - 'site-header-container' => 'container-fluid',
3711 - 'header-fluid-spacing' => array(
3712 - 'md' => array(
3713 - 'left' => '0',
3714 - 'right' => '0',
3715 - ),
3716 - 'sm' => array(
3717 - 'left' => '',
3718 - 'right' => '',
3719 - ),
3720 - 'xs' => array(
3721 - 'left' => '',
3722 - 'right' => '',
3723 - ),
3724 - 'md-unit' => 'px',
3725 - 'sm-unit' => 'px',
3726 - 'xs-unit' => 'px',
3727 - ),
3728 - 'site-footer-container' => 'container-fluid',
3729 - 'footer-fluid-spacing' => array(
3730 - 'md' => array(
3731 - 'left' => '0',
3732 - 'right' => '0',
3733 - ),
3734 - 'sm' => array(
3735 - 'left' => '',
3736 - 'right' => '',
3737 - ),
3738 - 'xs' => array(
3739 - 'left' => '',
3740 - 'right' => '',
3741 - ),
3742 - 'md-unit' => 'px',
3743 - 'sm-unit' => 'px',
3744 - 'xs-unit' => 'px',
3745 - ),
3746 - 'site-layout-container' => 'container-fluid',
3747 - 'site-fluid-spacing' => array(
3748 - 'md' => array(
3749 - 'left' => '0',
3750 - 'right' => '0',
3751 - ),
3752 - 'sm' => array(
3753 - 'left' => '',
3754 - 'right' => '',
3755 - ),
3756 - 'xs' => array(
3757 - 'left' => '',
3758 - 'right' => '',
3759 - ),
3760 - 'md-unit' => 'px',
3761 - 'sm-unit' => 'px',
3762 - 'xs-unit' => 'px',
3763 - ),
3764 - 'site-page-container' => 'container-fluid',
3765 - 'page-fluid-spacing' => array(
3766 - 'md' => array(
3767 - 'left' => '0',
3768 - 'right' => '0',
3769 - ),
3770 - 'sm' => array(
3771 - 'left' => '',
3772 - 'right' => '',
3773 - ),
3774 - 'xs' => array(
3775 - 'left' => '',
3776 - 'right' => '',
3777 - ),
3778 - 'md-unit' => 'px',
3779 - 'sm-unit' => 'px',
3780 - 'xs-unit' => 'px',
3781 - ),
3782 - 'site-page-container' => '',
3783 - 'site-posts-container' => '',
3784 - 'site-archive-container' => '',
3785 - );
3786 -
3787 - add_option( 'nxt-theme-options', $nexter_setting );
3788 - }
3789 -
3790 - $response = array(
3791 - 'message' => esc_html__( 'Theme Setting updated', 'wdesignkit' ),
3792 - 'description' => esc_html__( 'Theme Setting updated', 'wdesignkit' ),
3793 - 'success' => true,
3794 - );
3795 -
3796 - wp_send_json( $response );
3797 - wp_die();
3798 - }
3799 -
3800 - /**
3801 - * change site setting for import kit
3802 - *
3803 - * @since 2.0.0
3804 - */
3805 - protected function update_site_setting() {
3806 - $temp_id = isset( $_POST['id'] ) ? sanitize_text_field( wp_unslash( $_POST['id'] ) ) : '';
3807 - $shop_id = isset( $_POST['shop_id'] ) ? sanitize_text_field( wp_unslash( $_POST['shop_id'] ) ) : '';
3808 - $temp_type = isset( $_POST['temp_type'] ) ? sanitize_text_field( wp_unslash( $_POST['temp_type'] ) ) : 'page';
3809 - $site_name = isset( $_POST['site_name'] ) ? sanitize_text_field( wp_unslash( $_POST['site_name'] ) ) : '';
3810 - $site_tagline = isset( $_POST['site_tagline'] ) ? sanitize_text_field( wp_unslash( $_POST['site_tagline'] ) ) : '';
3811 -
3812 - $this->wdkit_nxt_thembuilder_update();
3813 -
3814 - if ( ! empty( $shop_id ) ) {
3815 - update_option( 'woocommerce_shop_page_id', $shop_id );
3816 - }
3817 -
3818 - if ( $temp_id ) {
3819 - update_option( 'show_on_front', $temp_type );
3820 - update_option( 'page_on_front', $temp_id );
3821 -
3822 - if ( ! empty( $site_name ) ) {
3823 - update_option( 'blogname', $site_name );
3824 - }
3825 -
3826 - if ( ! empty( $site_tagline ) ) {
3827 - update_option( 'blogdescription', $site_tagline );
3828 - }
3829 -
3830 - $response = array(
3831 - 'message' => esc_html__( 'Site link updated', 'wdesignkit' ),
3832 - 'description' => esc_html__( 'Site link updated', 'wdesignkit' ),
3833 - 'site_link' => get_site_url(),
3834 - 'success' => true,
3835 - );
3836 - } else {
3837 - $response = array(
3838 - 'message' => esc_html__( 'Site not found', 'wdesignkit' ),
3839 - 'description' => esc_html__( 'Site not found', 'wdesignkit' ),
3840 - 'success' => false,
3841 - );
3842 - }
3843 -
3844 - wp_send_json( $response );
3845 - wp_die();
3846 - }
3847 -
3848 - /**
3849 - * update theme builder
3850 - *
3851 - * @since 2.0.4
3852 - */
3853 - public function wdkit_nxt_thembuilder_update() {
3854 -
3855 - $page_information = isset( $_POST['page_information'] ) ? sanitize_text_field( wp_unslash( $_POST['page_information'] ) ) : '';
3856 - $page_information = json_decode( $page_information, true );
3857 -
3858 - if ( ! empty( $page_information ) && is_array( $page_information ) ) {
3859 - // Step 1: banavo mapping [ old_id => new_id ]
3860 - $id_mapping = array();
3861 - foreach ( $page_information as $page_info ) {
3862 - if ( ! empty( $page_info['old_page_id'] ) ) {
3863 - $id_mapping[ $page_info['old_page_id'] ] = $page_info['inserted_id'];
3864 - }
3865 - }
3866 -
3867 - // Step 2: loop karo and update exclude
3868 - foreach ( $page_information as $page_info ) {
3869 -
3870 - $post_id = $page_info['inserted_id'] ?? '';
3871 - $old_post_id = $page_info['old_page_id'] ?? '';
3872 - $post_type = $page_info['post_type'] ?? '';
3873 -
3874 - if ( empty( $old_post_id ) ) {
3875 - continue; // only update where old id exists
3876 - }
3877 -
3878 - if ( $post_type != 'nxt_builder' ) {
3879 - continue;
3880 - }
3881 -
3882 - $include_specific = get_post_meta( $post_id, 'nxt-hooks-layout-specific', true );
3883 - if ( ! empty( $include_specific ) && is_array( $include_specific ) ) {
3884 -
3885 - foreach ( $include_specific as $key => $val ) {
3886 -
3887 - // check karo ke koi old_id ka post match kare che ke nahi
3888 - foreach ( $id_mapping as $old_id => $new_id ) {
3889 - $search = 'post-' . $old_id;
3890 - $replace = 'post-' . $new_id;
3891 -
3892 - if ( $val === $search ) {
3893 - $include_specific[ $key ] = $replace;
3894 - }
3895 - }
3896 - }
3897 -
3898 - // save back updated array
3899 - update_post_meta( $post_id, 'nxt-hooks-layout-specific', $include_specific );
3900 - }
3901 -
3902 - // Get exclude meta
3903 - $exclude_specific = get_post_meta( $post_id, 'nxt-hooks-layout-exclude-specific', true );
3904 - if ( ! empty( $exclude_specific ) && is_array( $exclude_specific ) ) {
3905 -
3906 - foreach ( $exclude_specific as $key => $val ) {
3907 -
3908 - // check karo ke koi old_id ka post match kare che ke nahi
3909 - foreach ( $id_mapping as $old_id => $new_id ) {
3910 - $search = 'post-' . $old_id;
3911 - $replace = 'post-' . $new_id;
3912 -
3913 - if ( $val === $search ) {
3914 - $exclude_specific[ $key ] = $replace;
3915 - }
3916 - }
3917 - }
3918 -
3919 - // save back updated array
3920 - update_post_meta( $post_id, 'nxt-hooks-layout-exclude-specific', $exclude_specific );
3921 - }
3922 - }
3923 - }
3924 - }
3925 -
3926 - /**
3927 - *
3928 - * select team image for import kit
3929 - *
3930 - * @since 2.2.2
3931 - */
3932 - public function wdkit_check_user_credit() {
3933 - $array_data = array(
3934 - 'token' => isset( $_POST['token'] ) ? sanitize_text_field( $_POST['token'] ) : '',
3935 - );
3936 -
3937 - $response = $this->wkit_api_call( $array_data, 'ai/credits/get' );
3938 - $success = ! empty( $response['success'] ) ? $response['success'] : false;
3939 -
3940 - if ( empty( $success ) ) {
3941 - $response = array(
3942 - 'success' => false,
3943 - 'message' => esc_html__( 'Data Not Found', 'wdesignkit' ),
3944 - 'description' => esc_html__( 'Data not found', 'wdesignkit' ),
3945 - );
3946 -
3947 - wp_send_json( $response );
3948 - wp_die();
3949 - }
3950 -
3951 - $response = json_decode( wp_json_encode( $response['data'] ), true );
3952 -
3953 - wp_send_json( $response );
3954 - wp_die();
3955 - }
3956 -
3957 - public function wdkit_nxt_thembuilder_reset() {
3958 - $post_id = isset( $_POST['post_id'] ) ? sanitize_text_field( $_POST['post_id'] ) : '';
3959 - $sections_layout = get_post_meta( $post_id, 'nxt-hooks-layout-sections', true );
3960 -
3961 - if ( ( ! empty( $sections_layout ) && ( $sections_layout == 'header' || $sections_layout == 'footer' || $sections_layout == 'breadcrumb' || $sections_layout == 'hooks' ) ) ) {
3962 - if ( get_post_meta( $post_id, 'nxt-add-display-rule' ) ) {
3963 - delete_post_meta( $post_id, 'nxt-add-display-rule' );
3964 - }
3965 -
3966 - if ( get_post_meta( $post_id, 'nxt-hooks-layout-specific' ) ) {
3967 - update_post_meta( $post_id, 'nxt-hooks-layout-specific', '' );
3968 - }
3969 -
3970 - if ( get_post_meta( $post_id, 'nxt-exclude-display-rule' ) ) {
3971 - update_post_meta( $post_id, 'nxt-exclude-display-rule', '' );
3972 - }
3973 -
3974 - if ( get_post_meta( $post_id, 'nxt-hooks-layout-exclude-specific' ) ) {
3975 - update_post_meta( $post_id, 'nxt-hooks-layout-exclude-specific', '' );
3976 - }
3977 - }
3978 - }
3979 -
3980 -
3981 - /**
3982 1855 * Share with Me Template and widgets
3983 1856 *
3984 1857 * @since 1.0.0
3985 1858 */
@@ -4123,12 +1996,8 @@
4123 1996 if ( Wdkit_Wdesignkit::wdkit_is_compatible( 'gutenberg', 'widget' ) ) {
4124 1997 array_push( $builder, 'gutenberg' );
4125 1998 }
4126 1999
4127 - if ( Wdkit_Wdesignkit::wdkit_is_compatible( 'gutenberg_core', 'widget' ) ) {
4128 - array_push( $builder, 'gutenberg_core' );
4129 - }
4130 -
4131 2000 foreach ( $builder as $key => $name ) {
4132 2001 $elementor_dir = WDKIT_BUILDER_PATH . '/' . $name;
4133 2002
4134 2003 if ( ! empty( $elementor_dir ) && is_dir( $elementor_dir ) ) {
@@ -4136,10 +2005,10 @@
4136 2005 $elementor_list = array_diff( $elementor_list, array( '.', '..' ) );
4137 2006
4138 2007 if ( ! empty( $elementor_list ) ) {
4139 2008 foreach ( $elementor_list as $key => $value ) {
4140 - $a_c_s_d_s_c[ filemtime( "{$elementor_dir}/{$value}" ) . $key ]['data'] = $value;
4141 - $a_c_s_d_s_c[ filemtime( "{$elementor_dir}/{$value}" ) . $key ]['builder'] = $name;
2009 + $a_c_s_d_s_c[ filemtime( "{$elementor_dir}/{$value}" ) ]['data'] = $value;
2010 + $a_c_s_d_s_c[ filemtime( "{$elementor_dir}/{$value}" ) ]['builder'] = $name;
4142 2011 }
4143 2012 }
4144 2013 }
4145 2014 }
@@ -4206,108 +2075,521 @@
4206 2075 wp_send_json( get_option( 'wkit_builder' ) );
4207 2076 }
4208 2077
4209 2078 /**
4210 - * Get Workspace data
4211 2079 *
4212 - * @since 2.2.5
2080 + * Custom_upload_dir
2081 + *
2082 + * @since 1.0.0
2083 + *
2084 + * @param array $upload store data.
4213 2085 */
4214 - public function wdkit_get_workspace_data() {
2086 + public function custom_upload_dir( $upload ) {
2087 + // Specify the path to your custom upload directory.
2088 + if ( isset( $this->widget_folder_u_r_l ) && ! empty( $this->widget_folder_u_r_l ) ) {
4215 2089
4216 - $wid = isset( $_POST['wid'] ) ? sanitize_text_field( $_POST['wid'] ) : '';
4217 - $token = isset( $_POST['token'] ) ? sanitize_text_field( $_POST['token'] ) : '';
2090 + // Set the custom directory as the upload path.
2091 + $upload['path'] = $this->widget_folder_u_r_l;
2092 + // Set the URL for the uploaded file.
2093 + $upload['url'] = $upload['baseurl'] . $upload['subdir'];
2094 + }
4218 2095
4219 - if ( empty( $wid ) ) {
4220 - return array(
2096 + return $upload;
2097 + }
2098 +
2099 + /**
2100 + *
2101 + * It is Use for create widget for local
2102 + *
2103 + * @since 1.0.0
2104 + */
2105 + protected function wdkit_create_widget() {
2106 + $image = '';
2107 + if ( isset( $_FILES ) && ! empty( $_FILES ) && isset( $_FILES['image'] ) && ! empty( $_FILES['image'] ) ) {
2108 + $image = Wdkit_Data_Hooks::get_super_global_value( $_FILES, 'image' );
2109 + }
2110 +
2111 + $icon = '';
2112 + if ( isset( $_FILES ) && ! empty( $_FILES ) && isset( $_FILES['icon'] ) && ! empty( $_FILES['icon'] ) ) {
2113 + $icon = Wdkit_Data_Hooks::get_super_global_value( $_FILES, 'icon' );
2114 + }
2115 +
2116 + $data = ! empty( $_POST['value'] ) ? $this->wdkit_sanitizer_bypass( $_POST, 'value', 'cr_widget' ) : '';
2117 + $data = ! empty( $data ) ? stripslashes( $data ) : '';
2118 + $return = ! empty( $data ) ? json_decode( $data ) : '';
2119 +
2120 + $all_val = ! empty( $return ) ? $return : '';
2121 + if ( empty( $all_val ) ) {
2122 +
2123 + $responce = array(
2124 + 'message' => esc_html__( 'Data Not Found', 'wdesignkit' ),
2125 + 'description' => esc_html__( 'something went wrong! please try again later.', 'wdesignkit' ),
4221 2126 'success' => false,
4222 - 'message' => esc_html__( 'Workspace ID Not Found', 'wdesignkit' ),
4223 - 'description' => esc_html__( 'Workspace ID is required', 'wdesignkit' ),
4224 2127 );
2128 +
2129 + wp_send_json( $responce );
2130 + wp_die();
4225 2131 }
4226 2132
4227 - if ( empty( $token ) ) {
4228 - return array(
2133 + $file_name = ! empty( $all_val->file_name ) ? sanitize_text_field( $all_val->file_name ) : '';
2134 + $folder_name = ! empty( $all_val->folder_name ) ? sanitize_text_field( $all_val->folder_name ) : '';
2135 + $old_widget = ! empty( $all_val->old_folder ) ? sanitize_text_field( $all_val->old_folder ) : '';
2136 + $description = ! empty( $all_val->description ) ? sanitize_text_field( $all_val->description ) : '';
2137 + $json_file = ! empty( $all_val->json_file ) ? $all_val->json_file : '';
2138 + $function_call = ! empty( $all_val->call ) ? sanitize_text_field( $all_val->call ) : '';
2139 + $plugin = ! empty( $all_val->plugin ) ? $all_val->plugin : '';
2140 + $d_image = ! empty( $all_val->d_image ) ? $all_val->d_image : '';
2141 + $data = json_decode( $json_file );
2142 +
2143 + $elementor_php_file = ! empty( $all_val->elementor_php_file ) ? $all_val->elementor_php_file : '';
2144 + $elementor_js = ! empty( $all_val->elementor_js ) ? $all_val->elementor_js : '';
2145 + $elementor_css = ! empty( $all_val->elementor_css ) ? $all_val->elementor_css : '';
2146 +
2147 + $gutenberg_php_file = ! empty( $all_val->gutenberg_php_file ) ? $all_val->gutenberg_php_file : '';
2148 + $gutenberg_js = ! empty( $all_val->gutenberg_js ) ? $all_val->gutenberg_js : '';
2149 + $gutenberg_css = ! empty( $all_val->gutenberg_css ) ? $all_val->gutenberg_css : '';
2150 + $external_js_file = ! empty( $all_val->external_js_file ) ? $all_val->external_js_file : '';
2151 + $style_file = ! empty( $all_val->style_file ) ? $all_val->style_file : '';
2152 +
2153 + $bricks_php_file = ! empty( $all_val->bricks_php_file ) ? $all_val->bricks_php_file : '';
2154 + $bricks_js = ! empty( $all_val->bricks_js ) ? $all_val->bricks_js : '';
2155 + $bricks_css = ! empty( $all_val->bricks_css ) ? $all_val->bricks_css : '';
2156 +
2157 + $old_folder = ! empty( $old_widget ) ? str_replace( ' ', '-', $old_widget ) : '';
2158 + $widget_type = ! empty( $data->widget_data->widgetdata->type ) ? sanitize_text_field( $data->widget_data->widgetdata->type ) : '';
2159 +
2160 + if ( empty( $widget_type ) ) {
2161 + $responce = array(
2162 + 'message' => esc_html__( 'Builder Type not found', 'wdesignkit' ),
2163 + 'description' => esc_html__( 'something went wrong! please try again later.', 'wdesignkit' ),
4229 2164 'success' => false,
4230 - 'message' => esc_html__( 'Token Not Found', 'wdesignkit' ),
4231 - 'description' => esc_html__( 'Token is required', 'wdesignkit' ),
4232 2165 );
2166 +
2167 + wp_send_json( $responce );
2168 + wp_die();
4233 2169 }
4234 2170
4235 - $args = array(
4236 - 'token' => $token,
4237 - 'wid' => $wid,
4238 - );
2171 + $builder_type_path = trailingslashit( WDKIT_BUILDER_PATH ) . trailingslashit( $widget_type );
2172 + $widget_file_url = $builder_type_path . $folder_name;
4239 2173
4240 - $this->wdkit_api = $this->wdkit_api_v2;
2174 + if ( ! is_dir( $widget_file_url ) ) {
2175 + wp_mkdir_p( $widget_file_url );
2176 + }
4241 2177
4242 - $url = "workspace/{$wid}/get";
2178 + include_once ABSPATH . 'wp-admin/includes/file.php';
2179 + \WP_Filesystem();
2180 + global $wp_filesystem;
2181 + $widget_folder_u_r_l = trailingslashit( $widget_file_url ) . $file_name;
2182 + $this->widget_folder_u_r_l = $widget_file_url;
4243 2183
4244 - $response = $this->wkit_api_call( $args, $url );
2184 + if ( 'elementor' === $plugin ) {
2185 + $widget_file_list = scandir( $widget_file_url );
2186 + $widget_file_list = array_diff( $widget_file_list, array( '.', '..' ) );
4245 2187
4246 - wp_send_json( $response['data'] );
2188 + foreach ( $widget_file_list as $sub_dir_value ) {
2189 + $file = new SplFileInfo( $sub_dir_value );
2190 + $check_ext = $file->getExtension();
2191 + $extiona = pathinfo( $sub_dir_value, PATHINFO_EXTENSION );
2192 +
2193 + if ( 'js' === $extiona || 'css' === $extiona || 'json' === $extiona || 'php' === $extiona ) {
2194 + $wp_filesystem->rmdir( "$widget_file_url/$sub_dir_value", true );
2195 + }
2196 + }
2197 +
2198 + if ( ! empty( $elementor_php_file ) ) {
2199 + $wp_filesystem->put_contents( "$widget_folder_u_r_l.php", $elementor_php_file );
2200 + }
2201 + if ( ! empty( $json_file ) ) {
2202 + $wp_filesystem->put_contents( "$widget_folder_u_r_l.json", $json_file );
2203 + }
2204 + if ( ! empty( $elementor_css ) ) {
2205 + $wp_filesystem->put_contents( "$widget_folder_u_r_l.css", $elementor_css );
2206 + }
2207 + if ( ! empty( $elementor_js ) ) {
2208 + $wp_filesystem->put_contents( "$widget_folder_u_r_l.js", $elementor_js );
2209 + }
2210 + } elseif ( 'bricks' === $plugin ) {
2211 +
2212 + $widget_file_list = scandir( $widget_file_url );
2213 + $widget_file_list = array_diff( $widget_file_list, array( '.', '..' ) );
2214 +
2215 + foreach ( $widget_file_list as $sub_dir_value ) {
2216 + $file = new SplFileInfo( $sub_dir_value );
2217 + $check_ext = $file->getExtension();
2218 + $extiona = pathinfo( $sub_dir_value, PATHINFO_EXTENSION );
2219 +
2220 + if ( 'js' === $extiona || 'css' === $extiona || 'json' === $extiona || 'php' === $extiona ) {
2221 + $wp_filesystem->rmdir( "$widget_file_url/$sub_dir_value", true );
2222 + }
2223 + }
2224 +
2225 + $wp_filesystem->put_contents( "$widget_folder_u_r_l.php", $bricks_php_file );
2226 + $wp_filesystem->put_contents( "$widget_folder_u_r_l.json", $json_file );
2227 +
2228 + if ( ! empty( $bricks_css ) ) {
2229 + $wp_filesystem->put_contents( "$widget_folder_u_r_l.css", $bricks_css );
2230 + }
2231 +
2232 + if ( ! empty( $bricks_js ) ) {
2233 + $wp_filesystem->put_contents( "$widget_folder_u_r_l.js", $bricks_js );
2234 + }
2235 + } elseif ( 'gutenberg' === $plugin ) {
2236 +
2237 + $widget_file_list = scandir( $widget_file_url );
2238 + $widget_file_list = array_diff( $widget_file_list, array( '.', '..' ) );
2239 +
2240 + foreach ( $widget_file_list as $sub_dir_value ) {
2241 + $file = new SplFileInfo( $sub_dir_value );
2242 + $check_ext = $file->getExtension();
2243 + $extiona = pathinfo( $sub_dir_value, PATHINFO_EXTENSION );
2244 +
2245 + if ( 'js' === $extiona || 'css' === $extiona || 'json' === $extiona || 'php' === $extiona ) {
2246 + $wp_filesystem->rmdir( "$widget_file_url/$sub_dir_value", true );
2247 + }
2248 + }
2249 +
2250 + if ( ! empty( $external_js_file ) ) {
2251 + $wp_filesystem->put_contents( "$widget_file_url/index.js", $external_js_file );
2252 + }
2253 + $wp_filesystem->put_contents( "$widget_folder_u_r_l.php", $gutenberg_php_file );
2254 + $wp_filesystem->put_contents( "$widget_folder_u_r_l.json", $json_file );
2255 + if ( ! empty( $gutenberg_css ) ) {
2256 + $wp_filesystem->put_contents( "$widget_folder_u_r_l.css", $gutenberg_css );
2257 + }
2258 + $wp_filesystem->put_contents( "$widget_folder_u_r_l.js", $gutenberg_js );
2259 + }
2260 +
2261 + if ( ! empty( $image ) && ! empty( $image['tmp_name'] ) ) {
2262 +
2263 + $img_type = array( 'jpg', 'png' );
2264 +
2265 + foreach ( $img_type as $imgext ) {
2266 + $wp_filesystem->rmdir( "$widget_folder_u_r_l . $imgext", true );
2267 + }
2268 +
2269 + $ext = $image['type'];
2270 + $img_ext = '';
2271 + if ( strpos( $ext, 'jpeg' ) ) {
2272 + $img_ext = 'jpg';
2273 + } elseif ( strpos( $ext, 'png' ) ) {
2274 + $img_ext = 'png';
2275 + }
2276 + if ( ! empty( $img_ext ) ) {
2277 + add_filter( 'upload_dir', array( $this, 'custom_upload_dir' ) );
2278 +
2279 + $uploaded_file = wp_handle_upload( $image, array( 'test_form' => false ) );
2280 +
2281 + rename( $uploaded_file['file'], $widget_folder_u_r_l . '.' . $img_ext );
2282 +
2283 + remove_filter( 'upload_dir', array( $this, 'custom_upload_dir' ) );
2284 +
2285 + }
2286 + } elseif ( ! empty( $old_widget ) ) {
2287 + $img_url = $data->widget_data->widgetdata->w_image;
2288 + $img_ext = ! empty( pathinfo( $img_url )['extension'] ) ? pathinfo( $img_url )['extension'] : '';
2289 +
2290 + if ( ! empty( $img_ext ) ) {
2291 + $old_widget_folder = str_replace( ' ', '-', $old_widget );
2292 + $old_widget_file = str_replace( ' ', '_', $old_widget );
2293 + $img_path = "$builder_type_path$old_widget_folder/$old_widget_file.$img_ext";
2294 + $img_path = str_replace( '\\', '/', $img_path );
2295 +
2296 + if ( file_exists( $img_path ) ) {
2297 + $get_img = $img_path;
2298 + $put_img = "$widget_folder_u_r_l.$img_ext";
2299 +
2300 + if ( ! empty( $get_img ) && ! empty( $put_img ) ) {
2301 + rename( $get_img, $put_img );
2302 + }
2303 + }
2304 + }
2305 + }
2306 +
2307 + if ( ! empty( $d_image ) ) {
2308 + $d_image = str_replace( '\\', '', $d_image );
2309 + $d_img_url = $d_image;
2310 + $img_body = wp_remote_get( $d_img_url );
2311 + $img_ext = pathinfo( $d_img_url )['extension'];
2312 + $wp_filesystem->put_contents( WDKIT_BUILDER_PATH . "/$widget_type/$folder_name/$file_name.$img_ext", $img_body['body'] );
2313 + }
2314 +
2315 + if ( ! empty( $function_call ) && 'import' !== $function_call && ! empty( $old_folder ) && strtolower( $old_folder ) !== strtolower( $folder_name ) && is_dir( $builder_type_path . $old_folder ) ) {
2316 + require_once ABSPATH . 'wp-admin/includes/file.php';
2317 + global $wp_filesystem;
2318 + WP_Filesystem();
2319 + $wp_filesystem->rmdir( $builder_type_path . $old_folder, true );
2320 + } elseif ( $old_folder !== $folder_name ) {
2321 + rename( WDKIT_BUILDER_PATH . "/$widget_type/$old_folder", WDKIT_BUILDER_PATH . "/$widget_type/$folder_name" );
2322 + }
2323 +
2324 + $responce = array(
2325 + 'message' => esc_html__( 'Update Saved Successfully', 'wdesignkit' ),
2326 + 'description' => esc_html__( 'Success! Update Saved', 'wdesignkit' ),
2327 + 'success' => true,
2328 + );
2329 +
2330 + wp_send_json( $responce );
4247 2331 wp_die();
4248 2332 }
4249 2333
4250 2334 /**
4251 2335 *
4252 - * Custom_upload_dir
2336 + * It is Use for delete widget from server
4253 2337 *
4254 2338 * @since 1.0.0
4255 - *
4256 - * @param array $upload store data.
4257 2339 */
4258 - public function custom_upload_dir( $upload ) {
4259 - // Specify the path to your custom upload directory.
4260 - if ( isset( $this->widget_folder_u_r_l ) && ! empty( $this->widget_folder_u_r_l ) ) {
2340 + protected function wdkit_import_widget() {
2341 + $filename = '';
2342 + if ( isset( $_FILES ) && ! empty( $_FILES ) && isset( $_FILES['zipName'] ) && ! empty( $_FILES['zipName'] ) ) {
2343 + $filename = ! empty( $_FILES['zipName']['name'] ) ? sanitize_file_name( $_FILES['zipName']['name'] ) : '';
2344 + }
4261 2345
4262 - // Set the custom directory as the upload path.
4263 - $upload['path'] = $this->widget_folder_u_r_l;
4264 - // Set the URL for the uploaded file.
4265 - $upload['url'] = $upload['baseurl'] . $upload['subdir'];
2346 + $name = rtrim( $filename, '.zip' );
2347 + $ext = WDKIT_BUILDER_PATH . '/elementor/dump/';
2348 +
2349 + if ( ! is_dir( $ext ) ) {
2350 + wp_mkdir_p( $ext );
2351 + } else {
2352 + require_once ABSPATH . 'wp-admin/includes/file.php';
2353 + global $wp_filesystem;
2354 + WP_Filesystem();
2355 + $wp_filesystem->rmdir( $ext, true );
4266 2356 }
4267 2357
4268 - return $upload;
2358 + $dir = WDKIT_BUILDER_PATH . '/elementor/dump';
2359 + $getall_json = array();
2360 + $zip = new ZipArchive();
2361 +
2362 + $zipname = '';
2363 + if ( ! empty( $_FILES['zipName']['tmp_name'] ) ) {
2364 + $zipname = $this->wdkit_file_sanitizer_bypass( $_FILES, 'zipName', 'name' );
2365 + }
2366 +
2367 + $res = $zip->open( $zipname );
2368 + if ( true === $res ) {
2369 + $zip->extractTo( $ext );
2370 + $zip->close();
2371 + $widget_name = $image = $json_file = '';
2372 + $list = scandir( $dir );
2373 + $list = array_diff( $list, array( '.', '..' ) );
2374 + foreach ( $list as $sub_dir_value ) {
2375 + $file = new SplFileInfo( $sub_dir_value );
2376 + $check_ext = $file->getExtension();
2377 + $extiona = pathinfo( $sub_dir_value, PATHINFO_EXTENSION );
2378 + if ( 'json' === $extiona ) {
2379 + $json_file = $sub_dir_value;
2380 + $u_r_l = wp_json_file_decode( $ext . $sub_dir_value );
2381 + if ( ! empty( $u_r_l->widget_data->widgetdata->name ) && ! empty( $u_r_l->widget_data->widgetdata->widget_id ) ) {
2382 + $widget_name = $u_r_l->widget_data->widgetdata->name;
2383 + $widget_id = $u_r_l->widget_data->widgetdata->widget_id;
2384 + $widget_type = ! empty( $u_r_l->widget_data->widgetdata->type ) ? $u_r_l->widget_data->widgetdata->type : '';
2385 + }
2386 + } elseif ( 'jpg' === $extiona || 'png' === $extiona || 'jpeg' === $extiona ) {
2387 + $img_ext = $extiona;
2388 + $image = $sub_dir_value;
2389 + }
2390 + }
2391 +
2392 + if ( ! empty( $widget_name ) && ! empty( $json_file ) ) {
2393 + $folder_name = str_replace( ' ', '-', $widget_name );
2394 + $file_name = str_replace( ' ', '_', $widget_name );
2395 + if ( ! is_dir( WDKIT_BUILDER_PATH . "/{$widget_type}" ) ) {
2396 + wp_mkdir_p( WDKIT_BUILDER_PATH . "/{$widget_type}" );
2397 + }
2398 + $file_path = WDKIT_BUILDER_PATH . "/{$widget_type}/{$folder_name}_{$widget_id}";
2399 + $dummy_path = WDKIT_BUILDER_PATH . '/elementor/dump';
2400 +
2401 + if ( is_dir( $dummy_path ) ) {
2402 + if ( ! rename( $dummy_path, $file_path ) ) {
2403 +
2404 + require_once ABSPATH . 'wp-admin/includes/file.php';
2405 + global $wp_filesystem;
2406 + WP_Filesystem();
2407 + $wp_filesystem->rmdir( $dummy_path, true );
2408 +
2409 + $responce = (object) array(
2410 + 'success' => false,
2411 + 'message' => esc_html__( 'Widget Not imported', 'wdesignkit' ),
2412 + 'description' => esc_html__( 'Widget alreday exist!', 'wdesignkit' ),
2413 + );
2414 +
2415 + wp_send_json( $responce );
2416 + wp_die();
2417 + }
2418 + }
2419 +
2420 + rename( "{$file_path}/{$json_file}", "{$file_path}/{$file_name}_{$widget_id}.json" );
2421 +
2422 + $get_img_file = "{$file_path}/{$image}";
2423 +
2424 + if ( file_exists( $get_img_file ) ) {
2425 + rename( $get_img_file, "{$file_path}/{$file_name}_{$widget_id}.{$img_ext}" );
2426 + }
2427 + }
2428 +
2429 + $responce = (object) array(
2430 + 'success' => true,
2431 + 'message' => esc_html__( 'Widget imported', 'wdesignkit' ),
2432 + 'description' => esc_html__( 'Widget imported successfully', 'wdesignkit' ),
2433 + 'json' => $u_r_l,
2434 + );
2435 +
2436 + wp_send_json( $responce );
2437 + wp_die();
2438 +
2439 + } else {
2440 + $responce = (object) array(
2441 + 'success' => false,
2442 + 'message' => esc_html__( 'Operation Fial!', 'wdesignkit' ),
2443 + 'description' => esc_html__( 'Widget can not imported', 'wdesignkit' ),
2444 + );
2445 +
2446 + wp_send_json( $responce );
2447 + wp_die();
2448 + }
4269 2449 }
4270 2450
4271 2451 /**
4272 2452 *
2453 + * Create Uniq name
2454 + *
2455 + * @since 1.0.0
2456 + */
2457 + protected function generate_unique_id() {
2458 + $now = new DateTime();
2459 + $unique_i_d = $now->format( 'YmdHis' );
2460 + $hashed_i_d = (int) $unique_i_d % 10000;
2461 + return str_pad( $hashed_i_d, 4, '0', STR_PAD_LEFT );
2462 + }
2463 +
2464 + /**
2465 + *
4273 2466 * It is Use for delete widget from server
4274 2467 *
4275 2468 * @since 1.0.0
4276 2469 */
4277 - protected function wkit_widget_json() {
4278 - $widget_type = ! empty( $_POST['widget_type'] ) ? wp_unslash( $_POST['widget_type'] ) : '';
4279 - $folder_name = ! empty( $_POST['folder_name'] ) ? wp_unslash( $_POST['folder_name'] ) : '';
4280 - $file_name = ! empty( $_POST['file_name'] ) ? ( wp_unslash( $_POST['file_name'] ) ) : '';
2470 + protected function wdkit_export_widget() {
2471 + $data = isset( $_POST['info'] ) ? sanitize_text_field( wp_unslash( $_POST['info'] ) ) : '';
2472 + $data = json_decode( stripslashes( $data ) );
4281 2473
4282 - if ( empty( $widget_type ) || empty( $folder_name ) || empty( $file_name ) ) {
4283 - return array(
2474 + $widget_name_temp = isset( $data->widget_name ) ? sanitize_text_field( $data->widget_name ) : '';
2475 + $widget_type = isset( $data->widget_type ) ? sanitize_text_field( $data->widget_type ) : '';
2476 +
2477 + $widget_name = str_replace( ' ', '_', $widget_name_temp );
2478 + $folder = str_replace( ' ', '-', $widget_name_temp );
2479 + $unique_version = $this->generate_unique_id();
2480 +
2481 + if ( empty( $widget_type ) ) {
2482 + $result = (object) array(
4284 2483 'success' => false,
4285 - 'message' => esc_html__( 'Widget JSON not found', 'wdesignkit' ),
4286 - 'description' => esc_html__( 'widget JSON file not found.', 'wdesignkit' ),
2484 + 'url' => '',
2485 + 'message' => esc_html__( 'Widget Type Fail', 'wdesignkit' ),
2486 + 'description' => esc_html__( 'Widget Type Not Exists', 'wdesignkit' ),
4287 2487 );
2488 +
2489 + wp_send_json( $result );
2490 + wp_die();
4288 2491 }
4289 2492
4290 - $json_path = WDKIT_BUILDER_PATH . "/{$widget_type}/{$folder_name}/{$file_name}";
2493 + $downlod_path = WDKIT_BUILDER_PATH . "/{$widget_type}/";
2494 + $new_path = "{$downlod_path}/{$folder}/{$widget_name}";
4291 2495
4292 - $json_data = wp_json_file_decode( "$json_path.json" );
4293 - if ( ! empty( $json_data ) ) {
2496 + $download_url = WDKIT_SERVER_PATH . "/{$widget_type}/{$widget_name}.zip";
2497 + $zip = new ZipArchive();
2498 + $tmp_file = "{$downlod_path}{$widget_name}.zip";
2499 +
2500 + $json_data = wp_json_file_decode( "$new_path.json" );
2501 + $img_ext = $json_data->widget_data->widgetdata->img_ext;
2502 +
2503 + if ( true === $zip->open( $tmp_file, ZipArchive::CREATE ) ) {
2504 + $widget_wb = str_replace( '-', '_', $folder );
2505 + $zip->addFile( "$new_path.json", "$widget_wb.json" );
2506 + if ( ! empty( $img_ext ) ) {
2507 + $zip->addFile( "$new_path.$img_ext", "$widget_wb.$img_ext" );
2508 + }
2509 + $zip->close();
2510 +
4294 2511 $result = (object) array(
4295 2512 'success' => true,
4296 - 'data' => $json_data,
4297 - 'message' => esc_html__( 'Widget get Successfully', 'wdesignkit' ),
4298 - 'description' => esc_html__( 'Widget JSON get Successfully', 'wdesignkit' ),
2513 + 'url' => $download_url,
2514 + 'message' => esc_html__( 'Widget Exported', 'wdesignkit' ),
2515 + 'description' => esc_html__( 'Widget Exported successfully', 'wdesignkit' ),
4299 2516 );
2517 +
2518 + wp_send_json( $result );
2519 + wp_die();
4300 2520 } else {
4301 2521 $result = (object) array(
4302 2522 'success' => false,
4303 - 'message' => esc_html__( 'Widget not get', 'wdesignkit' ),
4304 - 'description' => esc_html__( 'Widget JSON not get', 'wdesignkit' ),
2523 + 'url' => '',
2524 + 'message' => esc_html__( 'Widget Exported Fail', 'wdesignkit' ),
2525 + 'description' => esc_html__( 'something went wrong! please try again later.', 'wdesignkit' ),
4305 2526 );
2527 +
2528 + wp_send_json( $result );
2529 + wp_die();
4306 2530 }
2531 + }
4307 2532
4308 - wp_send_json( $result );
4309 - wp_die();
2533 + /**
2534 + *
2535 + * It is Use for delete widget from server
2536 + *
2537 + * @since 1.0.0
2538 + */
2539 + protected function wdkit_delete_widget() {
2540 + $data = isset( $_POST['info'] ) ? sanitize_text_field( wp_unslash( $_POST['info'] ) ) : '';
2541 + $data = json_decode( stripslashes( $data ) );
2542 +
2543 + $delete_type = isset( $data->delete_type ) ? sanitize_text_field( $data->delete_type ) : '';
2544 +
2545 + if ( 'plugin_server' === $delete_type ) {
2546 + $array_data = array(
2547 + 'token' => isset( $data->token ) ? sanitize_text_field( $data->token ) : '',
2548 + 'type' => isset( $data->type ) ? sanitize_text_field( $data->type ) : '',
2549 + 'w_unique' => isset( $data->w_unique ) ? sanitize_text_field( $data->w_unique ) : '',
2550 + 'id' => isset( $data->id ) ? sanitize_text_field( $data->id ) : '',
2551 + );
2552 +
2553 + $response = $this->wkit_api_call( $array_data, 'save_widget' );
2554 + $success = ! empty( $response['success'] ) ? $response['success'] : false;
2555 +
2556 + if ( empty( $success ) ) {
2557 + $massage = ! empty( $response['massage'] ) ? $response['massage'] : esc_html__( 'server error', 'wdesignkit' );
2558 +
2559 + $result = (object) array(
2560 + 'success' => false,
2561 + 'message' => esc_html__( 'Widget Not Deleted', 'wdesignkit' ),
2562 + 'description' => esc_html__( 'Widget Not Deleted', 'wdesignkit' ),
2563 + );
2564 +
2565 + wp_send_json( $result );
2566 + wp_die();
2567 + }
2568 + }
2569 +
2570 + $dir_name = isset( $data->name ) ? sanitize_text_field( $data->name ) : '';
2571 + $widget_type = isset( $data->builder ) ? sanitize_text_field( $data->builder ) : '';
2572 + $dir = WDKIT_BUILDER_PATH . "/{$widget_type}/{$dir_name}";
2573 +
2574 + require_once ABSPATH . 'wp-admin/includes/file.php';
2575 + global $wp_filesystem;
2576 + WP_Filesystem();
2577 + $wp_filesystem->rmdir( $dir, true );
2578 +
2579 + if ( 'plugin_server' === $delete_type ) {
2580 + wp_send_json( $response['data'] );
2581 + wp_die();
2582 + } else {
2583 + $result = (object) array(
2584 + 'success' => true,
2585 + 'message' => esc_html__( 'widget deleted', 'wdesignkit' ),
2586 + 'description' => esc_html__( 'Widget deleted successfully', 'wdesignkit' ),
2587 + );
2588 +
2589 + wp_send_json( $result );
2590 + wp_die();
2591 + }
4310 2592 }
4311 2593
4312 2594 /**
4313 2595 *
@@ -4356,15 +2638,10 @@
4356 2638 wp_die();
4357 2639 }
4358 2640
4359 2641 $img_url = ! empty( $response['data']['image'] ) ? $response['data']['image'] : '';
4360 - $json_data = ! empty( $response['data']['json'] ) ? json_decode( $response['data']['json'], true ) : '';
2642 + $json_data = ! empty( $response['data']['json'] ) ? json_decode( $response['data']['json'] ) : '';
4361 2643
4362 - if ( empty( $response['success'] ) ) {
4363 - wp_send_json( $responce );
4364 - wp_die();
4365 - }
4366 -
4367 2644 if ( empty( $img_url ) && empty( $json_data ) ) {
4368 2645 $responce = (object) array(
4369 2646 'success' => false,
4370 2647 'message' => esc_html__( 'No Response Found', 'wdesignkit' ),
@@ -4378,16 +2655,12 @@
4378 2655 include_once ABSPATH . 'wp-admin/includes/file.php';
4379 2656 \WP_Filesystem();
4380 2657 global $wp_filesystem;
4381 2658
4382 - if ( ! is_array( $json_data ) ) {
4383 - $json_data = json_decode( $json_data, true );
4384 - }
2659 + $title = ! empty( $json_data->widget_data->widgetdata->name ) ? sanitize_text_field( $json_data->widget_data->widgetdata->name ) : '';
2660 + $builder = ! empty( $json_data->widget_data->widgetdata->type ) ? sanitize_text_field( $json_data->widget_data->widgetdata->type ) : '';
2661 + $w_uniq = ! empty( $json_data->widget_data->widgetdata->widget_id ) ? sanitize_text_field( $json_data->widget_data->widgetdata->widget_id ) : '';
4385 2662
4386 - $title = ! empty( $json_data['widget_data']['widgetdata']['name'] ) ? sanitize_text_field( $json_data['widget_data']['widgetdata']['name'] ) : '';
4387 - $builder = ! empty( $json_data['widget_data']['widgetdata']['type'] ) ? sanitize_text_field( $json_data['widget_data']['widgetdata']['type'] ) : '';
4388 - $w_uniq = ! empty( $json_data['widget_data']['widgetdata']['widget_id'] ) ? sanitize_text_field( $json_data['widget_data']['widgetdata']['widget_id'] ) : '';
4389 -
4390 2663 $folder_name = str_replace( ' ', '-', $title ) . '_' . $w_uniq;
4391 2664 $file_name = str_replace( ' ', '_', $title ) . '_' . $w_uniq;
4392 2665 $builder_type_path = WDKIT_BUILDER_PATH . "/{$builder}/";
4393 2666
@@ -4403,9 +2676,9 @@
4403 2676 $img_body = wp_remote_get( $img_url );
4404 2677 $img_ext = pathinfo( $img_url )['extension'];
4405 2678
4406 2679 $wp_filesystem->put_contents( WDKIT_BUILDER_PATH . "/$builder/$folder_name/$file_name.$img_ext", $img_body['body'] );
4407 - $json_data['widget_data']['widgetdata']['w_image'] = WDKIT_SERVER_PATH . "/$builder/$folder_name/$file_name.$img_ext";
2680 + $json_data->widget_data->widgetdata->w_image = WDKIT_SERVER_PATH . "/$builder/$folder_name/$file_name.$img_ext";
4408 2681 }
4409 2682
4410 2683 $result = (object) array(
4411 2684 'success' => false,
@@ -4419,8 +2692,87 @@
4419 2692 }
4420 2693
4421 2694 /**
4422 2695 *
2696 + * It is Use for download widget from browse page.
2697 + *
2698 + * @since 1.0.0
2699 + */
2700 + protected function wdkit_public_download_widget() {
2701 + $data = ! empty( $_POST['widget_info'] ) ? $this->wdkit_sanitizer_bypass( $_POST, 'widget_info', 'none' ) : '';
2702 + $data = json_decode( stripslashes( $data ) );
2703 +
2704 + $array_data = array(
2705 + 'id' => isset( $data->w_uniq ) ? sanitize_text_field( $data->w_uniq ) : '',
2706 + 'u_id' => isset( $data->u_id ) ? sanitize_text_field( $data->u_id ) : '',
2707 + 'type' => isset( $data->d_type ) ? sanitize_text_field( $data->d_type ) : '',
2708 + );
2709 +
2710 + $response = $this->wkit_api_call( $array_data, 'widget/download' );
2711 + $success = ! empty( $response['success'] ) ? $response['success'] : false;
2712 +
2713 + if ( empty( $success ) ) {
2714 + $massage = ! empty( $response['massage'] ) ? $response['massage'] : esc_html__( 'server error', 'wdesignkit' );
2715 +
2716 + $result = (object) array(
2717 + 'success' => false,
2718 + 'message' => $massage,
2719 + 'description' => esc_html__( 'Widget not Downloaded', 'wdesignkit' ),
2720 + );
2721 +
2722 + wp_send_json( $result );
2723 + wp_die();
2724 + }
2725 +
2726 + $response = json_decode( wp_json_encode( $response['data'] ), true );
2727 + if ( ! empty( $response ) && ! empty( $response['data'] ) ) {
2728 + $img_url = ! empty( $response['data']['image'] ) ? esc_url_raw( $response['data']['image'] ) : '';
2729 + $json = ! empty( $response['data']['json'] ) ? wp_json_encode( $response['data']['json'] ) : '';
2730 +
2731 + if ( ! empty( $json ) ) {
2732 + include_once ABSPATH . 'wp-admin/includes/file.php';
2733 + \WP_Filesystem();
2734 + global $wp_filesystem;
2735 +
2736 + $json_data = json_decode( $json );
2737 + $json_data = json_decode( $json_data );
2738 + $title = ! empty( $json_data->widget_data->widgetdata->name ) ? sanitize_text_field( $json_data->widget_data->widgetdata->name ) : '';
2739 + $builder = ! empty( $json_data->widget_data->widgetdata->type ) ? sanitize_text_field( $json_data->widget_data->widgetdata->type ) : '';
2740 + $widget_id = ! empty( $json_data->widget_data->widgetdata->widget_id ) ? sanitize_text_field( $json_data->widget_data->widgetdata->widget_id ) : '';
2741 +
2742 + $folder_name = str_replace( ' ', '-', $title ) . '_' . $widget_id;
2743 + $file_name = str_replace( ' ', '_', $title ) . '_' . $widget_id;
2744 +
2745 + $builder_type_path = WDKIT_BUILDER_PATH . "/{$builder}/";
2746 +
2747 + if ( ! is_dir( $builder_type_path . $folder_name ) ) {
2748 + wp_mkdir_p( $builder_type_path . $folder_name );
2749 + }
2750 +
2751 + if ( ! empty( $img_url ) ) {
2752 + $img_body = wp_remote_get( $img_url );
2753 + $img_ext = pathinfo( $img_url )['extension'];
2754 + $wp_filesystem->put_contents( WDKIT_BUILDER_PATH . "/$builder/$folder_name/$file_name.$img_ext", $img_body['body'] );
2755 +
2756 + $json_data->widget_data->widgetdata->w_image = WDKIT_SERVER_PATH . "/$builder/$folder_name/$file_name.$img_ext";
2757 + }
2758 +
2759 + $response = (object) array(
2760 + 'message' => ! empty( $response['message'] ) ? $response['message'] : '',
2761 + 'description' => ! empty( $response['description'] ) ? $response['description'] : '',
2762 + 'success' => ! empty( $response['success'] ) ? $response['success'] : false,
2763 + 'r_id' => ! empty( $response['data']['rid'] ) ? $response['data']['rid'] : 0,
2764 + 'json' => wp_json_encode( $json_data ),
2765 + );
2766 + }
2767 + }
2768 +
2769 + wp_send_json( $response );
2770 + wp_die();
2771 + }
2772 +
2773 + /**
2774 + *
4423 2775 * It is Use for sync widget to server
4424 2776 *
4425 2777 * @since 1.0.0
4426 2778 */
@@ -4425,10 +2777,9 @@
4425 2777 * @since 1.0.0
4426 2778 */
4427 2779 protected function wdkit_add_widget() {
4428 2780 $data = ! empty( $_POST['widget_info'] ) ? $this->wdkit_sanitizer_bypass( $_POST, 'widget_info', 'none' ) : '';
4429 - $data = base64_decode( $data );
4430 - $data = json_decode( $data );
2781 + $data = json_decode( stripslashes( $data ) );
4431 2782
4432 2783 $title = isset( $data->title ) ? sanitize_text_field( $data->title ) : '';
4433 2784 $builder = isset( $data->builder ) ? sanitize_text_field( $data->builder ) : '';
4434 2785 $w_uniq = isset( $data->w_uniq ) ? sanitize_text_field( $data->w_uniq ) : '';
@@ -4451,9 +2802,8 @@
4451 2802 'w_imgext' => isset( $data->w_imgext ) ? sanitize_text_field( $data->w_imgext ) : '',
4452 2803 'w_version' => isset( $data->w_version ) ? $data->w_version : '',
4453 2804 'w_updates' => ! empty( $data->w_updates ) ? serialize( $data->w_updates ) : serialize( array() ),
4454 2805 'r_id' => isset( $data->r_id ) ? $data->r_id : 0,
4455 - 'unique_id' => get_option( 'wdkit_unique_id' ) ?? '',
4456 2806 );
4457 2807
4458 2808 $response = $this->wkit_api_call( $array_data, 'save_widget' );
4459 2809 $success = ! empty( $response['success'] ) ? $response['success'] : false;
@@ -4476,9 +2826,8 @@
4476 2826 $response = json_decode( wp_json_encode( $res ), true );
4477 2827 $img_url = ! empty( $response['data']['imgurl'] ) ? $response['data']['imgurl'] : '';
4478 2828
4479 2829 if ( ! empty( $img_url ) && 'error' !== $res ) {
4480 -
4481 2830 $img_body = wp_remote_get( $img_url );
4482 2831 $img_ext = pathinfo( $img_url )['extension'];
4483 2832 include_once ABSPATH . 'wp-admin/includes/file.php';
4484 2833 \WP_Filesystem();
@@ -4559,9 +2908,9 @@
4559 2908 *
4560 2909 * @since 1.0.0
4561 2910 */
4562 2911 protected static function wkit_get_settings_panel() {
4563 - $new_version = '';
2912 +
4564 2913 $current_version = WDKIT_VERSION;
4565 2914 $response = wp_remote_get( 'https://api.wordpress.org/plugins/info/1.0/wdesignkit.json' );
4566 2915
4567 2916 if ( is_wp_error( $response ) ) {
@@ -4586,104 +2935,23 @@
4586 2935 }
4587 2936
4588 2937 $get_setting = get_option( 'wkit_settings_panel', false );
4589 2938
4590 - $setting_data = array(
4591 - 'builder' => isset( $get_setting['builder'] ) ? $get_setting['builder'] : true,
4592 - 'template' => isset( $get_setting['template'] ) ? $get_setting['template'] : true,
4593 - 'gutenberg_builder' => isset( $get_setting['gutenberg_builder'] ) ? $get_setting['gutenberg_builder'] : true,
4594 - 'gutenberg_core_builder' => isset( $get_setting['gutenberg_core_builder'] ) ? $get_setting['gutenberg_core_builder'] : false,
4595 - 'elementor_builder' => isset( $get_setting['elementor_builder'] ) ? $get_setting['elementor_builder'] : true,
4596 - 'bricks_builder' => isset( $get_setting['bricks_builder'] ) ? $get_setting['bricks_builder'] : false,
4597 - 'gutenberg_template' => isset( $get_setting['gutenberg_template'] ) ? $get_setting['gutenberg_template'] : true,
4598 - 'elementor_template' => isset( $get_setting['elementor_template'] ) ? $get_setting['elementor_template'] : true,
4599 - 'code_snippet' => isset( $get_setting['code_snippet'] ) ? $get_setting['code_snippet'] : true,
4600 - 'plugin_version' => $version_check,
2939 + return array(
2940 + 'builder' => isset( $get_setting['builder'] ) ? $get_setting['builder'] : true,
2941 + 'template' => isset( $get_setting['template'] ) ? $get_setting['template'] : true,
2942 + 'gutenberg_builder' => isset( $get_setting['gutenberg_builder'] ) ? $get_setting['gutenberg_builder'] : true,
2943 + 'elementor_builder' => isset( $get_setting['elementor_builder'] ) ? $get_setting['elementor_builder'] : true,
2944 + 'bricks_builder' => isset( $get_setting['bricks_builder'] ) ? $get_setting['bricks_builder'] : false,
2945 + 'debugger_mode' => isset( $get_setting['debugger_mode'] ) ? $get_setting['debugger_mode'] : false,
2946 + 'gutenberg_template' => isset( $get_setting['gutenberg_template'] ) ? $get_setting['gutenberg_template'] : true,
2947 + 'elementor_template' => isset( $get_setting['elementor_template'] ) ? $get_setting['elementor_template'] : true,
2948 + 'plugin_version' => $version_check,
4601 2949 );
4602 -
4603 - if ( isset( $get_setting['remove_db'] ) ) {
4604 - $setting_data['remove_db'] = $get_setting['remove_db'];
4605 - }
4606 -
4607 - if ( isset( $get_setting['debugger_mode'] ) ) {
4608 - $setting_data['debugger_mode'] = $get_setting['debugger_mode'];
4609 - }
4610 -
4611 - return $setting_data;
4612 2950 }
4613 2951
4614 2952 /**
4615 - * Updated White Label Data.
4616 2953 *
4617 - * @since 1.1.8
4618 - */
4619 - protected function wkit_white_label() {
4620 -
4621 - $get_wl_data = ! empty( $_POST['WhiteLabelData'] ) ? wp_unslash( $_POST['WhiteLabelData'] ) : array();
4622 -
4623 - if ( ! empty( $get_wl_data ) ) {
4624 - $white_label_data = json_decode( $get_wl_data, true );
4625 - $plugin_name = $white_label_data['plugin_name'];
4626 - } else {
4627 - $result = array(
4628 - 'success' => false,
4629 - 'message' => esc_html__( 'Data Not Found', 'wdesignkit' ),
4630 - );
4631 -
4632 - wp_send_json( $result );
4633 - wp_die();
4634 - }
4635 -
4636 - if ( ! empty( $plugin_name ) ) {
4637 - $get_white_label = get_option( 'wkit_white_label', false );
4638 - if ( ! empty( $get_white_label ) ) {
4639 - update_option( 'wkit_white_label', $white_label_data );
4640 - } else {
4641 - add_option( 'wkit_white_label', $white_label_data );
4642 - }
4643 - } else {
4644 - $result = array(
4645 - 'success' => false,
4646 - 'message' => esc_html__( 'Plugin Name Not Found', 'wdesignkit' ),
4647 - );
4648 -
4649 - wp_send_json( $result );
4650 - wp_die();
4651 - }
4652 -
4653 - $get_updated_data = get_option( 'wkit_white_label', false );
4654 - $response = array(
4655 - 'message' => 'Data Added successfully',
4656 - 'success' => true,
4657 - 'data' => $get_updated_data,
4658 - );
4659 -
4660 - wp_send_json( $response );
4661 - }
4662 -
4663 - /**
4664 - * Reset White Label Data.
4665 - *
4666 - * @since 1.1.8
4667 - */
4668 - public function wkit_reset_wl() {
4669 - $wl_data = get_option( 'wkit_white_label' );
4670 -
4671 - if ( ! empty( $wl_data ) ) {
4672 - delete_option( 'wkit_white_label' );
4673 -
4674 - $result = array(
4675 - 'success' => true,
4676 - 'message' => esc_html__( 'Reset White Label Successfully', 'wdesignkit' ),
4677 - );
4678 -
4679 - wp_send_json( $result );
4680 - wp_die();
4681 - }
4682 - }
4683 -
4684 - /**
4685 - *
4686 2954 * Use for Add new licence key.
4687 2955 *
4688 2956 * @since 1.0.0
4689 2957 */
@@ -4696,38 +2964,9 @@
4696 2964 );
4697 2965
4698 2966 $response = $this->wkit_api_call( $args, 'wkit_activate_key' );
4699 2967
4700 - if ( ! empty( $response['data'] ) ) {
4701 - $response = json_decode( wp_json_encode( $response['data'] ), true );
4702 -
4703 - if ( ! empty( $response['data']['tpae_licence'] ) && is_serialized( $response['data']['tpae_licence'] ) ) {
4704 - $response['data']['tpae_licence'] = unserialize( $response['data']['tpae_licence'] );
4705 - }
4706 -
4707 - if ( ! empty( $response['data']['tpag_licence'] ) && is_serialized( $response['data']['tpag_licence'] ) ) {
4708 - $response['data']['tpag_licence'] = unserialize( $response['data']['tpag_licence'] );
4709 - }
4710 -
4711 - if ( ! empty( $response['data']['uichemy_licence'] ) && is_serialized( $response['data']['uichemy_licence'] ) ) {
4712 - $response['data']['uichemy_licence'] = unserialize( $response['data']['uichemy_licence'] );
4713 - }
4714 -
4715 - if ( ! empty( $response['data']['wdkit_licence'] ) && is_serialized( $response['data']['wdkit_licence'] ) ) {
4716 - $response['data']['wdkit_licence'] = unserialize( $response['data']['wdkit_licence'] );
4717 -
4718 - // Store WDesignKit license status locally for quick access
4719 - if ( ! empty( $response['data']['wdkit_licence'] ) && is_array( $response['data']['wdkit_licence'] ) ) {
4720 - update_option( 'wdkit_licence_data', $response['data']['wdkit_licence'] );
4721 - }
4722 - }
4723 -
4724 - if ( ! empty( $response['data']['wdkit_licence_extra'] ) && is_serialized( $response['data']['wdkit_licence_extra'] ) ) {
4725 - $response['data']['wdkit_licence_extra'] = unserialize( $response['data']['wdkit_licence_extra'] );
4726 - }
4727 - }
4728 -
4729 - wp_send_json( $response );
2968 + wp_send_json( $response['data'] );
4730 2969 wp_die();
4731 2970 }
4732 2971
4733 2972 /**
@@ -4738,23 +2977,16 @@
4738 2977 */
4739 2978 protected function wdkit_delete_licence_key() {
4740 2979 $token = ! empty( $_POST['token'] ) ? sanitize_text_field( wp_unslash( $_POST['token'] ) ) : '';
4741 2980 $licencename = ! empty( $_POST['licencename'] ) ? sanitize_text_field( wp_unslash( $_POST['licencename'] ) ) : '';
4742 - $apikey = ! empty( $_POST['apikey'] ) ? sanitize_text_field( wp_unslash( $_POST['apikey'] ) ) : '';
4743 2981
4744 2982 $args = array(
4745 2983 'token' => $token,
4746 2984 'licencename' => $licencename,
4747 - 'apikey' => $apikey,
4748 2985 );
4749 2986
4750 2987 $response = $this->wkit_api_call( $args, 'licence_delete' );
4751 2988
4752 - // Remove local WDesignKit license data if deleting WDesignKit license
4753 - if ( 'wdkit' === $licencename ) {
4754 - delete_option( 'wdkit_licence_data' );
4755 - }
4756 -
4757 2989 wp_send_json( $response['data'] );
4758 2990 wp_die();
4759 2991 }
4760 2992
@@ -4779,118 +3011,9 @@
4779 3011 wp_die();
4780 3012 }
4781 3013
4782 3014 /**
4783 - * Rollback to Previous Versions
4784 3015 *
4785 - * @since 1.1.0
4786 - */
4787 - protected function wdkit_prev_version() {
4788 -
4789 - require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
4790 -
4791 - $plugin_info = plugins_api(
4792 - 'plugin_information',
4793 - array(
4794 - 'slug' => 'wdesignkit',
4795 - )
4796 - );
4797 -
4798 - if ( empty( $plugin_info->versions ) || ! is_array( $plugin_info->versions ) ) {
4799 - return array();
4800 - }
4801 -
4802 - krsort( $plugin_info->versions );
4803 -
4804 - $versions_list = array();
4805 - $index = 0;
4806 -
4807 - foreach ( $plugin_info->versions as $version => $download_link ) {
4808 -
4809 - $lowercase_version = strtolower( $version );
4810 -
4811 - $is_valid_version = ! preg_match( '/(beta|rc|trunk|dev)/i', $lowercase_version );
4812 -
4813 - $is_valid_version = apply_filters( 'wdkit_check_rollback_version', $is_valid_version, $lowercase_version );
4814 -
4815 - if ( ! $is_valid_version || version_compare( $version, WDKIT_VERSION, '>=' ) ) {
4816 - continue;
4817 - }
4818 -
4819 - $versions_list[] = $version;
4820 - ++$index;
4821 - }
4822 -
4823 - // set_transient( 'wdkit_rollback_version_' . WDKIT_VERSION, $versions_list, WEEK_IN_SECONDS );
4824 -
4825 - return $versions_list;
4826 - }
4827 -
4828 - /**
4829 - * Rollback to Previous Versions
4830 - *
4831 - * @since 1.1.0
4832 - */
4833 - protected function wdkit_rollback_check() {
4834 -
4835 - $current_ver = isset( $_POST['version'] ) ? sanitize_text_field( wp_unslash( $_POST['version'] ) ) : '';
4836 - $rv = $this->wdkit_prev_version();
4837 -
4838 - if ( empty( $current_ver ) || ! in_array( $current_ver, $rv ) ) {
4839 - return array(
4840 - 'message' => esc_html__( 'Invalid Nonce or version not found', 'wdesignkit' ),
4841 - 'status' => 'error',
4842 - 'success' => false,
4843 - );
4844 - }
4845 -
4846 - $plugin_slug = basename( WDKIT_PBNAME, '.php' );
4847 -
4848 - $this_version = $current_ver;
4849 - $this_pluginname = WDKIT_PBNAME;
4850 - $this_plugin_u_r_l = sprintf( 'https://downloads.wordpress.org/plugin/%s.%s.zip', $plugin_slug, $this_version );
4851 -
4852 - $plugin_info = new \stdClass();
4853 - $plugin_info->new_version = $this_version;
4854 - $plugin_info->slug = $plugin_slug;
4855 - $plugin_info->package = $this_plugin_u_r_l;
4856 - $plugin_info->url = 'https://wdesignkit.com/';
4857 -
4858 - $update_plugins_data = get_site_transient( 'update_plugins' );
4859 -
4860 - if ( ! is_object( $update_plugins_data ) ) {
4861 - $update_plugins_data = new \stdClass();
4862 - }
4863 -
4864 - $update_plugins_data->response[ $this_pluginname ] = $plugin_info;
4865 -
4866 - set_site_transient( 'update_plugins', $update_plugins_data );
4867 -
4868 - require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
4869 -
4870 - $logo_url = WDKIT_URL . 'assets/images/jpg/Wdesignkit-logo.png';
4871 -
4872 - $args = array(
4873 - 'url' => 'update.php?action=upgrade-plugin&plugin=' . rawurlencode( $this_pluginname ),
4874 - 'plugin' => $this_pluginname,
4875 - 'nonce' => 'upgrade-plugin_' . $this_pluginname,
4876 - 'title' => '<img src="' . esc_url( $logo_url ) . '" alt="wdesignkit-logo"><div class="theplus-rb-subtitle">' . esc_html__( 'Rollback to Previous Version', 'wdesignkit' ) . '</div>',
4877 - );
4878 -
4879 - $upgrader_plugin = new \Plugin_Upgrader( new \Plugin_Upgrader_Skin( $args ) );
4880 - $upgrader_plugin->upgrade( $this_pluginname );
4881 -
4882 - activate_plugin( $this_pluginname );
4883 -
4884 - return array(
4885 - 'message' => esc_html__( 'Rollback Successful, Plugin Re-activated', 'wdesignkit' ),
4886 - 'status' => 'Success',
4887 - 'success' => true,
4888 - );
4889 - }
4890 -
4891 - /**
4892 - *
4893 3016 * It is Use for logout.
4894 3017 *
4895 3018 * @since 1.0.0
4896 3019 */
@@ -4905,10 +3028,8 @@
4905 3028 $args = array( 'token' => $token );
4906 3029
4907 3030 if ( 'session' !== $logout_type ) {
4908 3031 delete_transient( 'wdkit_auth_' . $email );
4909 - // Clear stored license data on logout so banner shows again
4910 - delete_option( 'wdkit_licence_data' );
4911 3032 $response = WDesignKit_Data_Query::get_data( 'logout', $args );
4912 3033 }
4913 3034 }
4914 3035
@@ -4955,9 +3076,24 @@
4955 3076 return $data[ $type ];
4956 3077 }
4957 3078 }
4958 3079
3080 + /**
3081 + * Parse args $_POST
3082 + *
3083 + * @since 1.0.0
3084 + *
3085 + * @param string $data send all post data.
3086 + * @param string $type store text data.
3087 + * @param string $condition store text data.
3088 + */
3089 + protected function wdkit_file_sanitizer_bypass( $data, $type, $condition = 'none' ) {
4959 3090
3091 + if ( 'name' === $condition ) {
3092 + return wp_normalize_path( $data[ $type ]['tmp_name'] );
3093 + }
3094 + }
3095 +
4960 3096 /**
4961 3097 * Parse args $_POST
4962 3098 *
4963 3099 * @since 1.0.0
@@ -5033,28 +3169,8 @@
5033 3169 if ( isset( $data['plugin'] ) ) {
5034 3170 $args['plugin'] = isset( $data['plugin'] ) ? wp_unslash( $data['plugin'] ) : array();
5035 3171 }
5036 3172
5037 - if ( isset( $data['plugin_exclude'] ) ) {
5038 - $args['plugin_exclude'] = isset( $data['plugin_exclude'] ) ? wp_unslash( $data['plugin_exclude'] ) : array();
5039 - }
5040 -
5041 - if ( isset( $data['ai_compatibility'] ) ) {
5042 - $args['ai_compatibility'] = isset( $data['ai_compatibility'] ) ? wp_unslash( $data['ai_compatibility'] ) : array();
5043 - }
5044 -
5045 - // if ( isset( $data['global_color'] ) ) {
5046 - // $args['global_color'] = isset( $data['global_color'] ) ? wp_unslash( $data['global_color'] ) : array();
5047 - // }
5048 -
5049 - // if ( isset( $data['global_font_family'] ) ) {
5050 - // $args['global_font_family'] = isset( $data['global_font_family'] ) ? wp_unslash( $data['global_font_family'] ) : array();
5051 - // }
5052 -
5053 - if ( isset( $data['global_data'] ) ) {
5054 - $args['global_data'] = isset( $data['global_data'] ) ? wp_unslash( $data['global_data'] ) : array();
5055 - }
5056 -
5057 3173 if ( isset( $data['tag'] ) ) {
5058 3174 $args['tag'] = isset( $data['tag'] ) ? wp_unslash( $data['tag'] ) : array();
5059 3175 }
5060 3176
@@ -5083,34 +3199,8 @@
5083 3199 }
5084 3200
5085 3201 return $args;
5086 3202 }
5087 -
5088 - /**
5089 - * Dark Mode
5090 - *
5091 - * @since 2.0.0
5092 - *
5093 - * @param string store darkmode value in database.
5094 - */
5095 - protected function wdkit_dark_mode() {
5096 - $dark_mode = ! empty( $_POST['dark_mode'] ) ? sanitize_text_field( $_POST['dark_mode'] ) : 'light';
5097 -
5098 - if ( get_option( 'wdkit_dark_mode' ) ) {
5099 - update_option( 'wdkit_dark_mode', $dark_mode );
5100 - } else {
5101 - add_option( 'wdkit_dark_mode', $dark_mode );
5102 - }
5103 -
5104 - $response = array(
5105 - 'message' => esc_html__( 'Dark Mode Updated', 'wdesignkit' ),
5106 - 'status' => 'Success',
5107 - 'success' => true,
5108 - );
5109 -
5110 - wp_send_json( $response );
5111 - wp_die();
5112 - }
5113 3203 }
5114 3204
5115 3205 Wdkit_Api_Call::get_instance();
5116 -}
3206 +}