Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

If pretty permalinks are disabled, use query URL

  • Loading branch information...
rmccue committed Apr 15, 2014
1 parent 36f3f13 commit faf47548c96baf47259d57ca0f068ab0a6d6eeb4
Showing with 17 additions and 3 deletions.
  1. +17 −3 plugin.php
@@ -229,10 +229,24 @@ function json_output_link_header() {
* @return string Full URL to the endpoint
*/
function get_json_url( $blog_id = null, $path = '', $scheme = 'json' ) {
$url = get_home_url( $blog_id, 'wp-json', $scheme );
if ( get_option( 'permalink_structure' ) ) {
$url = get_home_url( $blog_id, 'wp-json', $scheme );
if ( !empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false )
$url .= '/' . ltrim( $path, '/' );
if ( !empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false )
$url .= '/' . ltrim( $path, '/' );
}
else {
$url = trailingslashit( get_home_url( $blog_id, '', $scheme ) );
if ( empty( $path ) ) {
$path = '/';
}
else {
$path = '/' . ltrim( $path, '/' );
}
$url = add_query_arg( 'json_route', $path, $url );
}
return apply_filters( 'json_url', $url, $path, $blog_id );
}

1 comment on commit faf4754

@rachelbaker

This comment has been minimized.

Copy link
Member

rachelbaker commented on faf4754 Apr 19, 2014

@rmccue During testing this patch still did not allow the JSON routes to respond without pretty permalinks enabled. This needs more debugging/testing.

Please sign in to comment.
You can’t perform that action at this time.