Пример #1
0
 function get_json($data, $status = 'ok')
 {
     // Include a status value with the response
     if (is_array($data)) {
         $data = array_merge(array('status' => $status), $data);
     } else {
         if (is_object($data)) {
             $data = get_object_vars($data);
             $data = array_merge(array('status' => $status), $data);
         }
     }
     $data = apply_filters('json_api_encode', $data);
     if (function_exists('json_encode')) {
         // Use the built-in json_encode function if it's available
         return json_encode($data);
     } else {
         // Use PEAR's Services_JSON encoder otherwise
         if (!class_exists('Services_JSON')) {
             $dir = gb_json_api_dir();
             require_once "{$dir}/library/JSON.php";
         }
         $json = new Services_JSON();
         return $json->encode($data);
     }
 }
Пример #2
0
 public function info()
 {
     global $gb_json_api;
     $php = '';
     if (!empty($gb_json_api->query->controller)) {
         return $gb_json_api->controller_info($gb_json_api->query->controller);
     } else {
         $dir = gb_json_api_dir();
         if (file_exists("{$dir}/gb_json-api.php")) {
             $php = file_get_contents("{$dir}/gb_json-api.php");
         } else {
             // Check one directory up, in case json-api.php was moved
             $dir = dirname($dir);
             if (file_exists("{$dir}/gb_json-api.php")) {
                 $php = file_get_contents("{$dir}/gb_json-api.php");
             }
         }
         if (preg_match('/^\\s*Version:\\s*(.+)$/m', $php, $matches)) {
             $version = $matches[1];
         } else {
             $version = '(Unknown)';
         }
         $active_controllers = explode(',', get_option('gb_json_api_controllers', 'core'));
         $controllers = array_intersect($gb_json_api->get_controllers(), $active_controllers);
         return array('gb_json_api_version' => $version, 'controllers' => array_values($controllers));
     }
 }
<?php

/*
Plugin Name: GoodBarber Api
Plugin URI: http://www.goodbarber.com/
Description: A JSON API fork for WordPress made by goodbarber
Version: 1.0.10
Original Author: Dan Phiffer
Original Author URI: http://phiffer.org/
Author: GoodBarber
Author URI: http://www.goodbarber.com/ 
*/
$dir = gb_json_api_dir();
/*@include_once "$dir/singletons/api.php";
@include_once "$dir/singletons/query.php";
@include_once "$dir/singletons/introspector.php";
@include_once "$dir/singletons/response.php";
@include_once "$dir/models/post.php";
@include_once "$dir/models/comment.php";
@include_once "$dir/models/category.php";
@include_once "$dir/models/tag.php";
@include_once "$dir/models/author.php";
@include_once "$dir/models/attachment.php";
*/
include_once "{$dir}/singletons/api.php";
include_once "{$dir}/singletons/query.php";
include_once "{$dir}/singletons/introspector.php";
include_once "{$dir}/singletons/response.php";
include_once "{$dir}/models/post.php";
include_once "{$dir}/models/comment.php";
include_once "{$dir}/models/category.php";
Пример #4
0
 function controller_path($controller)
 {
     $dir = gb_json_api_dir();
     $controller_class = $this->controller_class($controller);
     return apply_filters("{$controller_class}_path", "{$dir}/controllers/{$controller}.php");
 }