Created
December 30, 2014 18:05
-
-
Save bitflower/1a7efbcbec19079414d0 to your computer and use it in GitHub Desktop.
Activate CORS for WP-API (JSON REST API)
This file contains 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
/** | |
* bitflower: Activate CORS for WP-API (JSON REST API) | |
*/ | |
do_action("json_api", $controller, $method); | |
add_action( 'json_api', function( $controller, $method ) | |
{ | |
# DEBUG | |
// wp_die( "To target only this method use <pre><code>add_action('$controller-$method', function(){ /*YOUR-STUFF*/ });</code></pre>" ); | |
header( "Access-Control-Allow-Origin: *" ); | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment