Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hamidrezayazdani/931e7bc72747941e90103d272527ecb5 to your computer and use it in GitHub Desktop.
Save hamidrezayazdani/931e7bc72747941e90103d272527ecb5 to your computer and use it in GitHub Desktop.
<?php
/**
* Add custom endpoint to the My Account menu
*
* @param array $items
*
* @return array
*/
function ywp_account_menu_custom_item( $items ) {
$logout = $items['customer-logout'];
unset( $items['customer-logout'] );
$items['my-navigtion-item'] = 'عنوان منو';
$items['customer-logout'] = $logout;
return $items;
}
add_filter( 'woocommerce_account_menu_items', 'ywp_account_menu_custom_item', 10, 1 );
/**
* Custom endpoint content
*/
function ywp_account_custom_item_callback() {
?>
<h1>Page Title</h1>
<p>Blah blah blah</p>
<?php
}
add_action( 'woocommerce_account_favorites_endpoint', 'ywp_account_custom_item_callback' );
/**
*
* Note: The code performs heavy operations and using it in its current form does not work well.
* This code should only be executed once.
*
*/
/**
* Adding an endpoint creates extra rewrite rules
*/
function ywp_flush_rewrite_rules() {
add_rewrite_endpoint( 'my_custom_url', EP_PAGES );
flush_rewrite_rules();
}
add_action( 'init', 'ywp_flush_rewrite_rules' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment