Skip to content

Commit

Permalink
wc_get_endpoint_url - added support for permalinks containing a query…
Browse files Browse the repository at this point in the history
… string Closes woocommerce#5016
  • Loading branch information
mikejolley committed Mar 3, 2014
1 parent c6e63c6 commit 74e7829
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions includes/wc-page-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,17 @@ function wc_get_endpoint_url( $endpoint, $value = '', $permalink = '' ) {
// Map endpoint to options
$endpoint = isset( WC()->query->query_vars[ $endpoint ] ) ? WC()->query->query_vars[ $endpoint ] : $endpoint;

if ( get_option( 'permalink_structure' ) )
$url = trailingslashit( $permalink ) . $endpoint . '/' . $value;
else
if ( get_option( 'permalink_structure' ) ) {
if ( strstr( $permalink, '?' ) ) {
$query_string = '?' . parse_url( $permalink, PHP_URL_QUERY );
$permalink = current( explode( '?', $permalink ) );
} else {
$query_string = '';
}
$url = trailingslashit( $permalink ) . $endpoint . '/' . $value . $query_string;
} else {
$url = add_query_arg( $endpoint, $value, $permalink );
}

return apply_filters( 'woocommerce_get_endpoint_url', $url );
}
Expand Down

0 comments on commit 74e7829

Please sign in to comment.