This website uses cookies to allow us to see how the site is used. If you continue to use this site, we assume that you are okay with this. If you want to use the sites without cookies, please see our privacy policy.

Enable Automatic Updates for WordPress Plugins and Themes

With version 3.7 WordPress introduced automatic updates. By default, these are on for maintenance and security releases only, but the underlying code is smart enough to support updates for plugins and themes. Here’s a simple plugin that will enable automatic updates for themes:

/**
 * Plugin Name: Enable Automatic Updates for Themes
 */
add_filter( 'auto_update_theme', '__return_true' );

And here’s one for plugins:

/**
 * Plugin Name: Enable Automatic Updates for Plugins
 */
add_filter( 'auto_update_plugin', '__return_true' );

Please note that these will work only if your host is configured to support automatic WordPress updates. You can learn more about configuring and debugging automatic background updates in the codex.

Close WordPress Comments on All Posts and Pages Temporarily

The following snippet will close commenting throughout the whole website (or network, if network-activated), but will retain the original comment status on all posts and pages, so you can reopen commenting at any time.

add_filter( 'comments_open', '__return_false' );

It might come useful in several cases, like when you’re experiencing a massive attack of comment spam, or perhaps your website is under heavy load, and comments are causing your page cache to get busted. Or maybe you’re just going for vacation and don’t want to end up with a pile of comments you have to respond to when you get back 😉