Advertisement
thesufi

Woocommerce custom account menu item classes

Jan 10th, 2017
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.71 KB | None | 0 0
  1. /*
  2.  * Woocommerce filter account menu item classes
  3.  */
  4. function custom_woocommerce_account_menu_item_classes( $classes, $endpoint ) {
  5.     global $wp;
  6.  
  7.     $classes = array(
  8.         'woocommerce-myaccount-nav-link',
  9.         'woocommerce-myaccount-nav-link-' . $endpoint,
  10.     );
  11.  
  12.     // Set current item class.
  13.     $current = isset( $wp->query_vars[ $endpoint ] );
  14.     if ( 'dashboard' === $endpoint && ( isset( $wp->query_vars['page'] ) || empty( $wp->query_vars ) ) ) {
  15.         $current = true;
  16.     }
  17.  
  18.     if ( $current ) {
  19.         $classes[] = 'active';
  20.     }
  21.    
  22.     return $classes;
  23. };
  24.  
  25. add_filter( 'woocommerce_account_menu_item_classes', 'custom_woocommerce_account_menu_item_classes', 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement