From ca55291263bad7ab6da59f6f6e530d3bc2c3623b Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Mon, 20 Feb 2017 12:04:53 +0000 Subject: [PATCH] Skip plain text --- includes/class-wc-structured-data.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/includes/class-wc-structured-data.php b/includes/class-wc-structured-data.php index fd52c6bd658..83b3f0675ff 100644 --- a/includes/class-wc-structured-data.php +++ b/includes/class-wc-structured-data.php @@ -33,7 +33,7 @@ class WC_Structured_Data { add_action( 'woocommerce_email_order_details', array( $this, 'generate_order_data' ), 20, 3 ); // Output structured data. - add_action( 'woocommerce_email_order_details', array( $this, 'output_structured_data' ), 30 ); + add_action( 'woocommerce_email_order_details', array( $this, 'output_email_structured_data' ), 30, 3 ); add_action( 'wp_footer', array( $this, 'output_structured_data' ), 10 ); } @@ -121,6 +121,20 @@ class WC_Structured_Data { return array_filter( apply_filters( 'woocommerce_structured_data_type_for_page', $types ) ); } + /** + * Makes sure email structured data only outputs on non-plain text versions. + * + * @param WP_Order $order Order data. + * @param bool $sent_to_admin Send to admin (default: false). + * @param bool $plain_text Plain text email (default: false). + */ + public function output_email_structured_data( $order, $sent_to_admin = false, $plain_text = false ) { + if ( $plain_text ) { + return; + } + $this->output_structured_data(); + } + /** * Sanitizes, encodes and outputs structured data. *