PluginProbe ʕ •ᴥ•ʔ
Atarim – AI Agency for WordPress: Edit Pages, Fix Code, Update Plugins, SEO & Client Feedback / 5.1.3
Atarim – AI Agency for WordPress: Edit Pages, Fix Code, Update Plugins, SEO & Client Feedback v5.1.3
5.1.3 5.1.2 5.1.1 5.1 5.0 trunk 3.10 3.11 3.12 3.13 3.14 3.15 3.16 3.17 3.18 3.19 3.2.0 3.2.1 3.22 3.22.1 3.22.2 3.22.3 3.22.4 3.22.5 3.22.6 3.3.0 3.3.1 3.3.2 3.3.2.1 3.3.2.2 3.3.3 3.30 3.31 3.32 3.4 3.4.1 3.4.3 3.4.4 3.5 3.5.1 3.6 3.6.1 3.7 3.8 3.9 3.9.1 3.9.2 3.9.3 3.9.4 3.9.6 3.9.6.1 4.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.0.9 4.1.0 4.1.1 4.1.2 4.1.3 4.2 4.2.1 4.2.2 4.3 4.3.1 4.3.2 4.3.3 4.3.4 4.3.5 4.4
atarim-visual-collaboration / includes / class-ajax-functions.php
atarim-visual-collaboration / includes Last commit date
class-ajax-functions.php 2 days ago class-define-constant.php 2 days ago class-functions.php 2 days ago do-it.php 2 days ago inject-script.php 2 days ago
class-ajax-functions.php
104 lines
1 <?php
2 if (! defined('ABSPATH')) {
3 exit; // Exit if accessed directly
4 }
5 function avcf_deactivate_collab() {
6 $function = new AVCF_Functions();
7 if (! $function->avcf_validate_nonce() || ! is_user_logged_in()) {
8 wp_send_json_error(['message' => 'Unauthorized access.'], 403);
9 exit;
10 }
11
12 if ( ! current_user_can('manage_options') ) {
13 wp_send_json_error(['message' => 'Forbidden.'], 403);
14 }
15
16 $function->avcf_update_settings('avc_collab_active', 'no');
17 exit;
18 }
19 add_action('wp_ajax_avcf_deactivate_collab', 'avcf_deactivate_collab');
20
21 function avcf_user_consent() {
22 $function = new AVCF_Functions();
23 if (! $function->avcf_validate_nonce() || ! is_user_logged_in()) {
24 wp_send_json_error(['message' => 'Unauthorized access.'], 403);
25 exit;
26 }
27
28 $site_id = $function->avcf_get_setting_data('avc_site_id');
29 $email = $function->avcf_get_user_detail('email');
30 $fname = $function->avcf_get_user_detail('first_name');
31 $lname = $function->avcf_get_user_detail('last_name');
32
33 if (is_wp_error($email)) {
34 wp_send_json_error(['message' => $email->get_error_message()], 400);
35 exit;
36 }
37
38 $payload = [
39 'site_id' => $site_id,
40 'email' => $email,
41 'name' => $fname . ' ' . $lname,
42 'source' => 'wordpress',
43 'apikey' => 'ab497511-9293-4e36-8e8b-fe3fdf0c4086',
44 'apiurl' => AVCF_CRM_API . 'wp-api/user/auth',
45 ];
46
47 wp_send_json_success($payload);
48 exit;
49 }
50 add_action('wp_ajax_avcf_user_consent', 'avcf_user_consent');
51
52 function avcf_set_user_consent_status() {
53 $function = new AVCF_Functions();
54 if (! $function->avcf_validate_nonce() || ! is_user_logged_in()) {
55 wp_send_json_error(['message' => 'Unauthorized access.'], 403);
56 exit;
57 }
58
59 $user_id = $function->avcf_get_user_detail('id');
60 update_user_meta($user_id, 'avc_consent_status', true);
61
62 wp_send_json_success(['message' => 'Consent status updated.']);
63 }
64 add_action('wp_ajax_avcf_set_user_consent_status', 'avcf_set_user_consent_status');
65
66 function avcf_save_avcf_settings() {
67 if ( ! is_user_logged_in() ) {
68 wp_send_json_error( [ 'message' => 'Authentication required.' ], 401 );
69 }
70
71 if ( ! current_user_can( 'manage_options' ) ) {
72 wp_send_json_error( [ 'message' => 'Unauthorized.' ], 403 );
73 }
74
75 $nonce = '';
76 if ( isset($_SERVER['HTTP_X_AVC_NONCE']) ) {
77 $nonce = sanitize_text_field( wp_unslash($_SERVER['HTTP_X_AVC_NONCE']) );
78 }
79
80 if ( ! wp_verify_nonce( $nonce, 'avc-script-nonce' ) ) {
81 wp_send_json_error(['message' => 'Invalid nonce.'], 403);
82 }
83
84 $function = new AVCF_Functions();
85 $data = json_decode(file_get_contents('php://input'), true);
86
87 $allowed_fields = ['avc_selected_role', 'avc_website_developer', 'avc_enable_doit'];
88
89 foreach ($data as $key => $value) {
90 if (! in_array($key, $allowed_fields, true)) {
91 $key = sanitize_text_field($key);
92 wp_send_json_error(['message' => 'Invalid setting field: ' . esc_html($key)]);
93 }
94
95 if ($key === 'avc_enable_doit') {
96 $value = ! empty($value) ? '1' : '0';
97 }
98
99 $function->avcf_update_settings($key, $value);
100 }
101
102 wp_send_json_success(['message' => 'Settings saved']);
103 }
104 add_action('wp_ajax_avcf_save_settings', 'avcf_save_avcf_settings');