Skip to content

Instantly share code, notes, and snippets.

@geoffspink
Created November 10, 2014 07:07
Show Gist options
  • Save geoffspink/e191a7cad8c9a23f5c60 to your computer and use it in GitHub Desktop.
Save geoffspink/e191a7cad8c9a23f5c60 to your computer and use it in GitHub Desktop.
Rename the Admin Menu name for WooCommerce to the name of the website store.
<?php
add_action( 'admin_menu', 'rename_woocoomerce_admin_menu', 999 );
function rename_woocoomerce_admin_menu()
{
global $menu;
// Pinpoint menu item
$woo = recursive_array_search_php( 'WooCommerce', $menu );
// Validate
if( !$woo )
return;
$menu[$woo][0] = 'New Menu Name Here';
}
// http://www.php.net/manual/en/function.array-search.php#91365
function recursive_array_search_php( $needle, $haystack )
{
foreach( $haystack as $key => $value )
{
$current_key = $key;
if(
$needle === $value
OR (
is_array( $value )
&& recursive_array_search_php( $needle, $value ) !== false
)
)
{
return $current_key;
}
}
return false;
}
@bahiirwa
Copy link

This is interesting. Why do use a recursive method when the menu is always in the same place?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment