Skip to content

Commit 75e9b70

Browse files
authored
Merge pull request #1 from ajaxloadmore/hotfix/php-warnings
Fix for php warnings
2 parents 7831569 + 0e7f640 commit 75e9b70

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

README.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Donate link: https://connekthq.com/donate/
77
Tags: ajax load more, rest api, api, rest, ajax, infinite scroll, javascript, query, endpoints, endpoint, lazy load
88
Requires at least: 4.0
99
Tested up to: 6.1
10-
Stable tag: 1.2.2
10+
Stable tag: 1.2.3
1111
License: GPLv2 or later
1212
License URI: http://www.gnu.org/licenses/gpl-2.0.html
1313

@@ -74,6 +74,9 @@ Yes! As long as you are using the default /wp-json/ajaxloadmore/posts endpoint a
7474

7575
== Changelog ==
7676

77+
= 1.2.3 - February 23, 2023 =
78+
* FIX: Fixed up PHP warnign messages found in debug log for default endpoint.
79+
7780
= 1.2.2 - December 30, 2022 =
7881
* FIX: Added fix for saving posts in editor when REST API shortcode in place.
7982
* UPDATE: Updated custo endpoint to rely on core ALM query params.

ajax-load-more-rest-api.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Author: Darren Cooney
88
* Twitter: @KaptonKaos
99
* Author URI: https://connekthq.com
10-
* Version: 1.2.2
10+
* Version: 1.2.3
1111
* License: GPL
1212
* Copyright: Darren Cooney & Connekt Media
1313
*
@@ -23,8 +23,8 @@
2323
*/
2424
define( 'ALM_RESTAPI_PATH', plugin_dir_path( __FILE__ ) );
2525
define( 'ALM_RESTAPI_URL', plugins_url( '', __FILE__ ) );
26-
define( 'ALM_RESTAPI_VERSION', '1.2.2' );
27-
define( 'ALM_RESTAPI_RELEASE', 'December 30, 2022' );
26+
define( 'ALM_RESTAPI_VERSION', '1.2.3' );
27+
define( 'ALM_RESTAPI_RELEASE', 'February 16, 2023' );
2828

2929
/**
3030
* Activation hook

endpoints.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ function alm_get_posts( $data ) {
4646
$response = [];
4747

4848
// Set Defaults.
49-
$args = [];
50-
$page = $data['page'];
49+
$args = [];
50+
$page = isset( $data['page'] ) ? $data['page'] : 0;
51+
$posts_per_page = isset( $data['posts_per_page'] ) ? $data['posts_per_page'] : 5;
5152

5253
if ( method_exists( 'ALM_QUERY_ARGS', 'alm_build_queryargs' ) ) {
5354
/**
@@ -67,7 +68,7 @@ function alm_get_posts( $data ) {
6768
*
6869
* @see https://connekthq.com/plugins/ajax-load-more/docs/variables/
6970
*/
70-
$alm_item = $args['page'] * $posts_per_page;
71+
$alm_item = $page * $posts_per_page;
7172
$alm_found_posts = $posts->found_posts;
7273
$alm_post_count = $posts->post_count;
7374
$alm_current = 0;
@@ -90,7 +91,7 @@ function alm_get_posts( $data ) {
9091

9192
// Build $data JSON object.
9293
$data[] = [
93-
'alm_page' => $args['page'] + 1,
94+
'alm_page' => $page + 1,
9495
'alm_item' => ( $alm_item++ ) + 1,
9596
'alm_current' => $alm_current,
9697
'alm_found_posts' => $alm_found_posts,

0 commit comments

Comments
 (0)