function uni_price_form()
{
    $sCharset = 'UTF-8';
    mb_internal_encoding($sCharset);
    $aResult = array();
    $aResult['message'] = __('Error!', 'asana');
    $aResult['status'] = 'error';
    $sCustomerFName = !empty($_POST['uni_contact_firstname']) ? esc_sql($_POST['uni_contact_firstname']) : '';
    $sCustomerLName = !empty($_POST['uni_contact_lastname']) ? esc_sql($_POST['uni_contact_lastname']) : '';
    $sCustomerEmail = !empty($_POST['uni_contact_email']) ? esc_sql($_POST['uni_contact_email']) : '';
    $sCustomerPhone = !empty($_POST['uni_contact_phone']) ? esc_sql($_POST['uni_contact_phone']) : '';
    $sCustomerMsg = !empty($_POST['uni_contact_msg']) ? stripslashes_deep(strip_tags($_POST['uni_contact_msg'])) : '';
    $iPriceId = absint(esc_sql($_POST['uni_price_id']));
    $sNonce = $_POST['uni_contact_nonce'];
    $sAntiCheat = $_POST['cheaters_always_disable_js'];
    if (empty($sAntiCheat) || $sAntiCheat != 'true_bro' || !wp_verify_nonce($_POST['uni_contact_nonce'], 'uni_nonce')) {
        wp_send_json($aResult);
    }
    if ($sCustomerFName && $sCustomerLName && $sCustomerEmail && $sCustomerPhone && $sCustomerMsg) {
        $sAdminEmail = ot_get_option('uni_email') ? ot_get_option('uni_email') : get_bloginfo('admin_email');
        $sPriceTitle = esc_attr(get_the_title($iPriceId));
        $aCustomData = get_post_custom($iPriceId);
        $sPriceCurrency = !empty($aCustomData['uni_currency'][0]) ? esc_html($aCustomData['uni_currency'][0]) : __('- not specified -', 'asana');
        $sPriceVal = !empty($aCustomData['uni_price_val'][0]) ? esc_html($aCustomData['uni_price_val'][0]) : __('- not specified -', 'asana');
        $sPricePeriod = !empty($aCustomData['uni_period'][0]) ? esc_html($aCustomData['uni_period'][0]) : __('- not specified -', 'asana');
        $sPhone = ot_get_option('uni_phone') ? esc_html(ot_get_option('uni_phone')) : '+88 (0) 101 0000 000';
        $sEmail = ot_get_option('uni_email') ? esc_html(ot_get_option('uni_email')) : esc_html(get_bloginfo('admin_email'));
        // send an email to the client
        $sBlogName = get_bloginfo('name');
        $sHeadersText = esc_attr($sBlogName) . " " . "<{$sAdminEmail}>";
        $sSubjectText = sprintf(__('Successful request for "%s"', 'asana'), $sPriceTitle);
        $sEmailTemplateName = apply_filters('uni_asana_price_email_filter', 'email/price-guest.php', 'guest');
        $aMailVars = array('$sPriceTitle' => '"' . $sPriceTitle . '"', '$sPriceCurrency' => $sPriceCurrency, '$sPriceVal' => $sPriceVal, '$sPricePeriod' => $sPricePeriod, '$sPhone' => $sPhone, '$sEmail' => $sEmail);
        uni_send_email_wrapper($sCustomerEmail, $sHeadersText, $sSubjectText, $sEmailTemplateName, $aMailVars, '');
        // send an email to the admin
        $sHeadersText = "{$sCustomerFName} {$sCustomerLName} <{$sCustomerEmail}>";
        $sSubjectText = sprintf(__('A new request for "%s"', 'asana'), $sPriceTitle);
        $sClientName = $sCustomerFName . ' ' . $sCustomerLName;
        $sClientTel = $sCustomerPhone;
        $sClientEmail = $sCustomerEmail;
        $sClientMsg = $sCustomerMsg;
        $sEmailTemplateName = apply_filters('uni_asana_price_email_filter', 'email/price-admin.php', 'admin');
        $aMailVars = array('$sPriceTitle' => '"' . $sPriceTitle . '"', '$sPricePeriod' => $sPricePeriod, '$sClientName' => $sClientName, '$sClientTel' => $sClientTel, '$sClientEmail' => $sClientEmail, '$sClientMsg' => $sClientMsg);
        uni_send_email_wrapper($sAdminEmail, $sHeadersText, $sSubjectText, $sEmailTemplateName, $aMailVars, '');
        $aResult['status'] = 'success';
        $aResult['message'] = __('Thanks! You request is successfully sent!', 'asana');
    } else {
        $aResult['message'] = __('All fields are required!', 'asana');
    }
    wp_send_json($aResult);
}
コード例 #2
0
ファイル: functions.php プロジェクト: PHQ-Design/souza-lima
function uni_order_form()
{
    $aResult = array();
    $aResult['message'] = esc_html__('Error!', 'bauhaus');
    $aResult['status'] = 'error';
    $sCustomerName = isset($_POST['uni_contact_name']) ? esc_sql($_POST['uni_contact_name']) : '';
    $sCustomerEmail = isset($_POST['uni_contact_email']) ? esc_sql($_POST['uni_contact_email']) : '';
    $sCustomerSubject = isset($_POST['uni_contact_subject']) ? esc_sql($_POST['uni_contact_subject']) : '';
    $sCustomerMsg = isset($_POST['uni_contact_msg']) ? esc_sql($_POST['uni_contact_msg']) : '';
    $sNonce = $_POST['uni_contact_nonce'];
    $sAntiCheat = $_POST['cheaters_always_disable_js'];
    if (empty($sAntiCheat) || $sAntiCheat != 'true_bro' || !wp_verify_nonce($_POST['uni_contact_nonce'], 'uni_nonce')) {
        wp_send_json($aResult);
    }
    if ($sCustomerName && $sCustomerEmail && $sCustomerSubject && $sCustomerMsg) {
        $sToEmail = ot_get_option('uni_email') ? ot_get_option('uni_email') : get_bloginfo('admin_email');
        $sFromEmail = $sCustomerEmail;
        $sHeadersText = "{$sCustomerName} <{$sFromEmail}>";
        $sSubjectText = $sCustomerSubject;
        $sBlogName = get_bloginfo('name');
        $sMessage = "<h3>" . sprintf(esc_html__('You have a new order sent from "%s"!', 'bauhaus'), $sBlogName) . "</h3>\n                    <p></p>\n                    <p><strong>" . esc_html__('Contact information', 'bauhaus') . ":</strong><br>\n                    " . sprintf(esc_html__('Name: %s', 'bauhaus'), $sCustomerName) . "\n                    <br>\n                    " . sprintf(esc_html__('Email: %s', 'bauhaus'), $sCustomerEmail) . "\n                    <br>\n                    " . sprintf(esc_html__('Subject: %s', 'bauhaus'), $sCustomerSubject) . "\n                    <br>\n                    " . esc_html__('Message', 'bauhaus') . ":\n                    <br>{$sCustomerMsg}\n                    </p>";
        $sMessage = stripslashes_deep($sMessage);
        uni_send_email_wrapper($sToEmail, $sHeadersText, $sSubjectText, false, array(), $sMessage);
        $aResult['status'] = 'success';
        $aResult['message'] = esc_html__('Thanks! You message has been sent!', 'bauhaus');
    } else {
        $aResult['message'] = esc_html__('All fields are required!', 'bauhaus');
    }
    wp_send_json($aResult);
}