PluginProbe
King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder / 51.1.36
King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder v51.1.36
51.1.83 51.1.82 51.1.81 51.1.79 51.1.78 51.1.77 51.1.76 51.1.74 51.1.75 51.1.65 51.1.64 51.1.63 trunk 51.1.14 51.1.2 51.1.35 51.1.36 51.1.37 51.1.38 51.1.39 51.1.44 51.1.45 51.1.46 51.1.47 51.1.49 All 37 releases
king-addons / includes / widgets / Form_Builder / helpers / Update_Action_Meta.php

Update_Action_Meta.php in King Addons for Elementor – 80+ Elementor Widgets, 4 000+ Elementor Templates, WooCommerce, Mega Menu, Popup Builder 51.1.36, at includes/widgets/Form_Builder/helpers/Update_Action_Meta.php

76 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace King_Addons;
4
5 if (!defined('ABSPATH')) {
6 exit;
7 }
8
9 class Update_Action_Meta
10 {
11
12 public function __construct()
13 {
14 add_action('wp_ajax_king_addons_update_form_action_meta', [$this, 'king_addons_update_form_action_meta']);
15 add_action('wp_ajax_nopriv_king_addons_update_form_action_meta', [$this, 'king_addons_update_form_action_meta']);
16 }
17
18
19 public function king_addons_update_form_action_meta()
20 {
21 $nonce = $_POST['nonce'];
22
23 if (!wp_verify_nonce($nonce, 'king-addons-js')) {
24 return;
25 }
26
27
28 $custom_token = $_POST['custom_token'];
29
30 if (is_user_logged_in()) {
31
32 $user_id = get_current_user_id();
33 $stored_token = get_transient('king_addons_custom_token_' . $user_id);
34 } else {
35
36 if (isset($_COOKIE['king_addons_guest_token'])) {
37 $guest_id = sanitize_text_field($_COOKIE['king_addons_guest_token']);
38 $stored_token = get_transient('king_addons_custom_guest_token_' . $guest_id);
39 } else {
40 wp_send_json_error('Invalid token.');
41 return;
42 }
43 }
44
45 if (!$stored_token || $custom_token !== $stored_token) {
46 wp_send_json_error('Invalid token.');
47 return;
48 }
49
50 $post_id = isset($_POST['post_id']) ? intval($_POST['post_id']) : 0;
51 $action_name = isset($_POST['action_name']) ? sanitize_text_field($_POST['action_name']) : '';
52 $status = isset($_POST['status']) ? sanitize_text_field($_POST['status']) : '';
53 $message = isset($_POST['message']) ? sanitize_text_field($_POST['message']) : '';
54
55 $meta_value = [
56 'status' => $status,
57 'message' => $message
58 ];
59
60 $actions_whitelist = [
61 'king_addons_form_builder_email',
62 'king_addons_form_builder_submissions',
63 'king_addons_form_builder_mailchimp',
64 'king_addons_form_builder_webhook'
65 ];
66
67 if ($post_id && $action_name && $status && in_array($action_name, $actions_whitelist)) {
68 update_post_meta($post_id, '_action_' . $action_name, $meta_value);
69 wp_send_json_success('Post meta updated successfully');
70 } else {
71 wp_send_json_error('Invalid data provided');
72 }
73 }
74 }
75
76 new Update_Action_Meta();