Plugin Directory

Changeset 763379


Ignore:
Timestamp:
08/28/2013 02:51:26 AM (13 years ago)
Author:
takien
Message:

update to 0.2

Location:
jsonpress/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • jsonpress/trunk/README.md

    r762752 r763379  
    3737## Changelog
    3838
     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
    3949= 0.1 =
    4050* First release
  • jsonpress/trunk/inc/easy-get-attachments.php

    r762752 r763379  
    156156}
    157157
     158if(!function_exists('easy_get_image')) {
    158159function easy_get_image($size='thumbnail',$postid='',$featured=false) {
    159160    $return = new EasyAttachments;
     
    161162    return $return;
    162163}
     164}
    163165
  • jsonpress/trunk/jsonpress.php

    r762752 r763379  
    33Plugin Name: JSONPress
    44Author: Takien
    5 Version: 0.1
     5Version: 0.2
    66Description: JSON API for WordPress
    77Author URI: http://takien.com/
     
    1717        var $plugin_name    = 'JSONPress';
    1818        var $plugin_slug    = 'jsonpress';
    19         var $plugin_version = '0.1';
     19        var $plugin_version = '0.2';
    2020       
    2121        var $site_domain = '';
     
    4747       
    4848        function jsonpress_endpoints_activate() {
     49           
    4950            $this->jsonpress_endpoints_add_endpoint();
    5051            flush_rewrite_rules();
     
    5758       
    5859        function jsonpress_api_access() {
     60            global $wp_query;
    5961            if( !empty( $this->api_domain ) AND ($this->api_domain !== 'api.example.com' ) ) {
    6062                $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, '/' ) ) {
    6264                        return true;
     65                    }
    6366            }
    6467   
    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']))
    6672                return true;
    6773        }
     
    7076        function jsonpress_site_url( $url ){
    7177            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                }
    7381            }
    7482            return $url;
     
    7785        //TEMPLATE location
    7886        function jsonpress_template($template) {
    79             if( $this->jsonpress_api_access() OR get_query_var('json') ){
     87            if( $this->jsonpress_api_access() ){
    8088                $template = dirname( __FILE__ ) . '/template/index.php';
    8189            }
  • jsonpress/trunk/readme.txt

    r762752 r763379  
    33Donate link: http://takien.com/donate
    44Tags: json,api,jsonp,rest,restful,phonegap,json-api,rest-api
    5 Requires at least: 3.6
     5Requires at least: 3.5.1
    66Tested up to: 3.6
    7 Stable tag: 0.1
     7Stable tag: 0.2
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    6666== Changelog ==
    6767
     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
    6877= 0.1 =
    6978* First release
  • jsonpress/trunk/template/index.php

    r762752 r763379  
    33
    44$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
     7if( !empty($result['is_404']) ) {
     8    $result['status'] = 'not found';
    109}
    1110
    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     ));
     11else {
     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        ));
    2323
    2424
    2525
    26 $result = $pagination + $result;
    27 $result = $status + $result;
     26    $result = $pagination + $result;
     27    $result = $status + $result;
    2828
    29 $formatted_post = Array();
    30 if(!$result['posts']) {
    31     $result['status'] = 'not found';
    32 }
    33 else {
     29
    3430    foreach((array)$result['posts'] as $index=>$posts) {
    3531        foreach($posts as $key=>$value) {
     
    9187    }
    9288}
    93 
     89//unset excluded query
     90foreach(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}
    9496//UNSET ORIGINAL POSTS OBJECT
    9597unset($result['posts']);
Note: See TracChangeset for help on using the changeset viewer.