Skip to content

Commit

Permalink
Merge pull request #14 from a8cteam51/fix/load-more-inherit
Browse files Browse the repository at this point in the history
Fix Load more button to work with inherited templates
  • Loading branch information
nickpagz authored Aug 17, 2024
2 parents f478aa6 + 9f8f77e commit 05d1610
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ That's it! Your visitors can now load more posts by clicking the load more butto

## Changelog

### 1.0.3
* Fix - Loading more posts on "Inherit query from template"

### 1.0.2
* Add - SVN deployment workflow
* Update - Version and Stable tag
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "team51-plugin-qllm",
"version": "1.0.2",
"version": "1.0.3",
"description": "A qllm for WP.com Special Projects plugins",
"author": {
"name": "WordPress.com Special Projects Team",
Expand Down
6 changes: 4 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: wpspecialprojects, tommusrhodus
Tags: gutenberg, editor, block editor, load more, query loop
Requires at least: 6.2
Tested up to: 6.6.1
Stable tag: 1.0.2
Stable tag: 1.0.3
Requires PHP: 8.0
License: GPLv3 or later
License URI: https://www.gnu.org/licenses/gpl-3.0.html
Expand All @@ -29,11 +29,13 @@ Here is how to enable the load more option:

== Changelog ==

= 1.0.3 =
* Fix - Loading more posts on "Inherit query from template"

= 1.0.2 =
* Add - SVN deployment workflow
* Update - Version and Stable tag


= 1.0.1 =
* Fix - Unify GPL license
* Fix - Unify text domain and plugin slug
Expand Down
5 changes: 3 additions & 2 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ public function render( array $attributes, string $content, \WP_Block $block ):

// Get query context for current page number and query Id.
$page_key = isset( $block->context['queryId'] ) ? 'query-' . $block->context['queryId'] . '-page' : 'query-page';
$inherit = isset( $block->context['query']['inherit'] ) ? $block->context['query']['inherit'] : false;
$page = empty( $_GET[ $page_key ] ) ? 1 : (int) $_GET[ $page_key ]; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$block_query = new \WP_Query( build_query_vars_from_query_block( $block, $page ) );
$buttons = '';
Expand All @@ -221,9 +222,9 @@ public function render( array $attributes, string $content, \WP_Block $block ):
// Build list of load more links.
for ( $i = $page + 1; $i <= $block_query->max_num_pages; $i++ ) {
$buttons .= sprintf(
'<a class="%s" href="?%s=%d" data-loading-text="%s">%s</a>',
$inherit ? '<a class="%s" href="%s/page/%d/" data-loading-text="%s">%s</a>' : '<a class="%s" href="?%s=%d" data-loading-text="%s">%s</a>',
'wp-block-button__link wp-element-button wp-load-more__button',
esc_html( $page_key ),
$inherit ? '' : esc_html( $page_key ),
(int) $i,
esc_html( $attributes['loadingText'] ),
esc_html( $attributes['loadMoreText'] ) . $pagination_arrow
Expand Down

0 comments on commit 05d1610

Please sign in to comment.