diff --git a/README.md b/README.md old mode 100644 new mode 100755 index 0684c09..a2c9229 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # laravel-wp-api -Laravel package for the [Wordpress JSON REST API](https://github.com/WP-API/WP-API) +Laravel 5 package for the [Wordpress JSON REST API](https://github.com/WP-API/WP-API) ## Install @@ -11,9 +11,9 @@ Simply add the following line to your `composer.json` and run install/update: Publish the package config files to configure the location of your Wordpress install: - php artisan config:publish cyberduck/laravel-wp-api + php artisan vendor:publish -You will also need to add the service provider and the facade alias to your `app/config/app.php`: +You will also need to add the service provider and optionally the facade alias to your `app/config/app.php`: ```php 'providers' => array( @@ -36,6 +36,12 @@ WpApi::posts($page); ``` +#### Pages +```php +WpApi::pages($page); + +``` + #### Post ```php WpApi::post($slug); @@ -48,6 +54,12 @@ WpApi::categories(); ``` +#### Tags +```php +WpApi::tags(); + +``` + #### Category posts ```php WpApi::category_posts($slug, $page); diff --git a/composer.json b/composer.json old mode 100644 new mode 100755 index 49bf855..7c12ea9 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ ], "require": { "php": ">=5.4.0", - "illuminate/support": "4.2.*|~5.0", + "illuminate/support": "~5.0", "guzzlehttp/guzzle": "~4.0" }, "autoload": { diff --git a/src/Cyberduck/LaravelWpApi/LaravelWpApiServiceProvider.php b/src/Cyberduck/LaravelWpApi/LaravelWpApiServiceProvider.php old mode 100644 new mode 100755 index 40ab7ed..f59b8d0 --- a/src/Cyberduck/LaravelWpApi/LaravelWpApiServiceProvider.php +++ b/src/Cyberduck/LaravelWpApi/LaravelWpApiServiceProvider.php @@ -19,7 +19,9 @@ class LaravelWpApiServiceProvider extends ServiceProvider { */ public function boot() { - $this->package('cyberduck/laravel-wp-api'); + $this->publishes([ + __DIR__.'/../../config/config.php' => config_path('/packages/cyberduck/laravel-wp-api/laravel-wp-api.php'), + ]); } /** @@ -31,7 +33,7 @@ class LaravelWpApiServiceProvider extends ServiceProvider { { $this->app->bindShared('wp-api', function ($app) { - $endpoint = $this->app['config']->get('laravel-wp-api::endpoint'); + $endpoint = $this->app['config']->get('laravel-wp-api.endpoint'); $client = new Client(); return new WpApi($endpoint, $client); diff --git a/src/Cyberduck/LaravelWpApi/WpApi.php b/src/Cyberduck/LaravelWpApi/WpApi.php old mode 100644 new mode 100755 index 6cd4d45..7ff959a --- a/src/Cyberduck/LaravelWpApi/WpApi.php +++ b/src/Cyberduck/LaravelWpApi/WpApi.php @@ -18,6 +18,11 @@ class WpApi return $this->_get('posts', ['page' => $page]); } + public function pages($page = null) + { + return $this->_get('posts', ['type' => 'page', 'page' => $page]); + } + public function post($slug) { return $this->_get('posts', ['filter' => ['name' => $slug]]); @@ -28,6 +33,11 @@ class WpApi return $this->_get('taxonomies/category/terms'); } + public function tags() + { + return $this->_get('taxonomies/post_tag/terms'); + } + public function category_posts($slug, $page = null) { return $this->_get('posts', ['page' => $page, 'filter' => ['category_name' => $slug]]);