Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue-1153: Email Error Notifications #1180

Merged
merged 3 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions admin/apple-actions/index/class-push.php
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,14 @@ private function push( $user_id = null ): void {
$error_message = __( 'There has been an error with the Apple News API: ', 'apple-news' ) . esc_html( $original_error_message );
}

/**
* Actions to be taken after an article failed to be pushed to Apple News.
*
* @param int $post_id The ID of the post.
* @param string $original_error_message The original error message.
*/
do_action( 'apple_news_after_push_failure', $this->id, $original_error_message );

throw new Action_Exception( esc_html( $error_message ) );
}

Expand Down
7 changes: 4 additions & 3 deletions includes/apple-push-api/request/class-request.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ private function parse_response( $response, $json = true, $type = 'post', $meta

// Get the admin email.
$admin_email = filter_var( $settings['apple_news_admin_email'], FILTER_VALIDATE_EMAIL );

if ( empty( $admin_email ) ) {
return; // TODO Fix inconsistent return value.
}
Expand All @@ -191,8 +192,8 @@ private function parse_response( $response, $json = true, $type = 'post', $meta
if ( 'yes' === $settings['use_remote_images'] ) {
$body .= esc_html__( 'Use Remote images enabled ', 'apple-news' );
} elseif ( ! empty( $bundles ) ) {
$body .= "\n" . esc_html__( 'Bundled images', 'apple-news' ) . ":\n";
$body .= implode( "\n", $bundles );
$body .= "\n" . esc_html__( 'Bundled images', 'apple-news' ) . ":\n";
$body .= implode( "\n", $bundles );
} else {
$body .= esc_html__( 'No bundled images found.', 'apple-news' );
}
Expand All @@ -210,7 +211,7 @@ private function parse_response( $response, $json = true, $type = 'post', $meta
*
* @since 1.4.4
*
* @param string|array $headers Optional. Additional headers.
* @param string|array $headers Optional. Additional headers.
*/
$headers = apply_filters( 'apple_news_notification_headers', '' );

Expand Down