Add data-attr to links

function add_data_attributes_to_content_links( $content ) { if ( class_exists( ‘DOMDocument’ ) ) { // Use the mb_convert_encoding to handle different character sets correctly // and suppress HTML errors with the @ operator and LIBXML options. $dom = new DOMDocument(); @$dom->loadHTML( mb_convert_encoding(…Continue reading

Redirect user to 3blmedia.com

add_action( ‘template_redirect’, function() { // Define the external website URL $external_url = ‘https://www.3blmedia.com/?ref=https://3blmedia.net’; // Check if we are NOT in the admin panel and NOT on the login page if ( ! is_admin() && strpos($_SERVER[‘PHP_SELF’], ‘wp-login.php’) === false ) {…Continue reading

mobile redirect (chatgpt)

// Mobile redirect (admin INCLUDED, cache-friendly) add_action(‘template_redirect’, ‘rd_mobile_redirect’, 10); function rd_mobile_redirect() { // Skip only AJAX/cron/preview/REST to avoid breaking editors & API if (wp_doing_ajax() || wp_doing_cron() || is_preview() || defined(‘REST_REQUEST’)) return; $req_uri = $_SERVER[‘REQUEST_URI’] ?? ‘/’; $path = strtok($req_uri, ‘?’);…Continue reading

Set Stripe as default gateway in checkout

add_action(‘template_redirect’, ‘define_default_payment_gateway’); function define_default_payment_gateway() { // Prevent execution during admin, AJAX, or scheduled tasks if (is_admin() || wp_doing_ajax() || wp_doing_cron()) { return; } if (is_checkout() && !is_wc_endpoint_url()) { WC()->session->set(‘chosen_payment_method’, ‘stripe’); } }Continue reading

Discounts for Trade users FE

add_action(‘woocommerce_cart_calculate_fees’, ‘apply_trade_discount_by_category’, 20, 1); function apply_trade_discount_by_category($cart) { if (is_admin() && !defined(‘DOING_AJAX’)) return; // Ensure it only runs on the front-end $user = wp_get_current_user(); // Only apply discount for users with the “trade” role if (!in_array(‘trade’, (array) $user->roles)) { return; }…Continue reading

Discounts for Sister org users FE

add_action(‘woocommerce_cart_calculate_fees’, ‘apply_sister_discount_by_category’, 20, 1); function apply_sister_discount_by_category($cart) { if (is_admin() && !defined(‘DOING_AJAX’)) return; // Ensure it only runs on the front-end $user = wp_get_current_user(); // Only apply discount for users with the “sister” role if (!in_array(‘sister’, (array) $user->roles)) { return; }…Continue reading

Discounts for Full timer users FE

add_action(‘woocommerce_cart_calculate_fees’, ‘apply_fulltimer_discount_by_category’, 20, 1); function apply_fulltimer_discount_by_category($cart) { if (is_admin() && !defined(‘DOING_AJAX’)) return; // Ensure it only runs on the front-end $user = wp_get_current_user(); // Only apply discount for users with the “fulltimer” role if (!in_array(‘fulltimer’, (array) $user->roles)) { return; }…Continue reading