Uncategorized

  • add_image_size does nothing to images already uploaded

    add_image_size() registers a size that WordPress will generate at upload time. Adding one to a theme has no effect on the several thousand images already in the library,…

  • filter_var validates better than the regex you were about to write

    Email and URL validation by regular expression is a well-known way to reject valid input. The correct pattern for an address is famously unreadable, and the shortened versions…

  • requestAnimationFrame instead of setTimeout for animation

    setTimeout(fn, 16) approximates 60fps and is wrong in both directions: it keeps firing in a background tab, burning battery on frames nobody sees, and it drifts out of…

  • WP-Cron only runs when someone visits

    WP-Cron is not cron. It is a check performed on page load: if a scheduled task is overdue, WordPress fires a loopback request to run it. On a…

  • Exponential backoff needs jitter or everything retries together

    Backing off exponentially stops a failing dependency being hammered. What it does not stop is synchronisation: every client that failed at the same moment retries at the same…

  • An untested backup is not a backup

    A backup job that exits zero every night proves that the job ran, not that the output can be restored. Truncated dumps, a mysqldump that hit a lock…

  • The Xdebug profiler tells you where, not why

    A profile answers “which functions consumed the time” precisely and says nothing about the reason. The most common finding is that the top entry is PDOStatement::execute, which is…

  • Migrating PSR-0 to PSR-4 removes a directory level

    PSR-0 mapped the entire namespace onto the path, so AppReportBuilder had to live at src/App/Report/Builder.php — the vendor and package name repeated inside a directory that was already…

  • PHPUnit data providers turn six tests into one

    Testing the same behaviour across several inputs usually produces six near-identical methods, and when the assertion needs changing it has to change six times. A data provider separates…

  • Composer prefer-dist and prefer-source are not interchangeable

    Composer can install a package either as a downloaded archive or as a git clone. The default depends on package metadata and on whether the version is a…