From 980f08a897c53d0705f5b3036cf944f5ca107544 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Mon, 26 Sep 2011 15:12:39 +0100 Subject: [PATCH] Email and widget fixes --- widgets/widget-recent_products.php | 8 +++--- widgets/widget-recently_viewed.php | 4 +-- widgets/widget-top_rated_products.php | 4 +-- woocommerce_emails.php | 37 +++++++++++++-------------- 4 files changed, 26 insertions(+), 27 deletions(-) diff --git a/widgets/widget-recent_products.php b/widgets/widget-recent_products.php index b788395844a..dfdd03ce6f0 100644 --- a/widgets/widget-recent_products.php +++ b/widgets/widget-recent_products.php @@ -61,20 +61,20 @@ class WooCommerce_Widget_Recent_Products extends WP_Widget { $show_variations = $instance['show_variations'] ? '1' : '0'; - $args = array('showposts' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'post_type' => 'product'); + $query_args = array('showposts' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'post_type' => 'product'); if($show_variations=='0'){ - $args['meta_query'] = array( + $query_args['meta_query'] = array( array( 'key' => 'visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN' ) ); - $args['parent'] = '0'; + $query_args['parent'] = '0'; } - $r = new WP_Query($args); + $r = new WP_Query($query_args); if ($r->have_posts()) : ?> diff --git a/widgets/widget-recently_viewed.php b/widgets/widget-recently_viewed.php index 6fb003e9ec0..c035db24af9 100644 --- a/widgets/widget-recently_viewed.php +++ b/widgets/widget-recently_viewed.php @@ -61,9 +61,9 @@ class WooCommerce_Widget_Recently_Viewed extends WP_Widget { else if ( $number > 15 ) $number = 15; - $args = array('showposts' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'post_type' => 'product', 'post__in' => $_SESSION['viewed_products'], 'orderby' => 'rand'); + $query_args = array('showposts' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'post_type' => 'product', 'post__in' => $_SESSION['viewed_products'], 'orderby' => 'rand'); - $r = new WP_Query($args); + $r = new WP_Query($query_args); if ($r->have_posts()) : ?> diff --git a/widgets/widget-top_rated_products.php b/widgets/widget-top_rated_products.php index cfcd5d29ce4..b300c4d5c58 100644 --- a/widgets/widget-top_rated_products.php +++ b/widgets/widget-top_rated_products.php @@ -60,8 +60,8 @@ class WooCommerce_Widget_Top_Rated_Products extends WP_Widget { add_filter( 'posts_clauses', array(&$this, 'order_by_rating_post_clauses') ); - $args = array('posts_per_page' => $number, 'post_status' => 'publish', 'post_type' => 'product' ); - $top_rated_posts = new WP_Query( $args ); + $query_args = array('posts_per_page' => $number, 'post_status' => 'publish', 'post_type' => 'product' ); + $top_rated_posts = new WP_Query( $query_args ); if ($top_rated_posts->have_posts()) : diff --git a/woocommerce_emails.php b/woocommerce_emails.php index ecd2566dec1..caf1da173d3 100644 --- a/woocommerce_emails.php +++ b/woocommerce_emails.php @@ -9,6 +9,21 @@ * @author WooThemes */ +/** + * Option for email formatting + **/ +if (get_option('woocommerce_enable_sitewide_mail_template')=='yes') add_action('init', 'woocommerce_wpmail_init'); + +function woocommerce_wpmail_init() { + // From address + add_filter( 'wp_mail_from', 'woocommerce_mail_from' ); + add_filter( 'wp_mail_from_name', 'woocommerce_mail_from_name' ); + // HTML content type + add_filter( 'wp_mail_content_type', 'woocommerce_email_content_type' ); + // Fix password email + add_filter( 'retrieve_password_message', 'woocommerce_retrieve_password_message' ); +} + /** * Mail from name/email **/ @@ -22,28 +37,12 @@ function woocommerce_mail_from( $email ) { return $email; } -/** - * Option for email formatting - **/ -if (get_option('woocommerce_enable_sitewide_mail_template')=='yes') : - - // From address - add_filter( 'wp_mail_from', 'woocommerce_mail_from' ); - add_filter( 'wp_mail_from_name', 'woocommerce_mail_from_name' ); - // HTML content type - add_filter( 'wp_mail_content_type', 'woocommerce_email_content_type' ); - // Fix password email - add_filter( 'retrieve_password_message', 'woocommerce_retrieve_password_message' ); - -endif; - /** * HTML emails from WooCommerce **/ function woocommerce_mail( $to, $subject, $message ) { - // Hook in content type/from changes - if (get_option('woocommerce_enable_sitewide_mail_template')=='no') : + if (get_option('woocommerce_enable_sitewide_mail_template')!='yes') : add_filter( 'wp_mail_from', 'woocommerce_mail_from' ); add_filter( 'wp_mail_from_name', 'woocommerce_mail_from_name' ); add_filter( 'wp_mail_content_type', 'woocommerce_email_content_type' ); @@ -53,7 +52,7 @@ function woocommerce_mail( $to, $subject, $message ) { wp_mail( $to, $subject, $message ); // Unhook - if (get_option('woocommerce_enable_sitewide_mail_template')=='no') : + if (get_option('woocommerce_enable_sitewide_mail_template')!='yes') : remove_filter( 'wp_mail_from', 'woocommerce_mail_from' ); remove_filter( 'wp_mail_from_name', 'woocommerce_mail_from_name' ); remove_filter( 'wp_mail_content_type', 'woocommerce_email_content_type' ); @@ -67,7 +66,7 @@ add_action( 'phpmailer_init', 'woocommerce_email_template' ); function woocommerce_email_template( $phpmailer ) { - if (strstr($phpmailer->Body, '')) : + if (strstr($phpmailer->Body, '