Skip to content

Commit 6883ff9

Browse files
author
Ben Speakman
committed
Update for Laravel 5
1 parent f9d9c4a commit 6883ff9

File tree

4 files changed

+30
-6
lines changed

4 files changed

+30
-6
lines changed

README.md

100644100755
Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# laravel-wp-api
2-
Laravel package for the [Wordpress JSON REST API](https://github.com/WP-API/WP-API)
2+
Laravel 5 package for the [Wordpress JSON REST API](https://github.com/WP-API/WP-API)
33

44
## Install
55

@@ -11,9 +11,9 @@ Simply add the following line to your `composer.json` and run install/update:
1111

1212
Publish the package config files to configure the location of your Wordpress install:
1313

14-
php artisan config:publish cyberduck/laravel-wp-api
14+
php artisan vendor:publish
1515

16-
You will also need to add the service provider and the facade alias to your `app/config/app.php`:
16+
You will also need to add the service provider and optionally the facade alias to your `app/config/app.php`:
1717

1818
```php
1919
'providers' => array(
@@ -36,6 +36,12 @@ WpApi::posts($page);
3636

3737
```
3838

39+
#### Pages
40+
```php
41+
WpApi::pages($page);
42+
43+
```
44+
3945
#### Post
4046
```php
4147
WpApi::post($slug);
@@ -48,6 +54,12 @@ WpApi::categories();
4854

4955
```
5056

57+
#### Tags
58+
```php
59+
WpApi::tags();
60+
61+
```
62+
5163
#### Category posts
5264
```php
5365
WpApi::category_posts($slug, $page);

composer.json

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
],
1212
"require": {
1313
"php": ">=5.4.0",
14-
"illuminate/support": "4.2.*|~5.0",
14+
"illuminate/support": "~5.0",
1515
"guzzlehttp/guzzle": "~4.0"
1616
},
1717
"autoload": {

src/Cyberduck/LaravelWpApi/LaravelWpApiServiceProvider.php

100644100755
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ class LaravelWpApiServiceProvider extends ServiceProvider {
1919
*/
2020
public function boot()
2121
{
22-
$this->package('cyberduck/laravel-wp-api');
22+
$this->publishes([
23+
__DIR__.'/../../config/config.php' => config_path('/packages/cyberduck/laravel-wp-api/laravel-wp-api.php'),
24+
]);
2325
}
2426

2527
/**
@@ -31,7 +33,7 @@ public function register()
3133
{
3234
$this->app->bindShared('wp-api', function ($app) {
3335

34-
$endpoint = $this->app['config']->get('laravel-wp-api::endpoint');
36+
$endpoint = $this->app['config']->get('laravel-wp-api.endpoint');
3537
$client = new Client();
3638

3739
return new WpApi($endpoint, $client);

src/Cyberduck/LaravelWpApi/WpApi.php

100644100755
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ public function posts($page = null)
1818
return $this->_get('posts', ['page' => $page]);
1919
}
2020

21+
public function pages($page = null)
22+
{
23+
return $this->_get('posts', ['type' => 'page', 'page' => $page]);
24+
}
25+
2126
public function post($slug)
2227
{
2328
return $this->_get('posts', ['filter' => ['name' => $slug]]);
@@ -28,6 +33,11 @@ public function categories()
2833
return $this->_get('taxonomies/category/terms');
2934
}
3035

36+
public function tags()
37+
{
38+
return $this->_get('taxonomies/post_tag/terms');
39+
}
40+
3141
public function category_posts($slug, $page = null)
3242
{
3343
return $this->_get('posts', ['page' => $page, 'filter' => ['category_name' => $slug]]);

0 commit comments

Comments
 (0)