Use WC_Query->get_query_vars() instead of WC_Query->query_vars
Closes #17733
This commit is contained in:
parent
1bd30af0d0
commit
5a858eb2b1
|
@ -159,7 +159,7 @@ class WC_Query {
|
|||
public function add_endpoints() {
|
||||
$mask = $this->get_endpoints_mask();
|
||||
|
||||
foreach ( $this->query_vars as $key => $var ) {
|
||||
foreach ( $this->get_query_vars() as $key => $var ) {
|
||||
if ( ! empty( $var ) ) {
|
||||
add_rewrite_endpoint( $var, $mask );
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ class WC_Query {
|
|||
* @param object $q query object
|
||||
*/
|
||||
public function pre_get_posts( $q ) {
|
||||
// We only want to affect the main query
|
||||
// We only want to affect the main query.
|
||||
if ( ! $q->is_main_query() ) {
|
||||
return;
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ class WC_Query {
|
|||
// Fix for endpoints on the homepage
|
||||
if ( $this->is_showing_page_on_front( $q ) && ! $this->page_on_front_is( $q->get( 'page_id' ) ) ) {
|
||||
$_query = wp_parse_args( $q->query );
|
||||
if ( ! empty( $_query ) && array_intersect( array_keys( $_query ), array_keys( $this->query_vars ) ) ) {
|
||||
if ( ! empty( $_query ) && array_intersect( array_keys( $_query ), array_keys( $this->get_query_vars() ) ) ) {
|
||||
$q->is_page = true;
|
||||
$q->is_home = false;
|
||||
$q->is_singular = true;
|
||||
|
|
|
@ -89,9 +89,10 @@ function wc_get_endpoint_url( $endpoint, $value = '', $permalink = '' ) {
|
|||
$permalink = get_permalink();
|
||||
}
|
||||
|
||||
// Map endpoint to options
|
||||
$endpoint = ! empty( WC()->query->query_vars[ $endpoint ] ) ? WC()->query->query_vars[ $endpoint ] : $endpoint;
|
||||
$value = ( get_option( 'woocommerce_myaccount_edit_address_endpoint', 'edit-address' ) === $endpoint ) ? wc_edit_address_i18n( $value ) : $value;
|
||||
// Map endpoint to options.
|
||||
$query_vars = WC()->query->get_query_vars();
|
||||
$endpoint = ! empty( $query_vars[ $endpoint ] ) ? $query_vars[ $endpoint ]: $endpoint;
|
||||
$value = ( get_option( 'woocommerce_myaccount_edit_address_endpoint', 'edit-address' ) === $endpoint ) ? wc_edit_address_i18n( $value ) : $value;
|
||||
|
||||
if ( get_option( 'permalink_structure' ) ) {
|
||||
if ( strstr( $permalink, '?' ) ) {
|
||||
|
|
|
@ -259,7 +259,7 @@ function wc_body_class( $classes ) {
|
|||
$classes[] = 'woocommerce-demo-store';
|
||||
}
|
||||
|
||||
foreach ( WC()->query->query_vars as $key => $value ) {
|
||||
foreach ( WC()->query->get_query_vars() as $key => $value ) {
|
||||
if ( is_wc_endpoint_url( $key ) ) {
|
||||
$classes[] = 'woocommerce-' . sanitize_html_class( $key );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue