@@ -44,12 +44,12 @@ discard block |
||
44 | 44 | */ |
45 | 45 | protected $form_id; |
46 | 46 | |
47 | - function __construct( $title = '', $item_id = '', $item = array(), $settings = array(), $form_id = null) { |
|
47 | + function __construct( $title = '', $item_id = '', $item = array(), $settings = array(), $form_id = null ) { |
|
48 | 48 | |
49 | 49 | // Backward compat |
50 | - if ( ! empty( $item['type'] ) ) { |
|
51 | - $item['input_type'] = $item['type']; |
|
52 | - unset( $item['type'] ); |
|
50 | + if ( ! empty( $item[ 'type' ] ) ) { |
|
51 | + $item[ 'input_type' ] = $item[ 'type' ]; |
|
52 | + unset( $item[ 'type' ] ); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | if ( $admin_label = \GV\Utils::get( $settings, 'admin_label' ) ) { |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | $this->id = $item_id; |
77 | 77 | $this->form_id = $form_id; |
78 | 78 | $this->settings = $settings; |
79 | - $this->label_type = $item['label_type']; |
|
79 | + $this->label_type = $item[ 'label_type' ]; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -120,14 +120,14 @@ discard block |
||
120 | 120 | |
121 | 121 | foreach ( $field_info_items as $item ) { |
122 | 122 | |
123 | - if( \GV\Utils::get( $item, 'hide_in_picker', false ) ) { |
|
123 | + if ( \GV\Utils::get( $item, 'hide_in_picker', false ) ) { |
|
124 | 124 | continue; |
125 | 125 | } |
126 | 126 | |
127 | - $class = isset( $item['class'] ) ? sanitize_html_class( $item['class'] ) . ' description' : 'description'; |
|
127 | + $class = isset( $item[ 'class' ] ) ? sanitize_html_class( $item[ 'class' ] ) . ' description' : 'description'; |
|
128 | 128 | // Add the title in case the value's long, in which case, it'll be truncated by CSS. |
129 | 129 | $output .= '<span class="' . $class . '">'; |
130 | - $output .= esc_html( $item['value'] ); |
|
130 | + $output .= esc_html( $item[ 'value' ] ); |
|
131 | 131 | $output .= '</span>'; |
132 | 132 | } |
133 | 133 | |
@@ -156,43 +156,43 @@ discard block |
||
156 | 156 | |
157 | 157 | // $settings_html will just be hidden inputs if empty. Otherwise, it'll have an <ul>. Ugly hack, I know. |
158 | 158 | // TODO: Un-hack this |
159 | - $hide_settings_link_class = ( empty( $this->item['settings_html'] ) || strpos( $this->item['settings_html'], '<!-- No Options -->' ) > 0 ) ? 'hide-if-js' : ''; |
|
160 | - $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 ); |
|
159 | + $hide_settings_link_class = ( empty( $this->item[ 'settings_html' ] ) || strpos( $this->item[ 'settings_html' ], '<!-- No Options -->' ) > 0 ) ? 'hide-if-js' : ''; |
|
160 | + $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 ); |
|
161 | 161 | |
162 | 162 | // When a field label is empty, use the Field ID |
163 | 163 | $label = empty( $this->title ) ? sprintf( _x( 'Field #%s (No Label)', 'Label in field picker for empty label', 'gravityview' ), $this->id ) : $this->title; |
164 | 164 | |
165 | 165 | // If there's a custom label, and show label is checked, use that as the field heading |
166 | - if ( ! empty( $this->settings['custom_label'] ) && ! empty( $this->settings['show_label'] ) ) { |
|
167 | - $label = $this->settings['custom_label']; |
|
168 | - } else if ( ! empty( $this->item['customLabel'] ) ) { |
|
169 | - $label = $this->item['customLabel']; |
|
166 | + if ( ! empty( $this->settings[ 'custom_label' ] ) && ! empty( $this->settings[ 'show_label' ] ) ) { |
|
167 | + $label = $this->settings[ 'custom_label' ]; |
|
168 | + } else if ( ! empty( $this->item[ 'customLabel' ] ) ) { |
|
169 | + $label = $this->item[ 'customLabel' ]; |
|
170 | 170 | } |
171 | 171 | $label = esc_attr( $label ); |
172 | 172 | |
173 | 173 | $field_icon = ''; |
174 | 174 | |
175 | - if ( $this->item['icon'] && ! \GV\Utils::get( $this->item, 'parent' ) ) { |
|
175 | + if ( $this->item[ 'icon' ] && ! \GV\Utils::get( $this->item, 'parent' ) ) { |
|
176 | 176 | |
177 | - $has_gf_icon = ( false !== strpos( $this->item['icon'], 'gform-icon' ) ); |
|
178 | - $has_dashicon = ( false !== strpos( $this->item['icon'], 'dashicons' ) ); |
|
177 | + $has_gf_icon = ( false !== strpos( $this->item[ 'icon' ], 'gform-icon' ) ); |
|
178 | + $has_dashicon = ( false !== strpos( $this->item[ 'icon' ], 'dashicons' ) ); |
|
179 | 179 | |
180 | - if ( 0 === strpos( $this->item['icon'], 'data:' ) ) { |
|
180 | + if ( 0 === strpos( $this->item[ 'icon' ], 'data:' ) ) { |
|
181 | 181 | // Inline icon SVG |
182 | - $field_icon = '<i class="dashicons background-icon" style="background-image: url(\'' . esc_attr( $this->item['icon'] ) . '\');"></i>'; |
|
183 | - } elseif( $has_gf_icon && gravityview()->plugin->is_GF_25() ) { |
|
182 | + $field_icon = '<i class="dashicons background-icon" style="background-image: url(\'' . esc_attr( $this->item[ 'icon' ] ) . '\');"></i>'; |
|
183 | + } elseif ( $has_gf_icon && gravityview()->plugin->is_GF_25() ) { |
|
184 | 184 | // Gravity Forms icon font |
185 | - $field_icon = '<i class="gform-icon ' . esc_attr( $this->item['icon'] ) . '"></i>'; |
|
186 | - } elseif( $has_dashicon ) { |
|
185 | + $field_icon = '<i class="gform-icon ' . esc_attr( $this->item[ 'icon' ] ) . '"></i>'; |
|
186 | + } elseif ( $has_dashicon ) { |
|
187 | 187 | // Dashicon; prefix with "dashicons" |
188 | - $field_icon = '<i class="dashicons ' . esc_attr( $this->item['icon'] ) . '"></i>'; |
|
188 | + $field_icon = '<i class="dashicons ' . esc_attr( $this->item[ 'icon' ] ) . '"></i>'; |
|
189 | 189 | } else { |
190 | 190 | // Not dashicon icon |
191 | - $field_icon = '<i class="' . esc_attr( $this->item['icon'] ) . '"></i>'; |
|
191 | + $field_icon = '<i class="' . esc_attr( $this->item[ 'icon' ] ) . '"></i>'; |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | $field_icon = $field_icon . ' '; |
195 | - } elseif( \GV\Utils::get( $this->item, 'parent' ) ) { |
|
195 | + } elseif ( \GV\Utils::get( $this->item, 'parent' ) ) { |
|
196 | 196 | $field_icon = '<i class="gv-icon gv-icon-level-down"></i>' . ' '; |
197 | 197 | } |
198 | 198 | |
@@ -212,17 +212,17 @@ discard block |
||
212 | 212 | |
213 | 213 | $output .= '</h5>'; |
214 | 214 | |
215 | - $container_class = ! empty( $this->item['parent'] ) ? ' gv-child-field' : ''; |
|
215 | + $container_class = ! empty( $this->item[ 'parent' ] ) ? ' gv-child-field' : ''; |
|
216 | 216 | |
217 | - $container_class .= empty( $this->settings['show_as_link'] ) ? '' : ' has-single-entry-link'; |
|
217 | + $container_class .= empty( $this->settings[ 'show_as_link' ] ) ? '' : ' has-single-entry-link'; |
|
218 | 218 | |
219 | - $container_class .= empty( $this->settings['only_loggedin'] ) ? '' : ' has-custom-visibility'; |
|
219 | + $container_class .= empty( $this->settings[ 'only_loggedin' ] ) ? '' : ' has-custom-visibility'; |
|
220 | 220 | |
221 | - $data_form_id = ! empty( $this->form_id ) ? ' data-formid="' . esc_attr( $this->form_id ) . '"' : ''; |
|
221 | + $data_form_id = ! empty( $this->form_id ) ? ' data-formid="' . esc_attr( $this->form_id ) . '"' : ''; |
|
222 | 222 | |
223 | - $data_parent_label = ! empty( $this->item['parent'] ) ? ' data-parent-label="' . esc_attr( $this->item['parent']['label'] ) . '"' : ''; |
|
223 | + $data_parent_label = ! empty( $this->item[ 'parent' ] ) ? ' data-parent-label="' . esc_attr( $this->item[ 'parent' ][ 'label' ] ) . '"' : ''; |
|
224 | 224 | |
225 | - $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>'; |
|
225 | + $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>'; |
|
226 | 226 | |
227 | 227 | return $output; |
228 | 228 | } |
@@ -240,12 +240,12 @@ discard block |
||
240 | 240 | |
241 | 241 | $icons = array( |
242 | 242 | 'show_as_link' => array( |
243 | - 'visible' => ( ! empty( $this->settings['show_as_link'] ) ), |
|
243 | + 'visible' => ( ! empty( $this->settings[ 'show_as_link' ] ) ), |
|
244 | 244 | 'title' => __( 'This field links to the Single Entry', 'gravityview' ), |
245 | 245 | 'css_class' => 'dashicons dashicons-media-default icon-link-to-single-entry', |
246 | 246 | ), |
247 | 247 | 'only_loggedin' => array( |
248 | - 'visible' => ( \GV\Utils::get( $this->settings, 'only_loggedin' ) || isset( $this->settings['allow_edit_cap'] ) && 'read' !== $this->settings['allow_edit_cap'] ), |
|
248 | + 'visible' => ( \GV\Utils::get( $this->settings, 'only_loggedin' ) || isset( $this->settings[ 'allow_edit_cap' ] ) && 'read' !== $this->settings[ 'allow_edit_cap' ] ), |
|
249 | 249 | 'title' => __( 'This field has modified visibility', 'gravityview' ), |
250 | 250 | 'css_class' => 'dashicons dashicons-lock icon-custom-visibility', |
251 | 251 | ), |
@@ -259,21 +259,21 @@ discard block |
||
259 | 259 | * @param array $icons Array of icons to be shown, with `visible`, `title`, `css_class` keys. |
260 | 260 | * @param array $item_settings Settings for the current item (widget or field) |
261 | 261 | */ |
262 | - $icons = (array) apply_filters( 'gravityview/admin/indicator_icons', $icons, $this->settings ); |
|
262 | + $icons = (array)apply_filters( 'gravityview/admin/indicator_icons', $icons, $this->settings ); |
|
263 | 263 | |
264 | 264 | foreach ( $icons as $icon ) { |
265 | 265 | |
266 | - if ( empty( $icon['css_class'] ) || empty( $icon['title'] ) ) { |
|
266 | + if ( empty( $icon[ 'css_class' ] ) || empty( $icon[ 'title' ] ) ) { |
|
267 | 267 | continue; |
268 | 268 | } |
269 | 269 | |
270 | - $css_class = trim( $icon['css_class'] ); |
|
270 | + $css_class = trim( $icon[ 'css_class' ] ); |
|
271 | 271 | |
272 | - if ( empty( $icon['visible'] ) ) { |
|
272 | + if ( empty( $icon[ 'visible' ] ) ) { |
|
273 | 273 | $css_class .= ' hide-if-js'; |
274 | 274 | } |
275 | 275 | |
276 | - $output .= '<span class="' . gravityview_sanitize_html_class( $css_class ) . '" title="' . esc_attr( $icon['title'] ) . '"></span>'; |
|
276 | + $output .= '<span class="' . gravityview_sanitize_html_class( $css_class ) . '" title="' . esc_attr( $icon[ 'title' ] ) . '"></span>'; |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | return $output; |