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 user_has_activation_key($user_id) { | |
global $wpdb; | |
$user = $wpdb->get_row($wpdb->prepare( | |
"SELECT user_activation_key FROM {$wpdb->users} WHERE ID = %d", | |
$user_id | |
)); | |
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) { |
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_filter('wpgens_raf_code','gens_raf_code',10,1); | |
function gens_raf_code($raf_code) { | |
$current_user = wp_get_current_user(); | |
if(!user_has_orders($current_user->ID) && !in_array('editor', $current_user->roles)) { | |
return 'Referral code is available only to users with orders or Editors'; | |
} | |
return $raf_code; |
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 to get the referrer user ID | |
function get_referrer_user_id($rafID) { | |
// Check if the referrer is a guest using email | |
if (filter_var($rafID, FILTER_VALIDATE_EMAIL)) { | |
return $rafID; | |
} | |
// Retrieve the referrer user ID based on the custom meta field 'gens_referral_id' | |
$gens_users = get_users(array( |
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
const wpgensUTMCookieManage = { | |
set: function (name, value, days) { | |
const expires = days ? new Date(Date.now() + days * 24 * 60 * 60 * 1000).toUTCString() : ''; | |
const domain = this.getCleanHost(window.location.href) ? '; domain=' + this.getCleanHost(window.location.href) : ''; | |
document.cookie = `${name}=${encodeURIComponent(value || '')}; expires=${expires}${domain}; path=/`; | |
}, | |
get: function (name) { | |
const cookieArray = document.cookie.split(';'); | |
for (let i = 0; i < cookieArray.length; i++) { | |
let cookie = cookieArray[i].trim(); |
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_filter('woocommerce_apply_with_individual_use_coupon', 'filter_apply_with_individual_use_coupon', 10, 4); | |
function filter_apply_with_individual_use_coupon($apply, $the_coupon, $applied_coupon, $applied_coupons) { | |
// Check if the coupon code starts with 'ref' | |
if (strpos($the_coupon->get_code(), 'ref') === 0) { | |
$apply = true; | |
} | |
return $apply; | |
} |
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
function wpgens_get_user_email_by_meta_or_email($meta_value) { | |
// Check if the meta_value is a valid email | |
if (is_email($meta_value)) { | |
return $meta_value; // If it's a valid email, return it directly | |
} | |
$args = array( | |
'meta_key' => 'gens_referral_id', | |
'meta_value' => $meta_value, |
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 | |
/******************************************************************************/ | |
/******************************************************************************/ | |
class CRBSWooCommerce | |
{ | |
/**************************************************************************/ | |
function __construct() |
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 | |
// Car rental plugin - booking form | |
add_action('woocommerce_new_order', 'wpgens_save_source_tracker_meta', 10, 1); | |
function save_source_tracker_meta($order_id) | |
{ | |
if (!isset($_COOKIE['_wpgens_st_data'])) { | |
return; | |
} |
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_action( 'after_setup_theme', function() { | |
$current_user = wp_get_current_user(); | |
/* is guest? */ | |
if ( 0 == $current_user->ID ) { | |
return; | |
} else { | |
/* is not administrator */ |
NewerOlder