PHPackages                             shelob9/jp-rest-access - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. shelob9/jp-rest-access

ActiveLibrary

shelob9/jp-rest-access
======================

Sets CORS headers, and allows offest in posts route, with max post per page for WordPress REST API (WP-API).

311PHP

Since Nov 7Pushed 11y ago1 watchersCompare

[ Source](https://github.com/Shelob9/jp-rest-access)[ Packagist](https://packagist.org/packages/shelob9/jp-rest-access)[ RSS](/packages/shelob9-jp-rest-access/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

JP REST Access
==============

[](#jp-rest-access)

Adds common access and security filters for the WordPress REST API (WP REST).

It does the following:

1. Sets a cross-domain CORS header for the API to prevent cross-domain errors when accessing from a diffrent domain. By default it allows all domains ("\*"). You can set another domain or any array of domains with the "jp\_rest\_access\_cors" filter.
2. Allows for requests to the posts route to use the offset filter, without pagination.
3. Sets a maximum amount of posts that can be requested at once from the posts endpoint. By default the max is 20, that value can be changed with the "jp\_rest\_access\_max\_posts\_per\_page" filter. Prevents someone from trying to DDOS a site with a lot of posts by requesting a ton of posts\_per\_page.

### Installation

[](#installation)

This is not a plugin. It's a composer library. Add `"shelob9/jp-rest-access": "dev-master"` to your site/plugin/theme's composer.json.

### Controlling Cross-Orgin Domain (CORS) Headers

[](#controlling-cross-orgin-domain-cors-headers)

- Allow from any domain This it the dfault behaviour
- Allow from one domain

```
add_filter( 'jp_rest_access_cors', function( $domains ) {
	return 'http://somedomain.com';
});
```

- Allow from two domains

```
add_filter( 'jp_rest_access_cors', function( $domains ) {
	return array( 'http://somedomain.com', 'http://another_url.com' );
});
```

### Limiting the Max Number of Posts Per Request

[](#limiting-the-max-number-of-posts-per-request)

```
add_filter( 'jp_rest_access_max_posts_per_page', function( $max_posts ) {
  return 5;
}```

### License
Copyright 2014 Josh Pollock. Licensed under the terms of the GNU General public license version 2. Please share with your neighbor.
```

###  Health Score

21

—

LowBetter than 19% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/ca938daf3f2a666cd32c7bdb6e30714da6fe0e6cd5012fe4864b18afae43fbcd?d=identicon)[Shelob9](/maintainers/Shelob9)

---

Top Contributors

[![Shelob9](https://avatars.githubusercontent.com/u/1994311?v=4)](https://github.com/Shelob9 "Shelob9 (9 commits)")

### Embed Badge

![Health badge](/badges/shelob9-jp-rest-access/health.svg)

```
[![Health](https://phpackages.com/badges/shelob9-jp-rest-access/health.svg)](https://phpackages.com/packages/shelob9-jp-rest-access)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
