Skip to content

Instantly share code, notes, and snippets.

@tommcfarlin
Created December 19, 2016 14:31
Show Gist options
  • Save tommcfarlin/47c2850a59a4d3886eaeae19b9a679a3 to your computer and use it in GitHub Desktop.
Save tommcfarlin/47c2850a59a4d3886eaeae19b9a679a3 to your computer and use it in GitHub Desktop.
[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