PluginProbe ʕ •ᴥ•ʔ
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress / 4.0.3
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress v4.0.3
4.17.2 4.17.1 4.17.0 4.16.19 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 5 years ago AdminNotices.php 4 years ago AjaxHandler.php 4 years ago Autologin.php 4 years ago BuddyPressBbPress.php 5 years ago EditUserProfile.php 4 years ago ExtensionManager.php 4 years ago FileUploader.php 4 years ago FormPreviewHandler.php 5 years ago FormRepository.php 4 years ago FormShortcodeDefaults.php 5 years ago GDPR.php 4 years ago Geolocation.php 4 years ago GlobalSiteAccess.php 4 years ago ImageUploader.php 4 years ago LoginAuth.php 4 years ago Miscellaneous.php 4 years ago ModifyRedirectDefaultLinks.php 4 years ago PPRESS_Session.php 4 years ago PROFILEPRESS_sql.php 4 years ago PasswordReset.php 4 years ago ProfileUrlRewrite.php 4 years ago RegistrationAuth.php 4 years ago SendEmail.php 4 years ago ShortcodeThemeFactory.php 5 years ago UserAvatar.php 4 years ago UserSignupLocationListingPage.php 4 years ago UsernameEmailRestrictLogin.php 4 years ago WPProfileFieldParserTrait.php 4 years ago WelcomeEmailAfterSignup.php 4 years ago default-email-template.php 4 years ago index.php 5 years ago
WPProfileFieldParserTrait.php
181 lines
1 <?php
2
3 namespace ProfilePress\Core\Classes;
4
5 use ProfilePress\Core\Membership\CheckoutFields;
6 use ProfilePress\Core\ShortcodeParser\Builder\FieldsShortcodeCallback;
7
8 trait WPProfileFieldParserTrait
9 {
10 /**
11 * Add multipart/form-data to wordpress profile admin page
12 */
13 public function add_form_enctype()
14 {
15 echo ' enctype="multipart/form-data"';
16 }
17
18 protected function date_field_picker($field_key)
19 {
20 echo sprintf('<script>jQuery(function ($) {$("#%1$s").flatpickr(%2$s);});</script>', $field_key, json_encode(
21 FieldsShortcodeCallback::date_picker_config($field_key)
22 ));
23 }
24
25 private function description_markup($description)
26 {
27 if ( ! empty($description)) {
28 printf('<p class="description">%s</p>', esc_html($description));
29 }
30 }
31
32 public function parse_custom_field($user, $label_name, $field_key, $field_type, $options = [], $description = '')
33 {
34 $input_fields_array = ['text', 'password', 'email', 'tel', 'number', 'hidden'];
35 ?>
36 <tr>
37 <th>
38 <label for="<?= $field_key; ?>"><?= htmlspecialchars_decode($label_name); ?></label>
39 </th>
40 <td>
41 <?php if (in_array(($type = $field_type), $input_fields_array)) : ?>
42 <input type="<?= $type; ?>" name="<?= esc_attr($field_key); ?>" id="<?= $field_key; ?>" value="<?= esc_attr(get_the_author_meta($field_key, $user->ID)); ?>" class="regular-text"/>
43 <?php $this->description_markup($description); ?>
44 <?php endif; ?>
45
46 <?php if ($field_type == 'date') : ?>
47 <input type="text" name="<?= esc_attr($field_key); ?>" id="<?= $field_key; ?>" value="<?= esc_attr(get_the_author_meta($field_key, $user->ID)); ?>" class="pp_datepicker regular-text">
48 <?php $this->description_markup($description); ?>
49 <?php $this->date_field_picker($field_key); ?>
50 <?php endif; ?>
51
52 <?php if ($field_type == 'country') : ?>
53 <?php $countries = ppress_array_of_world_countries(); ?>
54 <?php $value = esc_attr(get_the_author_meta($field_key, $user->ID)); ?>
55 <select name="<?= $field_key; ?>">
56 <option value=""><?php esc_html__('Select a country&hellip;', 'profilepress-pro'); ?></option>
57 <?php foreach ($countries as $ckey => $cvalue) : ?>
58 <option value="<?= $ckey; ?>" <?php selected($value, $ckey); ?>><?= $cvalue; ?> </option>';
59 <?php endforeach; ?>
60 </select>
61 <?php $this->description_markup($description); ?>
62 <?php endif; ?>
63
64 <?php if ($field_type == 'textarea') : ?>
65 <textarea rows="5" name="<?= $field_key; ?>"><?= esc_attr(get_the_author_meta($field_key, $user->ID)); ?></textarea>
66 <?php $this->description_markup($description); ?>
67 <?php endif; ?>
68
69 <?php if ($field_type == 'radio') : ?>
70 <?php $radio_buttons = array_map('trim', explode(',', $options)); ?>
71 <?php foreach ($radio_buttons as $radio_button) : $radio_button = esc_attr($radio_button); ?>
72 <input id="<?= $radio_button ?>" type="radio" name="<?= esc_attr($field_key); ?>" value="<?= $radio_button ?>" <?php checked((get_the_author_meta($field_key, $user->ID)), $radio_button); ?> />
73 <label for="<?= $radio_button ?>"><?= $radio_button ?></label>
74 <br/>
75 <?php endforeach; ?>
76 <?php $this->description_markup($description); ?>
77 <?php endif; ?>
78
79 <?php if ($field_type == 'agreeable') {
80 $cpf_saved_data = get_the_author_meta($field_key, $user->ID);
81 $cpf_saved_data = ('1' == $cpf_saved_data) ? 'true' : $cpf_saved_data;
82
83 echo sprintf('<input type="hidden" name="%s" value="false" style="display: none">', $field_key);
84 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));
85 echo sprintf('<label for="%1$s">%2$s</label><br/>', esc_attr($field_key), $description);
86 }
87
88 if ($field_type == 'checkbox') {
89 $checkbox_values = array_map('trim', explode(',', $options));
90 $key = $field_key;
91 $checkbox_tag_key = "{$key}[]";
92 $cpf_saved_data = get_the_author_meta($field_key, $user->ID);
93 ?>
94 <?php foreach ($checkbox_values as $checkbox_value) {
95 $checked = null;
96 // if data is for multi select dropdown
97 if (is_array($cpf_saved_data) && in_array($checkbox_value, $cpf_saved_data)) {
98 $checked = 'checked="checked"';
99 } // if data is a single checkbox
100 elseif ( ! is_array($cpf_saved_data) && $checkbox_value == $cpf_saved_data) {
101 $checked = 'checked="checked"';
102 }
103 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);
104 echo sprintf('<label for="%1$s">%1$s</label><br/>', esc_attr($checkbox_value));
105 }
106 $this->description_markup($description);
107 }
108
109 if ($field_type == 'select') {
110
111 $select_options_values = $options;
112 if ( ! is_array($options)) {
113 $select_options_values = array_map('trim', explode(',', $options));
114 // make array values the array keys too
115 $select_options_values = array_combine($select_options_values, $select_options_values);
116 }
117 $is_multi_selectable = ppress_is_select_field_multi_selectable($field_key);
118 $select_tag_key = $is_multi_selectable ? "{$field_key}[]" : $field_key;
119 $multiple = $is_multi_selectable ? 'multiple' : null;
120
121 $cpf_saved_data = get_the_author_meta($field_key, $user->ID);
122
123 echo "<select id='$field_key' name='$select_tag_key' $multiple>";
124 foreach ($select_options_values as $options_key => $options_value) {
125 $selected = null;
126 // if data is for multi select dropdown
127 if (is_array($cpf_saved_data) && in_array($options_key, $cpf_saved_data)) {
128 $selected = 'selected="selected"';
129 } // if data is not multi select dropdown but a single selection dropdown
130 elseif ( ! $is_multi_selectable && ! is_array($cpf_saved_data) && $options_key == $cpf_saved_data) {
131 $selected = 'selected="selected"';
132 }
133
134 echo sprintf('<option value="%1$s" %3$s>%2$s</option>', esc_attr($options_key), esc_attr($options_value), $selected);
135 }
136 echo '</select>';
137
138 $this->description_markup($description);
139
140 if ($is_multi_selectable === true) {
141 echo sprintf('<script>jQuery(function () {jQuery("#%s").select2({width: "350px"});});</script>', $field_key);
142 }
143 }
144
145 if ($field_type == 'file') {
146 $user_upload_data = get_user_meta($user->ID, 'pp_uploaded_files', true);
147 // if the user uploads isn't empty and there exist a file with the custom field key.
148 if ( ! empty($user_upload_data) && $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="<?= $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 }