Skip to content
This repository has been archived by the owner on Sep 24, 2018. It is now read-only.

Commit

Permalink
Register rewrite rules on activation
Browse files Browse the repository at this point in the history
Fixes #17. Props @pippinsplugins
  • Loading branch information
rmccue committed Nov 25, 2013
1 parent d45284e commit a922d03
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@
* Register our rewrite rules for the API
*/
function json_api_init() {
add_rewrite_rule( '^wp-json\.php/?$','index.php?json_route=/','top' );
add_rewrite_rule( '^wp-json\.php(.*)?','index.php?json_route=$matches[1]','top' );
json_api_register_rewrites();

global $wp;
$wp->add_query_var('json_route');
}
add_action( 'init', 'json_api_init' );

function json_api_register_rewrites() {
add_rewrite_rule( '^wp-json\.php/?$','index.php?json_route=/','top' );
add_rewrite_rule( '^wp-json\.php(.*)?','index.php?json_route=$matches[1]','top' );
}

/**
* Register the default JSON API filters
*
Expand Down Expand Up @@ -114,6 +118,7 @@ function json_api_loaded() {
* Flush the rewrite rules on activation
*/
function json_api_activation() {
json_api_register_rewrites();
flush_rewrite_rules();
}
register_activation_hook( __FILE__, 'json_api_activation' );
Expand Down

0 comments on commit a922d03

Please sign in to comment.