Skip to content

Commit

Permalink
Added filter to allow suppressing the "invalid meta" notice
Browse files Browse the repository at this point in the history
  • Loading branch information
Diego committed Mar 17, 2020
1 parent 18c4457 commit b147fab
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions Puc/v4p9/Metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,29 @@ protected static function createFromJson($json, $target) {
$apiResponse = json_decode($json);
if ( empty($apiResponse) || !is_object($apiResponse) ){
$errorMessage = "Failed to parse update metadata. Try validating your .json file with http://jsonlint.com/";
do_action('puc_api_error', new WP_Error('puc-invalid-json', $errorMessage));
trigger_error($errorMessage, E_USER_NOTICE);

$api_error = new WP_Error('puc-invalid-json', $errorMessage);
do_action('puc_api_error', $api_error);

// Allow 3rd parties to suppress the notice, as they might have their own
// error handling mechanism in place
// @link https://github.com/YahnisElsts/plugin-update-checker/issues/347
if(apply_filters('puc_show_trigger_api_response_error', true, $api_error)) {
trigger_error($errorMessage, E_USER_NOTICE);
}
return false;
}

$valid = $target->validateMetadata($apiResponse);
if ( is_wp_error($valid) ){
do_action('puc_api_error', $valid);
trigger_error($valid->get_error_message(), E_USER_NOTICE);

// Allow 3rd parties to suppress the notice, as they might have their own
// error handling mechanism in place
// @link https://github.com/YahnisElsts/plugin-update-checker/issues/347
if(apply_filters('puc_show_trigger_api_response_error', true, $valid)) {
trigger_error($valid->get_error_message(), E_USER_NOTICE);
}
return false;
}

Expand Down

0 comments on commit b147fab

Please sign in to comment.