本文整理汇总了PHP中wpcf7_mail_replace_tags函数的典型用法代码示例。如果您正苦于以下问题:PHP wpcf7_mail_replace_tags函数的具体用法?PHP wpcf7_mail_replace_tags怎么用?PHP wpcf7_mail_replace_tags使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpcf7_mail_replace_tags函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wpcf7ev_verify_email_address
function wpcf7ev_verify_email_address($wpcf7_form)
{
// first prevent the emails being sent as per usual
add_filter('wpcf7_mail_components', 'wpcf7ev_skip_sending');
// fetch the submitted form details
$mail_tags = $wpcf7_form->prop('mail');
$mail_fields = wpcf7_mail_replace_tags($mail_tags);
$senders_email_address = $mail_fields['sender'];
// save any attachments to a temp directory
$mail_string = trim($mail_fields['attachments']);
if (strlen($mail_string) > 0 and !ctype_space($mail_string)) {
$mail_attachments = explode(" ", $mail_string);
foreach ($mail_attachments as $attachment) {
$uploaded_file_path = ABSPATH . 'wp-content/uploads/wpcf7_uploads/' . $attachment;
$new_filepath = WPCF7EV_UPLOADS_DIR . $attachment;
rename($uploaded_file_path, $new_filepath);
}
}
// send an email to the recipient to let them know verification is pending
wp_mail($mail_fields['recipient'], 'Form notice', "Hi,\n\nYou've had a form submission on " . get_option('blogname') . " from " . $senders_email_address . ".\n\nWe are waiting for them to confirm their email address.");
//create hash code for verification key
$random_hash = substr(md5(uniqid(rand(), true)), -16, 16);
// save submitted form as a transient object
$data_to_save = array($mail_fields, $random_hash);
set_transient(wpcf7ev_get_slug($random_hash), $data_to_save, WPCF7EV_STORAGE_TIME);
// send email to the sender with a verification link to click on
wp_mail($senders_email_address, 'Verify your email address', "Hi,\n\nThanks for your your recent submission on " . get_option('blogname') . ".\n\nIn order for your submission to be processed, please verify this is your email address by clicking on the following link:\n\n" . get_site_url() . "/wp-admin/admin-post.php?action=wpcf7ev&email-verification-key={$random_hash}" . "\n\nThanks.");
}
示例2: wpcf7_flamingo_get_value
function wpcf7_flamingo_get_value($field, $contactform)
{
if (empty($field) || empty($contactform)) {
return false;
}
$value = '';
if (in_array($field, array('email', 'name', 'subject'))) {
$templates = $contactform->additional_setting('flamingo_' . $field);
if (empty($templates[0])) {
$template = sprintf('[your-%s]', $field);
} else {
$template = trim(wpcf7_strip_quote($templates[0]));
}
$value = wpcf7_mail_replace_tags($template);
}
$value = apply_filters('wpcf7_flamingo_get_value', $value, $field, $contactform);
return $value;
}
示例3: replace_tags
public function replace_tags($content, $html = false)
{
$args = array('html' => $html, 'exclude_blank' => $this->exclude_blank);
return wpcf7_mail_replace_tags($content, $args);
}
示例4: message
public function message($status, $filter = true)
{
$messages = $this->prop('messages');
$message = isset($messages[$status]) ? $messages[$status] : '';
if ($filter) {
$message = wpcf7_mail_replace_tags($message, array('html' => true));
$message = apply_filters('wpcf7_display_message', $message, $status);
}
return $message;
}
示例5: storage_capture
function storage_capture($cf7)
{
// Store this entry and get its ID
$entry_id = wp_insert_post(array('post_type' => self::$post_type, 'post_status' => 'publish', 'post_parent' => $cf7->id()));
do_action('cf7_storage_pre_capture', $entry_id, $cf7);
// Make this entry ID available to this class
$this->set_entry_id($entry_id);
// Get the mail template and settings of this contact form
$template = $cf7->prop('mail');
// Replace all variables with form values
$mail = wpcf7_mail_replace_tags($template, array('html' => $template['use_html'], 'exclude_blank' => $template['exclude_blank']));
// Update post title and body content
wp_update_post(array('ID' => $entry_id, 'post_title' => $mail['sender'], 'post_content' => $mail['body']));
// Store all field values that were mailed
foreach ($mail as $mail_field => $mail_value) {
add_post_meta($entry_id, 'mail_' . $mail_field, $mail_value, true);
}
$submission = WPCF7_Submission::get_instance();
$posted_data_raw = $submission->get_posted_data();
$posted_fields = array();
foreach ($posted_data_raw as $field_key => $field_value) {
if (!preg_match('/^(_wpnonce|_wpcf7)/i', $field_key)) {
$posted_fields[$field_key] = $field_value;
}
}
// Store field values
add_post_meta($entry_id, 'form_fields', $posted_fields);
// Store user browser, IP, referer
$extra_meta = array('http_user_agent' => $_SERVER['HTTP_USER_AGENT'], 'remote_addr' => $_SERVER['REMOTE_ADDR'], 'http_referer' => $_SERVER['HTTP_REFERER']);
$unit_tag = $submission->get_meta('unit_tag');
// Store the post/page ID where the form was submitted
if ($unit_tag && preg_match('/^wpcf7-f(\\d+)-p(\\d+)-o(\\d+)$/', $unit_tag, $unit_matches)) {
$extra_meta['post_id'] = absint($unit_matches[2]);
}
if (is_user_logged_in()) {
$extra_meta['user_id'] = get_current_user_id();
}
foreach ($extra_meta as $key => $value) {
add_post_meta($entry_id, $key, $value);
}
// Store uploads permanently
$uploads_stored = $this->store_uploaded_files($entry_id, $submission->uploaded_files());
do_action('cf7_storage_capture', $entry_id, $cf7);
}
示例6: _hw_wpcf7_do_something
/**
* contact form submision
* @param object $WPCF7_ContactForm: current contact form object
*/
public function _hw_wpcf7_do_something($WPCF7_ContactForm)
{
/* Use WPCF7_Submission object's get_posted_data() method to get it. */
$properties = $WPCF7_ContactForm->get_properties();
//get google form ID of this form
$gformID = $properties['hw_gformID'];
// get the contact form object
$wpcf7 = WPCF7_ContactForm::get_current();
if (isset($properties['enable_email_by_gapp']) && $properties['enable_email_by_gapp']) {
// do not send the email
$wpcf7->skip_mail = true;
//turn off default send mail by wpcf7, use google drive instead
}
$atts = $WPCF7_ContactForm->form_scan_shortcode();
$fields_title = array();
//fields title
$data = array();
//fields value
//submission data
$submission = WPCF7_Submission::get_instance();
if ($submission) {
//get storage service
$storage_hook = $WPCF7_ContactForm->prop('hwcf_data_hook');
//get posted form data
$posted_data = $submission->get_posted_data();
//parse email template into user data
$mail_temp = $WPCF7_ContactForm->prop('mail');
$result = wpcf7_mail_replace_tags($mail_temp);
$admin_email = !empty($mail_temp['recipient']) ? $mail_temp['recipient'] : get_option('admin_email');
//set special field value
$special_fields_value['sendEmail'] = $result['body'];
$special_fields_value['admin_email'] = $admin_email;
#admin email
$special_fields_value['website'] = hw_wpcf7_current_page_url();
#site url
foreach ($atts as $field) {
//loop each field
$tag = new WPCF7_Shortcode($field);
$name = $tag->name;
//get field name
if ($tag->has_option('gfield') && $tag->type != 'hw_wpcf7_special_fields') {
if ($tag->get_option('gfield', '', true)) {
$name = $tag->get_option('gfield', '', true);
//modify field value
$data[$name] = apply_filters('hwwpcf7_field_value', $posted_data[$tag->name], array('name' => $name, 'tag' => $tag, 'data' => &$data, 'wpcf7' => $wpcf7));
/*if(isset($_POST['product_id']) && $tag->name=='order_detail'){
$sp=get_post($_POST['product_id']);
$data[$name] = '[ID='.$sp->ID.']'.PHP_EOL.$sp->post_title.PHP_EOL.get_permalink($sp->ID);
}*/
//else $data[$name] = $posted_data[$tag->name];
}
}
/**
* get field title
*/
if ($tag->has_option('placeholder') && $tag->type != 'hw_wpcf7_special_fields') {
$fields_title[$name] = (string) reset($tag->values);
#$tag->get_option('placeholder','',true);
}
/**
* special tag to get special fields
*/
if ($tag->type == 'hw_wpcf7_special_fields') {
foreach (HW_WPCF7::$special_gfields as $fname => $desc) {
if ($tag->has_option($fname) && isset($special_fields_value[$fname])) {
$data[$tag->get_option($fname, '', true)] = $special_fields_value[$fname];
//add special field value to data
}
}
}
}
//storage
if ($storage_hook == 'google_form') {
//get google form id
$gform_id = $WPCF7_ContactForm->prop('hw_gformID');
//from google spreadsheet as responses that link to google form. Create event onSubmitForm. you can send mail using google script.
hw_wpcf7_post_gform($gform_id, $data);
} elseif ($storage_hook == 'url') {
$hook_url = $WPCF7_ContactForm->prop('hook_url');
//web hook url
$data['labels'] = serialize($fields_title);
//nest labels for all fields in one data together
HW_CURL::curl_post($hook_url, $data);
}
/*hw_mail(array(
'subject'=>'Khách hàng liên hệ từ '.home_url(),
'body'=>$body
));*/
}
}
示例7: get_submitted_value
/**
* Get the value from the submitted fields
*
* @param string $subject The name of the field; ie: [first-name]
* @param array $posted_data The posted data, in array form.
*
* @return [type] [description]
*/
static function get_submitted_value($subject, &$obj, $pattern = '/\\[\\s*([a-zA-Z_][0-9a-zA-Z:._-]*)\\s*\\]/')
{
// new method ( since Contact Form 7 Version 4.0.1 )
if (function_exists('wpcf7_mail_replace_tags')) {
$subject = preg_replace('/^(?:\\[?)(.*)(?:\\]?)$/ism', '[$1]', $subject);
$replaced = wpcf7_mail_replace_tags($subject);
return $replaced;
}
// Keeping below for back compatibility (??)
if (is_callable(array($obj, 'replace_mail_tags'))) {
// Make sure the title is wrapped in []
$subject = preg_replace('/^(?:\\[?)(.*)(?:\\]?)$/ism', '[$1]', $subject);
$replaced = $obj->replace_mail_tags($subject);
return $replaced;
}
// Keeping below for back compatibility
$posted_data = $obj->posted_data;
if (preg_match($pattern, $subject, $matches) > 0) {
if (isset($posted_data[$matches[1]])) {
$submitted = $posted_data[$matches[1]];
if (is_array($submitted)) {
$replaced = join(', ', $submitted);
} else {
$replaced = $submitted;
}
if ($html) {
$replaced = strip_tags($replaced);
$replaced = wptexturize($replaced);
}
$replaced = apply_filters('wpcf7_mail_tag_replaced', $replaced, $submitted);
return stripslashes($replaced);
}
if ($special = apply_filters('wpcf7_special_mail_tags', '', $matches[1])) {
return $special;
}
return $matches[0];
}
return $subject;
}