Completed
Pull Request — master (#1399)
by Zack
06:22
created
future/includes/class-gv-oembed.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 		wp_embed_register_handler( 'gravityview_entry', self::get_entry_regex(), array( __CLASS__, 'render' ), 20000 );
27 27
 		wp_oembed_add_provider( self::get_entry_regex(), self::$provider_url, true );
28 28
 
29
-		if ( ! empty( $_GET['gv_oembed_provider'] ) && ! empty( $_GET['url'] ) ) {
29
+		if ( ! empty( $_GET[ 'gv_oembed_provider' ] ) && ! empty( $_GET[ 'url' ] ) ) {
30 30
 			add_action( 'template_redirect', array( __CLASS__, 'render_provider_request' ) );
31 31
 		}
32 32
 
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
 	 * @return void
44 44
 	 */
45 45
 	public static function render_provider_request() {
46
-		if ( ! empty( $_GET['url'] ) ) {
47
-			$url = $_GET['url'];
46
+		if ( ! empty( $_GET[ 'url' ] ) ) {
47
+			$url = $_GET[ 'url' ];
48 48
 		} else {
49 49
 			header( 'HTTP/1.0 404 Not Found' );
50 50
 			exit;
@@ -111,18 +111,18 @@  discard block
 block discarded – undo
111 111
 	 */
112 112
 	private static function parse_matches( $matches, $url ) {
113 113
 		// If not using permalinks, re-assign values for matching groups
114
-		if ( ! empty( $matches['entry_slug2'] ) ) {
115
-			$matches['is_cpt'] = $matches['is_cpt2'];
116
-			$matches['slug'] = $matches['slug2'];
117
-			$matches['entry_slug'] = $matches['entry_slug2'];
118
-			unset( $matches['is_cpt2'], $matches['slug2'], $matches['entry_slug2'] );
114
+		if ( ! empty( $matches[ 'entry_slug2' ] ) ) {
115
+			$matches[ 'is_cpt' ] = $matches[ 'is_cpt2' ];
116
+			$matches[ 'slug' ] = $matches[ 'slug2' ];
117
+			$matches[ 'entry_slug' ] = $matches[ 'entry_slug2' ];
118
+			unset( $matches[ 'is_cpt2' ], $matches[ 'slug2' ], $matches[ 'entry_slug2' ] );
119 119
 		}
120 120
 
121
-		if ( empty( $matches['entry_slug'] ) ) {
121
+		if ( empty( $matches[ 'entry_slug' ] ) ) {
122 122
 			gravityview()->log->error( 'Entry slug not parsed by regex.', array( 'data' => $matches ) );
123 123
 			return null;
124 124
 		} else {
125
-			$entry_id = $matches['entry_slug'];
125
+			$entry_id = $matches[ 'entry_slug' ];
126 126
 		}
127 127
 
128 128
 		if ( ! $entry = \GV\GF_Entry::by_id( $entry_id ) ) {
@@ -140,12 +140,12 @@  discard block
 block discarded – undo
140 140
 		if ( ! $view ) {
141 141
 
142 142
 			// If the slug doesn't work, maybe using Plain permalinks and not the slug, only ID
143
-			if( is_numeric( $matches['slug'] ) ) {
144
-				$view = \GV\View::by_id( $matches['slug'] );
143
+			if ( is_numeric( $matches[ 'slug' ] ) ) {
144
+				$view = \GV\View::by_id( $matches[ 'slug' ] );
145 145
 			}
146 146
 
147
-			if( ! $view ) {
148
-				$view = \GV\View::from_post( get_page_by_path( $matches['slug'], OBJECT, 'gravityview' ) );
147
+			if ( ! $view ) {
148
+				$view = \GV\View::from_post( get_page_by_path( $matches[ 'slug' ], OBJECT, 'gravityview' ) );
149 149
 			}
150 150
 		}
151 151
 
@@ -176,9 +176,9 @@  discard block
 block discarded – undo
176 176
 
177 177
 		return '
178 178
 		<div class="loading-placeholder" style="background-color:#e6f0f5;">
179
-			<h3 style="margin:0; padding:0; font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, Oxygen-Sans, Ubuntu, Cantarell, \'Helvetica Neue\', sans-serif;">'.$image.$embed_heading.'</h3>
179
+			<h3 style="margin:0; padding:0; font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, Oxygen-Sans, Ubuntu, Cantarell, \'Helvetica Neue\', sans-serif;">'.$image . $embed_heading . '</h3>
180 180
 			<p style="margin:0; padding:0; font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, Oxygen-Sans, Ubuntu, Cantarell, \'Helvetica Neue\', sans-serif;">
181
-				'.$embed_text.'
181
+				'.$embed_text . '
182 182
 			</p>
183 183
 			<br style="clear: both;">
184 184
 		</div>';
@@ -192,8 +192,8 @@  discard block
 block discarded – undo
192 192
 	private static function render_preview_notice() {
193 193
 		$floaty = \GravityView_Admin::get_floaty();
194 194
 		$title = esc_html__( 'This will look better when it is embedded.', 'gravityview' );
195
-		$message = esc_html__( 'Styles don\'t get loaded when being previewed, so the content below will look strange. Don\'t be concerned!', 'gravityview');
196
-		return '<div class="updated notice">'.$floaty.'<h3>'.$title.'</h3><p>'.$message.'</p><br style="clear:both;" /></div>';
195
+		$message = esc_html__( 'Styles don\'t get loaded when being previewed, so the content below will look strange. Don\'t be concerned!', 'gravityview' );
196
+		return '<div class="updated notice">' . $floaty . '<h3>' . $title . '</h3><p>' . $message . '</p><br style="clear:both;" /></div>';
197 197
 	}
198 198
 
199 199
 	/**
@@ -212,13 +212,13 @@  discard block
 block discarded – undo
212 212
 			return __( 'You are not allowed to view this content.', 'gravityview' );
213 213
 		}
214 214
 
215
-		if ( $entry && 'active' !== $entry['status'] ) {
215
+		if ( $entry && 'active' !== $entry[ 'status' ] ) {
216 216
 			gravityview()->log->notice( 'Entry ID #{entry_id} is not active', array( 'entry_id' => $entry->ID ) );
217 217
 			return __( 'You are not allowed to view this content.', 'gravityview' );
218 218
 		}
219 219
 
220 220
 		if ( $view->settings->get( 'show_only_approved' ) ) {
221
-			if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) )  ) {
221
+			if ( ! \GravityView_Entry_Approval_Status::is_approved( gform_get_meta( $entry->ID, \GravityView_Entry_Approval::meta_key ) ) ) {
222 222
 				gravityview()->log->error( 'Entry ID #{entry_id} is not approved for viewing', array( 'entry_id' => $entry->ID ) );
223 223
 				return __( 'You are not allowed to view this content.', 'gravityview' );
224 224
 			}
@@ -249,9 +249,9 @@  discard block
 block discarded – undo
249 249
 			 * Mocks old context, etc.
250 250
 			 */
251 251
 			$loader = \GravityView_Edit_Entry::getInstance();
252
-			$render = $loader->instances['render'];
252
+			$render = $loader->instances[ 'render' ];
253 253
 
254
-			$form = \GFAPI::get_form( $entry['form_id'] );
254
+			$form = \GFAPI::get_form( $entry[ 'form_id' ] );
255 255
 
256 256
 			// @todo We really need to rewrite Edit Entry soon
257 257
 			\GravityView_View::$instance = null;
@@ -260,13 +260,13 @@  discard block
 block discarded – undo
260 260
 			$data = \GravityView_View_Data::getInstance( get_post( $view->ID ) );
261 261
 			$template = \GravityView_View::getInstance( array(
262 262
 				'form' => $form,
263
-				'form_id' => $form['id'],
263
+				'form_id' => $form[ 'id' ],
264 264
 				'view_id' => $view->ID,
265 265
 				'entries' => array( $entry->as_entry() ),
266 266
 				'atts' => \GVCommon::get_template_settings( $view->ID ),
267 267
 			) );
268 268
 
269
-			ob_start() && $render->init( $data, \GV\Entry::by_id( $entry['id'] ), $view );
269
+			ob_start() && $render->init( $data, \GV\Entry::by_id( $entry[ 'id' ] ), $view );
270 270
 			$output = ob_get_clean(); // Render :)
271 271
 		} else {
272 272
 			/** Remove the back link. */
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 		// Catch either
311 311
 		$match_regex = "(?:{$using_permalinks}|{$not_using_permalinks})";
312 312
 
313
-		return '#'.$match_regex.'#i';
313
+		return '#' . $match_regex . '#i';
314 314
 	}
315 315
 
316 316
 	/**
Please login to merge, or discard this patch.
includes/class-ajax.php 1 patch
Spacing   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 		 * Don't exit if we're running test suite.
37 37
 		 * @since 1.15
38 38
 		 */
39
-		if( defined( 'DOING_GRAVITYVIEW_TESTS' ) && DOING_GRAVITYVIEW_TESTS ) {
39
+		if ( defined( 'DOING_GRAVITYVIEW_TESTS' ) && DOING_GRAVITYVIEW_TESTS ) {
40 40
 			return $mixed;
41 41
 		}
42 42
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 * @return void
51 51
 	 */
52 52
 	function check_ajax_nonce() {
53
-		if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( $_POST['nonce'], 'gravityview_ajaxviews' ) ) {
53
+		if ( ! isset( $_POST[ 'nonce' ] ) || ! wp_verify_nonce( $_POST[ 'nonce' ], 'gravityview_ajaxviews' ) ) {
54 54
 			$this->_exit( false );
55 55
 		}
56 56
 	}
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 		$context = rgpost( 'context' );
70 70
 
71 71
 		// Return markup for a single or multiple contexts
72
-		if( $context ) {
72
+		if ( $context ) {
73 73
 			$data = array(
74 74
 				esc_attr( $context ) => ''
75 75
 			);
@@ -113,17 +113,17 @@  discard block
 block discarded – undo
113 113
 	function get_active_areas() {
114 114
 		$this->check_ajax_nonce();
115 115
 
116
-		if( empty( $_POST['template_id'] ) ) {
116
+		if ( empty( $_POST[ 'template_id' ] ) ) {
117 117
 			$this->_exit( false );
118 118
 		}
119 119
 
120 120
 		ob_start();
121
-		do_action( 'gravityview_render_directory_active_areas', $_POST['template_id'], 'directory', '', true );
122
-		$response['directory'] = ob_get_clean();
121
+		do_action( 'gravityview_render_directory_active_areas', $_POST[ 'template_id' ], 'directory', '', true );
122
+		$response[ 'directory' ] = ob_get_clean();
123 123
 
124 124
 		ob_start();
125
-		do_action( 'gravityview_render_directory_active_areas',  $_POST['template_id'], 'single', '', true );
126
-		$response['single'] = ob_get_clean();
125
+		do_action( 'gravityview_render_directory_active_areas', $_POST[ 'template_id' ], 'single', '', true );
126
+		$response[ 'single' ] = ob_get_clean();
127 127
 
128 128
 		$response = array_map( 'gravityview_strip_whitespace', $response );
129 129
 
@@ -138,20 +138,20 @@  discard block
 block discarded – undo
138 138
 
139 139
 		$this->check_ajax_nonce();
140 140
 
141
-		if( empty( $_POST['template_id'] ) ) {
141
+		if ( empty( $_POST[ 'template_id' ] ) ) {
142 142
 			$this->_exit( false );
143 143
 		}
144 144
 
145 145
 		// get the fields xml config file for this specific preset
146
-		$preset_fields_path = apply_filters( 'gravityview_template_fieldsxml', array(), $_POST['template_id'] );
146
+		$preset_fields_path = apply_filters( 'gravityview_template_fieldsxml', array(), $_POST[ 'template_id' ] );
147 147
 		// import fields
148
-		if( !empty( $preset_fields_path ) ) {
148
+		if ( ! empty( $preset_fields_path ) ) {
149 149
 			$presets = $this->import_fields( $preset_fields_path );
150 150
 		} else {
151 151
 			$presets = array( 'widgets' => array(), 'fields' => array() );
152 152
 		}
153 153
 
154
-		$template_id = esc_attr( $_POST['template_id'] );
154
+		$template_id = esc_attr( $_POST[ 'template_id' ] );
155 155
 
156 156
 		// template areas
157 157
 		$template_areas_directory = apply_filters( 'gravityview_template_active_areas', array(), $template_id, 'directory' );
@@ -161,20 +161,20 @@  discard block
 block discarded – undo
161 161
 		$default_widget_areas = \GV\Widget::get_default_widget_areas();
162 162
 
163 163
 		ob_start();
164
-		do_action('gravityview_render_active_areas', $template_id, 'widget', 'header', $default_widget_areas, $presets['widgets'] );
165
-		$response['header'] = ob_get_clean();
164
+		do_action( 'gravityview_render_active_areas', $template_id, 'widget', 'header', $default_widget_areas, $presets[ 'widgets' ] );
165
+		$response[ 'header' ] = ob_get_clean();
166 166
 
167 167
 		ob_start();
168
-		do_action('gravityview_render_active_areas', $template_id, 'widget', 'footer', $default_widget_areas, $presets['widgets'] );
169
-		$response['footer'] = ob_get_clean();
168
+		do_action( 'gravityview_render_active_areas', $template_id, 'widget', 'footer', $default_widget_areas, $presets[ 'widgets' ] );
169
+		$response[ 'footer' ] = ob_get_clean();
170 170
 
171 171
 		ob_start();
172
-		do_action('gravityview_render_active_areas', $template_id, 'field', 'directory', $template_areas_directory, $presets['fields'] );
173
-		$response['directory'] = ob_get_clean();
172
+		do_action( 'gravityview_render_active_areas', $template_id, 'field', 'directory', $template_areas_directory, $presets[ 'fields' ] );
173
+		$response[ 'directory' ] = ob_get_clean();
174 174
 
175 175
 		ob_start();
176
-		do_action('gravityview_render_active_areas', $template_id, 'field', 'single', $template_areas_single, $presets['fields'] );
177
-		$response['single'] = ob_get_clean();
176
+		do_action( 'gravityview_render_active_areas', $template_id, 'field', 'single', $template_areas_single, $presets[ 'fields' ] );
177
+		$response[ 'single' ] = ob_get_clean();
178 178
 
179 179
 		$response = array_map( 'gravityview_strip_whitespace', $response );
180 180
 
@@ -192,26 +192,26 @@  discard block
 block discarded – undo
192 192
 
193 193
 		$this->check_ajax_nonce();
194 194
 
195
-		if( empty( $_POST['template_id'] ) ) {
195
+		if ( empty( $_POST[ 'template_id' ] ) ) {
196 196
 			gravityview()->log->error( 'Cannot create preset form; the template_id is empty.' );
197 197
 			$this->_exit( false );
198 198
 		}
199 199
 
200 200
 		// get the xml for this specific template_id
201
-		$preset_form_xml_path = apply_filters( 'gravityview_template_formxml', '', $_POST['template_id'] );
201
+		$preset_form_xml_path = apply_filters( 'gravityview_template_formxml', '', $_POST[ 'template_id' ] );
202 202
 
203 203
 		// import form
204 204
 		$form = $this->import_form( $preset_form_xml_path );
205 205
 
206 206
 		// get the form ID
207
-		if( false === $form ) {
207
+		if ( false === $form ) {
208 208
 			// send error to user
209
-			gravityview()->log->error( 'Error importing form for template id: {template_id}', array( 'template_id' => (int) $_POST['template_id'] ) );
209
+			gravityview()->log->error( 'Error importing form for template id: {template_id}', array( 'template_id' => (int)$_POST[ 'template_id' ] ) );
210 210
 
211 211
 			$this->_exit( false );
212 212
 		}
213 213
 
214
-		$this->_exit( '<option value="'.esc_attr( $form['id'] ).'" selected="selected">'.esc_html( $form['title'] ).'</option>' );
214
+		$this->_exit( '<option value="' . esc_attr( $form[ 'id' ] ) . '" selected="selected">' . esc_html( $form[ 'title' ] ) . '</option>' );
215 215
 
216 216
 	}
217 217
 
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 
226 226
 		gravityview()->log->debug( '[import_form] Import Preset Form. (File) {path}', array( 'path' => $xml_or_json_path ) );
227 227
 
228
-		if( empty( $xml_or_json_path ) || !class_exists('GFExport') || !file_exists( $xml_or_json_path ) ) {
228
+		if ( empty( $xml_or_json_path ) || ! class_exists( 'GFExport' ) || ! file_exists( $xml_or_json_path ) ) {
229 229
 			gravityview()->log->error( 'Class GFExport or file not found. file: {path}', array( 'path' => $xml_or_json_path ) );
230 230
 			return false;
231 231
 		}
@@ -237,13 +237,13 @@  discard block
 block discarded – undo
237 237
 		gravityview()->log->debug( '[import_form] Importing form (Result) {count}', array( 'count' => $count ) );
238 238
 		gravityview()->log->debug( '[import_form] Importing form (Form) ', array( 'data' => $forms ) );
239 239
 
240
-		if( $count != 1 || empty( $forms[0]['id'] ) ) {
240
+		if ( $count != 1 || empty( $forms[ 0 ][ 'id' ] ) ) {
241 241
 			gravityview()->log->error( 'Form Import Failed!' );
242 242
 			return false;
243 243
 		}
244 244
 
245 245
 		// import success - return form id
246
-		return $forms[0];
246
+		return $forms[ 0 ];
247 247
 	}
248 248
 
249 249
 
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 	function get_field_options() {
258 258
 		$this->check_ajax_nonce();
259 259
 
260
-		if( empty( $_POST['template'] ) || empty( $_POST['area'] ) || empty( $_POST['field_id'] ) || empty( $_POST['field_type'] ) ) {
260
+		if ( empty( $_POST[ 'template' ] ) || empty( $_POST[ 'area' ] ) || empty( $_POST[ 'field_id' ] ) || empty( $_POST[ 'field_type' ] ) ) {
261 261
 			gravityview()->log->error( 'Required fields were not set in the $_POST request. ' );
262 262
 			$this->_exit( false );
263 263
 		}
@@ -269,11 +269,11 @@  discard block
 block discarded – undo
269 269
 		$_post = array_map( 'esc_attr', $_post );
270 270
 
271 271
 		// The GF type of field: `product`, `name`, `creditcard`, `id`, `text`
272
-		$input_type = isset($_post['input_type']) ? esc_attr( $_post['input_type'] ) : NULL;
273
-		$context = isset($_post['context']) ? esc_attr( $_post['context'] ) : NULL;
272
+		$input_type = isset( $_post[ 'input_type' ] ) ? esc_attr( $_post[ 'input_type' ] ) : NULL;
273
+		$context = isset( $_post[ 'context' ] ) ? esc_attr( $_post[ 'context' ] ) : NULL;
274 274
 
275
-		$form_id = empty( $_post['form_id'] ) ? null : $_post['form_id'];
276
-		$response = GravityView_Render_Settings::render_field_options( $form_id, $_post['field_type'], $_post['template'], $_post['field_id'], $_post['field_label'], $_post['area'], $input_type, '', '', $context  );
275
+		$form_id = empty( $_post[ 'form_id' ] ) ? null : $_post[ 'form_id' ];
276
+		$response = GravityView_Render_Settings::render_field_options( $form_id, $_post[ 'field_type' ], $_post[ 'template' ], $_post[ 'field_id' ], $_post[ 'field_label' ], $_post[ 'area' ], $input_type, '', '', $context );
277 277
 
278 278
 		$response = gravityview_strip_whitespace( $response );
279 279
 
@@ -294,15 +294,15 @@  discard block
 block discarded – undo
294 294
 		$form = '';
295 295
 
296 296
 		// if form id is set, use it, else, get form from preset
297
-		if( !empty( $_POST['form_id'] ) ) {
297
+		if ( ! empty( $_POST[ 'form_id' ] ) ) {
298 298
 
299
-			$form = (int) $_POST['form_id'];
299
+			$form = (int)$_POST[ 'form_id' ];
300 300
 
301 301
 		}
302 302
 		// get form from preset
303
-		elseif( !empty( $_POST['template_id'] ) ) {
303
+		elseif ( ! empty( $_POST[ 'template_id' ] ) ) {
304 304
 
305
-			$form = GravityView_Ajax::pre_get_form_fields( $_POST['template_id'] );
305
+			$form = GravityView_Ajax::pre_get_form_fields( $_POST[ 'template_id' ] );
306 306
 
307 307
 		}
308 308
 
@@ -318,27 +318,27 @@  discard block
 block discarded – undo
318 318
 	 * @param  string $template_id Preset template
319 319
 	 *
320 320
 	 */
321
-	static function pre_get_form_fields( $template_id = '') {
321
+	static function pre_get_form_fields( $template_id = '' ) {
322 322
 
323
-		if( empty( $template_id ) ) {
323
+		if ( empty( $template_id ) ) {
324 324
 			gravityview()->log->error( 'Template ID not set.' );
325 325
 			return false;
326 326
 		} else {
327 327
 			$form_file = apply_filters( 'gravityview_template_formxml', '', $template_id );
328
-			if( !file_exists( $form_file )  ) {
328
+			if ( ! file_exists( $form_file ) ) {
329 329
 				gravityview()->log->error( 'Importing Form Fields for preset [{template_id}]. File not found. file: {path}', array( 'template_id' => $template_id, 'path' => $form_file ) );
330 330
 				return false;
331 331
 			}
332 332
 		}
333 333
 
334 334
 		// Load xml parser (from GravityForms)
335
-		if( class_exists( 'GFCommon' ) ) {
335
+		if ( class_exists( 'GFCommon' ) ) {
336 336
 			$xml_parser = GFCommon::get_base_path() . '/xml.php';
337 337
 		} else {
338 338
 			$xml_parser = trailingslashit( WP_PLUGIN_DIR ) . 'gravityforms/xml.php';
339 339
 		}
340 340
 
341
-		if( file_exists( $xml_parser ) ) {
341
+		if ( file_exists( $xml_parser ) ) {
342 342
 			require_once( $xml_parser );
343 343
 		} else {
344 344
 			gravityview()->log->debug( ' - Gravity Forms XML Parser not found {path}.', array( 'path' => $xml_parser ) );
@@ -349,32 +349,32 @@  discard block
 block discarded – undo
349 349
 		$xmlstr = file_get_contents( $form_file );
350 350
 
351 351
         $options = array(
352
-            "page" => array("unserialize_as_array" => true),
353
-            "form"=> array("unserialize_as_array" => true),
354
-            "field"=> array("unserialize_as_array" => true),
355
-            "rule"=> array("unserialize_as_array" => true),
356
-            "choice"=> array("unserialize_as_array" => true),
357
-            "input"=> array("unserialize_as_array" => true),
358
-            "routing_item"=> array("unserialize_as_array" => true),
359
-            "creditCard"=> array("unserialize_as_array" => true),
360
-            "routin"=> array("unserialize_as_array" => true),
361
-            "confirmation" => array("unserialize_as_array" => true),
362
-            "notification" => array("unserialize_as_array" => true)
352
+            "page" => array( "unserialize_as_array" => true ),
353
+            "form"=> array( "unserialize_as_array" => true ),
354
+            "field"=> array( "unserialize_as_array" => true ),
355
+            "rule"=> array( "unserialize_as_array" => true ),
356
+            "choice"=> array( "unserialize_as_array" => true ),
357
+            "input"=> array( "unserialize_as_array" => true ),
358
+            "routing_item"=> array( "unserialize_as_array" => true ),
359
+            "creditCard"=> array( "unserialize_as_array" => true ),
360
+            "routin"=> array( "unserialize_as_array" => true ),
361
+            "confirmation" => array( "unserialize_as_array" => true ),
362
+            "notification" => array( "unserialize_as_array" => true )
363 363
         );
364 364
 
365
-		$xml = new RGXML($options);
366
-        $forms = $xml->unserialize($xmlstr);
365
+		$xml = new RGXML( $options );
366
+        $forms = $xml->unserialize( $xmlstr );
367 367
 
368
-        if( !$forms ) {
368
+        if ( ! $forms ) {
369 369
         	gravityview()->log->error( 'Importing Form Fields for preset [{template_id}]. Error importing file. (File) {path}', array( 'template_id' => $template_id, 'path' => $form_file ) );
370 370
         	return false;
371 371
         }
372 372
 
373
-        if( !empty( $forms[0] ) && is_array( $forms[0] ) ) {
374
-        	$form = $forms[0];
373
+        if ( ! empty( $forms[ 0 ] ) && is_array( $forms[ 0 ] ) ) {
374
+        	$form = $forms[ 0 ];
375 375
         }
376 376
 
377
-        if( empty( $form ) ) {
377
+        if ( empty( $form ) ) {
378 378
         	gravityview()->log->error( '$form not set.', array( 'data' => $forms ) );
379 379
         	return false;
380 380
         }
@@ -393,38 +393,38 @@  discard block
 block discarded – undo
393 393
 	 */
394 394
 	function import_fields( $file ) {
395 395
 
396
-		if( empty( $file ) || !file_exists(  $file ) ) {
396
+		if ( empty( $file ) || ! file_exists( $file ) ) {
397 397
 			gravityview()->log->error( 'Importing Preset Fields. File not found. (File) {path}', array( 'path' => $file ) );
398 398
 			return false;
399 399
 		}
400 400
 
401
-		if( !class_exists('WXR_Parser') ) {
401
+		if ( ! class_exists( 'WXR_Parser' ) ) {
402 402
 			include_once GRAVITYVIEW_DIR . 'includes/lib/xml-parsers/parsers.php';
403 403
 		}
404 404
 
405 405
 		$parser = new WXR_Parser();
406 406
 		$presets = $parser->parse( $file );
407 407
 
408
-		if(is_wp_error( $presets )) {
408
+		if ( is_wp_error( $presets ) ) {
409 409
 			gravityview()->log->error( 'Importing Preset Fields failed. Threw WP_Error.', array( 'data' => $presets ) );
410 410
 			return false;
411 411
 		}
412 412
 
413
-		if( empty( $presets['posts'][0]['postmeta'] ) && !is_array( $presets['posts'][0]['postmeta'] ) ) {
413
+		if ( empty( $presets[ 'posts' ][ 0 ][ 'postmeta' ] ) && ! is_array( $presets[ 'posts' ][ 0 ][ 'postmeta' ] ) ) {
414 414
 			gravityview()->log->error( 'Importing Preset Fields failed. Meta not found in file. {path}', array( 'path' => $file ) );
415 415
 			return false;
416 416
 		}
417 417
 
418
-		gravityview()->log->debug( '[import_fields] postmeta', array( 'data' => $presets['posts'][0]['postmeta'] ) );
418
+		gravityview()->log->debug( '[import_fields] postmeta', array( 'data' => $presets[ 'posts' ][ 0 ][ 'postmeta' ] ) );
419 419
 
420 420
 		$fields = $widgets = array();
421
-		foreach( $presets['posts'][0]['postmeta'] as $meta ) {
422
-			switch ($meta['key']) {
421
+		foreach ( $presets[ 'posts' ][ 0 ][ 'postmeta' ] as $meta ) {
422
+			switch ( $meta[ 'key' ] ) {
423 423
 				case '_gravityview_directory_fields':
424
-					$fields = maybe_unserialize( $meta['value'] );
424
+					$fields = maybe_unserialize( $meta[ 'value' ] );
425 425
 					break;
426 426
 				case '_gravityview_directory_widgets':
427
-					$widgets = maybe_unserialize( $meta['value'] );
427
+					$widgets = maybe_unserialize( $meta[ 'value' ] );
428 428
 					break;
429 429
 			}
430 430
 		}
Please login to merge, or discard this patch.