Automattic / custom-metadata

A WordPress plugin that provides an easy way to add custom fields to your object types (post, pages, custom post types, users)
https://wordpress.org/plugins/custom-metadata/
193 stars 46 forks source link

Can't have a default value of "0" for a number field #131

Closed shantanu2704 closed 6 years ago

shantanu2704 commented 6 years ago

Fixes #115

Use isset() instead of empty(). PHP considers 0(0 as an integer) to be empty. Thus the default value gets applied. isset() determines if the variable is set and so the default value is not applied to field_id when its value is '0'.

sboisvert commented 6 years ago

This is a good fix. I suspect I mentioned it in my other feedback but adding the "Why" of this fix (even if it's in the linked issue) would be a good idea.