Email and widget fixes
This commit is contained in:
parent
cd1f136ae6
commit
980f08a897
|
@ -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()) :
|
||||
?>
|
||||
|
|
|
@ -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()) :
|
||||
?>
|
||||
|
|
|
@ -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()) :
|
||||
|
||||
|
|
|
@ -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, '<html>')) :
|
||||
if (strstr($phpmailer->Body, '<html')) :
|
||||
|
||||
// Email already using custom template
|
||||
|
||||
|
|
Loading…
Reference in New Issue