Ensure API Request URL scheme is not relative to the current page.

This commit is contained in:
Mike Jolley 2013-03-28 15:49:02 +00:00
parent 6079c8f0e3
commit 21c40fc6b9
2 changed files with 10 additions and 7 deletions

View File

@ -177,6 +177,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
* Fix - Put back sandbox pending fix. Aparently still needed for some accounts.
* Fix - Do not sanitize old attribute name to not mess up comparing
* Fix - Settings API empty value only used if set. In turn fixes blank values in flat rate shipping.
* Fix - Ensure API Request URL scheme is not relative to the current page.
* Tweak - UX - Placeholder fades out on focus
* Tweak - UX - Only display validation result on required fields
* Localisation - NZ States

View File

@ -490,7 +490,7 @@ class Woocommerce {
add_action( 'wp_footer', array( $this, 'output_inline_js' ), 25 );
// HTTPS urls with SSL on
$filters = array( 'post_thumbnail_html', 'widget_text', 'wp_get_attachment_url', 'wp_get_attachment_image_attributes', 'wp_get_attachment_url', 'option_siteurl', 'option_homeurl', 'option_home', 'option_url', 'option_wpurl', 'option_stylesheet_url', 'option_template_url', 'script_loader_src', 'style_loader_src', 'template_directory_uri', 'stylesheet_directory_uri', 'site_url' );
$filters = array( 'post_thumbnail_html', 'widget_text', 'wp_get_attachment_url', 'wp_get_attachment_image_attributes', 'wp_get_attachment_url', 'option_stylesheet_url', 'option_template_url', 'script_loader_src', 'style_loader_src', 'template_directory_uri', 'stylesheet_directory_uri', 'site_url' );
foreach ( $filters as $filter )
add_filter( $filter, array( $this, 'force_ssl' ) );
@ -1367,13 +1367,15 @@ class Woocommerce {
* @return string
*/
public function api_request_url( $request, $ssl = null ) {
if ( is_null( $ssl ) )
$ssl = is_ssl();
if ( is_null( $ssl ) ) {
$scheme = parse_url( get_option( 'home' ), PHP_URL_SCHEME );
} elseif ( $ssl ) {
$scheme = 'https';
} else {
$scheme = 'http';
}
$url = trailingslashit( home_url( '/wc-api/' . $request ) );
$url = $ssl ? str_replace( 'http:', 'https:', $url ) : str_replace( 'https:', 'http:', $url );
return esc_url_raw( $url );
return esc_url_raw( trailingslashit( home_url( '/wc-api/' . $request, $scheme ) ) );
}