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 +953 -2818 2.3.21.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,26 +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 'get_global_val':
202 - $data = $this->wdkit_get_global_val();
203 - break;
204 - case 'update_global_val':
205 - $data = $this->wdkit_update_global_val();
206 - break;
207 - case 'wdkit_get_site_setting':
208 - $data = $this->wdkit_get_site_setting();
209 - break;
210 - case 'wdkit_update_site_setting':
211 - $data = $this->wdkit_update_site_setting();
212 - break;
213 - case 'update_preset_setting':
214 - $data = $this->wdkit_update_preset();
215 - break;
216 171 case 'find_template':
217 172 $data = $this->wdkit_find_existing_template();
218 173 break;
219 174 case 'update_template':
@@ -227,62 +182,11 @@
227 182 break;
228 183 case 'install_plugins_depends':
229 184 $data = $this->wdkit_install_plugins_depends();
230 185 break;
231 - case 'generate_site_logo':
232 - $data = $this->wkit_generate_site_logo();
233 - break;
234 - case 'generate_ai_content':
235 - $data = apply_filters( 'wp_wdkit_import_temp_ajax', 'generate_ai_content' );
236 - break;
237 - case 'reset_site':
238 - $data = apply_filters( 'wp_wdkit_import_temp_ajax', 'reset_site' );
239 - break;
240 - case 'wdkit_nxt_thembuilder_reset':
241 - $data = $this->wdkit_nxt_thembuilder_reset();
242 - break;
243 - case 'wdkit_check_user_credit':
244 - $data = $this->wdkit_check_user_credit();
245 - break;
246 - case 'wdkit_remove_header_footer':
247 - $data = apply_filters( 'wp_wdkit_import_temp_ajax', 'wdkit_remove_header_footer' );
248 - break;
249 - case 'check_post_count':
250 - $data = apply_filters( 'wp_wdkit_import_temp_ajax', 'check_post_count' );
251 - break;
252 - case 'wkit_check_product_count':
253 - $data = apply_filters( 'wp_wdkit_import_temp_ajax', 'wkit_check_product_count' );
254 - break;
255 - case 'select_team_img':
256 - $data = apply_filters( 'wp_wdkit_import_temp_ajax', 'select_team_img' );
257 - break;
258 - case 'wkit_ai_desc_keyword':
259 - $data = apply_filters( 'wp_wdkit_import_temp_ajax', 'wkit_ai_desc_keyword' );
260 - break;
261 - case 'wkit_ai_credit_update':
262 - $data = apply_filters( 'wp_wdkit_import_temp_ajax', 'wkit_ai_credit_update' );
263 - break;
264 - case 'wkit_generate_post_data':
265 - $data = apply_filters( 'wp_wdkit_import_temp_ajax', 'wkit_generate_post_data' );
266 - break;
267 - case 'wkit_generate_product_data':
268 - $data = apply_filters( 'wp_wdkit_import_temp_ajax', 'wkit_generate_product_data' );
269 - break;
270 - case 'wkit_cteate_product':
271 - $data = apply_filters( 'wp_wdkit_import_temp_ajax', 'wkit_cteate_product' );
272 - break;
273 - case 'wkit_remove_dummy_post':
274 - $data = apply_filters( 'wp_wdkit_import_temp_ajax', 'wkit_remove_dummy_post' );
275 - break;
276 186 case 'update_latest_plugin':
277 187 $data = $this->wdkit_update_latest_plugin();
278 188 break;
279 - case 'activate_container':
280 - $data = $this->wdkit_activate_container();
281 - break;
282 - case 'import_taxonomy':
283 - $data = $this->wdkit_import_taxonomy();
284 - break;
285 189 case 'import_template':
286 190 $data = $this->wdkit_import_template();
287 191 break;
288 192 case 'import_multi_template':
@@ -287,55 +191,11 @@
287 191 break;
288 192 case 'import_multi_template':
289 193 $data = $this->wdkit_import_multi_template();
290 194 break;
291 - case 'import_page_section':
292 - $data = $this->import_page_section_content();
293 - break;
294 - case 'wkit_update_elementor_template':
295 - $data = $this->wkit_update_elementor_template();
296 - break;
297 - case 'update_plugin_setting':
298 - $data = $this->update_plugin_setting();
299 - break;
300 - case 'update_theme_setting':
301 - $data = $this->update_theme_setting();
302 - break;
303 - case 'update_site_setting':
304 - $data = $this->update_site_setting();
305 - break;
306 195 case 'import_kit_template':
307 196 $data = $this->wdkit_import_kit_template();
308 197 break;
309 - case 'enable_template_widgets':
310 - $data = $this->wdkit_enable_template_widgets();
311 - break;
312 - case 'scan_nexter_widgets':
313 - if ( ! empty( $_POST['blockNames'] ) && has_filter( 'nexter_block_list_merge' ) ) {
314 -
315 - $posted_blocks = json_decode( stripslashes( $_POST['blockNames'] ), true );
316 -
317 - if ( is_array( $posted_blocks ) ) {
318 - $blockList = array_map( 'sanitize_text_field', $posted_blocks );
319 -
320 - // अब filter call करो
321 - $result = apply_filters( 'nexter_block_list_merge', $blockList );
322 -
323 - wp_send_json( $result );
324 - wp_die();
325 - }
326 - }
327 -
328 - wp_send_json(
329 - array(
330 - 'success' => false,
331 - 'message' => 'No block names received or filter not found.',
332 - 'description' => 'Ensure blockNames are posted and the filter is attached.',
333 - )
334 - );
335 - wp_die();
336 - $data = '';
337 - break;
338 198 case 'shared_with_me':
339 199 $data = $this->wdkit_shared_with_me();
340 200 break;
341 201 case 'manage_workspace':
@@ -340,29 +200,8 @@
340 200 break;
341 201 case 'manage_workspace':
342 202 $data = $this->wdkit_manage_workspace();
343 203 break;
344 - case 'widget_browse_page':
345 - $data = apply_filters( 'wp_wdkit_widget_ajax', 'widget_browse_page' );
346 - break;
347 - case 'wkit_create_widget':
348 - $data = apply_filters( 'wp_wdkit_widget_ajax', 'wkit_create_widget' );
349 - break;
350 - case 'wkit_import_widget':
351 - $data = apply_filters( 'wp_wdkit_widget_ajax', 'wkit_import_widget' );
352 - break;
353 - case 'wkit_export_widget':
354 - $data = apply_filters( 'wp_wdkit_widget_ajax', 'wkit_export_widget' );
355 - break;
356 - case 'wkit_delete_widget':
357 - $data = apply_filters( 'wp_wdkit_widget_ajax', 'wkit_delete_widget' );
358 - break;
359 - case 'wkit_widget_preview':
360 - $data = apply_filters( 'wp_wdkit_widget_ajax', 'wkit_widget_preview' );
361 - break;
362 - case 'wkit_check_widget_versions':
363 - $data = apply_filters( 'wp_wdkit_widget_ajax', 'wkit_check_widget_versions' );
364 - break;
365 204 case 'wkit_manage_widget_workspace':
366 205 $data = $this->wdkit_manage_widget_workspace();
367 206 break;
368 207 case 'wkit_activate_key':
@@ -370,16 +209,25 @@
370 209 break;
371 210 case 'wkit_manage_widget_category':
372 211 $data = $this->wdkit_manage_widget_category();
373 212 break;
374 - case 'wkit_widget_json':
375 - $data = $this->wkit_widget_json();
213 + case 'wkit_create_widget':
214 + $data = $this->wdkit_create_widget();
376 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;
377 225 case 'wkit_download_widget':
378 226 $data = $this->wdkit_download_widget();
379 227 break;
380 228 case 'wkit_public_download_widget':
381 - $data = apply_filters( 'wp_wdkit_widget_ajax', 'wkit_public_download_widget' );
229 + $data = $this->wdkit_public_download_widget();
382 230 break;
383 231 case 'wkit_add_widget':
384 232 $data = $this->wdkit_add_widget();
385 233 break;
@@ -400,33 +248,14 @@
400 248 break;
401 249 case 'sync_licence':
402 250 $data = $this->wdkit_sync_licence_key();
403 251 break;
404 - case 'get_wkit_version':
405 - $data = $this->wdkit_prev_version();
406 - break;
407 - case 'rollback_wdkit':
408 - $data = $this->wdkit_rollback_check();
409 - break;
410 252 case 'wkit_logout':
411 253 $data = $this->wdkit_logout();
412 254 break;
413 - case 'wkit_white_label':
414 - $this->wkit_white_label();
415 - break;
416 - case 'wkit_reset_wl':
417 - $data = $this->wkit_reset_wl();
418 - break;
419 - case 'wdkit_dark_mode':
420 - $data = $this->wdkit_dark_mode();
421 - break;
422 - case 'wdkit_get_workspace_data':
423 - $data = $this->wdkit_get_workspace_data();
424 - break;
425 255 }
426 256
427 257 $this->wdkit_success_msg( $data );
428 - // wp_die();
429 258 }
430 259
431 260 /**
432 261 *
@@ -490,9 +319,41 @@
490 319 );
491 320 }
492 321
493 322 /**
323 + * This Function is used for API call
494 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 + *
495 356 * It is Use for handle onboarding data.
496 357 *
497 358 * @since 1.0.9
498 359 */
@@ -502,9 +363,8 @@
502 363
503 364 $elementor_plugin = isset( $_POST['elementor_plugin'] ) ? (int) sanitize_text_field( wp_unslash( $_POST['elementor_plugin'] ) ) : 0;
504 365 $tpag_plugin = isset( $_POST['tpag_plugin'] ) ? (int) sanitize_text_field( wp_unslash( $_POST['tpag_plugin'] ) ) : 0;
505 366 $bricks_theme = isset( $_POST['bricks_theme'] ) ? (int) sanitize_text_field( wp_unslash( $_POST['bricks_theme'] ) ) : 0;
506 - $site_info = isset( $_POST['info'] ) ? sanitize_text_field( wp_unslash( $_POST['info'] ) ) : false;
507 367
508 368 $server_software = ! empty( $_SERVER['SERVER_SOFTWARE'] ) ? sanitize_text_field( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) ) : '';
509 369
510 370 $web_server = $server_software;
@@ -543,27 +403,23 @@
543 403 'tpag_install' => $tpag_plugin,
544 404 'bricks_install' => $bricks_theme,
545 405 );
546 406
547 - if ( ! empty( $site_info ) ) {
548 - $final = array(
549 - 'web_server' => $web_server,
550 - 'memory_limit' => $memory_limit,
551 - 'max_execution_time' => $max_execution_time,
552 - 'php_version' => $php_version,
553 - 'wp_version' => $wp_version,
554 - 'email' => $email,
555 - 'site_url' => $siteurl,
556 - 'site_language' => $language,
557 - 'theme' => $theme,
558 - 'plugins' => $act_plugin,
559 - 'basic_requirements' => $basic_requirements,
560 - 'page_template' => $page_template,
561 - 'page_builder' => $page_builder,
562 - );
563 - } else {
564 - $final = array();
565 - }
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 + );
566 422
567 423 $response = wp_remote_post(
568 424 $this->wdkit_onbording_api,
569 425 array(
@@ -616,11 +472,172 @@
616 472 }
617 473
618 474 /**
619 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 + *
620 637 * It is Use for get meta data for non login user
621 638 *
622 - * @since 1.0.0
639 + * @since 1.0.0\
623 640 */
624 641 protected function wdkit_meta_data() {
625 642 $type = isset( $_POST['meta_type'] ) ? sanitize_text_field( wp_unslash( $_POST['meta_type'] ) ) : '';
626 643 $data = array( 'type' => $type );
@@ -664,42 +681,13 @@
664 681 }
665 682
666 683 /**
667 684 *
668 - * It is Use for get activate license key data from tpae and nexter blocks.
669 - *
670 - * @since 1.1.6
671 - */
672 - protected function wkit_manage_license_data() {
673 - $manage_licence = array();
674 - $theplus_active_check = is_plugin_active( 'the-plus-addons-for-elementor-page-builder/theplus_elementor_addon.php' );
675 - $nexter_active_check = is_plugin_active( 'the-plus-addons-for-block-editor/the-plus-addons-for-block-editor.php' );
676 -
677 - $theplus_licence = get_option( 'tpaep_licence_data', array() );
678 -
679 - if ( ! empty( $theplus_active_check ) && ! empty( $theplus_licence ) ) {
680 - $manage_licence['tpae'] = $theplus_licence;
681 - }
682 -
683 - $nexter_licence = get_option( 'tpgb_activate', array() );
684 -
685 - if ( ! empty( $nexter_active_check ) && ! empty( $nexter_licence ) && ! empty( $nexter_licence['tpgb_activate_key'] ) ) {
686 - $tpgb_license_status = get_option( 'tpgbp_license_status', array() );
687 - $tpgb_license_status['license_key'] = $nexter_licence['tpgb_activate_key'];
688 - $manage_licence['tpag'] = $tpgb_license_status;
689 - }
690 -
691 - return $manage_licence;
692 - }
693 -
694 - /**
695 - *
696 685 * It is Use for get all info of user.
697 686 *
698 687 * @since 1.0.0
699 688 */
700 689 protected function wdkit_get_user_info() {
701 - $token = isset( $_POST['token'] ) ? wp_unslash( $_POST['token'] ) : false;
702 690 $email = isset( $_POST['email'] ) ? strtolower( sanitize_email( wp_unslash( $_POST['email'] ) ) ) : false;
703 691 $builder = isset( $_POST['builder'] ) ? strtolower( sanitize_text_field( wp_unslash( $_POST['builder'] ) ) ) : '';
704 692
705 693 $site_url = isset( $_POST['site_url'] ) ? esc_url_raw( wp_unslash( $_POST['site_url'] ) ) : '';
@@ -705,9 +693,9 @@
705 693 $site_url = isset( $_POST['site_url'] ) ? esc_url_raw( wp_unslash( $_POST['site_url'] ) ) : '';
706 694
707 695 $response = array();
708 696
709 - if ( empty( $token ) ) {
697 + if ( empty( $email ) ) {
710 698 $response = array(
711 699 'success' => false,
712 700 'message' => $this->e_msg_login,
713 701 'description' => $this->e_desc_login,
@@ -716,10 +704,10 @@
716 704 wp_send_json( $response );
717 705 wp_die();
718 706 }
719 707
720 - // $token = $this->wdkit_login_user_token( $email );
721 - $args = array(
708 + $token = $this->wdkit_login_user_token( $email );
709 + $args = array(
722 710 'token' => $token,
723 711 'builder' => $builder,
724 712 'site_url' => $site_url,
725 713 );
@@ -730,32 +718,13 @@
730 718
731 719 /**Condtion user for user logout & expire token*/
732 720 if ( 'Token is Expired' === $status || 'Authorization Token not found' === $status ) {
733 721 delete_transient( 'wdkit_auth_' . $email );
734 - // Clear stored license data when token expires so banner shows again
735 - delete_option( 'wdkit_licence_data' );
736 722 }
737 723
738 - if ( empty( $response ) ) {
739 - $response['login_reset'] = 'yes';
740 - }
724 + $response['Setting'] = $this->wkit_get_settings_panel();
725 + $response['widget_list'] = $this->wkit_manage_widget_sequence( $response );
741 726
742 - // Store WDesignKit license data locally if present in response
743 - if ( ! empty( $response['credits']['wdkit_licence'] ) && is_array( $response['credits']['wdkit_licence'] ) ) {
744 - $wdkit_licence = $response['credits']['wdkit_licence'];
745 - // Handle serialized data
746 - if ( is_string( $wdkit_licence ) && is_serialized( $wdkit_licence ) ) {
747 - $wdkit_licence = unserialize( $wdkit_licence );
748 - }
749 - if ( ! empty( $wdkit_licence ) && is_array( $wdkit_licence ) ) {
750 - update_option( 'wdkit_licence_data', $wdkit_licence );
751 - }
752 - }
753 -
754 - $response['Setting'] = $this->wkit_get_settings_panel();
755 - $response['widget_list'] = $this->wkit_manage_widget_sequence( $response );
756 - $response['manage_licence'] = $this->wkit_manage_license_data();
757 -
758 727 $response = array(
759 728 'data' => $response,
760 729 'success' => true,
761 730 );
@@ -788,9 +757,9 @@
788 757 $builder_name = ! empty( $value['builder_name'] ) ? $value['builder_name'] : '';
789 758 $w_id = ! empty( $value['w_id'] ) ? $value['w_id'] : '';
790 759
791 760 if ( ! empty( $builder_name ) ) {
792 - $idx_builder[ $w_id ] = strtolower( str_replace( ' ', '_', trim( $builder_name ) ) );
761 + $idx_builder[ $w_id ] = strtolower( $builder_name );
793 762 }
794 763 }
795 764
796 765 foreach ( $server_list as $index => $value ) {
@@ -802,9 +771,9 @@
802 771
803 772 $count = 0;
804 773
805 774 foreach ( $local_list as $key => $value ) {
806 - $widget_id = ! empty( $value['widgetdata']['widget_id'] ) ? $value['widgetdata']['widget_id'] : '';
775 + $widget_id = ! empty( $value['widgetdata']['widget_id'] ) ? $value['widgetdata']['widget_id'] : '';
807 776 $allow_push = isset( $value['widgetdata']['allow_push'] ) ? $value['widgetdata']['allow_push'] : true;
808 777
809 778 if ( in_array( $widget_id, $server_w_unique ) ) {
810 779
@@ -824,9 +793,9 @@
824 793 unset( $server_list[ $index ] );
825 794 } else {
826 795 $local_list[ $key ]['widgetdata']['builder'] = $local_list[ $key ]['widgetdata']['type'];
827 796 $local_list[ $key ]['widgetdata']['w_unique'] = $local_list[ $key ]['widgetdata']['widget_id'];
828 - $local_list[ $key ]['widgetdata']['allow_push'] = $allow_push;
797 + $local_list[ $key ]['widgetdata']['allow_push'] = $allow_push;
829 798 $local_list[ $key ]['widgetdata']['image'] = ! empty( $local_list[ $key ]['widgetdata']['w_image'] ) ? $local_list[ $key ]['widgetdata']['w_image'] : $placeholderimg;
830 799 $local_list[ $key ]['widgetdata']['is_activated'] = 'active';
831 800
832 801 $local_list[ $key ]['widgetdata']['type'] = 'plugin';
@@ -849,9 +818,9 @@
849 818 if ( 'active' === $is_activated ) {
850 819 ++$count;
851 820 }
852 821
853 - if ( ( $count > $credits ) && ( 'unlimited' !== $credits ) ) {
822 + if ( ($count > $credits) && ('unlimited' !== $credits)) {
854 823 $final[ $key ]['is_activated'] = 'deactive';
855 824 }
856 825
857 826 if ( ! empty( $self['is_activated'] ) && 'active' !== $self['is_activated'] ) {
@@ -883,14 +852,48 @@
883 852 $args = $this->wdkit_parse_args( $_POST );
884 853
885 854 $response = WDesignKit_Data_Query::get_data( 'browse_page', $args );
886 855
887 - $manage_licence = array();
888 - $manage_licence['theplus_elementor_addon'] = ! empty( defined( 'THEPLUS_VERSION' ) ) ? true : false;
889 - $manage_licence['tpag'] = ! empty( defined( 'TPGBP_VERSION' ) ) ? true : false;
890 - $manage_licence['elementor-pro'] = ! empty( defined( 'ELEMENTOR_PRO_VERSION' ) ) ? true : false;
891 - $response['manage_licence'] = $manage_licence;
856 + wp_send_json( $response );
857 + wp_die();
858 + }
892 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 +
893 896 wp_send_json( $response );
894 897 wp_die();
895 898 }
896 899
@@ -949,12 +952,9 @@
949 952 *
950 953 * @since 1.0.0
951 954 */
952 955 protected function wdkit_put_save_template() {
953 - $email = isset( $_POST['email'] ) ? strtolower( sanitize_email( wp_unslash( $_POST['email'] ) ) ) : false;
954 - $post_id = isset( $_POST['post_id'] ) ? sanitize_text_field( wp_unslash( $_POST['post_id'] ) ) : '';
955 - $builder = isset( $_POST['builder'] ) ? sanitize_text_field( wp_unslash( $_POST['builder'] ) ) : '';
956 -
956 + $email = isset( $_POST['email'] ) ? strtolower( sanitize_email( wp_unslash( $_POST['email'] ) ) ) : false;
957 957 $response = '';
958 958
959 959 if ( empty( $email ) ) {
960 960 $response = array(
@@ -972,19 +972,14 @@
972 972 $args = $this->wdkit_parse_args( $_POST );
973 973 $args['token'] = $this->wdkit_login_user_token( $email );
974 974 unset( $args['email'] );
975 975
976 - if( 'elementor' === $builder ){
977 - $args['data'] = base64_decode( $args['data'] );
978 - } else if ( 'gutenberg' === $builder ) {
979 - $args['data'] = base64_decode( $args['data'] );
980 - }
981 -
982 976 global $post;
983 977
978 + $post_id = get_the_ID();
984 979 $custom_fields = array();
985 980 if ( ! empty( $post_id ) ) {
986 - $meta_fields = get_post_custom( $post_id );
981 + $meta_fields = get_post_custom( get_the_ID() );
987 982
988 983 foreach ( $meta_fields as $key => $value ) {
989 984 if ( str_contains( $key, 'nxt-' ) ) {
990 985 $custom_fields[ $key ] = $value;
@@ -1005,1023 +1000,8 @@
1005 1000 }
1006 1001
1007 1002 /**
1008 1003 *
1009 - * It is Use for update save template image.
1010 - *
1011 - * @since 2.0.6
1012 - */
1013 - protected function wdkit_update_save_temp_image() {
1014 - $temp_content = isset( $_POST['temp_content'] ) ? esc_url_raw( $_POST['temp_content'] ) : '';
1015 - $content_name = isset( $_POST['content_name'] ) ? sanitize_text_field( $_POST['content_name'] ) : '';
1016 - $token = isset( $_POST['token'] ) ? sanitize_text_field( $_POST['token'] ) : '';
1017 - $user_type = isset( $_POST['user_type'] ) ? sanitize_text_field( $_POST['user_type'] ) : '';
1018 - $type = isset( $_POST['content_type'] ) ? sanitize_text_field( $_POST['content_type'] ) : '';
1019 - $id = isset( $_POST['id'] ) ? sanitize_text_field( $_POST['id'] ) : '';
1020 - if ( empty( $temp_content ) || empty( $user_type ) || empty( $id ) || empty( $token ) ) {
1021 - $response = array(
1022 - 'message' => __( 'Data not found', 'wdesignkit' ),
1023 - 'description' => __( 'Data not found', 'wdesignkit' ),
1024 - 'success' => false,
1025 - );
1026 - } else {
1027 - $temp_content = str_replace( '\\', '', $temp_content );
1028 - $temp_content = wp_remote_get( $temp_content )['body'];
1029 - $temp_content = base64_encode( $temp_content );
1030 -
1031 - $args = array(
1032 - 'token' => $token,
1033 - 'template_id' => $id,
1034 - 'name' => $content_name,
1035 - 'content' => $temp_content,
1036 - 'type' => $type,
1037 - );
1038 -
1039 - $response = $this->wkit_api_call( $args, 'save_images' );
1040 - $success = ! empty( $response['success'] ) ? $response['success'] : false;
1041 -
1042 - if ( $success ) {
1043 - $response = array(
1044 - 'data' => $response['data'],
1045 - 'success' => true,
1046 - );
1047 - } else {
1048 - $response = array(
1049 - 'message' => __( 'API Error', 'wdesignkit' ),
1050 - 'description' => __( 'API Error', 'wdesignkit' ),
1051 - 'data' => $response['data'],
1052 - 'success' => false,
1053 - );
1054 - }
1055 - }
1056 -
1057 - wp_send_json( $response );
1058 - wp_die();
1059 - }
1060 -
1061 - /**
1062 - *
1063 - * Get Elementor Global color and Typography.
1064 - *
1065 - * @since 1.1.16
1066 - */
1067 - protected function wdkit_get_global_val() {
1068 -
1069 - $builder = isset( $_POST['builder'] ) ? strtolower( sanitize_text_field( $_POST['builder'] ) ) : '';
1070 -
1071 - if ( 'elementor' === $builder ) {
1072 - $kit_id = get_option( 'elementor_active_kit' );
1073 - if ( empty( $kit_id ) ) {
1074 - $response = array(
1075 - 'message' => __( 'Elementor kit not found', 'wdesignkit' ),
1076 - 'description' => __( 'No active Elementor kit found', 'wdesignkit' ),
1077 - 'success' => false,
1078 - );
1079 -
1080 - wp_send_json( $response );
1081 - wp_die();
1082 - }
1083 -
1084 - $kit_meta = get_post_meta( $kit_id, '_elementor_page_settings', true );
1085 - if ( empty( $kit_meta['system_colors'] ) ) {
1086 - $static_meta = array(
1087 - 'system_colors' => array(
1088 - 0 => array(
1089 - '_id' => 'primary',
1090 - 'title' => 'Primary',
1091 - 'color' => '#6EC1E4',
1092 - ),
1093 - 1 => array(
1094 - '_id' => 'secondary',
1095 - 'title' => 'Secondary',
1096 - 'color' => '#54595F',
1097 - ),
1098 - 2 => array(
1099 - '_id' => 'text',
1100 - 'title' => 'Text',
1101 - 'color' => '#7A7A7A',
1102 - ),
1103 - 3 => array(
1104 - '_id' => 'accent',
1105 - 'title' => 'Accent',
1106 - 'color' => '#61CE70',
1107 - ),
1108 - ),
1109 - 'custom_colors' => array(),
1110 - 'system_typography' => array(
1111 - 0 => array(
1112 - '_id' => 'primary',
1113 - 'title' => 'Primary',
1114 - 'typography_typography' => 'custom',
1115 - 'typography_font_family' => 'Roboto',
1116 - 'typography_font_weight' => '600',
1117 - ),
1118 - 1 => array(
1119 - '_id' => 'secondary',
1120 - 'title' => 'Secondary',
1121 - 'typography_typography' => 'custom',
1122 - 'typography_font_family' => 'Roboto Slab',
1123 - 'typography_font_weight' => '400',
1124 - ),
1125 - 2 => array(
1126 - '_id' => 'text',
1127 - 'title' => 'Text',
1128 - 'typography_typography' => 'custom',
1129 - 'typography_font_family' => 'Roboto',
1130 - 'typography_font_weight' => '400',
1131 - ),
1132 - 3 => array(
1133 - '_id' => 'accent',
1134 - 'title' => 'Accent',
1135 - 'typography_typography' => 'custom',
1136 - 'typography_font_family' => 'Roboto',
1137 - 'typography_font_weight' => '500',
1138 - ),
1139 - ),
1140 - 'custom_typography' => array(),
1141 - 'default_generic_fonts' => 'Sans-serif',
1142 - 'site_name' => ! empty( get_bloginfo( 'name' ) ) ? get_bloginfo( 'name' ) : '',
1143 - 'page_title_selector' => 'h1.entry-title',
1144 - 'activeItemIndex' => 1,
1145 - 'viewport_md' => 768,
1146 - 'viewport_lg' => 1025,
1147 - );
1148 -
1149 - $kit_meta = $static_meta;
1150 - update_post_meta( $kit_id, '_elementor_page_settings', $kit_meta );
1151 - }
1152 -
1153 - $system_colors = ! empty( $kit_meta['system_colors'] ) ? $kit_meta['system_colors'] : array();
1154 - $custom_colors = ! empty( $kit_meta['custom_colors'] ) ? $kit_meta['custom_colors'] : array();
1155 - $system_typography = ! empty( $kit_meta['system_typography'] ) ? $kit_meta['system_typography'] : array();
1156 - $custom_typography = ! empty( $kit_meta['custom_typography'] ) ? $kit_meta['custom_typography'] : array();
1157 -
1158 - $color_array = array_merge( $system_colors, $custom_colors );
1159 - $typo_array = array_merge( $system_typography, $custom_typography );
1160 -
1161 - $global_data = array(
1162 - 'color' => $color_array,
1163 - 'typography' => $typo_array,
1164 - );
1165 -
1166 - $response = array(
1167 - 'message' => __( 'Global data Found', 'wdesignkit' ),
1168 - 'description' => __( 'Global Color and Typography found', 'wdesignkit' ),
1169 - 'data' => $global_data,
1170 - 'success' => true,
1171 - );
1172 -
1173 - } elseif ( 'gutenberg' === $builder ) {
1174 -
1175 - $plus_settings = get_option( 'tpgb_global_options', false );
1176 - $plus_settings = ! empty( $plus_settings ) ? json_decode( $plus_settings, true ) : json_decode( '[]' );
1177 -
1178 - if ( empty( $plus_settings ) ) {
1179 -
1180 - $static_meta = array(
1181 - 'active' => 'preset1',
1182 - 'darkMode' => 'none',
1183 - 'presets' => array(
1184 - 'preset1' => array(
1185 - 'name' => 'Preset 1',
1186 - 'key' => 'preset1',
1187 - 'colors' => array(
1188 - array(
1189 - 'label' => 'Primary',
1190 - 'value' => '#8072FC',
1191 - ),
1192 - array(
1193 - 'label' => 'Secondary',
1194 - 'value' => '#6FC784',
1195 - ),
1196 - array(
1197 - 'label' => 'Tertiary',
1198 - 'value' => '#FF5A6E',
1199 - ),
1200 - array(
1201 - 'label' => 'Accent',
1202 - 'value' => '#F3F3F3',
1203 - ),
1204 - array(
1205 - 'label' => 'Background',
1206 - 'value' => '#888888',
1207 - ),
1208 - ),
1209 - 'gradient' => array(
1210 - array(
1211 - 'label' => 'Primary',
1212 - 'value' => 'linear-gradient(135deg,rgb(8,148,229) 0%,rgb(155,81,224) 100%)',
1213 - ),
1214 -
1215 - array(
1216 - 'label' => 'Secondary',
1217 - 'value' => 'linear-gradient(135deg,rgb(8,148,229) 0%,rgb(155,81,224) 100%)',
1218 - ),
1219 -
1220 - array(
1221 - 'label' => 'Tertiary',
1222 - 'value' => 'linear-gradient(135deg,rgb(8,148,229) 0%,rgb(155,81,224) 100%)',
1223 - ),
1224 -
1225 - array(
1226 - 'label' => 'Accent',
1227 - 'value' => 'linear-gradient(135deg,rgb(8,148,229) 0%,rgb(155,81,224) 100%)',
1228 - ),
1229 -
1230 - array(
1231 - 'label' => 'Background',
1232 - 'value' => 'linear-gradient(135deg,rgb(8,148,229) 0%,rgb(155,81,224) 100%)',
1233 - ),
1234 - ),
1235 - 'spacing' => array(
1236 - array(
1237 - 'label' => 'Large',
1238 - 'value' => array(
1239 - 'md' => 70,
1240 - 'unit' => 'px',
1241 - ),
1242 - ),
1243 - array(
1244 - 'label' => 'Medium',
1245 - 'value' => array(
1246 - 'md' => 40,
1247 - 'unit' => 'px',
1248 - ),
1249 - ),
1250 - array(
1251 - 'label' => 'Small',
1252 - 'value' => array(
1253 - 'md' => 20,
1254 - 'unit' => 'px',
1255 - ),
1256 -
1257 - ),
1258 - ),
1259 - 'typography' => array(
1260 - array(
1261 - 'label' => 'Display Text',
1262 - 'value' => array(
1263 - 'openTypography' => 1,
1264 - 'size' => array(
1265 - 'md' => 65,
1266 - 'unit' => 'px',
1267 - ),
1268 - 'height' => array(
1269 - 'md' => 75,
1270 - 'unit' => 'px',
1271 - ),
1272 - 'fontFamily' => array(
1273 - 'family' => 'Roboto',
1274 - 'type' => 'sans-serif',
1275 - 'fontWeight' => 700,
1276 - ),
1277 - 'spacing' => array(
1278 - 'md' => 0,
1279 - 'unit' => 'px',
1280 - ),
1281 - ),
1282 - ),
1283 - array(
1284 - 'label' => 'Headline',
1285 - 'value' => array(
1286 - 'openTypography' => 1,
1287 - 'size' => array(
1288 - 'md' => 45,
1289 - 'unit' => 'px',
1290 - ),
1291 - 'height' => array(
1292 - 'md' => 60,
1293 - 'unit' => 'px',
1294 - ),
1295 - 'fontFamily' => array(
1296 - 'family' => 'Roboto',
1297 - 'type' => 'sans-serif',
1298 - 'fontWeight' => 700,
1299 - ),
1300 - 'spacing' => array(
1301 - 'md' => 0,
1302 - 'unit' => 'px',
1303 - ),
1304 - ),
1305 - ),
1306 - array(
1307 - 'label' => 'Sub Headline',
1308 - 'value' => array(
1309 - 'openTypography' => 1,
1310 - 'size' => array(
1311 - 'md' => 38,
1312 - 'unit' => 'px',
1313 - ),
1314 - 'height' => array(
1315 - 'md' => 45,
1316 - 'unit' => 'px',
1317 - ),
1318 - 'fontFamily' => array(
1319 - 'family' => 'Roboto',
1320 - 'type' => 'sans-serif',
1321 - 'fontWeight' => 500,
1322 - ),
1323 - 'spacing' => array(
1324 - 'md' => 0,
1325 - 'unit' => 'px',
1326 - ),
1327 - ),
1328 - ),
1329 - array(
1330 - 'label' => 'Title 1',
1331 - 'value' => array(
1332 - 'openTypography' => 1,
1333 - 'size' => array(
1334 - 'md' => 30,
1335 - 'unit' => 'px',
1336 - ),
1337 - 'height' => array(
1338 - 'md' => 40,
1339 - 'unit' => 'px',
1340 - ),
1341 - 'fontFamily' => array(
1342 - 'family' => 'Roboto',
1343 - 'type' => 'sans-serif',
1344 - 'fontWeight' => 500,
1345 - ),
1346 - 'spacing' => array(
1347 - 'md' => 0,
1348 - 'unit' => 'px',
1349 - ),
1350 - ),
1351 - ),
1352 - array(
1353 - 'label' => 'Title 2',
1354 - 'value' => array(
1355 - 'openTypography' => 1,
1356 - 'size' => array(
1357 - 'md' => 25,
1358 - 'unit' => 'px',
1359 - ),
1360 - 'height' => array(
1361 - 'md' => 30,
1362 - 'unit' => 'px',
1363 - ),
1364 - 'fontFamily' => array(
1365 - 'family' => 'Roboto',
1366 - 'type' => 'sans-serif',
1367 - 'fontWeight' => 400,
1368 - ),
1369 - 'spacing' => array(
1370 - 'md' => 0,
1371 - 'unit' => 'px',
1372 - ),
1373 - ),
1374 - ),
1375 - array(
1376 - 'label' => 'Body',
1377 - 'value' => array(
1378 - 'openTypography' => 1,
1379 - 'size' => array(
1380 - 'md' => 17,
1381 - 'unit' => 'px',
1382 - ),
1383 - 'height' => array(
1384 - 'md' => 22,
1385 - 'unit' => 'px',
1386 - ),
1387 - 'fontFamily' => array(
1388 - 'family' => 'Roboto',
1389 - 'type' => 'sans-serif',
1390 - 'fontWeight' => 400,
1391 - ),
1392 - 'spacing' => array(
1393 - 'md' => 0,
1394 - 'unit' => 'px',
1395 - ),
1396 - ),
1397 - ),
1398 - array(
1399 - 'label' => 'Captions',
1400 - 'value' => array(
1401 - 'openTypography' => 1,
1402 - 'size' => array(
1403 - 'md' => 13,
1404 - 'unit' => 'px',
1405 - ),
1406 - 'height' => array(
1407 - 'md' => 16,
1408 - 'unit' => 'px',
1409 - ),
1410 - 'fontFamily' => array(
1411 - 'family' => 'Roboto',
1412 - 'type' => 'sans-serif',
1413 - 'fontWeight' => 400,
1414 - ),
1415 - 'spacing' => array(
1416 - 'md' => 0,
1417 - 'unit' => 'px',
1418 - ),
1419 - ),
1420 - ),
1421 - ),
1422 - 'boxshadow' => array(
1423 - array(
1424 - 'label' => 'Normal Shadow',
1425 - 'value' => array(
1426 - 'openShadow' => 1,
1427 - 'inset' => 0,
1428 - 'horizontal' => 2,
1429 - 'vertical' => 6,
1430 - 'blur' => 10,
1431 - 'spread' => 0,
1432 - 'color' => 'rgba(0,0,0,0.15)',
1433 - ),
1434 - ),
1435 - array(
1436 - 'label' => 'Hover Shadow',
1437 - 'value' => array(
1438 - 'openShadow' => 1,
1439 - 'inset' => 0,
1440 - 'horizontal' => 2,
1441 - 'vertical' => 5,
1442 - 'blur' => 14,
1443 - 'spread' => 3,
1444 - 'color' => 'rgba(0,0,0,0.2)',
1445 - ),
1446 - ),
1447 - ),
1448 - ),
1449 - 'preset2' => array(
1450 - 'name' => 'Preset 2',
1451 - 'key' => 'preset2',
1452 - 'colors' => array(
1453 - array(
1454 - 'label' => 'Primary',
1455 - 'value' => '#8072FC',
1456 - ),
1457 - array(
1458 - 'label' => 'Secondary',
1459 - 'value' => '#6FC784',
1460 - ),
1461 - array(
1462 - 'label' => 'Tertiary',
1463 - 'value' => '#FF5A6E',
1464 - ),
1465 - array(
1466 - 'label' => 'Accent',
1467 - 'value' => '#F3F3F3',
1468 - ),
1469 - array(
1470 - 'label' => 'Background',
1471 - 'value' => '#888888',
1472 - ),
1473 - ),
1474 - 'gradient' => array(
1475 - array(
1476 - 'label' => 'Primary',
1477 - 'value' => 'linear-gradient(135deg,rgb(8,148,229) 0%,rgb(155,81,224) 100%)',
1478 - ),
1479 -
1480 - array(
1481 - 'label' => 'Secondary',
1482 - 'value' => 'linear-gradient(135deg,rgb(8,148,229) 0%,rgb(155,81,224) 100%)',
1483 - ),
1484 -
1485 - array(
1486 - 'label' => 'Tertiary',
1487 - 'value' => 'linear-gradient(135deg,rgb(8,148,229) 0%,rgb(155,81,224) 100%)',
1488 - ),
1489 -
1490 - array(
1491 - 'label' => 'Accent',
1492 - 'value' => 'linear-gradient(135deg,rgb(8,148,229) 0%,rgb(155,81,224) 100%)',
1493 - ),
1494 -
1495 - array(
1496 - 'label' => 'Background',
1497 - 'value' => 'linear-gradient(135deg,rgb(8,148,229) 0%,rgb(155,81,224) 100%)',
1498 - ),
1499 - ),
1500 - 'spacing' => array(
1501 - array(
1502 - 'label' => 'Large',
1503 - 'value' => array(
1504 - 'md' => 70,
1505 - 'unit' => 'px',
1506 - ),
1507 - ),
1508 - array(
1509 - 'label' => 'Medium',
1510 - 'value' => array(
1511 - 'md' => 40,
1512 - 'unit' => 'px',
1513 - ),
1514 - ),
1515 - array(
1516 - 'label' => 'Small',
1517 - 'value' => array(
1518 - 'md' => 20,
1519 - 'unit' => 'px',
1520 - ),
1521 -
1522 - ),
1523 - ),
1524 - 'typography' => array(
1525 - array(
1526 - 'label' => 'Display Text',
1527 - 'value' => array(
1528 - 'openTypography' => 1,
1529 - 'size' => array(
1530 - 'md' => 65,
1531 - 'unit' => 'px',
1532 - ),
1533 - 'height' => array(
1534 - 'md' => 75,
1535 - 'unit' => 'px',
1536 - ),
1537 - 'fontFamily' => array(
1538 - 'family' => 'Roboto',
1539 - 'type' => 'sans-serif',
1540 - 'fontWeight' => 700,
1541 - ),
1542 - 'spacing' => array(
1543 - 'md' => 0,
1544 - 'unit' => 'px',
1545 - ),
1546 - ),
1547 - ),
1548 - array(
1549 - 'label' => 'Headline',
1550 - 'value' => array(
1551 - 'openTypography' => 1,
1552 - 'size' => array(
1553 - 'md' => 45,
1554 - 'unit' => 'px',
1555 - ),
1556 - 'height' => array(
1557 - 'md' => 60,
1558 - 'unit' => 'px',
1559 - ),
1560 - 'fontFamily' => array(
1561 - 'family' => 'Roboto',
1562 - 'type' => 'sans-serif',
1563 - 'fontWeight' => 700,
1564 - ),
1565 - 'spacing' => array(
1566 - 'md' => 0,
1567 - 'unit' => 'px',
1568 - ),
1569 - ),
1570 - ),
1571 - array(
1572 - 'label' => 'Sub Headline',
1573 - 'value' => array(
1574 - 'openTypography' => 1,
1575 - 'size' => array(
1576 - 'md' => 38,
1577 - 'unit' => 'px',
1578 - ),
1579 - 'height' => array(
1580 - 'md' => 45,
1581 - 'unit' => 'px',
1582 - ),
1583 - 'fontFamily' => array(
1584 - 'family' => 'Roboto',
1585 - 'type' => 'sans-serif',
1586 - 'fontWeight' => 500,
1587 - ),
1588 - 'spacing' => array(
1589 - 'md' => 0,
1590 - 'unit' => 'px',
1591 - ),
1592 - ),
1593 - ),
1594 - array(
1595 - 'label' => 'Title 1',
1596 - 'value' => array(
1597 - 'openTypography' => 1,
1598 - 'size' => array(
1599 - 'md' => 30,
1600 - 'unit' => 'px',
1601 - ),
1602 - 'height' => array(
1603 - 'md' => 40,
1604 - 'unit' => 'px',
1605 - ),
1606 - 'fontFamily' => array(
1607 - 'family' => 'Roboto',
1608 - 'type' => 'sans-serif',
1609 - 'fontWeight' => 500,
1610 - ),
1611 - 'spacing' => array(
1612 - 'md' => 0,
1613 - 'unit' => 'px',
1614 - ),
1615 - ),
1616 - ),
1617 - array(
1618 - 'label' => 'Title 2',
1619 - 'value' => array(
1620 - 'openTypography' => 1,
1621 - 'size' => array(
1622 - 'md' => 25,
1623 - 'unit' => 'px',
1624 - ),
1625 - 'height' => array(
1626 - 'md' => 30,
1627 - 'unit' => 'px',
1628 - ),
1629 - 'fontFamily' => array(
1630 - 'family' => 'Roboto',
1631 - 'type' => 'sans-serif',
1632 - 'fontWeight' => 400,
1633 - ),
1634 - 'spacing' => array(
1635 - 'md' => 0,
1636 - 'unit' => 'px',
1637 - ),
1638 - ),
1639 - ),
1640 - array(
1641 - 'label' => 'Body',
1642 - 'value' => array(
1643 - 'openTypography' => 1,
1644 - 'size' => array(
1645 - 'md' => 17,
1646 - 'unit' => 'px',
1647 - ),
1648 - 'height' => array(
1649 - 'md' => 22,
1650 - 'unit' => 'px',
1651 - ),
1652 - 'fontFamily' => array(
1653 - 'family' => 'Roboto',
1654 - 'type' => 'sans-serif',
1655 - 'fontWeight' => 400,
1656 - ),
1657 - 'spacing' => array(
1658 - 'md' => 0,
1659 - 'unit' => 'px',
1660 - ),
1661 - ),
1662 - ),
1663 - array(
1664 - 'label' => 'Captions',
1665 - 'value' => array(
1666 - 'openTypography' => 1,
1667 - 'size' => array(
1668 - 'md' => 13,
1669 - 'unit' => 'px',
1670 - ),
1671 - 'height' => array(
1672 - 'md' => 16,
1673 - 'unit' => 'px',
1674 - ),
1675 - 'fontFamily' => array(
1676 - 'family' => 'Roboto',
1677 - 'type' => 'sans-serif',
1678 - 'fontWeight' => 400,
1679 - ),
1680 - 'spacing' => array(
1681 - 'md' => 0,
1682 - 'unit' => 'px',
1683 - ),
1684 - ),
1685 - ),
1686 - ),
1687 - 'boxshadow' => array(
1688 - array(
1689 - 'label' => 'Normal Shadow',
1690 - 'value' => array(
1691 - 'openShadow' => 1,
1692 - 'inset' => 0,
1693 - 'horizontal' => 2,
1694 - 'vertical' => 6,
1695 - 'blur' => 10,
1696 - 'spread' => 0,
1697 - 'color' => 'rgba(0,0,0,0.15)',
1698 - ),
1699 - ),
1700 - array(
1701 - 'label' => 'Hover Shadow',
1702 - 'value' => array(
1703 - 'openShadow' => 1,
1704 - 'inset' => 0,
1705 - 'horizontal' => 2,
1706 - 'vertical' => 5,
1707 - 'blur' => 14,
1708 - 'spread' => 3,
1709 - 'color' => 'rgba(0,0,0,0.2)',
1710 - ),
1711 - ),
1712 - ),
1713 - ),
1714 - ),
1715 - 'globalContainer' => array(
1716 - 'md' => '',
1717 - 'unit' => 'px',
1718 - ),
1719 - );
1720 -
1721 - update_option( 'tpgb_global_options', json_encode( $static_meta ) );
1722 - $plus_settings = $static_meta;
1723 - }
1724 -
1725 - $active_id = ! empty( $plus_settings['active'] ) ? $plus_settings['active'] : '';
1726 - $preset_array = ! empty( $plus_settings['presets'] ) ? $plus_settings['presets'] : array();
1727 - $act_preset = ! empty( $plus_settings['presets'][ $active_id ] ) ? $plus_settings['presets'][ $active_id ] : array();
1728 -
1729 - foreach ( $act_preset['colors'] as $index => &$item ) {
1730 - $item['id'] = $index + 1;
1731 - }
1732 - unset( $item );
1733 -
1734 - foreach ( $act_preset['typography'] as $index => &$item ) {
1735 - $item['id'] = $index + 1;
1736 - }
1737 - unset( $item );
1738 -
1739 - $act_preset['color'] = $act_preset['colors'];
1740 - unset( $act_preset['colors'] );
1741 -
1742 - $response = array(
1743 - 'message' => __( 'Global data Found', 'wdesignkit' ),
1744 - 'description' => __( 'Global Color and Typography found', 'wdesignkit' ),
1745 - 'data' => $act_preset,
1746 - 'success' => true,
1747 - );
1748 - }
1749 -
1750 - wp_send_json( $response );
1751 - wp_die();
1752 - }
1753 -
1754 - /**
1755 - *
1756 - * Get site settings.
1757 - *
1758 - * @since 2.1.3
1759 - */
1760 - protected function wdkit_get_site_setting() {
1761 -
1762 - $kit_id = get_option( 'elementor_active_kit' );
1763 - if ( empty( $kit_id ) ) {
1764 - $response = array(
1765 - 'message' => __( 'Elementor kit not found', 'wdesignkit' ),
1766 - 'description' => __( 'No active Elementor kit found', 'wdesignkit' ),
1767 - 'success' => false,
1768 - );
1769 -
1770 - wp_send_json( $response );
1771 - wp_die();
1772 - }
1773 -
1774 - $kit_meta = get_post_meta( $kit_id, '_elementor_page_settings', true );
1775 -
1776 - $container_width = ! empty( $kit_meta['container_width'] ) ? $kit_meta['container_width'] : array();
1777 - $globals = ! empty( $kit_meta['__globals__'] ) ? $kit_meta['__globals__'] : array();
1778 - $body_background_color = ! empty( $kit_meta['body_background_color'] ) ? $kit_meta['body_background_color'] : array();
1779 -
1780 - $site_globals = array(
1781 - 'body_background_color' => $body_background_color,
1782 - 'container_width' => $container_width,
1783 - 'globals' => $globals,
1784 - );
1785 -
1786 - $response = array(
1787 - 'message' => __( 'Global data Found', 'wdesignkit' ),
1788 - 'description' => __( 'Global Color and Typography found', 'wdesignkit' ),
1789 - 'data' => $site_globals,
1790 - 'success' => true,
1791 - );
1792 -
1793 - wp_send_json( $response );
1794 - wp_die();
1795 - }
1796 -
1797 - /**
1798 - *
1799 - * update site settings.
1800 - *
1801 - * @since 2.1.3
1802 - */
1803 - protected function wdkit_update_site_setting() {
1804 -
1805 - $builder = ! empty( $_POST['builder'] ) ? sanitize_text_field( $_POST['builder'] ) : '';
1806 - $site_data = ! empty( $_POST['site_data'] ) ? json_decode( sanitize_text_field( wp_unslash( $_POST['site_data'] ) ), true ) : array();
1807 -
1808 - if ( 'elementor' == $builder ) {
1809 - $kit_id = get_option( 'elementor_active_kit' );
1810 - if ( ! $kit_id ) {
1811 - $response = array(
1812 - 'message' => __( 'Elementor kit not found', 'wdesignkit' ),
1813 - 'description' => __( 'No active Elementor kit found', 'wdesignkit' ),
1814 - 'success' => false,
1815 - );
1816 -
1817 - wp_send_json( $response );
1818 - wp_die();
1819 - }
1820 -
1821 - $kit_meta = get_post_meta( $kit_id, '_elementor_page_settings', true );
1822 - if ( empty( $kit_meta ) ) {
1823 - $response = array(
1824 - 'message' => __( 'Data Not Found', 'wdesignkit' ),
1825 - 'description' => __( 'No site data found in kit', 'wdesignkit' ),
1826 - 'success' => false,
1827 - );
1828 -
1829 - wp_send_json( $response );
1830 - wp_die();
1831 - }
1832 -
1833 - $kit_meta['container_width'] = ! empty( $site_data['container_width'] ) ? $site_data['container_width'] : array();
1834 - $kit_meta['__globals__'] = ! empty( $site_data['globals'] ) ? $site_data['globals'] : array();
1835 - $kit_meta['body_background_color'] = ! empty( $site_data['body_background_color'] ) ? $site_data['body_background_color'] : array();
1836 -
1837 - update_post_meta( $kit_id, '_elementor_page_settings', $kit_meta );
1838 -
1839 - $response = array(
1840 - 'message' => __( 'Site data Updated', 'wdesignkit' ),
1841 - 'description' => __( 'Site Globals Updated', 'wdesignkit' ),
1842 - 'success' => true,
1843 - );
1844 -
1845 - } elseif ( 'gutenberg' == $builder ) {
1846 - $plus_settings = get_option( 'tpgb_global_options' );
1847 -
1848 - $site_preset = json_decode( $plus_settings, true );
1849 - $site_preset['globalContainer'] = $site_data;
1850 -
1851 - update_option( 'tpgb_global_options', json_encode( $site_preset ) );
1852 -
1853 - $response = array(
1854 - 'message' => __( 'Site data Updated', 'wdesignkit' ),
1855 - 'description' => __( 'Site Globals Updated', 'wdesignkit' ),
1856 - 'success' => true,
1857 - );
1858 -
1859 - } else {
1860 - $response = array(
1861 - 'message' => __( 'Builder Not Found !', 'wdesignkit' ),
1862 - 'description' => __( 'Template Builder not Found', 'wdesignkit' ),
1863 - 'success' => true,
1864 - );
1865 - }
1866 -
1867 - wp_send_json( $response );
1868 - wp_die();
1869 - }
1870 -
1871 - /**
1872 - *
1873 - * Update Elementor Global color and Typography.
1874 - *
1875 - * @since 1.1.20
1876 - */
1877 - protected function wdkit_update_global_val() {
1878 -
1879 - $builder = ! empty( $_POST['builder'] ) ? sanitize_text_field( $_POST['builder'] ) : '';
1880 -
1881 - if ( 'elementor' == $builder ) {
1882 -
1883 - $g_color = ! empty( $_POST['g_color'] ) ? json_decode( sanitize_text_field( wp_unslash( $_POST['g_color'] ) ), true ) : array();
1884 - $g_typo = ! empty( $_POST['g_typography'] ) ? json_decode( sanitize_text_field( wp_unslash( $_POST['g_typography'] ) ), true ) : array();
1885 -
1886 - // Get colors from Elementor Site Kit
1887 - $kit_id = get_option( 'elementor_active_kit' );
1888 - if ( ! $kit_id ) {
1889 - $response = array(
1890 - 'message' => __( 'Elementor kit not found', 'wdesignkit' ),
1891 - 'description' => __( 'No active Elementor kit found', 'wdesignkit' ),
1892 - 'success' => false,
1893 - );
1894 -
1895 - wp_send_json( $response );
1896 - wp_die();
1897 - }
1898 -
1899 - $kit_meta = get_post_meta( $kit_id, '_elementor_page_settings', true );
1900 - if ( empty( $kit_meta ) ) {
1901 - $response = array(
1902 - 'message' => __( 'Data Not Found', 'wdesignkit' ),
1903 - 'description' => __( 'No meta data found in kit', 'wdesignkit' ),
1904 - 'success' => false,
1905 - );
1906 -
1907 - wp_send_json( $response );
1908 - wp_die();
1909 - }
1910 -
1911 - $kit_meta['custom_colors'] = array_merge( $g_color, $kit_meta['custom_colors'] );
1912 - $kit_meta['custom_typography'] = array_merge( $g_typo, $kit_meta['custom_typography'] );
1913 -
1914 - update_post_meta( $kit_id, '_elementor_page_settings', $kit_meta );
1915 -
1916 - $response = array(
1917 - 'message' => __( 'Global data Updated', 'wdesignkit' ),
1918 - 'description' => __( 'Global Color and Typography Updated', 'wdesignkit' ),
1919 - 'success' => true,
1920 - );
1921 -
1922 - } elseif ( 'gutenberg' == $builder ) {
1923 - $new_preset = ! empty( $_POST['new_preset'] ) ? json_decode( sanitize_text_field( wp_unslash( $_POST['new_preset'] ) ), true ) : array();
1924 - $new_preset_id = ! empty( $new_preset['key'] ) ? $new_preset['key'] : '';
1925 - $plus_settings = get_option( 'tpgb_global_options' );
1926 - $site_preset = json_decode( $plus_settings, true );
1927 -
1928 - $site_preset['presets'][ $new_preset_id ] = $new_preset;
1929 - $site_preset['active'] = $new_preset_id;
1930 -
1931 - update_option( 'tpgb_global_options', json_encode( $site_preset ) );
1932 -
1933 - $response = array(
1934 - 'message' => __( 'Global data Updated', 'wdesignkit' ),
1935 - 'description' => __( 'Global Color and Typography Updated', 'wdesignkit' ),
1936 - 'success' => true,
1937 - );
1938 -
1939 - } else {
1940 - $response = array(
1941 - 'message' => __( 'Builder Not Found !', 'wdesignkit' ),
1942 - 'description' => __( 'Template Builder not Found', 'wdesignkit' ),
1943 - 'success' => true,
1944 - );
1945 - }
1946 -
1947 - wp_send_json( $response );
1948 - wp_die();
1949 - }
1950 -
1951 - /**
1952 - *
1953 - * Create Gutenberg page and save for re-generate css file.
1954 - *
1955 - * @since 1.2.3
1956 - */
1957 - protected function wdkit_update_preset() {
1958 -
1959 - $act_type = ! empty( $_POST['act_type'] ) ? sanitize_text_field( $_POST['act_type'] ) : '';
1960 - $post_id = ! empty( $_POST['post_id'] ) ? sanitize_text_field( $_POST['post_id'] ) : '';
1961 -
1962 - if ( 'create' == $act_type ) {
1963 -
1964 - $page_id = wp_insert_post(
1965 - array(
1966 - 'post_title' => 'WDesignKit Gutenberg',
1967 - 'post_status' => 'publish',
1968 - 'post_type' => 'post',
1969 - 'post_name' => sanitize_title( 'wdesignkit' ),
1970 - 'post_content' => '<!-- wp:heading --><h2 class="wp-block-heading">Add Your Heading Text Here<h2><!-- /wp:heading -->',
1971 - 'meta_input' => array(
1972 - 'gutenberg_preview' => true,
1973 - '_wp_page_template' => 'default',
1974 - ),
1975 - )
1976 - );
1977 -
1978 - if ( is_wp_error( $page_id ) || ! $page_id ) {
1979 - $response = array(
1980 - 'success' => true,
1981 - 'message' => esc_html__( 'Page Not Found!', 'wdesignkit' ),
1982 - 'description' => esc_html__( 'Page Not Found!', 'wdesignkit' ),
1983 - );
1984 -
1985 - wp_send_json( $response );
1986 - wp_die();
1987 - }
1988 -
1989 - update_post_meta( $page_id, '_edit_lock', time() . ':1' );
1990 - update_post_meta( $page_id, '_edit_last', get_current_user_id() );
1991 -
1992 - $preview_url = admin_url( 'post.php?post=' . $page_id . '&action=edit' );
1993 -
1994 - $response = array(
1995 - 'success' => true,
1996 - 'post_id' => $page_id,
1997 - 'preview_url' => $preview_url,
1998 - 'message' => esc_html__( 'Page Created', 'wdesignkit' ),
1999 - 'description' => esc_html__( 'Page Created', 'wdesignkit' ),
2000 - );
2001 -
2002 - wp_send_json( $response );
2003 - wp_die();
2004 -
2005 - }
2006 -
2007 - if ( ! empty( $post_id ) && ( $act_type == 'remove' ) ) {
2008 -
2009 - wp_delete_post( $post_id, true );
2010 -
2011 - $response = array(
2012 - 'success' => true,
2013 - 'message' => esc_html__( 'post deleted', 'wdesignkit' ),
2014 - 'description' => esc_html__( 'post deleted', 'wdesignkit' ),
2015 - );
2016 -
2017 - wp_send_json( $response );
2018 - wp_die();
2019 - }
2020 - }
2021 -
2022 - /**
2023 - *
2024 1004 * It is For Find User Existing template List.
2025 1005 *
2026 1006 * @since 1.0.6
2027 1007 */
@@ -2048,39 +1028,16 @@
2048 1028 * @since 1.0.6
2049 1029 */
2050 1030 protected function wdkit_update_template() {
2051 1031 $array_data = array(
2052 - 'data' => isset( $_POST['data'] ) ? wp_unslash( $_POST['data'] ) : '',
2053 - 'post_id' => isset( $_POST['post_id'] ) ? sanitize_text_field( wp_unslash( $_POST['post_id'] ) ) : '',
2054 - 'token' => isset( $_POST['token'] ) ? sanitize_text_field( wp_unslash( $_POST['token'] ) ) : '',
2055 - 'type' => isset( $_POST['type'] ) ? sanitize_text_field( wp_unslash( $_POST['type'] ) ) : '',
2056 - 'id' => isset( $_POST['id'] ) ? sanitize_text_field( wp_unslash( $_POST['id'] ) ) : '',
2057 - 'global_data' => isset( $_POST['global_data'] ) ? wp_unslash( $_POST['global_data'] ) : array(),
2058 - // 'global_font_family' => isset( $_POST['global_font_family'] ) ? wp_unslash( $_POST['global_font_family'] ) : array(),
2059 - // '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'] ) ) : '',
2060 1036 );
2061 1037
2062 - if ( ! empty( $array_data['post_id'] ) ) {
2063 - $custom_fields = array();
2064 - $post_id = $array_data['post_id'];
1038 + $response = $this->wkit_api_call( $array_data, 'existing_template' );
2065 1039
2066 - $meta_fields = get_post_custom( $post_id );
2067 -
2068 - foreach ( $meta_fields as $key => $value ) {
2069 - if ( str_contains( $key, 'nxt-' ) ) {
2070 - $custom_fields[ $key ] = $value;
2071 - }
2072 - }
2073 -
2074 - if ( ! empty( $custom_fields ) ) {
2075 - $data = json_decode( $array_data['data'], true );
2076 - $data['custom_meta'] = $custom_fields;
2077 - $array_data['data'] = wp_json_encode( $data );
2078 - }
2079 - }
2080 -
2081 - $array_data['remove'] = 'yes';
2082 - $response = $this->wkit_api_call( $array_data, 'existing_template' );
2083 1040 wp_send_json( $response );
2084 1041 wp_die();
2085 1042 }
2086 1043
@@ -2124,9 +1081,8 @@
2124 1081 */
2125 1082 protected function wdkit_check_plugins_depends() {
2126 1083 $plugins = isset( $_POST['plugins'] ) ? json_decode( sanitize_text_field( wp_unslash( $_POST['plugins'] ) ) ) : array();
2127 1084 $update_plugin = array();
2128 - $update_theme = array();
2129 1085
2130 1086 if ( empty( $plugins ) || ! is_array( $plugins ) ) {
2131 1087 $this->wdkit_error_msg( array( 'plugins' => 'No Plugins' ) );
2132 1088 }
@@ -2139,9 +1095,8 @@
2139 1095
2140 1096 if ( is_null( $pluginslug ) ) {
2141 1097 $plugin->status = 'warning';
2142 1098 $update_plugin[] = $plugin;
2143 - $update_theme[] = $plugin;
2144 1099
2145 1100 continue;
2146 1101 }
2147 1102
@@ -2162,13 +1117,12 @@
2162 1117 $plugin->status = 'active';
2163 1118 $update_plugin[] = $plugin;
2164 1119 }
2165 1120 } elseif ( 'theme' === $type ) {
2166 - $theme_array = array_keys( wp_get_themes() );
2167 - $theme_slug = get_stylesheet();
2168 - $parent_theme_slug = get_template();
1121 + $theme_array = array_keys( wp_get_themes() );
1122 + $theme_slug = get_stylesheet();
2169 1123
2170 - if ( $theme_slug === $plugin->original_slug || $parent_theme_slug === $plugin->original_slug ) {
1124 + if ( $theme_slug === $plugin->original_slug ) {
2171 1125
2172 1126 $plugin->status = 'active';
2173 1127 } else {
2174 1128 $theme_name = $plugin->original_slug;
@@ -2182,19 +1136,13 @@
2182 1136 $plugin->status = 'inactive';
2183 1137 }
2184 1138 }
2185 1139
2186 - $update_theme[] = $plugin;
1140 + $update_plugin[] = $plugin;
2187 1141 }
2188 1142 }
2189 1143
2190 - $response = array(
2191 - 'plugins' => $update_plugin,
2192 - 'theme' => $update_theme,
2193 - 'ele_container' => get_option( 'elementor_experiment-container', false ),
2194 - );
2195 -
2196 - $this->wdkit_success_msg( $response );
1144 + $this->wdkit_success_msg( array( 'plugins' => $update_plugin ) );
2197 1145 }
2198 1146
2199 1147 /**
2200 1148 *
@@ -2205,9 +1153,8 @@
2205 1153 */
2206 1154 protected function wdkit_install_plugins_depends() {
2207 1155 $plugins = isset( $_POST['plugins'] ) ? json_decode( sanitize_text_field( wp_unslash( $_POST['plugins'] ) ), true ) : array();
2208 1156 $type = ! empty( $plugins['type'] ) ? $plugins['type'] : 'plugin';
2209 - $p_id = ! empty( $plugins['p_id'] ) ? $plugins['p_id'] : 'plugin';
2210 1157
2211 1158 $responce = '';
2212 1159 if ( 'plugin' === $type ) {
2213 1160 $responce = Wdkit_Depends_Installer::get_instance()->wdkit_install_plugin( $plugins );
@@ -2214,46 +1161,24 @@
2214 1161 } elseif ( 'theme' === $type ) {
2215 1162 $theme_name = ! empty( $plugins['original_slug'] ) ? $plugins['original_slug'] : '';
2216 1163 if ( ! empty( $theme_name ) ) {
2217 1164
2218 - $theme_array = array_keys( wp_get_themes() );
2219 - $theme_slug = get_stylesheet();
1165 + $activate_result = switch_theme( $theme_name );
2220 1166
2221 - if ( in_array( $theme_name, $theme_array ) ) {
2222 - $activate_result = switch_theme( $theme_name );
2223 -
2224 - if ( ! is_wp_error( $activate_result ) ) {
2225 - $responce = array(
2226 - 'message' => esc_html__( 'Theme activated successfully', 'wdesignkit' ),
2227 - 'description' => esc_html__( 'Theme successfully activated', 'wdesignkit' ),
2228 - 'slug' => 'nexter',
2229 - 'p_id' => $p_id,
2230 - 'status' => 'active',
2231 - 'success' => true,
2232 - );
2233 - } else {
2234 - $responce = array(
2235 - 'message' => esc_html__( 'Theme Not Activated !', 'wdesignkit' ),
2236 - 'description' => $activate_result->get_error_message(),
2237 - 'status' => 'inactive',
2238 - 'p_id' => $p_id,
2239 - 'success' => false,
2240 - );
2241 - }
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 + );
2242 1175 } else {
2243 - $result = $this->wdkit_install_theme_depends( $theme_name );
2244 -
2245 - $message = ! empty( $result['message'] ) ? $result['message'] : esc_html__( 'Somthing Wrong', 'wdesignkit' );
2246 - $description = ! empty( $result['description'] ) ? $result['description'] : esc_html__( 'Error Somthing Wrong', 'wdesignkit' );
2247 - $status = ! empty( $result['status'] ) ? $result['status'] : esc_html__( 'inactive', 'wdesignkit' );
2248 - $success = ! empty( $result['success'] ) ? $result['success'] : false;
2249 -
2250 1176 $responce = array(
2251 - 'message' => $message,
2252 - 'description' => $description,
2253 - 'p_id' => $p_id,
2254 - 'status' => $status,
2255 - 'success' => $success,
1177 + 'message' => esc_html__( 'Theme Not Activated !', 'wdesignkit' ),
1178 + 'description' => $activate_result->get_error_message(),
1179 + 'status' => 'inactive',
1180 + 'success' => false,
2256 1181 );
2257 1182 }
2258 1183 } else {
2259 1184 $responce = array(
@@ -2258,9 +1183,9 @@
2258 1183 } else {
2259 1184 $responce = array(
2260 1185 'message' => esc_html__( 'Theme Name not Found', 'wdesignkit' ),
2261 1186 'description' => esc_html__( 'Can Not Found Theme Name you Enterd.', 'wdesignkit' ),
2262 - 'success' => false,
1187 + 'success' => true,
2263 1188 );
2264 1189 }
2265 1190 }
2266 1191
@@ -2267,103 +1192,8 @@
2267 1192 wp_send_json( $responce );
2268 1193 wp_die();
2269 1194 }
2270 1195
2271 - protected function wdkit_install_theme_depends( $name = 'nexter' ) {
2272 -
2273 - if ( ! current_user_can( 'install_themes' ) ) {
2274 - $response = $this->tpae_set_response( false, 'Invalid nonce.', 'The security check failed. Please refresh the page and try again.' );
2275 - return $response;
2276 - }
2277 -
2278 - $theme_slug = $name;
2279 - $theme_api_url = 'https://api.wordpress.org/themes/info/1.0/';
2280 -
2281 - // Parameters for the request
2282 - $args = array(
2283 - 'body' => array(
2284 - 'action' => 'theme_information',
2285 - 'request' => serialize(
2286 - (object) array(
2287 - 'slug' => $name,
2288 - 'fields' => array(
2289 - 'description' => false,
2290 - 'sections' => false,
2291 - 'rating' => true,
2292 - 'ratings' => false,
2293 - 'downloaded' => true,
2294 - 'download_link' => true,
2295 - 'last_updated' => true,
2296 - 'homepage' => true,
2297 - 'tags' => true,
2298 - 'template' => true,
2299 - 'active_installs' => false,
2300 - 'parent' => false,
2301 - 'versions' => false,
2302 - 'screenshot_url' => true,
2303 - 'active_installs' => false,
2304 - ),
2305 - )
2306 - ),
2307 - ),
2308 - );
2309 -
2310 - // Make the request
2311 - $response = wp_remote_post( $theme_api_url, $args );
2312 - // Check for errors
2313 - if ( is_wp_error( $response ) ) {
2314 - $error_message = $response->get_error_message();
2315 -
2316 - $result = $this->tpae_set_response( false, 'oops', 'oops', '' );
2317 - } else {
2318 - $theme_info = unserialize( $response['body'] );
2319 - $theme_name = $theme_info->name;
2320 - $theme_zip_url = $theme_info->download_link;
2321 -
2322 - global $wp_filesystem;
2323 - // Install the theme
2324 - $theme = wp_remote_get( $theme_zip_url, array( 'timeout' => 30 ) );
2325 -
2326 - if ( ! function_exists( 'WP_Filesystem' ) ) {
2327 - require_once wp_normalize_path( ABSPATH . '/wp-admin/includes/file.php' );
2328 - }
2329 -
2330 - WP_Filesystem();
2331 -
2332 - $active_theme = wp_get_theme();
2333 - $theme_name = $active_theme->get( 'Name' );
2334 -
2335 - $wp_filesystem->put_contents( WP_CONTENT_DIR . '/themes/' . $theme_slug . '.zip', $theme['body'] );
2336 - $zip = new ZipArchive();
2337 - if ( $zip->open( WP_CONTENT_DIR . '/themes/' . $theme_slug . '.zip' ) === true ) {
2338 - $zip->extractTo( WP_CONTENT_DIR . '/themes/' );
2339 - $zip->close();
2340 - }
2341 -
2342 - $wp_filesystem->delete( WP_CONTENT_DIR . '/themes/' . $theme_slug . '.zip' );
2343 -
2344 - $activate_result = switch_theme( $name );
2345 -
2346 - if ( ! is_wp_error( $activate_result ) ) {
2347 - $response = array(
2348 - 'message' => esc_html__( 'Theme activated successfully', 'wdesignkit' ),
2349 - 'description' => esc_html__( 'Theme successfully activated', 'wdesignkit' ),
2350 - 'status' => 'active',
2351 - 'success' => true,
2352 - );
2353 - } else {
2354 - $response = array(
2355 - 'message' => esc_html__( 'Theme Not Activated !', 'wdesignkit' ),
2356 - 'description' => $activate_result->get_error_message(),
2357 - 'status' => 'inactive',
2358 - 'success' => false,
2359 - );
2360 - }
2361 - }
2362 -
2363 - return $response;
2364 - }
2365 -
2366 1196 /**
2367 1197 *
2368 1198 * It is Use Update WDesignKit plugin latest version.
2369 1199 *
@@ -2392,118 +1222,25 @@
2392 1222 * Get Download Template Content
2393 1223 *
2394 1224 * @since 1.0.0
2395 1225 */
2396 - protected function wdkit_activate_container() {
1226 + protected function wdkit_import_template() {
1227 + $args = $this->wdkit_parse_args( $_POST );
2397 1228
2398 - $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 + );
2399 1236
2400 - if ( $option_value === false ) {
2401 - add_option( 'elementor_experiment-container', 'active' );
2402 - } else {
2403 - update_option( 'elementor_experiment-container', 'active' );
1237 + wp_send_json( $response );
1238 + wp_die();
2404 1239 }
2405 1240
2406 - $result = array(
2407 - 'message' => esc_html__( 'Container Activated Successfully', 'wdesignkit' ),
2408 - 'description' => esc_html__( 'Elementor Container Activated Successfully.', 'wdesignkit' ),
2409 - 'success' => true,
2410 - );
2411 -
2412 - wp_send_json( $response );
2413 - wp_die();
2414 - }
2415 -
2416 - /**
2417 - * import category and tags for post
2418 - *
2419 - * @since 2.0.0
2420 - */
2421 - protected function wdkit_import_taxonomy() {
2422 - $category = isset( $_POST['category'] ) ? json_decode( wp_unslash( $_POST['category'] ) ) : array();
2423 - $tags = isset( $_POST['tags'] ) ? json_decode( wp_unslash( $_POST['tags'] ) ) : array();
2424 -
2425 - $response = array(
2426 - 'success' => false,
2427 - 'categories' => array(),
2428 - 'tags' => array(),
2429 - );
2430 -
2431 - if ( ! empty( $category ) && count( $category ) > 0 ) {
2432 - foreach ( $category as $category_name ) {
2433 - $category_name = sanitize_text_field( $category_name );
2434 -
2435 - $term_exists = term_exists( $category_name, 'category' );
2436 - if ( ! $term_exists ) {
2437 - $result = wp_insert_term( $category_name, 'category' );
2438 - if ( ! is_wp_error( $result ) ) {
2439 - $response['categories'][] = array(
2440 - 'name' => $category_name,
2441 - 'term_id' => $result['term_id'],
2442 - );
2443 - } else {
2444 - $response['categories'][] = array(
2445 - 'name' => $category_name,
2446 - 'error' => $result->get_error_message(),
2447 - );
2448 - }
2449 - } else {
2450 - $term_id = is_array( $term_exists ) ? $term_exists['term_id'] : $term_exists;
2451 - $response['categories'][] = array(
2452 - 'name' => $category_name,
2453 - 'term_id' => $term_id,
2454 - );
2455 - }
2456 - }
2457 -
2458 - $response['success'] = true;
2459 - }
2460 -
2461 - if ( ! empty( $tags ) && count( $tags ) > 0 ) {
2462 - foreach ( $tags as $tags_name ) {
2463 - $tags_name = sanitize_text_field( $tags_name );
2464 -
2465 - $term_exists = term_exists( $tags_name, 'post_tag' );
2466 - if ( ! $term_exists ) {
2467 - $result = wp_insert_term( $tags_name, 'post_tag' );
2468 - if ( ! is_wp_error( $result ) ) {
2469 - $response['tags'][] = array(
2470 - 'name' => $tags_name,
2471 - 'term_id' => $result['term_id'],
2472 - );
2473 - } else {
2474 - $response['tags'][] = array(
2475 - 'name' => $tags_name,
2476 - 'error' => $result->get_error_message(),
2477 - );
2478 - }
2479 - } else {
2480 - $term_id = is_array( $term_exists ) ? $term_exists['term_id'] : $term_exists;
2481 - $response['tags'][] = array(
2482 - 'name' => $tags_name,
2483 - 'term_id' => $term_id,
2484 - );
2485 - }
2486 - }
2487 -
2488 - $response['success'] = true;
2489 - }
2490 -
2491 - wp_send_json( $response );
2492 - wp_die();
2493 - }
2494 -
2495 - /**
2496 - * Get Download Template Content
2497 - *
2498 - * @since 1.0.0
2499 - */
2500 - protected function wdkit_import_template() {
2501 - $args = $this->wdkit_parse_args( $_POST );
2502 - $api_type = isset( $_POST['api_type'] ) ? sanitize_text_field( wp_unslash( $_POST['api_type'] ) ) : 'import_template';
2503 -
2504 1241 $response = '';
2505 - if ( empty( $args['template_id'] ) ) {
1242 + if ( empty( $args['email'] ) || empty( $args['template_id'] ) ) {
2506 1243 $result = array(
2507 1244 'content' => '',
2508 1245 'message' => esc_html__( 'Invalid import', 'wdesignkit' ),
2509 1246 'description' => esc_html__( 'Invalid import: Check your details and try again.', 'wdesignkit' ),
@@ -2516,10 +1253,9 @@
2516 1253
2517 1254 $args['token'] = $this->wdkit_login_user_token( $args['email'] );
2518 1255
2519 1256 unset( $args['email'] );
2520 - $args['unique_id'] = get_option( 'wdkit_unique_id' ) ?? '';
2521 - $response = WDesignKit_Data_Query::get_data( $api_type, $args );
1257 + $response = WDesignKit_Data_Query::get_data( 'import_template', $args );
2522 1258 $custom_meta = isset( $_POST['custom_meta'] ) ? sanitize_text_field( wp_unslash( $_POST['custom_meta'] ) ) : false;
2523 1259
2524 1260 /** Custom meta Field */
2525 1261 if ( ! empty( $custom_meta ) && 'true' === $custom_meta && ! empty( $response ) && ! empty( $response['content'] ) ) {
@@ -2755,15 +1491,10 @@
2755 1491 $blocks_attr[ $block_key ][ $key ] = $new_media;
2756 1492 } else {
2757 1493 foreach ( $val as $sub_key => $sub_val ) {
2758 1494 if ( isset( $sub_val['url'] ) && ( isset( $sub_val['Id'] ) || isset( $sub_val['id'] ) ) && ! empty( $sub_val['url'] ) ) {
2759 - $new_media = Wdkit_Import_Images::wdkit_Import_media( $sub_val );
2760 -
2761 - if ( is_array( $sub_val ) && is_array( $new_media ) ) {
2762 - $blocks_attr[ $block_key ][ $key ][ $sub_key ] = array_merge( $sub_val, $new_media );
2763 - } else {
2764 - $blocks_attr[ $block_key ][ $key ][ $sub_key ] = $new_media;
2765 - }
1495 + $new_media = Wdkit_Import_Images::wdkit_Import_media( $sub_val );
1496 + $blocks_attr[ $block_key ][ $key ][ $sub_key ] = $new_media;
2766 1497 } elseif ( isset( $sub_val['url'] ) && ! empty( $sub_val['url'] ) && preg_match( '/\.(jpg|png|jpeg|gif|svg|webp)$/', $sub_val['url'] ) ) {
2767 1498 $new_media = Wdkit_Import_Images::wdkit_Import_media( $sub_val );
2768 1499 $blocks_attr[ $block_key ][ $key ][ $sub_key ] = $new_media;
2769 1500 } elseif ( is_array( $sub_val ) && ! empty( $sub_val ) ) {
@@ -2769,14 +1500,9 @@
2769 1500 } elseif ( is_array( $sub_val ) && ! empty( $sub_val ) ) {
2770 1501 foreach ( $sub_val as $sub_key1 => $sub_val1 ) {
2771 1502 if ( isset( $sub_val1['url'] ) && ( isset( $sub_val1['Id'] ) || isset( $sub_val1['id'] ) ) && ! empty( $sub_val1['url'] ) ) {
2772 1503 $new_media = Wdkit_Import_Images::wdkit_Import_media( $sub_val1 );
2773 -
2774 - if ( is_array( $sub_val1 ) && is_array( $new_media ) ) {
2775 - $blocks_attr[ $block_key ][ $key ][ $sub_key ][ $sub_key1 ] = array_merge( $sub_val1, $new_media );
2776 - } else {
2777 - $blocks_attr[ $block_key ][ $key ][ $sub_key ][ $sub_key1 ] = $new_media;
2778 - }
1504 + $blocks_attr[ $block_key ][ $key ][ $sub_key ][ $sub_key1 ] = $new_media;
2779 1505 } elseif ( isset( $sub_val1['url'] ) && ! empty( $sub_val1['url'] ) && preg_match( '/\.(jpg|png|jpeg|gif|svg|webp)$/', $sub_val1['url'] ) ) {
2780 1506 $new_media = Wdkit_Import_Images::wdkit_Import_media( $sub_val1 );
2781 1507 $blocks_attr[ $block_key ][ $key ][ $sub_key ][ $sub_key1 ] = $new_media;
2782 1508 }
@@ -2809,10 +1535,8 @@
2809 1535 if ( ! current_user_can( 'manage_options' ) ) {
2810 1536 return false;
2811 1537 }
2812 1538
2813 - $builder = isset( $_POST['builder'] ) ? sanitize_text_field( wp_unslash( $_POST['builder'] ) ) : '';
2814 -
2815 1539 $page_section = ! empty( $_POST['page_section'] ) ? sanitize_text_field( wp_unslash( $_POST['page_section'] ) ) : '';
2816 1540
2817 1541 if ( isset( $page_section ) ) {
2818 1542 $args['page_section'] = ! empty( $page_section ) ? sanitize_text_field( wp_unslash( $page_section ) ) : '';
@@ -2817,16 +1541,14 @@
2817 1541 if ( isset( $page_section ) ) {
2818 1542 $args['page_section'] = ! empty( $page_section ) ? sanitize_text_field( wp_unslash( $page_section ) ) : '';
2819 1543 }
2820 1544
2821 - $template_ids = ! empty( $_POST['template_ids'] ) ? json_decode( sanitize_text_field( wp_unslash( $_POST['template_ids'] ) ), true ) : array();
2822 - $email = ! empty( $_POST['email'] ) ? strtolower( sanitize_email( wp_unslash( $_POST['email'] ) ) ) : '';
2823 - $editor = isset( $_POST['editor'] ) ? sanitize_text_field( wp_unslash( $_POST['editor'] ) ) : '';
2824 - $website_kit = isset( $_POST['website_kit'] ) ? sanitize_text_field( wp_unslash( $_POST['website_kit'] ) ) : '';
2825 - $api_type = isset( $_POST['api_type'] ) ? sanitize_text_field( wp_unslash( $_POST['api_type'] ) ) : 'import_template';
2826 - $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'] ) ) : '';
2827 1549
2828 - if ( empty( $template_ids ) ) {
1550 + if ( empty( $email ) || empty( $template_ids ) ) {
2829 1551 $output = array(
2830 1552 'message' => esc_html__( 'Invalid import', 'wdesignkit' ),
2831 1553 'description' => esc_html__( 'Invalid import: Check your details and try again.', 'wdesignkit' ),
2832 1554 'success' => false,
@@ -2850,100 +1572,32 @@
2850 1572 'token' => $token,
2851 1573 'template_id' => $template_ids['id'],
2852 1574 'editor' => $editor,
2853 1575 'website_kit' => $website_kit,
2854 - 'unique_id' => get_option( 'wdkit_unique_id' ) ?? '',
2855 1576 );
2856 1577
2857 - $response = WDesignKit_Data_Query::get_data( $api_type, $temp_args );
1578 + $response = WDesignKit_Data_Query::get_data( 'import_template', $temp_args );
2858 1579 $output = array();
2859 1580
2860 - if ( is_wp_error( $response ) ) {
2861 -
1581 + if ( 'error' === $response['content'] ) {
2862 1582 wp_send_json( $response );
2863 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'];
2864 1589 }
2865 1590
2866 - if ( isset( $response['content'] ) && 'error' === $response['content'] ) {
2867 - wp_send_json( $response );
2868 - wp_die();
2869 - }
2870 -
2871 - $result = array(
2872 - 'response' => $response,
2873 - 'args' => $args,
2874 - 'id' => $template_ids['id'],
2875 - 'temp_data' => $template_ids,
2876 - );
2877 -
2878 - $output['message'] = $response['message'];
2879 - $output['description'] = $response['description'];
2880 - $output['data'] = $result;
2881 - $output['success'] = $response['success'];
2882 -
2883 1591 wp_send_json( $output );
2884 1592 wp_die();
2885 1593 }
2886 1594
2887 - public function wdkit_enable_template_widgets() {
2888 - $widget_list = ! empty( $_POST['widget_list'] ) ? json_decode( wp_unslash( $_POST['widget_list'] ), true ) : array();
2889 - $extensions_list = ! empty( $_POST['extensions_list'] ) ? json_decode( wp_unslash( $_POST['extensions_list'] ), true ) : array();
2890 -
2891 - if ( empty( $widget_list ) && empty( $extensions_list ) ) {
2892 - $res = array(
2893 - 'massage' => __( 'Widget array not found', 'wdesignkit' ),
2894 - 'description' => __( 'Widget array not found', 'wdesignkit' ),
2895 - 'success' => false,
2896 - );
2897 - wp_send_json( $res );
2898 - wp_die();
2899 - }
2900 -
2901 - if ( ! has_filter( 'tpae_enable_selected_widgets' ) ) {
2902 - $res = array(
2903 - 'massage' => __( 'Relevant Plugin not Activated', 'wdesignkit' ),
2904 - 'description' => __( 'Relevant Plugin not Installed / Activated', 'wdesignkit' ),
2905 - 'success' => false,
2906 - );
2907 - wp_send_json( $res );
2908 - wp_die();
2909 - }
2910 -
2911 - $w_list = array(
2912 - 'widgets' => $widget_list,
2913 - 'extensions' => $extensions_list,
2914 - );
2915 -
2916 - $result = apply_filters( 'tpae_enable_selected_widgets', $w_list );
2917 -
2918 - if ( ! empty( $result['success'] ) ) {
2919 - $res = array(
2920 - 'massage' => __( 'Enabled widgets successfully', 'wdesignkit' ),
2921 - 'description' => __( 'Used widgets have been enabled successfully', 'wdesignkit' ),
2922 - 'success' => true,
2923 - );
2924 - } else {
2925 -
2926 - $message = isset( $result['message'] ) ? $result['message'] : __( 'Failed to enable widgets', 'wdesignkit' );
2927 - $description = isset( $result['description'] ) ? $result['description'] : __( 'Failed to enable widgets', 'wdesignkit' );
2928 -
2929 - $res = array(
2930 - 'massage' => $message,
2931 - 'description' => $description,
2932 - 'success' => false,
2933 - );
2934 - }
2935 -
2936 - wp_send_json( $res );
2937 - wp_die();
2938 - }
2939 -
2940 1595 /**
2941 1596 * Import single template and section from plugin only
2942 1597 * */
2943 1598 protected function wdkit_import_multi_template() {
2944 - $args = $this->wdkit_parse_args( $_POST );
2945 - $api_type = isset( $_POST['api_type'] ) ? sanitize_text_field( wp_unslash( $_POST['api_type'] ) ) : 'import_template';
1599 + $args = $this->wdkit_parse_args( $_POST );
2946 1600
2947 1601 if ( ! current_user_can( 'manage_options' ) ) {
2948 1602 return false;
2949 1603 }
@@ -2972,42 +1626,56 @@
2972 1626 $args['post_type'] = ! empty( $_POST['select'] ) ? sanitize_text_field( wp_unslash( $_POST['select'] ) ) : '';
2973 1627 }
2974 1628
2975 1629 $args['custom_meta'] = isset( $_POST['custom_meta'] ) ? sanitize_text_field( wp_unslash( $_POST['custom_meta'] ) ) : false;
2976 -
2977 1630 if ( ! empty( $args['template_ids'] ) && ! empty( $args['page_section'] ) ) {
2978 1631 $output = array();
2979 - 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 {
2980 1656 $token = $this->wdkit_login_user_token( $args['email'] );
2981 -
2982 1657 $temp_args = array(
2983 1658 'token' => $token,
2984 - 'template_id' => $args['template_ids']['id'],
1659 + 'template_id' => $args['template_ids'],
2985 1660 'editor' => $args['editor'],
2986 - 'unique_id' => get_option( 'wdkit_unique_id' ) ?? '',
2987 1661 );
2988 1662
2989 - $response = WDesignKit_Data_Query::get_data( $api_type, $temp_args );
1663 + $response = WDesignKit_Data_Query::get_data( 'import_template', $temp_args );
2990 1664
2991 1665 if ( 'error' === $response['content'] ) {
2992 1666 wp_send_json( $response );
2993 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'];
2994 1673 }
1674 + }
2995 1675
2996 - $result = array(
2997 - 'response' => $response,
2998 - 'args' => $args,
2999 - 'id' => $args['template_ids'],
3000 - 'value' => $args['template_ids'],
3001 - );
1676 + $output['success'] = true;
3002 1677
3003 - $output['message'] = $response['message'];
3004 - $output['description'] = $response['description'];
3005 - $output['data'] = $result;
3006 - $output['success'] = true;
3007 -
3008 - }
3009 -
3010 1678 wp_send_json( $output );
3011 1679 wp_die();
3012 1680 }
3013 1681 }
@@ -3012,59 +1680,8 @@
3012 1680 }
3013 1681 }
3014 1682
3015 1683 /**
3016 - * It is Use for remove selected category from content.
3017 - *
3018 - * @since 2.0.5
3019 - */
3020 - public function wdkit_content_remover( &$data ) {
3021 -
3022 - if ( is_array( $data ) ) {
3023 -
3024 - foreach ( $data as $key => &$value ) {
3025 - if ( $key === 'post_category' ) {
3026 - $data[ $key ] = array();
3027 - } else if ($key === 'include_products'){
3028 - $data[ $key ] = "";
3029 - } else {
3030 - $this->wdkit_content_remover( $value );
3031 - }
3032 - }
3033 - } elseif ( is_object( $data ) ) {
3034 -
3035 - foreach ( $data as $key => &$value ) {
3036 - if ( $key === 'post_category' ) {
3037 - $data->$key = array();
3038 - } else if ($key === 'include_products'){
3039 - $data->$key = "";
3040 - } else {
3041 - $this->wdkit_content_remover( $value );
3042 - }
3043 - }
3044 - }
3045 -
3046 - return $data;
3047 - }
3048 -
3049 - protected function wkit_update_elementor_template(){
3050 -
3051 - if ( isset( $_POST['data'] ) ) {
3052 - $content = ! empty( $_POST['data'] ) ? json_decode( wp_unslash( $_POST['data'] ), true ) : '';
3053 - }
3054 -
3055 - if ( isset( $_POST['template_id'] ) ) {
3056 - $template_id = ! empty( $_POST['template_id'] ) ? json_decode( sanitize_text_field( wp_unslash( $_POST['template_id'] ), true ) ) : '';
3057 - }
3058 -
3059 - $document = \Elementor\Plugin::$instance->documents->get($template_id);
3060 -
3061 - $document->save([
3062 - 'elements' => $content
3063 - ]);
3064 - }
3065 -
3066 - /**
3067 1684 * Import single template and section from plugin only
3068 1685 *
3069 1686 * @param array $args store data.
3070 1687 * @param array $template_id store data.
@@ -3070,42 +1687,9 @@
3070 1687 * @param array $template_id store data.
3071 1688 * @param array $data store data.
3072 1689 * @param array $temp_data store data.
3073 1690 * */
3074 - protected function import_page_section_content() {
3075 -
3076 - if ( isset( $_POST['args'] ) ) {
3077 - $args = ! empty( $_POST['args'] ) ? json_decode( sanitize_text_field( wp_unslash( $_POST['args'] ) ), true ) : array();
3078 - }
3079 -
3080 - if ( isset( $_POST['temp_data'] ) ) {
3081 - $temp_data = ! empty( $_POST['temp_data'] ) ? json_decode( sanitize_text_field( wp_unslash( $_POST['temp_data'] ) ), true ) : array();
3082 - }
3083 -
3084 - if ( isset( $_POST['category_list'] ) ) {
3085 - $category_list = ! empty( $_POST['category_list'] ) ? json_decode( wp_unslash( $_POST['category_list'] ), true ) : '';
3086 - }
3087 -
3088 - if ( isset( $_POST['tag_list'] ) ) {
3089 - $tag_list = ! empty( $_POST['tag_list'] ) ? json_decode( wp_unslash( $_POST['tag_list'] ), true ) : '';
3090 - }
3091 -
3092 - if ( isset( $_POST['thumb_image'] ) ) {
3093 - $thumb_image = ! empty( $_POST['thumb_image'] ) ? esc_url_raw( $_POST['thumb_image'] ) : '';
3094 - }
3095 -
3096 - if ( isset( $_POST['template_id'] ) ) {
3097 - $template_id = ! empty( $_POST['template_id'] ) ? json_decode( sanitize_text_field( wp_unslash( $_POST['template_id'] ), true ) ) : '';
3098 - }
3099 -
3100 - if ( isset( $_POST['temp_type'] ) ) {
3101 - $temp_type = isset( $_POST['temp_type'] ) ? sanitize_text_field( wp_unslash( $_POST['temp_type'] ) ) : 'normal';
3102 - }
3103 -
3104 - if ( isset( $_POST['data'] ) ) {
3105 - $data = ! empty( $_POST['data'] ) ? json_decode( wp_unslash( $_POST['data'] ) ) : '';
3106 - }
3107 -
1691 + private function import_page_section_content( $args, $template_id, $data, $temp_data = array() ) {
3108 1692 $enqueue_instance = new Wdkit_Enqueue();
3109 1693 $get_post_type = $enqueue_instance->wdkit_get_post_type_list();
3110 1694
3111 1695 $post_type = ! empty( $temp_data['type'] ) ? sanitize_text_field( wp_unslash( $temp_data['type'] ) ) : 'page';
@@ -3111,10 +1695,8 @@
3111 1695 $post_type = ! empty( $temp_data['type'] ) ? sanitize_text_field( wp_unslash( $temp_data['type'] ) ) : 'page';
3112 1696
3113 1697 if ( 'section' === $post_type ) {
3114 1698 $post_type = $temp_data['wp_post_type'];
3115 - } else {
3116 - $post_type = $temp_data['wp_post_type'];
3117 1699 }
3118 1700
3119 1701 if ( ! array_key_exists( $post_type, $get_post_type ) ) {
3120 1702 $post_type = 'page';
@@ -3119,15 +1701,13 @@
3119 1701 if ( ! array_key_exists( $post_type, $get_post_type ) ) {
3120 1702 $post_type = 'page';
3121 1703 }
3122 1704
3123 - if ( ! empty( $data ) && ! empty( $template_id ) && ! empty( $post_type ) && current_user_can( 'manage_options' ) ) {
3124 - $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'] );
3125 1707 $post_title = isset( $post_content->title ) ? sanitize_text_field( $post_content->title ) : '';
3126 - $post_slug = isset( $post_content->slug ) ? sanitize_text_field( $post_content->slug ) : '';
3127 1708 $file_type = isset( $post_content->file_type ) ? sanitize_text_field( $post_content->file_type ) : '';
3128 1709 $content = isset( $post_content->content ) ? wp_slash( $post_content->content ) : '';
3129 - $temp_con = '';
3130 1710
3131 1711 if ( 'gutenberg' === $args['editor'] || ( 'wdkit' === $args['editor'] && ! empty( $file_type ) && 'wp_block' === $file_type ) ) {
3132 1712 if ( empty( $content ) ) {
3133 1713 wp_send_json(
@@ -3137,36 +1717,19 @@
3137 1717 )
3138 1718 );
3139 1719 wp_die();
3140 1720 } elseif ( ! empty( $content ) && ! empty( $file_type ) && 'wp_block' === $file_type ) {
1721 + $parse_blocks = parse_blocks( stripslashes( $content ) );
3141 1722
3142 1723 $editor = ( 'wdkit' === $args['editor'] ) ? 'gutenberg' : $args['editor'];
3143 - $blocks = parse_blocks( stripslashes( $content ) );
3144 -
3145 - $blocks = $this->wdkit_media_import( $blocks, $editor );
1724 + $content = $this->wdkit_media_import( $parse_blocks, $editor );
1725 + $content = addslashes( serialize_blocks( $content ) );
3146 1726
3147 - $processor = new WDKIT_Nexter_Block_Processor();
3148 - $blocks = $processor->run( $blocks );
3149 - $content = serialize_blocks( $blocks );
3150 -
3151 - $content = $this->replace_unicode_glitch( serialize_blocks( $blocks ) );
3152 -
3153 - if ( ! empty( $category_list ) && is_array( $category_list ) ) {
3154 - $category_ids = array_map( 'intval', $category_list );
3155 - wp_set_post_terms( $inserted_id, $category_ids, 'category' );
3156 - }
3157 -
3158 - if ( ! empty( $tag_list ) && is_array( $tag_list ) ) {
3159 - $tag_ids = array_map( 'intval', $tag_list );
3160 - wp_set_post_terms( $inserted_id, $tag_ids, 'post_tag' );
3161 - }
3162 -
3163 1727 $inserted_post = wp_insert_post(
3164 1728 array(
3165 1729 'post_status' => 'publish',
3166 1730 'post_type' => $post_type,
3167 1731 'post_title' => $post_title,
3168 - 'post_name' => $post_slug,
3169 1732 'post_content' => $content,
3170 1733 )
3171 1734 );
3172 1735
@@ -3179,41 +1742,8 @@
3179 1742 );
3180 1743 wp_die();
3181 1744 }
3182 1745
3183 - if ( ! empty( $thumb_image ) ) {
3184 - // $featured_image_url = esc_url_raw( $thumb_image );
3185 - $tmp = download_url( $thumb_image );
3186 - if ( is_wp_error( $tmp ) ) {
3187 - error_log( 'Image download failed: ' . esc_html( $tmp->get_error_message() ) );
3188 - } else {
3189 - $file_array = array(
3190 - 'name' => wp_basename( $thumb_image ),
3191 - 'tmp_name' => $tmp,
3192 - );
3193 -
3194 - $image_id = media_handle_sideload( $file_array, $inserted_post );
3195 -
3196 - if ( is_wp_error( $image_id ) ) {
3197 - error_log( 'Image sideload failed: ' . esc_html( $image_id->get_error_message() ) );
3198 - } else {
3199 - set_post_thumbnail( $inserted_post, $image_id );
3200 - }
3201 -
3202 - @unlink( $tmp );
3203 - }
3204 - }
3205 -
3206 - if ( ! empty( $category_list ) && is_array( $category_list ) ) {
3207 - $category_ids = array_map( 'intval', $category_list );
3208 - wp_set_post_terms( $inserted_post, $category_ids, 'category' );
3209 - }
3210 -
3211 - if ( ! empty( $tag_list ) && is_array( $tag_list ) ) {
3212 - $tag_ids = array_map( 'intval', $tag_list );
3213 - wp_set_post_terms( $inserted_post, $tag_ids, 'post_tag' );
3214 - }
3215 -
3216 1746 if ( ! empty( $args['custom_meta'] ) && 'true' == $args['custom_meta'] ) {
3217 1747 $custom_meta = isset( $post_content->custom_meta ) ? json_decode( wp_json_encode( $post_content->custom_meta ), true ) : '';
3218 1748 if ( ! empty( $custom_meta ) ) {
3219 1749 foreach ( $custom_meta as $meta_key => $meta_val ) {
@@ -3227,42 +1757,13 @@
3227 1757 }
3228 1758 }
3229 1759 }
3230 1760
3231 - $temp_detail = array(
1761 + return array(
3232 1762 'title' => get_the_title( $inserted_post ),
3233 1763 'edit_link' => get_edit_post_link( $inserted_post, 'internal' ),
3234 1764 'view' => get_permalink( $inserted_post ),
3235 - 'id' => $inserted_post,
3236 1765 );
3237 -
3238 - if ( ! empty( $template_id->id ) ) {
3239 - $temp_id = $template_id->id;
3240 - } elseif ( ! empty( $template_id ) ) {
3241 - $temp_id = $template_id;
3242 - } else {
3243 - $temp_id = '';
3244 - }
3245 -
3246 - wp_update_post([
3247 - 'ID' => $inserted_post,
3248 - ]);
3249 -
3250 - if (class_exists('Tpgb_Library') && method_exists('Tpgb_Library', 'remove_backend_dir_files')) {
3251 - Tpgb_Library()->remove_backend_dir_files();
3252 - }
3253 -
3254 - clean_post_cache( $inserted_post );
3255 - wp_send_json(
3256 - array(
3257 - $temp_id => $temp_detail,
3258 - 'description' => 'Yay! Your Section has been Successfully Imported.',
3259 - 'message' => 'Successfully Imported.',
3260 - 'inserted_id' => $inserted_post,
3261 - 'success' => true,
3262 - )
3263 - );
3264 - wp_die();
3265 1766 }
3266 1767 } elseif ( 'elementor' === $args['editor'] || ( 'wdkit' === $args['editor'] && ! empty( $file_type ) && 'elementor' === $file_type ) ) {
3267 1768 if ( did_action( 'elementor/loaded' ) ) {
3268 1769 if ( empty( $content ) ) {
@@ -3273,16 +1774,12 @@
3273 1774 )
3274 1775 );
3275 1776 wp_die();
3276 1777 } elseif ( ! empty( $content ) && ! empty( $file_type ) && 'elementor' === $file_type ) {
3277 -
3278 - $content = $this->wdkit_content_remover( $content );
3279 -
3280 1778 $post_attributes = array(
3281 1779 'post_title' => $post_title,
3282 1780 'post_type' => $post_type,
3283 1781 'post_status' => 'publish',
3284 - 'post_name' => $post_slug,
3285 1782 );
3286 1783
3287 1784 if ( 'elementor_library' === $post_type ) {
3288 1785 $el_type = ( isset( $post_content->el_type ) && ! empty( $post_content->el_type ) ) ? sanitize_text_field( $post_content->el_type ) : 'page';
@@ -3306,43 +1803,8 @@
3306 1803 );
3307 1804 wp_die();
3308 1805 }
3309 1806
3310 - $inserted_id = $new_document->get_main_id();
3311 -
3312 - if ( ! empty( $thumb_image ) ) {
3313 - // $featured_image_url = esc_url_raw( $thumb_image );
3314 - $tmp = download_url( $thumb_image );
3315 - if ( is_wp_error( $tmp ) ) {
3316 - error_log( 'Image download failed: ' . esc_html( $tmp->get_error_message() ) );
3317 - } else {
3318 - $file_array = array(
3319 - 'name' => wp_basename( $thumb_image ),
3320 - 'tmp_name' => $tmp,
3321 - );
3322 -
3323 - $image_id = media_handle_sideload( $file_array, $inserted_id );
3324 -
3325 - if ( is_wp_error( $image_id ) ) {
3326 - error_log( 'Image sideload failed: ' . esc_html( $image_id->get_error_message() ) );
3327 - } else {
3328 - set_post_thumbnail( $inserted_id, $image_id );
3329 - }
3330 -
3331 - @unlink( $tmp );
3332 - }
3333 - }
3334 -
3335 - if ( ! empty( $category_list ) && is_array( $category_list ) ) {
3336 - $category_ids = array_map( 'intval', $category_list );
3337 - wp_set_post_terms( $inserted_id, $category_ids, 'category' );
3338 - }
3339 -
3340 - if ( ! empty( $tag_list ) && is_array( $tag_list ) ) {
3341 - $tag_ids = array_map( 'intval', $tag_list );
3342 - wp_set_post_terms( $inserted_id, $tag_ids, 'post_tag' );
3343 - }
3344 -
3345 1807 $settings = ( isset( $post_content->settings ) && ! empty( $post_content->settings ) ) ? json_decode( wp_json_encode( $post_content->settings ), true ) : array();
3346 1808
3347 1809 $content = wp_json_encode( $content );
3348 1810 $content = $this->wdkit_media_import( $content, $file_type );
@@ -3355,12 +1817,8 @@
3355 1817 );
3356 1818
3357 1819 $inserted_id = $new_document->get_main_id();
3358 1820
3359 - if( $temp_type == 'navigation' ){
3360 - $temp_con = $content;
3361 - }
3362 -
3363 1821 if ( ! empty( $args['custom_meta'] ) && 'true' == $args['custom_meta'] ) {
3364 1822 $custom_meta = isset( $post_content->custom_meta ) ? json_decode( wp_json_encode( $post_content->custom_meta ), true ) : '';
3365 1823 if ( ! empty( $custom_meta ) ) {
3366 1824 foreach ( $custom_meta as $meta_key => $meta_val ) {
@@ -3373,36 +1831,13 @@
3373 1831 }
3374 1832 }
3375 1833 }
3376 1834
3377 - $temp_detail = array(
1835 + return array(
3378 1836 'title' => get_the_title( $inserted_id ),
3379 1837 'edit_link' => get_edit_post_link( $inserted_id, 'internal' ),
3380 1838 'view' => get_permalink( $inserted_id ),
3381 - 'id' => $inserted_id,
3382 1839 );
3383 -
3384 - if ( ! empty( $template_id->id ) ) {
3385 - $temp_id = $template_id->id;
3386 - } elseif ( ! empty( $template_id ) ) {
3387 - $temp_id = $template_id;
3388 - } else {
3389 - $temp_id = '';
3390 - }
3391 -
3392 - \Elementor\Plugin::$instance->files_manager->clear_cache();
3393 -
3394 - wp_send_json(
3395 - array(
3396 - $temp_id => $temp_detail,
3397 - 'content' => $temp_con,
3398 - 'description' => 'Yay! Your Section has been Successfully Imported.',
3399 - 'message' => 'Successfully Imported.',
3400 - 'inserted_id' => $inserted_id,
3401 - 'success' => true,
3402 - )
3403 - );
3404 - wp_die();
3405 1840 }
3406 1841 } else {
3407 1842 wp_send_json(
3408 1843 array(
@@ -3413,528 +1848,11 @@
3413 1848 wp_die();
3414 1849 }
3415 1850 }
3416 1851 }
3417 -
3418 - wp_send_json(
3419 - array(
3420 - 'success' => false,
3421 - 'message' => esc_html__( 'Something went wrong', 'wdesignkit' ),
3422 - )
3423 - );
3424 - wp_die();
3425 1852 }
3426 1853
3427 1854 /**
3428 - * Replace unicode glitch
3429 - *
3430 - * @since 2.0.0
3431 - */
3432 - private function replace_unicode_glitch( $content ) {
3433 -
3434 - // Fix escaped unicode like \u003c → <
3435 - $content = preg_replace_callback(
3436 - '/\\\\u([0-9a-fA-F]{4})/',
3437 - function ( $match ) {
3438 - return html_entity_decode(
3439 - mb_convert_encoding(
3440 - pack('H*', $match[1]),
3441 - 'UTF-8',
3442 - 'UCS-2BE'
3443 - ),
3444 - ENT_QUOTES,
3445 - 'UTF-8'
3446 - );
3447 - },
3448 - $content
3449 - );
3450 -
3451 - return $content;
3452 - }
3453 -
3454 -
3455 - /**
3456 - * change plugins setting for import kit
3457 - *
3458 - * @since 2.0.0
3459 - */
3460 - protected function update_plugin_setting() {
3461 - $temp_id = isset( $_POST['plugin_type'] ) ? sanitize_text_field( $_POST['plugin_type'] ) : '';
3462 -
3463 - if ( $temp_id == 'elementor' ) {
3464 - $unfiltered_files = get_option( 'elementor_unfiltered_files_upload', false );
3465 - $load_fa4 = get_option( 'elementor_load_fa4_shim', false );
3466 - $Inline_font_icons = get_option( 'elementor_experiment-e_font_icon_svg', false );
3467 - $container = get_option( 'elementor_experiment-container', false );
3468 -
3469 - if ( isset( $unfiltered_files ) ) {
3470 - update_option( 'elementor_unfiltered_files_upload', 1 );
3471 - } else {
3472 - add_option( 'elementor_unfiltered_files_upload', 1 );
3473 - }
3474 -
3475 - if ( isset( $load_fa4 ) ) {
3476 - update_option( 'elementor_load_fa4_shim', 'yes' );
3477 - } else {
3478 - add_option( 'elementor_load_fa4_shim', 'yes' );
3479 - }
3480 -
3481 - if ( isset( $container ) ) {
3482 - update_option( 'elementor_experiment-container', 'active' );
3483 - } else {
3484 - add_option( 'elementor_experiment-container', 'active' );
3485 - }
3486 -
3487 - if ( isset( $Inline_font_icons ) ) {
3488 - update_option( 'elementor_experiment-e_font_icon_svg', 'inactive' );
3489 - } else {
3490 - add_option( 'elementor_experiment-e_font_icon_svg', 'inactive' );
3491 - }
3492 -
3493 - $response = array(
3494 - 'message' => esc_html__( 'Plugin Setting updated', 'wdesignkit' ),
3495 - 'description' => esc_html__( 'Plugin Setting updated', 'wdesignkit' ),
3496 - 'success' => true,
3497 - );
3498 - } else {
3499 - $response = array(
3500 - 'message' => esc_html__( 'Plugin not found', 'wdesignkit' ),
3501 - 'description' => esc_html__( 'Plugin not found', 'wdesignkit' ),
3502 - 'success' => false,
3503 - );
3504 - }
3505 -
3506 - wp_send_json( $response );
3507 - wp_die();
3508 - }
3509 -
3510 - /**
3511 - * generate different color logo
3512 - *
3513 - * @since 2.0.0
3514 - */
3515 - protected function wkit_generate_site_logo() {
3516 -
3517 - if ( empty( $_POST['image_url'] ) ) {
3518 - wp_send_json_error( 'Image URL not provided.' );
3519 - }
3520 -
3521 - if ( isset( $_POST['colors'] ) ) {
3522 - $img_colors = ! empty( $_POST['colors'] ) ? json_decode( sanitize_text_field( wp_unslash( $_POST['colors'] ) ), true ) : array();
3523 - }
3524 -
3525 - if ( empty( $img_colors ) ) {
3526 - wp_send_json_error( 'Image color not provided.' );
3527 - }
3528 -
3529 - $image_url = esc_url_raw( $_POST['image_url'] );
3530 -
3531 - $tmp_file = download_url( $image_url );
3532 - if ( is_wp_error( $tmp_file ) ) {
3533 - wp_send_json_error( 'Image could not be downloaded.' );
3534 - }
3535 -
3536 - if ( mime_content_type( $tmp_file ) !== 'image/png' ) {
3537 - unlink( $tmp_file );
3538 - wp_send_json_error( 'Not a PNG file.' );
3539 - }
3540 -
3541 - $src = imagecreatefrompng( $tmp_file );
3542 - imagesavealpha( $src, true );
3543 -
3544 - $width = imagesx( $src );
3545 - $height = imagesy( $src );
3546 -
3547 - $hasTransparency = false;
3548 - for ( $x = 0; $x < $width; $x++ ) {
3549 - for ( $y = 0; $y < $height; $y++ ) {
3550 - $rgba = imagecolorat( $src, $x, $y );
3551 - $alpha = ( $rgba & 0x7F000000 ) >> 24;
3552 -
3553 - if ( $alpha > 0 ) {
3554 - $hasTransparency = true;
3555 - break 2;
3556 - }
3557 - }
3558 - }
3559 -
3560 - if ( ! $hasTransparency ) {
3561 - unlink( $tmp_file );
3562 - wp_send_json_error( 'PNG has no transparent pixels.' );
3563 - }
3564 -
3565 - $upload_dir = wp_upload_dir();
3566 - $result_urls = array();
3567 -
3568 - foreach ( $img_colors as $name => $rgb ) {
3569 - $new = imagecreatetruecolor( $width, $height );
3570 - imagesavealpha( $new, true );
3571 - imagealphablending( $new, false );
3572 -
3573 - $transparent = imagecolorallocatealpha( $new, 0, 0, 0, 127 );
3574 - imagefill( $new, 0, 0, $transparent );
3575 -
3576 - for ( $x = 0; $x < $width; $x++ ) {
3577 - for ( $y = 0; $y < $height; $y++ ) {
3578 - $rgba = imagecolorat( $src, $x, $y );
3579 - $alpha = ( $rgba & 0x7F000000 ) >> 24;
3580 -
3581 - // Skip fully transparent pixels
3582 - if ( $alpha === 127 ) {
3583 - continue;
3584 - }
3585 -
3586 - // Replace pixel color directly
3587 - $new_r = $rgb[0];
3588 - $new_g = $rgb[1];
3589 - $new_b = $rgb[2];
3590 -
3591 - $color = imagecolorallocatealpha( $new, $new_r, $new_g, $new_b, $alpha );
3592 - imagesetpixel( $new, $x, $y, $color );
3593 - }
3594 - }
3595 -
3596 - $filename = 'colored-' . $name . '-' . time() . '.png';
3597 - $filepath = $upload_dir['path'] . '/' . $filename;
3598 -
3599 - imagepng( $new, $filepath );
3600 - imagedestroy( $new );
3601 -
3602 - $attachment = array(
3603 - 'post_mime_type' => 'image/png',
3604 - 'post_title' => sanitize_file_name( $filename ),
3605 - 'post_content' => '',
3606 - 'post_status' => 'inherit',
3607 - );
3608 -
3609 - $attach_id = wp_insert_attachment( $attachment, $filepath );
3610 - require_once ABSPATH . 'wp-admin/includes/image.php';
3611 - $attach_data = wp_generate_attachment_metadata( $attach_id, $filepath );
3612 - wp_update_attachment_metadata( $attach_id, $attach_data );
3613 -
3614 - $result_urls[ $name ] = wp_get_attachment_url( $attach_id );
3615 - }
3616 -
3617 - imagedestroy( $src );
3618 - unlink( $tmp_file );
3619 -
3620 - wp_send_json_success( $result_urls );
3621 - }
3622 -
3623 - /**
3624 - * change theme setting for import kit
3625 - *
3626 - * @since 2.0.0
3627 - */
3628 - protected function update_theme_setting() {
3629 - $theme_db = get_option( 'nxt-theme-options', false );
3630 -
3631 - $container_type = 'container-fluid';
3632 - $fluid_spacing = array(
3633 - 'md' => array(
3634 - 'left' => '0',
3635 - 'right' => '0',
3636 - ),
3637 - 'sm' => array(
3638 - 'left' => '',
3639 - 'right' => '',
3640 - ),
3641 - 'xs' => array(
3642 - 'left' => '',
3643 - 'right' => '',
3644 - ),
3645 - 'md-unit' => 'px',
3646 - 'sm-unit' => 'px',
3647 - 'xs-unit' => 'px',
3648 - );
3649 -
3650 - if ( isset( $theme_db ) ) {
3651 - $nexter_setting = $theme_db;
3652 - $nexter_setting['site-header-container'] = $container_type;
3653 - $nexter_setting['site-footer-container'] = $container_type;
3654 - $nexter_setting['site-layout-container'] = $container_type;
3655 - $nexter_setting['site-page-container'] = $container_type;
3656 -
3657 - $nexter_setting['header-fluid-spacing'] = $fluid_spacing;
3658 - $nexter_setting['footer-fluid-spacing'] = $fluid_spacing;
3659 - $nexter_setting['site-fluid-spacing'] = $fluid_spacing;
3660 - $nexter_setting['page-fluid-spacing'] = $fluid_spacing;
3661 -
3662 - update_option( 'nxt-theme-options', $nexter_setting );
3663 - } else {
3664 - $nexter_setting = array(
3665 - 'site-header-container' => 'container-fluid',
3666 - 'header-fluid-spacing' => array(
3667 - 'md' => array(
3668 - 'left' => '0',
3669 - 'right' => '0',
3670 - ),
3671 - 'sm' => array(
3672 - 'left' => '',
3673 - 'right' => '',
3674 - ),
3675 - 'xs' => array(
3676 - 'left' => '',
3677 - 'right' => '',
3678 - ),
3679 - 'md-unit' => 'px',
3680 - 'sm-unit' => 'px',
3681 - 'xs-unit' => 'px',
3682 - ),
3683 - 'site-footer-container' => 'container-fluid',
3684 - 'footer-fluid-spacing' => array(
3685 - 'md' => array(
3686 - 'left' => '0',
3687 - 'right' => '0',
3688 - ),
3689 - 'sm' => array(
3690 - 'left' => '',
3691 - 'right' => '',
3692 - ),
3693 - 'xs' => array(
3694 - 'left' => '',
3695 - 'right' => '',
3696 - ),
3697 - 'md-unit' => 'px',
3698 - 'sm-unit' => 'px',
3699 - 'xs-unit' => 'px',
3700 - ),
3701 - 'site-layout-container' => 'container-fluid',
3702 - 'site-fluid-spacing' => array(
3703 - 'md' => array(
3704 - 'left' => '0',
3705 - 'right' => '0',
3706 - ),
3707 - 'sm' => array(
3708 - 'left' => '',
3709 - 'right' => '',
3710 - ),
3711 - 'xs' => array(
3712 - 'left' => '',
3713 - 'right' => '',
3714 - ),
3715 - 'md-unit' => 'px',
3716 - 'sm-unit' => 'px',
3717 - 'xs-unit' => 'px',
3718 - ),
3719 - 'site-page-container' => 'container-fluid',
3720 - 'page-fluid-spacing' => array(
3721 - 'md' => array(
3722 - 'left' => '0',
3723 - 'right' => '0',
3724 - ),
3725 - 'sm' => array(
3726 - 'left' => '',
3727 - 'right' => '',
3728 - ),
3729 - 'xs' => array(
3730 - 'left' => '',
3731 - 'right' => '',
3732 - ),
3733 - 'md-unit' => 'px',
3734 - 'sm-unit' => 'px',
3735 - 'xs-unit' => 'px',
3736 - ),
3737 - 'site-page-container' => '',
3738 - 'site-posts-container' => '',
3739 - 'site-archive-container' => '',
3740 - );
3741 -
3742 - add_option( 'nxt-theme-options', $nexter_setting );
3743 - }
3744 -
3745 - $response = array(
3746 - 'message' => esc_html__( 'Theme Setting updated', 'wdesignkit' ),
3747 - 'description' => esc_html__( 'Theme Setting updated', 'wdesignkit' ),
3748 - 'success' => true,
3749 - );
3750 -
3751 - wp_send_json( $response );
3752 - wp_die();
3753 - }
3754 -
3755 - /**
3756 - * change site setting for import kit
3757 - *
3758 - * @since 2.0.0
3759 - */
3760 - protected function update_site_setting() {
3761 - $temp_id = isset( $_POST['id'] ) ? sanitize_text_field( wp_unslash( $_POST['id'] ) ) : '';
3762 - $shop_id = isset( $_POST['shop_id'] ) ? sanitize_text_field( wp_unslash( $_POST['shop_id'] ) ) : '';
3763 - $temp_type = isset( $_POST['temp_type'] ) ? sanitize_text_field( wp_unslash( $_POST['temp_type'] ) ) : 'page';
3764 - $site_name = isset( $_POST['site_name'] ) ? sanitize_text_field( wp_unslash( $_POST['site_name'] ) ) : '';
3765 - $site_tagline = isset( $_POST['site_tagline'] ) ? sanitize_text_field( wp_unslash( $_POST['site_tagline'] ) ) : '';
3766 -
3767 - $this->wdkit_nxt_thembuilder_update();
3768 -
3769 - if ( ! empty( $shop_id ) ) {
3770 - update_option( 'woocommerce_shop_page_id', $shop_id );
3771 - }
3772 -
3773 - if ( $temp_id ) {
3774 - update_option( 'show_on_front', $temp_type );
3775 - update_option( 'page_on_front', $temp_id );
3776 -
3777 - if ( ! empty( $site_name ) ) {
3778 - update_option( 'blogname', $site_name );
3779 - }
3780 -
3781 - if ( ! empty( $site_tagline ) ) {
3782 - update_option( 'blogdescription', $site_tagline );
3783 - }
3784 -
3785 - $response = array(
3786 - 'message' => esc_html__( 'Site link updated', 'wdesignkit' ),
3787 - 'description' => esc_html__( 'Site link updated', 'wdesignkit' ),
3788 - 'site_link' => get_site_url(),
3789 - 'success' => true,
3790 - );
3791 - } else {
3792 - $response = array(
3793 - 'message' => esc_html__( 'Site not found', 'wdesignkit' ),
3794 - 'description' => esc_html__( 'Site not found', 'wdesignkit' ),
3795 - 'success' => false,
3796 - );
3797 - }
3798 -
3799 - wp_send_json( $response );
3800 - wp_die();
3801 - }
3802 -
3803 - /**
3804 - * update theme builder
3805 - *
3806 - * @since 2.0.4
3807 - */
3808 - public function wdkit_nxt_thembuilder_update() {
3809 -
3810 - $page_information = isset( $_POST['page_information'] ) ? sanitize_text_field( wp_unslash( $_POST['page_information'] ) ) : '';
3811 - $page_information = json_decode( $page_information, true );
3812 -
3813 - if ( ! empty( $page_information ) && is_array( $page_information ) ) {
3814 - // Step 1: banavo mapping [ old_id => new_id ]
3815 - $id_mapping = array();
3816 - foreach ( $page_information as $page_info ) {
3817 - if ( ! empty( $page_info['old_page_id'] ) ) {
3818 - $id_mapping[ $page_info['old_page_id'] ] = $page_info['inserted_id'];
3819 - }
3820 - }
3821 -
3822 - // Step 2: loop karo and update exclude
3823 - foreach ( $page_information as $page_info ) {
3824 -
3825 - $post_id = $page_info['inserted_id'] ?? '';
3826 - $old_post_id = $page_info['old_page_id'] ?? '';
3827 - $post_type = $page_info['post_type'] ?? '';
3828 -
3829 - if ( empty( $old_post_id ) ) {
3830 - continue; // only update where old id exists
3831 - }
3832 -
3833 - if ( $post_type != 'nxt_builder' ) {
3834 - continue;
3835 - }
3836 -
3837 - $include_specific = get_post_meta( $post_id, 'nxt-hooks-layout-specific', true );
3838 - if ( ! empty( $include_specific ) && is_array( $include_specific ) ) {
3839 -
3840 - foreach ( $include_specific as $key => $val ) {
3841 -
3842 - // check karo ke koi old_id ka post match kare che ke nahi
3843 - foreach ( $id_mapping as $old_id => $new_id ) {
3844 - $search = 'post-' . $old_id;
3845 - $replace = 'post-' . $new_id;
3846 -
3847 - if ( $val === $search ) {
3848 - $include_specific[ $key ] = $replace;
3849 - }
3850 - }
3851 - }
3852 -
3853 - // save back updated array
3854 - update_post_meta( $post_id, 'nxt-hooks-layout-specific', $include_specific );
3855 - }
3856 -
3857 - // Get exclude meta
3858 - $exclude_specific = get_post_meta( $post_id, 'nxt-hooks-layout-exclude-specific', true );
3859 - if ( ! empty( $exclude_specific ) && is_array( $exclude_specific ) ) {
3860 -
3861 - foreach ( $exclude_specific as $key => $val ) {
3862 -
3863 - // check karo ke koi old_id ka post match kare che ke nahi
3864 - foreach ( $id_mapping as $old_id => $new_id ) {
3865 - $search = 'post-' . $old_id;
3866 - $replace = 'post-' . $new_id;
3867 -
3868 - if ( $val === $search ) {
3869 - $exclude_specific[ $key ] = $replace;
3870 - }
3871 - }
3872 - }
3873 -
3874 - // save back updated array
3875 - update_post_meta( $post_id, 'nxt-hooks-layout-exclude-specific', $exclude_specific );
3876 - }
3877 - }
3878 - }
3879 - }
3880 -
3881 - /**
3882 - *
3883 - * select team image for import kit
3884 - *
3885 - * @since 2.2.2
3886 - */
3887 - public function wdkit_check_user_credit() {
3888 - $array_data = array(
3889 - 'token' => isset( $_POST['token'] ) ? sanitize_text_field( $_POST['token'] ) : '',
3890 - );
3891 -
3892 - $response = $this->wkit_api_call( $array_data, 'ai/credits/get' );
3893 - $success = ! empty( $response['success'] ) ? $response['success'] : false;
3894 -
3895 - if ( empty( $success ) ) {
3896 - $response = array(
3897 - 'success' => false,
3898 - 'message' => esc_html__( 'Data Not Found', 'wdesignkit' ),
3899 - 'description' => esc_html__( 'Data not found', 'wdesignkit' ),
3900 - );
3901 -
3902 - wp_send_json( $response );
3903 - wp_die();
3904 - }
3905 -
3906 - $response = json_decode( wp_json_encode( $response['data'] ), true );
3907 -
3908 - wp_send_json( $response );
3909 - wp_die();
3910 - }
3911 -
3912 - public function wdkit_nxt_thembuilder_reset() {
3913 - $post_id = isset( $_POST['post_id'] ) ? sanitize_text_field( $_POST['post_id'] ) : '';
3914 - $sections_layout = get_post_meta( $post_id, 'nxt-hooks-layout-sections', true );
3915 -
3916 - if ( ( ! empty( $sections_layout ) && ( $sections_layout == 'header' || $sections_layout == 'footer' || $sections_layout == 'breadcrumb' || $sections_layout == 'hooks' ) ) ) {
3917 - if ( get_post_meta( $post_id, 'nxt-add-display-rule' ) ) {
3918 - delete_post_meta( $post_id, 'nxt-add-display-rule' );
3919 - }
3920 -
3921 - if ( get_post_meta( $post_id, 'nxt-hooks-layout-specific' ) ) {
3922 - update_post_meta( $post_id, 'nxt-hooks-layout-specific', '' );
3923 - }
3924 -
3925 - if ( get_post_meta( $post_id, 'nxt-exclude-display-rule' ) ) {
3926 - update_post_meta( $post_id, 'nxt-exclude-display-rule', '' );
3927 - }
3928 -
3929 - if ( get_post_meta( $post_id, 'nxt-hooks-layout-exclude-specific' ) ) {
3930 - update_post_meta( $post_id, 'nxt-hooks-layout-exclude-specific', '' );
3931 - }
3932 - }
3933 - }
3934 -
3935 -
3936 - /**
3937 1855 * Share with Me Template and widgets
3938 1856 *
3939 1857 * @since 1.0.0
3940 1858 */
@@ -4078,12 +1996,8 @@
4078 1996 if ( Wdkit_Wdesignkit::wdkit_is_compatible( 'gutenberg', 'widget' ) ) {
4079 1997 array_push( $builder, 'gutenberg' );
4080 1998 }
4081 1999
4082 - if ( Wdkit_Wdesignkit::wdkit_is_compatible( 'gutenberg_core', 'widget' ) ) {
4083 - array_push( $builder, 'gutenberg_core' );
4084 - }
4085 -
4086 2000 foreach ( $builder as $key => $name ) {
4087 2001 $elementor_dir = WDKIT_BUILDER_PATH . '/' . $name;
4088 2002
4089 2003 if ( ! empty( $elementor_dir ) && is_dir( $elementor_dir ) ) {
@@ -4091,10 +2005,10 @@
4091 2005 $elementor_list = array_diff( $elementor_list, array( '.', '..' ) );
4092 2006
4093 2007 if ( ! empty( $elementor_list ) ) {
4094 2008 foreach ( $elementor_list as $key => $value ) {
4095 - $a_c_s_d_s_c[ filemtime( "{$elementor_dir}/{$value}" ) . $key ]['data'] = $value;
4096 - $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;
4097 2011 }
4098 2012 }
4099 2013 }
4100 2014 }
@@ -4161,108 +2075,521 @@
4161 2075 wp_send_json( get_option( 'wkit_builder' ) );
4162 2076 }
4163 2077
4164 2078 /**
4165 - * Get Workspace data
4166 2079 *
4167 - * @since 2.2.5
2080 + * Custom_upload_dir
2081 + *
2082 + * @since 1.0.0
2083 + *
2084 + * @param array $upload store data.
4168 2085 */
4169 - 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 ) ) {
4170 2089
4171 - $wid = isset( $_POST['wid'] ) ? sanitize_text_field( $_POST['wid'] ) : '';
4172 - $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 + }
4173 2095
4174 - if ( empty( $wid ) ) {
4175 - 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' ),
4176 2126 'success' => false,
4177 - 'message' => esc_html__( 'Workspace ID Not Found', 'wdesignkit' ),
4178 - 'description' => esc_html__( 'Workspace ID is required', 'wdesignkit' ),
4179 2127 );
2128 +
2129 + wp_send_json( $responce );
2130 + wp_die();
4180 2131 }
4181 2132
4182 - if ( empty( $token ) ) {
4183 - 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' ),
4184 2164 'success' => false,
4185 - 'message' => esc_html__( 'Token Not Found', 'wdesignkit' ),
4186 - 'description' => esc_html__( 'Token is required', 'wdesignkit' ),
4187 2165 );
2166 +
2167 + wp_send_json( $responce );
2168 + wp_die();
4188 2169 }
4189 2170
4190 - $args = array(
4191 - 'token' => $token,
4192 - 'wid' => $wid,
4193 - );
2171 + $builder_type_path = trailingslashit( WDKIT_BUILDER_PATH ) . trailingslashit( $widget_type );
2172 + $widget_file_url = $builder_type_path . $folder_name;
4194 2173
4195 - $this->wdkit_api = $this->wdkit_api_v2;
2174 + if ( ! is_dir( $widget_file_url ) ) {
2175 + wp_mkdir_p( $widget_file_url );
2176 + }
4196 2177
4197 - $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;
4198 2183
4199 - $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( '.', '..' ) );
4200 2187
4201 - 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 );
4202 2331 wp_die();
4203 2332 }
4204 2333
4205 2334 /**
4206 2335 *
4207 - * Custom_upload_dir
2336 + * It is Use for delete widget from server
4208 2337 *
4209 2338 * @since 1.0.0
4210 - *
4211 - * @param array $upload store data.
4212 2339 */
4213 - public function custom_upload_dir( $upload ) {
4214 - // Specify the path to your custom upload directory.
4215 - 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 + }
4216 2345
4217 - // Set the custom directory as the upload path.
4218 - $upload['path'] = $this->widget_folder_u_r_l;
4219 - // Set the URL for the uploaded file.
4220 - $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 );
4221 2356 }
4222 2357
4223 - 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 + }
4224 2449 }
4225 2450
4226 2451 /**
4227 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 + *
4228 2466 * It is Use for delete widget from server
4229 2467 *
4230 2468 * @since 1.0.0
4231 2469 */
4232 - protected function wkit_widget_json() {
4233 - $widget_type = ! empty( $_POST['widget_type'] ) ? wp_unslash( $_POST['widget_type'] ) : '';
4234 - $folder_name = ! empty( $_POST['folder_name'] ) ? wp_unslash( $_POST['folder_name'] ) : '';
4235 - $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 ) );
4236 2473
4237 - if ( empty( $widget_type ) || empty( $folder_name ) || empty( $file_name ) ) {
4238 - 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(
4239 2483 'success' => false,
4240 - 'message' => esc_html__( 'Widget JSON not found', 'wdesignkit' ),
4241 - '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' ),
4242 2487 );
2488 +
2489 + wp_send_json( $result );
2490 + wp_die();
4243 2491 }
4244 2492
4245 - $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}";
4246 2495
4247 - $json_data = wp_json_file_decode( "$json_path.json" );
4248 - 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 +
4249 2511 $result = (object) array(
4250 2512 'success' => true,
4251 - 'data' => $json_data,
4252 - 'message' => esc_html__( 'Widget get Successfully', 'wdesignkit' ),
4253 - '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' ),
4254 2516 );
2517 +
2518 + wp_send_json( $result );
2519 + wp_die();
4255 2520 } else {
4256 2521 $result = (object) array(
4257 2522 'success' => false,
4258 - 'message' => esc_html__( 'Widget not get', 'wdesignkit' ),
4259 - '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' ),
4260 2526 );
2527 +
2528 + wp_send_json( $result );
2529 + wp_die();
4261 2530 }
2531 + }
4262 2532
4263 - wp_send_json( $result );
4264 - 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 + }
4265 2592 }
4266 2593
4267 2594 /**
4268 2595 *
@@ -4311,15 +2638,10 @@
4311 2638 wp_die();
4312 2639 }
4313 2640
4314 2641 $img_url = ! empty( $response['data']['image'] ) ? $response['data']['image'] : '';
4315 - $json_data = ! empty( $response['data']['json'] ) ? json_decode( $response['data']['json'], true ) : '';
2642 + $json_data = ! empty( $response['data']['json'] ) ? json_decode( $response['data']['json'] ) : '';
4316 2643
4317 - if ( empty( $response['success'] ) ) {
4318 - wp_send_json( $responce );
4319 - wp_die();
4320 - }
4321 -
4322 2644 if ( empty( $img_url ) && empty( $json_data ) ) {
4323 2645 $responce = (object) array(
4324 2646 'success' => false,
4325 2647 'message' => esc_html__( 'No Response Found', 'wdesignkit' ),
@@ -4333,16 +2655,12 @@
4333 2655 include_once ABSPATH . 'wp-admin/includes/file.php';
4334 2656 \WP_Filesystem();
4335 2657 global $wp_filesystem;
4336 2658
4337 - if ( ! is_array( $json_data ) ) {
4338 - $json_data = json_decode( $json_data, true );
4339 - }
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 ) : '';
4340 2662
4341 - $title = ! empty( $json_data['widget_data']['widgetdata']['name'] ) ? sanitize_text_field( $json_data['widget_data']['widgetdata']['name'] ) : '';
4342 - $builder = ! empty( $json_data['widget_data']['widgetdata']['type'] ) ? sanitize_text_field( $json_data['widget_data']['widgetdata']['type'] ) : '';
4343 - $w_uniq = ! empty( $json_data['widget_data']['widgetdata']['widget_id'] ) ? sanitize_text_field( $json_data['widget_data']['widgetdata']['widget_id'] ) : '';
4344 -
4345 2663 $folder_name = str_replace( ' ', '-', $title ) . '_' . $w_uniq;
4346 2664 $file_name = str_replace( ' ', '_', $title ) . '_' . $w_uniq;
4347 2665 $builder_type_path = WDKIT_BUILDER_PATH . "/{$builder}/";
4348 2666
@@ -4358,9 +2676,9 @@
4358 2676 $img_body = wp_remote_get( $img_url );
4359 2677 $img_ext = pathinfo( $img_url )['extension'];
4360 2678
4361 2679 $wp_filesystem->put_contents( WDKIT_BUILDER_PATH . "/$builder/$folder_name/$file_name.$img_ext", $img_body['body'] );
4362 - $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";
4363 2681 }
4364 2682
4365 2683 $result = (object) array(
4366 2684 'success' => false,
@@ -4374,8 +2692,87 @@
4374 2692 }
4375 2693
4376 2694 /**
4377 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 + *
4378 2775 * It is Use for sync widget to server
4379 2776 *
4380 2777 * @since 1.0.0
4381 2778 */
@@ -4380,10 +2777,9 @@
4380 2777 * @since 1.0.0
4381 2778 */
4382 2779 protected function wdkit_add_widget() {
4383 2780 $data = ! empty( $_POST['widget_info'] ) ? $this->wdkit_sanitizer_bypass( $_POST, 'widget_info', 'none' ) : '';
4384 - $data = base64_decode( $data );
4385 - $data = json_decode( $data );
2781 + $data = json_decode( stripslashes( $data ) );
4386 2782
4387 2783 $title = isset( $data->title ) ? sanitize_text_field( $data->title ) : '';
4388 2784 $builder = isset( $data->builder ) ? sanitize_text_field( $data->builder ) : '';
4389 2785 $w_uniq = isset( $data->w_uniq ) ? sanitize_text_field( $data->w_uniq ) : '';
@@ -4406,9 +2802,8 @@
4406 2802 'w_imgext' => isset( $data->w_imgext ) ? sanitize_text_field( $data->w_imgext ) : '',
4407 2803 'w_version' => isset( $data->w_version ) ? $data->w_version : '',
4408 2804 'w_updates' => ! empty( $data->w_updates ) ? serialize( $data->w_updates ) : serialize( array() ),
4409 2805 'r_id' => isset( $data->r_id ) ? $data->r_id : 0,
4410 - 'unique_id' => get_option( 'wdkit_unique_id' ) ?? '',
4411 2806 );
4412 2807
4413 2808 $response = $this->wkit_api_call( $array_data, 'save_widget' );
4414 2809 $success = ! empty( $response['success'] ) ? $response['success'] : false;
@@ -4431,9 +2826,8 @@
4431 2826 $response = json_decode( wp_json_encode( $res ), true );
4432 2827 $img_url = ! empty( $response['data']['imgurl'] ) ? $response['data']['imgurl'] : '';
4433 2828
4434 2829 if ( ! empty( $img_url ) && 'error' !== $res ) {
4435 -
4436 2830 $img_body = wp_remote_get( $img_url );
4437 2831 $img_ext = pathinfo( $img_url )['extension'];
4438 2832 include_once ABSPATH . 'wp-admin/includes/file.php';
4439 2833 \WP_Filesystem();
@@ -4514,9 +2908,9 @@
4514 2908 *
4515 2909 * @since 1.0.0
4516 2910 */
4517 2911 protected static function wkit_get_settings_panel() {
4518 - $new_version = '';
2912 +
4519 2913 $current_version = WDKIT_VERSION;
4520 2914 $response = wp_remote_get( 'https://api.wordpress.org/plugins/info/1.0/wdesignkit.json' );
4521 2915
4522 2916 if ( is_wp_error( $response ) ) {
@@ -4541,104 +2935,23 @@
4541 2935 }
4542 2936
4543 2937 $get_setting = get_option( 'wkit_settings_panel', false );
4544 2938
4545 - $setting_data = array(
4546 - 'builder' => isset( $get_setting['builder'] ) ? $get_setting['builder'] : true,
4547 - 'template' => isset( $get_setting['template'] ) ? $get_setting['template'] : true,
4548 - 'gutenberg_builder' => isset( $get_setting['gutenberg_builder'] ) ? $get_setting['gutenberg_builder'] : true,
4549 - 'gutenberg_core_builder' => isset( $get_setting['gutenberg_core_builder'] ) ? $get_setting['gutenberg_core_builder'] : false,
4550 - 'elementor_builder' => isset( $get_setting['elementor_builder'] ) ? $get_setting['elementor_builder'] : true,
4551 - 'bricks_builder' => isset( $get_setting['bricks_builder'] ) ? $get_setting['bricks_builder'] : false,
4552 - 'gutenberg_template' => isset( $get_setting['gutenberg_template'] ) ? $get_setting['gutenberg_template'] : true,
4553 - 'elementor_template' => isset( $get_setting['elementor_template'] ) ? $get_setting['elementor_template'] : true,
4554 - 'code_snippet' => isset( $get_setting['code_snippet'] ) ? $get_setting['code_snippet'] : true,
4555 - '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,
4556 2949 );
4557 -
4558 - if ( isset( $get_setting['remove_db'] ) ) {
4559 - $setting_data['remove_db'] = $get_setting['remove_db'];
4560 - }
4561 -
4562 - if ( isset( $get_setting['debugger_mode'] ) ) {
4563 - $setting_data['debugger_mode'] = $get_setting['debugger_mode'];
4564 - }
4565 -
4566 - return $setting_data;
4567 2950 }
4568 2951
4569 2952 /**
4570 - * Updated White Label Data.
4571 2953 *
4572 - * @since 1.1.8
4573 - */
4574 - protected function wkit_white_label() {
4575 -
4576 - $get_wl_data = ! empty( $_POST['WhiteLabelData'] ) ? wp_unslash( $_POST['WhiteLabelData'] ) : array();
4577 -
4578 - if ( ! empty( $get_wl_data ) ) {
4579 - $white_label_data = json_decode( $get_wl_data, true );
4580 - $plugin_name = $white_label_data['plugin_name'];
4581 - } else {
4582 - $result = array(
4583 - 'success' => false,
4584 - 'message' => esc_html__( 'Data Not Found', 'wdesignkit' ),
4585 - );
4586 -
4587 - wp_send_json( $result );
4588 - wp_die();
4589 - }
4590 -
4591 - if ( ! empty( $plugin_name ) ) {
4592 - $get_white_label = get_option( 'wkit_white_label', false );
4593 - if ( ! empty( $get_white_label ) ) {
4594 - update_option( 'wkit_white_label', $white_label_data );
4595 - } else {
4596 - add_option( 'wkit_white_label', $white_label_data );
4597 - }
4598 - } else {
4599 - $result = array(
4600 - 'success' => false,
4601 - 'message' => esc_html__( 'Plugin Name Not Found', 'wdesignkit' ),
4602 - );
4603 -
4604 - wp_send_json( $result );
4605 - wp_die();
4606 - }
4607 -
4608 - $get_updated_data = get_option( 'wkit_white_label', false );
4609 - $response = array(
4610 - 'message' => 'Data Added successfully',
4611 - 'success' => true,
4612 - 'data' => $get_updated_data,
4613 - );
4614 -
4615 - wp_send_json( $response );
4616 - }
4617 -
4618 - /**
4619 - * Reset White Label Data.
4620 - *
4621 - * @since 1.1.8
4622 - */
4623 - public function wkit_reset_wl() {
4624 - $wl_data = get_option( 'wkit_white_label' );
4625 -
4626 - if ( ! empty( $wl_data ) ) {
4627 - delete_option( 'wkit_white_label' );
4628 -
4629 - $result = array(
4630 - 'success' => true,
4631 - 'message' => esc_html__( 'Reset White Label Successfully', 'wdesignkit' ),
4632 - );
4633 -
4634 - wp_send_json( $result );
4635 - wp_die();
4636 - }
4637 - }
4638 -
4639 - /**
4640 - *
4641 2954 * Use for Add new licence key.
4642 2955 *
4643 2956 * @since 1.0.0
4644 2957 */
@@ -4651,38 +2964,9 @@
4651 2964 );
4652 2965
4653 2966 $response = $this->wkit_api_call( $args, 'wkit_activate_key' );
4654 2967
4655 - if ( ! empty( $response['data'] ) ) {
4656 - $response = json_decode( wp_json_encode( $response['data'] ), true );
4657 -
4658 - if ( ! empty( $response['data']['tpae_licence'] ) && is_serialized( $response['data']['tpae_licence'] ) ) {
4659 - $response['data']['tpae_licence'] = unserialize( $response['data']['tpae_licence'] );
4660 - }
4661 -
4662 - if ( ! empty( $response['data']['tpag_licence'] ) && is_serialized( $response['data']['tpag_licence'] ) ) {
4663 - $response['data']['tpag_licence'] = unserialize( $response['data']['tpag_licence'] );
4664 - }
4665 -
4666 - if ( ! empty( $response['data']['uichemy_licence'] ) && is_serialized( $response['data']['uichemy_licence'] ) ) {
4667 - $response['data']['uichemy_licence'] = unserialize( $response['data']['uichemy_licence'] );
4668 - }
4669 -
4670 - if ( ! empty( $response['data']['wdkit_licence'] ) && is_serialized( $response['data']['wdkit_licence'] ) ) {
4671 - $response['data']['wdkit_licence'] = unserialize( $response['data']['wdkit_licence'] );
4672 -
4673 - // Store WDesignKit license status locally for quick access
4674 - if ( ! empty( $response['data']['wdkit_licence'] ) && is_array( $response['data']['wdkit_licence'] ) ) {
4675 - update_option( 'wdkit_licence_data', $response['data']['wdkit_licence'] );
4676 - }
4677 - }
4678 -
4679 - if ( ! empty( $response['data']['wdkit_licence_extra'] ) && is_serialized( $response['data']['wdkit_licence_extra'] ) ) {
4680 - $response['data']['wdkit_licence_extra'] = unserialize( $response['data']['wdkit_licence_extra'] );
4681 - }
4682 - }
4683 -
4684 - wp_send_json( $response );
2968 + wp_send_json( $response['data'] );
4685 2969 wp_die();
4686 2970 }
4687 2971
4688 2972 /**
@@ -4693,23 +2977,16 @@
4693 2977 */
4694 2978 protected function wdkit_delete_licence_key() {
4695 2979 $token = ! empty( $_POST['token'] ) ? sanitize_text_field( wp_unslash( $_POST['token'] ) ) : '';
4696 2980 $licencename = ! empty( $_POST['licencename'] ) ? sanitize_text_field( wp_unslash( $_POST['licencename'] ) ) : '';
4697 - $apikey = ! empty( $_POST['apikey'] ) ? sanitize_text_field( wp_unslash( $_POST['apikey'] ) ) : '';
4698 2981
4699 2982 $args = array(
4700 2983 'token' => $token,
4701 2984 'licencename' => $licencename,
4702 - 'apikey' => $apikey,
4703 2985 );
4704 2986
4705 2987 $response = $this->wkit_api_call( $args, 'licence_delete' );
4706 2988
4707 - // Remove local WDesignKit license data if deleting WDesignKit license
4708 - if ( 'wdkit' === $licencename ) {
4709 - delete_option( 'wdkit_licence_data' );
4710 - }
4711 -
4712 2989 wp_send_json( $response['data'] );
4713 2990 wp_die();
4714 2991 }
4715 2992
@@ -4734,118 +3011,9 @@
4734 3011 wp_die();
4735 3012 }
4736 3013
4737 3014 /**
4738 - * Rollback to Previous Versions
4739 3015 *
4740 - * @since 1.1.0
4741 - */
4742 - protected function wdkit_prev_version() {
4743 -
4744 - require_once ABSPATH . 'wp-admin/includes/plugin-install.php';
4745 -
4746 - $plugin_info = plugins_api(
4747 - 'plugin_information',
4748 - array(
4749 - 'slug' => 'wdesignkit',
4750 - )
4751 - );
4752 -
4753 - if ( empty( $plugin_info->versions ) || ! is_array( $plugin_info->versions ) ) {
4754 - return array();
4755 - }
4756 -
4757 - krsort( $plugin_info->versions );
4758 -
4759 - $versions_list = array();
4760 - $index = 0;
4761 -
4762 - foreach ( $plugin_info->versions as $version => $download_link ) {
4763 -
4764 - $lowercase_version = strtolower( $version );
4765 -
4766 - $is_valid_version = ! preg_match( '/(beta|rc|trunk|dev)/i', $lowercase_version );
4767 -
4768 - $is_valid_version = apply_filters( 'wdkit_check_rollback_version', $is_valid_version, $lowercase_version );
4769 -
4770 - if ( ! $is_valid_version || version_compare( $version, WDKIT_VERSION, '>=' ) ) {
4771 - continue;
4772 - }
4773 -
4774 - $versions_list[] = $version;
4775 - ++$index;
4776 - }
4777 -
4778 - // set_transient( 'wdkit_rollback_version_' . WDKIT_VERSION, $versions_list, WEEK_IN_SECONDS );
4779 -
4780 - return $versions_list;
4781 - }
4782 -
4783 - /**
4784 - * Rollback to Previous Versions
4785 - *
4786 - * @since 1.1.0
4787 - */
4788 - protected function wdkit_rollback_check() {
4789 -
4790 - $current_ver = isset( $_POST['version'] ) ? sanitize_text_field( wp_unslash( $_POST['version'] ) ) : '';
4791 - $rv = $this->wdkit_prev_version();
4792 -
4793 - if ( empty( $current_ver ) || ! in_array( $current_ver, $rv ) ) {
4794 - return array(
4795 - 'message' => esc_html__( 'Invalid Nonce or version not found', 'wdesignkit' ),
4796 - 'status' => 'error',
4797 - 'success' => false,
4798 - );
4799 - }
4800 -
4801 - $plugin_slug = basename( WDKIT_PBNAME, '.php' );
4802 -
4803 - $this_version = $current_ver;
4804 - $this_pluginname = WDKIT_PBNAME;
4805 - $this_plugin_u_r_l = sprintf( 'https://downloads.wordpress.org/plugin/%s.%s.zip', $plugin_slug, $this_version );
4806 -
4807 - $plugin_info = new \stdClass();
4808 - $plugin_info->new_version = $this_version;
4809 - $plugin_info->slug = $plugin_slug;
4810 - $plugin_info->package = $this_plugin_u_r_l;
4811 - $plugin_info->url = 'https://wdesignkit.com/';
4812 -
4813 - $update_plugins_data = get_site_transient( 'update_plugins' );
4814 -
4815 - if ( ! is_object( $update_plugins_data ) ) {
4816 - $update_plugins_data = new \stdClass();
4817 - }
4818 -
4819 - $update_plugins_data->response[ $this_pluginname ] = $plugin_info;
4820 -
4821 - set_site_transient( 'update_plugins', $update_plugins_data );
4822 -
4823 - require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
4824 -
4825 - $logo_url = WDKIT_URL . 'assets/images/jpg/Wdesignkit-logo.png';
4826 -
4827 - $args = array(
4828 - 'url' => 'update.php?action=upgrade-plugin&plugin=' . rawurlencode( $this_pluginname ),
4829 - 'plugin' => $this_pluginname,
4830 - 'nonce' => 'upgrade-plugin_' . $this_pluginname,
4831 - 'title' => '<img src="' . esc_url( $logo_url ) . '" alt="wdesignkit-logo"><div class="theplus-rb-subtitle">' . esc_html__( 'Rollback to Previous Version', 'wdesignkit' ) . '</div>',
4832 - );
4833 -
4834 - $upgrader_plugin = new \Plugin_Upgrader( new \Plugin_Upgrader_Skin( $args ) );
4835 - $upgrader_plugin->upgrade( $this_pluginname );
4836 -
4837 - activate_plugin( $this_pluginname );
4838 -
4839 - return array(
4840 - 'message' => esc_html__( 'Rollback Successful, Plugin Re-activated', 'wdesignkit' ),
4841 - 'status' => 'Success',
4842 - 'success' => true,
4843 - );
4844 - }
4845 -
4846 - /**
4847 - *
4848 3016 * It is Use for logout.
4849 3017 *
4850 3018 * @since 1.0.0
4851 3019 */
@@ -4860,10 +3028,8 @@
4860 3028 $args = array( 'token' => $token );
4861 3029
4862 3030 if ( 'session' !== $logout_type ) {
4863 3031 delete_transient( 'wdkit_auth_' . $email );
4864 - // Clear stored license data on logout so banner shows again
4865 - delete_option( 'wdkit_licence_data' );
4866 3032 $response = WDesignKit_Data_Query::get_data( 'logout', $args );
4867 3033 }
4868 3034 }
4869 3035
@@ -4910,9 +3076,24 @@
4910 3076 return $data[ $type ];
4911 3077 }
4912 3078 }
4913 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' ) {
4914 3090
3091 + if ( 'name' === $condition ) {
3092 + return wp_normalize_path( $data[ $type ]['tmp_name'] );
3093 + }
3094 + }
3095 +
4915 3096 /**
4916 3097 * Parse args $_POST
4917 3098 *
4918 3099 * @since 1.0.0
@@ -4988,28 +3169,8 @@
4988 3169 if ( isset( $data['plugin'] ) ) {
4989 3170 $args['plugin'] = isset( $data['plugin'] ) ? wp_unslash( $data['plugin'] ) : array();
4990 3171 }
4991 3172
4992 - if ( isset( $data['plugin_exclude'] ) ) {
4993 - $args['plugin_exclude'] = isset( $data['plugin_exclude'] ) ? wp_unslash( $data['plugin_exclude'] ) : array();
4994 - }
4995 -
4996 - if ( isset( $data['ai_compatibility'] ) ) {
4997 - $args['ai_compatibility'] = isset( $data['ai_compatibility'] ) ? wp_unslash( $data['ai_compatibility'] ) : array();
4998 - }
4999 -
5000 - // if ( isset( $data['global_color'] ) ) {
5001 - // $args['global_color'] = isset( $data['global_color'] ) ? wp_unslash( $data['global_color'] ) : array();
5002 - // }
5003 -
5004 - // if ( isset( $data['global_font_family'] ) ) {
5005 - // $args['global_font_family'] = isset( $data['global_font_family'] ) ? wp_unslash( $data['global_font_family'] ) : array();
5006 - // }
5007 -
5008 - if ( isset( $data['global_data'] ) ) {
5009 - $args['global_data'] = isset( $data['global_data'] ) ? wp_unslash( $data['global_data'] ) : array();
5010 - }
5011 -
5012 3173 if ( isset( $data['tag'] ) ) {
5013 3174 $args['tag'] = isset( $data['tag'] ) ? wp_unslash( $data['tag'] ) : array();
5014 3175 }
5015 3176
@@ -5038,34 +3199,8 @@
5038 3199 }
5039 3200
5040 3201 return $args;
5041 3202 }
5042 -
5043 - /**
5044 - * Dark Mode
5045 - *
5046 - * @since 2.0.0
5047 - *
5048 - * @param string store darkmode value in database.
5049 - */
5050 - protected function wdkit_dark_mode() {
5051 - $dark_mode = ! empty( $_POST['dark_mode'] ) ? sanitize_text_field( $_POST['dark_mode'] ) : 'light';
5052 -
5053 - if ( get_option( 'wdkit_dark_mode' ) ) {
5054 - update_option( 'wdkit_dark_mode', $dark_mode );
5055 - } else {
5056 - add_option( 'wdkit_dark_mode', $dark_mode );
5057 - }
5058 -
5059 - $response = array(
5060 - 'message' => esc_html__( 'Dark Mode Updated', 'wdesignkit' ),
5061 - 'status' => 'Success',
5062 - 'success' => true,
5063 - );
5064 -
5065 - wp_send_json( $response );
5066 - wp_die();
5067 - }
5068 3203 }
5069 3204
5070 3205 Wdkit_Api_Call::get_instance();
5071 -}
3206 +}