Generates nofollow To Outbound Links

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 Files Upload (copy)

/** * 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

custom-restrict-pages-to-admins

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

Admin ShipStation rates

/** * 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

FluentCRM with YITH points tab plus actions

/** * 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

Admin order – Discount per product

/** * 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

custom-allow_unfiltered_uploads_for_admins

// 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