forked from Tetrakern/fictioneer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
user-profile.php
96 lines (80 loc) · 2.56 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
<?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
*/
?>
<?php
// 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();
}
// 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
);
?>
<?php get_header( null, array( 'type' => 'user-profile' ) ); ?>
<main id="main" class="main singular profile">
<div class="observer main-observer"></div>
<?php do_action( 'fictioneer_main' ); ?>
<div class="main__background polygon polygon--main background-texture"></div>
<div class="main__wrapper">
<?php do_action( 'fictioneer_main_wrapper' ); ?>
<article id="singular-<?php echo $post_id; ?>" class="singular__article padding-left padding-right padding-top padding-bottom">
<section class="singular__content content-section profile__content">
<?php do_action( 'fictioneer_account_content', $hook_args ); ?>
</section>
</article>
</div>
</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 );
?>