Changeset 763379
- Timestamp:
- 08/28/2013 02:51:26 AM (13 years ago)
- Location:
- jsonpress/trunk
- Files:
-
- 5 edited
-
README.md (modified) (1 diff)
-
inc/easy-get-attachments.php (modified) (2 diffs)
-
jsonpress.php (modified) (6 diffs)
-
readme.txt (modified) (2 diffs)
-
template/index.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
jsonpress/trunk/README.md
r762752 r763379 37 37 ## Changelog 38 38 39 = 0.2 = 40 * exclude_query now run after result is formatted 41 * function_exists check on `easy_get_image` library 42 * permalink/site_url changed only if API domain is configured 43 * fixed `json` endpoint, previously required to pass value json/1 44 * fix notice errors 45 * improved API access check 46 * fix 404 result 47 48 39 49 = 0.1 = 40 50 * First release -
jsonpress/trunk/inc/easy-get-attachments.php
r762752 r763379 156 156 } 157 157 158 if(!function_exists('easy_get_image')) { 158 159 function easy_get_image($size='thumbnail',$postid='',$featured=false) { 159 160 $return = new EasyAttachments; … … 161 162 return $return; 162 163 } 164 } 163 165 -
jsonpress/trunk/jsonpress.php
r762752 r763379 3 3 Plugin Name: JSONPress 4 4 Author: Takien 5 Version: 0. 15 Version: 0.2 6 6 Description: JSON API for WordPress 7 7 Author URI: http://takien.com/ … … 17 17 var $plugin_name = 'JSONPress'; 18 18 var $plugin_slug = 'jsonpress'; 19 var $plugin_version = '0. 1';19 var $plugin_version = '0.2'; 20 20 21 21 var $site_domain = ''; … … 47 47 48 48 function jsonpress_endpoints_activate() { 49 49 50 $this->jsonpress_endpoints_add_endpoint(); 50 51 flush_rewrite_rules(); … … 57 58 58 59 function jsonpress_api_access() { 60 global $wp_query; 59 61 if( !empty( $this->api_domain ) AND ($this->api_domain !== 'api.example.com' ) ) { 60 62 $path = str_replace('/index.php','',$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']); 61 if( $path == rtrim( $this->api_domain, '/' ) ) 63 if( $path == rtrim( $this->api_domain, '/' ) ) { 62 64 return true; 65 } 63 66 } 64 67 65 if( isset($_GET['json']) OR get_query_var('json') ) 68 if( isset($_GET['json']) ) 69 return true; 70 71 if (isset( $wp_query->query_vars['json'])) 66 72 return true; 67 73 } … … 70 76 function jsonpress_site_url( $url ){ 71 77 if( $this->jsonpress_api_access() ) { 72 $url = str_ireplace( $this->site_domain, $this->api_domain, $url); 78 if( !empty( $this->api_domain ) AND ($this->api_domain !== 'api.example.com' ) ) { 79 $url = str_ireplace( $this->site_domain, $this->api_domain, $url ); 80 } 73 81 } 74 82 return $url; … … 77 85 //TEMPLATE location 78 86 function jsonpress_template($template) { 79 if( $this->jsonpress_api_access() OR get_query_var('json')){87 if( $this->jsonpress_api_access() ){ 80 88 $template = dirname( __FILE__ ) . '/template/index.php'; 81 89 } -
jsonpress/trunk/readme.txt
r762752 r763379 3 3 Donate link: http://takien.com/donate 4 4 Tags: json,api,jsonp,rest,restful,phonegap,json-api,rest-api 5 Requires at least: 3. 65 Requires at least: 3.5.1 6 6 Tested up to: 3.6 7 Stable tag: 0. 17 Stable tag: 0.2 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 66 66 == Changelog == 67 67 68 = 0.2 = 69 * exclude_query now run after result is formatted 70 * function_exists check on `easy_get_image` library 71 * permalink/site_url changed only if API domain is configured 72 * fixed `json` endpoint, previously required to pass value json/1 73 * fix notice errors 74 * improved API access check 75 * fix 404 result 76 68 77 = 0.1 = 69 78 * First release -
jsonpress/trunk/template/index.php
r762752 r763379 3 3 4 4 $result = array_filter( (array)$wp_query ); 5 foreach(jsonpress_exclude_query() as $jsonpress_exclude_query) { 6 $jsonpress_exclude_query = trim($jsonpress_exclude_query); 7 if(isset($result[$jsonpress_exclude_query])) { 8 unset($result[$jsonpress_exclude_query]); 9 } 5 $formatted_post = Array(); 6 7 if( !empty($result['is_404']) ) { 8 $result['status'] = 'not found'; 10 9 } 11 10 12 $status = Array('status'=>'found'); 13 $pagination = Array( 14 'pagination'=> Array( 15 'current_page' => isset($result['query']['paged']) ? $result['query']['paged'] : isset($result['query_vars']['paged']) ? $result['query_vars']['paged'] : 0, 16 'previous_posts_link'=> get_previous_posts_link(), 17 'next_posts_link' => get_next_posts_link(), 18 'previous_posts_url' => previous_posts(false), 19 'next_posts_url' => next_posts(0,false), 20 'max_num_pages' => $result['max_num_pages'], 21 'found_posts' => $result['found_posts'] 22 )); 11 else { 12 $status = Array('status'=>'found'); 13 $pagination = Array( 14 'pagination'=> Array( 15 'current_page' => isset($result['query']['paged']) ? $result['query']['paged'] : isset($result['query_vars']['paged']) ? $result['query_vars']['paged'] : 0, 16 'previous_posts_link'=> get_previous_posts_link(), 17 'next_posts_link' => get_next_posts_link(), 18 'previous_posts_url' => previous_posts(false), 19 'next_posts_url' => next_posts(0,false), 20 'max_num_pages' => (isset($result['max_num_pages']) OR 0), 21 'found_posts' => $result['found_posts'] 22 )); 23 23 24 24 25 25 26 $result = $pagination + $result;27 $result = $status + $result;26 $result = $pagination + $result; 27 $result = $status + $result; 28 28 29 $formatted_post = Array(); 30 if(!$result['posts']) { 31 $result['status'] = 'not found'; 32 } 33 else { 29 34 30 foreach((array)$result['posts'] as $index=>$posts) { 35 31 foreach($posts as $key=>$value) { … … 91 87 } 92 88 } 93 89 //unset excluded query 90 foreach(jsonpress_exclude_query() as $jsonpress_exclude_query) { 91 $jsonpress_exclude_query = trim($jsonpress_exclude_query); 92 if(isset($result[$jsonpress_exclude_query])) { 93 unset($result[$jsonpress_exclude_query]); 94 } 95 } 94 96 //UNSET ORIGINAL POSTS OBJECT 95 97 unset($result['posts']);
Note: See TracChangeset
for help on using the changeset viewer.