In wp-dev-lib we have followed a convention of naming our project-specific PHP_CodeSniffer rulesets as phpcs.ruleset.xml. We named the ruleset files with “phpcs” in the filename to make it clear what kind of ruleset it is, and so that it would conflict with any other tool that may also want to use this name. Nevertheless, PHP_CodeSniffer … Continue reading Registering Project-specific PHP_CodeSniffer Rulesets in PhpStorm
We’re pleased to announce the v0.5 release of the Customize Posts plugin! Check out my rough release demo video: Key features in this release: Postmeta support A framework for registering postmeta types, adding controls, and previewing changes. Page template Changes to the page template can now be previewed, both in the Customizer and from the edit page admin screen. … Continue reading Customize Posts v0.5 Released
PhpStorm has excellent out of the box support for running unit tests using the PHPUnit testing framework. It also provides you with great code coverage statistics of your unit tests. The challenge however is getting it setup properly and actually running your WordPress unit tests. On my local development environment, I specifically use VVV and ideally I wanted … Continue reading Running PHPUnit tests with VVV and PhpStorm
On the command line shell, there is a magic symbol “-” (hyphen). When dealing with streams, it can refer to STDIN or STDOUT. When used in the context of the cd command, the – refers to the previous directory (it is the same as $OLDPWD). So you can switch between two directories by repeatedly entering … Continue reading Referring to the Previous Git Commit
Check out The Definitive Guide To PHP’s
empty() for a deep dive on these faux-function language constructs.
- always develop with error reporting turned to 11 (and fix all real errors)
- always use
isset for variables that may legitimately not exist
- never use
isset for variables that should exist
Note: To deal with PHP notices in 3rd-party code, if you can’t contribute fixes upstream you may want to consider using a plugin like Zack Tollman’s Ostrichcize.
it [is] impossible to distinguish between a variable that does not exist and a variable that has the value
null. […] Specifically for arrays, there’s an alternative to
array_key_exists. This function specifically does what it says: it returns
true if an array key exists, regardless of the value of that key. That makes it possible to detect
null values in arrays
array_key_exists() is used in
WP_Customize_Manager::post_value() for this reason. Since the Customizer’s dirty setting values are encoded as JSON it is possible for a post value to be
wp.customize.Value doesn’t directly facilitate
seting this value).
Some great merits of keeping changelogs along with some best practices for managing them: Keep a Changelog.
We use Varying Vagrant Vagrants (VVV) as the development environment for as many projects as we can. It provides a great foundation not only for developing client projects but also for core development itself.
Continue reading Running PHPUnit Tests Outside VVV
We often do bi-weekly sprint iteration demos for our client projects. In these demos, we get the chance to showcase the work we’ve done over the past couple weeks.
Continue reading Creating Project Demo Screencasts
When committing to SVN, “there is no reset button”. You cannot purge the memory of a commit once it has been made in an SVN repo (e.g. a theme on WordPress.com VIP, a plugin in the WordPress.org directory, or even especially WordPress core at develop.svn.wordpress.org). That is, in SVN there is no commit amending, hard … Continue reading Sanity check pre-commit hook for SVN
As seen previously on this blog, in Contributing to WordPress Core via GitHub and Streamlining Contributions to WordPress Core via GitHub, there are instructions for how to get a Git repo set up for committing patches for WordPress Core. These posts also include instructions for how to set up Travis CI to restrict reporting linting errors to just the scope of the changed lines … Continue reading Git pre-commit hook for WordPress development