PluginProbe
Listdom: AI-powered Business Directory with Classifieds Ads Listings / trunk
Listdom: AI-powered Business Directory with Classifieds Ads Listings vtrunk
6.0.0 5.9.0 5.8.1 5.8.0 5.7.0 5.6.0 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.1.1 1.2.0 1.2.1 1.3.0 1.3.1 1.4.0 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.7.0 1.8.0 1.9.0 All 75 releases
listdom / app / includes / author.php

author.php in Listdom: AI-powered Business Directory with Classifieds Ads Listings trunk, at app/includes/author.php

81 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class LSD_Author extends LSD_Base
4 {
5 public function init()
6 {
7 add_action('show_user_profile', [$this, 'form']);
8 add_action('edit_user_profile', [$this, 'form']);
9
10 add_action('personal_options_update', [$this, 'save']);
11 add_action('edit_user_profile_update', [$this, 'save']);
12 }
13
14 public function form($user)
15 {
16 // Generate output
17 include $this->include_html_file('metaboxes/author/form.php', ['return_path' => true]);
18 }
19
20 public function save($user_id): bool
21 {
22 // No Access
23 if (!current_user_can('edit_user', $user_id)) return false;
24
25 $nonce = isset($_POST['_wpnonce']) ? sanitize_text_field(wp_unslash($_POST['_wpnonce'])) : '';
26 if (!$nonce || !wp_verify_nonce($nonce, 'update-user_' . $user_id)) return false;
27
28 $profile_fields = LSD_User::profile_edit_fields();
29
30 // Job Title
31 if (!empty($profile_fields['job_title']))
32 {
33 update_user_meta($user_id, 'lsd_job_title', isset($_POST['lsd_job_title'])
34 ? sanitize_text_field(wp_unslash($_POST['lsd_job_title']))
35 : ''
36 );
37 }
38
39 // Save Social Networks
40 if (LSD_User::has_enabled_profile_social_fields()) do_action('lsd_social_networks_profile_save', $user_id);
41
42 // Phone
43 if (!empty($profile_fields['phone']))
44 {
45 update_user_meta($user_id, 'lsd_phone', isset($_POST['lsd_phone'])
46 ? sanitize_text_field(wp_unslash($_POST['lsd_phone']))
47 : ''
48 );
49 }
50
51 // Mobile
52 if (!empty($profile_fields['mobile']))
53 {
54 update_user_meta($user_id, 'lsd_mobile', isset($_POST['lsd_mobile'])
55 ? sanitize_text_field(wp_unslash($_POST['lsd_mobile']))
56 : ''
57 );
58 }
59
60 // Website
61 if (!empty($profile_fields['website']))
62 {
63 update_user_meta($user_id, 'lsd_website', isset($_POST['lsd_website'])
64 ? sanitize_text_field(wp_unslash($_POST['lsd_website']))
65 : ''
66 );
67 }
68
69 // Fax
70 if (!empty($profile_fields['fax']))
71 {
72 update_user_meta($user_id, 'lsd_fax', isset($_POST['lsd_fax'])
73 ? sanitize_text_field(wp_unslash($_POST['lsd_fax']))
74 : ''
75 );
76 }
77
78 return true;
79 }
80 }
81