Debugging WordPress on localhost
Airplane Mode uses the pre_http_request filter to block external requests. Nice job!
I installed Airplane Mode and wrote a shell script to disable all plugins. More on the script below.
Blocking External Requests from WordPress
I received additional suggestions after I wrote my script.
I would like to thank everyone who explained how to block external requests on localhost.
Block external URL requests by defining WP_HTTP_BLOCK_EXTERNAL as true and this will only allow localhost and your blog to make requests. The constant WP_ACCESSIBLE_HOSTS will allow additional hosts to go through for requests.
This wp-config.php file can be used in multiple environments (local, staging, production). It works by detecting the server hostname and defining different constants depending on which hostname is used.
I do something similar with wp-load.php, but his solution does not require editing core.
Importing a Production Database to localhost
I wrote a bash script to import a production database, and avoid the plugin update error.
import_wordpress_db_to_localhost is shown below.
Script disables plugins, sets blog to “private” and adds “LOCAL:” to a site’s name. It is easy to use this script for multiple sites.
alias import_blog='import_wordpress_db_for_local_use.sh DB SQL login password'
No connection errors today, using AirPlane Mode and my import script.
I learned how to block Gravatar and external font loaders, too.