Completed
Push — develop ( 540b54...24d594 )
by Zack
17:58
created
includes/admin/class-gravityview-admin-view-item.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -44,12 +44,12 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,46 +156,46 @@  discard block
 block discarded – undo
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 175
 		$form = ! empty( $this->form_id ) ? GVCommon::get_form( $this->form_id ) : false;
176
-		$nonexistent_form_field = $form && $this->id && preg_match('/^\d+\.\d+$|^\d+$/', $this->id) && ! gravityview_get_field( $form, $this->id );
176
+		$nonexistent_form_field = $form && $this->id && preg_match( '/^\d+\.\d+$|^\d+$/', $this->id ) && ! gravityview_get_field( $form, $this->id );
177 177
 
178
-		if ( $this->item['icon'] && ! \GV\Utils::get( $this->item, 'parent' ) ) {
178
+		if ( $this->item[ 'icon' ] && ! \GV\Utils::get( $this->item, 'parent' ) ) {
179 179
 
180
-			$has_gf_icon = ( false !== strpos( $this->item['icon'], 'gform-icon' ) );
181
-			$has_dashicon = ( false !== strpos( $this->item['icon'], 'dashicons' ) );
180
+			$has_gf_icon = ( false !== strpos( $this->item[ 'icon' ], 'gform-icon' ) );
181
+			$has_dashicon = ( false !== strpos( $this->item[ 'icon' ], 'dashicons' ) );
182 182
 
183
-			if ( 0 === strpos( $this->item['icon'], 'data:' ) ) {
183
+			if ( 0 === strpos( $this->item[ 'icon' ], 'data:' ) ) {
184 184
 				// Inline icon SVG
185
-				$field_icon = '<i class="dashicons background-icon" style="background-image: url(\'' . esc_attr( $this->item['icon'] ) . '\');"></i>';
186
-			} elseif( $has_gf_icon && gravityview()->plugin->is_GF_25() ) {
185
+				$field_icon = '<i class="dashicons background-icon" style="background-image: url(\'' . esc_attr( $this->item[ 'icon' ] ) . '\');"></i>';
186
+			} elseif ( $has_gf_icon && gravityview()->plugin->is_GF_25() ) {
187 187
 				// Gravity Forms icon font
188
-				$field_icon = '<i class="gform-icon ' . esc_attr( $this->item['icon'] ) . '"></i>';
189
-			} elseif( $has_dashicon ) {
188
+				$field_icon = '<i class="gform-icon ' . esc_attr( $this->item[ 'icon' ] ) . '"></i>';
189
+			} elseif ( $has_dashicon ) {
190 190
 				// Dashicon; prefix with "dashicons"
191
-				$field_icon = '<i class="dashicons ' . esc_attr( $this->item['icon'] ) . '"></i>';
191
+				$field_icon = '<i class="dashicons ' . esc_attr( $this->item[ 'icon' ] ) . '"></i>';
192 192
 			} else {
193 193
 				// Not dashicon icon
194
-				$field_icon = '<i class="' . esc_attr( $this->item['icon'] ) . '"></i>';
194
+				$field_icon = '<i class="' . esc_attr( $this->item[ 'icon' ] ) . '"></i>';
195 195
 			}
196 196
 
197 197
 			$field_icon = $field_icon . ' ';
198
-		} elseif( \GV\Utils::get( $this->item, 'parent' ) ) {
198
+		} elseif ( \GV\Utils::get( $this->item, 'parent' ) ) {
199 199
 			$field_icon = '<i class="gv-icon gv-icon-level-down"></i>' . ' ';
200 200
 		}
201 201
 
@@ -222,19 +222,19 @@  discard block
 block discarded – undo
222 222
 
223 223
 		$output .= '</h5>';
224 224
 
225
-		$container_class = ! empty( $this->item['parent'] ) ? ' gv-child-field' : '';
225
+		$container_class = ! empty( $this->item[ 'parent' ] ) ? ' gv-child-field' : '';
226 226
 
227 227
 		$container_class .= $nonexistent_form_field ? ' gv-nonexistent-form-field' : '';
228 228
 
229
-		$container_class .= empty( $this->settings['show_as_link'] ) ? '' : ' has-single-entry-link';
229
+		$container_class .= empty( $this->settings[ 'show_as_link' ] ) ? '' : ' has-single-entry-link';
230 230
 
231
-		$container_class .= empty( $this->settings['only_loggedin'] ) ? '' : ' has-custom-visibility';
231
+		$container_class .= empty( $this->settings[ 'only_loggedin' ] ) ? '' : ' has-custom-visibility';
232 232
 
233
-		$data_form_id   = $form ? ' data-formid="' . esc_attr( $this->form_id ) . '"' : '';
233
+		$data_form_id = $form ? ' data-formid="' . esc_attr( $this->form_id ) . '"' : '';
234 234
 
235
-		$data_parent_label = ! empty( $this->item['parent'] ) ? ' data-parent-label="' . esc_attr( $this->item['parent']['label'] ) . '"' : '';
235
+		$data_parent_label = ! empty( $this->item[ 'parent' ] ) ? ' data-parent-label="' . esc_attr( $this->item[ 'parent' ][ 'label' ] ) . '"' : '';
236 236
 
237
-		$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>';
237
+		$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>';
238 238
 
239 239
 		return $output;
240 240
 	}
@@ -252,12 +252,12 @@  discard block
 block discarded – undo
252 252
 
253 253
 		$icons = array(
254 254
 			'show_as_link' => array(
255
-				'visible' => ( ! empty( $this->settings['show_as_link'] ) ),
255
+				'visible' => ( ! empty( $this->settings[ 'show_as_link' ] ) ),
256 256
 				'title' => __( 'This field links to the Single Entry', 'gravityview' ),
257 257
 				'css_class' => 'dashicons dashicons-media-default icon-link-to-single-entry',
258 258
 			),
259 259
 			'only_loggedin' => array(
260
-				'visible' => ( \GV\Utils::get( $this->settings, 'only_loggedin' ) || isset( $this->settings['allow_edit_cap'] ) && 'read' !== $this->settings['allow_edit_cap'] ),
260
+				'visible' => ( \GV\Utils::get( $this->settings, 'only_loggedin' ) || isset( $this->settings[ 'allow_edit_cap' ] ) && 'read' !== $this->settings[ 'allow_edit_cap' ] ),
261 261
 				'title' => __( 'This field has modified visibility', 'gravityview' ),
262 262
 				'css_class' => 'dashicons dashicons-lock icon-custom-visibility',
263 263
 			),
@@ -271,21 +271,21 @@  discard block
 block discarded – undo
271 271
 		 * @param array $icons Array of icons to be shown, with `visible`, `title`, `css_class` keys.
272 272
 		 * @param array $item_settings Settings for the current item (widget or field)
273 273
 		 */
274
-		$icons = (array) apply_filters( 'gravityview/admin/indicator_icons', $icons, $this->settings );
274
+		$icons = (array)apply_filters( 'gravityview/admin/indicator_icons', $icons, $this->settings );
275 275
 
276 276
 		foreach ( $icons as $icon ) {
277 277
 
278
-			if ( empty( $icon['css_class'] ) || empty( $icon['title'] ) ) {
278
+			if ( empty( $icon[ 'css_class' ] ) || empty( $icon[ 'title' ] ) ) {
279 279
 				continue;
280 280
 			}
281 281
 
282
-			$css_class = trim( $icon['css_class'] );
282
+			$css_class = trim( $icon[ 'css_class' ] );
283 283
 
284
-			if ( empty( $icon['visible'] ) ) {
284
+			if ( empty( $icon[ 'visible' ] ) ) {
285 285
 				$css_class .= ' hide-if-js';
286 286
 			}
287 287
 
288
-			$output .= '<span class="' . gravityview_sanitize_html_class( $css_class ) . '" title="' . esc_attr( $icon['title'] ) . '"></span>';
288
+			$output .= '<span class="' . gravityview_sanitize_html_class( $css_class ) . '" title="' . esc_attr( $icon[ 'title' ] ) . '"></span>';
289 289
 		}
290 290
 
291 291
 		return $output;
Please login to merge, or discard this patch.