PluginProbe ʕ •ᴥ•ʔ
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress / trunk
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress vtrunk
4.16.18 4.16.17 4.16.16 trunk 1.0 1.0.1 1.0.2 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.5a 1.1.6 1.1.7 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.4 1.4.1 1.4.2 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.7 1.7.1 1.7.2 1.8 1.8.1 1.8.10 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.1.9 2.2.10 2.2.11 2.2.12 2.2.13 2.2.14 2.2.15 2.2.16 2.2.2 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 3.0 3.1 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.14 3.2.15 3.2.16 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 4.0.0 4.0.1 4.0.2 4.0.3 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.10.0 4.10.1 4.10.2 4.10.3 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.13.3 4.13.4 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.15.0 4.15.1 4.15.10 4.15.11 4.15.12 4.15.13 4.15.14 4.15.15 4.15.16 4.15.17 4.15.18 4.15.19 4.15.2 4.15.20 4.15.20.1 4.15.21 4.15.22 4.15.23 4.15.24 4.15.25 4.15.3 4.15.4 4.15.5 4.15.6 4.15.7 4.15.8 4.15.9 4.16.0 4.16.1 4.16.10 4.16.11 4.16.12 4.16.13 4.16.14 4.16.15 4.16.2 4.16.3 4.16.4 4.16.5 4.16.6 4.16.7 4.16.8 4.16.9 4.2.0 4.3.0 4.3.1 4.3.2 4.4.0 4.4.1 4.5.0 4.5.1 4.5.2 4.5.3 4.5.4 4.5.5 4.6.0 4.7.0 4.8.0 4.9.0
wp-user-avatar / src / Classes / WPProfileFieldParserTrait.php
wp-user-avatar / src / Classes Last commit date
Installer 3 years ago AdminNotices.php 1 month ago AjaxHandler.php 1 year ago Autologin.php 9 months ago BlockRegistrations.php 10 months ago BuddyPressBbPress.php 3 years ago DisableConcurrentLogins.php 2 years ago EditUserProfile.php 5 months ago ExtensionManager.php 1 month ago FileUploader.php 3 months ago FormPreviewHandler.php 5 months ago FormRepository.php 1 year ago FormShortcodeDefaults.php 1 month ago GDPR.php 3 years ago Geolocation.php 3 years ago GlobalSiteAccess.php 3 years ago ImageUploader.php 1 year ago LoginAuth.php 1 year ago Miscellaneous.php 3 years ago ModifyRedirectDefaultLinks.php 5 months ago PPRESS_Session.php 1 year ago PROFILEPRESS_sql.php 1 year ago PasswordReset.php 1 year ago ProfileUrlRewrite.php 4 years ago RegistrationAuth.php 1 week ago SendEmail.php 3 years ago ShortcodeThemeFactory.php 5 years ago UserAvatar.php 1 year ago UserSignupLocationListingPage.php 3 years ago UsernameEmailRestrictLogin.php 4 years ago WPProfileFieldParserTrait.php 1 year ago WelcomeEmailAfterSignup.php 1 year ago default-email-template.php 1 year ago index.php 3 years ago
WPProfileFieldParserTrait.php
181 lines
1 <?php
2
3 namespace ProfilePress\Core\Classes;
4
5 use ProfilePress\Core\ShortcodeParser\Builder\FieldsShortcodeCallback;
6
7 trait WPProfileFieldParserTrait
8 {
9 /**
10 * Add multipart/form-data to wordpress profile admin page
11 */
12 public function add_form_enctype()
13 {
14 echo ' enctype="multipart/form-data"';
15 }
16
17 protected function date_field_picker($field_key)
18 {
19 echo sprintf('<script>jQuery(function ($) {$("#%1$s").flatpickr(%2$s);});</script>', $field_key, json_encode(
20 FieldsShortcodeCallback::date_picker_config($field_key)
21 ));
22 }
23
24 private function description_markup($description)
25 {
26 if ( ! empty($description)) {
27 printf('<p class="description">%s</p>', esc_html($description));
28 }
29 }
30
31 public function parse_custom_field($user, $label_name, $field_key, $field_type, $options = [], $description = '')
32 {
33 $input_fields_array = ['text', 'password', 'email', 'tel', 'number', 'hidden'];
34 ?>
35 <tr>
36 <th>
37 <label for="<?= esc_attr($field_key); ?>"><?= wp_kses_post(htmlspecialchars_decode($label_name)); ?></label>
38 </th>
39 <td>
40 <?php if (in_array(($type = $field_type), $input_fields_array)) : ?>
41 <input type="<?= esc_attr($type); ?>" name="<?= esc_attr($field_key); ?>" id="<?= esc_attr($field_key); ?>" value="<?= esc_attr(get_the_author_meta($field_key, $user->ID)); ?>" class="regular-text"/>
42 <?php $this->description_markup($description); ?>
43 <?php endif; ?>
44
45 <?php if ($field_type == 'date') : ?>
46 <input type="text" name="<?= esc_attr($field_key); ?>" id="<?= esc_attr($field_key); ?>" value="<?= esc_attr(get_the_author_meta($field_key, $user->ID)); ?>" class="pp_datepicker regular-text">
47 <?php $this->description_markup($description); ?>
48 <?php $this->date_field_picker($field_key); ?>
49 <?php endif; ?>
50
51 <?php if ($field_type == 'country') : ?>
52 <?php $countries = ppress_array_of_world_countries(); ?>
53 <?php $value = esc_attr(get_the_author_meta($field_key, $user->ID)); ?>
54 <select name="<?= $field_key; ?>">
55 <option value=""><?php esc_html__('Select a country&hellip;', 'wp-user-avatar'); ?></option>
56 <?php foreach ($countries as $ckey => $cvalue) : ?>
57 <option value="<?= esc_attr($ckey); ?>" <?php selected($value, $ckey); ?>><?= esc_attr($cvalue); ?> </option>';
58 <?php endforeach; ?>
59 </select>
60 <?php $this->description_markup($description); ?>
61 <?php endif; ?>
62
63 <?php if ($field_type == 'textarea') : ?>
64 <textarea rows="5" name="<?= esc_attr($field_key); ?>"><?= esc_attr(get_the_author_meta($field_key, $user->ID)); ?></textarea>
65 <?php $this->description_markup($description); ?>
66 <?php endif; ?>
67
68 <?php if ($field_type == 'radio') : ?>
69 <?php $radio_buttons = array_map('trim', explode(',', $options)); ?>
70 <?php foreach ($radio_buttons as $radio_button) : $radio_button = esc_attr($radio_button); ?>
71 <input id="<?= esc_attr($radio_button) ?>" type="radio" name="<?= esc_attr($field_key); ?>" value="<?= $radio_button ?>" <?php checked((get_the_author_meta($field_key, $user->ID)), $radio_button); ?> />
72 <label for="<?= esc_attr($radio_button) ?>"><?= $radio_button ?></label>
73 <br/>
74 <?php endforeach; ?>
75 <?php $this->description_markup($description); ?>
76 <?php endif; ?>
77
78 <?php if ($field_type == 'agreeable') {
79 $cpf_saved_data = get_the_author_meta($field_key, $user->ID);
80 $cpf_saved_data = ('1' == $cpf_saved_data) ? 'true' : $cpf_saved_data;
81
82 echo sprintf('<input type="hidden" name="%s" value="false" style="display: none">', esc_attr($field_key));
83 echo sprintf('<input id="%1$s" type="checkbox" name="%1$s" value="true" %2$s/>', esc_attr($field_key), checked($cpf_saved_data, 'true', false));
84 echo sprintf('<label for="%1$s">%2$s</label><br/>', esc_attr($field_key), $description);
85 }
86
87 if ($field_type == 'checkbox') {
88 $checkbox_values = array_map('trim', explode(',', $options));
89 $key = $field_key;
90 $checkbox_tag_key = "{$key}[]";
91 $cpf_saved_data = get_the_author_meta($field_key, $user->ID);
92 ?>
93 <?php foreach ($checkbox_values as $checkbox_value) {
94 $checked = null;
95 // if data is for multi select dropdown
96 if (is_array($cpf_saved_data) && in_array($checkbox_value, $cpf_saved_data)) {
97 $checked = 'checked="checked"';
98 } // if data is a single checkbox
99 elseif ( ! is_array($cpf_saved_data) && $checkbox_value == $cpf_saved_data) {
100 $checked = 'checked="checked"';
101 }
102 echo sprintf('<input id="%1$s" type="checkbox" name="%2$s" value="%1$s" %3$s/>', esc_attr($checkbox_value), esc_attr($checkbox_tag_key), $checked);
103 echo sprintf('<label for="%1$s">%1$s</label><br/>', esc_attr($checkbox_value));
104 }
105 $this->description_markup($description);
106 }
107
108 if ($field_type == 'select') {
109
110 $select_options_values = $options;
111 if ( ! is_array($options)) {
112 $select_options_values = array_map('trim', explode(',', $options));
113 // make array values the array keys too
114 $select_options_values = array_combine($select_options_values, $select_options_values);
115 }
116 $is_multi_selectable = ppress_is_select_field_multi_selectable($field_key);
117 $select_tag_key = $is_multi_selectable ? "{$field_key}[]" : $field_key;
118 $multiple = $is_multi_selectable ? 'multiple' : null;
119
120 $cpf_saved_data = get_the_author_meta($field_key, $user->ID);
121
122 echo sprintf('<select id="%1$s" name="%2$s" %3$s>', esc_attr($field_key), esc_attr($select_tag_key), $multiple);
123 foreach ($select_options_values as $options_key => $options_value) {
124 $selected = null;
125 // if data is for multi select dropdown
126 if (is_array($cpf_saved_data) && in_array($options_key, $cpf_saved_data)) {
127 $selected = 'selected="selected"';
128 } // if data is not multi select dropdown but a single selection dropdown
129 elseif ( ! $is_multi_selectable && ! is_array($cpf_saved_data) && $options_key == $cpf_saved_data) {
130 $selected = 'selected="selected"';
131 }
132
133 echo sprintf('<option value="%1$s" %3$s>%2$s</option>', esc_attr($options_key), esc_attr($options_value), $selected);
134 }
135 echo '</select>';
136
137 $this->description_markup($description);
138
139 if ($is_multi_selectable === true) {
140 echo sprintf('<script>jQuery(function () {jQuery("#%s").select2({width: "350px"});});</script>', esc_attr($field_key));
141 }
142 }
143
144 if ($field_type == 'file') {
145 $user_upload_data = get_user_meta($user->ID, 'pp_uploaded_files', true);
146 // if the user uploads isn't empty and there exist a file with the custom field key.
147 if ( ! empty($user_upload_data) && isset($user_upload_data[$field_key])) {
148 $filename = $user_upload_data[$field_key];
149 $link = PPRESS_FILE_UPLOAD_URL . $filename;
150 echo "<p><a href='$link'>$filename</a></p>";
151 }
152 ?>
153 <input name="<?= esc_attr($field_key); ?>" type="file">
154 <?php $this->description_markup($description); ?>
155 <?php
156 }
157 ?>
158 </td>
159 </tr>
160 <?php
161 }
162
163 /**
164 * Array of core user profile.
165 *
166 * This is useful in cases where say first and last name field is added so it can be added to buddypress
167 * extended profile synced to WordPress user profile.
168 *
169 * @return array
170 */
171 public function core_user_fields()
172 {
173 return [
174 'first_name',
175 'last_name',
176 'user_nicename',
177 'user_url',
178 'display_name'
179 ];
180 }
181 }