Skip to content

nunopress/silex-wpapi-service-provider

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

This is a Service Provider for Silex and added the access to WordPress API websites easy.

Installation

You can simply install with composer:

composer require nunopress/silex-wpapi-service-provider

In your Silex application register the service provider:

$app->register(new NunoPress\Silex\WpApi\Provider\WpApiServiceProvider());

Configuration

You can configure this items inside the container:

wpapi.client

With default the service provider use GuzzleHttp client, but you can use what you want, you need to implement our NunoPress\Silex\WpApi\WpApiClientInterface.

wpapi.client.option

If you use our client you can pass GuzzleHttp options here, most useful for the base_uri instead to use all times the full uri or for the authentication.

Usage

This is our interface for get default WordPress API endpoint's and we added one method for call the Advanced Custom Fields API (you need a WordPress plugin ACF Rest API).

Example for get the first page from pages in order by menu_order and asc:

$wpapi->getItems('pages', 'menu_order', 'asc', 1)

If you want get the Advanced Custom Fields options page you can do it:

$wpapi->getAcf('options')

API

/**
 * @param string $type
 * @param string $orderBy
 * @param string $order
 * @param int $page
 *
 * @return array
*/
public function getItems($type = 'posts', $orderBy = 'menu_order', $order = 'desc', $page = 1)
/**
 * @param string $type
 * @param null|int $id
 *
 * @return array
 */
public function getAcf($type, $id = null)

About

WordPress API Service Provider for Silex

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages