Category: WordPress

  • Page Generation Graph for WordPress

    Page Generation Graph for WordPress

    At work, one of the more interesting customizations we have on WordPress.com for our VIP clients is a dashboard that contains custom widgets.  One of them is a page generation graph that shows the average page generation time for their site compared to all others.  That way they can judge their code performance against a…

  • Quick Tip: DreamHost cron and WP-CLI

    Quick Tip: DreamHost cron and WP-CLI

    If you’re hosting your WordPress website on DreamHost, and use their cron system to offload your WordPress faux-cron for better reliability, be careful of what version of PHP you have in your code. I recently had an issue where my cron events weren’t firing, and after enabling email output, I ended up with something like…

  • Blogging Anonymously

    Blogging Anonymously

    An interesting problem I came across recently was how to set up a WordPress blog with an anonymous user.  Now, a simple way would be to create a brand new user with fake information, but that’s too easy. After looking for some prior art, I found the Anonymizer plugin in the WordPress.org plugin repository.  Unfortunately, it’s…

  • Logging Failed Redirects

    Logging Failed Redirects

    WordPress has a built-in function called wp_safe_redirect().  This allows you to create redirects in code, but only to whitelisted domains (via the allowed_redirect_hosts filter). The downside to this is that you have to remember to whitelist the domains.  It’s easy to forget if you’re doing a lot of redirects, for instance with the WPCOM Legacy…

  • Purging All The Caches!

    Purging All The Caches!

    One of the best ways to ensure that a WordPress site–well any site really–stays performant and not broken is by leveraging caching. WordPress by default doesn’t do much caching other than some in-memory caching of objects, and the odd database caching via the Transients API. This site currently has three layers of caching: PHP OPcache…

  • Disabling WordPress Faux Cron

    Disabling WordPress Faux Cron

    The WordPress WP-Cron system is a decently okay faux cron system, but it has its problems, such as running on frontend requests and not running if no requests are coming through. WP-Cron works by: on every page load, a list of scheduled tasks is checked to see what needs to be run. Any tasks scheduled…

  • Quick Tip: Force Enable Auto-Updates in WordPress

    Quick Tip: Force Enable Auto-Updates in WordPress

    I know that auto-updates are a bit of a (#wpdrama) touchy subject, but I believe in them. In an mu-plugin I enable all auto-updates like so:

  • Query Caching (and a little extra)

    Query Caching (and a little extra)

    By default, WordPress does not cache WP_Query queries.  Doing so can greatly improve performance.  The way I do this is via the Advanced Post Cache plugin: By running this plugin (hopefully as an mu-plugin) with a persistent object cache, WP_Query calls, along with get_post() calls (only if suppress_filters is false) will be cached. Bonus! Now…

  • Auto-enable WP_DEBUG with a cookie

    Auto-enable WP_DEBUG with a cookie

    One of the most important things to do when working on new themes, plugins, or debugging issues in WordPress is to turn on WP_DEBUG.  According to the Codex: WP_DEBUG is a PHP constant (a permanent global variable) that can be used to trigger the “debug” mode throughout WordPress. It is assumed to be false by…