Skip to content

Instantly share code, notes, and snippets.

@tommcfarlin tommcfarlin/00-init.php Secret
Created Dec 19, 2016

Embed
What would you like to do?
[WordPress] WooCommerce Menu, Part 1: Adding a Menu
<?php
public function init() {
add_filter(
'woocommerce_account_menu_items',
array( $this, 'acme_menu_item' )
);
}
<?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 )
);
}
<?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
You can’t perform that action at this time.