diff --git a/admin/apple-actions/index/class-push.php b/admin/apple-actions/index/class-push.php index b679e598..bed4261a 100644 --- a/admin/apple-actions/index/class-push.php +++ b/admin/apple-actions/index/class-push.php @@ -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 ) ); } diff --git a/includes/apple-push-api/request/class-request.php b/includes/apple-push-api/request/class-request.php index 1c29a018..844904cb 100644 --- a/includes/apple-push-api/request/class-request.php +++ b/includes/apple-push-api/request/class-request.php @@ -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. } @@ -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' ); } @@ -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', '' );