JSON API - Version 0.9.3

Version Description

Fixed a bug where child pages could not be introspected by the API.

Download this release

Release Info

Developer dphiffer
Plugin Icon wp plugin JSON API
Version 0.9.3
Comparing to
See all releases

Code changes from version 0.9.2 to 0.9.3

Files changed (3) hide show
  1. json-api.php +1 -1
  2. readme.txt +7 -1
  3. singletons/controller.php +16 -0
json-api.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: JSON API
4
  Plugin URI: http://wordpress.org/extend/plugins/json-api/
5
  Description: A RESTful API for WordPress
6
- Version: 0.9.2
7
  Author: Dan Phiffer
8
  Author URI: http://phiffer.org/
9
  */
3
  Plugin Name: JSON API
4
  Plugin URI: http://wordpress.org/extend/plugins/json-api/
5
  Description: A RESTful API for WordPress
6
+ Version: 0.9.3
7
  Author: Dan Phiffer
8
  Author URI: http://phiffer.org/
9
  */
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: dphiffer
3
  Tags: json, api, ajax, cms, admin, integration, moma
4
  Requires at least: 2.8
5
  Tested up to: 2.9
6
- Stable tag: 0.9.2
7
 
8
  A RESTful API for WordPress
9
 
@@ -587,6 +587,9 @@ Submits a comment to a WordPress post.
587
 
588
  == Changelog ==
589
 
 
 
 
590
  = 0.9.2 (2010-03-18): =
591
  * Fixed a bug where the /api/ rewrite rules would be lost
592
 
@@ -628,6 +631,9 @@ Submits a comment to a WordPress post.
628
 
629
  == Upgrade Notice ==
630
 
 
 
 
631
  = 0.9.2 =
632
  Fixed a bug where the /api/ path would stop working upon publishing new pages.
633
 
3
  Tags: json, api, ajax, cms, admin, integration, moma
4
  Requires at least: 2.8
5
  Tested up to: 2.9
6
+ Stable tag: 0.9.3
7
 
8
  A RESTful API for WordPress
9
 
587
 
588
  == Changelog ==
589
 
590
+ = 0.9.3 (2010-03-19): =
591
+ * Fixed a bug where child pages were being ignored by the API. See also: https://core.trac.wordpress.org/ticket/12647
592
+
593
  = 0.9.2 (2010-03-18): =
594
  * Fixed a bug where the /api/ rewrite rules would be lost
595
 
631
 
632
  == Upgrade Notice ==
633
 
634
+ = 0.9.3 =
635
+ Fixed a bug where child pages could not be introspected by the API.
636
+
637
  = 0.9.2 =
638
  Fixed a bug where the /api/ path would stop working upon publishing new pages.
639
 
singletons/controller.php CHANGED
@@ -92,6 +92,22 @@ class JSON_API_Controller {
92
  $this->error("No page specified. Include 'page_id' or 'page_slug' var in your request.");
93
  }
94
  $pages = $this->introspector->get_posts($query);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  if (count($pages) == 1) {
96
  return $this->response->get_json(array(
97
  'page' => $pages[0]
92
  $this->error("No page specified. Include 'page_id' or 'page_slug' var in your request.");
93
  }
94
  $pages = $this->introspector->get_posts($query);
95
+
96
+ // Workaround for https://core.trac.wordpress.org/ticket/12647
97
+ if (empty($pages)) {
98
+ $url = $_SERVER['REQUEST_URI'];
99
+ $parsed_url = parse_url($url);
100
+ $path = $parsed_url['path'];
101
+ if (preg_match('#^http://[^/]+(/.+)$#', get_bloginfo('url'), $matches)) {
102
+ $blog_root = $matches[1];
103
+ $path = preg_replace("#^$blog_root#", '', $path);
104
+ }
105
+ if (substr($path, 0, 1) == '/') {
106
+ $path = substr($path, 1);
107
+ }
108
+ $pages = $this->introspector->get_posts("pagename=$path");
109
+ }
110
+
111
  if (count($pages) == 1) {
112
  return $this->response->get_json(array(
113
  'page' => $pages[0]