Completed
Pull Request — develop (#1504)
by Zack
17:49
created
includes/admin/class-gravityview-admin-view-item.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -183,7 +183,7 @@
 block discarded – undo
183 183
 
184 184
 		$parent_label = '';
185 185
 
186
-    if ( ! empty( $this->item['parent'] ) ) {
186
+	if ( ! empty( $this->item['parent'] ) ) {
187 187
 			$parent_label = ' <small>(' . esc_attr( $this->item['parent']['label'] ) . ')</small>';
188 188
 		}
189 189
 
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 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
 
@@ -155,26 +155,26 @@  discard block
 block discarded – undo
155 155
 
156 156
 		// $settings_html will just be hidden inputs if empty. Otherwise, it'll have an <ul>. Ugly hack, I know.
157 157
 		// TODO: Un-hack this
158
-		$hide_settings_link_class = ( empty( $this->item['settings_html'] ) || strpos( $this->item['settings_html'], '<!-- No Options -->' ) > 0 ) ? 'hide-if-js' : '';
159
-		$settings_link      = sprintf( '<button class="gv-field-settings" title="%1$s" aria-label="%1$s"><span class="dashicons-admin-generic dashicons %2$s"></span></button>', esc_attr( $settings_title ), $hide_settings_link_class );
158
+		$hide_settings_link_class = ( empty( $this->item[ 'settings_html' ] ) || strpos( $this->item[ 'settings_html' ], '<!-- No Options -->' ) > 0 ) ? 'hide-if-js' : '';
159
+		$settings_link = sprintf( '<button class="gv-field-settings" title="%1$s" aria-label="%1$s"><span class="dashicons-admin-generic dashicons %2$s"></span></button>', esc_attr( $settings_title ), $hide_settings_link_class );
160 160
 
161 161
 		// Should we show the icon that the field is being used as a link to single entry?
162
-		$hide_show_as_link_class = empty( $this->settings['show_as_link'] ) ? 'hide-if-js' : '';
162
+		$hide_show_as_link_class = empty( $this->settings[ 'show_as_link' ] ) ? 'hide-if-js' : '';
163 163
 		$show_as_link            = '<span class="dashicons dashicons-admin-links ' . $hide_show_as_link_class . '" title="' . esc_attr( $single_link_title ) . '"></span>';
164 164
 
165 165
 		// When a field label is empty, use the Field ID
166 166
 		$label = empty( $this->title ) ? sprintf( _x( 'Field #%s (No Label)', 'Label in field picker for empty label', 'gravityview' ), $this->id ) : $this->title;
167 167
 
168 168
 		// If there's a custom label, and show label is checked, use that as the field heading
169
-		if ( ! empty( $this->settings['custom_label'] ) && ! empty( $this->settings['show_label'] ) ) {
170
-			$label = $this->settings['custom_label'];
171
-		} else if ( ! empty( $this->item['customLabel'] ) ) {
172
-			$label = $this->item['customLabel'];
169
+		if ( ! empty( $this->settings[ 'custom_label' ] ) && ! empty( $this->settings[ 'show_label' ] ) ) {
170
+			$label = $this->settings[ 'custom_label' ];
171
+		} else if ( ! empty( $this->item[ 'customLabel' ] ) ) {
172
+			$label = $this->item[ 'customLabel' ];
173 173
 		}
174 174
 		$label = esc_attr( $label );
175 175
 
176
-		if ( $this->item['icon'] && ! \GV\Utils::get( $this->item, 'parent' ) ) {
177
-			$label = '<i class="dashicons ' . esc_attr( $this->item['icon'] ) . '"></i> ' . $label;
176
+		if ( $this->item[ 'icon' ] && ! \GV\Utils::get( $this->item, 'parent' ) ) {
177
+			$label = '<i class="dashicons ' . esc_attr( $this->item[ 'icon' ] ) . '"></i> ' . $label;
178 178
 		}
179 179
 
180 180
 		$output = '<button class="gv-add-field screen-reader-text">' . sprintf( esc_html__( 'Add "%s"', 'gravityview' ), $label ) . '</button>';
@@ -183,8 +183,8 @@  discard block
 block discarded – undo
183 183
 
184 184
 		$parent_label = '';
185 185
 
186
-    if ( ! empty( $this->item['parent'] ) ) {
187
-			$parent_label = ' <small>(' . esc_attr( $this->item['parent']['label'] ) . ')</small>';
186
+    if ( ! empty( $this->item[ 'parent' ] ) ) {
187
+			$parent_label = ' <small>(' . esc_attr( $this->item[ 'parent' ][ 'label' ] ) . ')</small>';
188 188
 		}
189 189
 
190 190
 		// Name of field / widget
@@ -199,10 +199,10 @@  discard block
 block discarded – undo
199 199
 
200 200
 		$output .= '</h5>';
201 201
 
202
-		$container_class = ! empty( $this->item['parent'] ) ? ' gv-child-field' : '';
203
-		$data_form_id   = ! empty( $this->form_id ) ? 'data-formid="' . esc_attr( $this->form_id ) . '"' : '';
202
+		$container_class = ! empty( $this->item[ 'parent' ] ) ? ' gv-child-field' : '';
203
+		$data_form_id = ! empty( $this->form_id ) ? 'data-formid="' . esc_attr( $this->form_id ) . '"' : '';
204 204
 
205
-		$output = '<div data-fieldid="' . esc_attr( $this->id ) . '" ' . $data_form_id . ' data-inputtype="' . esc_attr( $this->item['input_type'] ) . '" class="gv-fields' . $container_class . '">' . $output . $this->item['settings_html'] . '</div>';
205
+		$output = '<div data-fieldid="' . esc_attr( $this->id ) . '" ' . $data_form_id . ' data-inputtype="' . esc_attr( $this->item[ 'input_type' ] ) . '" class="gv-fields' . $container_class . '">' . $output . $this->item[ 'settings_html' ] . '</div>';
206 206
 
207 207
 		return $output;
208 208
 	}
Please login to merge, or discard this patch.