wc_get_account_menu_item_classes

Get account menu item classes.

Description

(string) wc_get_account_menu_item_classes( (string) $endpoint ); 

Returns (string)

Parameters (1)

0. $endpoint (string)
The endpoint.

Usage

  1. if ( !function_exists( 'wc_get_account_menu_item_classes' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-account-functions.php'; 
  3.  
  4. // The endpoint. 
  5. $endpoint = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wc_get_account_menu_item_classes($endpoint); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-account-functions.php  
  1. function wc_get_account_menu_item_classes( $endpoint ) { 
  2. global $wp; 
  3.  
  4. $classes = array( 
  5. 'woocommerce-MyAccount-navigation-link',  
  6. 'woocommerce-MyAccount-navigation-link--' . $endpoint,  
  7. ); 
  8.  
  9. // Set current item class. 
  10. $current = isset( $wp->query_vars[ $endpoint ] ); 
  11. if ( 'dashboard' === $endpoint && ( isset( $wp->query_vars['page'] ) || empty( $wp->query_vars ) ) ) { 
  12. $current = true; // Dashboard is not an endpoint, so needs a custom check. 
  13.  
  14. if ( $current ) { 
  15. $classes[] = 'is-active'; 
  16.  
  17. $classes = apply_filters( 'woocommerce_account_menu_item_classes', $classes, $endpoint ); 
  18.  
  19. return implode( ' ', array_map( 'sanitize_html_class', $classes ) );