PluginProbe ʕ •ᴥ•ʔ
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress / 3.2.7
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress v3.2.7
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 / Themes / DragDrop / UserProfile / DefaultTemplate.php
wp-user-avatar / src / Themes / DragDrop / UserProfile Last commit date
DefaultTemplate.php 4 years ago Dixon.php 5 years ago
DefaultTemplate.php
537 lines
1 <?php
2
3 namespace ProfilePress\Core\Themes\DragDrop\UserProfile;
4
5 use ProfilePress\Core\Admin\SettingsPages\DragDropBuilder\DragDropBuilder;
6 use ProfilePress\Core\Classes\ExtensionManager as EM;
7 use ProfilePress\Core\ShortcodeParser\Builder\FrontendProfileBuilder;
8 use ProfilePress\Core\Themes\DragDrop\AbstractTheme;
9 use ProfilePress\Core\Admin\SettingsPages\DragDropBuilder\Fields;
10
11 class DefaultTemplate extends AbstractTheme
12 {
13
14 public function __construct($form_id, $form_type)
15 {
16 parent::__construct($form_id, $form_type);
17
18 add_action('ppress_profile_tab_content_main', [$this, 'profile_content_main']);
19 add_action('ppress_profile_tab_content_posts', [$this, 'profile_content_posts']);
20 add_action('ppress_profile_tab_content_comments', [$this, 'profile_content_comments']);
21 }
22
23 public static function default_field_listing()
24 {
25 Fields\Init::init();
26 $standard_fields = DragDropBuilder::get_instance()->standard_fields();
27
28 return [
29 $standard_fields['profile-username'],
30 $standard_fields['profile-email'],
31 $standard_fields['profile-first-name'],
32 $standard_fields['profile-last-name'],
33 $standard_fields['profile-website'],
34 $standard_fields['profile-bio'],
35 ];
36 }
37
38 public function default_metabox_settings()
39 {
40 $data = parent::default_metabox_settings();
41 $data['ppress_dpf_max_width'] = '1000px';
42 $data['ppress_dpf_area_max_width'] = '600px';
43 $data['ppress_dpf_profile_cover_enabled'] = 'true';
44 $data['ppress_dpf_profile_show_bio'] = 'true';
45 $data['ppress_dpf_profile_cover_ratio'] = '2.7';
46 $data['ppress_dpf_profile_header_display_name'] = 'first_last_names';
47 $data['ppress_dpf_profile_user_meta'] = [];
48 $data['ppress_dpf_profile_menu_tabs'] = ['main', 'posts', 'comments'];
49
50 $data['ppress_dpf_profile_header_name_color'] = '#555555';
51 $data['ppress_dpf_profile_body_text_color'] = '#666666';
52 $data['ppress_dpf_profile_menu_background_color'] = '#444444';
53 $data['ppress_dpf_profile_menu_tab_text_color'] = '#ffffff';
54 $data['ppress_dpf_profile_active_menu_tab_bg_color'] = '#007bff';
55
56 return $data;
57 }
58
59 public function appearance_settings($settings)
60 {
61 $profile_tabs = $this->profile_tabs();
62
63 $settings[] = [
64 'id' => 'ppress_dpf_max_width',
65 'type' => 'text',
66 'label' => esc_html__('Profile Maximum Width', 'wp-user-avatar'),
67 'description' => esc_html__('The maximum width of the profile template.', 'wp-user-avatar'),
68 'priority' => 10
69 ];
70
71 $settings[] = [
72 'id' => 'ppress_dpf_area_max_width',
73 'type' => 'text',
74 'label' => esc_html__('Profile Area Maximum Width', 'wp-user-avatar'),
75 'description' => esc_html__('The maximum width of the profile area inside profile below the header.', 'wp-user-avatar'),
76 'priority' => 20
77 ];
78
79 $settings[] = [
80 'id' => 'ppress_dpf_profile_cover_enabled',
81 'type' => 'checkbox',
82 'label' => esc_html__('Enable Cover Photo', 'wp-user-avatar'),
83 'priority' => 40
84 ];
85
86 $settings[] = [
87 'id' => 'ppress_dpf_profile_cover_ratio',
88 'type' => 'select',
89 'label' => esc_html__('Profile Cover Ratio', 'wp-user-avatar'),
90 'options' => [
91 '1.6' => '1.6:1',
92 '2.7' => '2.7:1',
93 '3.2' => '3.2:1',
94 ],
95 'description' => esc_html__('Choose an aspect ratio of the profile cover photo.', 'wp-user-avatar'),
96 'priority' => 50
97 ];
98
99 $settings[] = [
100 'id' => 'ppress_dpf_profile_header_display_name',
101 'type' => 'select',
102 'label' => esc_html__('Header Text', 'wp-user-avatar'),
103 'options' => [
104 'hide' => esc_html__('Hide', 'wp-user-avatar'),
105 'username' => esc_html__('Username', 'wp-user-avatar'),
106 'display-name' => esc_html__('Display Name', 'wp-user-avatar'),
107 'nickname' => esc_html__('Nickname', 'wp-user-avatar'),
108 'first_last_names' => esc_html__('First & Last Name', 'wp-user-avatar'),
109 'last_first_names' => esc_html__('Last & First Name', 'wp-user-avatar'),
110 'first-name' => esc_html__('First Name Only', 'wp-user-avatar')
111 ],
112 'description' => esc_html__('What to use as display name in profile header. Select "Hide" to hide it from showing.', 'wp-user-avatar'),
113 'priority' => 60
114 ];
115
116 if (EM::is_enabled(EM::CUSTOM_FIELDS)) {
117
118 $settings[] = [
119 'id' => 'ppress_dpf_profile_show_social_links',
120 'type' => 'checkbox',
121 'label' => esc_html__('Show Social Links in Header', 'wp-user-avatar'),
122 'priority' => 70
123 ];
124 } else {
125
126 $upgrade_url = 'https://profilepress.net/pricing/?utm_source=wp_dashboard&utm_medium=upgrade&utm_campaign=default_profile_social_link';
127 $settings[] = [
128 'id' => 'ppress_dpf_profile_social_link_upsell',
129 'label' => '',
130 'type' => 'custom',
131 'content' => sprintf(
132 esc_html__('%sUpgrade to ProfilePress premium%s if you don\'t have the custom field addon to display users social profiles.', 'wp-user-avatar'),
133 '<a href="' . $upgrade_url . '" target="_blank">', '</a>'
134 ),
135 ];
136 }
137
138 $settings[] = [
139 'id' => 'ppress_dpf_profile_show_bio',
140 'type' => 'checkbox',
141 'label' => esc_html__('Show Bio in Header', 'wp-user-avatar'),
142 'priority' => 80
143 ];
144
145 $settings[] = [
146 'id' => 'ppress_dpf_profile_user_meta',
147 'type' => 'select2',
148 'label' => esc_html__('Fields to Show in User Meta', 'wp-user-avatar'),
149 'options' => ppress_standard_custom_fields_key_value_pair(true),
150 'priority' => 90
151 ];
152
153 $settings[] = [
154 'id' => 'ppress_dpf_profile_menu_tabs',
155 'type' => 'select2',
156 'label' => esc_html__('Profile Menu Tabs', 'wp-user-avatar'),
157 'options' => array_reduce(array_keys($profile_tabs), function ($carry, $item) use ($profile_tabs) {
158 $carry[$item] = $profile_tabs[$item]['title'];
159
160 return $carry;
161 }),
162 'priority' => 100
163 ];
164
165 return $settings;
166 }
167
168 public function color_settings($settings)
169 {
170 $settings2 = [
171 [
172 'id' => 'ppress_dpf_profile_header_name_color',
173 'type' => 'color',
174 'label' => esc_html__('Header Name', 'wp-user-avatar')
175 ],
176 [
177 'id' => 'ppress_dpf_profile_body_text_color',
178 'type' => 'color',
179 'label' => esc_html__('Body Text', 'wp-user-avatar')
180 ],
181 [
182 'id' => 'ppress_dpf_profile_menu_background_color',
183 'type' => 'color',
184 'label' => esc_html__('Menu Background', 'wp-user-avatar')
185 ],
186 [
187 'id' => 'ppress_dpf_profile_menu_tab_text_color',
188 'type' => 'color',
189 'label' => esc_html__('Menu Tab Text', 'wp-user-avatar')
190 ],
191 [
192 'id' => 'ppress_dpf_profile_active_menu_tab_bg_color',
193 'type' => 'color',
194 'label' => esc_html__('Active Menu Tab Background', 'wp-user-avatar')
195 ]
196 ];
197
198 return array_merge($settings, $settings2);
199 }
200
201 private function cover_image_structure()
202 {
203 $cover_ratio = $this->get_meta('ppress_dpf_profile_cover_ratio');
204 if (empty($cover_ratio)) $cover_ratio = '2.7';
205 ?>
206 <div class="ppress-default-profile-cover" data-ratio="<?php echo esc_attr($cover_ratio); ?>">
207 <div class="ppress-default-profile-cover-e" data-ratio="<?php echo esc_attr($cover_ratio); ?>">
208 <img src="[profile-cover-image-url]">
209 </div>
210 </div>
211 <?php
212 }
213
214 private function is_profile_cover_enabled()
215 {
216 return $this->get_meta('ppress_dpf_profile_cover_enabled') == 'true';
217 }
218
219 private function header_social_links()
220 {
221 if ($this->get_meta('ppress_dpf_profile_show_social_links') !== 'true') return;
222
223 $this->social_profile_icons();
224 }
225
226 public function profile_tabs()
227 {
228 return apply_filters('ppress_profile_tabs', [
229 'main' => [
230 'icon' => 'person',
231 'title' => esc_html__('About', 'wp-user-avatar')
232 ],
233 'posts' => [
234 'icon' => 'create',
235 'title' => esc_html__('Posts', 'wp-user-avatar')
236 ],
237 'comments' => [
238 'icon' => 'comment',
239 'title' => esc_html__('Comments', 'wp-user-avatar')
240 ]
241 ], $this);
242 }
243
244 private function active_tab()
245 {
246 $active = 'main';
247
248 if ( ! empty($_GET['tab'])) {
249
250 $sanitized_tab = sanitize_text_field($_GET['tab']);
251
252 if (in_array($sanitized_tab, array_keys($this->profile_tabs()))) {
253 $active = sanitize_text_field($_GET['tab']);
254 }
255 }
256
257 return $active;
258 }
259
260 public function profile_tabs_section()
261 {
262 $saved_tabs = array_filter($this->get_meta('ppress_dpf_profile_menu_tabs'), function ($item) {
263 return ! empty($item);
264 });
265
266 if (empty($saved_tabs)) $saved_tabs = ['main', 'posts' . 'comments'];
267
268 $profile_tabs = $this->profile_tabs();
269
270 if ( ! empty($saved_tabs)) {
271
272 echo '<div class="ppress-dpf-profile-nav">';
273
274 foreach ($saved_tabs as $tab_id) :
275 $url = esc_url(remove_query_arg('pfpage', add_query_arg('tab', $tab_id)));
276 ?>
277 <div class="ppress-dpf-profile-nav-item ppress-dpf-nav-<?= $tab_id ?><?= $this->active_tab() == $tab_id ? ' ppress-dpf-active' : ''; ?>">
278 <a href="<?= $url ?>">
279 <span class="ppress-material-icons"><?= $profile_tabs[$tab_id]['icon'] ?></span>
280 <span class="ppress-dpf-nav-title"><?= $profile_tabs[$tab_id]['title'] ?></span>
281 </a>
282 </div>
283 <?php endforeach;
284 echo '<div class="ppress-dpf-clear"></div>';
285 echo '</div>';
286 }
287 }
288
289 public function profile_content_main()
290 {
291 $profile_listing = $this->profile_listing()
292 ->item_wrap_start_tag('<div class="ppress-dpf-profile-body-item">')
293 ->item_wrap_end_tag('</div>')
294 ->title_start_tag('<div class="ppress-dpf-item-label">')
295 ->title_end_tag('</div>')
296 ->info_start_tag('<div class="ppress-dpf-item-value">')
297 ->info_end_tag('</div>')
298 ->forge();
299
300 $has_field_data = $profile_listing->has_field_data();
301
302 $profile_listing = $profile_listing->output();
303
304 if ($has_field_data === false) : ?>
305 <p class="ppress-dpf-profile-note">
306 <span class="ppress-material-icons">sentiment_dissatisfied</span>
307 <span>
308 <?= sprintf(
309 __('Your profile is looking a little empty. Why not <a href="%s">add some information</a>?', 'wp-user-avatar'),
310 ppress_edit_profile_url()
311 ); ?>
312 </span>
313 </p>
314 <?php endif;
315
316 if ($has_field_data === true) { ?>
317 <div class="ppress-dpf-profile-body-items">
318 <?php echo $profile_listing; ?>
319 </div>
320 <?php
321 }
322 }
323
324 public function profile_content_posts()
325 {
326 /** @var \WP_User */
327 global $ppress_frontend_profile_user_obj;
328
329 $current_page = absint(ppressGET_var('pfpage', 1));
330 $pagination_args = apply_filters('ppress_profile_posts_pagination_args', ['limit' => 10], $this);
331 $limit = absint($pagination_args['limit']);
332
333 $offset = $current_page > 1 ? ($current_page - 1) * $limit : 0;
334
335 $posts = FrontendProfileBuilder::author_posts_query(
336 $ppress_frontend_profile_user_obj->ID,
337 ['limit' => $limit, 'offset' => $offset]
338 );
339
340 echo $posts['structure'];
341
342 if (ppress_settings_by_key('author_slug_to_profile') != 'on' && $posts['total_post_count'] >= $limit) {
343
344 printf(
345 '<div class="ppress-dpf-more-post-wrap"><a href="%s" class="ppress-dpf-more-post-btn">%s</a></div>',
346 esc_url(add_query_arg('pfpage', ++$current_page)),
347 apply_filters(
348 'ppress_profile_posts_pagination_button',
349 esc_html__('See More Posts', 'wp-user-avatar'),
350 $this
351 )
352 );
353 }
354 }
355
356 public function profile_content_comments()
357 {
358 /** @var \WP_User */
359 global $ppress_frontend_profile_user_obj;
360
361 $current_page = absint(ppressGET_var('pfpage', 1));
362 $pagination_args = apply_filters('ppress_profile_comments_pagination_args', ['limit' => 10], $this);
363 $limit = absint($pagination_args['limit']);
364
365 $offset = $current_page > 1 ? ($current_page - 1) * $limit : 0;
366
367 $comments = FrontendProfileBuilder::author_comment_query(
368 $ppress_frontend_profile_user_obj->ID,
369 ['limit' => $limit, 'offset' => $offset]
370 );
371
372 echo $comments['structure'];
373
374 if ($comments['comment_count'] >= $limit) {
375 printf(
376 '<div class="ppress-dpf-more-post-wrap"><a href="%s" class="ppress-dpf-more-post-btn">%s</a></div>',
377 esc_url(add_query_arg('pfpage', ++$current_page)),
378 apply_filters(
379 'ppress_profile_comments_pagination_button',
380 esc_html__('See More Comments', 'wp-user-avatar'),
381 $this
382 )
383 );
384 }
385 }
386
387 public function form_structure()
388 {
389 $active_tab = $this->active_tab();
390
391 $max_width = $this->get_meta('ppress_dpf_max_width');
392 $profile_area_max_width = $this->get_meta('ppress_dpf_area_max_width');
393 $header_display_name = $this->get_meta('ppress_dpf_profile_header_display_name');
394
395 /** @see https://stackoverflow.com/a/20373067/2648410 using array_values to reindex array numeric keys */
396 $profile_user_meta = array_values(
397 array_filter(
398 array_map(function ($meta_key) {
399
400 if (empty($meta_key)) return false;
401
402 $value = $this->get_profile_field($meta_key, true);
403
404 return empty($value) ? false : $value;
405
406 }, $this->get_meta('ppress_dpf_profile_user_meta'))
407 )
408 );
409
410 $classes = 'ppress-default-profile';
411
412 if ( ! $this->is_profile_cover_enabled()) {
413 $classes .= ' ppdf-nocover';
414 }
415 ob_start();
416 ?>
417 [pp-form-wrapper class="<?= $classes ?>" style="max-width:<?= $max_width ?>"]
418
419 <?php if ($this->is_profile_cover_enabled()) $this->cover_image_structure(); ?>
420
421 <div class="ppress-dpf-header">
422 <?php if (ppress_is_my_own_profile()) : ?>
423 <div class="ppress-dpf-headericon">
424 <a href="<?= ppress_my_account_url(); ?>" class="ppress-dpf-edit-a ppress-hint-wrap hint--bottom" aria-label="<?= esc_html__('Edit your profile') ?>">
425 <span class="ppress-material-icons">settings</span>
426 </a>
427 </div>
428 <?php endif; ?>
429
430 <div class="ppress-dpf-profile-photo">
431 <img src="[profile-avatar-url]" width="190" height="190">
432 </div>
433
434 <div class="ppress-dpf-profile-meta">
435 <div class="ppress-dpf-main-meta">
436
437 <?php if ('hide' !== $header_display_name) : ?>
438 <div class="ppress-dpf-name"><?= $this->get_profile_field($header_display_name) ?></div>
439 <?php endif; ?>
440
441 <?php $this->header_social_links(); ?>
442 </div>
443
444 <?php if (is_array($profile_user_meta) && ! empty($profile_user_meta)) : $count = count($profile_user_meta) - 1; ?>
445 <div class="ppress-dpf-meta">
446 <?php foreach ($profile_user_meta as $index => $meta_data) : ?>
447 <?= $meta_data ?>
448 <?php if ($index !== $count): ?>
449 <span class="b">&bull;</span>
450 <?php endif; ?>
451 <?php endforeach; ?>
452 </div>
453 <?php endif; ?>
454
455 <?php if ($this->get_meta('ppress_dpf_profile_show_bio') == 'true') : ?>
456 <div class="ppress-dpf-meta-text">
457 [profile-bio]
458 </div>
459 <?php endif; ?>
460
461 </div>
462
463 <div class="ppress-dpf-clear"></div>
464
465 </div>
466
467 <?php $this->profile_tabs_section(); ?>
468
469 <div class="ppress-dpf-profile-body ppdf-<?= $active_tab ?>"<?= ! empty($profile_area_max_width) ? ' style="max-width:' . $profile_area_max_width . '"' : '' ?>>
470 <?php do_action(sprintf('ppress_profile_tab_content_%s', $active_tab)); ?>
471 </div>
472 [/pp-form-wrapper]
473
474 <?php
475 return ob_get_clean();
476 }
477
478 public function form_css()
479 {
480 $form_id = $this->form_id;
481 $form_type = $this->form_type;
482
483 $photo_size = 190;
484
485 $meta_padding = ($photo_size + 60) . 'px';
486
487 $photosize_up = ($photo_size / 2) + 5;
488
489 $profile_photo_style = [
490 "width:{$photo_size}px",
491 "height:{$photo_size}px"
492 ];
493
494 if ($this->is_profile_cover_enabled()) {
495 $profile_photo_style[] = "top:-" . $photosize_up . "px";
496 }
497
498 $profile_photo_style = implode(';', $profile_photo_style);
499
500 $header_name_color = $this->get_meta('ppress_dpf_profile_header_name_color');
501 $body_text_color = $this->get_meta('ppress_dpf_profile_body_text_color');
502 $menu_background_color = $this->get_meta('ppress_dpf_profile_menu_background_color');
503 $menu_tab_text_color = $this->get_meta('ppress_dpf_profile_menu_tab_text_color');
504 $active_menu_tab_bg_color = $this->get_meta('ppress_dpf_profile_active_menu_tab_bg_color');
505
506 return <<<CSS
507 div#pp-$form_type-$form_id.ppress-default-profile .ppress-dpf-profile-photo {
508 $profile_photo_style
509 }
510
511 div#pp-$form_type-$form_id.ppress-default-profile {
512 color: $body_text_color;
513 }
514
515 div#pp-$form_type-$form_id.ppress-default-profile .ppress-dpf-profile-nav {
516 background: $menu_background_color;
517 }
518
519 div#pp-$form_type-$form_id.ppress-default-profile .ppress-dpf-profile-nav-item a {
520 color: $menu_tab_text_color;
521 }
522
523 div#pp-$form_type-$form_id.ppress-default-profile .ppress-dpf-name {
524 color: $header_name_color;
525 }
526
527 div#pp-$form_type-$form_id.ppress-default-profile .ppress-dpf-profile-meta {
528 padding-left: $meta_padding;
529 }
530
531 div#pp-$form_type-$form_id.ppress-default-profile .ppress-dpf-profile-nav-item.ppress-dpf-active a {
532 background: $active_menu_tab_bg_color;
533 }
534 CSS;
535
536 }
537 }