=== Module Pager ===
Contributors: yamadev
Tags: pagination, pager, navigation, custom, mustache
Requires at least: 5.8
Tested up to: 7.0
Stable tag: 1.7.0
Requires PHP: 7.2
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Create customizable pagination by editing HTML templates in the WordPress admin screen.

== Description ==

Module Pager displays pagination that can be adapted to your site's design.

The Pagination Settings screen lets you edit separate HTML templates for the complete pager, previous link, next link, and page numbers.

= Features =

* Edit pagination HTML from the WordPress admin screen.
* Start with default templates that work immediately after activation.
* Configure the previous and next links separately.
* Use Mustache syntax to render page numbers and conditional states.
* Restrict the HTML elements and attributes that can be saved.
* Render pagination with a shortcode or from a theme's PHP template.

= Shortcode =

Add the shortcode where the main query's pagination should appear.

    [wp-module-pager]

Use `base_path` to specify the base path for pagination URLs.

    [wp-module-pager base_path="news"]

Use `post_type` when the post type needs to be specified explicitly.

    [wp-module-pager post_type="news" base_path="news"]

= PHP API =

The following example renders pagination for the current main query from a theme template.

    <?php
    $pager = new Wp_Module_Pager();
    $pager->render();

A custom `WP_Query` object, post type, and base path can also be passed to `render()`.

    <?php
    $pager = new Wp_Module_Pager();
    $pager->render( $custom_query, 'news', 'news' );

No pagination is rendered when the query has only one page.

== Installation ==

1. Open Plugins > Add New Plugin in the WordPress admin screen.
2. Search for "Module Pager" and install it.
3. Activate the plugin.
4. Review the default templates under Pagination Settings.
5. Add the shortcode or PHP call where pagination should appear.

To install a ZIP file, use Upload Plugin on the Add Plugins screen.

== Frequently Asked Questions ==

= Why is the pagination not displayed? =

Confirm that the target query contains enough posts to produce multiple pages.

The plugin does not output pagination for a single-page query.

= Can the templates be restored to their defaults? =

Select "Reset to defaults" on the Pagination Settings screen, and then save the settings.

= Can I use a custom WP_Query? =

Pass the `WP_Query` object as the first argument of the PHP API's `render()` method.

The shortcode uses the WordPress main query.

== Changelog ==

= 1.7.0 =

* Updated Mustache to version 3.
* Added test environments for WordPress 7.0 and PHP 8.5.
* Added automated tests for PHP 7.4 and PHP 8.5.
* Fixed the shortcode to return its rendered HTML correctly.
* Improved handling when the query string is unavailable or posts per page is zero.
* Fixed line break preservation and default restoration on the Pagination Settings screen.
* Registered default templates during plugin activation and added safe fallbacks for missing settings.
* Improved JavaScript escaping for templates displayed in the admin screen.
* Improved input validation and output escaping for Plugin Check compatibility.

== Upgrade Notice ==

= 1.7.0 =

This release updates Mustache to version 3 and fixes pagination rendering and settings restoration.
