use paged
instead of offset
This commit is contained in:
parent
7f3d31c59e
commit
f3d2243afb
1 changed files with 9 additions and 7 deletions
|
@ -61,7 +61,7 @@ class Outbox {
|
||||||
|
|
||||||
$post_types = \get_option( 'activitypub_support_post_types', array( 'post', 'page' ) );
|
$post_types = \get_option( 'activitypub_support_post_types', array( 'post', 'page' ) );
|
||||||
|
|
||||||
$page = $request->get_param( 'page', 0 );
|
$page = $request->get_param( 'page', 1 );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Action triggerd prior to the ActivityPub profile being created and sent to the client
|
* Action triggerd prior to the ActivityPub profile being created and sent to the client
|
||||||
|
@ -78,9 +78,6 @@ class Outbox {
|
||||||
$json->partOf = get_rest_url_by_path( sprintf( 'users/%d/outbox', $user_id ) ); // phpcs:ignore
|
$json->partOf = get_rest_url_by_path( sprintf( 'users/%d/outbox', $user_id ) ); // phpcs:ignore
|
||||||
$json->totalItems = 0; // phpcs:ignore
|
$json->totalItems = 0; // phpcs:ignore
|
||||||
|
|
||||||
// phpcs:ignore
|
|
||||||
$json->totalItems = 0;
|
|
||||||
|
|
||||||
foreach ( $post_types as $post_type ) {
|
foreach ( $post_types as $post_type ) {
|
||||||
$count_posts = \wp_count_posts( $post_type );
|
$count_posts = \wp_count_posts( $post_type );
|
||||||
$json->totalItems += \intval( $count_posts->publish ); // phpcs:ignore
|
$json->totalItems += \intval( $count_posts->publish ); // phpcs:ignore
|
||||||
|
@ -93,13 +90,17 @@ class Outbox {
|
||||||
$json->next = \add_query_arg( 'page', $page + 1, $json->partOf ); // phpcs:ignore
|
$json->next = \add_query_arg( 'page', $page + 1, $json->partOf ); // phpcs:ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( $page && ( $page > 1 ) ) { // phpcs:ignore
|
||||||
|
$json->prev = \add_query_arg( 'page', $page - 1, $json->partOf ); // phpcs:ignore
|
||||||
|
}
|
||||||
|
|
||||||
if ( $page ) {
|
if ( $page ) {
|
||||||
$posts = \get_posts(
|
$posts = \get_posts(
|
||||||
array(
|
array(
|
||||||
'posts_per_page' => 10,
|
'posts_per_page' => 10,
|
||||||
'author' => $user_id,
|
'author' => $user_id,
|
||||||
'offset' => ( $page - 1 ) * 10,
|
'paged' => $page,
|
||||||
'post_type' => $post_types,
|
'post_type' => $post_types,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -139,6 +140,7 @@ class Outbox {
|
||||||
|
|
||||||
$params['page'] = array(
|
$params['page'] = array(
|
||||||
'type' => 'integer',
|
'type' => 'integer',
|
||||||
|
'default' => 1,
|
||||||
);
|
);
|
||||||
|
|
||||||
$params['user_id'] = array(
|
$params['user_id'] = array(
|
||||||
|
|
Loading…
Reference in a new issue