-
-
Save tommcfarlin/47c2850a59a4d3886eaeae19b9a679a3 to your computer and use it in GitHub Desktop.
[WordPress] WooCommerce Menu, Part 1: Adding a Menu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function init() { | |
add_filter( | |
'woocommerce_account_menu_items', | |
array( $this, 'acme_menu_item' ) | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function acme_menu_item( $items ) { | |
return | |
array_merge( | |
array_slice( $items, 0, count( $items ) - 1 ), | |
array( 'acme' => 'Acme' ), | |
array_slice( $items, count( $items ) - 1 ) | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Acme\Frontend; | |
class Acme_Menu { | |
public function init() { | |
add_filter( | |
'woocommerce_account_menu_items', | |
array( $this, 'acme_menu_item' ) | |
); | |
} | |
public function acme_menu_item( $items ) { | |
return | |
array_merge( | |
array_slice( $items, 0, count( $items ) - 1 ), | |
array( 'acme' => 'Acme' ), | |
array_slice( $items, count( $items ) - 1 ) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment