function add_nofollow_to_outbound_links($content) { // Get site URL for comparison $site_url = parse_url(home_url(), PHP_URL_HOST); // Use regex to find all anchor tags return preg_replace_callback( ‘#]*href=[“\’](.*?)[“\’][^>]*>#is’, function ($matches) use ($site_url) { $href = $matches[1]; $link_tag = $matches[0]; // Skip if it’s an…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
function custom_envira_product_title( $title, $duplicated_product, $image, $post_id ) { $image_url = $image[‘src’]; $image_filename = basename($image_url); //Remove the Product text if you don’t want it to be appended at the end of the image filename return $image_filename . ‘ Product’; } add_filter(…Continue reading
function restrict_multiple_pages_to_admins() { $restricted_pages = array( ‘members’, ‘document’, ‘memebrs’, ‘moderation’, ‘photos’, ‘test-page’, ‘videos’ ); if ( !is_page($restricted_pages) ) { return; // Not one of the restricted pages } if ( !current_user_can(‘administrator’) ) { wp_redirect(home_url()); // Or custom denial page exit;…Continue reading
add_action(‘init’, function () { if (!is_admin()) return; // STOP if SKUs were already generated if (get_option(‘auto_sku_generated’) === ‘yes’) return; // ✅ Immediately mark it done to prevent infinite loops update_option(‘auto_sku_generated’, ‘yes’); // Fetch all published WooCommerce products $args = array(…Continue reading
/** * Title: WooCommerce ShipStation Admin Rates * Description: Adds ShipStation live rates to the WooCommerce admin order screen */ // Exit if accessed directly if (!defined(‘ABSPATH’)) { exit; } class WC_ShipStation_Admin_Rates { // Store the nonce so we can…Continue reading
/** * Production Snippet: FluentCRM + YITH Points * – No debug logs * – No capability checks * – Dynamically builds the FluentCRM hash URL */ /** * 1) Add the “Points and Rewards” tab in FluentCRM */ add_action(‘init’,…Continue reading
/** * Title: Add Percentage Discount to Order Line Items * Description: Adds percentage discount field to WooCommerce order line items in admin * Author: Claude AI * Version: 1.0 * * @package WPCode Snippets * @category Orders */ //…Continue reading
// Allow specific file types for administrators only. function allow_unfiltered_uploads_for_admins( $mimes ) { if ( current_user_can( ‘administrator’ ) ) { $mimes[‘svg’] = ‘image/svg+xml’; $mimes[‘json’] = ‘application/json’; $mimes[‘xml’] = ‘application/xml’; $mimes[‘html’] = ‘text/html’; $mimes[‘htm’] = ‘text/html’; $mimes[‘js’] = ‘application/javascript’; $mimes[‘css’] =…Continue reading
/** * MemberPress Downloads – Add Thumbnail Support * * Enables featured image functionality for MP Downloads files. */ add_action( ‘init’, function() { add_post_type_support( ‘mpdl-file’, ‘thumbnail’ ); });Continue reading