Advertisement
wclovers

Reorder myaccount menus

Jun 16th, 2022
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.49 KB | None | 0 0
  1. add_filter( 'woocommerce_account_menu_items', function( $items ) {
  2.     global $WCFMmp, $WCFM, $WCFMu;
  3.  
  4.     $items_to_add = [];
  5.  
  6.     if( has_filter( 'woocommerce_account_menu_items', [ $WCFMmp->frontend, 'wcfm_dashboard_my_account_menu_items' ] ) ) {
  7.         remove_filter('woocommerce_account_menu_items', [ $WCFMmp->frontend, 'wcfm_dashboard_my_account_menu_items' ], 999);
  8.        
  9.         if( wcfm_is_vendor() ) {
  10.             $dashboard_page_title = __( 'Store Manager', 'wc-multivendor-marketplace' );
  11.             $pages = get_option("wcfm_page_options");
  12.             if( isset($pages['wc_frontend_manager_page_id']) && $pages['wc_frontend_manager_page_id'] ) {
  13.                 $dashboard_page_title = get_the_title( $pages['wc_frontend_manager_page_id'] );
  14.             }
  15.             $dashboard_page_title = apply_filters( 'wcfmmp_wcmy_dashboard_page_title', $dashboard_page_title );
  16.            
  17.             if( isset( $items['wcfm-store-manager'] ) ) unset( $items['wcfm-store-manager'] );
  18.  
  19.             $items_to_add['wcfm-store-manager'] = __( $dashboard_page_title, 'wc-multivendor-marketplace' );
  20.         }
  21.     }
  22.  
  23.     if( has_filter( 'woocommerce_account_menu_items', [ $WCFMu->wcfmu_vendor_followers, 'wcfm_followers_my_account_menu_items' ] ) ) {
  24.         remove_filter('woocommerce_account_menu_items', [ $WCFMu->wcfmu_vendor_followers, 'wcfm_followers_my_account_menu_items' ], 190);
  25.  
  26.         $items_to_add[ $WCFMu->wcfmu_vendor_followers->wcfm_myaccount_followings_endpoint ] = __('Followings', 'wc-frontend-manager-ultimate');
  27.     }
  28.  
  29.     if( has_filter( 'woocommerce_account_menu_items', [ $WCFMu->wcfmu_support, 'wcfm_support_my_account_menu_items' ] ) ) {
  30.         remove_filter('woocommerce_account_menu_items', [ $WCFMu->wcfmu_support, 'wcfm_support_my_account_menu_items' ], 201);
  31.  
  32.         $items_to_add[ $WCFMu->wcfmu_support->wcfm_myaccount_support_ticket_endpoint ] = __('Support Tickets', 'wc-frontend-manager-ultimate');
  33.                                                                    
  34.     }
  35.  
  36.     if( has_filter( 'woocommerce_account_menu_items', [ $WCFM->wcfm_enquiry, 'wcfm_enquiry_my_account_menu_items' ] ) ) {
  37.         remove_filter('woocommerce_account_menu_items', [ $WCFM->wcfm_enquiry, 'wcfm_enquiry_my_account_menu_items' ], 200);
  38.        
  39.         $items_to_add[ $WCFM->wcfm_enquiry->wcfm_myaccount_inquiry_endpoint ] = __( 'Inquiries', 'wc-frontend-manager' );
  40.     }
  41.  
  42.     if( $items_to_add ) {
  43.         $items = array_slice($items, 0, 1, true) + $items_to_add + array_slice($items, 1, count($items) - 1, true) ;
  44.     }
  45.  
  46.     return $items;
  47. }, 1 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement