本文整理汇总了PHP中gf_apply_filters函数的典型用法代码示例。如果您正苦于以下问题:PHP gf_apply_filters函数的具体用法?PHP gf_apply_filters怎么用?PHP gf_apply_filters使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了gf_apply_filters函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: leads_page
//.........这里部分代码省略.........
case 'mark_read':
RGFormsModel::update_leads_property($leads, 'is_read', 1);
$update_message = sprintf(esc_html__('%s marked as read.', 'gravityforms'), $entry_count);
break;
case 'mark_unread':
RGFormsModel::update_leads_property($leads, 'is_read', 0);
$update_message = sprintf(esc_html__('%s marked as unread.', 'gravityforms'), $entry_count);
break;
case 'add_star':
RGFormsModel::update_leads_property($leads, 'is_starred', 1);
$update_message = sprintf(esc_html__('%s starred.', 'gravityforms'), $entry_count);
break;
case 'remove_star':
RGFormsModel::update_leads_property($leads, 'is_starred', 0);
$update_message = sprintf(esc_html__('%s unstarred.', 'gravityforms'), $entry_count);
break;
}
break;
case 'change_columns':
check_admin_referer('gforms_entry_list', 'gforms_entry_list');
$columns = GFCommon::json_decode(stripslashes($_POST['grid_columns']), true);
RGFormsModel::update_grid_column_meta($form_id, $columns);
break;
}
if (rgpost('button_delete_permanently')) {
if (GFCommon::current_user_can_any('gravityforms_delete_entries')) {
RGFormsModel::delete_leads_by_form($form_id, $filter);
}
}
$sort_field = empty($_GET['sort']) ? 0 : $_GET['sort'];
$sort_direction = empty($_GET['dir']) ? 'DESC' : $_GET['dir'];
$sort_field_meta = RGFormsModel::get_field($form, $sort_field);
$is_numeric = $sort_field_meta['type'] == 'number';
$page_size = gf_apply_filters('gform_entry_page_size', $form_id, 20, $form_id);
$first_item_index = $page_index * $page_size;
if (!empty($sort_field)) {
$sorting = array('key' => $_GET['sort'], 'direction' => $sort_direction, 'is_numeric' => $is_numeric);
} else {
$sorting = array();
}
$paging = array('offset' => $first_item_index, 'page_size' => $page_size);
$total_count = 0;
$leads = GFAPI::get_entries($form_id, $search_criteria, $sorting, $paging, $total_count);
$summary = RGFormsModel::get_form_counts($form_id);
$active_lead_count = $summary['total'];
$unread_count = $summary['unread'];
$starred_count = $summary['starred'];
$spam_count = $summary['spam'];
$trash_count = $summary['trash'];
$columns = RGFormsModel::get_grid_columns($form_id, true);
$search_qs = empty($search) ? '' : '&s=' . esc_attr(urlencode($search));
$sort_qs = empty($sort_field) ? '' : '&sort=' . esc_attr($sort_field);
$dir_qs = empty($sort_direction) ? '' : '&dir=' . esc_attr($sort_direction);
$star_qs = $star !== null ? '&star=' . esc_attr($star) : '';
$read_qs = $read !== null ? '&read=' . esc_attr($read) : '';
$filter_qs = '&filter=' . esc_attr($filter);
$search_field_id_qs = !isset($_GET['field_id']) ? '' : '&field_id=' . esc_attr($search_field_id);
$search_operator_urlencoded = urlencode($search_operator);
$search_operator_qs = empty($search_operator_urlencoded) ? '' : '&operator=' . esc_attr($search_operator_urlencoded);
$display_total = ceil($total_count / $page_size);
$page_links = paginate_links(array('base' => admin_url('admin.php') . "?page=gf_entries&view=entries&id={$form_id}&%_%" . $search_qs . $sort_qs . $dir_qs . $star_qs . $read_qs . $filter_qs . $search_field_id_qs . $search_operator_qs, 'format' => 'paged=%#%', 'prev_text' => esc_html__('«', 'gravityforms'), 'next_text' => esc_html__('»', 'gravityforms'), 'total' => $display_total, 'current' => $page_index + 1, 'show_all' => false));
wp_print_styles(array('thickbox'));
$field_filters = GFCommon::get_field_filter_settings($form);
$init_field_id = empty($search_field_id) ? 0 : $search_field_id;
$init_field_operator = empty($search_operator) ? 'contains' : $search_operator;
$init_filter_vars = array('mode' => 'off', 'filters' => array(array('field' => $init_field_id, 'operator' => $init_field_operator, 'value' => $search)));
示例2: get_field_input
/**
* Returns the field inner markup.
*
* @param array $form The Form Object currently being processed.
* @param string|array $value The field value. From default/dynamic population, $_POST, or a resumed incomplete submission.
* @param null|array $entry Null or the Entry Object currently being edited.
*
* @return string
*/
public function get_field_input($form, $value = '', $entry = null)
{
$form_id = absint($form['id']);
$is_entry_detail = $this->is_entry_detail();
$is_form_editor = $this->is_form_editor();
$id = $this->id;
$field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_{$id}" : 'input_' . $form_id . "_{$id}";
$logic_event = $this->get_conditional_logic_event('keyup');
$size = $this->size;
$class_suffix = $is_entry_detail ? '_admin' : '';
$class = $size . $class_suffix;
$css_class = trim(esc_attr($class) . ' gfield_select');
$tabindex = $this->get_tabindex();
$disabled_text = $is_form_editor ? 'disabled="disabled"' : '';
/**
* Allow the placeholder used by the enhanced ui to be overridden
*
* @param string $placeholder The placeholder text.
* @param integer $form_id The ID of the current form.
*/
$placeholder = gf_apply_filters(array('gform_multiselect_placeholder', $form_id, $this->id), __('Click to select...', 'gravityforms'), $form_id, $this);
$placeholder = $this->enableEnhancedUI ? "data-placeholder='" . esc_attr($placeholder) . "'" : '';
$size = $this->multiSelectSize;
if (empty($size)) {
$size = 7;
}
return sprintf("<div class='ginput_container ginput_container_multiselect'><select multiple='multiple' {$placeholder} size='{$size}' name='input_%d[]' id='%s' {$logic_event} class='%s' {$tabindex} %s>%s</select></div>", $id, esc_attr($field_id), $css_class, $disabled_text, $this->get_choices($value));
}
示例3: register_init_scripts
public function register_init_scripts($form)
{
if (!$this->has_copy_cat_field($form)) {
return;
}
$copy_fields = $this->get_copy_cat_fields($form);
$enable_overwrite = gf_apply_filters('gpcc_overwrite_existing_values', $form['id'], false, $form);
$script = 'new gwCopyObj( ' . $form['id'] . ', ' . json_encode($copy_fields) . ', ' . ($enable_overwrite ? 'true' : 'false') . ' );';
GFFormDisplay::add_init_script($form['id'], 'gp-copy-cat', GFFormDisplay::ON_PAGE_RENDER, $script);
}
示例4: get_field_input
public function get_field_input($form, $value = '', $entry = null)
{
if (is_array($value)) {
$value = array_values($value);
}
$form_id = $form['id'];
$is_entry_detail = $this->is_entry_detail();
$is_form_editor = $this->is_form_editor();
$is_admin = $is_entry_detail || $is_form_editor;
$id = (int) $this->id;
$field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_{$id}" : 'input_' . $form_id . "_{$id}";
$class_suffix = $is_entry_detail ? '_admin' : '';
$form_sub_label_placement = rgar($form, 'subLabelPlacement');
$field_sub_label_placement = $this->subLabelPlacement;
$is_sub_label_above = $field_sub_label_placement == 'above' || empty($field_sub_label_placement) && $form_sub_label_placement == 'above';
$sub_label_class_attribute = $field_sub_label_placement == 'hidden_label' ? "class='hidden_sub_label screen-reader-text'" : '';
$disabled_text = $is_form_editor ? 'disabled="disabled"' : '';
$first_tabindex = $this->get_tabindex();
$last_tabindex = $this->get_tabindex();
$strength_style = !$this->passwordStrengthEnabled ? "style='display:none;'" : '';
$strength_indicator_label = esc_html__('Strength indicator', 'gravityforms');
$strength = $this->passwordStrengthEnabled || $is_admin ? "<div id='{$field_id}_strength_indicator' class='gfield_password_strength' {$strength_style}>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{$strength_indicator_label}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<input type='hidden' class='gform_hidden' id='{$field_id}_strength' name='input_{$id}_strength' />" : '';
$action = !$is_admin ? "gformShowPasswordStrength(\"{$field_id}\");" : '';
$onchange = $this->passwordStrengthEnabled ? "onchange='{$action}'" : '';
$onkeyup = $this->passwordStrengthEnabled ? "onkeyup='{$action}'" : '';
$confirmation_value = rgpost('input_' . $id . '_2');
$password_value = is_array($value) ? $value[0] : $value;
$password_value = esc_attr($password_value);
$confirmation_value = esc_attr($confirmation_value);
$enter_password_field_input = GFFormsModel::get_input($this, $this->id . '');
$confirm_password_field_input = GFFormsModel::get_input($this, $this->id . '.2');
$enter_password_label = rgar($enter_password_field_input, 'customLabel') != '' ? $enter_password_field_input['customLabel'] : esc_html__('Enter Password', 'gravityforms');
$enter_password_label = gf_apply_filters(array('gform_password', $form_id), $enter_password_label, $form_id);
$confirm_password_label = rgar($confirm_password_field_input, 'customLabel') != '' ? $confirm_password_field_input['customLabel'] : esc_html__('Confirm Password', 'gravityforms');
$confirm_password_label = gf_apply_filters(array('gform_password_confirm', $form_id), $confirm_password_label, $form_id);
$required_attribute = $this->isRequired ? 'aria-required="true"' : '';
$invalid_attribute = $this->failed_validation ? 'aria-invalid="true"' : 'aria-invalid="false"';
$enter_password_placeholder_attribute = GFCommon::get_input_placeholder_attribute($enter_password_field_input);
$confirm_password_placeholder_attribute = GFCommon::get_input_placeholder_attribute($confirm_password_field_input);
if ($is_sub_label_above) {
return "<div class='ginput_complex{$class_suffix} ginput_container ginput_container_password' id='{$field_id}_container'>\n\t\t\t\t\t<span id='{$field_id}_1_container' class='ginput_left'>\n\t\t\t\t\t\t<label for='{$field_id}' {$sub_label_class_attribute}>{$enter_password_label}</label>\n\t\t\t\t\t\t<input type='password' name='input_{$id}' id='{$field_id}' {$onkeyup} {$onchange} value='{$password_value}' {$first_tabindex} {$enter_password_placeholder_attribute} {$required_attribute} {$invalid_attribute} {$disabled_text}/>\n\t\t\t\t\t</span>\n\t\t\t\t\t<span id='{$field_id}_2_container' class='ginput_right'>\n\t\t\t\t\t\t<label for='{$field_id}_2' {$sub_label_class_attribute}>{$confirm_password_label}</label>\n\t\t\t\t\t\t<input type='password' name='input_{$id}_2' id='{$field_id}_2' {$onkeyup} {$onchange} value='{$confirmation_value}' {$last_tabindex} {$confirm_password_placeholder_attribute} {$required_attribute} {$invalid_attribute} {$disabled_text}/>\n\t\t\t\t\t</span>\n\t\t\t\t\t<div class='gf_clear gf_clear_complex'></div>\n\t\t\t\t</div>{$strength}";
} else {
return "<div class='ginput_complex{$class_suffix} ginput_container ginput_container_password' id='{$field_id}_container'>\n\t\t\t\t\t<span id='{$field_id}_1_container' class='ginput_left'>\n\t\t\t\t\t\t<input type='password' name='input_{$id}' id='{$field_id}' {$onkeyup} {$onchange} value='{$password_value}' {$first_tabindex} {$enter_password_placeholder_attribute} {$required_attribute} {$invalid_attribute} {$disabled_text}/>\n\t\t\t\t\t\t<label for='{$field_id}' {$sub_label_class_attribute}>{$enter_password_label}</label>\n\t\t\t\t\t</span>\n\t\t\t\t\t<span id='{$field_id}_2_container' class='ginput_right'>\n\t\t\t\t\t\t<input type='password' name='input_{$id}_2' id='{$field_id}_2' {$onkeyup} {$onchange} value='{$confirmation_value}' {$last_tabindex} {$confirm_password_placeholder_attribute} {$required_attribute} {$invalid_attribute} {$disabled_text}/>\n\t\t\t\t\t\t<label for='{$field_id}_2' {$sub_label_class_attribute}>{$confirm_password_label}</label>\n\t\t\t\t\t</span>\n\t\t\t\t\t<div class='gf_clear gf_clear_complex'></div>\n\t\t\t\t</div>{$strength}";
}
}
示例5: get_field_input
public function get_field_input($form, $value = '', $entry = null)
{
$form_id = $form['id'];
$is_entry_detail = $this->is_entry_detail();
$is_form_editor = $this->is_form_editor();
$id = (int) $this->id;
$field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_{$id}" : 'input_' . $form_id . "_{$id}";
$product_name = !is_array($value) || empty($value[$this->id . '.1']) ? esc_attr($this->label) : esc_attr($value[$this->id . '.1']);
$price = !is_array($value) || empty($value[$this->id . '.2']) ? $this->basePrice : esc_attr($value[$this->id . '.2']);
$quantity = is_array($value) ? esc_attr($value[$this->id . '.3']) : '';
if (empty($price)) {
$price = 0;
}
$has_quantity = sizeof(GFCommon::get_product_fields_by_type($form, array('quantity'), $this->id)) > 0;
if ($has_quantity) {
$this->disableQuantity = true;
}
$currency = $is_entry_detail && !empty($entry) ? $entry['currency'] : '';
$quantity_field = '';
$disabled_text = $is_form_editor ? 'disabled="disabled"' : '';
$qty_input_type = GFFormsModel::is_html5_enabled() ? 'number' : 'text';
$qty_min_attr = GFFormsModel::is_html5_enabled() ? "min='0'" : '';
$product_quantity_sub_label = gf_apply_filters(array('gform_product_quantity', $form_id, $this->id), esc_html__('Quantity:', 'gravityforms'), $form_id);
if ($is_entry_detail || $is_form_editor) {
$style = $this->disableQuantity ? "style='display:none;'" : '';
$quantity_field = " <span class='ginput_quantity_label' {$style}>{$product_quantity_sub_label}</span> <input type='{$qty_input_type}' name='input_{$id}.3' value='{$quantity}' id='ginput_quantity_{$form_id}_{$this->id}' class='ginput_quantity' size='10' {$disabled_text}/>";
} else {
if (!$this->disableQuantity) {
$tabindex = $this->get_tabindex();
$quantity_field .= " <span class='ginput_quantity_label'>" . $product_quantity_sub_label . "</span> <input type='{$qty_input_type}' name='input_{$id}.3' value='{$quantity}' id='ginput_quantity_{$form_id}_{$this->id}' class='ginput_quantity' size='10' {$qty_min_attr} {$tabindex} {$disabled_text}/>";
} else {
if (!is_numeric($quantity)) {
$quantity = 1;
}
if (!$has_quantity) {
$quantity_field .= "<input type='hidden' name='input_{$id}.3' value='{$quantity}' class='ginput_quantity_{$form_id}_{$this->id} gform_hidden' />";
}
}
}
return "<div class='ginput_container ginput_container_singleproduct'>\n\t\t\t\t\t<input type='hidden' name='input_{$id}.1' value='{$product_name}' class='gform_hidden' />\n\t\t\t\t\t<span class='ginput_product_price_label'>" . gf_apply_filters(array('gform_product_price', $form_id, $this->id), esc_html__('Price', 'gravityforms'), $form_id) . ":</span> <span class='ginput_product_price' id='{$field_id}'>" . esc_html(GFCommon::to_money($price, $currency)) . "</span>\n\t\t\t\t\t<input type='hidden' name='input_{$id}.2' id='ginput_base_price_{$form_id}_{$this->id}' class='gform_hidden' value='" . esc_attr($price) . "'/>\n\t\t\t\t\t{$quantity_field}\n\t\t\t\t</div>";
}
示例6: get_field_input
public function get_field_input($form, $value = '', $entry = null)
{
$form_id = $form['id'];
$is_entry_detail = $this->is_entry_detail();
$is_form_editor = $this->is_form_editor();
$is_admin = $is_entry_detail || $is_form_editor;
$id = (int) $this->id;
$field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_{$id}" : 'input_' . $form_id . "_{$id}";
$value = esc_attr($value);
$size = $this->size;
$class_suffix = $is_entry_detail ? '_admin' : '';
$class = $size . $class_suffix;
$disabled_text = $is_form_editor ? 'disabled="disabled"' : '';
$title = esc_attr(rgget($this->id . '.1', $value));
$caption = esc_attr(rgget($this->id . '.4', $value));
$description = esc_attr(rgget($this->id . '.7', $value));
//hidding meta fields for admin
$hidden_style = "style='display:none;'";
$title_style = !$this->displayTitle && $is_admin ? $hidden_style : '';
$caption_style = !$this->displayCaption && $is_admin ? $hidden_style : '';
$description_style = !$this->displayDescription && $is_admin ? $hidden_style : '';
$file_label_style = $is_admin && !($this->displayTitle || $this->displayCaption || $this->displayDescription) ? $hidden_style : '';
$hidden_class = $preview = '';
$file_info = RGFormsModel::get_temp_filename($form_id, "input_{$id}");
if ($file_info) {
$hidden_class = ' gform_hidden';
$file_label_style = $hidden_style;
$preview = "<span class='ginput_preview'><strong>" . esc_html($file_info['uploaded_filename']) . "</strong> | <a href='javascript:;' onclick='gformDeleteUploadedFile({$form_id}, {$id});'>" . __('delete', 'gravityforms') . '</a></span>';
}
//in admin, render all meta fields to allow for immediate feedback, but hide the ones not selected
$file_label = $is_admin || $this->displayTitle || $this->displayCaption || $this->displayDescription ? "<label for='{$field_id}' class='ginput_post_image_file' {$file_label_style}>" . gf_apply_filters(array('gform_postimage_file', $form_id), __('File', 'gravityforms'), $form_id) . '</label>' : '';
$tabindex = $this->get_tabindex();
$upload = sprintf("<span class='ginput_full{$class_suffix}'>{$preview}<input name='input_%d' id='%s' type='file' value='%s' class='%s' {$tabindex} %s/>{$file_label}</span>", $id, $field_id, esc_attr($value), esc_attr($class . $hidden_class), $disabled_text);
$tabindex = $this->get_tabindex();
$title_field = $this->displayTitle || $is_admin ? sprintf("<span class='ginput_full{$class_suffix} ginput_post_image_title' {$title_style}><input type='text' name='input_%d.1' id='%s_1' value='%s' {$tabindex} %s/><label for='%s_1'>" . gf_apply_filters(array('gform_postimage_title', $form_id), __('Title', 'gravityforms'), $form_id) . '</label></span>', $id, $field_id, $title, $disabled_text, $field_id) : '';
$tabindex = $this->get_tabindex();
$caption_field = $this->displayCaption || $is_admin ? sprintf("<span class='ginput_full{$class_suffix} ginput_post_image_caption' {$caption_style}><input type='text' name='input_%d.4' id='%s_4' value='%s' {$tabindex} %s/><label for='%s_4'>" . gf_apply_filters(array('gform_postimage_caption', $form_id), __('Caption', 'gravityforms'), $form_id) . '</label></span>', $id, $field_id, $caption, $disabled_text, $field_id) : '';
$tabindex = $this->get_tabindex();
$description_field = $this->displayDescription || $is_admin ? sprintf("<span class='ginput_full{$class_suffix} ginput_post_image_description' {$description_style}><input type='text' name='input_%d.7' id='%s_7' value='%s' {$tabindex} %s/><label for='%s_7'>" . gf_apply_filters(array('gform_postimage_description', $form_id), __('Description', 'gravityforms'), $form_id) . '</label></span>', $id, $field_id, $description, $disabled_text, $field_id) : '';
return "<div class='ginput_complex{$class_suffix} ginput_container ginput_container_post_image'>" . $upload . $title_field . $caption_field . $description_field . '</div>';
}
示例7: send_notifications
/**
* Sends all active notifications for a form given an entry object and an event.
*
* @param $form
* @param $entry
* @param string $event Default = 'form_submission'
* @param array $data Optional. Array of data which can be used in the notifications via the generic {object:property} merge tag.
*
* @return array
*/
public static function send_notifications($form, $entry, $event = 'form_submission', $data = array())
{
if (rgempty('notifications', $form) || !is_array($form['notifications'])) {
return array();
}
$entry_id = rgar($entry, 'id');
GFCommon::log_debug("GFAPI::send_notifications(): Gathering notifications for {$event} event for entry #{$entry_id}.");
$notifications_to_send = array();
//running through filters that disable form submission notifications
foreach ($form['notifications'] as $notification) {
if (rgar($notification, 'event') != $event) {
continue;
}
if ($event == 'form_submission') {
if (rgar($notification, 'type') == 'user' && gf_apply_filters(array('gform_disable_user_notification', $form['id']), false, $form, $entry)) {
GFCommon::log_debug("GFAPI::send_notifications(): Notification is disabled by gform_disable_user_notification hook, not including notification (#{$notification['id']} - {$notification['name']}).");
//skip user notification if it has been disabled by a hook
continue;
} elseif (rgar($notification, 'type') == 'admin' && gf_apply_filters(array('gform_disable_admin_notification', $form['id']), false, $form, $entry)) {
GFCommon::log_debug("GFAPI::send_notifications(): Notification is disabled by gform_disable_admin_notification hook, not including notification (#{$notification['id']} - {$notification['name']}).");
//skip admin notification if it has been disabled by a hook
continue;
}
}
if (gf_apply_filters(array('gform_disable_notification', $form['id']), false, $notification, $form, $entry)) {
GFCommon::log_debug("GFAPI::send_notifications(): Notification is disabled by gform_disable_notification hook, not including notification (#{$notification['id']} - {$notification['name']}).");
//skip notifications if it has been disabled by a hook
continue;
}
$notifications_to_send[] = $notification['id'];
}
GFCommon::send_notifications($notifications_to_send, $form, $entry, true, $event, $data);
}
示例8: get_field_input
public function get_field_input($form, $value = '', $entry = null)
{
$is_entry_detail = $this->is_entry_detail();
$is_form_editor = $this->is_form_editor();
$form_id = $form['id'];
$id = intval($this->id);
$field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_{$id}" : 'input_' . $form_id . "_{$id}";
$form_id = ($is_entry_detail || $is_form_editor) && empty($form_id) ? rgget('id') : $form_id;
$disabled_text = $is_form_editor ? "disabled='disabled'" : '';
$class_suffix = $is_entry_detail ? '_admin' : '';
$form_sub_label_placement = rgar($form, 'subLabelPlacement');
$field_sub_label_placement = $this->subLabelPlacement;
$is_sub_label_above = $field_sub_label_placement == 'above' || empty($field_sub_label_placement) && $form_sub_label_placement == 'above';
$sub_label_class_attribute = $field_sub_label_placement == 'hidden_label' ? "class='hidden_sub_label screen-reader-text'" : '';
$card_number = '';
$card_name = '';
$expiration_month = '';
$expiration_year = '';
$security_code = '';
$autocomplete = RGFormsModel::is_html5_enabled() ? "autocomplete='off'" : '';
if (is_array($value)) {
$card_number = esc_attr(rgget($this->id . '.1', $value));
$card_name = esc_attr(rgget($this->id . '.5', $value));
$expiration_date = rgget($this->id . '.2', $value);
if (!is_array($expiration_date) && !empty($expiration_date)) {
$expiration_date = explode('/', $expiration_date);
}
if (is_array($expiration_date) && count($expiration_date) == 2) {
$expiration_month = $expiration_date[0];
$expiration_year = $expiration_date[1];
}
$security_code = esc_attr(rgget($this->id . '.3', $value));
}
$action = !($is_entry_detail || $is_form_editor) ? "gformMatchCard(\"{$field_id}_1\");" : '';
$onchange = "onchange='{$action}'";
$onkeyup = "onkeyup='{$action}'";
$card_icons = '';
$cards = GFCommon::get_card_types();
$card_style = $this->creditCardStyle ? $this->creditCardStyle : 'style1';
foreach ($cards as $card) {
$style = '';
if ($this->is_card_supported($card['slug'])) {
$print_card = true;
} elseif ($is_form_editor || $is_entry_detail) {
$print_card = true;
$style = "style='display:none;'";
} else {
$print_card = false;
}
if ($print_card) {
$card_icons .= "<div class='gform_card_icon gform_card_icon_{$card['slug']}' {$style}>{$card['name']}</div>";
}
}
$payment_methods = apply_filters('gform_payment_methods', array(), $this, $form_id);
$payment_options = '';
if (is_array($payment_methods)) {
foreach ($payment_methods as $payment_method) {
$checked = rgpost('gform_payment_method') == $payment_method['key'] ? "checked='checked'" : '';
$payment_options .= "<div class='gform_payment_option gform_payment_{$payment_method['key']}'><input type='radio' name='gform_payment_method' value='{$payment_method['key']}' id='gform_payment_method_{$payment_method['key']}' onclick='gformToggleCreditCard();' onkeypress='gformToggleCreditCard();' {$checked}/> {$payment_method['label']}</div>";
}
}
$checked = rgpost('gform_payment_method') == 'creditcard' || rgempty('gform_payment_method') ? "checked='checked'" : '';
$card_radio_button = empty($payment_options) ? '' : "<input type='radio' name='gform_payment_method' id='gform_payment_method_creditcard' value='creditcard' onclick='gformToggleCreditCard();' onkeypress='gformToggleCreditCard();' {$checked}/>";
$card_icons = "{$payment_options}<div class='gform_card_icon_container gform_card_icon_{$card_style}'>{$card_radio_button}{$card_icons}</div>";
//card number fields
$tabindex = $this->get_tabindex();
$card_number_field_input = GFFormsModel::get_input($this, $this->id . '.1');
$html5_output = !is_admin() && GFFormsModel::is_html5_enabled() ? "pattern='[0-9]*' title='" . esc_attr__('Only digits are allowed', 'gravityforms') . "'" : '';
$card_number_label = rgar($card_number_field_input, 'customLabel') != '' ? $card_number_field_input['customLabel'] : esc_html__('Card Number', 'gravityforms');
$card_number_label = gf_apply_filters(array('gform_card_number', $form_id), $card_number_label, $form_id);
$card_number_placeholder = $this->get_input_placeholder_attribute($card_number_field_input);
if ($is_sub_label_above) {
$card_field = "<span class='ginput_full{$class_suffix}' id='{$field_id}_1_container' >\n {$card_icons}\n <label for='{$field_id}_1' id='{$field_id}_1_label' {$sub_label_class_attribute}>{$card_number_label}</label>\n <input type='text' name='input_{$id}.1' id='{$field_id}_1' value='{$card_number}' {$tabindex} {$disabled_text} {$onchange} {$onkeyup} {$autocomplete} {$html5_output} {$card_number_placeholder}/>\n </span>";
} else {
$card_field = "<span class='ginput_full{$class_suffix}' id='{$field_id}_1_container' >\n {$card_icons}\n <input type='text' name='input_{$id}.1' id='{$field_id}_1' value='{$card_number}' {$tabindex} {$disabled_text} {$onchange} {$onkeyup} {$autocomplete} {$html5_output} {$card_number_placeholder}/>\n <label for='{$field_id}_1' id='{$field_id}_1_label' {$sub_label_class_attribute}>{$card_number_label}</label>\n </span>";
}
//expiration date field
$expiration_month_tab_index = $this->get_tabindex();
$expiration_year_tab_index = $this->get_tabindex();
$expiration_month_input = GFFormsModel::get_input($this, $this->id . '.2_month');
$expiration_month_placeholder = $this->get_input_placeholder_value($expiration_month_input);
$expiration_year_input = GFFormsModel::get_input($this, $this->id . '.2_year');
$expiration_year_placeholder = $this->get_input_placeholder_value($expiration_year_input);
$expiration_months = $this->get_expiration_months($expiration_month, $expiration_month_placeholder);
$expiration_years = $this->get_expiration_years($expiration_year, $expiration_year_placeholder);
$expiration_label = rgar($expiration_month_input, 'customLabel') != '' ? $expiration_month_input['customLabel'] : esc_html__('Expiration Date', 'gravityforms');
$expiration_label = gf_apply_filters(array('gform_card_expiration', $form_id), $expiration_label, $form_id);
if ($is_sub_label_above) {
$expiration_field = "<span class='ginput_full{$class_suffix} ginput_cardextras' id='{$field_id}_2_container'>\n <span class='ginput_cardinfo_left{$class_suffix}' id='{$field_id}_2_cardinfo_left'>\n <span class='ginput_card_expiration_container ginput_card_field'>\n <label for='{$field_id}_2_month' {$sub_label_class_attribute}>{$expiration_label}</label>\n <select name='input_{$id}.2[]' id='{$field_id}_2_month' {$expiration_month_tab_index} {$disabled_text} class='ginput_card_expiration ginput_card_expiration_month'>\n {$expiration_months}\n </select>\n <select name='input_{$id}.2[]' id='{$field_id}_2_year' {$expiration_year_tab_index} {$disabled_text} class='ginput_card_expiration ginput_card_expiration_year'>\n {$expiration_years}\n </select>\n </span>\n </span>";
} else {
$expiration_field = "<span class='ginput_full{$class_suffix} ginput_cardextras' id='{$field_id}_2_container'>\n <span class='ginput_cardinfo_left{$class_suffix}' id='{$field_id}_2_cardinfo_left'>\n <span class='ginput_card_expiration_container ginput_card_field'>\n <select name='input_{$id}.2[]' id='{$field_id}_2_month' {$expiration_month_tab_index} {$disabled_text} class='ginput_card_expiration ginput_card_expiration_month'>\n {$expiration_months}\n </select>\n <select name='input_{$id}.2[]' id='{$field_id}_2_year' {$expiration_year_tab_index} {$disabled_text} class='ginput_card_expiration ginput_card_expiration_year'>\n {$expiration_years}\n </select>\n <label for='{$field_id}_2_month' {$sub_label_class_attribute}>{$expiration_label}</label>\n </span>\n </span>";
}
//security code field
$tabindex = $this->get_tabindex();
$security_code_field_input = GFFormsModel::get_input($this, $this->id . '.3');
$security_code_label = rgar($security_code_field_input, 'customLabel') != '' ? $security_code_field_input['customLabel'] : esc_html__('Security Code', 'gravityforms');
$security_code_label = gf_apply_filters(array('gform_card_security_code', $form_id), $security_code_label, $form_id);
$html5_output = GFFormsModel::is_html5_enabled() ? "pattern='[0-9]*' title='" . esc_attr__('Only digits are allowed', 'gravityforms') . "'" : '';
$security_code_placeholder = $this->get_input_placeholder_attribute($security_code_field_input);
if ($is_sub_label_above) {
//.........这里部分代码省略.........
示例9: get_field_input
public function get_field_input($form, $value = '', $entry = null)
{
$lead_id = absint(rgar($entry, 'id'));
$form_id = absint($form['id']);
$is_entry_detail = $this->is_entry_detail();
$is_form_editor = $this->is_form_editor();
$id = absint($this->id);
$field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_{$id}" : 'input_' . $form_id . "_{$id}";
$size = $this->size;
$class_suffix = $is_entry_detail ? '_admin' : '';
$class = $size . $class_suffix;
$disabled_text = $is_form_editor ? 'disabled="disabled"' : '';
$tabindex = $this->get_tabindex();
$multiple_files = $this->multipleFiles;
$file_list_id = 'gform_preview_' . $form_id . '_' . $id;
$is_entry_detail = $this->is_entry_detail();
$is_form_editor = $this->is_form_editor();
$is_admin = $is_entry_detail || $is_form_editor;
$max_upload_size = !$is_admin && $this->maxFileSize > 0 ? $this->maxFileSize * 1048576 : wp_max_upload_size();
$allowed_extensions = !empty($this->allowedExtensions) ? join(',', GFCommon::clean_extensions(explode(',', strtolower($this->allowedExtensions)))) : array();
if (!empty($allowed_extensions)) {
$extensions_message = esc_attr(sprintf(__('Accepted file types: %s.', 'gravityforms'), str_replace(',', ', ', $allowed_extensions)));
} else {
$extensions_message = '';
}
if ($multiple_files) {
$upload_action_url = trailingslashit(site_url()) . '?gf_page=' . GFCommon::get_upload_page_slug();
$max_files = $this->maxFiles > 0 ? $this->maxFiles : 0;
$browse_button_id = 'gform_browse_button_' . $form_id . '_' . $id;
$container_id = 'gform_multifile_upload_' . $form_id . '_' . $id;
$drag_drop_id = 'gform_drag_drop_area_' . $form_id . '_' . $id;
$messages_id = "gform_multifile_messages_{$form_id}_{$id}";
if (empty($allowed_extensions)) {
$allowed_extensions = '*';
}
$disallowed_extensions = GFCommon::get_disallowed_file_extensions();
if (defined('DOING_AJAX') && DOING_AJAX && 'rg_change_input_type' === rgpost('action')) {
$plupload_init = array();
} else {
$plupload_init = array('runtimes' => 'html5,flash,html4', 'browse_button' => $browse_button_id, 'container' => $container_id, 'drop_element' => $drag_drop_id, 'filelist' => $file_list_id, 'unique_names' => true, 'file_data_name' => 'file', 'url' => $upload_action_url, 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'), 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'), 'filters' => array('mime_types' => array(array('title' => __('Allowed Files', 'gravityforms'), 'extensions' => $allowed_extensions)), 'max_file_size' => $max_upload_size . 'b'), 'multipart' => true, 'urlstream_upload' => false, 'multipart_params' => array('form_id' => $form_id, 'field_id' => $id), 'gf_vars' => array('max_files' => $max_files, 'message_id' => $messages_id, 'disallowed_extensions' => $disallowed_extensions));
if (rgar($form, 'requireLogin')) {
$plupload_init['multipart_params']['_gform_file_upload_nonce_' . $form_id] = wp_create_nonce('gform_file_upload_' . $form_id, '_gform_file_upload_nonce_' . $form_id);
}
// plupload 2 was introduced in WordPress 3.9. Plupload 1 accepts a slightly different init array.
if (version_compare(get_bloginfo('version'), '3.9-RC1', '<')) {
$plupload_init['max_file_size'] = $max_upload_size . 'b';
$plupload_init['filters'] = array(array('title' => __('Allowed Files', 'gravityforms'), 'extensions' => $allowed_extensions));
}
}
$plupload_init = gf_apply_filters('gform_plupload_settings', $form_id, $plupload_init, $form_id, $this);
$drop_files_here_text = esc_html__('Drop files here or', 'gravityforms');
$select_files_text = esc_attr__('Select files', 'gravityforms');
$plupload_init_json = htmlspecialchars(json_encode($plupload_init), ENT_QUOTES, 'UTF-8');
$upload = "<div id='{$container_id}' data-settings='{$plupload_init_json}' class='gform_fileupload_multifile'>\n\t\t\t\t\t\t\t\t\t\t<div id='{$drag_drop_id}' class='gform_drop_area'>\n\t\t\t\t\t\t\t\t\t\t\t<span class='gform_drop_instructions'>{$drop_files_here_text} </span>\n\t\t\t\t\t\t\t\t\t\t\t<input id='{$browse_button_id}' type='button' value='{$select_files_text}' class='button gform_button_select_files' aria-describedby='extensions_message' {$tabindex} />\n\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t</div>";
if (!$is_admin) {
$upload .= "<span id='extensions_message' class='screen-reader-text'>{$extensions_message}</span>";
$upload .= "<div class='validation_message'>\n\t\t\t\t\t\t\t\t<ul id='{$messages_id}'>\n\t\t\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t\t</div>";
}
if ($is_entry_detail) {
$upload .= sprintf('<input type="hidden" name="input_%d" value=\'%s\' />', $id, esc_attr($value));
}
} else {
$upload = '';
if ($max_upload_size <= 2047 * 1048576) {
// MAX_FILE_SIZE > 2048MB fails. The file size is checked anyway once uploaded, so it's not necessary.
$upload = sprintf("<input type='hidden' name='MAX_FILE_SIZE' value='%d' />", $max_upload_size);
}
$upload .= sprintf("<input name='input_%d' id='%s' type='file' class='%s' aria-describedby='extensions_message' {$tabindex} %s/>", $id, $field_id, esc_attr($class), $disabled_text);
if (!$is_admin) {
$upload .= "<span id='extensions_message' class='screen-reader-text'>{$extensions_message}</span>";
}
}
if ($is_entry_detail && !empty($value)) {
// edit entry
$file_urls = $multiple_files ? json_decode($value) : array($value);
$upload_display = $multiple_files ? '' : "style='display:none'";
$preview = "<div id='upload_{$id}' {$upload_display}>{$upload}</div>";
$preview .= sprintf("<div id='%s'></div>", $file_list_id);
$preview .= sprintf("<div id='preview_existing_files_%d'>", $id);
foreach ($file_urls as $file_index => $file_url) {
if (GFCommon::is_ssl() && strpos($file_url, 'http:') !== false) {
$file_url = str_replace('http:', 'https:', $file_url);
}
$download_file_text = esc_attr__('Download file', 'gravityforms');
$delete_file_text = esc_attr__('Delete file', 'gravityforms');
$file_index = intval($file_index);
$file_url = esc_attr($file_url);
$display_file_url = GFCommon::truncate_url($file_url);
$download_button_url = GFCommon::get_base_url() . '/images/download.png';
$delete_button_url = GFCommon::get_base_url() . '/images/delete.png';
$preview .= "<div id='preview_file_{$file_index}' class='ginput_preview'>\n\t\t\t\t\t\t\t\t<a href='{$file_url}' target='_blank' alt='{$file_url}' title='{$file_url}'>{$display_file_url}</a>\n\t\t\t\t\t\t\t\t<a href='{$file_url}' target='_blank' alt='{$download_file_text}' title='{$download_file_text}'>\n\t\t\t\t\t\t\t\t<img src='{$download_button_url}' style='margin-left:10px;'/></a><a href='javascript:void(0);' alt='{$delete_file_text}' title='{$delete_file_text}' onclick='DeleteFile({$lead_id},{$id},this);' ><img src='{$delete_button_url}' style='margin-left:10px;'/></a>\n\t\t\t\t\t\t\t</div>";
}
$preview .= '</div>';
return $preview;
} else {
$input_name = "input_{$id}";
$uploaded_files = isset(GFFormsModel::$uploaded_files[$form_id][$input_name]) ? GFFormsModel::$uploaded_files[$form_id][$input_name] : array();
$file_infos = $multiple_files ? $uploaded_files : RGFormsModel::get_temp_filename($form_id, $input_name);
if (!empty($file_infos)) {
$preview = sprintf("<div id='%s'>", $file_list_id);
//.........这里部分代码省略.........
示例10: Input
var monthInput = new Input(field.id + ".2_month", <?php
echo json_encode(gf_apply_filters(array('gform_card_expiration', rgget('id')), esc_html__('Expiration Month', 'gravityforms'), rgget('id')));
?>
);
monthInput.defaultLabel = <?php
echo json_encode(esc_html__('Expiration Date', 'gravityforms'));
?>
;
var yearInput = new Input(field.id + ".2_year", <?php
echo json_encode(esc_html__('Expiration Year', 'gravityforms'));
?>
);
field.inputs.splice(1, 1, monthInput, yearInput);
var nameInput = GetInput(field, field.id + ".5");
nameInput.label = <?php
echo json_encode(gf_apply_filters(array('gform_card_name', rgget('id')), __('Cardholder Name', 'gravityforms'), rgget('id')));
?>
;
}
return field;
}
function GetDefaultPrefixChoices() {
return new Array(new Choice(<?php
echo json_encode(esc_html__('Mr.', 'gravityforms'));
?>
), new Choice(<?php
echo json_encode(esc_html__('Mrs.', 'gravityforms'));
?>
), new Choice(<?php
示例11: get_field_input
public function get_field_input($form, $value = '', $entry = null)
{
$is_entry_detail = $this->is_entry_detail();
$is_form_editor = $this->is_form_editor();
if (is_array($value)) {
$value = array_values($value);
}
$form_id = absint($form['id']);
$id = absint($this->id);
$field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_{$id}" : 'input_' . $form_id . "_{$id}";
$form_id = ($is_entry_detail || $is_form_editor) && empty($form_id) ? rgget('id') : $form_id;
$size = $this->size;
$disabled_text = $is_form_editor ? "disabled='disabled'" : '';
$class_suffix = $is_entry_detail ? '_admin' : '';
$class = $this->emailConfirmEnabled ? '' : $size . $class_suffix;
//Size only applies when confirmation is disabled
$form_sub_label_placement = rgar($form, 'subLabelPlacement');
$field_sub_label_placement = $this->subLabelPlacement;
$is_sub_label_above = $field_sub_label_placement == 'above' || empty($field_sub_label_placement) && $form_sub_label_placement == 'above';
$sub_label_class_attribute = $field_sub_label_placement == 'hidden_label' ? "class='hidden_sub_label screen-reader-text'" : '';
$html_input_type = RGFormsModel::is_html5_enabled() ? 'email' : 'text';
$required_attribute = $this->isRequired ? 'aria-required="true"' : '';
$invalid_attribute = $this->failed_validation ? 'aria-invalid="true"' : 'aria-invalid="false"';
$enter_email_field_input = GFFormsModel::get_input($this, $this->id . '');
$confirm_field_input = GFFormsModel::get_input($this, $this->id . '.2');
$enter_email_label = rgar($enter_email_field_input, 'customLabel') != '' ? $enter_email_field_input['customLabel'] : esc_html__('Enter Email', 'gravityforms');
$enter_email_label = gf_apply_filters(array('gform_email', $form_id), $enter_email_label, $form_id);
$confirm_email_label = rgar($confirm_field_input, 'customLabel') != '' ? $confirm_field_input['customLabel'] : esc_html__('Confirm Email', 'gravityforms');
$confirm_email_label = gf_apply_filters(array('gform_email_confirm', $form_id), $confirm_email_label, $form_id);
$single_placeholder_attribute = $this->get_field_placeholder_attribute();
$enter_email_placeholder_attribute = $this->get_input_placeholder_attribute($enter_email_field_input);
$confirm_email_placeholder_attribute = $this->get_input_placeholder_attribute($confirm_field_input);
if ($is_form_editor) {
$single_style = $this->emailConfirmEnabled ? "style='display:none;'" : '';
$confirm_style = $this->emailConfirmEnabled ? '' : "style='display:none;'";
if ($is_sub_label_above) {
return "<div class='ginput_container ginput_container_email ginput_single_email' {$single_style}>\n <input name='input_{$id}' type='{$html_input_type}' class='" . esc_attr($class) . "' disabled='disabled' {$single_placeholder_attribute} {$required_attribute} {$invalid_attribute} />\n <div class='gf_clear gf_clear_complex'></div>\n </div>\n <div class='ginput_complex ginput_container ginput_container_email ginput_confirm_email' {$confirm_style} id='{$field_id}_container'>\n <span id='{$field_id}_1_container' class='ginput_left'>\n <label for='{$field_id}' {$sub_label_class_attribute}>{$enter_email_label}</label>\n <input class='{$class}' type='text' name='input_{$id}' id='{$field_id}' disabled='disabled' {$enter_email_placeholder_attribute} {$required_attribute} {$invalid_attribute} />\n </span>\n <span id='{$field_id}_2_container' class='ginput_right'>\n <label for='{$field_id}_2' {$sub_label_class_attribute}>{$confirm_email_label}</label>\n <input class='{$class}' type='text' name='input_{$id}_2' id='{$field_id}_2' disabled='disabled' {$confirm_email_placeholder_attribute} {$required_attribute} {$invalid_attribute} />\n </span>\n <div class='gf_clear gf_clear_complex'></div>\n </div>";
} else {
return "<div class='ginput_container ginput_container_email ginput_single_email' {$single_style}>\n <input class='{$class}' name='input_{$id}' type='{$html_input_type}' class='" . esc_attr($class) . "' disabled='disabled' {$single_placeholder_attribute} {$required_attribute} {$invalid_attribute} />\n <div class='gf_clear gf_clear_complex'></div>\n </div>\n <div class='ginput_complex ginput_container ginput_container_email ginput_confirm_email' {$confirm_style} id='{$field_id}_container'>\n <span id='{$field_id}_1_container' class='ginput_left'>\n <input class='{$class}' type='text' name='input_{$id}' id='{$field_id}' disabled='disabled' {$enter_email_placeholder_attribute} {$required_attribute} {$invalid_attribute} />\n <label for='{$field_id}' {$sub_label_class_attribute}>{$enter_email_label}</label>\n </span>\n <span id='{$field_id}_2_container' class='ginput_right'>\n <input class='{$class}' type='text' name='input_{$id}_2' id='{$field_id}_2' disabled='disabled' {$confirm_email_placeholder_attribute} {$required_attribute} {$invalid_attribute} />\n <label for='{$field_id}_2' {$sub_label_class_attribute}>{$confirm_email_label}</label>\n </span>\n <div class='gf_clear gf_clear_complex'></div>\n </div>";
}
} else {
$logic_event = $this->get_conditional_logic_event('keyup');
if ($this->emailConfirmEnabled && !$is_entry_detail) {
$first_tabindex = $this->get_tabindex();
$last_tabindex = $this->get_tabindex();
$email_value = is_array($value) ? $value[0] : $value;
$email_value = esc_attr($email_value);
$confirmation_value = is_array($value) ? $value[1] : rgpost('input_' . $this->id . '_2');
$confirmation_value = esc_attr($confirmation_value);
$confirmation_disabled = $is_entry_detail ? "disabled='disabled'" : $disabled_text;
if ($is_sub_label_above) {
return "<div class='ginput_complex ginput_container ginput_container_email' id='{$field_id}_container'>\n <span id='{$field_id}_1_container' class='ginput_left'>\n <label for='{$field_id}'>" . $enter_email_label . "</label>\n <input class='{$class}' type='{$html_input_type}' name='input_{$id}' id='{$field_id}' value='{$email_value}' {$first_tabindex} {$logic_event} {$disabled_text} {$enter_email_placeholder_attribute} {$required_attribute} {$invalid_attribute}/>\n </span>\n <span id='{$field_id}_2_container' class='ginput_right'>\n <label for='{$field_id}_2' {$sub_label_class_attribute}>{$confirm_email_label}</label>\n <input class='{$class}' type='{$html_input_type}' name='input_{$id}_2' id='{$field_id}_2' value='{$confirmation_value}' {$last_tabindex} {$confirmation_disabled} {$confirm_email_placeholder_attribute} {$required_attribute} {$invalid_attribute}/>\n </span>\n <div class='gf_clear gf_clear_complex'></div>\n </div>";
} else {
return "<div class='ginput_complex ginput_container ginput_container_email' id='{$field_id}_container'>\n <span id='{$field_id}_1_container' class='ginput_left'>\n <input class='{$class}' type='{$html_input_type}' name='input_{$id}' id='{$field_id}' value='{$email_value}' {$first_tabindex} {$logic_event} {$disabled_text} {$enter_email_placeholder_attribute} {$required_attribute} {$invalid_attribute}/>\n <label for='{$field_id}' {$sub_label_class_attribute}>{$enter_email_label}</label>\n </span>\n <span id='{$field_id}_2_container' class='ginput_right'>\n <input class='{$class}' type='{$html_input_type}' name='input_{$id}_2' id='{$field_id}_2' value='{$confirmation_value}' {$last_tabindex} {$confirmation_disabled} {$confirm_email_placeholder_attribute} {$required_attribute} {$invalid_attribute}/>\n <label for='{$field_id}_2' {$sub_label_class_attribute}>{$confirm_email_label}</label>\n </span>\n <div class='gf_clear gf_clear_complex'></div>\n </div>";
}
} else {
$tabindex = $this->get_tabindex();
$value = esc_attr($value);
$class = esc_attr($class);
return "<div class='ginput_container ginput_container_email'>\n <input name='input_{$id}' id='{$field_id}' type='{$html_input_type}' value='{$value}' class='{$class}' {$tabindex} {$logic_event} {$disabled_text} {$single_placeholder_attribute}/>\n </div>";
}
}
}
示例12: handle_save_confirmation
public static function handle_save_confirmation($form, $resume_token, $confirmation_message, $ajax)
{
$resume_email = isset($_POST['gform_resume_email']) ? $_POST['gform_resume_email'] : null;
$confirmation_message = self::replace_save_variables($confirmation_message, $form, $resume_token, $resume_email);
$confirmation_message = GFCommon::gform_do_shortcode($confirmation_message);
$confirmation_message = "<div class='form_saved_message'><span>" . $confirmation_message . '</span></div>';
$form_id = absint($form['id']);
$has_pages = self::has_pages($form);
$default_anchor = $has_pages || $ajax ? true : false;
$use_anchor = gf_apply_filters(array('gform_confirmation_anchor', $form_id), $default_anchor);
if ($use_anchor !== false) {
$confirmation_message = "<a id='gf_{$form_id}' class='gform_anchor' ></a>" . $confirmation_message;
}
$wrapper_css_class = GFCommon::get_browser_class() . ' gform_wrapper';
$confirmation_message = "<div class='{$wrapper_css_class}' id='gform_wrapper_{$form_id}'>" . $confirmation_message . '</div>';
if ($ajax) {
$confirmation_message = "<!DOCTYPE html><html><head><meta charset='UTF-8' /></head><body class='GF_AJAX_POSTBACK'>" . $confirmation_message . '</body></html>';
}
GFCommon::log_debug('GFFormDisplay::handle_save_confirmation(): Confirmation => ' . print_r($confirmation_message, true));
return $confirmation_message;
}
示例13: sanitize_entry_value
/**
* Override this method to implement the appropriate sanitization specific to the field type before the value is saved.
*
* This base method provides a generic sanitization similar to wp_kses but values are not encoded.
* Scripts are stripped out leaving allowed tags if HTMl is allowed.
*
* @param string $value The field value to be processed.
* @param int $form_id The ID of the form currently being processed.
*
* @return string
*/
public function sanitize_entry_value($value, $form_id)
{
if (is_array($value)) {
return '';
}
//allow HTML for certain field types
$allow_html = $this->allow_html();
$allowable_tags = gf_apply_filters(array('gform_allowable_tags', $form_id), $allow_html, $this, $form_id);
if ($allowable_tags !== true) {
$value = strip_tags($value, $allowable_tags);
}
$allowed_protocols = wp_allowed_protocols();
$value = wp_kses_no_null($value, array('slash_zero' => 'keep'));
$value = wp_kses_hook($value, 'post', $allowed_protocols);
$value = wp_kses_split($value, 'post', $allowed_protocols);
return $value;
}
示例14: forms_page
//.........这里部分代码省略.........
InsertVariable(element_id, callback);
}
function IsValidFormula(formula) {
if (formula == '')
return true;
var patt = /{([^}]+)}/i,
exprPatt = /^[0-9 -/*\(\)]+$/i,
expr = formula.replace(/(\r\n|\n|\r)/gm, ''),
match;
while (match = patt.exec(expr)) {
expr = expr.replace(match[0], 1);
}
if (exprPatt.test(expr)) {
try {
var r = eval(expr);
return !isNaN(parseFloat(r)) && isFinite(r);
} catch (e) {
return false;
}
} else {
return false;
}
}
</script>
<?php
$form = !rgempty('meta', $update_result) ? rgar($update_result, 'meta') : GFFormsModel::get_form_meta($form_id);
if (!isset($form['fields']) || !is_array($form['fields'])) {
$form['fields'] = array();
}
$form = gf_apply_filters(array('gform_admin_pre_render', $form_id), $form);
if (isset($form['id'])) {
echo "<script type=\"text/javascript\">var form = " . json_encode($form) . ';</script>';
} else {
echo "<script type=\"text/javascript\">var form = new Form();</script>";
}
?>
<?php
echo GFCommon::get_remote_message();
?>
<div class="wrap gforms_edit_form <?php
echo GFCommon::get_browser_class();
?>
">
<?php
if (empty($form_id)) {
?>
<h2 class="gf_admin_page_title"><?php
esc_html_e('New Form', 'gravityforms');
?>
</h2>
<?php
} else {
?>
<h2 class="gf_admin_page_title">
<span><?php
esc_html_e('Form Editor', 'gravityforms');
?>
</span><span class="gf_admin_page_subtitle"><span class="gf_admin_page_formid">ID: <?php
echo absint($form['id']);
?>
</span><span class="gf_admin_page_formname"><?php
示例15: redirect_url
public function redirect_url($feed, $submission_data, $form, $entry)
{
//Don't process redirect url if request is a PayPal return
if (!rgempty('gf_paypal_return', $_GET)) {
return false;
}
//updating lead's payment_status to Processing
GFAPI::update_entry_property($entry['id'], 'payment_status', 'Processing');
//Getting Url (Production or Sandbox)
$url = $feed['meta']['mode'] == 'production' ? $this->production_url : $this->sandbox_url;
$invoice_id = apply_filters('gform_paypal_invoice', '', $form, $entry);
$invoice = empty($invoice_id) ? '' : "&invoice={$invoice_id}";
//Current Currency
$currency = GFCommon::get_currency();
//Customer fields
$customer_fields = $this->customer_query_string($feed, $entry);
//Page style
$page_style = !empty($feed['meta']['pageStyle']) ? '&page_style=' . urlencode($feed['meta']['pageStyle']) : '';
//Continue link text
$continue_text = !empty($feed['meta']['continueText']) ? '&cbt=' . urlencode($feed['meta']['continueText']) : '&cbt=' . __('Click here to continue', 'gravityformspaypal');
//Set return mode to 2 (PayPal will post info back to page). rm=1 seems to create lots of problems with the redirect back to the site. Defaulting it to 2.
$return_mode = '2';
$return_url = '&return=' . urlencode($this->return_url($form['id'], $entry['id'])) . "&rm={$return_mode}";
//Cancel URL
$cancel_url = !empty($feed['meta']['cancelUrl']) ? '&cancel_return=' . urlencode($feed['meta']['cancelUrl']) : '';
//Don't display note section
$disable_note = !empty($feed['meta']['disableNote']) ? '&no_note=1' : '';
//Don't display shipping section
$disable_shipping = !empty($feed['meta']['disableShipping']) ? '&no_shipping=1' : '';
//URL that will listen to notifications from PayPal
$ipn_url = urlencode(get_bloginfo('url') . '/?page=gf_paypal_ipn');
$business_email = urlencode(trim($feed['meta']['paypalEmail']));
$custom_field = $entry['id'] . '|' . wp_hash($entry['id']);
$url .= "?notify_url={$ipn_url}&charset=UTF-8¤cy_code={$currency}&business={$business_email}&custom={$custom_field}{$invoice}{$customer_fields}{$page_style}{$continue_text}{$cancel_url}{$disable_note}{$disable_shipping}{$return_url}";
$query_string = '';
switch ($feed['meta']['transactionType']) {
case 'product':
//build query string using $submission_data
$query_string = $this->get_product_query_string($submission_data, $entry['id']);
break;
case 'donation':
$query_string = $this->get_donation_query_string($submission_data, $entry['id']);
break;
case 'subscription':
$query_string = $this->get_subscription_query_string($feed, $submission_data, $entry['id']);
break;
}
$query_string = gf_apply_filters('gform_paypal_query', $form['id'], $query_string, $form, $entry, $feed, $submission_data);
if (!$query_string) {
$this->log_debug(__METHOD__ . '(): NOT sending to PayPal: The price is either zero or the gform_paypal_query filter was used to remove the querystring that is sent to PayPal.');
return '';
}
$url .= $query_string;
$url = gf_apply_filters('gform_paypal_request', $form['id'], $url, $form, $entry, $feed, $submission_data);
//add the bn code (build notation code)
$url .= '&bn=Rocketgenius_SP';
$this->log_debug(__METHOD__ . "(): Sending to PayPal: {$url}");
return $url;
}