Category: WordPress
-
Half Baked Idea: Limiting WordPress Image Upload Sizes
in WordPressLimit image upload size in WordPress media library by using the `wp_handle_upload_prefilter` filter. Implement a custom function to check and restrict the size of uploaded images. Utilize PHP code to set a maximum size limit and display an error message if the file exceeds it. Add this functionality to your WordPress site.
-
Quick Tip: Get Size of Revisions in WordPress
in WordPressMonitoring and managing data bloat in a WordPress site can be crucial. The introduction of the block editor has led to a surge in post revisions, which can clog up the database. Conducting a revision data audit using SQL queries can reveal the extent of unnecessary data accumulation, highlighting the importance of setting limits to…
-
Quick Tip: Script Debugging in WordPress
in WordPressWhen debugging core WordPress scripts, dealing with cached copies like in `script-loader.php` can be tricky. You can apply a unique `ver` argument to core scripts on each refresh using a filter. This ensures you get the most recent version from page and browser cache. Remember to enable `SCRIPT_DEBUG` when debugging core scripts.
-
Quick Tip: Disable WordPress Block Editor Fullscreen Mode
in WordPressEditing posts in WordPress can be frustrating when the block editor keeps defaulting to fullscreen mode. Utilize this PHP code snippet to disable the fullscreen mode by default for a smoother editing experience. Credits to Jean-Baptiste Audras for sharing this helpful solution.
-
Quick Tip: Export WordPress SQL output via WP-CLI
Learn how to run custom SQL queries on your WordPress database using a small WP-CLI command. The command supports different output formats like table, CSV, JSON, and more. Plus, it includes a dry run option for safety. No need to rely on `wp db query` anymore!
-
Deleting Old Post Revisions in WordPress with WP-CLI
in WordPressWorking with a client’s large database, I crafted a custom WP-CLI command to purge post revisions based on specific criteria, saving backups of those deleted. This script efficiently prunes revisions older than a year and prior to post publication, reducing the overall database size prior to a site migration.