Completed
Branch master (3ac4b1)
by Zack
04:30
created
includes/fields/section.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 	function __construct() {
11 11
 		parent::__construct();
12 12
 
13
-		add_filter( 'gravityview_field_entry_value_section', array( $this, 'prevent_empty_field' ) );
13
+		add_filter('gravityview_field_entry_value_section', array($this, 'prevent_empty_field'));
14 14
 	}
15 15
 
16 16
 	/**
@@ -22,13 +22,13 @@  discard block
 block discarded – undo
22 22
 	 *
23 23
 	 * @return string If output was empty, return an empty HTML comment tag. Otherwise, return output.
24 24
 	 */
25
-	function prevent_empty_field( $output = '' ) {
26
-		return empty( $output ) ? '<!-- -->' : $output;
25
+	function prevent_empty_field($output = '') {
26
+		return empty($output) ? '<!-- -->' : $output;
27 27
 	}
28 28
 
29
-	function field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
29
+	function field_options($field_options, $template_id, $field_id, $context, $input_type) {
30 30
 
31
-		unset ( $field_options['search_filter'], $field_options['show_as_link'] );
31
+		unset ($field_options['search_filter'], $field_options['show_as_link']);
32 32
 
33 33
 		// Set the default CSS class to gv-section, which applies a border and top/bottom margin
34 34
 		$field_options['custom_class']['value'] = 'gv-section';
Please login to merge, or discard this patch.
includes/fields/source-url.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -7,26 +7,26 @@
 block discarded – undo
7 7
 
8 8
 	var $name = 'source_url';
9 9
 
10
-	function field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
10
+	function field_options($field_options, $template_id, $field_id, $context, $input_type) {
11 11
 
12 12
 		// Don't link to entry; doesn't make sense.
13
-		unset( $field_options['show_as_link'] );
13
+		unset($field_options['show_as_link']);
14 14
 
15
-		if( 'edit' === $context ) {
15
+		if ('edit' === $context) {
16 16
 			return $field_options;
17 17
 		}
18 18
 
19 19
 		$add_options = array();
20 20
 		$add_options['link_to_source'] = array(
21 21
 			'type' => 'checkbox',
22
-			'label' => __( 'Link to URL:', 'gravityview' ),
22
+			'label' => __('Link to URL:', 'gravityview'),
23 23
 			'desc' => __('Display as a link to the Source URL', 'gravityview'),
24 24
 			'value' => false,
25 25
 			'merge_tags' => false,
26 26
 		);
27 27
 		$add_options['source_link_text'] = array(
28 28
 			'type' => 'text',
29
-			'label' => __( 'Link Text:', 'gravityview' ),
29
+			'label' => __('Link Text:', 'gravityview'),
30 30
 			'desc' => __('Customize the link text. If empty, the link text will be the the URL.', 'gravityview'),
31 31
 			'value' => NULL,
32 32
 			'merge_tags' => true,
Please login to merge, or discard this patch.
includes/fields/textarea.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -7,9 +7,9 @@  discard block
 block discarded – undo
7 7
 
8 8
 	var $name = 'textarea';
9 9
 
10
-	function field_options( $field_options, $template_id = '', $field_id = '', $context = '', $input_type = '' ) {
10
+	function field_options($field_options, $template_id = '', $field_id = '', $context = '', $input_type = '') {
11 11
 
12
-		if( 'edit' === $context ) {
12
+		if ('edit' === $context) {
13 13
 			return $field_options;
14 14
 		}
15 15
 
@@ -17,16 +17,16 @@  discard block
 block discarded – undo
17 17
 			'type' => 'number',
18 18
 			'merge_tags' => false,
19 19
 			'value' => null,
20
-			'label' => __( 'Maximum words shown', 'gravityview' ),
21
-			'tooltip' => __( 'Enter the number of words to be shown. If specified it truncates the text. Leave it blank if you want to show the full text.', 'gravityview' ),
20
+			'label' => __('Maximum words shown', 'gravityview'),
21
+			'tooltip' => __('Enter the number of words to be shown. If specified it truncates the text. Leave it blank if you want to show the full text.', 'gravityview'),
22 22
 		);
23 23
 
24 24
         $field_options['make_clickable'] = array(
25 25
             'type' => 'checkbox',
26 26
             'merge_tags' => false,
27 27
             'value' => 0,
28
-            'label' => __( 'Convert text URLs to HTML links', 'gravityview' ),
29
-            'tooltip' => __( 'Converts URI, www, FTP, and email addresses in HTML links', 'gravityview' ),
28
+            'label' => __('Convert text URLs to HTML links', 'gravityview'),
29
+            'tooltip' => __('Converts URI, www, FTP, and email addresses in HTML links', 'gravityview'),
30 30
         );
31 31
 
32 32
 		return $field_options;
Please login to merge, or discard this patch.
includes/fields/time.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
 	public function __construct() {
39 39
 		parent::__construct();
40 40
 
41
-		add_filter( 'gravityview/sorting/time', array( $this, 'modify_sort_id' ), 10, 2 );
41
+		add_filter('gravityview/sorting/time', array($this, 'modify_sort_id'), 10, 2);
42 42
 
43
-		add_filter('gravityview_search_criteria', array( $this, '_maybe_filter_gravity_forms_query' ), 10, 4 );
43
+		add_filter('gravityview_search_criteria', array($this, '_maybe_filter_gravity_forms_query'), 10, 4);
44 44
 	}
45 45
 
46 46
 	/**
@@ -54,14 +54,14 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 * @return string Modified sort key imploded with $_sort_divider, like `5|:time:|12|:time:|h:i A`
56 56
 	 */
57
-	public function modify_sort_id( $sort_field_id, $form_id ) {
57
+	public function modify_sort_id($sort_field_id, $form_id) {
58 58
 
59
-		$time_format = self::_get_time_format_for_field( $sort_field_id, $form_id );
59
+		$time_format = self::_get_time_format_for_field($sort_field_id, $form_id);
60 60
 
61
-		$date_format = self::date_format( $time_format, $sort_field_id );
61
+		$date_format = self::date_format($time_format, $sort_field_id);
62 62
 
63 63
 		// Should look something like `5|:time:|12|:time:|h:i A`
64
-		$new_sort_field_id = implode( $this->_sort_divider, array( $sort_field_id, $time_format, $date_format ) );
64
+		$new_sort_field_id = implode($this->_sort_divider, array($sort_field_id, $time_format, $date_format));
65 65
 
66 66
 		return $new_sort_field_id;
67 67
 	}
@@ -78,25 +78,25 @@  discard block
 block discarded – undo
78 78
 	 *
79 79
 	 * @return $criteria If a match, the sorting will be updated to set `is_numeric` to true and make sure the field ID is an int
80 80
 	 */
81
-	public function _maybe_filter_gravity_forms_query( $criteria, $form_ids, $view_id ) {
81
+	public function _maybe_filter_gravity_forms_query($criteria, $form_ids, $view_id) {
82 82
 
83 83
 		// If the search is being sorted
84
-		if( ! empty( $criteria['sorting']['key'] ) ) {
84
+		if (!empty($criteria['sorting']['key'])) {
85 85
 
86
-			$pieces = explode( $this->_sort_divider, $criteria['sorting']['key'] );
86
+			$pieces = explode($this->_sort_divider, $criteria['sorting']['key']);
87 87
 
88 88
 			/**
89 89
 			 * And the sort key matches the key set in modify_sort_id(), then modify the Gravity Forms query SQL
90 90
 			 * @see modify_sort_id()
91 91
 			 */
92
-			if( ! empty( $pieces[1] ) ) {
92
+			if (!empty($pieces[1])) {
93 93
 
94 94
 				// Pass these to the _modify_query_sort_by_time_hack() method
95 95
 				$this->_time_format = $pieces[1];
96 96
 				$this->_date_format = $pieces[2];
97 97
 
98 98
 				// Remove fake input IDs (5.1 doesn't exist. Use 5)
99
-				$criteria['sorting']['key'] = floor( $pieces[0] );
99
+				$criteria['sorting']['key'] = floor($pieces[0]);
100 100
 
101 101
 				/**
102 102
 				 * Make sure sorting is numeric (# of seconds). IMPORTANT.
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 				$criteria['sorting']['is_numeric'] = true;
106 106
 
107 107
 				// Modify the Gravity Forms WP Query
108
-				add_filter('query', array( $this, '_modify_query_sort_by_time_hack' ) );
108
+				add_filter('query', array($this, '_modify_query_sort_by_time_hack'));
109 109
 			}
110 110
 		}
111 111
 
@@ -121,22 +121,22 @@  discard block
 block discarded – undo
121 121
 	 *
122 122
 	 * @return string Modified query, if the query matches the expected Gravity Forms SQL string used for sorting time fields. Otherwise, original query.
123 123
 	 */
124
-	function _modify_query_sort_by_time_hack( $query ) {
124
+	function _modify_query_sort_by_time_hack($query) {
125 125
 
126 126
 		/**
127 127
 		 * If this is a Gravity Forms entry selection sorting query, generated by sort_by_field_query(),
128 128
 		 * then we want to modify the query.
129 129
 		 * @see GFFormsModel::sort_by_field_query()
130 130
 		 */
131
-		if( strpos( $query, self::GF_SORTING_SQL ) > 0 ) {
131
+		if (strpos($query, self::GF_SORTING_SQL) > 0) {
132 132
 
133
-			if( $this->_time_format === '24' ) {
133
+			if ($this->_time_format === '24') {
134 134
 				$sql_str_to_date = "STR_TO_DATE( `value`, '%H:%i' )";
135 135
 			} else {
136 136
 				$sql_str_to_date = "STR_TO_DATE( `value`, '%h:%i %p' )";
137 137
 			}
138 138
 
139
-			switch ( $this->_date_format ) {
139
+			switch ($this->_date_format) {
140 140
 				case 'h':
141 141
 				case 'H':
142 142
 					$modification = "TIME_FORMAT( {$sql_str_to_date}, '%H' )";
@@ -154,40 +154,40 @@  discard block
 block discarded – undo
154 154
 			 * Convert the time (12:30 pm) to the MySQL `TIME_TO_SEC()` value for that time (45000)
155 155
 			 * This way, Gravity Forms is able to sort numerically.
156 156
 			 */
157
-			$replacement_query = str_replace( 'value', "{$modification} as value", self::GF_SORTING_SQL );
157
+			$replacement_query = str_replace('value', "{$modification} as value", self::GF_SORTING_SQL);
158 158
 
159 159
 			/**
160 160
 			 * Replace it in the main query
161 161
 			 */
162
-			$query = str_replace( self::GF_SORTING_SQL, $replacement_query, $query );
162
+			$query = str_replace(self::GF_SORTING_SQL, $replacement_query, $query);
163 163
 
164 164
 			/**
165 165
 			 * REMOVE the Gravity Forms WP Query modifications!
166 166
 			 */
167
-			remove_filter( 'query', array( $this, '_modify_query_sort_by_time_hack' ) );
167
+			remove_filter('query', array($this, '_modify_query_sort_by_time_hack'));
168 168
 		}
169 169
 
170 170
 		return $query;
171 171
 	}
172 172
 
173 173
 
174
-	function field_options( $field_options, $template_id = '', $field_id = '', $context = '', $input_type = '' ) {
174
+	function field_options($field_options, $template_id = '', $field_id = '', $context = '', $input_type = '') {
175 175
 
176 176
 		// Set variables
177
-		parent::field_options( $field_options, $template_id, $field_id, $context, $input_type );
177
+		parent::field_options($field_options, $template_id, $field_id, $context, $input_type);
178 178
 
179
-		if( 'edit' === $context ) {
179
+		if ('edit' === $context) {
180 180
 			return $field_options;
181 181
 		}
182 182
 
183 183
 		/**
184 184
 		 * Set default date format based on field ID and Form ID
185 185
 		 */
186
-		add_filter('gravityview_date_format', array( $this, '_filter_date_display_date_format' ) );
186
+		add_filter('gravityview_date_format', array($this, '_filter_date_display_date_format'));
187 187
 
188
-		$this->add_field_support('date_display', $field_options );
188
+		$this->add_field_support('date_display', $field_options);
189 189
 
190
-		remove_filter('gravityview_date_format', array( $this, '_filter_date_display_date_format' ) );
190
+		remove_filter('gravityview_date_format', array($this, '_filter_date_display_date_format'));
191 191
 
192 192
 		return $field_options;
193 193
 	}
@@ -202,9 +202,9 @@  discard block
 block discarded – undo
202 202
 	private function _get_time_format() {
203 203
 		global $post;
204 204
 
205
-		$current_form = isset( $_POST['form_id'] ) ? intval( $_POST['form_id'] ) : gravityview_get_form_id( $post->ID );
205
+		$current_form = isset($_POST['form_id']) ? intval($_POST['form_id']) : gravityview_get_form_id($post->ID);
206 206
 
207
-		return self::_get_time_format_for_field( $this->_field_id, $current_form );
207
+		return self::_get_time_format_for_field($this->_field_id, $current_form);
208 208
 	}
209 209
 
210 210
 	/**
@@ -216,17 +216,17 @@  discard block
 block discarded – undo
216 216
 	 * @param int $form_id ID for Gravity Forms form
217 217
 	 * @return string Either "12" or "24". "12" is default.
218 218
 	 */
219
-	static public function _get_time_format_for_field( $field_id, $form_id = 0 ) {
219
+	static public function _get_time_format_for_field($field_id, $form_id = 0) {
220 220
 
221 221
 		// GF defaults to 12, so should we.
222 222
 		$time_format = '12';
223 223
 
224
-		if( $form_id ) {
225
-			$form = GFAPI::get_form( $form_id );
224
+		if ($form_id) {
225
+			$form = GFAPI::get_form($form_id);
226 226
 
227
-			if ( $form ) {
228
-				$field = GFFormsModel::get_field( $form, floor( $field_id ) );
229
-				if ( $field && $field instanceof GF_Field_Time ) {
227
+			if ($form) {
228
+				$field = GFFormsModel::get_field($form, floor($field_id));
229
+				if ($field && $field instanceof GF_Field_Time) {
230 230
 					$field->sanitize_settings(); // Make sure time is set
231 231
 					$time_format = $field->timeFormat;
232 232
 				}
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 		$time_format = $this->_get_time_format();
249 249
 		$field_id = $this->_field_id;
250 250
 
251
-		return self::date_format( $time_format, $field_id );
251
+		return self::date_format($time_format, $field_id);
252 252
 	}
253 253
 
254 254
 	/**
@@ -261,19 +261,19 @@  discard block
 block discarded – undo
261 261
 	 *
262 262
 	 * @return string PHP date format for the time
263 263
 	 */
264
-	static public function date_format( $time_format = '12', $field_id = 0 ) {
264
+	static public function date_format($time_format = '12', $field_id = 0) {
265 265
 
266
-		$field_id_array = explode( '.', $field_id );
266
+		$field_id_array = explode('.', $field_id);
267 267
 
268
-		$field_input_id = isset( $field_id_array[1] ) ? intval( $field_id_array[1] ) : 0;
268
+		$field_input_id = isset($field_id_array[1]) ? intval($field_id_array[1]) : 0;
269 269
 
270 270
 		$default = 'h:i A';
271 271
 
272 272
 		// This doesn't take into account 24-hour
273
-		switch( $field_input_id ) {
273
+		switch ($field_input_id) {
274 274
 			// Hours
275 275
 			case 1:
276
-				return ( $time_format === '12' ) ? 'h' : 'H';
276
+				return ($time_format === '12') ? 'h' : 'H';
277 277
 				break;
278 278
 			// Minutes
279 279
 			case 2:
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 				break;
286 286
 			// Full time field
287 287
 			case 0:
288
-				return ( $time_format === '12' ) ? $default : 'H:i';
288
+				return ($time_format === '12') ? $default : 'H:i';
289 289
 				break;
290 290
 		}
291 291
 
Please login to merge, or discard this patch.
includes/fields/website.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@  discard block
 block discarded – undo
7 7
 
8 8
 	var $name = 'website';
9 9
 
10
-	function field_options( $field_options, $template_id = '', $field_id = '', $context = '', $input_type = '' ) {
10
+	function field_options($field_options, $template_id = '', $field_id = '', $context = '', $input_type = '') {
11 11
 
12 12
 		// It makes no sense to use this as the link.
13
-		unset( $field_options['show_as_link'] );
13
+		unset($field_options['show_as_link']);
14 14
 
15
-		if( 'edit' === $context ) {
15
+		if ('edit' === $context) {
16 16
 			return $field_options;
17 17
 		}
18 18
 
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
 		 */
22 22
 		$field_options['anchor_text'] = array(
23 23
 			'type' => 'text',
24
-			'label' => __( 'Link Text:', 'gravityview' ),
25
-			'desc' => __( 'Define custom link text. Leave blank to display the URL', 'gravityview' ),
24
+			'label' => __('Link Text:', 'gravityview'),
25
+			'desc' => __('Define custom link text. Leave blank to display the URL', 'gravityview'),
26 26
 			'value' => '',
27 27
 			'merge_tags' => 'force',
28 28
 		);
@@ -30,15 +30,15 @@  discard block
 block discarded – undo
30 30
 		$field_options['truncatelink'] = array(
31 31
 			'type' => 'checkbox',
32 32
 			'value' => true,
33
-			'label' => __( 'Shorten Link Display', 'gravityview' ),
34
-			'tooltip' => __( 'Only show the domain for a URL instead of the whole link.', 'gravityview' ),
35
-			'desc' => __( 'Don&rsquo;t show the full URL, only show the domain.', 'gravityview' )
33
+			'label' => __('Shorten Link Display', 'gravityview'),
34
+			'tooltip' => __('Only show the domain for a URL instead of the whole link.', 'gravityview'),
35
+			'desc' => __('Don&rsquo;t show the full URL, only show the domain.', 'gravityview')
36 36
 		);
37 37
 
38 38
 		$field_options['open_same_window'] = array(
39 39
 			'type' => 'checkbox',
40 40
 			'value' => false,
41
-			'label' => __( 'Open link in the same window?', 'gravityview' ),
41
+			'label' => __('Open link in the same window?', 'gravityview'),
42 42
 		);
43 43
 
44 44
 		return $field_options;
Please login to merge, or discard this patch.
includes/helper-functions.php 1 patch
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
  *
16 16
  * @return bool true: $mixed is *not* an empty string; false: $mixed *is* an empty string
17 17
  */
18
-function gravityview_is_not_empty_string( $mixed = '' ) {
19
-	return ( $mixed !== '' );
18
+function gravityview_is_not_empty_string($mixed = '') {
19
+	return ($mixed !== '');
20 20
 }
21 21
 
22 22
 /**
@@ -32,22 +32,22 @@  discard block
 block discarded – undo
32 32
  *
33 33
  * @return array URL args, if exists. Empty array if not.
34 34
  */
35
-function gravityview_get_permalink_query_args( $id = 0 ) {
35
+function gravityview_get_permalink_query_args($id = 0) {
36 36
 
37
-	$parsed_permalink = parse_url( get_permalink( $id ) );
37
+	$parsed_permalink = parse_url(get_permalink($id));
38 38
 
39
-	$permalink_args =  isset( $parsed_permalink['query'] ) ? $parsed_permalink['query'] : false;
39
+	$permalink_args = isset($parsed_permalink['query']) ? $parsed_permalink['query'] : false;
40 40
 
41
-	if( empty( $permalink_args ) ) {
41
+	if (empty($permalink_args)) {
42 42
 		return array();
43 43
 	}
44 44
 
45
-	parse_str( $permalink_args, $args );
45
+	parse_str($permalink_args, $args);
46 46
 
47 47
 	return $args;
48 48
 }
49 49
 
50
-if( ! function_exists( 'gravityview_sanitize_html_class' ) ) {
50
+if (!function_exists('gravityview_sanitize_html_class')) {
51 51
 
52 52
 	/**
53 53
 	 * sanitize_html_class doesn't handle spaces (multiple classes). We remedy that.
@@ -58,20 +58,20 @@  discard block
 block discarded – undo
58 58
 	 *
59 59
 	 * @return string            Sanitized CSS string
60 60
 	 */
61
-	function gravityview_sanitize_html_class( $classes ) {
61
+	function gravityview_sanitize_html_class($classes) {
62 62
 
63
-		if ( is_string( $classes ) ) {
64
-			$classes = explode( ' ', $classes );
63
+		if (is_string($classes)) {
64
+			$classes = explode(' ', $classes);
65 65
 		}
66 66
 
67 67
 		// If someone passes something not string or array, we get outta here.
68
-		if ( ! is_array( $classes ) ) {
68
+		if (!is_array($classes)) {
69 69
 			return $classes;
70 70
 		}
71 71
 
72
-		$classes = array_map( 'sanitize_html_class', $classes );
72
+		$classes = array_map('sanitize_html_class', $classes);
73 73
 
74
-		return implode( ' ', $classes );
74
+		return implode(' ', $classes);
75 75
 	}
76 76
 }
77 77
 
@@ -89,9 +89,9 @@  discard block
 block discarded – undo
89 89
  *
90 90
  * @return string Stripped string!
91 91
  */
92
-function gravityview_strip_whitespace( $string ) {
93
-	$string = normalize_whitespace( $string );
94
-	return preg_replace('/[\r\n\t ]+/', ' ', $string );
92
+function gravityview_strip_whitespace($string) {
93
+	$string = normalize_whitespace($string);
94
+	return preg_replace('/[\r\n\t ]+/', ' ', $string);
95 95
 }
96 96
 
97 97
 /**
@@ -104,13 +104,13 @@  discard block
 block discarded – undo
104 104
  * @param mixed $object Pass pseudo-global to the included file
105 105
  * @return string Included file contents
106 106
  */
107
-function gravityview_ob_include( $file_path, $object = NULL ) {
108
-	if( ! file_exists( $file_path ) ) {
109
-		do_action( 'gravityview_log_error', __FUNCTION__ . ': File path does not exist. ', $file_path );
107
+function gravityview_ob_include($file_path, $object = NULL) {
108
+	if (!file_exists($file_path)) {
109
+		do_action('gravityview_log_error', __FUNCTION__.': File path does not exist. ', $file_path);
110 110
 		return '';
111 111
 	}
112 112
 	ob_start();
113
-	include( $file_path );
113
+	include($file_path);
114 114
 	return ob_get_clean();
115 115
 }
116 116
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
  */
122 122
 function gravityview_get_floaty() {
123 123
 
124
-	if( function_exists('is_rtl') && is_rtl() ) {
124
+	if (function_exists('is_rtl') && is_rtl()) {
125 125
 		$style = 'margin:10px 10px 10px 0;';
126 126
 		$class = 'alignright';
127 127
 	} else {
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 		$class = 'alignleft';
130 130
 	}
131 131
 
132
-	return '<img src="'.plugins_url( 'assets/images/astronaut-200x263.png', GRAVITYVIEW_FILE ).'" class="'.$class.'" height="87" width="66" alt="The GravityView Astronaut Says:" style="'.$style.'" />';
132
+	return '<img src="'.plugins_url('assets/images/astronaut-200x263.png', GRAVITYVIEW_FILE).'" class="'.$class.'" height="87" width="66" alt="The GravityView Astronaut Says:" style="'.$style.'" />';
133 133
 }
134 134
 
135 135
 /**
@@ -149,21 +149,21 @@  discard block
 block discarded – undo
149 149
  *
150 150
  * @return string Converted number in string format.
151 151
  */
152
-function gravityview_number_format( $number, $decimals = '' ) {
152
+function gravityview_number_format($number, $decimals = '') {
153 153
 	global $wp_locale;
154 154
 
155
-	if( '' === $decimals ) {
155
+	if ('' === $decimals) {
156 156
 
157
-		$decimal_point = isset( $wp_locale ) ? $wp_locale->number_format['decimal_point'] : '.';
157
+		$decimal_point = isset($wp_locale) ? $wp_locale->number_format['decimal_point'] : '.';
158 158
 
159 159
 		/**
160 160
 		 * Calculate the position of the decimal point in the number
161 161
 		 * @see http://stackoverflow.com/a/2430144/480856
162 162
 		 */
163
-		$decimals = strlen( substr( strrchr( $number, $decimal_point ), 1 ) );
163
+		$decimals = strlen(substr(strrchr($number, $decimal_point), 1));
164 164
 	}
165 165
 
166
-	$number = number_format_i18n( $number, (int)$decimals );
166
+	$number = number_format_i18n($number, (int)$decimals);
167 167
 
168 168
 	return $number;
169 169
 }
@@ -177,13 +177,13 @@  discard block
 block discarded – undo
177 177
  * @param  string $value Existing URL
178 178
  * @return string        If parse_url doesn't find a 'host', returns original value. Otherwise, returns formatted link.
179 179
  */
180
-function gravityview_format_link( $value = null ) {
180
+function gravityview_format_link($value = null) {
181 181
 
182 182
 
183
-	$parts = parse_url( $value );
183
+	$parts = parse_url($value);
184 184
 
185 185
 	// No domain? Strange...show the original text.
186
-	if( empty( $parts['host'] ) ) {
186
+	if (empty($parts['host'])) {
187 187
 		return $value;
188 188
 	}
189 189
 
@@ -196,9 +196,9 @@  discard block
 block discarded – undo
196 196
 	 * @param boolean $enable Whether to strip the scheme. Return false to show scheme. (default: true)\n
197 197
 	 * If true: `http://example.com => example.com`
198 198
 	 */
199
-	if( false === apply_filters('gravityview_anchor_text_striphttp', true) ) {
199
+	if (false === apply_filters('gravityview_anchor_text_striphttp', true)) {
200 200
 
201
-		if( isset( $parts['scheme'] ) ) {
201
+		if (isset($parts['scheme'])) {
202 202
 			$return .= $parts['scheme'];
203 203
 		}
204 204
 
@@ -213,10 +213,10 @@  discard block
 block discarded – undo
213 213
 	 * @param boolean $enable Whether to strip www. Return false to show www. (default: true)\n
214 214
 	 * If true: `www.example.com => example.com`
215 215
 	 */
216
-	$strip_www = apply_filters('gravityview_anchor_text_stripwww', true );
216
+	$strip_www = apply_filters('gravityview_anchor_text_stripwww', true);
217 217
 
218
-	if( $strip_www ) {
219
-		$domain = str_replace('www.', '', $domain );
218
+	if ($strip_www) {
219
+		$domain = str_replace('www.', '', $domain);
220 220
 	}
221 221
 
222 222
 	/**
@@ -228,9 +228,9 @@  discard block
 block discarded – undo
228 228
 	 */
229 229
 	$strip_subdomains = apply_filters('gravityview_anchor_text_nosubdomain', true);
230 230
 
231
-	if( $strip_subdomains ) {
231
+	if ($strip_subdomains) {
232 232
 
233
-		$domain = _gravityview_strip_subdomain( $parts['host'] );
233
+		$domain = _gravityview_strip_subdomain($parts['host']);
234 234
 
235 235
 	}
236 236
 
@@ -246,9 +246,9 @@  discard block
 block discarded – undo
246 246
 	 */
247 247
 	$root_only = apply_filters('gravityview_anchor_text_rootonly', true);
248 248
 
249
-	if( empty( $root_only ) ) {
249
+	if (empty($root_only)) {
250 250
 
251
-		if( isset( $parts['path'] ) ) {
251
+		if (isset($parts['path'])) {
252 252
 			$return .= $parts['path'];
253 253
 		}
254 254
 	}
@@ -259,11 +259,11 @@  discard block
 block discarded – undo
259 259
 	 * @param boolean $enable Whether to enable "root only". Return false to show full path. (default: true)\n
260 260
 	 * If true: `http://example.com/?query=example => example.com`
261 261
 	 */
262
-	$strip_query_string = apply_filters('gravityview_anchor_text_noquerystring', true );
262
+	$strip_query_string = apply_filters('gravityview_anchor_text_noquerystring', true);
263 263
 
264
-	if( empty( $strip_query_string ) ) {
264
+	if (empty($strip_query_string)) {
265 265
 
266
-		if( isset( $parts['query'] ) ) {
266
+		if (isset($parts['query'])) {
267 267
 			$return .= '?'.$parts['query'];
268 268
 		}
269 269
 
@@ -279,9 +279,9 @@  discard block
 block discarded – undo
279 279
  * @param  string $domain Domain to check if it's a TLD or subdomain
280 280
  * @return string         Extracted domain if it has a subdomain
281 281
  */
282
-function _gravityview_strip_subdomain( $string_maybe_has_subdomain ) {
282
+function _gravityview_strip_subdomain($string_maybe_has_subdomain) {
283 283
 
284
-	if( preg_match("/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.(?:com\.|co\.|net\.|org\.|firm\.|me\.|school\.|law\.|gov\.|mod\.|msk\.|irkutsks\.|sa\.|act\.|police\.|plc\.|ac\.|tm\.|asso\.|biz\.|pro\.|cg\.|telememo\.)?[a-z\.]{2,6})$/i", $string_maybe_has_subdomain, $matches ) ) {
284
+	if (preg_match("/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.(?:com\.|co\.|net\.|org\.|firm\.|me\.|school\.|law\.|gov\.|mod\.|msk\.|irkutsks\.|sa\.|act\.|police\.|plc\.|ac\.|tm\.|asso\.|biz\.|pro\.|cg\.|telememo\.)?[a-z\.]{2,6})$/i", $string_maybe_has_subdomain, $matches)) {
285 285
 		return $matches['domain'];
286 286
 	} else {
287 287
 		return $string_maybe_has_subdomain;
@@ -301,37 +301,37 @@  discard block
 block discarded – undo
301 301
  * @param boolean $allow_string_booleans Whether to check if 'yes', 'true' => `true` and 'no', 'false' => `false`
302 302
  * @return boolean        True: empty; false: not empty
303 303
  */
304
-function gv_empty( $value, $zero_is_empty = true, $allow_string_booleans = true ) {
304
+function gv_empty($value, $zero_is_empty = true, $allow_string_booleans = true) {
305 305
 
306
-	if(
307
-		! isset( $value ) // If it's not set, it's empty!
306
+	if (
307
+		!isset($value) // If it's not set, it's empty!
308 308
 		|| false === $value
309 309
 		|| null === $value
310 310
 	    || '' === $value // Empty string
311 311
 		|| array() === $value // Empty array
312
-		|| ( is_object( $value ) && ! get_object_vars( $value ) ) // Empty object
312
+		|| (is_object($value) && !get_object_vars($value)) // Empty object
313 313
 	) {
314 314
 		return true;
315 315
 	}
316 316
 
317
-	if( is_string( $value ) && $allow_string_booleans ) {
317
+	if (is_string($value) && $allow_string_booleans) {
318 318
 
319
-		$value = trim( $value );
320
-		$value = strtolower( $value );
319
+		$value = trim($value);
320
+		$value = strtolower($value);
321 321
 
322
-		if ( in_array( $value, array( 'yes', 'true' ), true ) ) {
322
+		if (in_array($value, array('yes', 'true'), true)) {
323 323
 			$value = true;
324
-		} else if( in_array( $value, array( 'no', 'false' ), true ) ) {
324
+		} else if (in_array($value, array('no', 'false'), true)) {
325 325
 			$value = false;
326 326
 		}
327 327
 	}
328 328
 
329 329
 	// If zero isn't empty, then if $value is a number and it's empty, it's zero. Thus, return false.
330
-	if( ! $zero_is_empty && is_numeric( $value ) && empty( $value ) ) {
330
+	if (!$zero_is_empty && is_numeric($value) && empty($value)) {
331 331
 		return false;
332 332
 	}
333 333
 
334
-	return empty( $value );
334
+	return empty($value);
335 335
 }
336 336
 
337 337
 /**
@@ -344,15 +344,15 @@  discard block
 block discarded – undo
344 344
  *
345 345
  * @return bool True: it's a valid datetime, formatted as expected. False: it's not a date formatted as expected.
346 346
  */
347
-function gravityview_is_valid_datetime( $datetime, $expected_format = 'Y-m-d' ) {
347
+function gravityview_is_valid_datetime($datetime, $expected_format = 'Y-m-d') {
348 348
 
349 349
 	/**
350 350
 	 * @var bool|DateTime False if not a valid date, (like a relative date). DateTime if a date was created.
351 351
 	 */
352
-	$formatted_date = DateTime::createFromFormat( $expected_format, $datetime );
352
+	$formatted_date = DateTime::createFromFormat($expected_format, $datetime);
353 353
 
354 354
 	/**
355 355
 	 * @see http://stackoverflow.com/a/19271434/480856
356 356
 	 */
357
-	return ( $formatted_date && $formatted_date->format( $expected_format ) === $datetime );
357
+	return ($formatted_date && $formatted_date->format($expected_format) === $datetime);
358 358
 }
359 359
\ No newline at end of file
Please login to merge, or discard this patch.
includes/lib/EDD_SL_Plugin_Updater.php 1 patch
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 //set_site_transient( 'update_plugins', null );
5 5
 
6 6
 // Exit if accessed directly
7
-if ( ! defined( 'ABSPATH' ) ) exit;
7
+if (!defined('ABSPATH')) exit;
8 8
 
9 9
 /**
10 10
  * Allows plugins to use their own update API.
@@ -29,16 +29,16 @@  discard block
 block discarded – undo
29 29
 	 * @param string  $_plugin_file Path to the plugin file.
30 30
 	 * @param array   $_api_data    Optional data to send with API calls.
31 31
 	 */
32
-	function __construct( $_api_url, $_plugin_file, $_api_data = null ) {
33
-		$this->api_url  = trailingslashit( $_api_url );
32
+	function __construct($_api_url, $_plugin_file, $_api_data = null) {
33
+		$this->api_url  = trailingslashit($_api_url);
34 34
 		$this->api_data = $_api_data;
35
-		$this->name     = plugin_basename( $_plugin_file );
36
-		$this->slug     = basename( $_plugin_file, '.php' );
35
+		$this->name     = plugin_basename($_plugin_file);
36
+		$this->slug     = basename($_plugin_file, '.php');
37 37
 		$this->version  = $_api_data['version'];
38 38
 
39 39
 		// Set up hooks.
40 40
 		$this->init();
41
-		add_action( 'admin_init', array( $this, 'show_changelog' ) );
41
+		add_action('admin_init', array($this, 'show_changelog'));
42 42
 
43 43
 	}
44 44
 
@@ -50,11 +50,11 @@  discard block
 block discarded – undo
50 50
 	 * @return void
51 51
 	 */
52 52
 	public function init() {
53
-		add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
54
-		add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
53
+		add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'));
54
+		add_filter('plugins_api', array($this, 'plugins_api_filter'), 10, 3);
55 55
 
56
-		remove_action( 'after_plugin_row_' . $this->name, 'wp_plugin_update_row', 10, 2 );
57
-		add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 );
56
+		remove_action('after_plugin_row_'.$this->name, 'wp_plugin_update_row', 10, 2);
57
+		add_action('after_plugin_row_'.$this->name, array($this, 'show_update_notification'), 10, 2);
58 58
 	}
59 59
 
60 60
 	/**
@@ -70,32 +70,32 @@  discard block
 block discarded – undo
70 70
 	 * @param array   $_transient_data Update array build by WordPress.
71 71
 	 * @return array Modified update array with custom plugin data.
72 72
 	 */
73
-	function check_update( $_transient_data ) {
73
+	function check_update($_transient_data) {
74 74
 
75 75
 		global $pagenow;
76 76
 
77
-		if( ! is_object( $_transient_data ) ) {
77
+		if (!is_object($_transient_data)) {
78 78
 			$_transient_data = new stdClass;
79 79
 		}
80 80
 
81
-		if( 'plugins.php' == $pagenow && is_multisite() ) {
81
+		if ('plugins.php' == $pagenow && is_multisite()) {
82 82
 			return $_transient_data;
83 83
 		}
84 84
 
85
-		if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) {
85
+		if (empty($_transient_data->response) || empty($_transient_data->response[$this->name])) {
86 86
 
87
-			$version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
87
+			$version_info = $this->api_request('plugin_latest_version', array('slug' => $this->slug));
88 88
 
89
-			if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
89
+			if (false !== $version_info && is_object($version_info) && isset($version_info->new_version)) {
90 90
 
91
-				if( version_compare( $this->version, $version_info->new_version, '<' ) ) {
91
+				if (version_compare($this->version, $version_info->new_version, '<')) {
92 92
 
93
-					$_transient_data->response[ $this->name ] = $version_info;
93
+					$_transient_data->response[$this->name] = $version_info;
94 94
 
95 95
 				}
96 96
 
97 97
 				$_transient_data->last_checked = time();
98
-				$_transient_data->checked[ $this->name ] = $this->version;
98
+				$_transient_data->checked[$this->name] = $this->version;
99 99
 
100 100
 			}
101 101
 
@@ -110,86 +110,86 @@  discard block
 block discarded – undo
110 110
 	 * @param string  $file
111 111
 	 * @param array   $plugin
112 112
 	 */
113
-	public function show_update_notification( $file, $plugin ) {
113
+	public function show_update_notification($file, $plugin) {
114 114
 
115
-		if( ! current_user_can( 'update_plugins' ) ) {
115
+		if (!current_user_can('update_plugins')) {
116 116
 			return;
117 117
 		}
118 118
 
119
-		if( ! is_multisite() ) {
119
+		if (!is_multisite()) {
120 120
 			return;
121 121
 		}
122 122
 
123
-		if ( $this->name != $file ) {
123
+		if ($this->name != $file) {
124 124
 			return;
125 125
 		}
126 126
 
127 127
 		// Remove our filter on the site transient
128
-		remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );
128
+		remove_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'), 10);
129 129
 
130
-		$update_cache = get_site_transient( 'update_plugins' );
130
+		$update_cache = get_site_transient('update_plugins');
131 131
 
132
-		$update_cache = is_object( $update_cache ) ? $update_cache : new stdClass();
132
+		$update_cache = is_object($update_cache) ? $update_cache : new stdClass();
133 133
 
134
-		if ( empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {
134
+		if (empty($update_cache->response) || empty($update_cache->response[$this->name])) {
135 135
 
136
-			$cache_key    = md5( 'edd_plugin_' .sanitize_key( $this->name ) . '_version_info' );
137
-			$version_info = get_transient( $cache_key );
136
+			$cache_key    = md5('edd_plugin_'.sanitize_key($this->name).'_version_info');
137
+			$version_info = get_transient($cache_key);
138 138
 
139
-			if( false === $version_info ) {
139
+			if (false === $version_info) {
140 140
 
141
-				$version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
141
+				$version_info = $this->api_request('plugin_latest_version', array('slug' => $this->slug));
142 142
 
143
-				set_transient( $cache_key, $version_info, 3600 );
143
+				set_transient($cache_key, $version_info, 3600);
144 144
 			}
145 145
 
146 146
 
147
-			if( ! is_object( $version_info ) ) {
147
+			if (!is_object($version_info)) {
148 148
 				return;
149 149
 			}
150 150
 
151
-			if( version_compare( $this->version, $version_info->new_version, '<' ) ) {
151
+			if (version_compare($this->version, $version_info->new_version, '<')) {
152 152
 
153
-				$update_cache->response[ $this->name ] = $version_info;
153
+				$update_cache->response[$this->name] = $version_info;
154 154
 
155 155
 			}
156 156
 
157 157
 			$update_cache->last_checked = time();
158
-			$update_cache->checked[ $this->name ] = $this->version;
158
+			$update_cache->checked[$this->name] = $this->version;
159 159
 
160
-			set_site_transient( 'update_plugins', $update_cache );
160
+			set_site_transient('update_plugins', $update_cache);
161 161
 
162 162
 		} else {
163 163
 
164
-			$version_info = $update_cache->response[ $this->name ];
164
+			$version_info = $update_cache->response[$this->name];
165 165
 
166 166
 		}
167 167
 
168 168
 		// Restore our filter
169
-		add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
169
+		add_filter('pre_set_site_transient_update_plugins', array($this, 'check_update'));
170 170
 
171
-		if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
171
+		if (!empty($update_cache->response[$this->name]) && version_compare($this->version, $version_info->new_version, '<')) {
172 172
 
173 173
 			// build a plugin list row, with update notification
174
-			$wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
175
-			echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">';
174
+			$wp_list_table = _get_list_table('WP_Plugins_List_Table');
175
+			echo '<tr class="plugin-update-tr"><td colspan="'.$wp_list_table->get_column_count().'" class="plugin-update colspanchange"><div class="update-message">';
176 176
 
177
-			$changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' );
177
+			$changelog_link = self_admin_url('index.php?edd_sl_action=view_plugin_changelog&plugin='.$this->name.'&slug='.$this->slug.'&TB_iframe=true&width=772&height=911');
178 178
 
179
-			if ( empty( $version_info->download_link ) ) {
179
+			if (empty($version_info->download_link)) {
180 180
 				printf(
181
-					__( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'gravityview' ),
182
-					esc_html( $version_info->name ),
183
-					esc_url( $changelog_link ),
184
-					esc_html( $version_info->new_version )
181
+					__('There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'gravityview'),
182
+					esc_html($version_info->name),
183
+					esc_url($changelog_link),
184
+					esc_html($version_info->new_version)
185 185
 				);
186 186
 			} else {
187 187
 				printf(
188
-					__( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'gravityview' ),
189
-					esc_html( $version_info->name ),
190
-					esc_url( $changelog_link ),
191
-					esc_html( $version_info->new_version ),
192
-					esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) )
188
+					__('There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'gravityview'),
189
+					esc_html($version_info->name),
190
+					esc_url($changelog_link),
191
+					esc_html($version_info->new_version),
192
+					esc_url(wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=').$this->name, 'upgrade-plugin_'.$this->name))
193 193
 				);
194 194
 			}
195 195
 
@@ -208,16 +208,16 @@  discard block
 block discarded – undo
208 208
 	 * @param object  $_args
209 209
 	 * @return object $_data
210 210
 	 */
211
-	function plugins_api_filter( $_data, $_action = '', $_args = null ) {
211
+	function plugins_api_filter($_data, $_action = '', $_args = null) {
212 212
 
213 213
 
214
-		if ( $_action != 'plugin_information' ) {
214
+		if ($_action != 'plugin_information') {
215 215
 
216 216
 			return $_data;
217 217
 
218 218
 		}
219 219
 
220
-		if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) {
220
+		if (!isset($_args->slug) || ($_args->slug != $this->slug)) {
221 221
 
222 222
 			return $_data;
223 223
 
@@ -232,9 +232,9 @@  discard block
 block discarded – undo
232 232
 			)
233 233
 		);
234 234
 
235
-		$api_response = $this->api_request( 'plugin_information', $to_send );
235
+		$api_response = $this->api_request('plugin_information', $to_send);
236 236
 
237
-		if ( false !== $api_response ) {
237
+		if (false !== $api_response) {
238 238
 			$_data = $api_response;
239 239
 		}
240 240
 
@@ -249,9 +249,9 @@  discard block
 block discarded – undo
249 249
 	 * @param string  $url
250 250
 	 * @return object $array
251 251
 	 */
252
-	function http_request_args( $args, $url ) {
252
+	function http_request_args($args, $url) {
253 253
 		// If it is an https request and we are performing a package download, disable ssl verification
254
-		if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
254
+		if (strpos($url, 'https://') !== false && strpos($url, 'edd_action=package_download')) {
255 255
 			$args['sslverify'] = false;
256 256
 		}
257 257
 		return $args;
@@ -268,43 +268,43 @@  discard block
 block discarded – undo
268 268
 	 * @param array   $_data   Parameters for the API action.
269 269
 	 * @return false|object
270 270
 	 */
271
-	private function api_request( $_action, $_data ) {
271
+	private function api_request($_action, $_data) {
272 272
 
273 273
 		global $wp_version;
274 274
 
275
-		$data = array_merge( $this->api_data, $_data );
275
+		$data = array_merge($this->api_data, $_data);
276 276
 
277
-		if ( $data['slug'] != $this->slug ) {
277
+		if ($data['slug'] != $this->slug) {
278 278
 			return;
279 279
 		}
280 280
 
281
-		if( $this->api_url == home_url() ) {
281
+		if ($this->api_url == home_url()) {
282 282
 			return false; // Don't allow a plugin to ping itself
283 283
 		}
284 284
 
285 285
 		$api_params = array(
286 286
 			'edd_action' => 'get_version',
287
-			'license'    => ! empty( $data['license'] ) ? $data['license'] : '',
288
-			'item_name'  => isset( $data['item_name'] ) ? $data['item_name'] : false,
289
-			'item_id'    => isset( $data['item_id'] ) ? $data['item_id'] : false,
287
+			'license'    => !empty($data['license']) ? $data['license'] : '',
288
+			'item_name'  => isset($data['item_name']) ? $data['item_name'] : false,
289
+			'item_id'    => isset($data['item_id']) ? $data['item_id'] : false,
290 290
 			'slug'       => $data['slug'],
291 291
 			'author'     => $data['author'],
292 292
 			'url'        => home_url()
293 293
 		);
294 294
 
295
-		$request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
295
+		$request = wp_remote_post($this->api_url, array('timeout' => 15, 'sslverify' => false, 'body' => $api_params));
296 296
 
297
-		if ( ! is_wp_error( $request ) ) {
298
-			$request = json_decode( wp_remote_retrieve_body( $request ) );
297
+		if (!is_wp_error($request)) {
298
+			$request = json_decode(wp_remote_retrieve_body($request));
299 299
 		}
300 300
 
301
-		if ( $request ) {
302
-			if( isset( $request->sections ) ) {
303
-				$request->sections = maybe_unserialize( $request->sections );
301
+		if ($request) {
302
+			if (isset($request->sections)) {
303
+				$request->sections = maybe_unserialize($request->sections);
304 304
 			}
305 305
 
306
-			if( isset( $request->banners ) ) {
307
-				$request->banners = (array)maybe_unserialize( $request->banners );
306
+			if (isset($request->banners)) {
307
+				$request->banners = (array)maybe_unserialize($request->banners);
308 308
 			}
309 309
 		} else {
310 310
 			$request = false;
@@ -316,26 +316,26 @@  discard block
 block discarded – undo
316 316
 	public function show_changelog() {
317 317
 
318 318
 
319
-		if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
319
+		if (empty($_REQUEST['edd_sl_action']) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action']) {
320 320
 			return;
321 321
 		}
322 322
 
323
-		if( empty( $_REQUEST['plugin'] ) ) {
323
+		if (empty($_REQUEST['plugin'])) {
324 324
 			return;
325 325
 		}
326 326
 
327
-		if( empty( $_REQUEST['slug'] ) ) {
327
+		if (empty($_REQUEST['slug'])) {
328 328
 			return;
329 329
 		}
330 330
 
331
-		if( ! current_user_can( 'update_plugins' ) ) {
332
-			wp_die( __( 'You do not have permission to install plugin updates', 'gravityview' ), __( 'Error', 'gravityview' ), array( 'response' => 403 ) );
331
+		if (!current_user_can('update_plugins')) {
332
+			wp_die(__('You do not have permission to install plugin updates', 'gravityview'), __('Error', 'gravityview'), array('response' => 403));
333 333
 		}
334 334
 
335
-		$response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) );
335
+		$response = $this->api_request('plugin_latest_version', array('slug' => $_REQUEST['slug']));
336 336
 
337
-		if( $response && isset( $response->sections['changelog'] ) ) {
338
-			echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>';
337
+		if ($response && isset($response->sections['changelog'])) {
338
+			echo '<div style="background:#fff;padding:10px;">'.$response->sections['changelog'].'</div>';
339 339
 		}
340 340
 
341 341
 
Please login to merge, or discard this patch.
includes/lib/class-gamajo-template-loader.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -76,15 +76,15 @@  discard block
 block discarded – undo
76 76
 	 *
77 77
 	 * @return string
78 78
 	 */
79
-	public function get_template_part( $slug, $name = null, $load = true ) {
79
+	public function get_template_part($slug, $name = null, $load = true) {
80 80
 		// Execute code for this part
81
-		do_action( 'get_template_part_' . $slug, $slug, $name );
81
+		do_action('get_template_part_'.$slug, $slug, $name);
82 82
 
83 83
 		// Get files names of templates, for given slug and name.
84
-		$templates = $this->get_template_file_names( $slug, $name );
84
+		$templates = $this->get_template_file_names($slug, $name);
85 85
 
86 86
 		// Return the part that is found
87
-		return $this->locate_template( $templates, $load, false );
87
+		return $this->locate_template($templates, $load, false);
88 88
 	}
89 89
 
90 90
 	/**
@@ -97,12 +97,12 @@  discard block
 block discarded – undo
97 97
 	 *
98 98
 	 * @return array
99 99
 	 */
100
-	protected function get_template_file_names( $slug, $name ) {
100
+	protected function get_template_file_names($slug, $name) {
101 101
 		$templates = array();
102
-		if ( isset( $name ) ) {
103
-			$templates[] = $slug . '-' . $name . '.php';
102
+		if (isset($name)) {
103
+			$templates[] = $slug.'-'.$name.'.php';
104 104
 		}
105
-		$templates[] = $slug . '.php';
105
+		$templates[] = $slug.'.php';
106 106
 
107 107
 		/**
108 108
 		 * Allow template choices to be filtered.
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 		 * @param string $slug Template slug.
117 117
 		 * @param string $name Template name.
118 118
 		 */
119
-		return apply_filters( $this->filter_prefix . '_get_template_part', $templates, $slug, $name );
119
+		return apply_filters($this->filter_prefix.'_get_template_part', $templates, $slug, $name);
120 120
 	}
121 121
 
122 122
 	/**
@@ -137,30 +137,30 @@  discard block
 block discarded – undo
137 137
 	 *
138 138
 	 * @return string The template filename if one is located.
139 139
 	 */
140
-	public function locate_template( $template_names, $load = false, $require_once = true ) {
140
+	public function locate_template($template_names, $load = false, $require_once = true) {
141 141
 		// No file found yet
142 142
 		$located = false;
143 143
 
144 144
 		// Remove empty entries
145
-		$template_names = array_filter( (array) $template_names );
145
+		$template_names = array_filter((array)$template_names);
146 146
 		$template_paths = $this->get_template_paths();
147 147
 
148 148
 		// Try to find a template file
149
-		foreach ( $template_names as $template_name ) {
149
+		foreach ($template_names as $template_name) {
150 150
 			// Trim off any slashes from the template name
151
-			$template_name = ltrim( $template_name, '/' );
151
+			$template_name = ltrim($template_name, '/');
152 152
 
153 153
 			// Try locating this template file by looping through the template paths
154
-			foreach ( $template_paths as $template_path ) {
155
-				if ( file_exists( $template_path . $template_name ) ) {
156
-					$located = $template_path . $template_name;
154
+			foreach ($template_paths as $template_path) {
155
+				if (file_exists($template_path.$template_name)) {
156
+					$located = $template_path.$template_name;
157 157
 					break 2;
158 158
 				}
159 159
 			}
160 160
 		}
161 161
 
162
-		if ( $load && $located ) {
163
-			load_template( $located, $require_once );
162
+		if ($load && $located) {
163
+			load_template($located, $require_once);
164 164
 		}
165 165
 
166 166
 		return $located;
@@ -178,16 +178,16 @@  discard block
 block discarded – undo
178 178
 	 * @return mixed|void
179 179
 	 */
180 180
 	protected function get_template_paths() {
181
-		$theme_directory = trailingslashit( $this->theme_template_directory );
181
+		$theme_directory = trailingslashit($this->theme_template_directory);
182 182
 
183 183
 		$file_paths = array(
184
-			10  => trailingslashit( get_template_directory() ) . $theme_directory,
184
+			10  => trailingslashit(get_template_directory()).$theme_directory,
185 185
 			100 => $this->get_templates_dir()
186 186
 		);
187 187
 
188 188
 		// Only add this conditionally, so non-child themes don't redundantly check active theme twice.
189
-		if ( is_child_theme() ) {
190
-			$file_paths[1] = trailingslashit( get_stylesheet_directory() ) . $theme_directory;
189
+		if (is_child_theme()) {
190
+			$file_paths[1] = trailingslashit(get_stylesheet_directory()).$theme_directory;
191 191
 		}
192 192
 
193 193
 		/**
@@ -197,12 +197,12 @@  discard block
 block discarded – undo
197 197
 		 *
198 198
 		 * @param array $var Default is directory in child theme at index 1, parent theme at 10, and plugin at 100.
199 199
 		 */
200
-		$file_paths = apply_filters( $this->filter_prefix . '_template_paths', $file_paths );
200
+		$file_paths = apply_filters($this->filter_prefix.'_template_paths', $file_paths);
201 201
 
202 202
 		// sort the file paths based on priority
203
-		ksort( $file_paths, SORT_NUMERIC );
203
+		ksort($file_paths, SORT_NUMERIC);
204 204
 
205
-		return array_map( 'trailingslashit', $file_paths );
205
+		return array_map('trailingslashit', $file_paths);
206 206
 	}
207 207
 
208 208
 	/**
@@ -215,6 +215,6 @@  discard block
 block discarded – undo
215 215
 	 * @return string
216 216
 	 */
217 217
 	protected function get_templates_dir() {
218
-		return trailingslashit( $this->plugin_directory ) . $this->plugin_template_directory;
218
+		return trailingslashit($this->plugin_directory).$this->plugin_template_directory;
219 219
 	}
220 220
 }
Please login to merge, or discard this patch.
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.