- fixed User Profile posts pagination;

- 2.0.29 release;
This commit is contained in:
nikitozzzzzzz
2018-10-08 23:36:05 +03:00
parent 846e9b3b5a
commit b4c2ff15dd
11 changed files with 246 additions and 149 deletions
+2 -4
View File
@@ -7,7 +7,7 @@ Ultimate Member is the #1 user profile & membership plugin for WordPress. The pl
| Latest Version |Requires at least|Stable Tag|
| :------------: |:------------:|:------------:|
| 2.0.28 | WordPress 4.9 or higher| 2.0.28 |
| 2.0.29 | WordPress 4.9 or higher| 2.0.29 |
Features of the plugin include:
@@ -48,9 +48,7 @@ GNU Version 2 or Any Later Version
Releases
====================
[Official Release Version: 2.0.28](https://github.com/ultimatemember/ultimatemember/releases/tag/2.0.28).
[Official Release Version: 1.3.88](https://github.com/ultimatemember/ultimatemember/releases).
[Official Release Version: 2.0.29](https://github.com/ultimatemember/ultimatemember/releases/tag/2.0.29).
Changelog
====================
+56 -25
View File
@@ -241,31 +241,62 @@ jQuery(document).ready(function() {
return false;
});
jQuery(document).on('click', '.um-ajax-paginate', function(e){
e.preventDefault();
var parent = jQuery(this).parent();
parent.addClass('loading');
var args = jQuery(this).data('args');
var hook = jQuery(this).data('hook');
var container = jQuery(this).parents('.um').find('.um-ajax-items');
jQuery.ajax({
url: wp.ajax.settings.url,
type: 'post',
data: {
action: 'um_ajax_paginate',
hook: hook,
args: args
},
complete: function(){
parent.removeClass('loading');
},
success: function(data){
parent.remove();
container.append( data );
}
});
return false;
});
jQuery( document.body ).on( 'click', '.um-ajax-paginate', function(e) {
e.preventDefault();
var obj = jQuery(this);
var parent = jQuery(this).parent();
parent.addClass( 'loading' );
var hook = jQuery(this).data('hook');
if ( 'um_load_posts' === hook ) {
var pages = jQuery(this).data('pages')*1;
var next_page = jQuery(this).data('page')*1 + 1;
jQuery.ajax({
url: wp.ajax.settings.url,
type: 'post',
data: {
action: 'um_ajax_paginate_posts',
author: jQuery(this).data('author'),
page: next_page
},
complete: function() {
parent.removeClass( 'loading' );
},
success: function( data ) {
parent.before( data );
if ( next_page === pages ) {
parent.remove();
} else {
obj.data( 'page', next_page );
}
}
});
} else {
var args = jQuery(this).data('args');
var container = jQuery(this).parents('.um').find('.um-ajax-items');
jQuery.ajax({
url: wp.ajax.settings.url,
type: 'post',
data: {
action: 'um_ajax_paginate',
hook: hook,
args: args
},
complete: function() {
parent.removeClass( 'loading' );
},
success: function(data){
parent.remove();
container.append( data );
}
});
}
});
jQuery(document).on('click', '.um-ajax-action', function(e){
e.preventDefault();
+1 -1
View File
File diff suppressed because one or more lines are too long
+3
View File
@@ -36,7 +36,10 @@ if ( ! class_exists( 'um\core\AJAX_Common' ) ) {
add_action( 'wp_ajax_um_delete_profile_photo', array( UM()->profile(), 'ajax_delete_profile_photo' ) );
add_action( 'wp_ajax_um_delete_cover_photo', array( UM()->profile(), 'ajax_delete_cover_photo' ) );
add_action( 'wp_ajax_um_ajax_paginate', array( UM()->query(), 'ajax_paginate' ) );
add_action( 'wp_ajax_um_ajax_paginate_posts', array( UM()->user_posts(), 'load_posts' ) );
add_action( 'wp_ajax_um_muted_action', array( UM()->form(), 'ajax_muted_action' ) );
add_action( 'wp_ajax_um_remove_file', array( UM()->files(), 'ajax_remove_file' ) );
-3
View File
@@ -272,14 +272,11 @@ if ( ! class_exists( 'um\core\Shortcodes' ) ) {
$file = um_path . "templates/{$tpl}.php";
$theme_file = get_stylesheet_directory() . "/ultimate-member/templates/{$tpl}.php";
if ( file_exists( $theme_file ) ) {
$file = $theme_file;
}
if ( file_exists( $file ) ) {
include $file;
}
}
+91 -30
View File
@@ -20,32 +20,109 @@ if ( ! class_exists( 'um\core\User_posts' ) ) {
add_action( 'um_profile_content_posts', array( &$this, 'add_posts' ) );
add_action( 'um_profile_content_comments', array( &$this, 'add_comments' ) );
add_action( 'um_ajax_load_posts__um_load_posts', array( &$this, 'load_posts' ) );
add_action( 'um_ajax_load_posts__um_load_comments', array( &$this, 'load_comments' ) );
add_action( 'um_ajax_load_posts__um_load_comments', array( &$this, 'load_comments' ), 10, 1 );
}
/**
* Add posts
*/
function add_posts() {
$args = array(
'post_type' => 'post',
'posts_per_page' => 10,
'offset' => 0,
'author' => um_get_requested_user(),
'post_status' => array( 'publish' )
);
/**
* UM hook
*
* @type filter
* @title um_profile_query_make_posts
* @description Some changes of WP_Query Posts Tab
* @input_vars
* [{"var":"$query_posts","type":"WP_Query","desc":"UM Posts Tab query"}]
* @change_log
* ["Since: 2.0"]
* @usage
* <?php add_filter( 'um_profile_query_make_posts', 'function_name', 10, 1 ); ?>
* @example
* <?php
* add_filter( 'um_profile_query_make_posts', 'my_profile_query_make_posts', 10, 1 );
* function my_profile_query_make_posts( $query_posts ) {
* // your code here
* return $query_posts;
* }
* ?>
*/
$args = apply_filters( 'um_profile_query_make_posts', $args );
$posts = get_posts( $args );
$count_posts = wp_count_posts();
$count_posts = ! empty( $count_posts->publish ) ? $count_posts->publish : 0;
UM()->shortcodes()->set_args = array( 'posts' => $posts, 'count_posts' => $count_posts );
UM()->shortcodes()->load_template( 'profile/posts' );
}
/**
* Add comments
*/
function add_comments() {
UM()->shortcodes()->load_template( 'profile/comments' );
}
/**
* Dynamic load of posts
*
* @param array $args
*/
function load_posts( $args ) {
$array = explode(',', $args );
$post_type = $array[0];
$posts_per_page = $array[1];
$offset = $array[2];
$author = $array[3];
function load_posts() {
$author = ! empty( $_POST['author'] ) ? $_POST['author'] : get_current_user_id();
$page = ! empty( $_POST['page'] ) ? $_POST['page'] : 0;
$offset_n = $posts_per_page + $offset;
$args = array(
'post_type' => 'post',
'posts_per_page' => 10,
'offset' => ( $page - 1 ) * 10,
'author' => $author,
'post_status' => array( 'publish' )
);
UM()->shortcodes()->modified_args = "$post_type,$posts_per_page,$offset_n,$author";
/**
* UM hook
*
* @type filter
* @title um_profile_query_make_posts
* @description Some changes of WP_Query Posts Tab
* @input_vars
* [{"var":"$query_posts","type":"WP_Query","desc":"UM Posts Tab query"}]
* @change_log
* ["Since: 2.0"]
* @usage
* <?php add_filter( 'um_profile_query_make_posts', 'function_name', 10, 1 ); ?>
* @example
* <?php
* add_filter( 'um_profile_query_make_posts', 'my_profile_query_make_posts', 10, 1 );
* function my_profile_query_make_posts( $query_posts ) {
* // your code here
* return $query_posts;
* }
* ?>
*/
$args = apply_filters( 'um_profile_query_make_posts', $args );
$posts = get_posts( $args );
UM()->shortcodes()->loop = UM()->query()->make("post_type=$post_type&posts_per_page=$posts_per_page&offset=$offset&author=$author");
UM()->shortcodes()->load_template('profile/posts-single');
UM()->shortcodes()->set_args = array( 'posts' => $posts );
UM()->shortcodes()->load_template( 'profile/posts' );
wp_die();
}
/**
* Dynamic load of comments
*
@@ -68,22 +145,6 @@ if ( ! class_exists( 'um\core\User_posts' ) ) {
}
/**
* Add posts
*/
function add_posts() {
UM()->shortcodes()->load_template( 'profile/posts' );
}
/**
* Add comments
*/
function add_comments() {
UM()->shortcodes()->load_template( 'profile/comments' );
}
/**
* Count posts by type
*
+17 -17
View File
@@ -1,8 +1,8 @@
msgid ""
msgstr ""
"Project-Id-Version: Ultimate Member\n"
"POT-Creation-Date: 2018-10-05 10:16+0300\n"
"PO-Revision-Date: 2018-10-05 10:16+0300\n"
"POT-Creation-Date: 2018-10-08 23:32+0300\n"
"PO-Revision-Date: 2018-10-08 23:32+0300\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: en_US\n"
@@ -6513,17 +6513,17 @@ msgstr ""
msgid "Wrong nonce"
msgstr ""
#: includes/core/class-shortcodes.php:358
#: includes/core/class-shortcodes.php:355
msgid ""
"This content has been restricted to logged in users only. Please <a href="
"\"{login_referrer}\">login</a> to view this content."
msgstr ""
#: includes/core/class-shortcodes.php:518
#: includes/core/class-shortcodes.php:515
msgid "You are already registered"
msgstr ""
#: includes/core/class-shortcodes.php:760
#: includes/core/class-shortcodes.php:757
msgid "Default Template"
msgstr ""
@@ -7043,37 +7043,37 @@ msgstr ""
msgid "This user has not made any comments."
msgstr ""
#: templates/profile/posts-single.php:16
#: templates/profile/posts-single.php:21
#, php-format
msgid "%s ago"
msgstr ""
#: templates/profile/posts-single.php:17
#: templates/profile/posts-single.php:24
msgid "in"
msgstr ""
#: templates/profile/posts-single.php:18
#: templates/profile/posts-single.php:30
msgid "no comments"
msgstr ""
#: templates/profile/posts-single.php:18
#: templates/profile/posts-single.php:32
#, php-format
msgid "%s comments"
msgstr ""
#: templates/profile/posts-single.php:34
msgid "1 comment"
msgstr ""
#: templates/profile/posts-single.php:18
#, php-format
msgid "% comments"
msgstr ""
#: templates/profile/posts-single.php:27 templates/profile/posts.php:35
#: templates/profile/posts.php:21
msgid "load more posts"
msgstr ""
#: templates/profile/posts.php:43
#: templates/profile/posts.php:32
msgid "You have not created any posts."
msgstr ""
#: templates/profile/posts.php:43
#: templates/profile/posts.php:32
msgid "This user has not created any posts."
msgstr ""
+6 -1
View File
@@ -6,7 +6,7 @@ Donate link:
Tags: community, member, membership, user-profile, user-registration
Requires at least: 4.7
Tested up to: 4.9
Stable tag: 2.0.28
Stable tag: 2.0.29
License: GNU Version 2 or Any Later Version
License URI: http://www.gnu.org/licenses/gpl-3.0.txt
@@ -133,6 +133,11 @@ The plugin works with popular caching plugins by automatically excluding Ultimat
= Important: UM2.0+ is a significant update to the code base from 1.3.88. Please make sure you take a full-site backup with restore point before updating the plugin =
= 2.0.29: October 8, 2018 =
* Bugfixes:
- Fixed User Profile Posts pagination
= 2.0.28: October 5, 2018 =
* Bugfixes:
+37 -27
View File
@@ -1,30 +1,40 @@
<?php while (UM()->shortcodes()->loop->have_posts()) { UM()->shortcodes()->loop->the_post(); $post_id = get_the_ID(); ?>
<div class="um-item">
<div class="um-item-link">
<i class="um-icon-ios-paper"></i>
<a href="<?php echo get_permalink( $post ) ?>"><?php echo $post->post_title; ?></a>
</div>
<div class="um-item">
<div class="um-item-link"><i class="um-icon-ios-paper"></i><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
<?php if ( has_post_thumbnail( $post_id ) ) {
$image_id = get_post_thumbnail_id( $post_id );
$image_url = wp_get_attachment_image_src( $image_id, 'full', true );
?>
<div class="um-item-img"><a href="<?php the_permalink(); ?>"><?php echo get_the_post_thumbnail( $post_id, 'medium' ); ?></a></div>
<?php } ?>
<div class="um-item-meta">
<span><?php echo sprintf(__('%s ago','ultimate-member'), human_time_diff( get_the_time('U'), current_time('timestamp') ) ); ?></span>
<span><?php echo __('in','ultimate-member');?>: <?php the_category( ', ' ); ?></span>
<span><?php comments_number( __('no comments','ultimate-member'), __('1 comment','ultimate-member'), __('% comments','ultimate-member') ); ?></span>
</div>
<?php if ( has_post_thumbnail( $post->ID ) ) {
$image_id = get_post_thumbnail_id( $post->ID );
$image_url = wp_get_attachment_image_src( $image_id, 'full', true ); ?>
<div class="um-item-img">
<a href="<?php echo get_permalink( $post ) ?>">
<?php echo get_the_post_thumbnail( $post->ID, 'medium' ); ?>
</a>
</div>
<?php } ?>
<?php if ( isset(UM()->shortcodes()->modified_args) && UM()->shortcodes()->loop->have_posts() && UM()->shortcodes()->loop->found_posts >= 10 ) { ?>
<div class="um-load-items">
<a href="#" class="um-ajax-paginate um-button" data-hook="um_load_posts" data-args="<?php echo UM()->shortcodes()->modified_args; ?>"><?php _e('load more posts','ultimate-member'); ?></a>
</div>
<?php } ?>
<div class="um-item-meta">
<span>
<?php printf( __( '%s ago', 'ultimate-member' ), human_time_diff( get_the_time( 'U', $post->ID ), current_time( 'timestamp' ) ) ); ?>
</span>
<span>
<?php echo __( 'in', 'ultimate-member' ); ?>: <?php the_category( ', ', '', $post->ID ); ?>
</span>
<span>
<?php $num_comments = get_comments_number( $post->ID );
if ( $num_comments == 0 ) {
$comments = __( 'no comments', 'ultimate-member' );
} elseif ( $num_comments > 1 ) {
$comments = sprintf( __( '%s comments', 'ultimate-member' ), $num_comments );
} else {
$comments = __( '1 comment', 'ultimate-member' );
} ?>
<a href="<?php echo get_comments_link( $post->ID ) ?>"><?php echo $comments ?></a>
</span>
</div>
</div>
+32 -40
View File
@@ -1,45 +1,37 @@
<?php $query_posts = UM()->query()->make('post_type=post&posts_per_page=10&offset=0&author=' . um_get_requested_user() );
<?php if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
//Only for AJAX loading posts
if ( ! empty( $posts ) ) {
foreach ( $posts as $post ) {
UM()->shortcodes()->set_args = array( 'post' => $post );
UM()->shortcodes()->load_template( 'profile/posts-single' );
}
}
} else {
if ( ! empty( $posts ) ) { ?>
<div class="um-ajax-items">
/**
* UM hook
*
* @type filter
* @title um_profile_query_make_posts
* @description Some changes of WP_Query Posts Tab
* @input_vars
* [{"var":"$query_posts","type":"WP_Query","desc":"UM Posts Tab query"}]
* @change_log
* ["Since: 2.0"]
* @usage
* <?php add_filter( 'um_profile_query_make_posts', 'function_name', 10, 1 ); ?>
* @example
* <?php
* add_filter( 'um_profile_query_make_posts', 'my_profile_query_make_posts', 10, 1 );
* function my_profile_query_make_posts( $query_posts ) {
* // your code here
* return $query_posts;
* }
* ?>
*/
UM()->shortcodes()->loop = apply_filters( 'um_profile_query_make_posts', $query_posts );
<?php foreach ( $posts as $post ) {
UM()->shortcodes()->set_args = array( 'post' => $post );
UM()->shortcodes()->load_template( 'profile/posts-single' );
}
if ( UM()->shortcodes()->loop->have_posts() ) {
if ( $count_posts > 10 ) { ?>
<div class="um-load-items">
<a href="javascript:void(0);" class="um-ajax-paginate um-button" data-hook="um_load_posts" data-author="<?php echo um_get_requested_user(); ?>" data-page="1" data-pages="<?php echo ceil( $count_posts / 10 ) ?>">
<?php _e( 'load more posts', 'ultimate-member' ); ?>
</a>
</div>
<?php } ?>
UM()->shortcodes()->load_template( 'profile/posts-single' ); ?>
<div class="um-ajax-items">
<!--Ajax output-->
<?php if ( UM()->shortcodes()->loop->found_posts >= 10 ) { ?>
<div class="um-load-items">
<a href="#" class="um-ajax-paginate um-button" data-hook="um_load_posts" data-args="post,10,10,<?php echo um_get_requested_user(); ?>"><?php _e('load more posts','ultimate-member'); ?></a>
</div>
</div>
<?php } ?>
</div>
<?php } else { ?>
<?php } else { ?>
<div class="um-profile-note"><span><?php echo ( um_profile_id() == get_current_user_id() ) ? __('You have not created any posts.','ultimate-member') : __('This user has not created any posts.','ultimate-member'); ?></span></div>
<?php } wp_reset_postdata(); ?>
<div class="um-profile-note">
<span>
<?php echo ( um_profile_id() == get_current_user_id() ) ? __( 'You have not created any posts.', 'ultimate-member' ) : __( 'This user has not created any posts.', 'ultimate-member' ); ?>
</span>
</div>
<?php }
}
+1 -1
View File
@@ -3,7 +3,7 @@
Plugin Name: Ultimate Member
Plugin URI: http://ultimatemember.com/
Description: The easiest way to create powerful online communities and beautiful user profiles with WordPress
Version: 2.0.28
Version: 2.0.29
Author: Ultimate Member
Author URI: http://ultimatemember.com/
Text Domain: ultimate-member