-
Notifications
You must be signed in to change notification settings - Fork 123
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
Roy Sivan
authored and
Roy Sivan
committed
Apr 16, 2015
1 parent
d2b02df
commit 6b44e8a
Showing
7 changed files
with
80 additions
and
51 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
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,39 @@ | ||
<?php | ||
global $myplugin_api_mytype; | ||
|
||
class angular_theme_routes { | ||
|
||
function __construct() { | ||
$this->init(); | ||
} | ||
|
||
function init() { | ||
global $myplugin_api_mytype; | ||
add_filter( 'json_endpoints', array( $this, 'register_routes' ) ); | ||
} | ||
|
||
function register_routes( $routes ) { | ||
$routes['/post_by_slug'] = array( | ||
array( array( $this, 'get_post_by_slug'), WP_JSON_Server::READABLE ), | ||
); | ||
|
||
// Add more custom routes here | ||
|
||
return $routes; | ||
} | ||
|
||
function get_post_by_slug() { | ||
|
||
$slug = $_GET['slug']; | ||
$return['slug'] = $slug; | ||
|
||
$return['post'] = get_page_by_path( $slug, ARRAY_A, 'post' ); | ||
|
||
$response = new WP_JSON_Response(); | ||
$response->set_data( $return ); | ||
return $response; | ||
|
||
} | ||
} | ||
|
||
new angular_theme_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
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
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
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
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