Created
December 15, 2018 11:31
-
-
Save trueqap/e47fdc73c66de7e119ae5c6424700917 to your computer and use it in GitHub Desktop.
Add the AffiliateWP menu (with content) to the WooCommerce My Account section
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 | |
// Add new slug | |
function hellowp_add_premium_support_endpoint() | |
{ | |
add_rewrite_endpoint('affiliate-partner', EP_ROOT | EP_PAGES); | |
} | |
add_action('init', 'hellowp_add_premium_support_endpoint'); | |
// ------------------ | |
// Add new query var | |
function hellowp_premium_support_query_vars($vars) | |
{ | |
$vars[] = 'affiliate-partner'; | |
return $vars; | |
} | |
add_filter('query_vars', 'hellowp_premium_support_query_vars', 0); | |
// ------------------ | |
// Insert the new endpoint into the My Account menu after ORDER menu | |
function hellowp_add_premium_support_link_my_account($items) | |
{ | |
$label = 'Partnerprogram'; | |
if (array_key_exists('orders', $items)) { | |
$items = wcs_array_insert_after('orders', $items, 'affiliate-partner', $label); | |
} else { | |
$items['affiliate-partner'] = $label; | |
} | |
return $items; | |
} | |
add_filter('woocommerce_account_menu_items', 'hellowp_add_premium_support_link_my_account', 5, 1); | |
// ------------------ | |
// Add content to the new endpoint | |
function hellowp_premium_support_content() | |
{ | |
echo '<h3>Legyélt Te is a Partnerünk!</h3><p> Szeretnéd támogatni az oldalunkat egy visszalinkkel? Adunk jutalékot cserébe. Minden értékesítés után (ami a te linkeden keresztül jött) 20%-ot adunk neked! Jól hangzik ugye?!</p>'; | |
echo do_shortcode('[affiliate_area]'); | |
} | |
add_action('woocommerce_account_affiliate-partner_endpoint', 'hellowp_premium_support_content', 10, 5); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment