Created
December 8, 2013 05:29
-
-
Save lordspace/7853704 to your computer and use it in GitHub Desktop.
How to return JSON from a WordPress plugin without an external plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| Plugin Name: Orbisius Sample Code | |
| Plugin URI: http://club.orbisius.com/products/ | |
| Description: Sample plugin to return JSON | |
| Version: 1.0.0 | |
| Author: Svetoslav Marinov (Slavi) | |
| Author URI: http://orbisius.com | |
| License: GPL v2 | |
| */ | |
| add_action('init', 'orbisius_example_code', 0); | |
| /** | |
| * Based on the parameters will output some JSON | |
| */ | |
| function orbisius_example_code() { | |
| if (!empty($_REQUEST['orb_cmd']) && $_REQUEST['orb_cmd'] == 'test') { | |
| echo json_encode( array( 'status' => 1, 'message' => 'hello' ) ); | |
| die; | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment