• Hello dphiffer, thank you for writing this great plugin!
    I added a new controller that I needed for a project, for querying the WordPress options, for example the blogtitle. It can be downloaded at http://waywayway.nl/easyapp/wp-content/uploads/2012/05/json-api.1.0.7-plus-WPoptions-controller.zip

    This controller must be activated in the WordPress dashboard: Settings > JSON API.

    Example usage:

    This URL: http://example.org/?json=options.get_options&options=blogname,show_on_front

    For a blog with blogname ‘My blog name’ that has a page as the front page, not the usual list of posts, this outputs:

    {
      "status": "ok",
      "blogname": "My blog name",
      "show_on_front": "page"
    }

    Changes:
    – Added a file ‘options.php’ in folder ‘controllers’.
    – Changed the plugin name in ‘json-api.php’ to ‘Plugin Name: JSON API – with WordPress options by http://waywayway.nl’, to make clear in the WordPress dashboard that the plugin is extended with a custom controller.

    Content of ‘options.php’:

    <?php
    
    class JSON_API_options_Controller {
    
    	// Get WordPress option settings from the options table, e.g. the blog name, see http://codex.wordpress.org/Option_Reference
        public function get_options() {
            global $json_api;
            $optionstring = $json_api->query->options;
    	$optionarrayindexed = explode(',', $optionstring);
    
    	foreach ($optionarrayindexed as $option) {
    		$optionarrayassociative["$option"] = get_option($option);
    	}
    
    	if ($optionstring) {
    	        return $optionarrayassociative;
    	} else {
    		$json_api->error("Include 'options' var in your request, options comma separated. See for a list of options: http://codex.wordpress.org/Option_Reference");
    		return null;
    	}
    
        }
    
    }
    
    ?>

    http://wordpress.org/extend/plugins/json-api/

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: JSON API] Added a custom controller for querying WordPress options’ is closed to new replies.