2023-01-21 01:31:34 +01:00
|
|
|
<?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
|
2024-01-26 17:45:59 +01:00
|
|
|
* @since 4.5.0
|
2023-01-21 01:31:34 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
// Only for logged-in users...
|
|
|
|
if ( ! is_user_logged_in() && ! get_option( 'fictioneer_enable_public_cache_compatibility' ) ) {
|
|
|
|
wp_safe_redirect( home_url() );
|
2024-07-19 20:52:52 +02:00
|
|
|
exit;
|
2023-01-21 01:31:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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 ) );
|
2024-07-19 20:52:52 +02:00
|
|
|
exit;
|
2023-01-21 01:31:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Redundant safeguard
|
|
|
|
if ( ! is_user_logged_in() ) {
|
|
|
|
wp_safe_redirect( home_url() );
|
2024-07-19 20:52:52 +02:00
|
|
|
exit;
|
2023-01-21 01:31:34 +01:00
|
|
|
}
|
|
|
|
|
2024-07-23 01:47:52 +02:00
|
|
|
// 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.' );
|
|
|
|
|
2023-01-21 01:31:34 +01:00
|
|
|
// Setup
|
2023-12-02 22:28:56 +01:00
|
|
|
$post_id = get_the_ID();
|
2023-01-21 01:31:34 +01:00
|
|
|
$current_user = wp_get_current_user();
|
|
|
|
$title = trim( get_the_title() );
|
|
|
|
$title = empty( $title ) ? __( 'User Profile', 'fictioneer' ) : $title;
|
2023-12-02 22:28:56 +01:00
|
|
|
$this_breadcrumb = [ $title, get_the_permalink() ];
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
// 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
|
|
|
|
);
|
|
|
|
|
2024-05-17 12:29:52 +02:00
|
|
|
// Header
|
2024-06-09 10:43:12 +02:00
|
|
|
get_header( null, array( 'type' => 'user-profile', 'no_index' => 1 ) );
|
2023-01-21 01:31:34 +01:00
|
|
|
|
2024-05-17 12:29:52 +02:00
|
|
|
?>
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
<main id="main" class="main singular profile">
|
2024-04-14 12:57:59 +02:00
|
|
|
|
2024-06-14 00:31:31 +02:00
|
|
|
<?php do_action( 'fictioneer_main', 'user-profile' ); ?>
|
2024-04-14 12:57:59 +02:00
|
|
|
|
2023-01-21 01:31:34 +01:00
|
|
|
<div class="main__wrapper">
|
2024-04-14 12:57:59 +02:00
|
|
|
|
2023-01-21 01:31:34 +01:00
|
|
|
<?php do_action( 'fictioneer_main_wrapper' ); ?>
|
|
|
|
|
2023-12-02 22:28:56 +01:00
|
|
|
<article id="singular-<?php echo $post_id; ?>" class="singular__article padding-left padding-right padding-top padding-bottom">
|
2023-01-21 01:31:34 +01:00
|
|
|
|
|
|
|
<section class="singular__content content-section profile__content">
|
|
|
|
<?php do_action( 'fictioneer_account_content', $hook_args ); ?>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
</article>
|
2024-04-14 12:57:59 +02:00
|
|
|
|
2023-01-21 01:31:34 +01:00
|
|
|
</div>
|
2024-04-14 12:57:59 +02:00
|
|
|
|
2023-01-21 01:31:34 +01:00
|
|
|
</main>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
// Footer arguments
|
|
|
|
$footer_args = array(
|
|
|
|
'post_type' => 'page',
|
2023-12-02 22:28:56 +01:00
|
|
|
'post_id' => $post_id,
|
2023-01-21 01:31:34 +01:00
|
|
|
'breadcrumbs' => array(
|
|
|
|
[fcntr( 'frontpage' ), get_home_url()]
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
// Add current breadcrumb
|
|
|
|
$footer_args['breadcrumbs'][] = $this_breadcrumb;
|
|
|
|
|
|
|
|
// Get footer with breadcrumbs
|
|
|
|
get_footer( null, $footer_args );
|
|
|
|
?>
|