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0-beta.1 3.2.2 6.3.0-rc.1 3.2.3 6.3.0-rc.2 3.2.4 6.3.1 3.2.5 6.3.2 3.2.6 6.4.0 3.3.0 6.4.0-beta.1 3.3.1 6.4.0-rc.1 3.3.2 6.4.1 3.3.2-rc.1 6.4.2 3.3.3 6.5.0 3.3.4 6.5.0-beta.1 3.3.5 6.5.0-rc.1 3.3.6 6.5.0-rc.2 3.4.0 6.5.1 3.4.0-beta.1 6.5.2 3.4.0-rc.2 6.6.0 3.4.1 6.6.0-beta.1 3.4.2 6.6.0-rc.1 3.4.3 6.6.0-rc.2 3.4.4 6.6.1 3.4.5 6.6.2 3.4.6 6.7.0 3.4.7 6.7.0-beta.1 3.4.8 6.7.0-beta.2 3.5.0 6.7.0-rc.1 3.5.0-beta.1 6.7.1 3.5.0-rc.1 6.8.0 3.5.0-rc.2 6.8.0-beta.1 3.5.1 6.8.0-beta.2 3.5.10 6.8.0-rc.1 3.5.2 6.8.1 3.5.3 6.8.2 3.5.4 6.8.3 3.5.5 6.9.0 3.5.6 6.9.0-beta.1 3.5.7 6.9.0-beta.2 3.5.8 6.9.0-rc.1 3.5.9 6.9.1 3.6.0 6.9.2 3.6.0-beta.1 6.9.3 3.6.0-rc.1 6.9.4 3.6.0-rc.2 6.9.5 3.6.0-rc.3 7.0.0 3.6.1 7.0.0-beta.1 3.6.2 7.0.0-beta.2 3.6.3 7.0.0-beta.3 3.6.4 7.0.0-rc.1 3.6.5 7.0.0-rc.2 3.6.6 7.0.1 3.6.7 7.0.2 3.7.0 7.1.0 3.7.0-beta.1 7.1.0-beta.1 3.7.0-rc.1 7.1.0-beta.2 3.7.0-rc.2 7.1.0-rc.1 3.7.1 7.1.0-rc.2 3.7.2 7.1.1
woocommerce / includes / wc-page-functions.php
woocommerce / includes Last commit date
abstracts 6 years ago admin 6 years ago cli 7 years ago customizer 8 years ago data-stores 6 years ago emails 6 years ago export 7 years ago gateways 6 years ago import 6 years ago interfaces 6 years ago legacy 6 years ago libraries 6 years ago log-handlers 7 years ago payment-tokens 8 years ago queue 7 years ago shipping 6 years ago shortcodes 6 years ago theme-support 7 years ago tracks 6 years ago walkers 8 years ago wccom-site 6 years ago widgets 6 years ago class-wc-ajax.php 6 years ago class-wc-api.php 6 years ago class-wc-auth.php 7 years ago class-wc-autoloader.php 6 years ago class-wc-background-emailer.php 8 years ago class-wc-background-updater.php 7 years ago class-wc-breadcrumb.php 7 years ago class-wc-cache-helper.php 6 years ago class-wc-cart-fees.php 8 years ago class-wc-cart-session.php 6 years ago class-wc-cart-totals.php 6 years ago class-wc-cart.php 6 years ago class-wc-checkout.php 6 years ago class-wc-cli.php 8 years ago class-wc-comments.php 6 years ago class-wc-countries.php 6 years ago class-wc-coupon.php 6 years ago class-wc-customer-download-log.php 8 years ago class-wc-customer-download.php 6 years ago class-wc-customer.php 7 years ago class-wc-data-exception.php 8 years ago class-wc-data-store.php 7 years ago class-wc-datetime.php 7 years ago class-wc-deprecated-action-hooks.php 8 years ago class-wc-deprecated-filter-hooks.php 7 years ago class-wc-discounts.php 6 years ago class-wc-download-handler.php 6 years ago class-wc-emails.php 6 years ago class-wc-embed.php 8 years ago class-wc-form-handler.php 6 years ago class-wc-frontend-scripts.php 6 years ago class-wc-geo-ip.php 8 years ago class-wc-geolite-integration.php 7 years ago class-wc-geolocation.php 7 years ago class-wc-https.php 8 years ago class-wc-install.php 6 years ago class-wc-integrations.php 8 years ago class-wc-log-levels.php 7 years ago class-wc-logger.php 7 years ago class-wc-meta-data.php 7 years ago class-wc-order-factory.php 8 years ago class-wc-order-item-coupon.php 7 years ago class-wc-order-item-fee.php 7 years ago class-wc-order-item-meta.php 7 years ago class-wc-order-item-product.php 7 years ago class-wc-order-item-shipping.php 7 years ago class-wc-order-item-tax.php 6 years ago class-wc-order-item.php 6 years ago class-wc-order-query.php 7 years ago class-wc-order-refund.php 8 years ago class-wc-order.php 6 years ago class-wc-payment-gateways.php 7 years ago class-wc-payment-tokens.php 7 years ago class-wc-post-data.php 6 years ago class-wc-post-types.php 7 years ago class-wc-privacy-background-process.php 8 years ago class-wc-privacy-erasers.php 8 years ago class-wc-privacy-exporters.php 7 years ago class-wc-privacy.php 7 years ago class-wc-product-attribute.php 7 years ago class-wc-product-download.php 7 years ago class-wc-product-external.php 8 years ago class-wc-product-factory.php 7 years ago class-wc-product-grouped.php 8 years ago class-wc-product-query.php 7 years ago class-wc-product-simple.php 8 years ago class-wc-product-variable.php 6 years ago class-wc-product-variation.php 7 years ago class-wc-query.php 6 years ago class-wc-regenerate-images-request.php 7 years ago class-wc-regenerate-images.php 7 years ago class-wc-register-wp-admin-settings.php 8 years ago class-wc-rest-authentication.php 6 years ago class-wc-rest-exception.php 6 years ago class-wc-session-handler.php 6 years ago class-wc-shipping-rate.php 8 years ago class-wc-shipping-zone.php 6 years ago class-wc-shipping-zones.php 8 years ago class-wc-shipping.php 7 years ago class-wc-shortcodes.php 7 years ago class-wc-structured-data.php 6 years ago class-wc-tax.php 6 years ago class-wc-template-loader.php 7 years ago class-wc-tracker.php 6 years ago class-wc-validation.php 6 years ago class-wc-webhook.php 6 years ago class-woocommerce.php 6 years ago wc-account-functions.php 7 years ago wc-attribute-functions.php 7 years ago wc-cart-functions.php 6 years ago wc-conditional-functions.php 6 years ago wc-core-functions.php 6 years ago wc-coupon-functions.php 7 years ago wc-deprecated-functions.php 7 years ago wc-formatting-functions.php 6 years ago wc-notice-functions.php 7 years ago wc-order-functions.php 6 years ago wc-order-item-functions.php 7 years ago wc-page-functions.php 7 years ago wc-product-functions.php 6 years ago wc-rest-functions.php 7 years ago wc-stock-functions.php 7 years ago wc-template-functions.php 6 years ago wc-template-hooks.php 6 years ago wc-term-functions.php 7 years ago wc-update-functions.php 6 years ago wc-user-functions.php 6 years ago wc-webhook-functions.php 7 years ago wc-widget-functions.php 8 years ago
wc-page-functions.php
225 lines
1 <?php
2 /**
3 * WooCommerce Page Functions
4 *
5 * Functions related to pages and menus.
6 *
7 * @package WooCommerce\Functions
8 * @version 2.6.0
9 */
10
11 defined( 'ABSPATH' ) || exit;
12
13 /**
14 * Replace a page title with the endpoint title.
15 *
16 * @param string $title Post title.
17 * @return string
18 */
19 function wc_page_endpoint_title( $title ) {
20 global $wp_query;
21
22 if ( ! is_null( $wp_query ) && ! is_admin() && is_main_query() && in_the_loop() && is_page() && is_wc_endpoint_url() ) {
23 $endpoint = WC()->query->get_current_endpoint();
24 $endpoint_title = WC()->query->get_endpoint_title( $endpoint );
25 $title = $endpoint_title ? $endpoint_title : $title;
26
27 remove_filter( 'the_title', 'wc_page_endpoint_title' );
28 }
29
30 return $title;
31 }
32
33 add_filter( 'the_title', 'wc_page_endpoint_title' );
34
35 /**
36 * Retrieve page ids - used for myaccount, edit_address, shop, cart, checkout, pay, view_order, terms. returns -1 if no page is found.
37 *
38 * @param string $page Page slug.
39 * @return int
40 */
41 function wc_get_page_id( $page ) {
42 if ( 'pay' === $page || 'thanks' === $page ) {
43 wc_deprecated_argument( __FUNCTION__, '2.1', 'The "pay" and "thanks" pages are no-longer used - an endpoint is added to the checkout instead. To get a valid link use the WC_Order::get_checkout_payment_url() or WC_Order::get_checkout_order_received_url() methods instead.' );
44
45 $page = 'checkout';
46 }
47 if ( 'change_password' === $page || 'edit_address' === $page || 'lost_password' === $page ) {
48 wc_deprecated_argument( __FUNCTION__, '2.1', 'The "change_password", "edit_address" and "lost_password" pages are no-longer used - an endpoint is added to the my-account instead. To get a valid link use the wc_customer_edit_account_url() function instead.' );
49
50 $page = 'myaccount';
51 }
52
53 $page = apply_filters( 'woocommerce_get_' . $page . '_page_id', get_option( 'woocommerce_' . $page . '_page_id' ) );
54
55 return $page ? absint( $page ) : -1;
56 }
57
58 /**
59 * Retrieve page permalink.
60 *
61 * @param string $page page slug.
62 * @param string|bool $fallback Fallback URL if page is not set. Defaults to home URL. @since 3.4.0.
63 * @return string
64 */
65 function wc_get_page_permalink( $page, $fallback = null ) {
66 $page_id = wc_get_page_id( $page );
67 $permalink = 0 < $page_id ? get_permalink( $page_id ) : '';
68
69 if ( ! $permalink ) {
70 $permalink = is_null( $fallback ) ? get_home_url() : $fallback;
71 }
72
73 return apply_filters( 'woocommerce_get_' . $page . '_page_permalink', $permalink );
74 }
75
76 /**
77 * Get endpoint URL.
78 *
79 * Gets the URL for an endpoint, which varies depending on permalink settings.
80 *
81 * @param string $endpoint Endpoint slug.
82 * @param string $value Query param value.
83 * @param string $permalink Permalink.
84 *
85 * @return string
86 */
87 function wc_get_endpoint_url( $endpoint, $value = '', $permalink = '' ) {
88 if ( ! $permalink ) {
89 $permalink = get_permalink();
90 }
91
92 // Map endpoint to options.
93 $query_vars = WC()->query->get_query_vars();
94 $endpoint = ! empty( $query_vars[ $endpoint ] ) ? $query_vars[ $endpoint ] : $endpoint;
95 $value = ( get_option( 'woocommerce_myaccount_edit_address_endpoint', 'edit-address' ) === $endpoint ) ? wc_edit_address_i18n( $value ) : $value;
96
97 if ( get_option( 'permalink_structure' ) ) {
98 if ( strstr( $permalink, '?' ) ) {
99 $query_string = '?' . wp_parse_url( $permalink, PHP_URL_QUERY );
100 $permalink = current( explode( '?', $permalink ) );
101 } else {
102 $query_string = '';
103 }
104 $url = trailingslashit( $permalink ) . trailingslashit( $endpoint );
105
106 if ( $value ) {
107 $url .= trailingslashit( $value );
108 }
109
110 $url .= $query_string;
111 } else {
112 $url = add_query_arg( $endpoint, $value, $permalink );
113 }
114
115 return apply_filters( 'woocommerce_get_endpoint_url', $url, $endpoint, $value, $permalink );
116 }
117
118 /**
119 * Hide menu items conditionally.
120 *
121 * @param array $items Navigation items.
122 * @return array
123 */
124 function wc_nav_menu_items( $items ) {
125 if ( ! is_user_logged_in() ) {
126 $customer_logout = get_option( 'woocommerce_logout_endpoint', 'customer-logout' );
127
128 if ( ! empty( $customer_logout ) && ! empty( $items ) && is_array( $items ) ) {
129 foreach ( $items as $key => $item ) {
130 if ( empty( $item->url ) ) {
131 continue;
132 }
133 $path = wp_parse_url( $item->url, PHP_URL_PATH );
134 $query = wp_parse_url( $item->url, PHP_URL_QUERY );
135
136 if ( strstr( $path, $customer_logout ) || strstr( $query, $customer_logout ) ) {
137 unset( $items[ $key ] );
138 }
139 }
140 }
141 }
142
143 return $items;
144 }
145 add_filter( 'wp_nav_menu_objects', 'wc_nav_menu_items', 10 );
146
147
148 /**
149 * Fix active class in nav for shop page.
150 *
151 * @param array $menu_items Menu items.
152 * @return array
153 */
154 function wc_nav_menu_item_classes( $menu_items ) {
155 if ( ! is_woocommerce() ) {
156 return $menu_items;
157 }
158
159 $shop_page = wc_get_page_id( 'shop' );
160 $page_for_posts = (int) get_option( 'page_for_posts' );
161
162 if ( ! empty( $menu_items ) && is_array( $menu_items ) ) {
163 foreach ( $menu_items as $key => $menu_item ) {
164 $classes = (array) $menu_item->classes;
165 $menu_id = (int) $menu_item->object_id;
166
167 // Unset active class for blog page.
168 if ( $page_for_posts === $menu_id ) {
169 $menu_items[ $key ]->current = false;
170
171 if ( in_array( 'current_page_parent', $classes, true ) ) {
172 unset( $classes[ array_search( 'current_page_parent', $classes, true ) ] );
173 }
174
175 if ( in_array( 'current-menu-item', $classes, true ) ) {
176 unset( $classes[ array_search( 'current-menu-item', $classes, true ) ] );
177 }
178 } elseif ( is_shop() && $shop_page === $menu_id && 'page' === $menu_item->object ) {
179 // Set active state if this is the shop page link.
180 $menu_items[ $key ]->current = true;
181 $classes[] = 'current-menu-item';
182 $classes[] = 'current_page_item';
183
184 } elseif ( is_singular( 'product' ) && $shop_page === $menu_id ) {
185 // Set parent state if this is a product page.
186 $classes[] = 'current_page_parent';
187 }
188
189 $menu_items[ $key ]->classes = array_unique( $classes );
190 }
191 }
192
193 return $menu_items;
194 }
195 add_filter( 'wp_nav_menu_objects', 'wc_nav_menu_item_classes', 2 );
196
197
198 /**
199 * Fix active class in wp_list_pages for shop page.
200 *
201 * See details in https://github.com/woocommerce/woocommerce/issues/177.
202 *
203 * @param string $pages Pages list.
204 * @return string
205 */
206 function wc_list_pages( $pages ) {
207 if ( ! is_woocommerce() ) {
208 return $pages;
209 }
210
211 // Remove current_page_parent class from any item.
212 $pages = str_replace( 'current_page_parent', '', $pages );
213 // Find shop_page_id through woocommerce options.
214 $shop_page = 'page-item-' . wc_get_page_id( 'shop' );
215
216 if ( is_shop() ) {
217 // Add current_page_item class to shop page.
218 return str_replace( $shop_page, $shop_page . ' current_page_item', $pages );
219 }
220
221 // Add current_page_parent class to shop page.
222 return str_replace( $shop_page, $shop_page . ' current_page_parent', $pages );
223 }
224 add_filter( 'wp_list_pages', 'wc_list_pages' );
225