Drop repeated conditions for rtl aligning, use variable instead
This commit is contained in:
parent
6aed418b6f
commit
a894e7b241
|
@ -177,6 +177,27 @@ class WC_Emails {
|
|||
* Init email classes.
|
||||
*/
|
||||
public function init() {
|
||||
// Global variable for aligning to be used in email templates
|
||||
global $_align;
|
||||
|
||||
if ( is_rtl() ) {
|
||||
$_align = array(
|
||||
'left' => 'right',
|
||||
'right' => 'left',
|
||||
'rtl' => 'ltr',
|
||||
'ltr' => 'rtl',
|
||||
);
|
||||
} else {
|
||||
$_align = array(
|
||||
'left' => 'left',
|
||||
'right' => 'right',
|
||||
'rtl' => 'rtl',
|
||||
'ltr' => 'ltr',
|
||||
);
|
||||
}
|
||||
|
||||
$_align = apply_filters( 'woocommerce_email_aligning', $_align );
|
||||
|
||||
// Include email classes
|
||||
include_once( dirname( __FILE__ ) . '/emails/class-wc-email.php' );
|
||||
|
||||
|
|
|
@ -20,15 +20,17 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
exit;
|
||||
}
|
||||
|
||||
global $_align;
|
||||
|
||||
?><table id="addresses" cellspacing="0" cellpadding="0" style="width: 100%; vertical-align: top;" border="0">
|
||||
<tr>
|
||||
<td class="td" style="text-align:<?php echo is_rtl() ? 'right' : 'left'; ?>; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;" valign="top" width="50%">
|
||||
<td class="td" style="text-align:<?php echo $_align['left']; ?>; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;" valign="top" width="50%">
|
||||
<h3><?php _e( 'Billing address', 'woocommerce' ); ?></h3>
|
||||
|
||||
<p class="text"><?php echo $order->get_formatted_billing_address(); ?></p>
|
||||
</td>
|
||||
<?php if ( ! wc_ship_to_billing_address_only() && $order->needs_shipping_address() && ( $shipping = $order->get_formatted_shipping_address() ) ) : ?>
|
||||
<td class="td" style="text-align:<?php echo is_rtl() ? 'right' : 'left'; ?>; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;" valign="top" width="50%">
|
||||
<td class="td" style="text-align:<?php echo $_align['left']; ?>; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;" valign="top" width="50%">
|
||||
<h3><?php _e( 'Shipping address', 'woocommerce' ); ?></h3>
|
||||
|
||||
<p class="text"><?php echo $shipping; ?></p>
|
||||
|
|
|
@ -20,6 +20,8 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
global $_align;
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html <?php language_attributes(); ?>>
|
||||
|
@ -27,8 +29,8 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
<meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo( 'charset' ); ?>" />
|
||||
<title><?php echo get_bloginfo( 'name', 'display' ); ?></title>
|
||||
</head>
|
||||
<body <?php echo is_rtl() ? 'rightmargin' : 'leftmargin'; ?>="0" marginwidth="0" topmargin="0" marginheight="0" offset="0">
|
||||
<div id="wrapper" dir="<?php echo is_rtl() ? 'rtl' : 'ltr'?>">
|
||||
<body <?php echo $_align['left']; ?>margin="0" marginwidth="0" topmargin="0" marginheight="0" offset="0">
|
||||
<div id="wrapper" dir="<?php echo $_align['ltr']; ?>">
|
||||
<table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">
|
||||
<tr>
|
||||
<td align="center" valign="top">
|
||||
|
|
|
@ -31,9 +31,9 @@ do_action( 'woocommerce_email_before_order_table', $order, $sent_to_admin, $plai
|
|||
<table class="td" cellspacing="0" cellpadding="6" style="width: 100%; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;" border="1">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="td" scope="col" style="text-align:<?php echo is_rtl() ? 'right' : 'left'; ?>;"><?php _e( 'Product', 'woocommerce' ); ?></th>
|
||||
<th class="td" scope="col" style="text-align:<?php echo is_rtl() ? 'right' : 'left'; ?>;"><?php _e( 'Quantity', 'woocommerce' ); ?></th>
|
||||
<th class="td" scope="col" style="text-align:<?php echo is_rtl() ? 'right' : 'left'; ?>;"><?php _e( 'Price', 'woocommerce' ); ?></th>
|
||||
<th class="td" scope="col" style="text-align:<?php echo $_align['left']; ?>;"><?php _e( 'Product', 'woocommerce' ); ?></th>
|
||||
<th class="td" scope="col" style="text-align:<?php echo $_align['left']; ?>;"><?php _e( 'Quantity', 'woocommerce' ); ?></th>
|
||||
<th class="td" scope="col" style="text-align:<?php echo $_align['left']; ?>;"><?php _e( 'Price', 'woocommerce' ); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -52,8 +52,8 @@ do_action( 'woocommerce_email_before_order_table', $order, $sent_to_admin, $plai
|
|||
foreach ( $totals as $total ) {
|
||||
$i++;
|
||||
?><tr>
|
||||
<th class="td" scope="row" colspan="2" style="text-align:<?php echo is_rtl() ? 'right' : 'left'; ?>; <?php echo ( 1 === $i ) ? 'border-top-width: 4px;' : ''; ?>"><?php echo $total['label']; ?></th>
|
||||
<td class="td" style="text-align:<?php echo is_rtl() ? 'right' : 'left'; ?>; <?php echo ( 1 === $i ) ? 'border-top-width: 4px;' : ''; ?>"><?php echo $total['value']; ?></td>
|
||||
<th class="td" scope="row" colspan="2" style="text-align:<?php echo $_align['left']; ?>; <?php echo ( 1 === $i ) ? 'border-top-width: 4px;' : ''; ?>"><?php echo $total['label']; ?></th>
|
||||
<td class="td" style="text-align:<?php echo $_align['left']; ?>; <?php echo ( 1 === $i ) ? 'border-top-width: 4px;' : ''; ?>"><?php echo $total['value']; ?></td>
|
||||
</tr><?php
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,16 +20,18 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|||
exit;
|
||||
}
|
||||
|
||||
global $_align;
|
||||
|
||||
foreach ( $items as $item_id => $item ) :
|
||||
if ( apply_filters( 'woocommerce_order_item_visible', true, $item ) ) {
|
||||
$product = $item->get_product();
|
||||
?>
|
||||
<tr class="<?php echo esc_attr( apply_filters( 'woocommerce_order_item_class', 'order_item', $item, $order ) ); ?>">
|
||||
<td class="td" style="text-align:<?php echo is_rtl() ? 'right' : 'left'; ?>; vertical-align:middle; border: 1px solid #eee; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; word-wrap:break-word;"><?php
|
||||
<td class="td" style="text-align:<?php echo $_align['left']; ?>; vertical-align:middle; border: 1px solid #eee; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; word-wrap:break-word;"><?php
|
||||
|
||||
// Show title/image etc
|
||||
if ( $show_image ) {
|
||||
echo apply_filters( 'woocommerce_order_item_thumbnail', '<div style="margin-bottom: 5px"><img src="' . ( $product->get_image_id() ? current( wp_get_attachment_image_src( $product->get_image_id(), 'thumbnail' ) ) : wc_placeholder_img_src() ) . '" alt="' . esc_attr__( 'Product image', 'woocommerce' ) . '" height="' . esc_attr( $image_size[1] ) . '" width="' . esc_attr( $image_size[0] ) . '" style="vertical-align:middle; margin-' . ( is_rtl() ? 'left' : 'right' ) . ': 10px;" /></div>', $item );
|
||||
echo apply_filters( 'woocommerce_order_item_thumbnail', '<div style="margin-bottom: 5px"><img src="' . ( $product->get_image_id() ? current( wp_get_attachment_image_src( $product->get_image_id(), 'thumbnail' ) ) : wc_placeholder_img_src() ) . '" alt="' . esc_attr__( 'Product image', 'woocommerce' ) . '" height="' . esc_attr( $image_size[1] ) . '" width="' . esc_attr( $image_size[0] ) . '" style="vertical-align:middle; margin-' . $_align['right'] . ': 10px;" /></div>', $item );
|
||||
}
|
||||
|
||||
// Product name
|
||||
|
@ -53,15 +55,15 @@ foreach ( $items as $item_id => $item ) :
|
|||
do_action( 'woocommerce_order_item_meta_end', $item_id, $item, $order, $plain_text );
|
||||
|
||||
?></td>
|
||||
<td class="td" style="text-align:<?php echo is_rtl() ? 'right' : 'left'; ?>; vertical-align:middle; border: 1px solid #eee; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;"><?php echo apply_filters( 'woocommerce_email_order_item_quantity', $item->get_quantity(), $item ); ?></td>
|
||||
<td class="td" style="text-align:<?php echo is_rtl() ? 'right' : 'left'; ?>; vertical-align:middle; border: 1px solid #eee; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;"><?php echo $order->get_formatted_line_subtotal( $item ); ?></td>
|
||||
<td class="td" style="text-align:<?php echo $_align['left']; ?>; vertical-align:middle; border: 1px solid #eee; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;"><?php echo apply_filters( 'woocommerce_email_order_item_quantity', $item->get_quantity(), $item ); ?></td>
|
||||
<td class="td" style="text-align:<?php echo $_align['left']; ?>; vertical-align:middle; border: 1px solid #eee; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;"><?php echo $order->get_formatted_line_subtotal( $item ); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
||||
if ( $show_purchase_note && is_object( $product ) && ( $purchase_note = $product->get_purchase_note() ) ) : ?>
|
||||
<tr>
|
||||
<td colspan="3" style="text-align:<?php echo is_rtl() ? 'right' : 'left'; ?>; vertical-align:middle; border: 1px solid #eee; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;"><?php echo wpautop( do_shortcode( wp_kses_post( $purchase_note ) ) ); ?></td>
|
||||
<td colspan="3" style="text-align:<?php echo $_align['left']; ?>; vertical-align:middle; border: 1px solid #eee; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;"><?php echo wpautop( do_shortcode( wp_kses_post( $purchase_note ) ) ); ?></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
global $_align;
|
||||
|
||||
// Load colors
|
||||
$bg = get_option( 'woocommerce_email_background_color' );
|
||||
$body = get_option( 'woocommerce_email_body_background_color' );
|
||||
|
@ -104,7 +106,7 @@ $text_lighter_20 = wc_hex_lighter( $text, 20 );
|
|||
font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif;
|
||||
font-size: 14px;
|
||||
line-height: 150%;
|
||||
text-align: <?php echo is_rtl() ? 'right' : 'left'; ?>;
|
||||
text-align: <?php echo $_align['left']; ?>;
|
||||
}
|
||||
|
||||
.td {
|
||||
|
@ -133,7 +135,7 @@ h1 {
|
|||
font-weight: 300;
|
||||
line-height: 150%;
|
||||
margin: 0;
|
||||
text-align: <?php echo is_rtl() ? 'right' : 'left'; ?>;
|
||||
text-align: <?php echo $_align['left']; ?>;
|
||||
text-shadow: 0 1px 0 <?php echo esc_attr( $base_lighter_20 ); ?>;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
@ -146,7 +148,7 @@ h2 {
|
|||
font-weight: bold;
|
||||
line-height: 130%;
|
||||
margin: 16px 0 8px;
|
||||
text-align: <?php echo is_rtl() ? 'right' : 'left'; ?>;
|
||||
text-align: <?php echo $_align['left']; ?>;
|
||||
}
|
||||
|
||||
h3 {
|
||||
|
@ -157,7 +159,7 @@ h3 {
|
|||
font-weight: bold;
|
||||
line-height: 130%;
|
||||
margin: 16px 0 8px;
|
||||
text-align: <?php echo is_rtl() ? 'right' : 'left'; ?>;
|
||||
text-align: <?php echo $_align['left']; ?>;
|
||||
}
|
||||
|
||||
a {
|
||||
|
|
Loading…
Reference in New Issue