Skip plain text

This commit is contained in:
Mike Jolley 2017-02-20 12:04:53 +00:00
parent 4c75f2b7a2
commit ca55291263
1 changed files with 15 additions and 1 deletions

View File

@ -33,7 +33,7 @@ class WC_Structured_Data {
add_action( 'woocommerce_email_order_details', array( $this, 'generate_order_data' ), 20, 3 ); add_action( 'woocommerce_email_order_details', array( $this, 'generate_order_data' ), 20, 3 );
// Output structured data. // 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 ); 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 ) ); 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. * Sanitizes, encodes and outputs structured data.
* *