55 if ( ! empty(
$item[
'type'] ) ) {
57 unset(
$item[
'type'] );
60 if ( $admin_label = \
GV\Utils::get(
$settings,
'admin_label' ) ) {
68 'parent_label' => null,
71 'settings_html' => null,
75 'placeholder' => null,
85 $this->label_type =
$item[
'label_type'];
123 $field_info_items = apply_filters(
'gravityview_admin_label_item_info', $field_info_items, $this );
127 foreach ( $field_info_items as
$item ) {
129 if( \
GV\Utils::get( $item,
'hide_in_picker',
false ) ) {
133 $class = isset( $item[
'class'] ) ? sanitize_html_class( $item[
'class'] ) .
' description' :
'description';
136 $output .= esc_html( $item[
'value'] );
142 $values = wp_list_pluck( $field_info_items,
'value' );
144 $output = esc_html( implode(
"\n", $values ) );
158 $settings_title = sprintf( __(
'Configure %s Settings',
'gk-gravityview' ), esc_html( rgar( $this->item,
'label', ucfirst( $this->label_type ?:
'' ) ) ) );
159 $delete_title = sprintf( __(
'Remove %s',
'gk-gravityview' ), ucfirst( $this->label_type ?:
'' ) );
160 $single_link_title = __(
'This field links to the Single Entry',
'gk-gravityview' );
161 $visibility_title = __(
'This field has modified visibility',
'gk-gravityview' );
165 $hide_settings_link_class = ( empty( $this->item[
'settings_html'] ) || strpos( $this->item[
'settings_html'],
'<!-- No Options -->' ) > 0 ) ?
'hide-if-js' :
'';
166 $settings_link = sprintf(
'<button class="gv-field-settings %2$s" title="%1$s" aria-label="%1$s"><span class="dashicons-admin-generic dashicons"></span></button>', esc_attr( $settings_title ), $hide_settings_link_class );
169 $label = empty( $this->title ) ? sprintf( _x(
'Field #%s (No Label)',
'Label in field picker for empty label',
'gk-gravityview' ), $this->
id ) :
$this->title;
172 if ( ! empty( $this->settings[
'custom_label'] ) && ! empty( $this->settings[
'show_label'] ) ) {
173 $label = $this->settings[
'custom_label'];
174 }
else if ( ! empty( $this->item[
'customLabel'] ) ) {
175 $label = $this->item[
'customLabel'];
181 $form = ! empty( $this->form ) ? $this->form :
false;
186 if ( $this->item[
'icon'] && ! \
GV\Utils::get( $this->item,
'parent' ) ) {
188 $has_gf_icon = (
false !== strpos( $this->item[
'icon'],
'gform-icon' ) );
189 $has_dashicon = (
false !== strpos( $this->item[
'icon'],
'dashicons' ) );
191 if ( 0 === strpos( $this->item[
'icon'],
'data:' ) ) {
193 $field_icon =
'<i class="dashicons background-icon" style="background-image: url(\'' . esc_attr( $this->item[
'icon'] ) .
'\');
"></i>'; 194 } elseif( $has_gf_icon && gravityview()->plugin->is_GF_25() ) { 195 // Gravity Forms icon font 196 $field_icon = '<i class="gform-icon
' . esc_attr( $this->item['icon
'] ) . '"></i>'; 197 } elseif( $has_dashicon ) { 198 // Dashicon; prefix with "dashicons
" 199 $field_icon = '<i class="dashicons
' . esc_attr( $this->item['icon
'] ) . '"></i>'; 202 $field_icon = '<i class="' . esc_attr( $this->item['icon
'] ) . '"></i>'; 205 $field_icon = $field_icon . ' '; 206 } elseif( \GV\Utils::get( $this->item, 'parent' ) ) { 207 $field_icon = '<i class="gv-icon gv-icon-level-down
"></i>' . ' '; 210 $output = '<button class="gv-add-field screen-reader-text
">' . sprintf( esc_html__( 'Add "%s
"', 'gk-gravityview' ), $label ) . '</button>'; 211 $title = esc_attr( sprintf( __( 'Field: %s', 'gk-gravityview' ), $label ) ); 212 if ( ! $nonexistent_form_field ) { 213 $title .= "\n
" . $this->get_item_info( false ); 217 $label = '<span class="dashicons-warning dashicons
"></span> ' . esc_html( sprintf( __( 'The field connected to "%s
" was deleted from the form. The associated entry data no longer exists.', 'gk-gravityview' ), $label ) ); 220 $output .= '<h5 class="selectable gfield field-
id-
' . esc_attr( $this->id ) . '">'; 222 $output .= '<span class="gv-field-controls
">' . $settings_link . $this->get_indicator_icons() . '<button class="gv-
remove-field
" aria-label="' . esc_attr( $delete_title ) . '" title="' . esc_attr( $delete_title ) . '"><span class="dashicons-dismiss dashicons
"></span></button></span>'; 224 $output .= '<span class="gv-field-label
" data-original-title="' . esc_attr( $label ) . '" title="' . $title . '">' . $field_icon . '<span class="gv-field-label-text-container
">' . $label . '</span></span>'; 226 // Displays only in the field/widget picker 227 if ( ! $nonexistent_form_field && $field_info = $this->get_item_info() ) { 228 $output .= '<span class="gv-field-info
">' . $field_info . '</span>'; 233 $container_class = ! empty( $this->item['parent'] ) ? ' gv-child-field' : ''; 235 $container_class .= $nonexistent_form_field ? ' gv-nonexistent-form-field' : ''; 237 $container_class .= empty( $this->settings['show_as_link'] ) ? '' : ' has-single-entry-link'; 239 $container_class .= empty( $this->settings['only_loggedin'] ) ? '' : ' has-custom-visibility'; 241 $data_form_id = $form ? ' data-formid="' . esc_attr( $this->form_id ) . '"' : ''; 243 $data_parent_label = ! empty( $this->item['parent'] ) ? ' data-parent-label="' . esc_attr( $this->item['parent
']['label
'] ) . '"' : ''; 245 $output = '<div data-fieldid="' . esc_attr( $this->id ) . '" ' . $data_form_id . $data_parent_label . ' data-inputtype="' . esc_attr( $this->item['input_type
'] ) . '" class="gv-fields
' . $container_class . '">' . $output . $this->item['settings_html'] . '</div>'; 259 private function get_indicator_icons() {
262 'show_as_link' => array(
263 'visible' => ( ! empty( $this->settings['show_as_link'] ) ),
264 'title' => __( 'This field links to the Single Entry', 'gk-gravityview' ),
265 'css_class' => 'dashicons dashicons-media-default icon-link-to-single-entry',
267 'only_loggedin' => array(
268 'visible' => ( \GV\Utils::get( $this->settings, 'only_loggedin' ) || isset( $this->settings['allow_edit_cap'] ) && 'read' !== $this->settings['allow_edit_cap'] ),
269 'title' => __( 'This field has modified visibility', 'gk-gravityview' ),
270 'css_class' => 'dashicons dashicons-lock icon-custom-visibility',
282 $icons = (array) apply_filters( 'gravityview/admin/indicator_icons', $icons, $this->settings );
284 foreach ( $icons as $icon ) {
286 if ( empty( $icon['css_class'] ) || empty( $icon['title'] ) ) {
290 $css_class = trim( $icon['css_class'] );
292 if ( empty( $icon['visible'] ) ) {
293 $css_class .= ' hide-if-js';
296 $output .= '<span class="
' . gravityview_sanitize_html_class( $css_class ) . '" title="' . esc_attr( $icon['title
'] ) . '"></span>'; __toString()
When echoing this class, print the HTML output.
get_item_info( $html=true)
Generate the output for a field based on the additional_info() output.
gravityview_get_field( $form, $field_id)
Returns the field details array of a specific form given the field id.
getOutput()
Generate HTML for field or a widget modal.
A field or widget in GravityView view configuration.
additional_info()
Overridden by child classes.
__construct( $title='', $item_id='', $item=array(), $settings=array(), $form_id=null, $form=array())
static get_form( $form_id)
Returns the form object for a given Form ID.