Completed
Pull Request — master (#813)
by
unknown
06:28 queued 03:03
created
lib/timber-image.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -141,27 +141,27 @@  discard block
 block discarded – undo
141 141
 	 * @internal
142 142
 	 * @param  int $iid the id number of the image in the WP database
143 143
 	 */
144
-	protected function get_image_info( $iid ) {
144
+	protected function get_image_info($iid) {
145 145
 		$image_info = $iid;
146
-		if (is_numeric($iid)) {
146
+		if ( is_numeric($iid) ) {
147 147
 			$image_info = wp_get_attachment_metadata($iid);
148
-			if (!is_array($image_info)) {
148
+			if ( !is_array($image_info) ) {
149 149
 				$image_info = array();
150 150
 			}
151 151
 			$image_custom = get_post_custom($iid);
152 152
 			$basic = get_post($iid);
153
-			if ($basic) {
154
-				if (isset($basic->post_excerpt)) {
153
+			if ( $basic ) {
154
+				if ( isset($basic->post_excerpt) ) {
155 155
 					$this->caption = $basic->post_excerpt;
156 156
 				}
157 157
 				$image_custom = array_merge($image_custom, get_object_vars($basic));
158 158
 			}
159 159
 			return array_merge($image_info, $image_custom);
160 160
 		}
161
-		if (is_array($image_info) && isset($image_info['image'])) {
161
+		if ( is_array($image_info) && isset($image_info['image']) ) {
162 162
 			return $image_info['image'];
163 163
 		}
164
-		if (is_object($image_info)) {
164
+		if ( is_object($image_info) ) {
165 165
 		   return get_object_vars($image_info);
166 166
 		}
167 167
 		return $iid;
@@ -193,9 +193,9 @@  discard block
 block discarded – undo
193 193
 	 * @internal
194 194
 	 * @param int $iid
195 195
 	 */
196
-	function init( $iid = false ) {
197
-		if ( !is_numeric( $iid ) && is_string( $iid ) ) {
198
-			if (strstr($iid, '://')) {
196
+	function init($iid = false) {
197
+		if ( !is_numeric($iid) && is_string($iid) ) {
198
+			if ( strstr($iid, '://') ) {
199 199
 				$this->init_with_url($iid);
200 200
 				return;
201 201
 			}
@@ -244,9 +244,9 @@  discard block
 block discarded – undo
244 244
 	 * @internal
245 245
 	 * @param string $relative_path
246 246
 	 */
247
-	protected function init_with_relative_path( $relative_path ) {
248
-		$this->abs_url = home_url( $relative_path );
249
-		$file_path = TimberURLHelper::get_full_path( $relative_path );
247
+	protected function init_with_relative_path($relative_path) {
248
+		$this->abs_url = home_url($relative_path);
249
+		$file_path = TimberURLHelper::get_full_path($relative_path);
250 250
 		$this->file_loc = $file_path;
251 251
 		$this->file = $file_path;
252 252
 	}
@@ -255,8 +255,8 @@  discard block
 block discarded – undo
255 255
 	 * @internal
256 256
 	 * @param string $file_path
257 257
 	 */
258
-	protected function init_with_file_path( $file_path ) {
259
-		$url = TimberURLHelper::file_system_to_url( $file_path );
258
+	protected function init_with_file_path($file_path) {
259
+		$url = TimberURLHelper::file_system_to_url($file_path);
260 260
 		$this->abs_url = $url;
261 261
 		$this->file_loc = $file_path;
262 262
 		$this->file = $file_path;
@@ -455,8 +455,8 @@  discard block
 block discarded – undo
455 455
 	 * @param string $size
456 456
 	 * @return bool|string
457 457
 	 */
458
-	function get_src( $size = '' ) {
459
-		return $this->src( $size );
458
+	function get_src($size = '') {
459
+		return $this->src($size);
460 460
 	}
461 461
 
462 462
 	/**
Please login to merge, or discard this patch.
lib/image/timber-image-operation-tojpg.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -36,14 +36,14 @@  discard block
 block discarded – undo
36 36
 	 * @return bool                  true if everything went fine, false otherwise
37 37
 	 */
38 38
 	function run($load_filename, $save_filename) {
39
-		$input = self::image_create( $load_filename );
40
-		list( $width, $height ) = getimagesize( $load_filename );
41
-		$output = imagecreatetruecolor( $width, $height );
42
-		$c = self::hexrgb( $this->color );
43
-		$color = imagecolorallocate( $output, $c['red'], $c['green'], $c['blue'] );
44
-		imagefilledrectangle( $output, 0, 0, $width, $height, $color );
45
-		imagecopy( $output, $input, 0, 0, 0, 0, $width, $height );
46
-		imagejpeg( $output, $save_filename );
39
+		$input = self::image_create($load_filename);
40
+		list($width, $height) = getimagesize($load_filename);
41
+		$output = imagecreatetruecolor($width, $height);
42
+		$c = self::hexrgb($this->color);
43
+		$color = imagecolorallocate($output, $c['red'], $c['green'], $c['blue']);
44
+		imagefilledrectangle($output, 0, 0, $width, $height, $color);
45
+		imagecopy($output, $input, 0, 0, 0, 0, $width, $height);
46
+		imagejpeg($output, $save_filename);
47 47
 		return true;
48 48
 	}
49 49
 
@@ -52,10 +52,10 @@  discard block
 block discarded – undo
52 52
 	 * @return resource an image identifier representing the image obtained from the given filename
53 53
 	 *                  will return the same data type regardless of whether the source is gif or png
54 54
 	 */
55
-	function image_create( $filename, $ext = 'auto' ) {
55
+	function image_create($filename, $ext = 'auto') {
56 56
 		if ( $ext == 'auto' ) {
57 57
 			$ext = wp_check_filetype($filename);
58
-			if (isset($ext['ext'])) {
58
+			if ( isset($ext['ext']) ) {
59 59
 				$ext = $ext['ext'];
60 60
 			}
61 61
 		}
@@ -69,6 +69,6 @@  discard block
 block discarded – undo
69 69
 		if ( $ext == 'jpg' || $ext == 'jpeg' ) {
70 70
 			return imagecreatefromjpeg($filename);
71 71
 		}
72
-		throw new InvalidArgumentException( 'image_create only accepts PNG, GIF and JPGs. File extension was: '.$ext );
72
+		throw new InvalidArgumentException('image_create only accepts PNG, GIF and JPGs. File extension was: ' . $ext);
73 73
 	}
74 74
 }
Please login to merge, or discard this patch.
lib/timber-archives.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	 * }
55 55
 	 * @param string $base any additional paths that need to be prepended to the URLs that are generated, for example: "tags"
56 56
 	 */
57
-	function __construct( $args = null, $base = '' ) {
57
+	function __construct($args = null, $base = '') {
58 58
 		$this->init($args, $base);
59 59
 	}
60 60
 
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	 * @param array|string $args
64 64
 	 * @param string $base
65 65
 	 */
66
-	function init( $args = null, $base = '' ) {
66
+	function init($args = null, $base = '') {
67 67
 		$this->base = $base;
68 68
 		$this->items = $this->get_items($args);
69 69
 	}
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
 	 * @param string $text
75 75
 	 * @return mixed
76 76
 	 */
77
-	protected function get_archives_link( $url, $text ) {
77
+	protected function get_archives_link($url, $text) {
78 78
 		$ret = array();
79 79
 		$ret['text'] = $ret['title'] = $ret['name'] = wptexturize($text);
80 80
 		$ret['url'] = $ret['link'] = esc_url(TimberURLHelper::prepend_to_url($url, $this->base));
@@ -91,19 +91,19 @@  discard block
 block discarded – undo
91 91
 	 * @param string $limit
92 92
 	 * @return array
93 93
 	 */
94
-	protected function get_items_yearly( $args, $last_changed, $join, $where, $order, $limit ) {
94
+	protected function get_items_yearly($args, $last_changed, $join, $where, $order, $limit) {
95 95
 		global $wpdb;
96 96
 		$output = array();
97 97
 		$query = "SELECT YEAR(post_date) AS `year`, count(ID) as posts FROM {$wpdb->posts} $join $where GROUP BY YEAR(post_date) ORDER BY post_date $order $limit";
98 98
 		$key = md5($query);
99 99
 		$key = "wp_get_archives:$key:$last_changed";
100
-		if (!$results = wp_cache_get($key, 'posts')) {
100
+		if ( !$results = wp_cache_get($key, 'posts') ) {
101 101
 			$results = $wpdb->get_results($query);
102 102
 			wp_cache_set($key, $results, 'posts');
103 103
 		}
104
-		if ($results) {
105
-			foreach ( (array)$results as $result ) {
106
-				$url = get_year_link( $result->year );
104
+		if ( $results ) {
105
+			foreach ((array) $results as $result) {
106
+				$url = get_year_link($result->year);
107 107
 				$text = sprintf('%d', $result->year);
108 108
 				$output[] = $this->get_archives_link($url, $text);
109 109
 			}
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	 * @param bool $nested
123 123
 	 * @return array
124 124
 	 */
125
-	protected function get_items_monthly( $args, $last_changed, $join, $where, $order, $limit = 1000, $nested = true ) {
125
+	protected function get_items_monthly($args, $last_changed, $join, $where, $order, $limit = 1000, $nested = true) {
126 126
 		global $wpdb, $wp_locale;
127 127
 		$output = array();
128 128
 		$defaults = array(
@@ -137,26 +137,26 @@  discard block
 block discarded – undo
137 137
 			. "ORDER BY post_date $order $limit";
138 138
 		$key = md5($query);
139 139
 		$key = "wp_get_archives:$key:$last_changed";
140
-		if (!$results = wp_cache_get($key, 'posts')) {
140
+		if ( !$results = wp_cache_get($key, 'posts') ) {
141 141
 			$results = $wpdb->get_results($query);
142 142
 			wp_cache_set($key, $results, 'posts');
143 143
 		}
144
-		if ($results) {
145
-			foreach ((array)$results as $result) {
144
+		if ( $results ) {
145
+			foreach ((array) $results as $result) {
146 146
 				$url = get_month_link($result->year, $result->month);
147
-				if ($show_year && !$nested) {
147
+				if ( $show_year && !$nested ) {
148 148
 					$text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($result->month), $result->year);
149 149
 				} else {
150 150
 					$text = sprintf(__('%1$s'), $wp_locale->get_month($result->month));
151 151
 				}
152
-				if ($nested) {
152
+				if ( $nested ) {
153 153
 					$output[$result->year][] = $this->get_archives_link($url, $text);
154 154
 				} else {
155 155
 					$output[] = $this->get_archives_link($url, $text);
156 156
 				}
157 157
 			}
158 158
 		}
159
-		if ($nested) {
159
+		if ( $nested ) {
160 160
 			$out2 = array();
161 161
 			foreach ($output as $year => $months) {
162 162
 				$out2[] = array('name' => $year, 'children' => $months);
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 	 * @param array|string $args
172 172
 	 * @return array|string
173 173
 	 */
174
-	function get_items( $args = null ) {
174
+	function get_items($args = null) {
175 175
 		global $wpdb;
176 176
 
177 177
 		$defaults = array(
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 		$archive_week_start_date_format = 'Y/m/d';
221 221
 		$archive_week_end_date_format = 'Y/m/d';
222 222
 
223
-		if (!$archive_date_format_over_ride) {
223
+		if ( !$archive_date_format_over_ride ) {
224 224
 			$archive_day_date_format = get_option('date_format');
225 225
 			$archive_week_start_date_format = get_option('date_format');
226 226
 			$archive_week_end_date_format = get_option('date_format');
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 
233 233
 		$output = array();
234 234
 		$last_changed = wp_cache_get('last_changed', 'posts');
235
-		if (!$last_changed) {
235
+		if ( !$last_changed ) {
236 236
 			$last_changed = microtime();
237 237
 			wp_cache_set('last_changed', $last_changed, 'posts');
238 238
 		}
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 			$output = $this->get_items_yearly($args, $last_changed, $join, $where, $order, $limit);
243 243
 		} elseif ( 'monthly-nested' == $type ) {
244 244
 			$years = $this->get_items_yearly($args, $last_changed, $join, $where, $order, $limit);
245
-			foreach ( $years as &$year ) {
245
+			foreach ($years as &$year) {
246 246
 				$args = array('show_year' => false);
247 247
 				$year['children'] = $this->get_items_monthly($args, $last_changed, $join, $where, $order, $limit);
248 248
 			}
@@ -251,14 +251,14 @@  discard block
 block discarded – undo
251 251
 			$query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date $order $limit";
252 252
 			$key = md5($query);
253 253
 			$key = "wp_get_archives:$key:$last_changed";
254
-			if (!$results = wp_cache_get($key, 'posts')) {
254
+			if ( !$results = wp_cache_get($key, 'posts') ) {
255 255
 				$results = $wpdb->get_results($query);
256 256
 				$cache = array();
257 257
 				$cache[$key] = $results;
258 258
 				wp_cache_set($key, $results, 'posts');
259 259
 			}
260 260
 			if ( $results ) {
261
-				foreach ( (array)$results as $result ) {
261
+				foreach ((array) $results as $result) {
262 262
 					$url = get_day_link($result->year, $result->month, $result->dayofmonth);
263 263
 					$date = sprintf('%1$d-%2$02d-%3$02d 00:00:00', $result->year, $result->month, $result->dayofmonth);
264 264
 					$text = mysql2date($archive_day_date_format, $date);
@@ -271,13 +271,13 @@  discard block
 block discarded – undo
271 271
 				. "count( `ID` ) AS `posts` FROM `$wpdb->posts` $join $where GROUP BY $week, YEAR( `post_date` ) ORDER BY `post_date` $order $limit";
272 272
 			$key = md5($query);
273 273
 			$key = "wp_get_archives:$key:$last_changed";
274
-			if (!$results = wp_cache_get($key, 'posts')) {
274
+			if ( !$results = wp_cache_get($key, 'posts') ) {
275 275
 				$results = $wpdb->get_results($query);
276 276
 				wp_cache_set($key, $results, 'posts');
277 277
 			}
278 278
 			$arc_w_last = '';
279 279
 			if ( $results ) {
280
-				foreach ( (array)$results as $result ) {
280
+				foreach ((array) $results as $result) {
281 281
 					if ( $result->week != $arc_w_last ) {
282 282
 						$arc_year = $result->yr;
283 283
 						$arc_w_last = $result->week;
@@ -300,10 +300,10 @@  discard block
 block discarded – undo
300 300
 				wp_cache_set($key, $results, 'posts');
301 301
 			}
302 302
 			if ( $results ) {
303
-				foreach ( (array)$results as $result ) {
304
-					if ($result->post_date != '0000-00-00 00:00:00') {
303
+				foreach ((array) $results as $result) {
304
+					if ( $result->post_date != '0000-00-00 00:00:00' ) {
305 305
 						$url = get_permalink($result);
306
-						if ($result->post_title) {
306
+						if ( $result->post_title ) {
307 307
 							/** This filter is documented in wp-includes/post-template.php */
308 308
 							$text = strip_tags(apply_filters('the_title', $result->post_title, $result->ID));
309 309
 						} else {
Please login to merge, or discard this patch.