/** * Determine daily credits based on membership level. */ function get_daily_credits($membership_level) { switch ($membership_level->name ?? ”) { case ‘Chic’: return 1; case ‘Glamour’: return 5; case ‘Prestige’: return 10; default: return null; } }Continue reading
/** * Claim daily credits via MyCred. */ function mycred_claim_daily_credits() { check_ajax_referer(‘mycred_nonce’, ‘_ajax_nonce’); $messages = mycred_get_messages(); // Ensure the user is logged in if (!is_user_logged_in()) { wp_send_json_error([‘message’ => $messages[‘error_not_logged_in’]]); } // Get user ID and membership level $user_id = get_current_user_id();…Continue reading
/** * AJAX handler for MyCred transactions (credit or debit). */ function mycred_transaction_handler() { // Verify the nonce for security if (!isset($_POST[‘_ajax_nonce’]) || !wp_verify_nonce($_POST[‘_ajax_nonce’], ‘mycred_nonce’)) { wp_send_json_error([‘message’ => ‘Invalid security token.’]); } // Ensure the user is logged in if…Continue reading
if (!function_exists(‘shortcode_show_credits’)) { /** * Shortcode to display MyCred balance with dynamic updates (default black text). */ function shortcode_show_credits($atts) { return generate_mycred_balance_shortcode($atts, ‘black’); } add_shortcode(‘show_credits’, ‘shortcode_show_credits’); } if (!function_exists(‘shortcode_show_credits_white’)) { /** * Shortcode to display MyCred balance with white text…Continue reading
/** * Shortcode to claim daily credits. */ function shortcode_claim_daily_credits() { if (!is_user_logged_in()) { return ‘ Please log in to claim your daily credits. ‘; } $user_id = get_current_user_id(); $last_claim = get_user_meta($user_id, ‘_last_daily_claim’, true); if ($last_claim === date(‘Y-m-d’)) { return…Continue reading
add_action(‘wp_head’, function () { ?>Continue reading
ภาษาไทย: https : //pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-3968759292085187Continue reading
/** * Removes the ‘woocommerce_package_rates’ filter added by the Caddy plugin. * * Removes the filter that hides other WooCommerce shipping rates * when free shipping is available, allowing all rates to show. * * @author Mike Valera * @plugin…Continue reading
function pw_edd_prevent_duplicate_purchase( $valid_data, $posted ) { $cart_contents = edd_get_cart_contents(); foreach( $cart_contents as $item ) { if( edd_has_user_purchased( get_current_user_id(), $item[‘id’] ) ) { edd_set_error( ‘duplicate_item’, ‘You have already purchased this item so may not purchase it again’ ); } } }…Continue reading
/** * Allow SVG uploads for administrator users. * * @param array $upload_mimes Allowed mime types. * * @return mixed */ add_filter( ‘upload_mimes’, function ( $upload_mimes ) { // By default, only administrator users are allowed to add SVGs. //…Continue reading