", $input );
}
public function allow_html() {
return in_array( $this->type, array( 'post_custom_field', 'post_tags' ) ) ? true : false;
}
/**
* Gets merge tag values.
*
* @since Unknown
* @access public
*
* @uses GF_Field::get_allowable_tags()
*
* @param array|string $value The value of the input.
* @param string $input_id The input ID to use.
* @param array $entry The Entry Object.
* @param array $form The Form Object
* @param string $modifier The modifier passed.
* @param array|string $raw_value The raw value of the input.
* @param bool $url_encode If the result should be URL encoded.
* @param bool $esc_html If the HTML should be escaped.
* @param string $format The format that the value should be.
* @param bool $nl2br If the nl2br function should be used.
*
* @return string The processed merge tag.
*/
public function get_value_merge_tag( $value, $input_id, $entry, $form, $modifier, $raw_value, $url_encode, $esc_html, $format, $nl2br ) {
if ( $format === 'html' ) {
$value = $raw_value;
if ( $nl2br ) {
$value = nl2br( $value );
}
$form_id = absint( $form['id'] );
$allowable_tags = $this->get_allowable_tags( $form_id );
if ( $allowable_tags === false ) {
// The value is unsafe so encode the value.
$return = esc_html( $value );
} else {
// The value contains HTML but the value was sanitized before saving.
$return = $value;
}
} else {
$return = $value;
}
return $return;
}
/**
* Format the entry value safe for displaying on the entry list page.
*
* @since Unknown
* @access public
*
* @uses GF_Field::get_allowable_tags()
*
* @param string $value The field value.
* @param array $entry The Entry Object currently being processed.
* @param string $field_id The field or input ID currently being processed.
* @param array $columns The properties for the columns being displayed on the entry list page.
* @param array $form The Form Object currently being processed.
*
* @return string
*/
public function get_value_entry_list( $value, $entry, $field_id, $columns, $form ) {
if ( is_array( $value ) ) {
return '';
}
$form_id = absint( $form['id'] );
$allowable_tags = $this->get_allowable_tags( $form_id );
if ( $allowable_tags === false ) {
// The value is unsafe so encode the value.
$return = esc_html( $value );
} else {
// The value contains HTML but the value was sanitized before saving.
$return = $value;
}
return $return;
}
/**
* Format the entry value safe for displaying on the entry detail page and for the {all_fields} merge tag.
*
* @param string|array $value The field value.
* @param string $currency The entry currency code.
* @param bool|false $use_text When processing choice based fields should the choice text be returned instead of the value.
* @param string $format The format requested for the location the merge is being used. Possible values: html, text or url.
* @param string $media The location where the value will be displayed. Possible values: screen or email.
*
* @return string
*/
public function get_value_entry_detail( $value, $currency = '', $use_text = false, $format = 'html', $media = 'screen' ) {
if ( is_array( $value ) ) {
return '';
}
if ( $format === 'html' ) {
$value = nl2br( $value );
$allowable_tags = $this->get_allowable_tags();
if ( $allowable_tags === false ) {
// The value is unsafe so encode the value.
$return = esc_html( $value );
} else {
// The value contains HTML but the value was sanitized before saving.
$return = $value;
}
} else {
$return = $value;
}
return $return;
}
/**
* Add the hint text to aria-describedby.
*
* @param array $extra_ids any extra ids that should be added to the describedby attribute.
*
* @since 2.5
*
* @return string
*/
public function get_aria_describedby( $extra_ids = array() ) {
if ( $this->type === 'text' || $this->type === 'post_custom_field' ) {
return parent::get_aria_describedby( $extra_ids );
}
$id = (int) $this->id;
$form_id = (int) $this->formId;
$is_entry_detail = $this->is_entry_detail();
$is_form_editor = $this->is_form_editor();
$field_id = $is_entry_detail || $is_form_editor || $form_id == 0 ? "input_$id" : 'input_' . $form_id . "_$id";
$describedby = '';
if ( $this->inputType === 'text' || empty( $this->inputType ) ) {
$describedby .= "{$field_id}_desc";
}
if ( ! empty( $this->description ) ) {
$describedby .= " gfield_description_{$form_id}_{$id}";
}
if ( $this->failed_validation ) {
$describedby .= " validation_message_{$this->formId}_{$this->id}";
}
if ( ! empty( $extra_ids ) ) {
$describedby .= implode( ' ', $extra_ids );
}
return empty( $describedby ) ? '' : 'aria-describedby="' . $describedby . '"';
}
// # FIELD FILTER UI HELPERS ---------------------------------------------------------------------------------------
/**
* Returns the filter operators for the current field.
*
* @since 2.4
*
* @return array
*/
public function get_filter_operators() {
$operators = parent::get_filter_operators();
$operators[] = 'contains';
return $operators;
}
}
GF_Fields::register( new GF_Field_Text() );