function wc_ei_upgrade_plugin()
{
    // Upgrade to 1.0.3
    if (version_compare(get_option('a3rev_wc_email_inquiry_version'), '1.0.3') === -1) {
        WC_Email_Inquiry_Functions::reset_products_to_global_settings();
        update_option('a3rev_wc_email_inquiry_version', '1.0.3');
    }
    // Upgrade Ultimate to 1.0.8
    if (version_compare(get_option('a3rev_wc_email_inquiry_version'), '1.0.8') === -1) {
        include WC_EMAIL_INQUIRY_DIR . '/includes/updates/update-1.0.8.php';
        update_option('a3rev_wc_email_inquiry_version', '1.0.8');
    }
    if (version_compare(get_option('a3rev_wc_email_inquiry_version'), '1.0.9.2') === -1) {
        include WC_EMAIL_INQUIRY_DIR . '/includes/updates/update-1.0.9.2.php';
        update_option('a3rev_wc_email_inquiry_version', '1.0.9.2');
    }
    if (version_compare(get_option('a3rev_wc_email_inquiry_version'), '1.2.0') === -1) {
        // Build sass
        global $wc_email_inquiry_less;
        $wc_email_inquiry_less->plugin_build_sass();
        update_option('a3rev_wc_email_inquiry_version', '1.2.0');
    }
    if (version_compare(get_option('a3rev_wc_email_inquiry_version'), '1.2.3') === -1) {
        global $wc_ei_admin_init;
        $wc_ei_admin_init->set_default_settings();
    }
    update_option('a3rev_wc_email_inquiry_version', '1.3.0');
    update_option('a3rev_wc_email_inquiry_ultimate_version', '1.2.6');
    update_option('a3rev_wc_orders_quotes_version', '1.1.8');
}
    public static function email_inquiry($product_id, $your_name, $your_email, $your_phone, $your_message, $send_copy_yourself = 1)
    {
        global $wc_email_inquiry_contact_form_settings;
        $wc_email_inquiry_contact_success = stripslashes(get_option('wc_email_inquiry_contact_success', ''));
        if (WC_Email_Inquiry_Functions::check_add_email_inquiry_button($product_id)) {
            if (trim($wc_email_inquiry_contact_success) != '') {
                $wc_email_inquiry_contact_success = wpautop(wptexturize($wc_email_inquiry_contact_success));
            } else {
                $wc_email_inquiry_contact_success = __("Thanks for your inquiry - we'll be in touch with you as soon as possible!", 'wc_email_inquiry');
            }
            $to_email = $wc_email_inquiry_contact_form_settings['inquiry_email_to'];
            if (trim($to_email) == '') {
                $to_email = get_option('admin_email');
            }
            if ($wc_email_inquiry_contact_form_settings['inquiry_email_from_address'] == '') {
                $from_email = get_option('admin_email');
            } else {
                $from_email = $wc_email_inquiry_contact_form_settings['inquiry_email_from_address'];
            }
            if ($wc_email_inquiry_contact_form_settings['inquiry_email_from_name'] == '') {
                $from_name = get_option('blogname');
            } else {
                $from_name = $wc_email_inquiry_contact_form_settings['inquiry_email_from_name'];
            }
            $cc_emails = $wc_email_inquiry_contact_form_settings['inquiry_email_cc'];
            if (trim($cc_emails) == '') {
                $cc_emails = '';
            }
            $headers = array();
            $headers[] = 'MIME-Version: 1.0';
            $headers[] = 'Content-type: text/html; charset=' . get_option('blog_charset');
            $headers[] = 'From: ' . $from_name . ' <' . $from_email . '>';
            $headers_yourself = $headers;
            if (trim($cc_emails) != '') {
                $cc_emails_a = explode(",", $cc_emails);
                if (is_array($cc_emails_a) && count($cc_emails_a) > 0) {
                    foreach ($cc_emails_a as $cc_email) {
                        $headers[] = 'Cc: ' . $cc_email;
                    }
                } else {
                    $headers[] = 'Cc: ' . $cc_emails;
                }
            }
            $product_name = get_the_title($product_id);
            $product_url = get_permalink($product_id);
            $subject = __('Email inquiry for', 'wc_email_inquiry') . ' ' . $product_name;
            $subject_yourself = __('[Copy]: Email inquiry for', 'wc_email_inquiry') . ' ' . $product_name;
            $content = '
	<table width="99%" cellspacing="0" cellpadding="1" border="0" bgcolor="#eaeaea"><tbody>
	  <tr>
		<td>
		  <table width="100%" cellspacing="0" cellpadding="5" border="0" bgcolor="#ffffff"><tbody>
			<tr bgcolor="#eaf2fa">
			  <td colspan="2"><font style="FONT-FAMILY:sans-serif;FONT-SIZE:12px"><strong>' . __('Name', 'wc_email_inquiry') . '</strong></font> 
			  </td></tr>
			<tr bgcolor="#ffffff">
			  <td width="20">&nbsp;</td>
			  <td><font style="FONT-FAMILY:sans-serif;FONT-SIZE:12px">[your_name]</font> </td></tr>
			<tr bgcolor="#eaf2fa">
			  <td colspan="2"><font style="FONT-FAMILY:sans-serif;FONT-SIZE:12px"><strong>' . __('Email Address', 'wc_email_inquiry') . '</strong></font> </td></tr>
			<tr bgcolor="#ffffff">
			  <td width="20">&nbsp;</td>
			  <td><font style="FONT-FAMILY:sans-serif;FONT-SIZE:12px"><a target="_blank" href="mailto:[your_email]">[your_email]</a></font> 
			  </td></tr>
			<tr bgcolor="#eaf2fa">
			  <td colspan="2"><font style="FONT-FAMILY:sans-serif;FONT-SIZE:12px"><strong>' . __('Phone', 'wc_email_inquiry') . '</strong></font> </td></tr>
			<tr bgcolor="#ffffff">
			  <td width="20">&nbsp;</td>
			  <td><font style="FONT-FAMILY:sans-serif;FONT-SIZE:12px">[your_phone]</font> </td></tr>
			<tr bgcolor="#eaf2fa">
			  <td colspan="2"><font style="FONT-FAMILY:sans-serif;FONT-SIZE:12px"><strong>' . __('Product Name', 'wc_email_inquiry') . '</strong></font> </td></tr>
			<tr bgcolor="#ffffff">
			  <td width="20">&nbsp;</td>
			  <td><font style="FONT-FAMILY:sans-serif;FONT-SIZE:12px"><a target="_blank" href="[product_url]">[product_name]</a></font> </td></tr>
			<tr bgcolor="#eaf2fa">
			  <td colspan="2"><font style="FONT-FAMILY:sans-serif;FONT-SIZE:12px"><strong>' . __('Message', 'wc_email_inquiry') . '</strong></font> </td></tr>
			<tr bgcolor="#ffffff">
			  <td width="20">&nbsp;</td>
			  <td><font style="FONT-FAMILY:sans-serif;FONT-SIZE:12px">[your_message]</font> 
		  </td></tr></tbody></table></td></tr></tbody></table>';
            $content = str_replace('[your_name]', $your_name, $content);
            $content = str_replace('[your_email]', $your_email, $content);
            $content = str_replace('[your_phone]', $your_phone, $content);
            $content = str_replace('[product_name]', $product_name, $content);
            $content = str_replace('[product_url]', $product_url, $content);
            $your_message = str_replace('://', ':&#173;­//', $your_message);
            $your_message = str_replace('.com', '&#173;.com', $your_message);
            $your_message = str_replace('.net', '&#173;.net', $your_message);
            $your_message = str_replace('.info', '&#173;.info', $your_message);
            $your_message = str_replace('.org', '&#173;.org', $your_message);
            $your_message = str_replace('.au', '&#173;.au', $your_message);
            $content = str_replace('[your_message]', wpautop($your_message), $content);
            $content = apply_filters('wc_email_inquiry_inquiry_content', $content);
            // Filters for the email
            add_filter('wp_mail_from', array('WC_Email_Inquiry_Functions', 'get_from_address'));
            add_filter('wp_mail_from_name', array('WC_Email_Inquiry_Functions', 'get_from_name'));
            add_filter('wp_mail_content_type', array('WC_Email_Inquiry_Functions', 'get_content_type'));
            wp_mail($to_email, $subject, $content, $headers, '');
            // Unhook filters
            remove_filter('wp_mail_from', array('WC_Email_Inquiry_Functions', 'get_from_address'));
            remove_filter('wp_mail_from_name', array('WC_Email_Inquiry_Functions', 'get_from_name'));
            remove_filter('wp_mail_content_type', array('WC_Email_Inquiry_Functions', 'get_content_type'));
            return $wc_email_inquiry_contact_success;
        } else {
            return __("Sorry, this product don't enable email inquiry.", 'wc_email_inquiry');
        }
    }
 public static function wc_email_inquiry_action()
 {
     $product_id = esc_attr(stripslashes($_REQUEST['product_id']));
     $your_name = esc_attr(stripslashes($_REQUEST['your_name']));
     $your_email = esc_attr(stripslashes($_REQUEST['your_email']));
     $your_phone = esc_attr(stripslashes($_REQUEST['your_phone']));
     $your_message = esc_attr(stripslashes(strip_tags($_REQUEST['your_message'])));
     $send_copy_yourself = esc_attr(stripslashes($_REQUEST['send_copy']));
     $email_result = WC_Email_Inquiry_Functions::email_inquiry($product_id, $your_name, $your_email, $your_phone, $your_message, $send_copy_yourself);
     echo json_encode($email_result);
     die;
 }