Astra_Woocommerce::astra_update_customize_admin_bar_link( WP_Admin_Bar $wp_admin_bar )
Update the “Customize” link to the Toolbar.
Description
Parameters
- $wp_admin_bar
-
(WP_Admin_Bar) (Required) The WP_Admin_Bar instance.
Source
File: inc/compatibility/woocommerce/class-astra-woocommerce.php
public function astra_update_customize_admin_bar_link( $wp_admin_bar ) { $admin_bar_nodes = $wp_admin_bar->get_nodes(); if ( ! is_admin() && class_exists( 'WooCommerce' ) && isset( $admin_bar_nodes['customize'] ) ) { $customize_link = isset( $admin_bar_nodes['customize']->href ) ? $admin_bar_nodes['customize']->href : wp_customize_url(); /** @psalm-suppress PossiblyFalseOperand */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort $current_url = substr( $customize_link, strpos( $customize_link, '?url=' ) + 1 ); /** @psalm-suppress PossiblyFalseOperand */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort $wp_admin_bar->remove_node( 'customize' ); if ( is_product() ) { $customize_link = admin_url( 'customize.php' ) . '?autofocus[section]=section-woo-shop-single&' . $current_url; } if ( is_cart() ) { $customize_link = admin_url( 'customize.php' ) . '?autofocus[section]=section-woo-shop-cart&' . $current_url; } if ( is_checkout() ) { $customize_link = admin_url( 'customize.php' ) . '?autofocus[section]=woocommerce_checkout&' . $current_url; } if ( is_account_page() ) { $customize_link = admin_url( 'customize.php' ) . '?autofocus[section]=section-ast-woo-my-account&' . $current_url; } if ( is_shop() || is_product_taxonomy() ) { $customize_link = admin_url( 'customize.php' ) . '?autofocus[section]=woocommerce_product_catalog&' . $current_url; } $customize_node = array( 'id' => 'customize', 'title' => __( 'Customize', 'astra' ), 'href' => $customize_link, 'meta' => array( 'class' => 'hide-if-no-customize', ), ); /** @psalm-suppress InvalidArgument */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort $wp_admin_bar->add_node( $customize_node ); /** @psalm-suppress InvalidArgument */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort } }
Expand full source code Collapse full source code View on Trac
Changelog
Version | Description |
---|---|
3.9.2 | Introduced. |