本文整理汇总了PHP中WPCF7_ContactForm::get_current方法的典型用法代码示例。如果您正苦于以下问题:PHP WPCF7_ContactForm::get_current方法的具体用法?PHP WPCF7_ContactForm::get_current怎么用?PHP WPCF7_ContactForm::get_current使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WPCF7_ContactForm
的用法示例。
在下文中一共展示了WPCF7_ContactForm::get_current方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cf7bs_get_form_property
function cf7bs_get_form_property($property, $form_id = 0)
{
global $current_form_id, $current_form_properties;
if ($form_id == 0) {
if (is_callable(array('WPCF7_ContactForm', 'get_current'))) {
$current_form = WPCF7_ContactForm::get_current();
if (is_a($current_form, 'WPCF7_ContactForm') && is_callable(array($current_form, 'id'))) {
$form_id = $current_form->id();
}
}
}
if ($form_id == 0) {
return false;
}
if ($current_form_id != $form_id) {
$current_form_id = $form_id;
$properties = cf7bs_get_default_form_properties();
if (is_a($current_form, 'WPCF7_ContactForm') && is_callable(array($current_form, 'additional_setting'))) {
foreach ($properties as $key => &$value) {
$setting = $current_form->additional_setting($key);
if (isset($setting[0])) {
$value = $setting[0];
}
}
unset($key);
unset($value);
}
$current_form_properties = apply_filters('cf7bs_form_' . $form_id . '_properties', $properties);
}
if (isset($current_form_properties[$property])) {
return $current_form_properties[$property];
}
return false;
}
示例2: wpcf7_scan_form_tags
function wpcf7_scan_form_tags($cond = null)
{
$contact_form = WPCF7_ContactForm::get_current();
if ($contact_form) {
return $contact_form->scan_form_tags($cond);
}
return array();
}
示例3: send_mail_for_form
function send_mail_for_form($cf7_posted_data)
{
$wpcf7 = WPCF7_ContactForm::get_current();
if ($wpcf7->id() == 596) {
$wpcf7->skip_mail = false;
}
return $cf7_posted_data;
}
示例4: prepare_body
/**
* Takes the body of the mail, evaluates it and sets it back.
*
* @param [Object] The $WPCF7_ContactForm object.
* @return void
*/
public function prepare_body($cf7)
{
// Get the object.
$wpcf = WPCF7_ContactForm::get_current();
// Now we get the mail body and evaluate it.
$mail = $wpcf->prop('mail');
$mail['body'] = $this->evaluate($mail['body']);
// Set the new body.
$wpcf->set_properties(array('mail' => $mail));
return $wpcf;
}
开发者ID:kailn,项目名称:Mail-Conditions-for-Contact-Form-7,代码行数:17,代码来源:mail_conditions_for_contact_form_7.php
示例5: wpcf7gpg_encrypt_mail
function wpcf7gpg_encrypt_mail($wpcf7gpg_mailcomponents)
{
$wpcf7gpg_contactform = WPCF7_ContactForm::get_current();
$wpcf7gpg_publickey = $wpcf7gpg_contactform->additional_setting('wpcf7gpg_publickey');
if ($wpcf7gpg_publickey) {
// A public key has been defined (element 0 in array), sanitize as required by GPG library
$wpcf7gpg_publickey = str_replace('|', "\n", $wpcf7gpg_publickey[0]);
// Replace body of mail with encrypted body text
$wpcf7gpg_mailcomponents['body'] = wpcf7gpg_encrypt_text($wpcf7gpg_mailcomponents['body'], $wpcf7gpg_publickey);
} else {
// No public key has been defined, we can skip encryption
}
return $wpcf7gpg_mailcomponents;
}
示例6: dynamic_shortcode_handler
public function dynamic_shortcode_handler($tag)
{
// generates html for form field
if (!is_array($tag)) {
return '';
}
$name = $tag['name'];
if (empty($name)) {
return '';
}
$wpcf7_contact_form = WPCF7_ContactForm::get_current();
// most attributes not really needed, not included
$name_att = $name;
$filter = '';
$filter_args = array();
$filter_string = '';
$values = $tag['values'];
if (isset($values[0])) {
$filter_string = $values[0];
}
//echo $filter_string;
if ($filter_string != '') {
$filter_parts = explode(' ', $filter_string);
$filter = trim($filter_parts[0]);
$count = count($filter_parts);
for ($i = 1; $i < $count; $i++) {
if (trim($filter_parts[$i]) != '') {
$arg_parts = explode('=', $filter_parts[$i]);
if (count($arg_parts) == 2) {
$filter_args[trim($arg_parts[0])] = trim($arg_parts[1], ' \'');
} else {
$filter_args[] = trim($arg_parts[0], ' \'');
}
}
// end if filter part
}
// end for
}
// end if filter string
$value = '';
if ($filter != '') {
$value = apply_filters($filter, $value, $filter_args);
}
$atts = ' name="' . $name . '" value="' . $value . '" autocomplete="off"';
$html = '<input type="hidden"' . $atts . ' />';
return $html;
}
示例7: maybe_reset_autop
function maybe_reset_autop($form)
{
$form_instance = WPCF7_ContactForm::get_current();
$manager = WPCF7_ShortcodeManager::get_instance();
$form_meta = get_post_meta($form_instance->id(), '_form', true);
$form = $manager->do_shortcode($form_meta);
$form_instance->set_properties(array('form' => $form));
return $form;
}
示例8: cf7bs_get_current_form_id
function cf7bs_get_current_form_id()
{
if (is_callable(array('WPCF7_ContactForm', 'get_current'))) {
$current_form = WPCF7_ContactForm::get_current();
if (is_a($current_form, 'WPCF7_ContactForm') && is_callable(array($current_form, 'id'))) {
return $current_form->id();
}
}
return false;
}
示例9: wpcf7c_ajax_json_echo_step1
function wpcf7c_ajax_json_echo_step1($items, $result)
{
global $wpcf7_confflag;
$flag = false;
if (WPCF7_VERSION == '3.9' || WPCF7_VERSION == '3.9.1') {
$flag = $wpcf7_confflag;
} else {
if (WPCF7_VERSION >= "3.9.2") {
if ('mail_sent' == $result['status']) {
$flag = true;
}
} else {
$flag = $result['mail_sent'];
}
}
if ($flag) {
if (!isset($items["onSubmit"]) || $items["onSubmit"] == null) {
$items["onSubmit"] = array("wpcf7c_step1('" . $_POST['_wpcf7_unit_tag'] . "');");
} else {
$items["onSubmit"][] = "wpcf7c_step1('" . $_POST['_wpcf7_unit_tag'] . "');";
}
// オプションによる追加チェック
$form = WPCF7_ContactForm::get_current();
$on_confirm = $form->additional_setting('on_confirm', false);
if (!empty($on_confirm)) {
foreach ($on_confirm as $key => $on_confirm_func) {
$items["onSubmit"][] = wpcf7_strip_quote($on_confirm_func);
}
}
$items["message"] = "";
$items["mailSent"] = false;
unset($items['captcha']);
} else {
// フィルタ指定があればエラー時にアンカーまでスクロールさせる
$result = false;
if (apply_filters('wpcf7c_input_error_scroll', $result)) {
if (!isset($items["onSubmit"]) || $items["onSubmit"] == null) {
$items["onSubmit"] = array("wpcf7c_scroll('" . $_POST['_wpcf7_unit_tag'] . "');");
} else {
$items["onSubmit"][] = "wpcf7c_scroll('" . $_POST['_wpcf7_unit_tag'] . "');";
}
}
}
return $items;
}
示例10: _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
));*/
}
}
示例11: current_form
/**
* return current working form
*/
function current_form()
{
$current = WPCF7_ContactForm::get_current();
return $current;
}
示例12: __construct
/**
* Initialize the plugin by setting localization, filters, and administration functions.
*
* @since 1.0.0
*
* @access private
*/
private function __construct()
{
global $formworks_tracker;
//auto load modules
$dir = FRMWKS_PATH . 'includes/modules';
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($folder = readdir($dh)) !== false) {
if ($folder === '..' || $folder === '.') {
continue;
}
if (file_exists($dir . '/' . $folder . '/handler.php')) {
include_once $dir . '/' . $folder . '/handler.php';
}
}
closedir($dh);
}
}
// Load plugin text domain
add_action('init', array($this, 'load_plugin_textdomain'));
//initialize visitor tracker
if (!is_admin()) {
add_action('wp', array($this, 'register_visitor_session'));
}
// Activate plugin when new blog is added
add_action('wpmu_new_blog', array($this, 'activate_new_site'));
// Load admin style sheet and JavaScript.
add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_stylescripts'));
// Load front style sheet and JavaScript.
add_action('wp_enqueue_scripts', array($this, 'enqueue_front_stylescripts'));
// output tracking code
add_action('wp_print_footer_scripts', array($this, 'print_front_scripts'));
// Add partial completions
add_action('wp_ajax_frmwks_push', array($this, 'tracker_push'));
add_action('wp_ajax_nopriv_frmwks_push', array($this, 'tracker_push'));
// open actions
add_action('formworks_track', array($this, 'handle_track'), 10, 4);
/**
* Tracking
*/
/** Caldera Forms */
add_action('caldera_forms_submit_complete', function ($form) {
do_action('formworks_track', 'caldera', $form['ID'], 'submission');
});
add_filter('caldera_forms_render_form', function ($html, $form) {
$selector = array("name" => $form['name'], "selector" => "." . $form['ID'], "prefix" => 'caldera', "id" => $form['ID']);
do_action('formworks_track', 'caldera', $form['ID'], 'loaded', $selector);
return $html;
}, 10, 2);
/** JETPACK */
add_filter('grunion_contact_form_success_message', function ($html) {
if (isset($_GET['contact-form-id'])) {
$form_id = $_GET['contact-form-id'];
do_action('formworks_track', 'jp', $form_id, 'submission');
}
return $html;
});
add_filter('grunion_contact_form_form_action', function ($url, $post, $form) {
$selector = array("name" => $post->post_title, "selector" => "#contact-form-" . $form);
do_action('formworks_track', 'jp', $form, 'loaded', $selector);
return $url;
}, 15, 3);
/** Formidable */
add_action('frm_process_entry', function ($params) {
do_action('formworks_track', 'frmid', $params['form_id'], 'submission');
}, 15);
add_filter('formidable_shortcode_atts', function ($shortcode_atts, $atts) {
if (class_exists('\\FrmForm')) {
$form = \FrmForm::getOne($atts['id']);
}
$selector = array("name" => $form->name, "selector" => "#form_" . $form->form_key);
do_action('formworks_track', 'frmid', $form->id, 'loaded', $selector);
}, 10, 2);
/** Contact Form 7 */
add_filter('wpcf7_form_elements', function ($html) {
if (class_exists('\\WPCF7_ContactForm')) {
$form = \WPCF7_ContactForm::get_current();
do_action('formworks_track', 'cf7', $form->id(), 'loaded');
}
return $html;
}, 10, 2);
add_action('wpcf7_submit', function ($instance, $result) {
if (isset($result['status']) && 'mail_sent' === $result['status']) {
do_action('formworks_track', 'cf7', $instance->id(), 'submission');
}
}, 20, 2);
/** Gravity Forms */
add_filter('gform_get_form_filter', function ($html, $form) {
$selector = array("name" => $form['title'], "selector" => "#gform_" . $form['id']);
do_action('formworks_track', 'gform', $form['id'], 'loaded', $selector);
return $html;
}, 10, 2);
add_action('gform_after_submission', function ($form) {
//.........这里部分代码省略.........
示例13: get_default_option
public function get_default_option($default = '', $args = '')
{
$args = wp_parse_args($args, array('multiple' => false));
$options = (array) $this->get_option('default');
$values = array();
if (empty($options)) {
return $args['multiple'] ? $values : $default;
}
foreach ($options as $opt) {
$opt = sanitize_key($opt);
if ('user_' == substr($opt, 0, 5) && is_user_logged_in()) {
$primary_props = array('user_login', 'user_email', 'user_url');
$opt = in_array($opt, $primary_props) ? $opt : substr($opt, 5);
$user = wp_get_current_user();
$user_prop = $user->get($opt);
if (!empty($user_prop)) {
if ($args['multiple']) {
$values[] = $user_prop;
} else {
return $user_prop;
}
}
} elseif ('post_meta' == $opt && in_the_loop()) {
if ($args['multiple']) {
$values = array_merge($values, get_post_meta(get_the_ID(), $this->name));
} else {
$val = (string) get_post_meta(get_the_ID(), $this->name, true);
if (strlen($val)) {
return $val;
}
}
} elseif ('get' == $opt && isset($_GET[$this->name])) {
$vals = (array) $_GET[$this->name];
$vals = array_map('wpcf7_sanitize_query_var', $vals);
if ($args['multiple']) {
$values = array_merge($values, $vals);
} else {
$val = isset($vals[0]) ? (string) $vals[0] : '';
if (strlen($val)) {
return $val;
}
}
} elseif ('post' == $opt && isset($_POST[$this->name])) {
$vals = (array) $_POST[$this->name];
$vals = array_map('wpcf7_sanitize_query_var', $vals);
if ($args['multiple']) {
$values = array_merge($values, $vals);
} else {
$val = isset($vals[0]) ? (string) $vals[0] : '';
if (strlen($val)) {
return $val;
}
}
} elseif ('shortcode_attr' == $opt) {
if ($contact_form = WPCF7_ContactForm::get_current()) {
$val = $contact_form->shortcode_attr($this->name);
if (strlen($val)) {
if ($args['multiple']) {
$values[] = $val;
} else {
return $val;
}
}
}
}
}
if ($args['multiple']) {
$values = array_unique($values);
return $values;
} else {
return $default;
}
}
示例14: affwp_cf7_success_page_redirect
/**
* Redirect the user to the thanks/success page after submitting the form
*
* @since 1.0
*/
function affwp_cf7_success_page_redirect($contact_form)
{
// Success page ID
$success_page = affwp_cf7_get_success_page_id();
$submission = WPCF7_Submission::get_instance();
// get the value of the name field
$name = $submission->get_posted_data('your-name');
// get the description
$description = rawurlencode($contact_form->title());
// add customer's email address to the description
$description .= ' - ' . $submission->get_posted_data('your-email');
// set the reference to be the first name
$reference = isset($name) ? rawurlencode($name) : '';
// redirect to success page
if ($success_page) {
$wpcf7 = WPCF7_ContactForm::get_current();
$wpcf7->set_properties(array('additional_settings' => "on_sent_ok: \"location.replace(' " . add_query_arg(array('description' => $description, 'reference' => $reference, 'amount' => affwp_cf7_get_form_amount($contact_form->id())), get_permalink($success_page)) . " ');\""));
}
}
示例15: wpcf7_dynamichidden_shortcode_handler
function wpcf7_dynamichidden_shortcode_handler($tag)
{
$wpcf7_contact_form = WPCF7_ContactForm::get_current();
if (!is_array($tag)) {
return '';
}
$type = $tag['type'];
$name = $tag['name'];
$options = (array) $tag['options'];
$values = (array) $tag['values'];
if (empty($name)) {
return '';
}
$atts = '';
$id_att = '';
$class_att = '';
$size_att = '';
$maxlength_att = '';
$tabindex_att = '';
$class_att .= ' wpcf7-text';
foreach ($options as $option) {
if (preg_match('%^id:([-0-9a-zA-Z_]+)$%', $option, $matches)) {
$id_att = $matches[1];
}
}
if ($id_att) {
$atts .= ' id="' . trim($id_att) . '"';
}
// Value
if (is_a($wpcf7_contact_form, 'WPCF7_ContactForm') && $wpcf7_contact_form->is_posted()) {
if (isset($_POST['_wpcf7_mail_sent']) && $_POST['_wpcf7_mail_sent']['ok']) {
$value = '';
} else {
$value = stripslashes_deep($_POST[$name]);
}
} else {
$value = isset($values[0]) ? $values[0] : '';
}
$scval = do_shortcode('[' . $value . ']');
if ($scval != '[' . $value . ']') {
$value = $scval;
}
//echo '<pre>'; print_r($options);echo '</pre>';
$html = '<input type="hidden" name="' . $name . '" value="' . esc_attr($value) . '"' . $atts . ' />';
//No need to validate, it's a hidden field - we could validate by checking the value hasn't changed, but that seems overkill I think
//$validation_error = '';
//if ( is_a( $wpcf7_contact_form, 'WPCF7_ContactForm' ) )
// $validation_error = $wpcf7_contact_form->validation_error( $name );
$html = '<span class="wpcf7-form-control-wrap ' . $name . '">' . $html . '</span>';
return $html;
}