本文整理匯總了PHP中GF_Field類的典型用法代碼示例。如果您正苦於以下問題:PHP GF_Field類的具體用法?PHP GF_Field怎麽用?PHP GF_Field使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了GF_Field類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: has_field_calculation
/**
* @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();
}
示例2: pre_validation
/**
* 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;
}
示例3: pre_validation
/**
* 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;
}
示例4: prepare_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;
}
示例5: display_poll_on_entry_detail
/**
* 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;
}
示例6: sanitize_settings
public function sanitize_settings()
{
parent::sanitize_settings();
if ($this->phoneFormat && !in_array($this->phoneFormat, array('standard', 'international'))) {
$this->phoneFormat = 'standard';
}
}
示例7: sanitize_settings
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);
}
}
示例8: sanitize_settings
public function sanitize_settings()
{
parent::sanitize_settings();
$this->enableEnhancedUI = (bool) $this->enableEnhancedUI;
if ($this->type === 'post_category') {
$this->displayAllCategories = (bool) $this->displayAllCategories;
}
}
示例9: maybe_fire_array_access_deprecation_notice
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;
}
}
示例10: sanitize_settings
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']);
}
}
}
示例11: maybe_fire_array_access_deprecation_notice
/**
* 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;
}
}
示例12: sanitize_settings
public function sanitize_settings()
{
parent::sanitize_settings();
$allowed_tags = wp_kses_allowed_html('post');
$this->content = wp_kses($this->content, $allowed_tags);
}
示例13: get_value_default
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;
}
示例14: sanitize_settings
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);
}
}
示例15: get_value_default
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;
}