We’ve all been there. You need one tiny feature, so you search the repository and suddenly you’ve installed a 2MB plugin just to do one thing. The “New Way” is to replace plugins with code snippets. It’s smarter architecture with less bloat.
That’s the Old Way. It’s heavy, it’s cluttered, and it’s unnecessary.
Here are 5 essential WordPress tweaks that show you exactly how to replace plugins with code to keep your site lean and mean.
1. Enable SVG Uploads (The Safe Way) 🎨
WordPress blocks SVGs by default for security, but you don’t need a dedicated plugin to unlock them. This snippet enables SVG support and ensures only Admins can upload them, keeping your site light and secure.
add_filter( 'upload_mimes', function ( $mimes ) {
if ( current_user_can( 'administrator' ) ) {
$mimes['svg'] = 'image/svg+xml';
$mimes['svgz'] = 'image/svg+xml';
}
return $mimes;
} );
add_filter( 'wp_check_filetype_and_ext', function ( $data, $file, $filename, $mimes ) {
$filetype = wp_check_filetype( $filename, $mimes );
return [
'ext' => $filetype['ext'],
'type' => $filetype['type'],
'proper_filename' => $data['proper_filename']
];
}, 10, 4 );
⚠️ Important note: This does not sanitize SVG files. For production or client sites, consider sanitizing SVGs before upload.
2. Kill the Emoji Bloat 📉
Did you know WordPress loads a dedicated JavaScript file on every single page just to detect emojis? If you aren’t using them, that’s pure dead weight.
add_action( 'init', function () {
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
} );
3. Customize Your Login Logo 🏛️
Stop using “Login Customizer” plugins that add bulk to your database. This snippet lets you swap the WordPress logo for your own brand in seconds.
add_action( 'login_enqueue_scripts', function() { ?>
💡 Optional improvement: also change the login URL + title for a fully branded experience.
4. Limit Post Revisions (Database Diet) 🔋
By default, WordPress stores every single save of every post. This bloats your database over time. Instead of a “Database Cleaner” plugin, just cap the revisions at the source.
add_filter( 'wp_revisions_to_keep', function ( $num, $post ) {
return 5; // Keep only the last 5 revisions
}, 10, 2 );
💡 Alternative: you can also define this globally in wp-config.php.
5. Disable XML-RPC (Security Boost) 🛡️
XML-RPC is an old feature often used by hackers for brute-force attacks. If you aren’t using the Jetpack app or remote posting, turn it off with one line instead of a security plugin.
add_filter( 'xmlrpc_enabled', '__return_false' );
⚠️ Only disable this if you’re not using services that depend on it (some apps and integrations still do).
The choice is simple: you can keep piling on plugins until your dashboard feels like a digital hoarders’ nest, or you can start building with intent. When you replace plugins with code, you aren’t just saving disk space you’re taking total control of your site’s performance. Stop searching the repository and start architecting.
Stop searching for a new plugin. Start architecting a better solution.
❓FAQ: Frequently Asked Questions
Is it safe to delete the old plugins?
🛡️ Yes! Once you’ve activated these snippets in Code Snippets Pro, you can safely deactivate and delete the single-purpose plugins.
What if I break something?
That’s the beauty of the Pro version. Our Safe Edit mode detects errors before they happen, so you’ll never see a white screen of death.
Can I use these on all my client sites?
☁️ Absolutely. Save these to your Cloud Library and deploy them to every new build in one click.