2023-01-21 01:31:34 +01:00
< ? php
/**
* Partial : Account - Data
*
* @ package WordPress
* @ subpackage Fictioneer
2024-01-26 17:45:59 +01:00
* @ since 5.0 . 0
2023-01-21 01:31:34 +01:00
*
2023-08-19 22:22:56 +02:00
* @ internal $args [ 'user' ] Current user .
* @ internal $args [ 'is_admin' ] True if the user is an administrator .
* @ internal $args [ 'is_author' ] True if the user is an author ( by capabilities ) .
* @ internal $args [ 'is_editor' ] True if the user is an editor .
* @ internal $args [ 'is_moderator' ] True if the user is a moderator ( by capabilities ) .
2023-01-21 01:31:34 +01:00
*/
2023-08-20 20:21:48 +02:00
// No direct access!
defined ( 'ABSPATH' ) OR exit ;
2023-01-21 01:31:34 +01:00
// Setup
$current_user = $args [ 'user' ];
2023-08-03 23:51:04 +02:00
$bookmarks_link = fictioneer_get_assigned_page_link ( 'fictioneer_bookmarks_page' );
$bookshelf_link = fictioneer_get_assigned_page_link ( 'fictioneer_bookshelf_page' );
2023-08-07 12:43:02 +02:00
$comments_count = get_comments (
array ( 'user_id' => $current_user -> ID , 'count' => true , 'update_comment_meta_cache' => false )
);
2023-01-21 01:31:34 +01:00
$last_comment = $comments_count > 0 ? get_comments ( [ 'user_id' => $current_user -> ID , 'number' => 1 ] )[ 0 ] : false ;
$timezone = get_user_meta ( $current_user -> ID , 'fictioneer_user_timezone_string' , true );
$timezone = empty ( $timezone ) ? get_option ( 'timezone_string' ) : $timezone ;
$notification_validator = get_user_meta ( $current_user -> ID , 'fictioneer_comment_reply_validator' , true );
if ( empty ( $notification_validator ) ) {
$comment_subscriptions_count = 0 ;
} else {
$comment_subscriptions_count = get_comments (
array (
'user_id' => $current_user -> ID ,
'meta_key' => 'fictioneer_send_notifications' ,
'meta_value' => $notification_validator ,
2023-08-07 12:43:02 +02:00
'count' => true ,
'update_comment_meta_cache' => false
2023-01-21 01:31:34 +01:00
)
);
}
// Remember data to pass on to hooks
$args [ 'timezone' ] = $timezone ;
$args [ 'comments_count' ] = $comments_count ;
// Flags
$can_follows = get_option ( 'fictioneer_enable_follows' );
$can_reminders = get_option ( 'fictioneer_enable_reminders' );
2023-08-08 20:33:24 +02:00
$can_checkmarks = get_option ( 'fictioneer_enable_checkmarks' );
2023-01-21 01:31:34 +01:00
$can_bookmarks = get_option ( 'fictioneer_enable_bookmarks' );
2023-08-08 20:33:24 +02:00
// Follows/Reminders/Checkmarks
if ( $can_follows ) {
$follows = fictioneer_load_follows ( $current_user );
$args [ 'follows' ] = $follows ;
}
if ( $can_reminders ) {
$reminders = fictioneer_load_reminders ( $current_user );
$args [ 'reminders' ] = $reminders ;
}
if ( $can_checkmarks ) {
$checkmarks = fictioneer_load_checkmarks ( $current_user );
$args [ 'checkmarks' ] = $checkmarks ;
}
2024-03-09 13:55:16 +01:00
// Prompts
$confirmation = _x ( 'DELETE' , 'Prompt deletion confirmation string.' , 'fictioneer' );
$delete_comments_prompt = sprintf (
__ ( 'Are you sure? Comments will be irrevocably deleted. Enter %s to confirm.' , 'fictioneer' ),
$confirmation
);
$delete_comment_subscriptions_prompt = sprintf (
__ ( 'Are you sure? Comment subscriptions will be irrevocably deleted. Enter %s to confirm.' , 'fictioneer' ),
$confirmation
);
$delete_follows_prompt = sprintf (
__ ( 'Are you sure? Follows will be irrevocably deleted. Enter %s to confirm.' , 'fictioneer' ),
$confirmation
);
$delete_reminders_prompt = sprintf (
__ ( 'Are you sure? Reminders will be irrevocably deleted. Enter %s to confirm.' , 'fictioneer' ),
$confirmation
);
$delete_checkmarks_prompt = sprintf (
__ ( 'Are you sure? Checkmarks will be irrevocably deleted. Enter %s to confirm.' , 'fictioneer' ),
$confirmation
);
$delete_bookmarks_prompt = sprintf (
__ ( 'Are you sure? Bookmarks will be irrevocably deleted. Enter %s to confirm.' , 'fictioneer' ),
$confirmation
);
2023-01-21 01:31:34 +01:00
?>
< div id = " profile-data-translations " data - cleared - success = " <?php esc_attr_e( 'Data has been cleared.', 'fictioneer' ); ?> " data - cleared - error = " <?php esc_attr_e( 'Error. Data could not be cleared.', 'fictioneer' ); ?> " hidden ></ div >
2023-09-16 14:25:26 +02:00
< h3 class = " profile__actions-headline " id = " profile-actions " >< ? php _e ( 'Data' , 'fictioneer' ); ?> </h3>
2023-01-21 01:31:34 +01:00
< p class = " profile__description " >< ? php
printf (
__ ( 'The following cards represent data nodes stored in your account. Anything submitted by yourself, such as comments. You can clear these nodes by clicking on the trash icon, but be aware that this is irreversible. The timestamps are based on the server’ s timezone (%s).' , 'fictioneer' ),
wp_timezone_string ()
);
?> </p>
2024-01-21 22:58:26 +01:00
< div class = " profile__data profile__segment container-inline-size " >
2024-01-19 14:55:50 +01:00
< ul class = " grid-columns " >
2023-01-21 01:31:34 +01:00
< ? php if ( $comments_count > 0 ) : ?>
< li class = " card _small " >
< div class = " card__body polygon " >
< div class = " card__header _small " >
2023-01-26 12:23:41 +01:00
< h3 class = " card__title _with-delete _small " >< ? php _e ( 'Comments' , 'fictioneer' ); ?> </h3>
2023-01-21 01:31:34 +01:00
</ div >
< div class = " card__main _small " >
2024-05-14 16:56:31 +02:00
< div class = " card__content cell-data _small " >
2023-01-21 01:31:34 +01:00
< ? php
printf (
2024-05-14 16:56:31 +02:00
__ ( 'You have written <strong>%1$s %2$s</strong>. Last comment written on %3$s.' , 'fictioneer' ),
2023-01-21 01:31:34 +01:00
$comments_count ,
_n ( 'comment' , 'comments' , $comments_count , 'fictioneer' ),
wp_date ( get_option ( 'date_format' ) . ' ' . get_option ( 'time_format' ), date_format ( date_create ( $last_comment -> comment_date ), 'U' ) )
);
?>
</ div >
</ div >
2025-01-08 18:59:34 +01:00
< button class = " card__delete button-clear-comments " data - nonce = " <?php echo wp_create_nonce( 'fictioneer_clear_comments' ); ?> " data - confirm = " <?php echo $confirmation ; ?> " data - warning = " <?php echo esc_attr( $delete_comments_prompt ); ?> " data - fictioneer - target = " dcjProtected " disabled >< i class = " fa-solid fa-trash-can " ></ i ></ button >
2023-01-21 01:31:34 +01:00
</ div >
</ li >
< ? php endif ; ?>
< ? php if ( $comment_subscriptions_count > 0 ) : ?>
< li class = " card _small " >
< div class = " card__body polygon " >
< div class = " card__header _small " >
2023-01-26 12:23:41 +01:00
< h3 class = " card__title _with-delete _small " >< ? php _e ( 'Comment Subscriptions' , 'fictioneer' ); ?> </h3>
2023-01-21 01:31:34 +01:00
</ div >
< div class = " card__main _small " >
2024-05-14 16:56:31 +02:00
< div class = " card__content cell-data _small " >
2023-01-21 01:31:34 +01:00
< ? php
printf (
2024-05-14 16:56:31 +02:00
__ ( 'You are currently subscribed to <strong>%1$s %2$s</strong>. You will get an email notification for each direct reply.' , 'fictioneer' ),
2023-01-21 01:31:34 +01:00
$comment_subscriptions_count ,
_n ( 'comment' , 'comments' , $comment_subscriptions_count , 'fictioneer' )
);
?>
</ div >
</ div >
2025-01-08 18:59:34 +01:00
< button class = " card__delete button-clear-comment-subscriptions " data - nonce = " <?php echo wp_create_nonce( 'fictioneer_clear_comment_subscriptions' ); ?> " data - confirm = " <?php echo $confirmation ; ?> " data - warning = " <?php echo esc_attr( $delete_comment_subscriptions_prompt ); ?> " data - fictioneer - target = " dcjProtected " disabled >< i class = " fa-solid fa-trash-can " ></ i ></ button >
2023-01-21 01:31:34 +01:00
</ div >
</ li >
< ? php endif ; ?>
< ? php if ( $can_follows ) : ?>
< ? php $follows_count = count ( $follows [ 'data' ] ); ?>
< li class = " card _small " >
< div class = " card__body polygon " >
< div class = " card__header _small " >
2023-01-26 12:23:41 +01:00
< h3 class = " card__title _with-delete _small " >< ? php
2023-01-21 01:31:34 +01:00
if ( $bookshelf_link ) {
?> <a href="<?php echo add_query_arg( 'tab', 'follows', $bookshelf_link ) . '#tabs'; ?>"><?php echo fcntr( 'follows' ); ?></a><?php
} else {
echo fcntr ( 'follows' );
}
?> </h3>
</ div >
< div class = " card__main _small " >
2024-05-14 16:56:31 +02:00
< div class = " card__content cell-data _small " >
2023-01-21 01:31:34 +01:00
< ? php
printf (
2024-05-14 16:56:31 +02:00
__ ( 'You are currently following <strong>%1$s %2$s</strong>. Last modified on %3$s.' , 'fictioneer' ),
2023-01-21 01:31:34 +01:00
$follows_count ,
_n ( 'story' , 'stories' , $follows_count , 'fictioneer' ),
wp_date ( get_option ( 'date_format' ) . ' ' . get_option ( 'time_format' ), $follows [ 'updated' ] / 1000 )
);
?>
</ div >
</ div >
2023-01-24 02:18:31 +01:00
< ? php if ( $follows_count > 0 ) : ?>
2025-01-08 18:59:34 +01:00
< button class = " card__delete button-clear-follows " data - nonce = " <?php echo wp_create_nonce( 'fictioneer_clear_follows' ); ?> " data - confirm = " <?php echo $confirmation ; ?> " data - warning = " <?php echo esc_attr( $delete_follows_prompt ); ?> " data - fictioneer - target = " dcjProtected " disabled >< i class = " fa-solid fa-trash-can " ></ i ></ button >
2023-01-24 02:18:31 +01:00
< ? php endif ; ?>
2023-01-21 01:31:34 +01:00
</ div >
</ li >
< ? php endif ; ?>
< ? php if ( $can_reminders ) : ?>
< ? php $reminders_count = count ( $reminders [ 'data' ] ); ?>
< li class = " card _small " >
< div class = " card__body polygon " >
< div class = " card__header _small " >
2023-01-26 12:23:41 +01:00
< h3 class = " card__title _with-delete _small " >< ? php
2023-01-21 01:31:34 +01:00
if ( $bookshelf_link ) {
?> <a href="<?php echo add_query_arg( 'tab', 'reminders', $bookshelf_link ) . '#tabs'; ?>"><?php echo fcntr( 'reminders' ); ?></a><?php
} else {
echo fcntr ( 'reminders' );
}
?> </h3>
</ div >
< div class = " card__main _small " >
2024-05-14 16:56:31 +02:00
< div class = " card__content cell-data _small " >
2023-01-21 01:31:34 +01:00
< ? php
printf (
2024-05-14 16:56:31 +02:00
__ ( 'You have <strong>%1$s %2$s</strong> marked to be read later. Last modified on %3$s.' , 'fictioneer' ),
2023-01-21 01:31:34 +01:00
$reminders_count ,
_n ( 'story' , 'stories' , $reminders_count , 'fictioneer' ),
wp_date ( get_option ( 'date_format' ) . ' ' . get_option ( 'time_format' ), $reminders [ 'updated' ] / 1000 )
);
?>
</ div >
</ div >
2023-01-24 02:18:31 +01:00
< ? php if ( $reminders_count > 0 ) : ?>
2025-01-08 18:59:34 +01:00
< button class = " card__delete button-clear-reminders " data - nonce = " <?php echo wp_create_nonce( 'fictioneer_clear_reminders' ); ?> " data - confirm = " <?php echo $confirmation ; ?> " data - warning = " <?php echo esc_attr( $delete_reminders_prompt ); ?> " data - fictioneer - target = " dcjProtected " disabled >< i class = " fa-solid fa-trash-can " ></ i ></ button >
2023-01-24 02:18:31 +01:00
< ? php endif ; ?>
2023-01-21 01:31:34 +01:00
</ div >
</ li >
< ? php endif ; ?>
< ? php if ( $can_checkmarks ) : ?>
< ? php
$stories_count = count ( fictioneer_get_finished_checkmarks ( $checkmarks ) );
$chapters_count = fictioneer_count_chapter_checkmarks ( $checkmarks );
?>
< li class = " card _small " >
< div class = " card__body polygon " >
< div class = " card__header _small " >
2023-01-26 12:23:41 +01:00
< h3 class = " card__title _with-delete _small " >< ? php
2023-01-21 01:31:34 +01:00
if ( $bookshelf_link ) {
?> <a href="<?php echo add_query_arg( 'tab', 'finished', $bookshelf_link ) . '#tabs'; ?>"><?php _e( 'Checkmarks', 'fictioneer' ); ?></a><?php
} else {
_e ( 'Checkmarks' , 'fictioneer' );
}
?> </h3>
</ div >
< div class = " card__main _small " >
2024-05-14 16:56:31 +02:00
< div class = " card__content cell-data _small " >
2023-01-21 01:31:34 +01:00
< ? php
printf (
2024-05-14 16:56:31 +02:00
__ ( 'You have marked <strong>%1$s %2$s</strong> as finished and <strong>%3$s %4$s</strong> as read. Last modified on %5$s.' , 'fictioneer' ),
2023-01-21 01:31:34 +01:00
$stories_count ,
_n ( 'story' , 'stories' , $stories_count , 'fictioneer' ),
$chapters_count ,
_n ( 'chapter' , 'chapters' , $chapters_count , 'fictioneer' ),
wp_date ( get_option ( 'date_format' ) . ' ' . get_option ( 'time_format' ), $checkmarks [ 'updated' ] / 1000 )
);
?>
</ div >
</ div >
2023-01-24 02:18:31 +01:00
< ? php if ( $stories_count > 0 || $chapters_count > 0 ) : ?>
2025-01-08 18:59:34 +01:00
< button class = " card__delete button-clear-checkmarks " data - nonce = " <?php echo wp_create_nonce( 'fictioneer_clear_checkmarks' ); ?> " data - confirm = " <?php echo $confirmation ; ?> " data - warning = " <?php echo esc_attr( $delete_checkmarks_prompt ); ?> " data - fictioneer - target = " dcjProtected " disabled >< i class = " fa-solid fa-trash-can " ></ i ></ button >
2023-01-24 02:18:31 +01:00
< ? php endif ; ?>
2023-01-21 01:31:34 +01:00
</ div >
</ li >
< ? php endif ; ?>
< ? php if ( $can_bookmarks ) : ?>
< li class = " card _small " >
< div class = " card__body polygon " >
< div class = " card__header _small " >
2023-01-26 12:23:41 +01:00
< h3 class = " card__title _with-delete _small " >< ? php
2023-01-21 01:31:34 +01:00
if ( $bookmarks_link ) {
?> <a href="<?php echo $bookmarks_link; ?>"><?php echo fcntr( 'bookmarks' ); ?></a><?php
} else {
echo fcntr ( 'bookmarks' );
}
?> </h3>
</ div >
< div class = " card__main _small " >
2024-12-06 17:38:32 +01:00
< div class = " card__content cell-data _small profile-bookmarks-stats " data - fictioneer - bookmarks - target = " dataCard " >
2024-05-14 16:56:31 +02:00
< ? php _e ( 'You have currently <strong>%s bookmark(s)</strong> set. Bookmarks are only processed in your browser.' , 'fictioneer' ); ?>
2023-01-21 01:31:34 +01:00
</ div >
</ div >
2025-01-08 18:59:34 +01:00
< button class = " card__delete button-clear-bookmarks " data - confirm = " <?php echo $confirmation ; ?> " data - warning = " <?php echo esc_attr( $delete_bookmarks_prompt ); ?> " data - fictioneer - target = " dcjProtected " disabled >< i class = " fa-solid fa-trash-can " ></ i ></ button >
2023-01-21 01:31:34 +01:00
</ div >
</ li >
< ? php endif ; ?>
< ? php do_action ( 'fictioneer_account_data_nodes' , $current_user , $args ); ?>
</ ul >
</ div >