Last active
July 3, 2024 09:02
-
-
Save goranefbl/e478e6a4462e63dbec299b193e4472b3 to your computer and use it in GitHub Desktop.
Change referral shortcode
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 | |
function override_woo_gens_raf_advance_shortcode() { | |
remove_shortcode('WOO_GENS_RAF_ADVANCE'); | |
add_shortcode('WOO_GENS_RAF_ADVANCE', 'custom_woo_gens_raf_advance_shortcode'); | |
} | |
add_action('init', 'override_woo_gens_raf_advance_shortcode'); | |
function custom_woo_gens_raf_advance_shortcode($atts) { | |
$atts = shortcode_atts( array( | |
'guest_text' => 'Please <a href="' . wc_get_account_endpoint_url('myreferrals') . '">register</a> to get your referral link.', | |
'url' => get_home_url(), | |
'id' => get_current_user_id(), | |
'two_columns' => false | |
), $atts, 'WOO_GENS_RAF_ADVANCE' ); | |
$guest_text = $atts['guest_text']; | |
$two_columns = $atts['two_columns']; | |
$title = __(get_option( 'gens_raf_twitter_title' ),'gens-raf'); | |
$twitter_via = __(get_option( 'gens_raf_twitter_via' ),'gens-raf'); | |
$share_text = __(get_option( 'gens_raf_share_text' ),'gens-raf'); | |
$email_hide = get_option( 'gens_raf_email_hide' ); | |
$linkedin = get_option( 'gens_raf_linkedin' ); | |
$pinterest = get_option( 'gens_raf_pinterest' ); | |
$twitter = get_option( 'gens_raf_twitter' ); | |
$messenger = get_option( 'gens_raf_messenger' ); | |
$facebook = get_option( 'gens_raf_facebook' ); | |
$whatsapp = get_option( 'gens_raf_whatsapp' ); | |
$viber = get_option( 'gens_raf_viber' ); | |
$allow_guests = get_option( 'gens_raf_allow_guests' ); | |
$raf_user = new WPGens_RAF_User($atts['id']); | |
$rafLink = $raf_user->generate_referral_url('shortcode',$atts['url']); | |
$referral_code = get_option( 'gens_raf_referral_codes' ); | |
$raf_id = $raf_user->get_referral_id(); | |
$template_path = WPGens_RAF::get_template_path('advance-shortcode.php','',TRUE); | |
$guest_cookie_class = (isset($_COOKIE['gens_raf_guest']) || isset($_GET['order'])) && ($allow_guests === "yes" || $allow_guests === "1") ? "guest_cookie_true" : "guest_cookie_false"; | |
if (!is_readable($template_path)) { | |
return sprintf('<!-- Could not read "%s" file -->', $template_path); | |
} | |
ob_start(); | |
include $template_path; | |
return ob_get_clean(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment