Download the PHP package gebruederheitz/wp-async-posts-provider without Composer

On this page you can find all versions of the php package gebruederheitz/wp-async-posts-provider. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package wp-async-posts-provider

Wordpress Async Posts Provider

Helps you get your posts asynchronously to the frontend in your plugin or theme

Provides a simple interface ideal for custom pagination especially on hybrid setups using both synchronous server-side rendering and asynchronous AJAX-powered loading of posts from a frontend script or framework using WP's own REST API.

Installation

via composer:

Usage

Using the container with default settings

Initialize the container (usually in your functions.php):

Make sure you have Composer autoload or an alternative class loader present.

You may pass any options provided by ContainerSettings as class properties in a string-keyed array to the container to modify defaults (see below):

Instantiating the container will register all the relevant Wordpress hooks and set up the REST route for use with your frontend scripts / framework.

Available options

The following options can be set by passing the container an array with the following keys:

option key default value description
initialPostCount (int) 8 The number of posts rendered server-side (on page 0).
perPage (int) 6 The number of posts per page after page 0.
postFilterClass (string) PostFilter::class The classes used for the various functionalities. This is where...
asyncPostsClass (string) AsyncPosts::class ...you can provide your own classes implementing the...
validatorClass (string) Validator::class ...respective interfaces to extend...
rendererClass (string) PostRenderer::class ...or modify functionality.
rendererTemplatePath (string) 'template-parts/content/content-excerpt' The template path passed to get_template_part by the renderer.
defaultPartial (string) 'small' The default template name passed as the second parameter to get_template_part by the renderer. This can be overwritten by the partial request parameter.
route (string) '/posts/load-more' The route used for retrieving paginated posts asynchronously. This will be prefixed with /ghwapp/v1 and the basic WP REST path (usually /wp/json).

Basic usage

Hybrid setup: Rendering "page zero"

If you want to deliver rendered HTML with the first couple of posts to the user, you can use the PostFilter to automatically limit the number of posts initially returned by the main query on the front page (currently is_home(), will be customizable soon).
Set the number of posts you want to be loaded initially by passing the initialPostCount option. Setting this value to 0 will disable the pre-filtering, and you will receive the default number of items on the main query (which can be set through the Wordpress settings).

To determine whether or not there are any posts left to be loaded asynchronously you can use the PostFilter's shouldShowLoadMoreButton() method:

Usage on the front end

todo

Extending or modifying components

Injecting services

todo

Custom filtering using PostFilter

todo

Development

todo


All versions of wp-async-posts-provider with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3
php-di/php-di Version ^6.3
gebruederheitz/simple-singleton Version ^1.0
gebruederheitz/wp-simple-rest Version ^2.1
phpstan/phpstan Version ^1.7
szepeviktor/phpstan-wordpress Version ^1.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package gebruederheitz/wp-async-posts-provider contains the following files

Loading the files please wait ....