PHPackages                             moxie-lean/wp-endpoints-post - 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. [API Development](/categories/api)
4. /
5. moxie-lean/wp-endpoints-post

AbandonedLibrary[API Development](/categories/api)

moxie-lean/wp-endpoints-post
============================

Generic but customisable post endpoint to expose post content via WP-API

1.0.2(10y ago)06671MITPHPPHP &gt;=5.4

Since Mar 14Pushed 10y ago3 watchersCompare

[ Source](https://github.com/wearenolte/wp-endpoints-post)[ Packagist](https://packagist.org/packages/moxie-lean/wp-endpoints-post)[ Docs](https://github.com/moxie-lean/wp-endpoints-post)[ RSS](/packages/moxie-lean-wp-endpoints-post/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (8)Dependencies (5)Versions (11)Used By (0)

WP Endpoints: View
==================

[](#wp-endpoints-view)

**This package is depreciated. LEAN now uses the WordPress REST API plugins instead**

> Generic but customisable view endpoint to expose our content via WP-API. This extension will create an endpoint (at `/wp-json/leean/v1/view` by default) which returns all the data required by a front-end app to render a view.

The endpoint takes a slug parameter (e.g. `/wp-json/leean/v1/view?slug=sample-page`) and returns the following data for a single post:

- Id
- Template
- Content
    - WordPress default fields: title, content
    - All ACF fields associated with the page, grouped by their ACF field groups.
- Meta Data: title, description, open graph (note this hasn't been implemented yet).

Note: currently it just works for single posts (including pages and cpt's). We need to consider the best solution for other types of views, such as archive pages.

Getting Started
---------------

[](#getting-started)

The easiest way to install this package is by using composer from your terminal:

```
composer require moxie-lean/wp-endpoints-view --save
```

Or by adding the following lines on your `composer.json` file

```
"require": {
  "moxie-lean/wp-endpoints-view": "dev-master"
}
```

This will download the files from the [packagist site](https://packagist.org/packages/moxie-lean/wp-endpoints-view)and set you up with the latest version located on master branch of the repository.

After that you can include the `autoload.php` file in order to be able to autoload the class during the object creation.

```
include '/vendor/autoload.php';
```

Finally you need to initialise the endpoint by adding this to your code:

```
\Lean\Endpoints\View::init();
```

Usage
-----

[](#usage)

The extension has a number of filters which can be used to customised the output. In addition it does some useful extra manipulation of ACF data to make it more useful to a front-end app.

### Filters

[](#filters)

Common parameters passed by many filers are:

- $endpoint : the name of the endpoint. Always '/view' for this extension.
- $post\_id : the id of the post.
- $field : the ACF [field object](http://www.advancedcustomfields.com/resources/get_field_object/).

#### ln\_endpoints\_api\_namespace

[](#ln_endpoints_api_namespace)

Customise the API namespace ('leean' in `/wp-json/leean/v1/view`)

```
add_filter( 'ln_endpoints_api_namespace', function( $namespace, $endpoint ) {
    return 'my-app';
}, 10, 2 );
```

#### ln\_endpoints\_api\_version

[](#ln_endpoints_api_version)

Customise the API version ('v1' in `/wp-json/leean/v1/view`)

```
add_filter( 'ln_endpoints_api_version', function( $version, $endpoint ) {
    return 'v2';
}, 10, 2 );
```

#### ln\_endpoints\_query\_args

[](#ln_endpoints_query_args)

Customise the query args before the post is queried using WP\_Query. $request is the WP\_REST\_Request object received by endpoint handler.

```
add_filter( 'ln_endpoints_{endpoint}_query_args', function( $query_args, $request ) {
    $query_args['post_type'] = 'page';
    return $query_args;
}, 10, 3 );
```

#### ln\_endpoints\_data

[](#ln_endpoints_data)

Customise the results just before they are sent.

```
add_filter( 'ln_endpoints_data_{endpoint}', function( $data, $post_id ) {
    $data['content']['title'] = '***' . $data['content']['title'] . '***';
    return $data;
}, 10, 3 );
```

On the previous two filters `{endpoint}` is the name of your endpoint in this case is `post`, so for example `ln_endpoints_data_post` is the name of the filter you should use to filter the data.

#### ln\_endpoints\_acf

[](#ln_endpoints_acf)

Customise the value of an ACF field.

```
add_filter( 'ln_endpoints_acf', function( $value, $endpoint, $post_id, $field ) {
    if ( 'image' === $field['type'] ) {
        return 'https://upload.wikimedia.org/wikipedia/commons/1/1b/Nice-night-view-with-blurred-cars_1200x900.jpg';
    }
    return $value;
}, 10, 4 );
```

#### ln\_endpoints\_acf\_image\_size

[](#ln_endpoints_acf_image_size)

Set the image size to use. Only activated for image fields whose return format is set to 'id'. Note that $sub\_field is only used for images within repeaters.

```
add_filter( 'ln_endpoints_acf_image_size', function( $size, $endpoint, $post_id, $field, $sub_field ) {
    if ( 'logo' === $field['name'] ) {
        return 'very_small';
    }
    return $size;
}, 10, 4 );
```

#### ln\_endpoints\_acf\_repeater\_as\_array

[](#ln_endpoints_acf_repeater_as_array)

Whether to return a repeater as an array. Only activated for repeater fields with exactly one value.

```
add_filter( 'ln_endpoints_acf_repeater_as_array', function( $as_array, $endpoint, $post_id, $field ) {
    $post = get_post( $post_id );
    return 'training' === $post->page_template && 'cta' === $field['name'] ? false : $as_array;
}, 10, 4 );
```

### ACF Manipulations

[](#acf-manipulations)

#### Posts

[](#posts)

Activated when the ACF field type is 'Post Object' and the return format is 'id'. Gets all the content for the post (including its ACF fields). If the 'select multiple values' option is set, then it returns an array of post data.

#### Images

[](#images)

Activated when the ACF field type is 'Image' and the return format is 'id'. The image size must be set using the `ln_endpoints_acf_image_size` filter. Returns the image url, width, height and alt.

#### Repeaters

[](#repeaters)

Activated when the ACF field type is 'Repeater' and there is exactly one item. It passes a filter, `ln_endpoints_acf_repeater_as_array` which returns an object instead of an array if false.

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 95% 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.

###  Release Activity

Cadence

Every ~9 days

Total

8

Last Release

3683d ago

Major Versions

0.1.4 → 1.0.02016-04-25

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3921289?v=4)[Crisoforo Gaspar Hernández](/maintainers/mitogh)[@mitogh](https://github.com/mitogh)

![](https://www.gravatar.com/avatar/4aa05a59deaf5695b3a80e42e2c6b971ab92c171ad13cd7b95ca8175382cda60?d=identicon)[WeAreNolte](/maintainers/WeAreNolte)

---

Top Contributors

[![mitogh](https://avatars.githubusercontent.com/u/3921289?v=4)](https://github.com/mitogh "mitogh (38 commits)")[![zzuga](https://avatars.githubusercontent.com/u/13990408?v=4)](https://github.com/zzuga "zzuga (2 commits)")

---

Tags

apiwordpress

###  Code Quality

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/moxie-lean-wp-endpoints-post/health.svg)

```
[![Health](https://phpackages.com/badges/moxie-lean-wp-endpoints-post/health.svg)](https://phpackages.com/packages/moxie-lean-wp-endpoints-post)
```

###  Alternatives

[wp-graphql/wp-graphql-woocommerce

WooCommerce bindings for WPGraphQL

70055.0k](/packages/wp-graphql-wp-graphql-woocommerce)[wordpress/wp-ai-client

An AI client and API for WordPress to communicate with any generative AI models of various capabilities using a uniform API.

12521.8k3](/packages/wordpress-wp-ai-client)[rickwest/laravel-wordpress-api

A Laravel read-only client for the WordPress REST API (v2)

3714.3k1](/packages/rickwest-laravel-wordpress-api)

PHPackages © 2026

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