Confirm buffer is not empty before erasing

Confirm file_exists before opening. For PHP 5.3 or earlier, check if
safe_mode is active to avoid errors.
Use wp_send_json() WordPress function for AJAX

The header(), json_encode(), and die(), functions are all executed with
a better logical routine that should provide consistent results.
Allow downloadable products URL to be relative
sync fork with master
Allow home_url() to determine the scheme
Remove diff code block from wc-customer
Merge pull request #5555 from toddlahman/master

Confirm buffer is not empty before erasing