Created
April 10, 2018 21:42
-
-
Save samholguin/7265ea68ab309b7436ef0294774b7c70 to your computer and use it in GitHub Desktop.
WordPress - add admin page endpoint
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
/** | |
* Account menu items. | |
* | |
* @param arr $items | |
* | |
* @return arr | |
*/ | |
function swd_account_menu_items($items) | |
{ | |
$items['profile'] = 'Profile'; | |
return $items; | |
} | |
add_filter('woocommerce_account_menu_items', 'swd_account_menu_items', 10, 1); | |
/** | |
* Add 'profile' endpoint. | |
*/ | |
function swd_wc_add_my_account_endpoint() | |
{ | |
add_rewrite_endpoint('profile', EP_PAGES); | |
} | |
add_action('init', 'swd_wc_add_my_account_endpoint'); | |
/** | |
* My Account > profile content. | |
*/ | |
function swd_wc_profile_endpoint_content() | |
{ | |
wc_get_template('myaccount/profile.php'); | |
} | |
add_action('woocommerce_account_profile_endpoint', 'swd_wc_profile_endpoint_content'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment