-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
157 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/*! | ||
* Vue.js v2.6.10 | ||
* (c) 2014-2019 Evan You | ||
* Released under the MIT License. | ||
*/ | ||
|
||
/*! | ||
* vue-router v3.1.3 | ||
* (c) 2019 Evan You | ||
* @license MIT | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "tareq1988/vue-wp-starter", | ||
"description": "A WordPress Vue.js starter plugin", | ||
"type": "wordpress-plugin", | ||
"license": "GPL-2.0-or-later", | ||
"authors": [ | ||
{ | ||
"name": "Tareq Hasan", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"minimum-stability": "dev", | ||
"require": {}, | ||
"autoload": { | ||
"psr-4": { | ||
"App\\": "includes/" | ||
} | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
namespace App; | ||
|
||
use WP_REST_Controller; | ||
|
||
/** | ||
* REST_API Handler | ||
*/ | ||
class Api extends WP_REST_Controller { | ||
|
||
/** | ||
* [__construct description] | ||
*/ | ||
public function __construct() { | ||
$this->includes(); | ||
|
||
add_action( 'rest_api_init', [ $this, 'register_routes' ] ); | ||
} | ||
|
||
/** | ||
* Include the controller classes | ||
* | ||
* @return void | ||
*/ | ||
private function includes() { | ||
if ( !class_exists( __NAMESPACE__ . '\Api\Example' ) ) { | ||
require_once __DIR__ . '/Api/Example.php'; | ||
} | ||
} | ||
|
||
/** | ||
* Register the API routes | ||
* | ||
* @return void | ||
*/ | ||
public function register_routes() { | ||
(new Api\Example())->register_routes(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
namespace App\Api; | ||
|
||
use WP_REST_Controller; | ||
|
||
/** | ||
* REST_API Handler | ||
*/ | ||
class Example extends WP_REST_Controller { | ||
|
||
/** | ||
* [__construct description] | ||
*/ | ||
public function __construct() { | ||
$this->namespace = 'myapp/v1'; | ||
$this->rest_base = 'test'; | ||
} | ||
|
||
/** | ||
* Register the routes | ||
* | ||
* @return void | ||
*/ | ||
public function register_routes() { | ||
register_rest_route( | ||
$this->namespace, | ||
'/' . $this->rest_base, | ||
array( | ||
array( | ||
'methods' => \WP_REST_Server::READABLE, | ||
'callback' => array( $this, 'get_items' ), | ||
'permission_callback' => array( $this, 'get_items_permissions_check' ), | ||
'args' => $this->get_collection_params(), | ||
) | ||
) | ||
); | ||
} | ||
|
||
/** | ||
* Retrieves a collection of items. | ||
* | ||
* @param WP_REST_Request $request Full details about the request. | ||
* | ||
* @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. | ||
*/ | ||
public function get_items( $request ) { | ||
$items = [ | ||
'foo' => 'bar' | ||
]; | ||
|
||
$response = rest_ensure_response( $items ); | ||
|
||
return $response; | ||
} | ||
|
||
/** | ||
* Checks if a given request has access to read the items. | ||
* | ||
* @param WP_REST_Request $request Full details about the request. | ||
* | ||
* @return true|WP_Error True if the request has read access, WP_Error object otherwise. | ||
*/ | ||
public function get_items_permissions_check( $request ) { | ||
return true; | ||
} | ||
|
||
/** | ||
* Retrieves the query params for the items collection. | ||
* | ||
* @return array Collection parameters. | ||
*/ | ||
public function get_collection_params() { | ||
return []; | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters