<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[2348] 2013/rmccue/trunk: Add generic CPT class</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://gsoc.trac.wordpress.org/changeset/2348">2348</a></dd>
<dt>Author</dt> <dd>rmccue</dd>
<dt>Date</dt> <dd>2013-09-21 10:37:30 +0000 (Sat, 21 Sep 2013)</dd>
</dl>
<h3>Log Message</h3>
<pre>Add generic CPT class
Better fix for <a href="http://gsoc.trac.wordpress.org/ticket/380">#380</a> for generic post types and plugins.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#2013rmccuetrunkdocsguidesextendingmd">2013/rmccue/trunk/docs/guides/extending.md</a></li>
<li><a href="#2013rmccuetrunklibclasswpjsonpagesphp">2013/rmccue/trunk/lib/class-wp-json-pages.php</a></li>
<li><a href="#2013rmccuetrunkpluginphp">2013/rmccue/trunk/plugin.php</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#2013rmccuetrunklibclasswpjsoncustomposttypephp">2013/rmccue/trunk/lib/class-wp-json-customposttype.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="2013rmccuetrunkdocsguidesextendingmd"></a>
<div class="modfile"><h4>Modified: 2013/rmccue/trunk/docs/guides/extending.md (2347 => 2348)</h4>
<pre class="diff"><span>
<span class="info">--- 2013/rmccue/trunk/docs/guides/extending.md 2013-09-21 09:31:22 UTC (rev 2347)
+++ 2013/rmccue/trunk/docs/guides/extending.md 2013-09-21 10:37:30 UTC (rev 2348)
</span><span class="lines">@@ -124,9 +124,10 @@
</span><span class="cx">
</span><span class="cx"> The recommended way to organize your endpoints is to group related endpoints
</span><span class="cx"> together into a class, and extend the base classes built into the API.
</span><del>-Post-related endpoints should look to extend the `WP_JSON_Posts` class, and use
-the same method naming as it, falling back to it for the post preparation and
-request handling.
</del><ins>+Post-related endpoints should look to extend the `WP_JSON_CustomPostType` class,
+and use the same method naming as it, falling back to it for the post
+preparation and request handling. This will automatically register all the post
+methods for their endpoints.
</ins><span class="cx">
</span><span class="cx"> Along these lines, keep your methods named as generically as possible; while
</span><span class="cx"> `MyPlugin_API_MyType::getMyTypeItems()` might seem like a good name, it makes it
</span><span class="lines">@@ -248,12 +249,47 @@
</span><span class="cx"> array( array( $this, 'deletePost'), WP_JSON_Server::DELETABLE ),
</span><span class="cx"> );
</span><span class="cx">
</span><ins>+ // Add more custom routes here
+
</ins><span class="cx"> return $routes;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // ...
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+Alternatively, use the custom post type base class, which will handle the
+hooking and more for you:
+
+ // main.php
+ function myplugin_api_init() {
+ global $myplugin_api_mytype;
+
+ require_once dirname( __FILE__ ) . '/class-myplugin-api-mytype.php';
+ $myplugin_api_mytype = new MyPlugin_API_MyType();
+ }
+ add_action( 'plugins_loaded', 'myplugin_api_init' );
+
+ // class-myplugin-api-mytype.php
+ class MyPlugin_API_MyType extends WP_JSON_CustomPostType {
+ protected $base = '/myplugin/mytypeitems';
+ protected $type = 'myplugin-mytype';
+
+ public function registerRoutes( $routes ) {
+ $routes = parent::registerRoutes( $routes );
+ // $routes = parent::registerRevisionRoutes( $routes );
+ // $routes = parent::registerCommentRoutes( $routes );
+
+ // Add more custom routes here
+
+ return $routes;
+ }
+
+ // ...
+ }
+
+(Note that this CPT base class handles other things as well, including strict
+post type checking and correcting URLs.)
+
</ins><span class="cx"> The data passed in and returned by the `json_endpoints` filter should be in the
</span><span class="cx"> format of an array containing a map of route regular expression to endpoint
</span><span class="cx"> lists. An endpoint list is a potentially unlimited array of endpoints' data.
</span></span></pre></div>
<a id="2013rmccuetrunklibclasswpjsoncustomposttypephp"></a>
<div class="addfile"><h4>Added: 2013/rmccue/trunk/lib/class-wp-json-customposttype.php (0 => 2348)</h4>
<pre class="diff"><span>
<span class="info">--- 2013/rmccue/trunk/lib/class-wp-json-customposttype.php (rev 0)
+++ 2013/rmccue/trunk/lib/class-wp-json-customposttype.php 2013-09-21 10:37:30 UTC (rev 2348)
</span><span class="lines">@@ -0,0 +1,213 @@
</span><ins>+<?php
+/**
+ * Custom Post Type base class
+ *
+ * A sensible base for custom post type APIs
+ */
+
+/**
+ * Custom Post Type base class
+ *
+ * A sensible base for custom post type APIs
+ */
+abstract class WP_JSON_CustomPostType extends WP_JSON_Posts {
+ /**
+ * Base route name
+ *
+ * @var string Route base (e.g. /my-plugin/my-type)
+ */
+ protected $base = null;
+
+ /**
+ * Associated post type
+ *
+ * @var string Type slug
+ */
+ protected $type = null;
+
+ /**
+ * Construct the API handler object
+ */
+ public function __construct() {
+ if ( empty( $this->base ) ) {
+ _doing_it_wrong( 'WP_JSON_CustomPostType::__construct', __( 'The route base must be overridden' ), 'WPAPI-0.6' );
+ return;
+ }
+ if ( empty( $this->type ) ) {
+ _doing_it_wrong( 'WP_JSON_CustomPostType::__construct', __( 'The post type must be overridden' ), 'WPAPI-0.6' );
+ return;
+ }
+
+ add_filter( 'json_endpoints', array( $this, 'registerRoutes' ) );
+ add_filter( 'json_post_type_data', array( $this, 'type_archive_link' ), 10, 2 );
+ }
+
+ /**
+ * Register the routes for the post type
+ *
+ * @param array $routes Routes for the post type
+ * @return array Modified routes
+ */
+ public function registerRoutes( $routes ) {
+ $routes[ $this->base ] = array(
+ array( array( $this, 'getPosts' ), WP_JSON_Server::READABLE ),
+ array( array( $this, 'newPost' ), WP_JSON_Server::CREATABLE ),
+ );
+
+ $routes[ $this->base . '/(?P<id>\d+)' ] = array(
+ array( array( $this, 'getPost' ), WP_JSON_Server::READABLE ),
+ array( array( $this, 'editPost' ), WP_JSON_Server::EDITABLE ),
+ array( array( $this, 'deletePost' ), WP_JSON_Server::DELETABLE ),
+ );
+ return $routes;
+ }
+
+ /**
+ * Register revision-related routes for the post type
+ *
+ * @param array $routes Routes for the post type
+ * @return array Modified routes
+ */
+ public function registerRevisionRoutes( $routes ) {
+ $routes[ '/pages/(?P<id>\d+)/revisions' ] = array(
+ array( '__return_null', WP_JSON_Server::READABLE ),
+ );
+ return $routes;
+ }
+
+ /**
+ * Register comment-related routes for the post type
+ *
+ * @param array $routes Routes for the post type
+ * @return array Modified routes
+ */
+ public function registerCommentRoutes( $routes ) {
+ $routes[ $this->base . '/(?P<id>\d+)/comments'] = array(
+ array( array( $this, 'getComments' ), WP_JSON_Server::READABLE ),
+ array( '__return_null', WP_JSON_Server::CREATABLE | WP_JSON_Server::ACCEPT_JSON ),
+ );
+ $routes[ $this->base . '/(?P<id>\d+)/comments/(?P<comment>\d+)' ] = array(
+ array( array( $this, 'getComment' ), WP_JSON_Server::READABLE ),
+ array( '__return_null', WP_JSON_Server::EDITABLE | WP_JSON_Server::ACCEPT_JSON ),
+ array( '__return_null', WP_JSON_Server::DELETABLE ),
+ );
+ return $routes;
+ }
+
+ /**
+ * Retrieve posts
+ *
+ * Overrides the $type to set to $this->type, then passes through to the
+ * post endpoints.
+ *
+ * @see WP_JSON_Posts::getPosts()
+ */
+ public function getPosts( $filter = array(), $context = 'view', $type = null, $page = 1 ) {
+ if ( !empty( $type ) && $type !== $this->type )
+ return new WP_Error( 'json_post_invalid_type', __( 'Invalid post type' ), array( 'status' => 400 ) );
+
+ return parent::getPosts( $filter, $context, $this->type, $page );
+ }
+
+ /**
+ * Retrieve a post
+ *
+ * @see WP_JSON_Posts::getPost()
+ */
+ public function getPost( $id, $context = 'view' ) {
+ $id = (int) $id;
+
+ if ( empty( $id ) )
+ return new WP_Error( 'json_post_invalid_id', __( 'Invalid post ID.' ), array( 'status' => 404 ) );
+
+ $post = get_post( $id, ARRAY_A );
+
+ if ( $post['post_type'] !== $this->type )
+ return new WP_Error( 'json_post_invalid_type', __( 'Invalid post type' ), array( 'status' => 400 ) );
+
+ return parent::getPost( $id, $context );
+ }
+
+ /**
+ * Edit a post
+ *
+ * @see WP_JSON_Posts::editPost()
+ */
+ function editPost( $id, $data, $_headers = array() ) {
+ $id = (int) $id;
+ if ( empty( $id ) )
+ return new WP_Error( 'json_post_invalid_id', __( 'Invalid post ID.' ), array( 'status' => 404 ) );
+
+ $post = get_post( $id, ARRAY_A );
+
+ if ( empty( $post['ID'] ) )
+ return new WP_Error( 'json_post_invalid_id', __( 'Invalid post ID.' ), array( 'status' => 404 ) );
+
+ if ( $post['post_type'] !== $this->type )
+ return new WP_Error( 'json_post_invalid_type', __( 'Invalid post type' ), array( 'status' => 400 ) );
+
+ return parent::editPost( $id, $data, $_headers );
+ }
+
+ /**
+ * Delete a post
+ *
+ * @see WP_JSON_Posts::deletePost()
+ */
+ public function deletePost( $id, $force = false ) {
+ $id = (int) $id;
+
+ if ( empty( $id ) )
+ return new WP_Error( 'json_post_invalid_id', __( 'Invalid post ID.' ), array( 'status' => 404 ) );
+
+ $post = get_post( $id, ARRAY_A );
+
+ if ( $post['post_type'] !== $this->type )
+ return new WP_Error( 'json_post_invalid_type', __( 'Invalid post type' ), array( 'status' => 400 ) );
+
+ return parent::deletePost( $id, $force );
+ }
+
+ /**
+ * Prepare post data
+ *
+ * @param array $post The unprepared post data
+ * @param array $fields The subset of post type fields to return
+ * @return array The prepared post data
+ */
+ protected function prepare_post( $post, $context = 'view' ) {
+ $_post = parent::prepare_post( $post, $context );
+
+ // Override entity meta keys with the correct links
+ $_post['meta'] = array(
+ 'links' => array(
+ 'self' => json_url( $this->base . '/' . $post['ID'] ),
+ 'author' => json_url( '/users/' . $post['post_author'] ),
+ 'collection' => json_url( '/pages' ),
+ 'replies' => json_url( $this->base . '/' . $post['ID'] . '/comments' ),
+ 'version-history' => json_url( $this->base . '/' . $post['ID'] . '/revisions' ),
+ ),
+ );
+
+ if ( ! empty( $post['post_parent'] ) )
+ $_post['meta']['links']['up'] = json_url( $this->base . '/' . $post['ID'] );
+
+ return apply_filters( 'json_prepare_{$this->type}', $_post, $post, $context );
+ }
+
+ /**
+ * Filter the post type archive link
+ *
+ * @param array $data Post type data
+ * @param stdClass $type Internal post type data
+ * @return array Filtered data
+ */
+ public function type_archive_link( $data, $type ) {
+ if ( $type->name !== $this->type ) {
+ return $data;
+ }
+
+ $data['meta']['links']['archives'] = json_url( $this->base );
+ return $data;
+ }
+}
</ins><span class="cx">\ No newline at end of file
</span><span class="cx">Property changes on: 2013/rmccue/trunk/lib/class-wp-json-customposttype.php
</span><span class="cx">___________________________________________________________________
</span></span></pre></div>
<a id="svnexecutable"></a>
<div class="addfile"><h4>Added: svn:executable</h4></div>
<ins>+*
</ins><span class="cx">\ No newline at end of property
</span><a id="2013rmccuetrunklibclasswpjsonpagesphp"></a>
<div class="modfile"><h4>Modified: 2013/rmccue/trunk/lib/class-wp-json-pages.php (2347 => 2348)</h4>
<pre class="diff"><span>
<span class="info">--- 2013/rmccue/trunk/lib/class-wp-json-pages.php 2013-09-21 09:31:22 UTC (rev 2347)
+++ 2013/rmccue/trunk/lib/class-wp-json-pages.php 2013-09-21 10:37:30 UTC (rev 2348)
</span><span class="lines">@@ -18,123 +18,43 @@
</span><span class="cx"> * @package WordPress
</span><span class="cx"> * @subpackage JSON API
</span><span class="cx"> */
</span><del>-class WP_JSON_Pages extends WP_JSON_Posts {
</del><ins>+class WP_JSON_Pages extends WP_JSON_CustomPostType {
</ins><span class="cx"> /**
</span><del>- * Register the page-related routes
</del><ins>+ * Base route
</ins><span class="cx"> *
</span><del>- * @param array $routes Existing routes
- * @return array Modified routes
</del><ins>+ * @var string
</ins><span class="cx"> */
</span><del>- public function registerRoutes( $routes ) {
- $page_routes = array(
- // Page endpoints
- '/pages' => array(
- array( array( $this, 'getPosts' ), WP_JSON_Server::READABLE ),
- array( array( $this, 'newPost' ), WP_JSON_Server::CREATABLE | WP_JSON_Server::ACCEPT_JSON ),
- ),
</del><ins>+ protected $base = '/pages';
</ins><span class="cx">
</span><del>- '/pages/(?P<id>\d+)' => array(
- array( array( $this, 'getPost' ), WP_JSON_Server::READABLE ),
- array( array( $this, 'editPost' ), WP_JSON_Server::EDITABLE | WP_JSON_Server::ACCEPT_JSON ),
- array( array( $this, 'deletePost' ), WP_JSON_Server::DELETABLE ),
- ),
- '/pages/(?P<path>.+)' => array(
- array( array( $this, 'getPostByPath' ), WP_JSON_Server::READABLE ),
- array( array( $this, 'editPostByPath' ), WP_JSON_Server::EDITABLE | WP_JSON_Server::ACCEPT_JSON ),
- array( array( $this, 'deletePostByPath' ), WP_JSON_Server::DELETABLE ),
- ),
-
- '/pages/(?P<id>\d+)/revisions' => array( '__return_null', WP_JSON_Server::READABLE ),
-
- // Page comments
- '/pages/(?P<id>\d+)/comments' => array(
- array( array( $this, 'getComments' ), WP_JSON_Server::READABLE ),
- array( '__return_null', WP_JSON_Server::CREATABLE | WP_JSON_Server::ACCEPT_JSON ),
- ),
- '/pages/(?P<id>\d+)/comments/(?P<comment>\d+)' => array(
- array( array( $this, 'getComment' ), WP_JSON_Server::READABLE ),
- array( '__return_null', WP_JSON_Server::EDITABLE | WP_JSON_Server::ACCEPT_JSON ),
- array( '__return_null', WP_JSON_Server::DELETABLE ),
- ),
- );
- return array_merge( $routes, $page_routes );
- }
-
</del><span class="cx"> /**
</span><del>- * Retrieve pages
</del><ins>+ * Post type
</ins><span class="cx"> *
</span><del>- * Overrides the $type to set to 'page', then passes through to the post
- * endpoints.
- *
- * @see WP_JSON_Posts::getPosts()
</del><ins>+ * @var string
</ins><span class="cx"> */
</span><del>- public function getPosts( $filter = array(), $context = 'view', $type = 'page', $page = 1 ) {
- if ( $type !== 'page' )
- return new WP_Error( 'json_post_invalid_type', __( 'Invalid post type' ), array( 'status' => 400 ) );
</del><ins>+ protected $type = 'page';
</ins><span class="cx">
</span><del>- return parent::getPosts( $filter, $context, 'page', $page );
- }
-
</del><span class="cx"> /**
</span><del>- * Retrieve a page
</del><ins>+ * Register the page-related routes
</ins><span class="cx"> *
</span><del>- * @see WP_JSON_Posts::getPost()
</del><ins>+ * @param array $routes Existing routes
+ * @return array Modified routes
</ins><span class="cx"> */
</span><del>- public function getPost( $id, $context = 'view' ) {
- $id = (int) $id;
</del><ins>+ public function registerRoutes( $routes ) {
+ $routes = parent::registerRoutes( $routes );
+ $routes = parent::registerRevisionRoutes( $routes );
+ $routes = parent::registerCommentRoutes( $routes );
</ins><span class="cx">
</span><del>- if ( empty( $id ) )
- return new WP_Error( 'json_post_invalid_id', __( 'Invalid post ID.' ), array( 'status' => 404 ) );
</del><ins>+ // Add post-by-path routes
+ $routes[ $this->base . '/(?P<path>.+)'] = array(
+ array( array( $this, 'getPostByPath' ), WP_JSON_Server::READABLE ),
+ array( array( $this, 'editPostByPath' ), WP_JSON_Server::EDITABLE | WP_JSON_Server::ACCEPT_JSON ),
+ array( array( $this, 'deletePostByPath' ), WP_JSON_Server::DELETABLE ),
+ );
</ins><span class="cx">
</span><del>- $post = get_post( $id, ARRAY_A );
-
- if ( $post['post_type'] !== 'page' )
- return new WP_Error( 'json_post_invalid_type', __( 'Invalid post type' ), array( 'status' => 400 ) );
-
- return parent::getPost( $id, $context );
</del><ins>+ return $routes;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><del>- * Edit a page
- *
- * @see WP_JSON_Posts::editPost()
- */
- function editPost( $id, $data, $_headers = array() ) {
- $id = (int) $id;
- if ( empty( $id ) )
- return new WP_Error( 'json_post_invalid_id', __( 'Invalid post ID.' ), array( 'status' => 404 ) );
-
- $post = get_post( $id, ARRAY_A );
-
- if ( empty( $post['ID'] ) )
- return new WP_Error( 'json_post_invalid_id', __( 'Invalid post ID.' ), array( 'status' => 404 ) );
-
- if ( $post['post_type'] !== 'page' )
- return new WP_Error( 'json_post_invalid_type', __( 'Invalid post type' ), array( 'status' => 400 ) );
-
- return parent::editPost( $id, $data, $_headers );
- }
-
- /**
- * Delete a page
- *
- * @see WP_JSON_Posts::deletePost()
- */
- public function deletePost( $id, $force = false ) {
- $id = (int) $id;
-
- if ( empty( $id ) )
- return new WP_Error( 'json_post_invalid_id', __( 'Invalid post ID.' ), array( 'status' => 404 ) );
-
- $post = get_post( $id, ARRAY_A );
-
- if ( $post['post_type'] !== 'page' )
- return new WP_Error( 'json_post_invalid_type', __( 'Invalid post type' ), array( 'status' => 400 ) );
-
- return parent::deletePost( $id, $force );
- }
-
- /**
</del><span class="cx"> * Retrieve a page by path name
</span><span class="cx"> *
</span><span class="cx"> * @param string $path
</span><span class="lines">@@ -187,15 +107,7 @@
</span><span class="cx"> $_post = parent::prepare_post( $post, $context );
</span><span class="cx">
</span><span class="cx"> // Override entity meta keys with the correct links
</span><del>- $_post['meta'] = array(
- 'links' => array(
- 'self' => json_url( '/pages/' . get_page_uri( $post['ID'] ) ),
- 'author' => json_url( '/users/' . $post['post_author'] ),
- 'collection' => json_url( '/pages' ),
- 'replies' => json_url( '/pages/' . $post['ID'] . '/comments' ),
- 'version-history' => json_url( '/pages/' . $post['ID'] . '/revisions' ),
- ),
- );
</del><ins>+ $_post['meta']['links']['self'] = json_url( '/pages/' . get_page_uri( $post['ID'] ) );
</ins><span class="cx">
</span><span class="cx"> if ( ! empty( $post['post_parent'] ) )
</span><span class="cx"> $_post['meta']['links']['up'] = json_url( '/posts/' . get_page_uri( (int) $post['post_parent'] ) );
</span></span></pre></div>
<a id="2013rmccuetrunkpluginphp"></a>
<div class="modfile"><h4>Modified: 2013/rmccue/trunk/plugin.php (2347 => 2348)</h4>
<pre class="diff"><span>
<span class="info">--- 2013/rmccue/trunk/plugin.php 2013-09-21 09:31:22 UTC (rev 2347)
+++ 2013/rmccue/trunk/plugin.php 2013-09-21 10:37:30 UTC (rev 2348)
</span><span class="lines">@@ -8,6 +8,7 @@
</span><span class="cx"> * Plugin URI: https://github.com/rmccue/WP-API
</span><span class="cx"> */
</span><span class="cx"> include_once( dirname( __FILE__ ) . '/lib/class-wp-json-posts.php' );
</span><ins>+include_once( dirname( __FILE__ ) . '/lib/class-wp-json-customposttype.php' );
</ins><span class="cx"> include_once( dirname( __FILE__ ) . '/lib/class-wp-json-pages.php' );
</span><span class="cx"> include_once( dirname( __FILE__ ) . '/lib/class-wp-json-media.php' );
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>