-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
user-profile.php
107 lines (83 loc) · 2.67 KB
/
user-profile.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
/**
* Template Name: User Profile
*
* Ths template renders a limited user profile form on the frontend to keep
* subscribers out of the admin panel and make it look pretty. Requires an empty
* page with the template assigned in the theme's settings.
*
* @package WordPress
* @subpackage Fictioneer
* @since 4.5.0
*/
// Only for logged-in users...
if ( ! is_user_logged_in() && ! get_option( 'fictioneer_enable_public_cache_compatibility' ) ) {
wp_safe_redirect( home_url() );
exit;
}
// If public caching is active, redirect to dashboard profile
if (
! get_option( 'fictioneer_enable_private_cache_compatibility' ) &&
get_option( 'fictioneer_enable_public_cache_compatibility' )
) {
wp_safe_redirect( get_edit_profile_url( 0 ) );
exit;
}
// Redundant safeguard
if ( ! is_user_logged_in() ) {
wp_safe_redirect( home_url() );
exit;
}
// Try to prevent caching of the page
if ( ! defined( 'DONOTCACHEPAGE' ) ) {
define( 'DONOTCACHEPAGE', true );
}
do_action( 'litespeed_control_set_nocache', 'nocache due to user-specific page.' );
// Setup
$post_id = get_the_ID();
$current_user = wp_get_current_user();
$title = trim( get_the_title() );
$title = empty( $title ) ? __( 'User Profile', 'fictioneer' ) : $title;
$this_breadcrumb = [ $title, get_the_permalink() ];
// Flags
$is_admin = fictioneer_is_admin( $current_user->ID );
$is_author = fictioneer_is_author( $current_user->ID );
$is_editor = fictioneer_is_editor( $current_user->ID );
$is_moderator = fictioneer_is_moderator( $current_user->ID );
// Arguments for hooks and templates/etc. and includes
$hook_args = array(
'user' => $current_user,
'is_admin' => $is_admin,
'is_author' => $is_author,
'is_editor' => $is_editor,
'is_moderator' => $is_moderator
);
// Header
get_header( null, array( 'type' => 'user-profile', 'no_index' => 1 ) );
?>
<main id="main" class="main singular profile">
<?php do_action( 'fictioneer_main', 'user-profile' ); ?>
<div class="main__wrapper">
<?php do_action( 'fictioneer_main_wrapper' ); ?>
<article id="singular-<?php echo $post_id; ?>" class="singular__article">
<section class="singular__content content-section profile__content">
<?php do_action( 'fictioneer_account_content', $hook_args ); ?>
</section>
</article>
</div>
<?php do_action( 'fictioneer_main_end', 'user-profile' ); ?>
</main>
<?php
// Footer arguments
$footer_args = array(
'post_type' => 'page',
'post_id' => $post_id,
'breadcrumbs' => array(
[fcntr( 'frontpage' ), get_home_url()]
)
);
// Add current breadcrumb
$footer_args['breadcrumbs'][] = $this_breadcrumb;
// Get footer with breadcrumbs
get_footer( null, $footer_args );
?>