Customizer APIs in 4.6 for Setting Validation and Notifications
Links
The Definitive Guide To PHP’s isset() And empty()
Check out The Definitive Guide To PHP’s isset()
And empty()
for a deep dive on these faux-function language constructs.
TL;DR
- always develop with error reporting turned to 11 (and fix all real errors)
- always use
empty
orisset
for variables that may legitimately not exist- never use
empty
orisset
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 toisset($array['key'])
calledarray_key_exists
. This function specifically does what it says: it returnstrue
if an array key exists, regardless of the value of that key. That makes it possible to detectnull
values in arrays
Note that 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 null
(although wp.customize.Value
doesn’t directly facilitate set
ing this value).
/via @Josh412
Keep a Changelog
Some great merits of keeping changelogs along with some best practices for managing them: Keep a Changelog.