From 5a858eb2b1537c901657d7e3fd5be83c64cece41 Mon Sep 17 00:00:00 2001 From: Claudio Sanches Date: Mon, 20 Nov 2017 14:40:56 -0200 Subject: [PATCH] Use WC_Query->get_query_vars() instead of WC_Query->query_vars Closes #17733 --- includes/class-wc-query.php | 6 +++--- includes/wc-page-functions.php | 7 ++++--- includes/wc-template-functions.php | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/includes/class-wc-query.php b/includes/class-wc-query.php index df8d29d1c0e..762fdef6807 100644 --- a/includes/class-wc-query.php +++ b/includes/class-wc-query.php @@ -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; diff --git a/includes/wc-page-functions.php b/includes/wc-page-functions.php index 206af096128..2b28b31087d 100644 --- a/includes/wc-page-functions.php +++ b/includes/wc-page-functions.php @@ -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, '?' ) ) { diff --git a/includes/wc-template-functions.php b/includes/wc-template-functions.php index 58f572369cf..b728216df5c 100644 --- a/includes/wc-template-functions.php +++ b/includes/wc-template-functions.php @@ -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 ); }