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

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

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

Enable HTTP Strict Transport Security (HSTS) in WordPress (copy)

/** * Enables the HTTP Strict Transport Security (HSTS) header in WordPress. * Includes preloading with subdomain support. */ function tg_enable_strict_transport_security_hsts_header_wordpress() { header( ‘Strict-Transport-Security: max-age=31536000; includeSubDomains; preload’ ); } add_action( ‘send_headers’, ‘tg_enable_strict_transport_security_hsts_header_wordpress’ );Continue reading