is_wc_endpoint_url Closes #4731

This commit is contained in:
Mike Jolley 2014-02-12 12:18:36 +00:00
parent 60fbf90d7f
commit d7493b0b8a
2 changed files with 32 additions and 0 deletions

View File

@ -115,6 +115,14 @@ class WC_Query {
return $vars; return $vars;
} }
/**
* Get query vars
* @return array()
*/
public function get_query_vars() {
return $this->query_vars;
}
/** /**
* Parse the request and look for query vars - endpoints may not be supported * Parse the request and look for query vars - endpoints may not be supported
*/ */

View File

@ -130,6 +130,30 @@ if ( ! function_exists( 'is_checkout_pay_page' ) ) {
} }
} }
if ( ! function_exists( 'is_wc_endpoint_url' ) ) {
/**
* is_wc_endpoint_url - Check if an endpoint is showing
*
* @access public
* @param string $endpoint
* @return bool
*/
function is_wc_endpoint_url( $endpoint ) {
global $wp;
$wc_endpoints = WC()->query->get_query_vars();
if ( ! isset( $wc_endpoints[ $endpoint ] ) ) {
return false;
} else {
$endpoint_var = $wc_endpoints[ $endpoint ];
}
return isset( $wp->query_vars[ $endpoint_var ] ) ? true : false;
}
}
if ( ! function_exists( 'is_account_page' ) ) { if ( ! function_exists( 'is_account_page' ) ) {
/** /**