Staying safe and DRY with register_meta()

I know this is probably going to upset, but this is the best way to save an input from a form to a post meta field in WordPress:  update_post_meta( $post->ID, ‘_slug_number_field’, $_POST[ ‘number_field’ ] ); And yes, on its own that line of code is a terrible, no good idea. Most likely, you mentally rewrote it to something like this: if ( isset( $_POST[ ‘number_field’ ] ) && 0 < absint( $_POST[ 'number_field' ] ) ) {   update_post_meta( $post->ID, ‘_slug_number_field’, (int) $_POST[ ‘number_field’ ]  ); } Before I discuss how to make that first line of code acceptable, I […]