mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-06-05 15:09:37 +09:00
- changed logic of the comments loading on the user profile page;
This commit is contained in:
@@ -1,39 +1,16 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
foreach ( UM()->shortcodes()->loop as $comment ) {
|
||||
$comment_title = apply_filters( 'um_user_profile_comment_title', get_the_title( $comment->comment_post_ID ), $comment );
|
||||
$link = apply_filters( 'um_user_profile_comment_url', get_permalink( $comment->comment_post_ID ), $comment ); ?>
|
||||
|
||||
$post_type = get_post_type( $comment->comment_post_ID );
|
||||
if ( $post_type == 'um_groups_discussion' ) {
|
||||
$comment_id = $comment->comment_post_ID;
|
||||
$group_id = get_post_meta( $comment_id, '_group_id', true );
|
||||
$comment_title = get_the_title( $group_id );
|
||||
$link = site_url() . '/groups/' . $comment_title . '/?tab=discussion#commentid-' . $comment_id;
|
||||
} else {
|
||||
$comment_title = get_the_title( $comment->comment_post_ID );
|
||||
$link = get_permalink( $comment->comment_post_ID );
|
||||
} ?>
|
||||
|
||||
<div class="um-item">
|
||||
<div class="um-item-link">
|
||||
<i class="um-icon-chatboxes"></i>
|
||||
<a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
|
||||
<?php echo get_comment_excerpt( $comment->comment_ID ); ?>
|
||||
</a>
|
||||
</div>
|
||||
<div class="um-item-meta">
|
||||
<span><?php printf( __( 'On <a href="%1$s">%2$s</a>','ultimate-member' ), $link, $comment_title ); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php }
|
||||
|
||||
if ( isset( UM()->shortcodes()->modified_args ) && count( UM()->shortcodes()->loop ) >= 10 ) { ?>
|
||||
|
||||
<div class="um-load-items">
|
||||
<a href="javascript:void(0);" class="um-ajax-paginate um-button" data-hook="um_load_comments"
|
||||
data-args="<?php echo esc_attr( UM()->shortcodes()->modified_args ); ?>">
|
||||
<?php _e( 'load more comments', 'ultimate-member' ); ?>
|
||||
<div class="um-item">
|
||||
<div class="um-item-link">
|
||||
<i class="um-icon-chatboxes"></i>
|
||||
<a href="<?php echo esc_url( get_comment_link( $comment->comment_ID ) ); ?>">
|
||||
<?php echo get_comment_excerpt( $comment->comment_ID ); ?>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<?php }
|
||||
<div class="um-item-meta">
|
||||
<span><?php printf( __( 'On <a href="%1$s">%2$s</a>','ultimate-member' ), $link, $comment_title ); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,38 +1,44 @@
|
||||
<?php if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
UM()->shortcodes()->loop = UM()->query()->make('post_type=comment&number=10&offset=0&user_id=' . um_user('ID') );
|
||||
|
||||
if ( UM()->shortcodes()->loop ) {
|
||||
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
|
||||
//Only for AJAX loading posts
|
||||
if ( ! empty( $comments ) ) {
|
||||
foreach ( $comments as $comment ) {
|
||||
UM()->get_template( 'profile/comments-single.php', '', array( 'comment' => $comment ), true );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ( ! empty( $comments ) ) { ?>
|
||||
<div class="um-ajax-items">
|
||||
|
||||
UM()->shortcodes()->load_template('profile/comments-single'); ?>
|
||||
|
||||
<div class="um-ajax-items">
|
||||
|
||||
<!--Ajax output-->
|
||||
|
||||
<?php if ( count( UM()->shortcodes()->loop ) >= 10 ) { ?>
|
||||
|
||||
<div class="um-load-items">
|
||||
<a href="javascript:void(0);" class="um-ajax-paginate um-button" data-hook="um_load_comments"
|
||||
data-args="comment,10,10,<?php echo esc_attr( um_user( 'ID' ) ); ?>">
|
||||
<?php _e( 'load more comments', 'ultimate-member' ); ?>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
|
||||
<?php } else { ?>
|
||||
<?php foreach ( $comments as $comment ) {
|
||||
UM()->get_template( 'profile/comments-single.php', '', array( 'comment' => $comment ), true );
|
||||
}
|
||||
|
||||
<div class="um-profile-note">
|
||||
<span>
|
||||
<?php if ( um_profile_id() == get_current_user_id() ) {
|
||||
_e( 'You have not made any comments.', 'ultimate-member' );
|
||||
} else {
|
||||
_e( 'This user has not made any comments.', 'ultimate-member' );
|
||||
} ?>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<?php }
|
||||
if ( $count_comments > 10 ) { ?>
|
||||
<div class="um-load-items">
|
||||
<a href="javascript:void(0);" class="um-ajax-paginate um-button" data-hook="um_load_comments"
|
||||
data-user_id="<?php echo esc_attr( um_get_requested_user() ); ?>" data-page="1"
|
||||
data-pages="<?php echo esc_attr( ceil( $count_comments / 10 ) ); ?>">
|
||||
<?php _e( 'load more comments', 'ultimate-member' ); ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
</div>
|
||||
|
||||
<?php } else { ?>
|
||||
|
||||
<div class="um-profile-note">
|
||||
<span>
|
||||
<?php if ( um_profile_id() == get_current_user_id() ) {
|
||||
_e( 'You have not made any comments.', 'ultimate-member' );
|
||||
} else {
|
||||
_e( 'This user has not made any comments.', 'ultimate-member' );
|
||||
} ?>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<?php }
|
||||
}
|
||||
Reference in New Issue
Block a user