public function sanitize_settings() { parent::sanitize_settings(); if ($this->phoneFormat && !in_array($this->phoneFormat, array('standard', 'international'))) { $this->phoneFormat = 'standard'; } }
public function sanitize_settings() { parent::sanitize_settings(); if (is_multisite() || !current_user_can('manage_options')) { $allowed_tags = wp_kses_allowed_html('post'); $this->content = wp_kses($this->content, $allowed_tags); } }
public function sanitize_settings() { parent::sanitize_settings(); $this->enableEnhancedUI = (bool) $this->enableEnhancedUI; if ($this->type === 'post_category') { $this->displayAllCategories = (bool) $this->displayAllCategories; } }
private function maybe_fire_array_access_deprecation_notice($offset) { if (self::SUPPRESS_DEPRECATION_NOTICE) { return; } if (!self::$deprecation_notice_fired) { _deprecated_function('Array access to the field object is now deprecated. Further notices will be suppressed. Offset: ' . $offset, '1.9', 'the object operator e.g. $field->' . $offset); self::$deprecation_notice_fired = true; } }
public function sanitize_settings() { parent::sanitize_settings(); if ($this->nextButton) { $this->nextButton['imageUrl'] = wp_strip_all_tags($this->nextButton['imageUrl']); $allowed_tags = wp_kses_allowed_html('post'); $this->nextButton['text'] = wp_kses($this->nextButton['text'], $allowed_tags); $this->nextButton['type'] = wp_strip_all_tags($this->nextButton['type']); if (isset($this->nextButton['conditionalLogic']) && is_array($this->nextButton['conditionalLogic'])) { $this->nextButton['conditionalLogic'] = $this->sanitize_settings_conditional_logic($this->nextButton['conditionalLogic']); } } }
/** * Fires the deprecation notice only once per page. Not fired during AJAX requests. * * @param string $offset The array key being accessed. */ private function maybe_fire_array_access_deprecation_notice($offset) { if (self::SUPPRESS_DEPRECATION_NOTICE) { return; } if (defined('DOING_AJAX') && DOING_AJAX) { return; } if (!self::$deprecation_notice_fired) { _deprecated_function("Array access to the field object is now deprecated. Further notices will be suppressed. \$field['" . $offset . "']", '2.0', 'the object operator e.g. $field->' . $offset); self::$deprecation_notice_fired = true; } }
/** * @deprecated * * @param GF_Field $field * * @return mixed */ public static function has_field_calculation($field) { _deprecated_function('has_field_calculation', '1.7', 'GF_Field::has_calculation'); return $field->has_calculation(); }
public function sanitize_settings() { parent::sanitize_settings(); $allowed_tags = wp_kses_allowed_html('post'); $this->content = wp_kses($this->content, $allowed_tags); }
public function get_value_default() { $value = parent::get_value_default(); if (is_array($this->inputs)) { $value = $this->get_date_array_by_format($value); } return $value; }
/** * Validate the card type and prevent the field from failing required validation, Stripe.js will handle the required validation. * * The card field inputs are erased on submit, this will cause two issues: * 1. The field will fail standard validation if marked as required. * 2. The card type validation will not be performed. * * @param array $result The field validation result and message. * @param mixed $value The field input values; empty for the credit card field as they are cleared by frontend.js. * @param array $form The Form currently being processed. * @param GF_Field $field The field currently being processed. * * @return array */ public function pre_validation($result, $value, $form, $field) { // If this is a credit card field and the last four credit card digits are defined, validate. if ($field->type == 'creditcard' && rgpost('stripe_credit_card_last_four')) { // Get card slug. $card_type = rgpost('stripe_credit_card_type'); $card_slug = $this->get_card_slug($card_type); // If credit card type is not supported, mark field as invalid. if (!$field->is_card_supported($card_slug)) { $result['is_valid'] = false; $result['message'] = $card_type . ' ' . esc_html__('is not supported. Please enter one of the supported credit cards.', 'gravityforms'); } else { $result['is_valid'] = true; $result['message'] = ''; } } return $result; }
public function sanitize_settings() { parent::sanitize_settings(); if ($this->addressType) { $this->addressType = wp_strip_all_tags($this->addressType); } if ($this->defaultCountry) { $this->defaultCountry = wp_strip_all_tags($this->defaultCountry); } if ($this->defaultProvince) { $this->defaultProvince = wp_strip_all_tags($this->defaultProvince); } }
/** * Validate the card type and prevent the field from failing required validation, Stripe.js will handle the required validation. * * The card field inputs are erased on submit, this will cause two issues: * 1. The field will fail standard validation if marked as required. * 2. The card type validation will not be performed. * * @param array $result The field validation result and message. * @param mixed $value The field input values; empty for the credit card field as they are cleared by frontend.js * @param array $form The Form currently being processed. * @param GF_Field $field The field currently being processed. * * @return array */ public function pre_validation($result, $value, $form, $field) { if ($field->type == 'creditcard' && rgpost('stripe_credit_card_last_four')) { $this->populate_credit_card_last_four($form); $card_type = rgpost('stripe_credit_card_type'); $card_slug = $this->get_card_slug($card_type); if (!$field->is_card_supported($card_slug)) { $result['is_valid'] = false; $result['message'] = $card_type . ' ' . esc_html__('is not supported. Please enter one of the supported credit cards.', 'gravityforms'); } else { $result['is_valid'] = true; $result['message'] = ''; } } return $result; }
public function get_value_default() { $value = parent::get_value_default(); // the default value for mulit-input date fields will always be an array in mdy order // this code will alter the order of the values to the date format of the field if (is_array($this->inputs)) { $format = empty($this->dateFormat) ? 'mdy' : esc_attr($this->dateFormat); $position = substr($format, 0, 3); $date = array_combine(array('m', 'd', 'y'), $value); // takes our numerical array and converts it to an associative array $value = array_merge(array_flip(str_split($position)), $date); // uses the mdy position as the array keys and creates a new array in the desired order } return $value; }
public function sanitize_settings() { parent::sanitize_settings(); $this->gsurveyLikertEnableMultipleRows = (bool) $this->gsurveyLikertEnableMultipleRows; $this->gsurveyLikertEnableScoring = (bool) $this->gsurveyLikertEnableScoring; if ($this->gsurveyLikertEnableMultipleRows && is_array($this->gsurveyLikertRows)) { foreach ($this->gsurveyLikertRows as &$row) { if (isset($row['text'])) { $row['text'] = trim($this->maybe_wp_kses($row['text'])); } if (isset($row['value'])) { $row['value'] = wp_strip_all_tags($row['value']); } } } }
/** * Prepare the value before saving it to the lead. * * @param mixed $form * @param GF_Field $field * @param mixed $value * @param mixed $input_name * @param mixed $lead_id the current lead ID, used for fields that are processed after other fields have been saved (ie Total, Calculations) * @param mixed $lead passed by the RGFormsModel::create_lead() method, lead ID is not available for leads created by this function * * @return mixed */ public static function prepare_value($form, $field, $value, $input_name, $lead_id, $lead = array()) { $value = $field->get_value_save_entry($value, $form, $input_name, $lead_id, $lead); // special format for Post Category fields if ($field->type == 'post_category') { $full_values = array(); if (!is_array($value)) { $value = explode(',', $value); } foreach ($value as $cat_id) { $cat = get_term($cat_id, 'category'); $full_values[] = !is_wp_error($cat) && is_object($cat) ? $cat->name . ':' . $cat_id : ''; } $value = implode(',', $full_values); } //do not save price fields with blank price if ($field->enablePrice) { $ary = explode('|', $value); $label = count($ary) > 0 ? $ary[0] : ''; $price = count($ary) > 1 ? $ary[1] : ''; $is_empty = strlen(trim($price)) <= 0; if ($is_empty) { $value = ''; } } return $value; }
public function sanitize_settings() { parent::sanitize_settings(); $this->calendarIconType = wp_strip_all_tags($this->calendarIconType); $this->calendarIconUrl = wp_strip_all_tags($this->calendarIconUrl); if ($this->dateFormat && !in_array($this->dateFormat, array('mdy', 'dmy', 'dmy_dash', 'dmy_dot', 'ymd_slash', 'ymd_dash', 'ymd_dot'))) { $this->dateFormat = 'mdy'; } }
public function get_value_submission($field_values, $get_from_post_global_var = true) { $value = parent::get_value_submission($field_values, $get_from_post_global_var); $value[$this->id . '_copy_values_activated'] = rgpost('input_' . $this->id . '_copy_values_activated'); return $value; }
/** * Format the Poll field values for display on the entry detail page and print entry. * * @param string|array $value The field value. * @param GF_Field $field The field currently being processed. * @param array $entry The entry object currently being processed. * @param array $form The form object currently being processed. * * @return string|array */ public function display_poll_on_entry_detail($value, $field, $entry, $form) { if ($field->type == 'poll') { if ($field->is_entry_detail()) { $results = $this->gpoll_get_results($form['id'], $field->id, 'green', true, true, $entry); $new_value = sprintf('<div class="gpoll_entry">%s</div>', rgar($results, 'summary')); $this->gpoll_add_scripts = true; //if original response is not in results display below $selected_values = $this->get_selected_values($form['id'], $field->id, $entry); $possible_choices = $this->get_possible_choices($form['id'], $field->id); foreach ($selected_values as $selected_value) { if (!in_array($selected_value, $possible_choices)) { $new_value = sprintf('%s<h2>%s</h2>%s', $new_value, esc_html__('Original Response', 'gravityformspolls'), $value); break; } } return $new_value; } elseif (is_array($field->choices)) { if ($field->inputType == 'checkbox') { foreach ($field->choices as $choice) { $val = rgar($choice, 'value'); $text = rgar($choice, 'text'); $value = str_replace($val, $text, $value); } } else { $value = RGFormsModel::get_choice_text($field, $value); } } } return $value; }
public function sanitize_settings() { parent::sanitize_settings(); if (!$this->get_phone_format()) { $this->phoneFormat = 'standard'; } }
/** * Support for legacy Time fields which did not have an inputs array * * @param $form * * @return string */ public function get_first_input_id($form) { // legacy (< 1.9) Time fields did not have an inputs array if (!is_array($this->inputs)) { return 'input_' . $form['id'] . '_' . $this->id . '_1'; } return parent::get_first_input_id($form); }
public function sanitize_settings() { parent::sanitize_settings(); if (!$this->timeFormat || !in_array($this->timeFormat, array(12, 24))) { $this->timeFormat = '12'; } }
public function sanitize_settings() { parent::sanitize_settings(); $this->enableCalculation = (bool) $this->enableCalculation; if ($this->numberFormat == 'currency') { require_once GFCommon::get_base_path() . '/currency.php'; $currency = new RGCurrency(GFCommon::get_currency()); $this->rangeMin = $currency->to_number($this->rangeMin); $this->rangeMax = $currency->to_number($this->rangeMax); } elseif ($this->numberFormat == 'decimal_comma') { $this->rangeMin = GFCommon::clean_number($this->rangeMin, 'decimal_comma'); $this->rangeMax = GFCommon::clean_number($this->rangeMax, 'decimal_comma'); } elseif ($this->numberFormat == 'decimal_dot') { $this->rangeMin = GFCommon::clean_number($this->rangeMin, 'decimal_dot'); $this->rangeMin = GFCommon::clean_number($this->rangeMin, 'decimal_dot'); } }
/** * @param GF_Field $field * @param string $value * @param bool $force_frontend_label * @param int $form_id * @param null|array $form * * @return string */ public static function get_field_content($field, $value = '', $force_frontend_label = false, $form_id = 0, $form = null) { $field_label = $field->get_field_label($form, $value); $admin_buttons = $field->get_admin_buttons(); $input_type = GFFormsModel::get_input_type($field); $is_form_editor = GFCommon::is_form_editor(); $is_entry_detail = GFCommon::is_entry_detail(); $is_admin = $is_form_editor || $is_entry_detail; if ($input_type == 'adminonly_hidden') { $field_content = !$is_admin ? '{FIELD}' : sprintf("%s<label class='gfield_label' >%s</label>{FIELD}", $admin_buttons, esc_html($field_label)); } else { $field_content = $field->get_field_content($value, $force_frontend_label, $form); } if ($input_type == 'creditcard' && !GFCommon::is_ssl() && !$is_admin) { $field_content = "<div class='gfield_creditcard_warning_message'><span>" . esc_html__('This page is unsecured. Do not enter a real credit card number! Use this field only for testing purposes. ', 'gravityforms') . '</span></div>' . $field_content; } $value = $field->get_value_default_if_empty($value); $field_content = str_replace('{FIELD}', GFCommon::get_field_input($field, $value, 0, $form_id, $form), $field_content); $field_content = apply_filters('gform_field_content', $field_content, $field, $value, 0, $form_id); return $field_content; }
public function sanitize_settings() { parent::sanitize_settings(); if ($this->type === 'option') { $this->productField = absint($this->productField); } if ($this->type === 'post_category') { $this->displayAllCategories = (bool) $this->displayAllCategories; } }
public function sanitize_settings() { parent::sanitize_settings(); $this->enableCalculation = (bool) $this->enableCalculation; }
public function sanitize_settings() { parent::sanitize_settings(); if (is_array($this->inputs)) { foreach ($this->inputs as &$input) { if (isset($input['choices']) && is_array($input['choices'])) { $input['choices'] = $this->sanitize_settings_choices($input['choices']); } } } }
public function sanitize_settings() { parent::sanitize_settings(); $price_number = GFCommon::to_number($this->basePrice); $this->basePrice = GFCommon::to_money($price_number); }
public function sanitize_settings() { parent::sanitize_settings(); $this->maxRows = absint($this->maxRows); }
public function sanitize_settings() { parent::sanitize_settings(); if ($this->maxFileSize) { $this->maxFileSize = absint($this->maxFileSize); } if ($this->maxFiles) { $this->maxFiles = preg_replace('/[^0-9,.]/', '', $this->maxFiles); } $this->multipleFiles = (bool) $this->multipleFiles; $this->allowedExtensions = sanitize_text_field($this->allowedExtensions); }
public static function get_field_content(GF_Field $field, $value, $form, $entry) { $validation_message = $field->failed_validation && !empty($field->validation_message) ? sprintf("<div class='gfield_description validation_message'>%s</div>", $field->validation_message) : ''; $required_div = $field->isRequired ? sprintf("<span class='gfield_required'>%s</span>", $field->isRequired ? '*' : '') : ''; $target_input_id = $field->get_first_input_id($form); $for_attribute = empty($target_input_id) ? '' : "for='{$target_input_id}'"; $form_id = absint($form['id']); $td_id = 'field_' . $form_id . '_' . $field->id; $td_id = esc_attr($td_id); $description = $field->get_description($field->description, 'gfield_description'); $field->conditionalLogicFields = GFFormDisplay::get_conditional_logic_fields($form, $field->id); $field_input = self::get_field_input($field, $value, $entry['id'], $form_id, $form); if ($field->is_description_above($form)) { $clear = "<div class='gf_clear'></div>"; $field_input = $description . $field_input . $validation_message . $clear; } else { $field_input = $field_input . $description . $validation_message; } $field_content = "<tr valign='top'><td colspan='2' class='detail-view' id='{$td_id}'><ul><li><label class='gfield_label' {$for_attribute} >" . esc_html(rgar($field, 'label')) . $required_div . "</label>{$field_input}</li></ul> </td></tr>"; return $field_content; }