Completed
Push — develop ( bd6ad5...7b688d )
by Zack
04:29
created
includes/lib/xml-parsers/parsers.php 1 patch
Spacing   +299 added lines, -299 removed lines patch added patch discarded remove patch
@@ -10,42 +10,42 @@  discard block
 block discarded – undo
10 10
  * WordPress Importer class for managing parsing of WXR files.
11 11
  */
12 12
 class WXR_Parser {
13
-	function parse( $file ) {
13
+	function parse($file) {
14 14
 		// Attempt to use proper XML parsers first
15
-		if ( extension_loaded( 'simplexml' ) ) {
15
+		if (extension_loaded('simplexml')) {
16 16
 			$parser = new WXR_Parser_SimpleXML;
17
-			$result = $parser->parse( $file );
17
+			$result = $parser->parse($file);
18 18
 
19 19
 			// If SimpleXML succeeds or this is an invalid WXR file then return the results
20
-			if ( ! is_wp_error( $result ) || 'SimpleXML_parse_error' != $result->get_error_code() )
20
+			if (!is_wp_error($result) || 'SimpleXML_parse_error' != $result->get_error_code())
21 21
 				return $result;
22
-		} else if ( extension_loaded( 'xml' ) ) {
22
+		} else if (extension_loaded('xml')) {
23 23
 			$parser = new WXR_Parser_XML;
24
-			$result = $parser->parse( $file );
24
+			$result = $parser->parse($file);
25 25
 
26 26
 			// If XMLParser succeeds or this is an invalid WXR file then return the results
27
-			if ( ! is_wp_error( $result ) || 'XML_parse_error' != $result->get_error_code() )
27
+			if (!is_wp_error($result) || 'XML_parse_error' != $result->get_error_code())
28 28
 				return $result;
29 29
 		}
30 30
 
31 31
 		// We have a malformed XML file, so display the error and fallthrough to regex
32
-		if ( isset($result) && defined('IMPORT_DEBUG') && IMPORT_DEBUG ) {
32
+		if (isset($result) && defined('IMPORT_DEBUG') && IMPORT_DEBUG) {
33 33
 			echo '<pre>';
34
-			if ( 'SimpleXML_parse_error' == $result->get_error_code() ) {
35
-				foreach  ( $result->get_error_data() as $error )
36
-					echo $error->line . ':' . $error->column . ' ' . esc_html( $error->message ) . "\n";
37
-			} else if ( 'XML_parse_error' == $result->get_error_code() ) {
34
+			if ('SimpleXML_parse_error' == $result->get_error_code()) {
35
+				foreach ($result->get_error_data() as $error)
36
+					echo $error->line.':'.$error->column.' '.esc_html($error->message)."\n";
37
+			} else if ('XML_parse_error' == $result->get_error_code()) {
38 38
 				$error = $result->get_error_data();
39
-				echo $error[0] . ':' . $error[1] . ' ' . esc_html( $error[2] );
39
+				echo $error[0].':'.$error[1].' '.esc_html($error[2]);
40 40
 			}
41 41
 			echo '</pre>';
42
-			echo '<p><strong>' . __( 'There was an error when reading this WXR file', 'wordpress-importer' ) . '</strong><br />';
43
-			echo __( 'Details are shown above. The importer will now try again with a different parser...', 'wordpress-importer' ) . '</p>';
42
+			echo '<p><strong>'.__('There was an error when reading this WXR file', 'wordpress-importer').'</strong><br />';
43
+			echo __('Details are shown above. The importer will now try again with a different parser...', 'wordpress-importer').'</p>';
44 44
 		}
45 45
 
46 46
 		// use regular expressions if nothing else available or this is bad XML
47 47
 		$parser = new WXR_Parser_Regex;
48
-		return $parser->parse( $file );
48
+		return $parser->parse($file);
49 49
 	}
50 50
 }
51 51
 
@@ -53,171 +53,171 @@  discard block
 block discarded – undo
53 53
  * WXR Parser that makes use of the SimpleXML PHP extension.
54 54
  */
55 55
 class WXR_Parser_SimpleXML {
56
-	function parse( $file ) {
56
+	function parse($file) {
57 57
 		$authors = $posts = $categories = $tags = $terms = array();
58 58
 
59 59
 		$internal_errors = libxml_use_internal_errors(true);
60 60
 
61 61
 		$dom = new DOMDocument;
62 62
 		$old_value = null;
63
-		if ( function_exists( 'libxml_disable_entity_loader' ) ) {
64
-			$old_value = libxml_disable_entity_loader( true );
63
+		if (function_exists('libxml_disable_entity_loader')) {
64
+			$old_value = libxml_disable_entity_loader(true);
65 65
 		}
66
-		$success = $dom->loadXML( file_get_contents( $file ) );
67
-		if ( ! is_null( $old_value ) ) {
68
-			libxml_disable_entity_loader( $old_value );
66
+		$success = $dom->loadXML(file_get_contents($file));
67
+		if (!is_null($old_value)) {
68
+			libxml_disable_entity_loader($old_value);
69 69
 		}
70 70
 
71
-		if ( ! $success || isset( $dom->doctype ) ) {
72
-			return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this WXR file', 'wordpress-importer' ), libxml_get_errors() );
71
+		if (!$success || isset($dom->doctype)) {
72
+			return new WP_Error('SimpleXML_parse_error', __('There was an error when reading this WXR file', 'wordpress-importer'), libxml_get_errors());
73 73
 		}
74 74
 
75
-		$xml = simplexml_import_dom( $dom );
76
-		unset( $dom );
75
+		$xml = simplexml_import_dom($dom);
76
+		unset($dom);
77 77
 
78 78
 		// halt if loading produces an error
79
-		if ( ! $xml )
80
-			return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this WXR file', 'wordpress-importer' ), libxml_get_errors() );
79
+		if (!$xml)
80
+			return new WP_Error('SimpleXML_parse_error', __('There was an error when reading this WXR file', 'wordpress-importer'), libxml_get_errors());
81 81
 
82 82
 		$wxr_version = $xml->xpath('/rss/channel/wp:wxr_version');
83
-		if ( ! $wxr_version )
84
-			return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) );
83
+		if (!$wxr_version)
84
+			return new WP_Error('WXR_parse_error', __('This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer'));
85 85
 
86
-		$wxr_version = (string) trim( $wxr_version[0] );
86
+		$wxr_version = (string)trim($wxr_version[0]);
87 87
 		// confirm that we are dealing with the correct file format
88
-		if ( ! preg_match( '/^\d+\.\d+$/', $wxr_version ) )
89
-			return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) );
88
+		if (!preg_match('/^\d+\.\d+$/', $wxr_version))
89
+			return new WP_Error('WXR_parse_error', __('This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer'));
90 90
 
91 91
 		$base_url = $xml->xpath('/rss/channel/wp:base_site_url');
92
-		$base_url = isset($base_url[0]) ? (string) trim( $base_url[0] ) : ''; // Modified by GravityView: Check if base_url exists; the GV import files may exclude them.
92
+		$base_url = isset($base_url[0]) ? (string)trim($base_url[0]) : ''; // Modified by GravityView: Check if base_url exists; the GV import files may exclude them.
93 93
 
94 94
 		$namespaces = $xml->getDocNamespaces();
95
-		if ( ! isset( $namespaces['wp'] ) )
95
+		if (!isset($namespaces['wp']))
96 96
 			$namespaces['wp'] = 'http://wordpress.org/export/1.1/';
97
-		if ( ! isset( $namespaces['excerpt'] ) )
97
+		if (!isset($namespaces['excerpt']))
98 98
 			$namespaces['excerpt'] = 'http://wordpress.org/export/1.1/excerpt/';
99 99
 
100 100
 		// grab authors
101
-		foreach ( $xml->xpath('/rss/channel/wp:author') as $author_arr ) {
102
-			$a = $author_arr->children( $namespaces['wp'] );
103
-			$login = (string) $a->author_login;
101
+		foreach ($xml->xpath('/rss/channel/wp:author') as $author_arr) {
102
+			$a = $author_arr->children($namespaces['wp']);
103
+			$login = (string)$a->author_login;
104 104
 			$authors[$login] = array(
105
-				'author_id' => (int) $a->author_id,
105
+				'author_id' => (int)$a->author_id,
106 106
 				'author_login' => $login,
107
-				'author_email' => (string) $a->author_email,
108
-				'author_display_name' => (string) $a->author_display_name,
109
-				'author_first_name' => (string) $a->author_first_name,
110
-				'author_last_name' => (string) $a->author_last_name
107
+				'author_email' => (string)$a->author_email,
108
+				'author_display_name' => (string)$a->author_display_name,
109
+				'author_first_name' => (string)$a->author_first_name,
110
+				'author_last_name' => (string)$a->author_last_name
111 111
 			);
112 112
 		}
113 113
 
114 114
 		// grab cats, tags and terms
115
-		foreach ( $xml->xpath('/rss/channel/wp:category') as $term_arr ) {
116
-			$t = $term_arr->children( $namespaces['wp'] );
115
+		foreach ($xml->xpath('/rss/channel/wp:category') as $term_arr) {
116
+			$t = $term_arr->children($namespaces['wp']);
117 117
 			$categories[] = array(
118
-				'term_id' => (int) $t->term_id,
119
-				'category_nicename' => (string) $t->category_nicename,
120
-				'category_parent' => (string) $t->category_parent,
121
-				'cat_name' => (string) $t->cat_name,
122
-				'category_description' => (string) $t->category_description
118
+				'term_id' => (int)$t->term_id,
119
+				'category_nicename' => (string)$t->category_nicename,
120
+				'category_parent' => (string)$t->category_parent,
121
+				'cat_name' => (string)$t->cat_name,
122
+				'category_description' => (string)$t->category_description
123 123
 			);
124 124
 		}
125 125
 
126
-		foreach ( $xml->xpath('/rss/channel/wp:tag') as $term_arr ) {
127
-			$t = $term_arr->children( $namespaces['wp'] );
126
+		foreach ($xml->xpath('/rss/channel/wp:tag') as $term_arr) {
127
+			$t = $term_arr->children($namespaces['wp']);
128 128
 			$tags[] = array(
129
-				'term_id' => (int) $t->term_id,
130
-				'tag_slug' => (string) $t->tag_slug,
131
-				'tag_name' => (string) $t->tag_name,
132
-				'tag_description' => (string) $t->tag_description
129
+				'term_id' => (int)$t->term_id,
130
+				'tag_slug' => (string)$t->tag_slug,
131
+				'tag_name' => (string)$t->tag_name,
132
+				'tag_description' => (string)$t->tag_description
133 133
 			);
134 134
 		}
135 135
 
136
-		foreach ( $xml->xpath('/rss/channel/wp:term') as $term_arr ) {
137
-			$t = $term_arr->children( $namespaces['wp'] );
136
+		foreach ($xml->xpath('/rss/channel/wp:term') as $term_arr) {
137
+			$t = $term_arr->children($namespaces['wp']);
138 138
 			$terms[] = array(
139
-				'term_id' => (int) $t->term_id,
140
-				'term_taxonomy' => (string) $t->term_taxonomy,
141
-				'slug' => (string) $t->term_slug,
142
-				'term_parent' => (string) $t->term_parent,
143
-				'term_name' => (string) $t->term_name,
144
-				'term_description' => (string) $t->term_description
139
+				'term_id' => (int)$t->term_id,
140
+				'term_taxonomy' => (string)$t->term_taxonomy,
141
+				'slug' => (string)$t->term_slug,
142
+				'term_parent' => (string)$t->term_parent,
143
+				'term_name' => (string)$t->term_name,
144
+				'term_description' => (string)$t->term_description
145 145
 			);
146 146
 		}
147 147
 
148 148
 		// grab posts
149
-		foreach ( $xml->channel->item as $item ) {
149
+		foreach ($xml->channel->item as $item) {
150 150
 			$post = array(
151
-				'post_title' => (string) $item->title,
152
-				'guid' => (string) $item->guid,
151
+				'post_title' => (string)$item->title,
152
+				'guid' => (string)$item->guid,
153 153
 			);
154 154
 
155
-			$dc = $item->children( 'http://purl.org/dc/elements/1.1/' );
156
-			$post['post_author'] = (string) $dc->creator;
157
-
158
-			$content = $item->children( 'http://purl.org/rss/1.0/modules/content/' );
159
-			$excerpt = $item->children( $namespaces['excerpt'] );
160
-			$post['post_content'] = (string) $content->encoded;
161
-			$post['post_excerpt'] = (string) $excerpt->encoded;
162
-
163
-			$wp = $item->children( $namespaces['wp'] );
164
-			$post['post_id'] = (int) $wp->post_id;
165
-			$post['post_date'] = (string) $wp->post_date;
166
-			$post['post_date_gmt'] = (string) $wp->post_date_gmt;
167
-			$post['comment_status'] = (string) $wp->comment_status;
168
-			$post['ping_status'] = (string) $wp->ping_status;
169
-			$post['post_name'] = (string) $wp->post_name;
170
-			$post['status'] = (string) $wp->status;
171
-			$post['post_parent'] = (int) $wp->post_parent;
172
-			$post['menu_order'] = (int) $wp->menu_order;
173
-			$post['post_type'] = (string) $wp->post_type;
174
-			$post['post_password'] = (string) $wp->post_password;
175
-			$post['is_sticky'] = (int) $wp->is_sticky;
176
-
177
-			if ( isset($wp->attachment_url) )
178
-				$post['attachment_url'] = (string) $wp->attachment_url;
179
-
180
-			foreach ( $item->category as $c ) {
155
+			$dc = $item->children('http://purl.org/dc/elements/1.1/');
156
+			$post['post_author'] = (string)$dc->creator;
157
+
158
+			$content = $item->children('http://purl.org/rss/1.0/modules/content/');
159
+			$excerpt = $item->children($namespaces['excerpt']);
160
+			$post['post_content'] = (string)$content->encoded;
161
+			$post['post_excerpt'] = (string)$excerpt->encoded;
162
+
163
+			$wp = $item->children($namespaces['wp']);
164
+			$post['post_id'] = (int)$wp->post_id;
165
+			$post['post_date'] = (string)$wp->post_date;
166
+			$post['post_date_gmt'] = (string)$wp->post_date_gmt;
167
+			$post['comment_status'] = (string)$wp->comment_status;
168
+			$post['ping_status'] = (string)$wp->ping_status;
169
+			$post['post_name'] = (string)$wp->post_name;
170
+			$post['status'] = (string)$wp->status;
171
+			$post['post_parent'] = (int)$wp->post_parent;
172
+			$post['menu_order'] = (int)$wp->menu_order;
173
+			$post['post_type'] = (string)$wp->post_type;
174
+			$post['post_password'] = (string)$wp->post_password;
175
+			$post['is_sticky'] = (int)$wp->is_sticky;
176
+
177
+			if (isset($wp->attachment_url))
178
+				$post['attachment_url'] = (string)$wp->attachment_url;
179
+
180
+			foreach ($item->category as $c) {
181 181
 				$att = $c->attributes();
182
-				if ( isset( $att['nicename'] ) )
182
+				if (isset($att['nicename']))
183 183
 					$post['terms'][] = array(
184
-						'name' => (string) $c,
185
-						'slug' => (string) $att['nicename'],
186
-						'domain' => (string) $att['domain']
184
+						'name' => (string)$c,
185
+						'slug' => (string)$att['nicename'],
186
+						'domain' => (string)$att['domain']
187 187
 					);
188 188
 			}
189 189
 
190
-			foreach ( $wp->postmeta as $meta ) {
190
+			foreach ($wp->postmeta as $meta) {
191 191
 				$post['postmeta'][] = array(
192
-					'key' => (string) $meta->meta_key,
193
-					'value' => (string) $meta->meta_value
192
+					'key' => (string)$meta->meta_key,
193
+					'value' => (string)$meta->meta_value
194 194
 				);
195 195
 			}
196 196
 
197
-			foreach ( $wp->comment as $comment ) {
197
+			foreach ($wp->comment as $comment) {
198 198
 				$meta = array();
199
-				if ( isset( $comment->commentmeta ) ) {
200
-					foreach ( $comment->commentmeta as $m ) {
199
+				if (isset($comment->commentmeta)) {
200
+					foreach ($comment->commentmeta as $m) {
201 201
 						$meta[] = array(
202
-							'key' => (string) $m->meta_key,
203
-							'value' => (string) $m->meta_value
202
+							'key' => (string)$m->meta_key,
203
+							'value' => (string)$m->meta_value
204 204
 						);
205 205
 					}
206 206
 				}
207 207
 
208 208
 				$post['comments'][] = array(
209
-					'comment_id' => (int) $comment->comment_id,
210
-					'comment_author' => (string) $comment->comment_author,
211
-					'comment_author_email' => (string) $comment->comment_author_email,
212
-					'comment_author_IP' => (string) $comment->comment_author_IP,
213
-					'comment_author_url' => (string) $comment->comment_author_url,
214
-					'comment_date' => (string) $comment->comment_date,
215
-					'comment_date_gmt' => (string) $comment->comment_date_gmt,
216
-					'comment_content' => (string) $comment->comment_content,
217
-					'comment_approved' => (string) $comment->comment_approved,
218
-					'comment_type' => (string) $comment->comment_type,
219
-					'comment_parent' => (string) $comment->comment_parent,
220
-					'comment_user_id' => (int) $comment->comment_user_id,
209
+					'comment_id' => (int)$comment->comment_id,
210
+					'comment_author' => (string)$comment->comment_author,
211
+					'comment_author_email' => (string)$comment->comment_author_email,
212
+					'comment_author_IP' => (string)$comment->comment_author_IP,
213
+					'comment_author_url' => (string)$comment->comment_author_url,
214
+					'comment_date' => (string)$comment->comment_date,
215
+					'comment_date_gmt' => (string)$comment->comment_date_gmt,
216
+					'comment_content' => (string)$comment->comment_content,
217
+					'comment_approved' => (string)$comment->comment_approved,
218
+					'comment_type' => (string)$comment->comment_type,
219
+					'comment_parent' => (string)$comment->comment_parent,
220
+					'comment_user_id' => (int)$comment->comment_user_id,
221 221
 					'commentmeta' => $meta,
222 222
 				);
223 223
 			}
@@ -251,32 +251,32 @@  discard block
 block discarded – undo
251 251
 	);
252 252
 	var $wp_sub_tags = array(
253 253
 		'wp:comment_id', 'wp:comment_author', 'wp:comment_author_email', 'wp:comment_author_url',
254
-		'wp:comment_author_IP',	'wp:comment_date', 'wp:comment_date_gmt', 'wp:comment_content',
254
+		'wp:comment_author_IP', 'wp:comment_date', 'wp:comment_date_gmt', 'wp:comment_content',
255 255
 		'wp:comment_approved', 'wp:comment_type', 'wp:comment_parent', 'wp:comment_user_id',
256 256
 	);
257 257
 
258
-	function parse( $file ) {
258
+	function parse($file) {
259 259
 		$this->wxr_version = $this->in_post = $this->cdata = $this->data = $this->sub_data = $this->in_tag = $this->in_sub_tag = false;
260 260
 		$this->authors = $this->posts = $this->term = $this->category = $this->tag = array();
261 261
 
262
-		$xml = xml_parser_create( 'UTF-8' );
263
-		xml_parser_set_option( $xml, XML_OPTION_SKIP_WHITE, 1 );
264
-		xml_parser_set_option( $xml, XML_OPTION_CASE_FOLDING, 0 );
265
-		xml_set_object( $xml, $this );
266
-		xml_set_character_data_handler( $xml, 'cdata' );
267
-		xml_set_element_handler( $xml, 'tag_open', 'tag_close' );
268
-
269
-		if ( ! xml_parse( $xml, file_get_contents( $file ), true ) ) {
270
-			$current_line = xml_get_current_line_number( $xml );
271
-			$current_column = xml_get_current_column_number( $xml );
272
-			$error_code = xml_get_error_code( $xml );
273
-			$error_string = xml_error_string( $error_code );
274
-			return new WP_Error( 'XML_parse_error', 'There was an error when reading this WXR file', array( $current_line, $current_column, $error_string ) );
262
+		$xml = xml_parser_create('UTF-8');
263
+		xml_parser_set_option($xml, XML_OPTION_SKIP_WHITE, 1);
264
+		xml_parser_set_option($xml, XML_OPTION_CASE_FOLDING, 0);
265
+		xml_set_object($xml, $this);
266
+		xml_set_character_data_handler($xml, 'cdata');
267
+		xml_set_element_handler($xml, 'tag_open', 'tag_close');
268
+
269
+		if (!xml_parse($xml, file_get_contents($file), true)) {
270
+			$current_line = xml_get_current_line_number($xml);
271
+			$current_column = xml_get_current_column_number($xml);
272
+			$error_code = xml_get_error_code($xml);
273
+			$error_string = xml_error_string($error_code);
274
+			return new WP_Error('XML_parse_error', 'There was an error when reading this WXR file', array($current_line, $current_column, $error_string));
275 275
 		}
276
-		xml_parser_free( $xml );
276
+		xml_parser_free($xml);
277 277
 
278
-		if ( ! preg_match( '/^\d+\.\d+$/', $this->wxr_version ) )
279
-			return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) );
278
+		if (!preg_match('/^\d+\.\d+$/', $this->wxr_version))
279
+			return new WP_Error('WXR_parse_error', __('This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer'));
280 280
 
281 281
 		return array(
282 282
 			'authors' => $this->authors,
@@ -289,26 +289,26 @@  discard block
 block discarded – undo
289 289
 		);
290 290
 	}
291 291
 
292
-	function tag_open( $parse, $tag, $attr ) {
293
-		if ( in_array( $tag, $this->wp_tags ) ) {
294
-			$this->in_tag = substr( $tag, 3 );
292
+	function tag_open($parse, $tag, $attr) {
293
+		if (in_array($tag, $this->wp_tags)) {
294
+			$this->in_tag = substr($tag, 3);
295 295
 			return;
296 296
 		}
297 297
 
298
-		if ( in_array( $tag, $this->wp_sub_tags ) ) {
299
-			$this->in_sub_tag = substr( $tag, 3 );
298
+		if (in_array($tag, $this->wp_sub_tags)) {
299
+			$this->in_sub_tag = substr($tag, 3);
300 300
 			return;
301 301
 		}
302 302
 
303
-		switch ( $tag ) {
303
+		switch ($tag) {
304 304
 			case 'category':
305
-				if ( isset($attr['domain'], $attr['nicename']) ) {
305
+				if (isset($attr['domain'], $attr['nicename'])) {
306 306
 					$this->sub_data['domain'] = $attr['domain'];
307 307
 					$this->sub_data['slug'] = $attr['nicename'];
308 308
 				}
309 309
 				break;
310 310
 			case 'item': $this->in_post = true;
311
-			case 'title': if ( $this->in_post ) $this->in_tag = 'post_title'; break;
311
+			case 'title': if ($this->in_post) $this->in_tag = 'post_title'; break;
312 312
 			case 'guid': $this->in_tag = 'guid'; break;
313 313
 			case 'dc:creator': $this->in_tag = 'post_author'; break;
314 314
 			case 'content:encoded': $this->in_tag = 'post_content'; break;
@@ -320,18 +320,18 @@  discard block
 block discarded – undo
320 320
 		}
321 321
 	}
322 322
 
323
-	function cdata( $parser, $cdata ) {
324
-		if ( ! trim( $cdata ) )
323
+	function cdata($parser, $cdata) {
324
+		if (!trim($cdata))
325 325
 			return;
326 326
 
327
-		$this->cdata .= trim( $cdata );
327
+		$this->cdata .= trim($cdata);
328 328
 	}
329 329
 
330
-	function tag_close( $parser, $tag ) {
331
-		switch ( $tag ) {
330
+	function tag_close($parser, $tag) {
331
+		switch ($tag) {
332 332
 			case 'wp:comment':
333
-				unset( $this->sub_data['key'], $this->sub_data['value'] ); // remove meta sub_data
334
-				if ( ! empty( $this->sub_data ) )
333
+				unset($this->sub_data['key'], $this->sub_data['value']); // remove meta sub_data
334
+				if (!empty($this->sub_data))
335 335
 					$this->data['comments'][] = $this->sub_data;
336 336
 				$this->sub_data = false;
337 337
 				break;
@@ -342,14 +342,14 @@  discard block
 block discarded – undo
342 342
 				);
343 343
 				break;
344 344
 			case 'category':
345
-				if ( ! empty( $this->sub_data ) ) {
345
+				if (!empty($this->sub_data)) {
346 346
 					$this->sub_data['name'] = $this->cdata;
347 347
 					$this->data['terms'][] = $this->sub_data;
348 348
 				}
349 349
 				$this->sub_data = false;
350 350
 				break;
351 351
 			case 'wp:postmeta':
352
-				if ( ! empty( $this->sub_data ) )
352
+				if (!empty($this->sub_data))
353 353
 					$this->data['postmeta'][] = $this->sub_data;
354 354
 				$this->sub_data = false;
355 355
 				break;
@@ -360,12 +360,12 @@  discard block
 block discarded – undo
360 360
 			case 'wp:category':
361 361
 			case 'wp:tag':
362 362
 			case 'wp:term':
363
-				$n = substr( $tag, 3 );
364
-				array_push( $this->$n, $this->data );
363
+				$n = substr($tag, 3);
364
+				array_push($this->$n, $this->data);
365 365
 				$this->data = false;
366 366
 				break;
367 367
 			case 'wp:author':
368
-				if ( ! empty($this->data['author_login']) )
368
+				if (!empty($this->data['author_login']))
369 369
 					$this->authors[$this->data['author_login']] = $this->data;
370 370
 				$this->data = false;
371 371
 				break;
@@ -377,11 +377,11 @@  discard block
 block discarded – undo
377 377
 				break;
378 378
 
379 379
 			default:
380
-				if ( $this->in_sub_tag ) {
381
-					$this->sub_data[$this->in_sub_tag] = ! empty( $this->cdata ) ? $this->cdata : '';
380
+				if ($this->in_sub_tag) {
381
+					$this->sub_data[$this->in_sub_tag] = !empty($this->cdata) ? $this->cdata : '';
382 382
 					$this->in_sub_tag = false;
383
-				} else if ( $this->in_tag ) {
384
-					$this->data[$this->in_tag] = ! empty( $this->cdata ) ? $this->cdata : '';
383
+				} else if ($this->in_tag) {
384
+					$this->data[$this->in_tag] = !empty($this->cdata) ? $this->cdata : '';
385 385
 					$this->in_tag = false;
386 386
 				}
387 387
 		}
@@ -407,66 +407,66 @@  discard block
 block discarded – undo
407 407
 	}*/
408 408
 
409 409
 	function __construct() {
410
-		$this->has_gzip = is_callable( 'gzopen' );
410
+		$this->has_gzip = is_callable('gzopen');
411 411
 	}
412 412
 
413
-	function parse( $file ) {
413
+	function parse($file) {
414 414
 		$wxr_version = $in_post = false;
415 415
 
416
-		$fp = $this->fopen( $file, 'r' );
417
-		if ( $fp ) {
418
-			while ( ! $this->feof( $fp ) ) {
419
-				$importline = rtrim( $this->fgets( $fp ) );
416
+		$fp = $this->fopen($file, 'r');
417
+		if ($fp) {
418
+			while (!$this->feof($fp)) {
419
+				$importline = rtrim($this->fgets($fp));
420 420
 
421
-				if ( ! $wxr_version && preg_match( '|<wp:wxr_version>(\d+\.\d+)</wp:wxr_version>|', $importline, $version ) )
421
+				if (!$wxr_version && preg_match('|<wp:wxr_version>(\d+\.\d+)</wp:wxr_version>|', $importline, $version))
422 422
 					$wxr_version = $version[1];
423 423
 
424
-				if ( false !== strpos( $importline, '<wp:base_site_url>' ) ) {
425
-					preg_match( '|<wp:base_site_url>(.*?)</wp:base_site_url>|is', $importline, $url );
424
+				if (false !== strpos($importline, '<wp:base_site_url>')) {
425
+					preg_match('|<wp:base_site_url>(.*?)</wp:base_site_url>|is', $importline, $url);
426 426
 					$this->base_url = $url[1];
427 427
 					continue;
428 428
 				}
429
-				if ( false !== strpos( $importline, '<wp:category>' ) ) {
430
-					preg_match( '|<wp:category>(.*?)</wp:category>|is', $importline, $category );
431
-					$this->categories[] = $this->process_category( $category[1] );
429
+				if (false !== strpos($importline, '<wp:category>')) {
430
+					preg_match('|<wp:category>(.*?)</wp:category>|is', $importline, $category);
431
+					$this->categories[] = $this->process_category($category[1]);
432 432
 					continue;
433 433
 				}
434
-				if ( false !== strpos( $importline, '<wp:tag>' ) ) {
435
-					preg_match( '|<wp:tag>(.*?)</wp:tag>|is', $importline, $tag );
436
-					$this->tags[] = $this->process_tag( $tag[1] );
434
+				if (false !== strpos($importline, '<wp:tag>')) {
435
+					preg_match('|<wp:tag>(.*?)</wp:tag>|is', $importline, $tag);
436
+					$this->tags[] = $this->process_tag($tag[1]);
437 437
 					continue;
438 438
 				}
439
-				if ( false !== strpos( $importline, '<wp:term>' ) ) {
440
-					preg_match( '|<wp:term>(.*?)</wp:term>|is', $importline, $term );
441
-					$this->terms[] = $this->process_term( $term[1] );
439
+				if (false !== strpos($importline, '<wp:term>')) {
440
+					preg_match('|<wp:term>(.*?)</wp:term>|is', $importline, $term);
441
+					$this->terms[] = $this->process_term($term[1]);
442 442
 					continue;
443 443
 				}
444
-				if ( false !== strpos( $importline, '<wp:author>' ) ) {
445
-					preg_match( '|<wp:author>(.*?)</wp:author>|is', $importline, $author );
446
-					$a = $this->process_author( $author[1] );
444
+				if (false !== strpos($importline, '<wp:author>')) {
445
+					preg_match('|<wp:author>(.*?)</wp:author>|is', $importline, $author);
446
+					$a = $this->process_author($author[1]);
447 447
 					$this->authors[$a['author_login']] = $a;
448 448
 					continue;
449 449
 				}
450
-				if ( false !== strpos( $importline, '<item>' ) ) {
450
+				if (false !== strpos($importline, '<item>')) {
451 451
 					$post = '';
452 452
 					$in_post = true;
453 453
 					continue;
454 454
 				}
455
-				if ( false !== strpos( $importline, '</item>' ) ) {
455
+				if (false !== strpos($importline, '</item>')) {
456 456
 					$in_post = false;
457
-					$this->posts[] = $this->process_post( $post );
457
+					$this->posts[] = $this->process_post($post);
458 458
 					continue;
459 459
 				}
460
-				if ( $in_post ) {
461
-					$post .= $importline . "\n";
460
+				if ($in_post) {
461
+					$post .= $importline."\n";
462 462
 				}
463 463
 			}
464 464
 
465 465
 			$this->fclose($fp);
466 466
 		}
467 467
 
468
-		if ( ! $wxr_version )
469
-			return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) );
468
+		if (!$wxr_version)
469
+			return new WP_Error('WXR_parse_error', __('This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer'));
470 470
 
471 471
 		return array(
472 472
 			'authors' => $this->authors,
@@ -479,17 +479,17 @@  discard block
 block discarded – undo
479 479
 		);
480 480
 	}
481 481
 
482
-	function get_tag( $string, $tag ) {
483
-		preg_match( "|<$tag.*?>(.*?)</$tag>|is", $string, $return );
484
-		if ( isset( $return[1] ) ) {
485
-			if ( substr( $return[1], 0, 9 ) == '<![CDATA[' ) {
486
-				if ( strpos( $return[1], ']]]]><![CDATA[>' ) !== false ) {
487
-					preg_match_all( '|<!\[CDATA\[(.*?)\]\]>|s', $return[1], $matches );
482
+	function get_tag($string, $tag) {
483
+		preg_match("|<$tag.*?>(.*?)</$tag>|is", $string, $return);
484
+		if (isset($return[1])) {
485
+			if (substr($return[1], 0, 9) == '<![CDATA[') {
486
+				if (strpos($return[1], ']]]]><![CDATA[>') !== false) {
487
+					preg_match_all('|<!\[CDATA\[(.*?)\]\]>|s', $return[1], $matches);
488 488
 					$return = '';
489
-					foreach( $matches[1] as $match )
489
+					foreach ($matches[1] as $match)
490 490
 						$return .= $match;
491 491
 				} else {
492
-					$return = preg_replace( '|^<!\[CDATA\[(.*)\]\]>$|s', '$1', $return[1] );
492
+					$return = preg_replace('|^<!\[CDATA\[(.*)\]\]>$|s', '$1', $return[1]);
493 493
 				}
494 494
 			} else {
495 495
 				$return = $return[1];
@@ -500,166 +500,166 @@  discard block
 block discarded – undo
500 500
 		return $return;
501 501
 	}
502 502
 
503
-	function process_category( $c ) {
503
+	function process_category($c) {
504 504
 		return array(
505
-			'term_id' => $this->get_tag( $c, 'wp:term_id' ),
506
-			'cat_name' => $this->get_tag( $c, 'wp:cat_name' ),
507
-			'category_nicename'	=> $this->get_tag( $c, 'wp:category_nicename' ),
508
-			'category_parent' => $this->get_tag( $c, 'wp:category_parent' ),
509
-			'category_description' => $this->get_tag( $c, 'wp:category_description' ),
505
+			'term_id' => $this->get_tag($c, 'wp:term_id'),
506
+			'cat_name' => $this->get_tag($c, 'wp:cat_name'),
507
+			'category_nicename'	=> $this->get_tag($c, 'wp:category_nicename'),
508
+			'category_parent' => $this->get_tag($c, 'wp:category_parent'),
509
+			'category_description' => $this->get_tag($c, 'wp:category_description'),
510 510
 		);
511 511
 	}
512 512
 
513
-	function process_tag( $t ) {
513
+	function process_tag($t) {
514 514
 		return array(
515
-			'term_id' => $this->get_tag( $t, 'wp:term_id' ),
516
-			'tag_name' => $this->get_tag( $t, 'wp:tag_name' ),
517
-			'tag_slug' => $this->get_tag( $t, 'wp:tag_slug' ),
518
-			'tag_description' => $this->get_tag( $t, 'wp:tag_description' ),
515
+			'term_id' => $this->get_tag($t, 'wp:term_id'),
516
+			'tag_name' => $this->get_tag($t, 'wp:tag_name'),
517
+			'tag_slug' => $this->get_tag($t, 'wp:tag_slug'),
518
+			'tag_description' => $this->get_tag($t, 'wp:tag_description'),
519 519
 		);
520 520
 	}
521 521
 
522
-	function process_term( $t ) {
522
+	function process_term($t) {
523 523
 		return array(
524
-			'term_id' => $this->get_tag( $t, 'wp:term_id' ),
525
-			'term_taxonomy' => $this->get_tag( $t, 'wp:term_taxonomy' ),
526
-			'slug' => $this->get_tag( $t, 'wp:term_slug' ),
527
-			'term_parent' => $this->get_tag( $t, 'wp:term_parent' ),
528
-			'term_name' => $this->get_tag( $t, 'wp:term_name' ),
529
-			'term_description' => $this->get_tag( $t, 'wp:term_description' ),
524
+			'term_id' => $this->get_tag($t, 'wp:term_id'),
525
+			'term_taxonomy' => $this->get_tag($t, 'wp:term_taxonomy'),
526
+			'slug' => $this->get_tag($t, 'wp:term_slug'),
527
+			'term_parent' => $this->get_tag($t, 'wp:term_parent'),
528
+			'term_name' => $this->get_tag($t, 'wp:term_name'),
529
+			'term_description' => $this->get_tag($t, 'wp:term_description'),
530 530
 		);
531 531
 	}
532 532
 
533
-	function process_author( $a ) {
533
+	function process_author($a) {
534 534
 		return array(
535
-			'author_id' => $this->get_tag( $a, 'wp:author_id' ),
536
-			'author_login' => $this->get_tag( $a, 'wp:author_login' ),
537
-			'author_email' => $this->get_tag( $a, 'wp:author_email' ),
538
-			'author_display_name' => $this->get_tag( $a, 'wp:author_display_name' ),
539
-			'author_first_name' => $this->get_tag( $a, 'wp:author_first_name' ),
540
-			'author_last_name' => $this->get_tag( $a, 'wp:author_last_name' ),
535
+			'author_id' => $this->get_tag($a, 'wp:author_id'),
536
+			'author_login' => $this->get_tag($a, 'wp:author_login'),
537
+			'author_email' => $this->get_tag($a, 'wp:author_email'),
538
+			'author_display_name' => $this->get_tag($a, 'wp:author_display_name'),
539
+			'author_first_name' => $this->get_tag($a, 'wp:author_first_name'),
540
+			'author_last_name' => $this->get_tag($a, 'wp:author_last_name'),
541 541
 		);
542 542
 	}
543 543
 
544
-	function process_post( $post ) {
545
-		$post_id        = $this->get_tag( $post, 'wp:post_id' );
546
-		$post_title     = $this->get_tag( $post, 'title' );
547
-		$post_date      = $this->get_tag( $post, 'wp:post_date' );
548
-		$post_date_gmt  = $this->get_tag( $post, 'wp:post_date_gmt' );
549
-		$comment_status = $this->get_tag( $post, 'wp:comment_status' );
550
-		$ping_status    = $this->get_tag( $post, 'wp:ping_status' );
551
-		$status         = $this->get_tag( $post, 'wp:status' );
552
-		$post_name      = $this->get_tag( $post, 'wp:post_name' );
553
-		$post_parent    = $this->get_tag( $post, 'wp:post_parent' );
554
-		$menu_order     = $this->get_tag( $post, 'wp:menu_order' );
555
-		$post_type      = $this->get_tag( $post, 'wp:post_type' );
556
-		$post_password  = $this->get_tag( $post, 'wp:post_password' );
557
-		$is_sticky      = $this->get_tag( $post, 'wp:is_sticky' );
558
-		$guid           = $this->get_tag( $post, 'guid' );
559
-		$post_author    = $this->get_tag( $post, 'dc:creator' );
560
-
561
-		$post_excerpt = $this->get_tag( $post, 'excerpt:encoded' );
562
-		$post_excerpt = preg_replace_callback( '|<(/?[A-Z]+)|', array( &$this, '_normalize_tag' ), $post_excerpt );
563
-		$post_excerpt = str_replace( '<br>', '<br />', $post_excerpt );
564
-		$post_excerpt = str_replace( '<hr>', '<hr />', $post_excerpt );
565
-
566
-		$post_content = $this->get_tag( $post, 'content:encoded' );
567
-		$post_content = preg_replace_callback( '|<(/?[A-Z]+)|', array( &$this, '_normalize_tag' ), $post_content );
568
-		$post_content = str_replace( '<br>', '<br />', $post_content );
569
-		$post_content = str_replace( '<hr>', '<hr />', $post_content );
570
-
571
-		$postdata = compact( 'post_id', 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_excerpt',
544
+	function process_post($post) {
545
+		$post_id        = $this->get_tag($post, 'wp:post_id');
546
+		$post_title     = $this->get_tag($post, 'title');
547
+		$post_date      = $this->get_tag($post, 'wp:post_date');
548
+		$post_date_gmt  = $this->get_tag($post, 'wp:post_date_gmt');
549
+		$comment_status = $this->get_tag($post, 'wp:comment_status');
550
+		$ping_status    = $this->get_tag($post, 'wp:ping_status');
551
+		$status         = $this->get_tag($post, 'wp:status');
552
+		$post_name      = $this->get_tag($post, 'wp:post_name');
553
+		$post_parent    = $this->get_tag($post, 'wp:post_parent');
554
+		$menu_order     = $this->get_tag($post, 'wp:menu_order');
555
+		$post_type      = $this->get_tag($post, 'wp:post_type');
556
+		$post_password  = $this->get_tag($post, 'wp:post_password');
557
+		$is_sticky      = $this->get_tag($post, 'wp:is_sticky');
558
+		$guid           = $this->get_tag($post, 'guid');
559
+		$post_author    = $this->get_tag($post, 'dc:creator');
560
+
561
+		$post_excerpt = $this->get_tag($post, 'excerpt:encoded');
562
+		$post_excerpt = preg_replace_callback('|<(/?[A-Z]+)|', array(&$this, '_normalize_tag'), $post_excerpt);
563
+		$post_excerpt = str_replace('<br>', '<br />', $post_excerpt);
564
+		$post_excerpt = str_replace('<hr>', '<hr />', $post_excerpt);
565
+
566
+		$post_content = $this->get_tag($post, 'content:encoded');
567
+		$post_content = preg_replace_callback('|<(/?[A-Z]+)|', array(&$this, '_normalize_tag'), $post_content);
568
+		$post_content = str_replace('<br>', '<br />', $post_content);
569
+		$post_content = str_replace('<hr>', '<hr />', $post_content);
570
+
571
+		$postdata = compact('post_id', 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_excerpt',
572 572
 			'post_title', 'status', 'post_name', 'comment_status', 'ping_status', 'guid', 'post_parent',
573 573
 			'menu_order', 'post_type', 'post_password', 'is_sticky'
574 574
 		);
575 575
 
576
-		$attachment_url = $this->get_tag( $post, 'wp:attachment_url' );
577
-		if ( $attachment_url )
576
+		$attachment_url = $this->get_tag($post, 'wp:attachment_url');
577
+		if ($attachment_url)
578 578
 			$postdata['attachment_url'] = $attachment_url;
579 579
 
580
-		preg_match_all( '|<category domain="([^"]+?)" nicename="([^"]+?)">(.+?)</category>|is', $post, $terms, PREG_SET_ORDER );
581
-		foreach ( $terms as $t ) {
580
+		preg_match_all('|<category domain="([^"]+?)" nicename="([^"]+?)">(.+?)</category>|is', $post, $terms, PREG_SET_ORDER);
581
+		foreach ($terms as $t) {
582 582
 			$post_terms[] = array(
583 583
 				'slug' => $t[2],
584 584
 				'domain' => $t[1],
585
-				'name' => str_replace( array( '<![CDATA[', ']]>' ), '', $t[3] ),
585
+				'name' => str_replace(array('<![CDATA[', ']]>'), '', $t[3]),
586 586
 			);
587 587
 		}
588
-		if ( ! empty( $post_terms ) ) $postdata['terms'] = $post_terms;
588
+		if (!empty($post_terms)) $postdata['terms'] = $post_terms;
589 589
 
590
-		preg_match_all( '|<wp:comment>(.+?)</wp:comment>|is', $post, $comments );
590
+		preg_match_all('|<wp:comment>(.+?)</wp:comment>|is', $post, $comments);
591 591
 		$comments = $comments[1];
592
-		if ( $comments ) {
593
-			foreach ( $comments as $comment ) {
594
-				preg_match_all( '|<wp:commentmeta>(.+?)</wp:commentmeta>|is', $comment, $commentmeta );
592
+		if ($comments) {
593
+			foreach ($comments as $comment) {
594
+				preg_match_all('|<wp:commentmeta>(.+?)</wp:commentmeta>|is', $comment, $commentmeta);
595 595
 				$commentmeta = $commentmeta[1];
596 596
 				$c_meta = array();
597
-				foreach ( $commentmeta as $m ) {
597
+				foreach ($commentmeta as $m) {
598 598
 					$c_meta[] = array(
599
-						'key' => $this->get_tag( $m, 'wp:meta_key' ),
600
-						'value' => $this->get_tag( $m, 'wp:meta_value' ),
599
+						'key' => $this->get_tag($m, 'wp:meta_key'),
600
+						'value' => $this->get_tag($m, 'wp:meta_value'),
601 601
 					);
602 602
 				}
603 603
 
604 604
 				$post_comments[] = array(
605
-					'comment_id' => $this->get_tag( $comment, 'wp:comment_id' ),
606
-					'comment_author' => $this->get_tag( $comment, 'wp:comment_author' ),
607
-					'comment_author_email' => $this->get_tag( $comment, 'wp:comment_author_email' ),
608
-					'comment_author_IP' => $this->get_tag( $comment, 'wp:comment_author_IP' ),
609
-					'comment_author_url' => $this->get_tag( $comment, 'wp:comment_author_url' ),
610
-					'comment_date' => $this->get_tag( $comment, 'wp:comment_date' ),
611
-					'comment_date_gmt' => $this->get_tag( $comment, 'wp:comment_date_gmt' ),
612
-					'comment_content' => $this->get_tag( $comment, 'wp:comment_content' ),
613
-					'comment_approved' => $this->get_tag( $comment, 'wp:comment_approved' ),
614
-					'comment_type' => $this->get_tag( $comment, 'wp:comment_type' ),
615
-					'comment_parent' => $this->get_tag( $comment, 'wp:comment_parent' ),
616
-					'comment_user_id' => $this->get_tag( $comment, 'wp:comment_user_id' ),
605
+					'comment_id' => $this->get_tag($comment, 'wp:comment_id'),
606
+					'comment_author' => $this->get_tag($comment, 'wp:comment_author'),
607
+					'comment_author_email' => $this->get_tag($comment, 'wp:comment_author_email'),
608
+					'comment_author_IP' => $this->get_tag($comment, 'wp:comment_author_IP'),
609
+					'comment_author_url' => $this->get_tag($comment, 'wp:comment_author_url'),
610
+					'comment_date' => $this->get_tag($comment, 'wp:comment_date'),
611
+					'comment_date_gmt' => $this->get_tag($comment, 'wp:comment_date_gmt'),
612
+					'comment_content' => $this->get_tag($comment, 'wp:comment_content'),
613
+					'comment_approved' => $this->get_tag($comment, 'wp:comment_approved'),
614
+					'comment_type' => $this->get_tag($comment, 'wp:comment_type'),
615
+					'comment_parent' => $this->get_tag($comment, 'wp:comment_parent'),
616
+					'comment_user_id' => $this->get_tag($comment, 'wp:comment_user_id'),
617 617
 					'commentmeta' => $c_meta,
618 618
 				);
619 619
 			}
620 620
 		}
621
-		if ( ! empty( $post_comments ) ) $postdata['comments'] = $post_comments;
621
+		if (!empty($post_comments)) $postdata['comments'] = $post_comments;
622 622
 
623
-		preg_match_all( '|<wp:postmeta>(.+?)</wp:postmeta>|is', $post, $postmeta );
623
+		preg_match_all('|<wp:postmeta>(.+?)</wp:postmeta>|is', $post, $postmeta);
624 624
 		$postmeta = $postmeta[1];
625
-		if ( $postmeta ) {
626
-			foreach ( $postmeta as $p ) {
625
+		if ($postmeta) {
626
+			foreach ($postmeta as $p) {
627 627
 				$post_postmeta[] = array(
628
-					'key' => $this->get_tag( $p, 'wp:meta_key' ),
629
-					'value' => $this->get_tag( $p, 'wp:meta_value' ),
628
+					'key' => $this->get_tag($p, 'wp:meta_key'),
629
+					'value' => $this->get_tag($p, 'wp:meta_value'),
630 630
 				);
631 631
 			}
632 632
 		}
633
-		if ( ! empty( $post_postmeta ) ) $postdata['postmeta'] = $post_postmeta;
633
+		if (!empty($post_postmeta)) $postdata['postmeta'] = $post_postmeta;
634 634
 
635 635
 		return $postdata;
636 636
 	}
637 637
 
638
-	function _normalize_tag( $matches ) {
639
-		return '<' . strtolower( $matches[1] );
638
+	function _normalize_tag($matches) {
639
+		return '<'.strtolower($matches[1]);
640 640
 	}
641 641
 
642
-	function fopen( $filename, $mode = 'r' ) {
643
-		if ( $this->has_gzip )
644
-			return gzopen( $filename, $mode );
645
-		return fopen( $filename, $mode );
642
+	function fopen($filename, $mode = 'r') {
643
+		if ($this->has_gzip)
644
+			return gzopen($filename, $mode);
645
+		return fopen($filename, $mode);
646 646
 	}
647 647
 
648
-	function feof( $fp ) {
649
-		if ( $this->has_gzip )
650
-			return gzeof( $fp );
651
-		return feof( $fp );
648
+	function feof($fp) {
649
+		if ($this->has_gzip)
650
+			return gzeof($fp);
651
+		return feof($fp);
652 652
 	}
653 653
 
654
-	function fgets( $fp, $len = 8192 ) {
655
-		if ( $this->has_gzip )
656
-			return gzgets( $fp, $len );
657
-		return fgets( $fp, $len );
654
+	function fgets($fp, $len = 8192) {
655
+		if ($this->has_gzip)
656
+			return gzgets($fp, $len);
657
+		return fgets($fp, $len);
658 658
 	}
659 659
 
660
-	function fclose( $fp ) {
661
-		if ( $this->has_gzip )
662
-			return gzclose( $fp );
663
-		return fclose( $fp );
660
+	function fclose($fp) {
661
+		if ($this->has_gzip)
662
+			return gzclose($fp);
663
+		return fclose($fp);
664 664
 	}
665 665
 }
Please login to merge, or discard this patch.
includes/load-plugin-and-theme-hooks.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -14,12 +14,12 @@
 block discarded – undo
14 14
 
15 15
 
16 16
 /** @define "GRAVITYVIEW_DIR" "../" */
17
-$include_path = GRAVITYVIEW_DIR . 'includes/plugin-and-theme-hooks/';
17
+$include_path = GRAVITYVIEW_DIR.'includes/plugin-and-theme-hooks/';
18 18
 
19 19
 // Abstract class
20
-require $include_path . 'abstract-gravityview-plugin-and-theme-hooks.php';
20
+require $include_path.'abstract-gravityview-plugin-and-theme-hooks.php';
21 21
 
22 22
 // Load all plugin and theme files automatically
23
-foreach ( glob( $include_path . 'class-gravityview-{plugin,theme}-hooks-*.php', GLOB_BRACE ) as $gv_hooks_filename ) {
23
+foreach (glob($include_path.'class-gravityview-{plugin,theme}-hooks-*.php', GLOB_BRACE) as $gv_hooks_filename) {
24 24
 	include $gv_hooks_filename;
25 25
 }
26 26
\ No newline at end of file
Please login to merge, or discard this patch.
plugin-and-theme-hooks/abstract-gravityview-plugin-and-theme-hooks.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -89,11 +89,11 @@  discard block
 block discarded – undo
89 89
 	 * @return void
90 90
 	 */
91 91
 	private function maybe_add_hooks() {
92
-		$class_exists = ! $this->class_name || ( $this->class_name && class_exists( $this->class_name ) );
93
-		$function_exists = ! $this->function_name || ( $this->function_name && function_exists( $this->function_name ) );
94
-		$constant_defined = ! $this->constant_name || ( $this->constant_name && defined( $this->constant_name ) );
92
+		$class_exists = !$this->class_name || ($this->class_name && class_exists($this->class_name));
93
+		$function_exists = !$this->function_name || ($this->function_name && function_exists($this->function_name));
94
+		$constant_defined = !$this->constant_name || ($this->constant_name && defined($this->constant_name));
95 95
 
96
-		if( $class_exists || $function_exists || $constant_defined ) {
96
+		if ($class_exists || $function_exists || $constant_defined) {
97 97
 			$this->add_hooks();
98 98
 		}
99 99
 	}
@@ -104,20 +104,20 @@  discard block
 block discarded – undo
104 104
 	 * @return void
105 105
 	 */
106 106
 	protected function add_hooks() {
107
-		if( $this->content_meta_keys ) {
108
-			add_filter( 'gravityview/data/parse/meta_keys', array( $this, 'merge_content_meta_keys' ), 10, 2 );
107
+		if ($this->content_meta_keys) {
108
+			add_filter('gravityview/data/parse/meta_keys', array($this, 'merge_content_meta_keys'), 10, 2);
109 109
 		}
110 110
 
111
-		if( $this->script_handles ) {
112
-			add_filter( 'gravityview_noconflict_scripts', array( $this, 'merge_noconflict_scripts' ) );
111
+		if ($this->script_handles) {
112
+			add_filter('gravityview_noconflict_scripts', array($this, 'merge_noconflict_scripts'));
113 113
 		}
114 114
 
115
-		if( $this->style_handles ) {
116
-			add_filter( 'gravityview_noconflict_styles', array( $this, 'merge_noconflict_styles' ) );
115
+		if ($this->style_handles) {
116
+			add_filter('gravityview_noconflict_styles', array($this, 'merge_noconflict_styles'));
117 117
 		}
118 118
 
119
-		if( $this->post_type_support ) {
120
-			add_filter( 'gravityview_post_type_support', array( $this, 'merge_post_type_support' ), 10, 2 );
119
+		if ($this->post_type_support) {
120
+			add_filter('gravityview_post_type_support', array($this, 'merge_post_type_support'), 10, 2);
121 121
 		}
122 122
 	}
123 123
 
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
 	 *
132 132
 	 * @return array Array of features associated with a functional area of the edit screen, merged with existing values
133 133
 	 */
134
-	public function merge_post_type_support( $supports = array(), $is_hierarchical = false ) {
135
-		$supports = array_merge( $this->post_type_support, $supports );
134
+	public function merge_post_type_support($supports = array(), $is_hierarchical = false) {
135
+		$supports = array_merge($this->post_type_support, $supports);
136 136
 		return $supports;
137 137
 	}
138 138
 
@@ -145,8 +145,8 @@  discard block
 block discarded – undo
145 145
 	 *
146 146
 	 * @return array Handles, merged with existing styles
147 147
 	 */
148
-	public function merge_noconflict_styles( $handles ) {
149
-		$handles = array_merge( $this->style_handles, $handles );
148
+	public function merge_noconflict_styles($handles) {
149
+		$handles = array_merge($this->style_handles, $handles);
150 150
 		return $handles;
151 151
 	}
152 152
 
@@ -159,8 +159,8 @@  discard block
 block discarded – undo
159 159
 	 *
160 160
 	 * @return array Handles, merged with existing scripts
161 161
 	 */
162
-	public function merge_noconflict_scripts( $handles ) {
163
-		$handles = array_merge( $this->script_handles, $handles );
162
+	public function merge_noconflict_scripts($handles) {
163
+		$handles = array_merge($this->script_handles, $handles);
164 164
 		return $handles;
165 165
 	}
166 166
 
@@ -174,8 +174,8 @@  discard block
 block discarded – undo
174 174
 	 *
175 175
 	 * @return array Meta key array, merged with existing meta keys
176 176
 	 */
177
-	public function merge_content_meta_keys( $meta_keys = array(), $post_id = 0 ) {
178
-		return array_merge( $this->content_meta_keys, $meta_keys );
177
+	public function merge_content_meta_keys($meta_keys = array(), $post_id = 0) {
178
+		return array_merge($this->content_meta_keys, $meta_keys);
179 179
 	}
180 180
 
181 181
 }
182 182
\ No newline at end of file
Please login to merge, or discard this patch.
plugin-and-theme-hooks/class-gravityview-plugin-hooks-yoast-seo.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -56,16 +56,16 @@  discard block
 block discarded – undo
56 56
 
57 57
 		parent::add_hooks();
58 58
 
59
-		if( gravityview_is_admin_page() ) {
59
+		if (gravityview_is_admin_page()) {
60 60
 
61 61
 				// Make Yoast metabox go down to the bottom please.
62
-			add_filter( 'wpseo_metabox_prio', array( $this, '__return_low' ) );
62
+			add_filter('wpseo_metabox_prio', array($this, '__return_low'));
63 63
 
64 64
 			// Prevent the SEO from being checked. Eesh.
65
-			add_filter( 'wpseo_use_page_analysis', '__return_false' );
65
+			add_filter('wpseo_use_page_analysis', '__return_false');
66 66
 
67 67
 			// WordPress SEO Plugin
68
-			add_filter( 'option_wpseo_titles', array( $this, 'hide_wordpress_seo_metabox' ) );
68
+			add_filter('option_wpseo_titles', array($this, 'hide_wordpress_seo_metabox'));
69 69
 		}
70 70
 	}
71 71
 
@@ -79,11 +79,11 @@  discard block
 block discarded – undo
79 79
 	 * @param  array       $options WP SEO options array
80 80
 	 * @return array               Modified array if on post-new.php
81 81
 	 */
82
-	function hide_wordpress_seo_metabox( $options = array() ) {
82
+	function hide_wordpress_seo_metabox($options = array()) {
83 83
 		global $pagenow;
84 84
 
85 85
 		// New View page
86
-		if( $pagenow === 'post-new.php' ) {
86
+		if ($pagenow === 'post-new.php') {
87 87
 			$options['hideeditbox-gravityview'] = true;
88 88
 		}
89 89
 
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 	 * @param string $existing Existing priority. Default: `high`
100 100
 	 * @return string Returns 'low'
101 101
 	 */
102
-	function __return_low( $existing = 'high' ) {
102
+	function __return_low($existing = 'high') {
103 103
 		return 'low';
104 104
 	}
105 105
 }
Please login to merge, or discard this patch.
includes/plugin-and-theme-hooks/class-gravityview-theme-hooks-woothemes.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 
66 66
 		parent::add_hooks();
67 67
 
68
-		add_action( 'admin_menu', array( $this, 'remove_meta_box' ), 11 );
68
+		add_action('admin_menu', array($this, 'remove_meta_box'), 11);
69 69
 	}
70 70
 
71 71
 	/**
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
 	function remove_meta_box() {
76 76
 		global $pagenow;
77 77
 
78
-		$gv_page = gravityview_is_admin_page( '', 'single' );
78
+		$gv_page = gravityview_is_admin_page('', 'single');
79 79
 
80 80
 		// New View or Edit View page
81
-		if( $gv_page && $pagenow === 'post-new.php' ) {
82
-			remove_meta_box( 'woothemes-settings', 'gravityview', 'normal' );
81
+		if ($gv_page && $pagenow === 'post-new.php') {
82
+			remove_meta_box('woothemes-settings', 'gravityview', 'normal');
83 83
 		}
84 84
 	}
85 85
 
Please login to merge, or discard this patch.
includes/presets/business-data/class-gravityview-preset-business-data.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -21,15 +21,15 @@
 block discarded – undo
21 21
 		$settings = array(
22 22
 			'slug'          => 'table',
23 23
 			'type'          => 'preset',
24
-			'label'         => __( 'Business Data', 'gravityview' ),
25
-			'description'   => __( 'Display business information in a table.', 'gravityview' ),
26
-			'logo'          => plugins_url( 'includes/presets/business-data/logo-business-data.png', GRAVITYVIEW_FILE ),
24
+			'label'         => __('Business Data', 'gravityview'),
25
+			'description'   => __('Display business information in a table.', 'gravityview'),
26
+			'logo'          => plugins_url('includes/presets/business-data/logo-business-data.png', GRAVITYVIEW_FILE),
27 27
 			'preview'       => 'http://demo.gravityview.co/blog/view/business-table/',
28
-			'preset_form'   => GRAVITYVIEW_DIR . 'includes/presets/business-data/form-business-data.xml',
29
-			'preset_fields' => GRAVITYVIEW_DIR . 'includes/presets/business-data/fields-business-data.xml'
28
+			'preset_form'   => GRAVITYVIEW_DIR.'includes/presets/business-data/form-business-data.xml',
29
+			'preset_fields' => GRAVITYVIEW_DIR.'includes/presets/business-data/fields-business-data.xml'
30 30
 		);
31 31
 
32
-		parent::__construct( $id, $settings );
32
+		parent::__construct($id, $settings);
33 33
 	}
34 34
 }
35 35
 
Please login to merge, or discard this patch.
presets/business-listings/class-gravityview-preset-business-listings.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -21,15 +21,15 @@
 block discarded – undo
21 21
 		$settings = array(
22 22
 			'slug'          => 'list',
23 23
 			'type'          => 'preset',
24
-			'label'         => __( 'Business Listings', 'gravityview' ),
25
-			'description'   => __( 'Display business profiles.', 'gravityview' ),
26
-			'logo'          => plugins_url( 'includes/presets/business-listings/logo-business-listings.png', GRAVITYVIEW_FILE ),
24
+			'label'         => __('Business Listings', 'gravityview'),
25
+			'description'   => __('Display business profiles.', 'gravityview'),
26
+			'logo'          => plugins_url('includes/presets/business-listings/logo-business-listings.png', GRAVITYVIEW_FILE),
27 27
 			'preview'       => 'http://demo.gravityview.co/blog/view/business-listings/',
28
-			'preset_form'   => GRAVITYVIEW_DIR . 'includes/presets/business-listings/form-business-listings.xml',
29
-			'preset_fields' => GRAVITYVIEW_DIR . 'includes/presets/business-listings/fields-business-listings.xml'
28
+			'preset_form'   => GRAVITYVIEW_DIR.'includes/presets/business-listings/form-business-listings.xml',
29
+			'preset_fields' => GRAVITYVIEW_DIR.'includes/presets/business-listings/fields-business-listings.xml'
30 30
 		);
31 31
 
32
-		parent::__construct( $id, $settings );
32
+		parent::__construct($id, $settings);
33 33
 
34 34
 	}
35 35
 }
Please login to merge, or discard this patch.
includes/presets/default-edit/class-gravityview-default-template-edit.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -18,18 +18,18 @@  discard block
 block discarded – undo
18 18
  */
19 19
 class GravityView_Default_Template_Edit extends GravityView_Template {
20 20
 
21
-	function __construct( $id = 'default_table_edit', $settings = array(), $field_options = array(), $areas = array() ) {
21
+	function __construct($id = 'default_table_edit', $settings = array(), $field_options = array(), $areas = array()) {
22 22
 
23 23
 		$edit_settings = array(
24 24
 			'slug' => 'edit',
25 25
 			'type' => 'internal',
26
-			'label' =>  __( 'Edit Table', 'gravityview' ),
26
+			'label' =>  __('Edit Table', 'gravityview'),
27 27
 			'description' => __('Display items in a table view.', 'gravityview'),
28 28
 			'logo' => plugins_url('includes/presets/default-table/logo-default-table.png', GRAVITYVIEW_FILE),
29 29
 			'css_source' => plugins_url('templates/css/table-view.css', GRAVITYVIEW_FILE),
30 30
 		);
31 31
 
32
-		$settings = wp_parse_args( $settings, $edit_settings );
32
+		$settings = wp_parse_args($settings, $edit_settings);
33 33
 
34 34
 		/**
35 35
 		 * @see  GravityView_Admin_Views::get_default_field_options() for Generic Field Options
@@ -42,14 +42,14 @@  discard block
 block discarded – undo
42 42
 				'1-1' => array(
43 43
 					array(
44 44
 						'areaid' => 'edit-fields',
45
-						'title' => __('Visible Edit Fields', 'gravityview' )
45
+						'title' => __('Visible Edit Fields', 'gravityview')
46 46
 					)
47 47
 				)
48 48
 			)
49 49
 		);
50 50
 
51 51
 
52
-		parent::__construct( $id, $settings, $field_options, $areas );
52
+		parent::__construct($id, $settings, $field_options, $areas);
53 53
 
54 54
 	}
55 55
 
Please login to merge, or discard this patch.
includes/presets/default-list/class-gravityview-default-template-list.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -6,23 +6,23 @@  discard block
 block discarded – undo
6 6
  */
7 7
 class GravityView_Default_Template_List extends GravityView_Template {
8 8
 
9
-	function __construct( $id = 'default_list', $settings = array(), $field_options = array(), $areas = array() ) {
9
+	function __construct($id = 'default_list', $settings = array(), $field_options = array(), $areas = array()) {
10 10
 
11 11
 		$list_settings = array(
12 12
 			'slug'        => 'list',
13 13
 			'type'        => 'custom',
14
-			'label'       => __( 'List (default)', 'gravityview' ),
15
-			'description' => __( 'Display items in a listing view.', 'gravityview' ),
16
-			'logo'        => plugins_url( 'includes/presets/default-list/logo-default-list.png', GRAVITYVIEW_FILE ),
17
-			'css_source'  => plugins_url( 'templates/css/list-view.css', GRAVITYVIEW_FILE ),
14
+			'label'       => __('List (default)', 'gravityview'),
15
+			'description' => __('Display items in a listing view.', 'gravityview'),
16
+			'logo'        => plugins_url('includes/presets/default-list/logo-default-list.png', GRAVITYVIEW_FILE),
17
+			'css_source'  => plugins_url('templates/css/list-view.css', GRAVITYVIEW_FILE),
18 18
 		);
19 19
 
20
-		$settings = wp_parse_args( $settings, $list_settings );
20
+		$settings = wp_parse_args($settings, $list_settings);
21 21
 
22 22
 		$field_options = array(
23 23
 			'show_as_link' => array(
24 24
 				'type'    => 'checkbox',
25
-				'label'   => __( 'Link to single entry', 'gravityview' ),
25
+				'label'   => __('Link to single entry', 'gravityview'),
26 26
 				'value'   => false,
27 27
 				'context' => 'directory'
28 28
 			),
@@ -33,27 +33,27 @@  discard block
 block discarded – undo
33 33
 				'1-1' => array(
34 34
 					array(
35 35
 						'areaid'   => 'list-title',
36
-						'title'    => __( 'Listing Title', 'gravityview' ),
36
+						'title'    => __('Listing Title', 'gravityview'),
37 37
 						'subtitle' => ''
38 38
 					),
39 39
 					array(
40 40
 						'areaid'   => 'list-subtitle',
41
-						'title'    => __( 'Subheading', 'gravityview' ),
42
-						'subtitle' => __( 'Data placed here will be bold.', 'gravityview' ),
41
+						'title'    => __('Subheading', 'gravityview'),
42
+						'subtitle' => __('Data placed here will be bold.', 'gravityview'),
43 43
 					),
44 44
 				),
45 45
 				'1-3' => array(
46 46
 					array(
47 47
 						'areaid'   => 'list-image',
48
-						'title'    => __( 'Image', 'gravityview' ),
49
-						'subtitle' => __( 'Leave empty to remove.', 'gravityview' ),
48
+						'title'    => __('Image', 'gravityview'),
49
+						'subtitle' => __('Leave empty to remove.', 'gravityview'),
50 50
 					)
51 51
 				),
52 52
 				'2-3' => array(
53 53
 					array(
54 54
 						'areaid'   => 'list-description',
55
-						'title'    => __( 'Other Fields', 'gravityview' ),
56
-						'subtitle' => __( 'Below the subheading, a good place for description and other data.', 'gravityview' ),
55
+						'title'    => __('Other Fields', 'gravityview'),
56
+						'subtitle' => __('Below the subheading, a good place for description and other data.', 'gravityview'),
57 57
 					)
58 58
 				)
59 59
 			),
@@ -61,21 +61,21 @@  discard block
 block discarded – undo
61 61
 				'1-2' => array(
62 62
 					array(
63 63
 						'areaid'   => 'list-footer-left',
64
-						'title'    => __( 'Footer Left', 'gravityview' ),
64
+						'title'    => __('Footer Left', 'gravityview'),
65 65
 						'subtitle' => ''
66 66
 					)
67 67
 				),
68 68
 				'2-2' => array(
69 69
 					array(
70 70
 						'areaid'   => 'list-footer-right',
71
-						'title'    => __( 'Footer Right', 'gravityview' ),
71
+						'title'    => __('Footer Right', 'gravityview'),
72 72
 						'subtitle' => ''
73 73
 					)
74 74
 				)
75 75
 			)
76 76
 		);
77 77
 
78
-		parent::__construct( $id, $settings, $field_options, $areas );
78
+		parent::__construct($id, $settings, $field_options, $areas);
79 79
 
80 80
 	}
81 81
 }
Please login to merge, or discard this patch.