Completed
Pull Request — master (#793)
by Jared
03:28 queued 29s
created
lib/timber-url-helper.php 3 patches
Doc Comments   +7 added lines patch added patch discarded remove patch
@@ -136,6 +136,9 @@  discard block
 block discarded – undo
136 136
 		return $path;
137 137
 	}
138 138
 
139
+	/**
140
+	 * @param string $fs
141
+	 */
139 142
 	public static function file_system_to_url( $fs ) {
140 143
 		$relative_path = self::get_rel_path( $fs );
141 144
 		$home = home_url( '/'.$relative_path );
@@ -210,6 +213,7 @@  discard block
 block discarded – undo
210 213
 	/**
211 214
 	 * This will evaluate wheter a URL is at an aboslute location (like http://example.org/whatever)
212 215
 	 *
216
+	 * @param string $path
213 217
 	 * @return boolean true if $path is an absolute url, false if relative.
214 218
 	 */
215 219
 	public static function is_absolute( $path ) {
@@ -230,6 +234,9 @@  discard block
 block discarded – undo
230 234
 		return $is_external;
231 235
 	}
232 236
 
237
+	/**
238
+	 * @param string $url
239
+	 */
233 240
 	private static function is_internal_content($url) {
234 241
 		// using content_url() instead of site_url or home_url is IMPORTANT
235 242
 		// otherwise you run into errors with sites that:
Please login to merge, or discard this patch.
Spacing   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -9,8 +9,8 @@  discard block
 block discarded – undo
9 9
 	 */
10 10
 	public static function get_current_url() {
11 11
 		$pageURL = "http://";
12
-		if ( isset( $_SERVER['HTTPS'] ) && $_SERVER["HTTPS"] == "on" ) {
13
-			$pageURL = "https://";;
12
+		if ( isset($_SERVER['HTTPS']) && $_SERVER["HTTPS"] == "on" ) {
13
+			$pageURL = "https://"; ;
14 14
 		}
15 15
 		if ( isset($_SERVER["SERVER_PORT"]) && $_SERVER["SERVER_PORT"] && $_SERVER["SERVER_PORT"] != "80" ) {
16 16
 			$pageURL .= self::get_host() . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
@@ -26,12 +26,12 @@  discard block
 block discarded – undo
26 26
 	 * @param string  $url
27 27
 	 * @return bool
28 28
 	 */
29
-	public static function is_url( $url ) {
30
-		if ( !is_string( $url ) ) {
29
+	public static function is_url($url) {
30
+		if ( !is_string($url) ) {
31 31
 			return false;
32 32
 		}
33
-		$url = strtolower( $url );
34
-		if ( strstr( $url, '://' ) ) {
33
+		$url = strtolower($url);
34
+		if ( strstr($url, '://') ) {
35 35
 			return true;
36 36
 		}
37 37
 		return false;
@@ -43,11 +43,11 @@  discard block
 block discarded – undo
43 43
 	 * @return string
44 44
 	 */
45 45
 	public static function get_path_base() {
46
-		$struc = get_option( 'permalink_structure' );
47
-		$struc = explode( '/', $struc );
46
+		$struc = get_option('permalink_structure');
47
+		$struc = explode('/', $struc);
48 48
 		$p = '/';
49
-		foreach ( $struc as $s ) {
50
-			if ( !strstr( $s, '%' ) && strlen( $s ) ) {
49
+		foreach ($struc as $s) {
50
+			if ( !strstr($s, '%') && strlen($s) ) {
51 51
 				$p .= $s . '/';
52 52
 			}
53 53
 		}
@@ -61,22 +61,22 @@  discard block
 block discarded – undo
61 61
 	 * @param bool    $force
62 62
 	 * @return string
63 63
 	 */
64
-	public static function get_rel_url( $url, $force = false ) {
65
-		$url_info = parse_url( $url );
66
-		if ( isset( $url_info['host'] ) && $url_info['host'] != self::get_host() && !$force ) {
64
+	public static function get_rel_url($url, $force = false) {
65
+		$url_info = parse_url($url);
66
+		if ( isset($url_info['host']) && $url_info['host'] != self::get_host() && !$force ) {
67 67
 			return $url;
68 68
 		}
69 69
 		$link = '';
70
-		if ( isset( $url_info['path'] ) ) {
70
+		if ( isset($url_info['path']) ) {
71 71
 			$link = $url_info['path'];
72 72
 		}
73
-		if ( isset( $url_info['query'] ) && strlen( $url_info['query'] ) ) {
73
+		if ( isset($url_info['query']) && strlen($url_info['query']) ) {
74 74
 			$link .= '?' . $url_info['query'];
75 75
 		}
76
-		if ( isset( $url_info['fragment'] ) && strlen( $url_info['fragment'] ) ) {
76
+		if ( isset($url_info['fragment']) && strlen($url_info['fragment']) ) {
77 77
 			$link .= '#' . $url_info['fragment'];
78 78
 		}
79
-		$link = TimberURLHelper::remove_double_slashes( $link );
79
+		$link = TimberURLHelper::remove_double_slashes($link);
80 80
 		return $link;
81 81
 	}
82 82
 
@@ -86,10 +86,10 @@  discard block
 block discarded – undo
86 86
 	 * @return string the HTTP_HOST or SERVER_NAME
87 87
 	 */
88 88
 	public static function get_host() {
89
-		if (isset($_SERVER['HTTP_HOST'])) {
89
+		if ( isset($_SERVER['HTTP_HOST']) ) {
90 90
 			return $_SERVER['HTTP_HOST'];
91 91
 		}
92
-		if (isset($_SERVER['SERVER_NAME'])) {
92
+		if ( isset($_SERVER['SERVER_NAME']) ) {
93 93
 			return $_SERVER['SERVER_NAME'];
94 94
 		}
95 95
 		return '';
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 	 * @param string  $url
102 102
 	 * @return bool
103 103
 	 */
104
-	public static function is_local( $url ) {
105
-		if ( strstr( $url, self::get_host() ) ) {
104
+	public static function is_local($url) {
105
+		if ( strstr($url, self::get_host()) ) {
106 106
 			return true;
107 107
 		}
108 108
 		return false;
@@ -114,10 +114,10 @@  discard block
 block discarded – undo
114 114
 	 * @param string  $src
115 115
 	 * @return string
116 116
 	 */
117
-	public static function get_full_path( $src ) {
117
+	public static function get_full_path($src) {
118 118
 		$root = ABSPATH;
119 119
 		$old_root_path = $root . $src;
120
-		$old_root_path = str_replace( '//', '/', $old_root_path );
120
+		$old_root_path = str_replace('//', '/', $old_root_path);
121 121
 		return $old_root_path;
122 122
 	}
123 123
 
@@ -129,16 +129,16 @@  discard block
 block discarded – undo
129 129
 	 * @param string  $url
130 130
 	 * @return string
131 131
 	 */
132
-	public static function url_to_file_system( $url ) {
133
-		$url_parts = parse_url( $url );
132
+	public static function url_to_file_system($url) {
133
+		$url_parts = parse_url($url);
134 134
 		$path = ABSPATH . $url_parts['path'];
135
-		$path = str_replace( '//', '/', $path );
135
+		$path = str_replace('//', '/', $path);
136 136
 		return $path;
137 137
 	}
138 138
 
139
-	public static function file_system_to_url( $fs ) {
140
-		$relative_path = self::get_rel_path( $fs );
141
-		$home = home_url( '/'.$relative_path );
139
+	public static function file_system_to_url($fs) {
140
+		$relative_path = self::get_rel_path($fs);
141
+		$home = home_url('/' . $relative_path);
142 142
 		return $home;
143 143
 	}
144 144
 
@@ -148,12 +148,12 @@  discard block
 block discarded – undo
148 148
 	 * @param string  $src
149 149
 	 * @return string
150 150
 	 */
151
-	public static function get_rel_path( $src ) {
152
-		if ( strstr( $src, ABSPATH ) ) {
153
-			return str_replace( ABSPATH, '', $src );
151
+	public static function get_rel_path($src) {
152
+		if ( strstr($src, ABSPATH) ) {
153
+			return str_replace(ABSPATH, '', $src);
154 154
 		}
155 155
 		//its outside the wordpress directory, alternate setups:
156
-		$src = str_replace( WP_CONTENT_DIR, '', $src );
156
+		$src = str_replace(WP_CONTENT_DIR, '', $src);
157 157
 		return WP_CONTENT_SUBDIR . $src;
158 158
 	}
159 159
 
@@ -163,10 +163,10 @@  discard block
 block discarded – undo
163 163
 	 * @param string  $url
164 164
 	 * @return string
165 165
 	 */
166
-	public static function remove_double_slashes( $url ) {
167
-		$url = str_replace( '//', '/', $url );
168
-		if ( strstr( $url, 'http:' ) && !strstr( $url, 'http://' ) ) {
169
-			$url = str_replace( 'http:/', 'http://', $url );
166
+	public static function remove_double_slashes($url) {
167
+		$url = str_replace('//', '/', $url);
168
+		if ( strstr($url, 'http:') && !strstr($url, 'http://') ) {
169
+			$url = str_replace('http:/', 'http://', $url);
170 170
 		}
171 171
 		return $url;
172 172
 	}
@@ -178,20 +178,20 @@  discard block
 block discarded – undo
178 178
 	 * @param string  $path
179 179
 	 * @return string
180 180
 	 */
181
-	public static function prepend_to_url( $url, $path ) {
182
-		if ( strstr( strtolower( $url ), 'http' ) ) {
183
-			$url_parts = parse_url( $url );
181
+	public static function prepend_to_url($url, $path) {
182
+		if ( strstr(strtolower($url), 'http') ) {
183
+			$url_parts = parse_url($url);
184 184
 			$url = $url_parts['scheme'] . '://' . $url_parts['host'] . $path . $url_parts['path'];
185
-			if ( isset( $url_parts['query'] ) ) {
185
+			if ( isset($url_parts['query']) ) {
186 186
 				$url .= $url_parts['query'];
187 187
 			}
188
-			if ( isset( $url_parts['fragment'] ) ) {
188
+			if ( isset($url_parts['fragment']) ) {
189 189
 				$url .= $url_parts['fragment'];
190 190
 			}
191 191
 		} else {
192 192
 			$url = $url . $path;
193 193
 		}
194
-		return self::remove_double_slashes( $url );
194
+		return self::remove_double_slashes($url);
195 195
 	}
196 196
 
197 197
 	/**
@@ -200,8 +200,8 @@  discard block
 block discarded – undo
200 200
 	 * @param string  $path
201 201
 	 * @return string
202 202
 	 */
203
-	public static function preslashit( $path ) {
204
-		if ( strpos( $path, '/' ) != 0 ) {
203
+	public static function preslashit($path) {
204
+		if ( strpos($path, '/') != 0 ) {
205 205
 			$path = '/' . $path;
206 206
 		}
207 207
 		return $path;
@@ -212,8 +212,8 @@  discard block
 block discarded – undo
212 212
 	 *
213 213
 	 * @return boolean true if $path is an absolute url, false if relative.
214 214
 	 */
215
-	public static function is_absolute( $path ) {
216
-		return (boolean) ( strstr( $path, 'http' ) );
215
+	public static function is_absolute($path) {
216
+		return (boolean) (strstr($path, 'http'));
217 217
 	}
218 218
 
219 219
 	/**
@@ -224,8 +224,8 @@  discard block
 block discarded – undo
224 224
 	 * @param string  $url a URL to evaluate against
225 225
 	 * @return boolean if $url points to an external location returns true
226 226
 	 */
227
-	public static function is_external_content( $url ) {
228
-		$is_external = TimberURLHelper::is_absolute( $url ) && ! TimberURLHelper::is_internal_content( $url );
227
+	public static function is_external_content($url) {
228
+		$is_external = TimberURLHelper::is_absolute($url) && !TimberURLHelper::is_internal_content($url);
229 229
 
230 230
 		return $is_external;
231 231
 	}
@@ -235,11 +235,11 @@  discard block
 block discarded – undo
235 235
 		// otherwise you run into errors with sites that:
236 236
 		// 1. use WPML plugin
237 237
 		// 2. or redefine content directory
238
-		$is_content_url = strstr( $url, content_url() );
238
+		$is_content_url = strstr($url, content_url());
239 239
 
240 240
 		// this case covers when the upload directory has been redefined
241 241
 		$upload_dir = wp_upload_dir();
242
-		$is_upload_url = strstr( $url, $upload_dir['baseurl'] );
242
+		$is_upload_url = strstr($url, $upload_dir['baseurl']);
243 243
 
244 244
 		return $is_content_url || $is_upload_url;
245 245
 	}
@@ -251,9 +251,9 @@  discard block
 block discarded – undo
251 251
 	 * @return bool     true if $path is an external url, false if relative or local.
252 252
 	 *                  true if it's a subdomain (http://cdn.example.org = true)
253 253
 	 */
254
-	public static function is_external( $url ) {
255
-		$has_http = strstr( strtolower( $url ), 'http' );
256
-		$on_domain = strstr( $url, self::get_host() );
254
+	public static function is_external($url) {
255
+		$has_http = strstr(strtolower($url), 'http');
256
+		$on_domain = strstr($url, self::get_host());
257 257
 		if ( $has_http && !$on_domain ) {
258 258
 			return true;
259 259
 		}
@@ -266,9 +266,9 @@  discard block
 block discarded – undo
266 266
 	 * @param string  $link
267 267
 	 * @return string
268 268
 	 */
269
-	public static function remove_trailing_slash( $link ) {
269
+	public static function remove_trailing_slash($link) {
270 270
 		if ( $link != "/" )
271
-			$link = untrailingslashit( $link );
271
+			$link = untrailingslashit($link);
272 272
 		return $link;
273 273
 	}
274 274
 
@@ -280,25 +280,25 @@  discard block
 block discarded – undo
280 280
 	 * @return string|WP_Error the location of the temporay file name or an error
281 281
 	 * @deprecated since 0.20.0
282 282
 	 */
283
-	static function download_url( $url, $timeout = 300 ) {
283
+	static function download_url($url, $timeout = 300) {
284 284
 		if ( !$url ) {
285
-			return new WP_Error( 'http_no_url', __( 'Invalid URL Provided.' ) );
285
+			return new WP_Error('http_no_url', __('Invalid URL Provided.'));
286 286
 		}
287 287
 
288
-		$tmpfname = wp_tempnam( $url );
288
+		$tmpfname = wp_tempnam($url);
289 289
 		if ( !$tmpfname ) {
290
-			return new WP_Error( 'http_no_file', __( 'Could not create Temporary file.' ) );
290
+			return new WP_Error('http_no_file', __('Could not create Temporary file.'));
291 291
 		}
292 292
 
293
-		$response = wp_remote_get( $url, array( 'timeout' => $timeout, 'stream' => true, 'filename' => $tmpfname ) );
293
+		$response = wp_remote_get($url, array('timeout' => $timeout, 'stream' => true, 'filename' => $tmpfname));
294 294
 
295
-		if ( is_wp_error( $response ) ) {
296
-			unlink( $tmpfname );
295
+		if ( is_wp_error($response) ) {
296
+			unlink($tmpfname);
297 297
 			return $response;
298 298
 		}
299
-		if ( 200 != wp_remote_retrieve_response_code( $response ) ) {
300
-			unlink( $tmpfname );
301
-			return new WP_Error( 'http_404', trim( wp_remote_retrieve_response_message( $response ) ) );
299
+		if ( 200 != wp_remote_retrieve_response_code($response) ) {
300
+			unlink($tmpfname);
301
+			return new WP_Error('http_404', trim(wp_remote_retrieve_response_message($response)));
302 302
 		}
303 303
 		return $tmpfname;
304 304
 	}
@@ -311,11 +311,11 @@  discard block
 block discarded – undo
311 311
 	 * @param int $i the position of the parameter to grab.
312 312
 	 * @return array|string
313 313
 	 */
314
-	public static function get_params( $i = false ) {
315
-		$args = explode( '/', trim( strtolower( $_SERVER['REQUEST_URI'] ) ) );
314
+	public static function get_params($i = false) {
315
+		$args = explode('/', trim(strtolower($_SERVER['REQUEST_URI'])));
316 316
 		$newargs = array();
317
-		foreach ( $args as $arg ) {
318
-			if ( strlen( $arg ) ) {
317
+		foreach ($args as $arg) {
318
+			if ( strlen($arg) ) {
319 319
 				$newargs[] = $arg;
320 320
 			}
321 321
 		}
@@ -324,9 +324,9 @@  discard block
 block discarded – undo
324 324
 		}
325 325
 		if ( $i < 0 ) {
326 326
 			//count from end
327
-			$i = count( $newargs ) + $i;
327
+			$i = count($newargs) + $i;
328 328
 		}
329
-		if ( isset( $newargs[$i] ) ) {
329
+		if ( isset($newargs[$i]) ) {
330 330
 			return $newargs[$i];
331 331
 		}
332 332
 	}
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -267,8 +267,9 @@
 block discarded – undo
267 267
 	 * @return string
268 268
 	 */
269 269
 	public static function remove_trailing_slash( $link ) {
270
-		if ( $link != "/" )
271
-			$link = untrailingslashit( $link );
270
+		if ( $link != "/" ) {
271
+					$link = untrailingslashit( $link );
272
+		}
272 273
 		return $link;
273 274
 	}
274 275
 
Please login to merge, or discard this patch.
timber.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -606,7 +606,7 @@
 block discarded – undo
606 606
 	 * Is post class or class map.
607 607
 	 *
608 608
 	 * @param string|array $args
609
-	 * @return bool
609
+	 * @return boolean|null
610 610
 	 * @deprecated since 0.20.0
611 611
 	 */
612 612
 	public static function is_post_class_or_class_map( $args ) {
Please login to merge, or discard this patch.
Spacing   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -14,11 +14,11 @@  discard block
 block discarded – undo
14 14
 // we look for Composer files first in the plugins dir.
15 15
 // then in the wp-content dir (site install).
16 16
 // and finally in the current themes directories.
17
-if (   file_exists( $composer_autoload = __DIR__ . '/vendor/autoload.php' ) /* check in self */
18
-	|| file_exists( $composer_autoload = WP_CONTENT_DIR.'/vendor/autoload.php') /* check in wp-content */
19
-	|| file_exists( $composer_autoload = plugin_dir_path( __FILE__ ).'vendor/autoload.php') /* check in plugin directory */
20
-	|| file_exists( $composer_autoload = get_stylesheet_directory().'/vendor/autoload.php') /* check in child theme */
21
-	|| file_exists( $composer_autoload = get_template_directory().'/vendor/autoload.php') /* check in parent theme */
17
+if ( file_exists($composer_autoload = __DIR__ . '/vendor/autoload.php') /* check in self */
18
+	|| file_exists($composer_autoload = WP_CONTENT_DIR . '/vendor/autoload.php') /* check in wp-content */
19
+	|| file_exists($composer_autoload = plugin_dir_path(__FILE__) . 'vendor/autoload.php') /* check in plugin directory */
20
+	|| file_exists($composer_autoload = get_stylesheet_directory() . '/vendor/autoload.php') /* check in child theme */
21
+	|| file_exists($composer_autoload = get_template_directory() . '/vendor/autoload.php') /* check in parent theme */
22 22
 	) {
23 23
 	require_once $composer_autoload;
24 24
 }
@@ -71,16 +71,16 @@  discard block
 block discarded – undo
71 71
 		if ( is_admin() || $_SERVER['PHP_SELF'] == '/wp-login.php' ) {
72 72
 			return;
73 73
 		}
74
-		if ( version_compare( phpversion(), '5.3.0', '<' ) && !is_admin() ) {
75
-			trigger_error( 'Timber requires PHP 5.3.0 or greater. You have '.phpversion(), E_USER_ERROR );
74
+		if ( version_compare(phpversion(), '5.3.0', '<') && !is_admin() ) {
75
+			trigger_error('Timber requires PHP 5.3.0 or greater. You have ' . phpversion(), E_USER_ERROR);
76 76
 		}
77
-		if ( !class_exists( 'Twig_Autoloader' ) ) {
78
-			trigger_error( 'You have not run "composer install" to download required dependencies for Timber, you can read more on https://github.com/jarednova/timber#installation', E_USER_ERROR );
77
+		if ( !class_exists('Twig_Autoloader') ) {
78
+			trigger_error('You have not run "composer install" to download required dependencies for Timber, you can read more on https://github.com/jarednova/timber#installation', E_USER_ERROR);
79 79
 		}
80 80
 	}
81 81
 
82 82
 	function init_constants() {
83
-		defined( "TIMBER_LOC" ) or define( "TIMBER_LOC", realpath( __DIR__ ) );
83
+		defined("TIMBER_LOC") or define("TIMBER_LOC", realpath(__DIR__));
84 84
 	}
85 85
 
86 86
 	/**
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	 */
89 89
 	protected function init() {
90 90
 		TimberTwig::init();
91
-		TimberRoutes::init( $this );
91
+		TimberRoutes::init($this);
92 92
 		TimberImageHelper::init();
93 93
 		TimberAdmin::init();
94 94
 		TimberIntegrations::init();
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
 	 * @param string  $PostClass
105 105
 	 * @return array|bool|null
106 106
 	 */
107
-	public static function get_post( $query = false, $PostClass = 'TimberPost' ) {
108
-		return TimberPostGetter::get_post( $query, $PostClass );
107
+	public static function get_post($query = false, $PostClass = 'TimberPost') {
108
+		return TimberPostGetter::get_post($query, $PostClass);
109 109
 	}
110 110
 
111 111
 	/**
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
 	 * @param string  $PostClass
116 116
 	 * @return array|bool|null
117 117
 	 */
118
-	public static function get_posts( $query = false, $PostClass = 'TimberPost', $return_collection = false ) {
119
-		return TimberPostGetter::get_posts( $query, $PostClass, $return_collection );
118
+	public static function get_posts($query = false, $PostClass = 'TimberPost', $return_collection = false) {
119
+		return TimberPostGetter::get_posts($query, $PostClass, $return_collection);
120 120
 	}
121 121
 
122 122
 	/**
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
 	 * @param string  $PostClass
127 127
 	 * @return array|bool|null
128 128
 	 */
129
-	public static function query_post( $query = false, $PostClass = 'TimberPost' ) {
130
-		return TimberPostGetter::query_post( $query, $PostClass );
129
+	public static function query_post($query = false, $PostClass = 'TimberPost') {
130
+		return TimberPostGetter::query_post($query, $PostClass);
131 131
 	}
132 132
 
133 133
 	/**
@@ -137,8 +137,8 @@  discard block
 block discarded – undo
137 137
 	 * @param string  $PostClass
138 138
 	 * @return array|bool|null
139 139
 	 */
140
-	public static function query_posts( $query = false, $PostClass = 'TimberPost' ) {
141
-		return TimberPostGetter::query_posts( $query, $PostClass );
140
+	public static function query_posts($query = false, $PostClass = 'TimberPost') {
141
+		return TimberPostGetter::query_posts($query, $PostClass);
142 142
 	}
143 143
 
144 144
 	/**
@@ -148,8 +148,8 @@  discard block
 block discarded – undo
148 148
 	 * @return array
149 149
 	 * @deprecated since 0.20.0
150 150
 	 */
151
-	static function get_pids( $query = null ) {
152
-		return TimberPostGetter::get_pids( $query );
151
+	static function get_pids($query = null) {
152
+		return TimberPostGetter::get_pids($query);
153 153
 	}
154 154
 
155 155
 	/**
@@ -159,8 +159,8 @@  discard block
 block discarded – undo
159 159
 	 * @return array
160 160
 	 * @deprecated since 0.20.0
161 161
 	 */
162
-	static function get_posts_from_loop( $PostClass ) {
163
-		return TimberPostGetter::get_posts( $PostClass );
162
+	static function get_posts_from_loop($PostClass) {
163
+		return TimberPostGetter::get_posts($PostClass);
164 164
 	}
165 165
 
166 166
 	/**
@@ -171,8 +171,8 @@  discard block
 block discarded – undo
171 171
 	 * @return array
172 172
 	 * @deprecated since 0.20.0
173 173
 	 */
174
-	static function get_posts_from_slug( $slug, $PostClass = 'TimberPost' ) {
175
-		return TimberPostGetter::get_posts( $slug, $PostClass );
174
+	static function get_posts_from_slug($slug, $PostClass = 'TimberPost') {
175
+		return TimberPostGetter::get_posts($slug, $PostClass);
176 176
 	}
177 177
 
178 178
 	/**
@@ -183,8 +183,8 @@  discard block
 block discarded – undo
183 183
 	 * @return array
184 184
 	 * @deprecated since 0.20.0
185 185
 	 */
186
-	static function get_posts_from_wp_query( $query = array(), $PostClass = 'TimberPost' ) {
187
-		return TimberPostGetter::query_posts( $query, $PostClass );
186
+	static function get_posts_from_wp_query($query = array(), $PostClass = 'TimberPost') {
187
+		return TimberPostGetter::query_posts($query, $PostClass);
188 188
 	}
189 189
 
190 190
 	/**
@@ -195,8 +195,8 @@  discard block
 block discarded – undo
195 195
 	 * @return array|null
196 196
 	 * @deprecated since 0.20.0
197 197
 	 */
198
-	static function get_posts_from_array_of_ids( $query = array(), $PostClass = 'TimberPost' ) {
199
-		return TimberPostGetter::get_posts( $query, $PostClass );
198
+	static function get_posts_from_array_of_ids($query = array(), $PostClass = 'TimberPost') {
199
+		return TimberPostGetter::get_posts($query, $PostClass);
200 200
 	}
201 201
 
202 202
 	/**
@@ -206,9 +206,9 @@  discard block
 block discarded – undo
206 206
 	 * @return int
207 207
 	 * @deprecated since 0.20.0
208 208
 	 */
209
-	static function get_pid( $query ) {
210
-		$pids = TimberPostGetter::get_pids( $query );
211
-		if ( is_array( $pids ) && count( $pids ) ) {
209
+	static function get_pid($query) {
210
+		$pids = TimberPostGetter::get_pids($query);
211
+		if ( is_array($pids) && count($pids) ) {
212 212
 			return $pids[0];
213 213
 		}
214 214
 	}
@@ -234,8 +234,8 @@  discard block
 block discarded – undo
234 234
 	 * @param string  $TermClass
235 235
 	 * @return mixed
236 236
 	 */
237
-	public static function get_terms( $args = null, $maybe_args = array(), $TermClass = 'TimberTerm' ) {
238
-		return TimberTermGetter::get_terms( $args, $maybe_args, $TermClass );
237
+	public static function get_terms($args = null, $maybe_args = array(), $TermClass = 'TimberTerm') {
238
+		return TimberTermGetter::get_terms($args, $maybe_args, $TermClass);
239 239
 	}
240 240
 
241 241
 	/* Site Retrieval
@@ -247,14 +247,14 @@  discard block
 block discarded – undo
247 247
 	 * @param array|bool $blog_ids
248 248
 	 * @return array
249 249
 	 */
250
-	public static function get_sites( $blog_ids = false ) {
251
-		if ( !is_array( $blog_ids ) ) {
250
+	public static function get_sites($blog_ids = false) {
251
+		if ( !is_array($blog_ids) ) {
252 252
 			global $wpdb;
253
-			$blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs ORDER BY blog_id ASC" );
253
+			$blog_ids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs ORDER BY blog_id ASC");
254 254
 		}
255 255
 		$return = array();
256
-		foreach ( $blog_ids as $blog_id ) {
257
-			$return[] = new TimberSite( $blog_id );
256
+		foreach ($blog_ids as $blog_id) {
257
+			$return[] = new TimberSite($blog_id);
258 258
 		}
259 259
 		return $return;
260 260
 	}
@@ -272,29 +272,29 @@  discard block
 block discarded – undo
272 272
 		$data = array();
273 273
 		$data['http_host'] = 'http://' . TimberURLHelper::get_host();
274 274
 		$data['wp_title'] = TimberHelper::get_wp_title();
275
-		$data['wp_head'] = TimberHelper::function_wrapper( 'wp_head' );
276
-		$data['wp_footer'] = TimberHelper::function_wrapper( 'wp_footer' );
277
-		$data['body_class'] = implode( ' ', get_body_class() );
275
+		$data['wp_head'] = TimberHelper::function_wrapper('wp_head');
276
+		$data['wp_footer'] = TimberHelper::function_wrapper('wp_footer');
277
+		$data['body_class'] = implode(' ', get_body_class());
278 278
 
279 279
 		$data['site'] = new TimberSite();
280 280
 		$data['theme'] = $data['site']->theme;
281 281
 		//deprecated, these should be fetched via TimberSite or TimberTheme
282
-		$data['theme_dir'] = WP_CONTENT_SUBDIR.str_replace( WP_CONTENT_DIR, '', get_stylesheet_directory() );
283
-		$data['language_attributes'] = TimberHelper::function_wrapper( 'language_attributes' );
282
+		$data['theme_dir'] = WP_CONTENT_SUBDIR . str_replace(WP_CONTENT_DIR, '', get_stylesheet_directory());
283
+		$data['language_attributes'] = TimberHelper::function_wrapper('language_attributes');
284 284
 		$data['stylesheet_uri'] = get_stylesheet_uri();
285 285
 		$data['template_uri'] = get_template_directory_uri();
286 286
 
287 287
 		$data['posts'] = Timber::query_posts();
288 288
 
289 289
 		//deprecated, this should be fetched via TimberMenu
290
-		if ( function_exists( 'wp_nav_menu' ) ) {
290
+		if ( function_exists('wp_nav_menu') ) {
291 291
 			$locations = get_nav_menu_locations();
292
-			if ( count( $locations ) ) {
293
-				$data['wp_nav_menu'] = wp_nav_menu( array( 'container_class' => 'menu-header', 'echo' => false, 'menu_class' => 'nav-menu' ) );
292
+			if ( count($locations) ) {
293
+				$data['wp_nav_menu'] = wp_nav_menu(array('container_class' => 'menu-header', 'echo' => false, 'menu_class' => 'nav-menu'));
294 294
 			}
295 295
 		}
296
-		$data = apply_filters( 'timber_context', $data );
297
-		$data = apply_filters( 'timber/context', $data );
296
+		$data = apply_filters('timber_context', $data);
297
+		$data = apply_filters('timber/context', $data);
298 298
 		return $data;
299 299
 	}
300 300
 
@@ -308,27 +308,27 @@  discard block
 block discarded – undo
308 308
 	 * @param bool    $via_render
309 309
 	 * @return bool|string
310 310
 	 */
311
-	public static function compile( $filenames, $data = array(), $expires = false, $cache_mode = TimberLoader::CACHE_USE_DEFAULT, $via_render = false ) {
311
+	public static function compile($filenames, $data = array(), $expires = false, $cache_mode = TimberLoader::CACHE_USE_DEFAULT, $via_render = false) {
312 312
 		$caller = self::get_calling_script_dir();
313 313
 		$caller_file = self::get_calling_script_file();
314
-		$caller_file = apply_filters( 'timber_calling_php_file', $caller_file );
315
-		$loader = new TimberLoader( $caller );
316
-		$file = $loader->choose_template( $filenames );
314
+		$caller_file = apply_filters('timber_calling_php_file', $caller_file);
315
+		$loader = new TimberLoader($caller);
316
+		$file = $loader->choose_template($filenames);
317 317
 		$output = '';
318
-		if ( is_null( $data ) ) {
318
+		if ( is_null($data) ) {
319 319
 			$data = array();
320 320
 		}
321
-		if ( strlen( $file ) ) {
321
+		if ( strlen($file) ) {
322 322
 			if ( $via_render ) {
323
-				$file = apply_filters( 'timber_render_file', $file );
324
-				$data = apply_filters( 'timber_render_data', $data );
323
+				$file = apply_filters('timber_render_file', $file);
324
+				$data = apply_filters('timber_render_data', $data);
325 325
 			} else {
326
-				$file = apply_filters( 'timber_compile_file', $file );
327
-				$data = apply_filters( 'timber_compile_data', $data );
326
+				$file = apply_filters('timber_compile_file', $file);
327
+				$data = apply_filters('timber_compile_data', $data);
328 328
 			}
329
-			$output = $loader->render( $file, $data, $expires, $cache_mode );
329
+			$output = $loader->render($file, $data, $expires, $cache_mode);
330 330
 		}
331
-		do_action( 'timber_compile_done' );
331
+		do_action('timber_compile_done');
332 332
 		return $output;
333 333
 	}
334 334
 
@@ -339,14 +339,14 @@  discard block
 block discarded – undo
339 339
 	 * @param array   $data   an array with data in it.
340 340
 	 * @return  bool|string
341 341
 	 */
342
-	public static function compile_string( $string, $data = array() ) {
342
+	public static function compile_string($string, $data = array()) {
343 343
 		$dummy_loader = new TimberLoader();
344 344
 		$dummy_loader->get_twig();
345 345
 		$loader = new Twig_Loader_String();
346
-		$twig = new Twig_Environment( $loader );
347
-		$twig = apply_filters( 'timber/twig/filters', $twig );
348
-		$twig = apply_filters( 'twig_apply_filters', $twig );
349
-		return $twig->render( $string, $data );
346
+		$twig = new Twig_Environment($loader);
347
+		$twig = apply_filters('timber/twig/filters', $twig);
348
+		$twig = apply_filters('twig_apply_filters', $twig);
349
+		return $twig->render($string, $data);
350 350
 	}
351 351
 
352 352
 	/**
@@ -358,15 +358,15 @@  discard block
 block discarded – undo
358 358
 	 * @param string  $cache_mode
359 359
 	 * @return bool|string
360 360
 	 */
361
-	public static function fetch( $filenames, $data = array(), $expires = false, $cache_mode = TimberLoader::CACHE_USE_DEFAULT ) {
361
+	public static function fetch($filenames, $data = array(), $expires = false, $cache_mode = TimberLoader::CACHE_USE_DEFAULT) {
362 362
 		if ( $expires === true ) {
363 363
 			//if this is reading as true; the user probably is using the old $echo param
364 364
 			//so we should move all vars up by a spot
365 365
 			$expires = $cache_mode;
366 366
 			$cache_mode = TimberLoader::CACHE_USE_DEFAULT;
367 367
 		}
368
-		$output = self::compile( $filenames, $data, $expires, $cache_mode, true );
369
-		$output = apply_filters( 'timber_compile_result', $output );
368
+		$output = self::compile($filenames, $data, $expires, $cache_mode, true);
369
+		$output = apply_filters('timber_compile_result', $output);
370 370
 		return $output;
371 371
 	}
372 372
 
@@ -379,8 +379,8 @@  discard block
 block discarded – undo
379 379
 	 * @param string  $cache_mode
380 380
 	 * @return bool|string
381 381
 	 */
382
-	public static function render( $filenames, $data = array(), $expires = false, $cache_mode = TimberLoader::CACHE_USE_DEFAULT ) {
383
-		$output = static::fetch( $filenames, $data, $expires, $cache_mode );
382
+	public static function render($filenames, $data = array(), $expires = false, $cache_mode = TimberLoader::CACHE_USE_DEFAULT) {
383
+		$output = static::fetch($filenames, $data, $expires, $cache_mode);
384 384
 		echo $output;
385 385
 		return $output;
386 386
 	}
@@ -392,8 +392,8 @@  discard block
 block discarded – undo
392 392
 	 * @param array   $data   an array with data in it.
393 393
 	 * @return  bool|string
394 394
 	 */
395
-	public static function render_string( $string, $data = array() ) {
396
-		$compiled = self::compile_string( $string, $data );
395
+	public static function render_string($string, $data = array()) {
396
+		$compiled = self::compile_string($string, $data);
397 397
 		echo $compiled;
398 398
 		return $compiled;
399 399
 	}
@@ -409,14 +409,14 @@  discard block
 block discarded – undo
409 409
 	 * @param array   $data
410 410
 	 * @return bool|string
411 411
 	 */
412
-	public static function get_sidebar( $sidebar = '', $data = array() ) {
412
+	public static function get_sidebar($sidebar = '', $data = array()) {
413 413
 		if ( $sidebar == '' ) {
414 414
 			$sidebar = 'sidebar.php';
415 415
 		}
416
-		if ( strstr( strtolower( $sidebar ), '.php' ) ) {
417
-			return self::get_sidebar_from_php( $sidebar, $data );
416
+		if ( strstr(strtolower($sidebar), '.php') ) {
417
+			return self::get_sidebar_from_php($sidebar, $data);
418 418
 		}
419
-		return self::compile( $sidebar, $data );
419
+		return self::compile($sidebar, $data);
420 420
 	}
421 421
 
422 422
 	/**
@@ -426,21 +426,21 @@  discard block
 block discarded – undo
426 426
 	 * @param array   $data
427 427
 	 * @return string
428 428
 	 */
429
-	public static function get_sidebar_from_php( $sidebar = '', $data ) {
429
+	public static function get_sidebar_from_php($sidebar = '', $data) {
430 430
 		$caller = self::get_calling_script_dir();
431 431
 		$loader = new TimberLoader();
432
-		$uris = $loader->get_locations( $caller );
432
+		$uris = $loader->get_locations($caller);
433 433
 		ob_start();
434 434
 		$found = false;
435
-		foreach ( $uris as $uri ) {
436
-			if ( file_exists( trailingslashit( $uri ) . $sidebar ) ) {
437
-				include trailingslashit( $uri ) . $sidebar;
435
+		foreach ($uris as $uri) {
436
+			if ( file_exists(trailingslashit($uri) . $sidebar) ) {
437
+				include trailingslashit($uri) . $sidebar;
438 438
 				$found = true;
439 439
 				break;
440 440
 			}
441 441
 		}
442 442
 		if ( !$found ) {
443
-			TimberHelper::error_log( 'error loading your sidebar, check to make sure the file exists' );
443
+			TimberHelper::error_log('error loading your sidebar, check to make sure the file exists');
444 444
 		}
445 445
 		$ret = ob_get_contents();
446 446
 		ob_end_clean();
@@ -456,8 +456,8 @@  discard block
 block discarded – undo
456 456
 	 * @param int     $widget_id
457 457
 	 * @return TimberFunctionWrapper
458 458
 	 */
459
-	public static function get_widgets( $widget_id ) {
460
-		return TimberHelper::function_wrapper( 'dynamic_sidebar', array( $widget_id ), true );
459
+	public static function get_widgets($widget_id) {
460
+		return TimberHelper::function_wrapper('dynamic_sidebar', array($widget_id), true);
461 461
 	}
462 462
 
463 463
 
@@ -472,15 +472,15 @@  discard block
 block discarded – undo
472 472
 	 * @param array   $args
473 473
 	 * @deprecated since 0.20.0
474 474
 	 */
475
-	public static function add_route( $route, $callback, $args = array() ) {
476
-		Routes::map( $route, $callback, $args );
475
+	public static function add_route($route, $callback, $args = array()) {
476
+		Routes::map($route, $callback, $args);
477 477
 	}
478 478
 
479 479
 	/**
480 480
 	 * @deprecated since 0.22.2
481 481
 	 */
482 482
 	public function cancel_query() {
483
-		add_action( 'posts_request', array( $this, 'cancel_query_posts_request' ) );
483
+		add_action('posts_request', array($this, 'cancel_query_posts_request'));
484 484
 	}
485 485
 
486 486
 	/**
@@ -497,8 +497,8 @@  discard block
 block discarded – undo
497 497
 	 *
498 498
 	 * @deprecated since 0.20.0
499 499
 	 */
500
-	public static function load_template( $template, $query = false, $status_code = 200, $tparams = false ) {
501
-		return Routes::load( $template, $tparams, $query, $status_code );
500
+	public static function load_template($template, $query = false, $status_code = 200, $tparams = false) {
501
+		return Routes::load($template, $tparams, $query, $status_code);
502 502
 	}
503 503
 
504 504
 	/**
@@ -506,8 +506,8 @@  discard block
 block discarded – undo
506 506
 	 *
507 507
 	 * @deprecated since 0.20.2
508 508
 	 */
509
-	public static function load_view( $template, $query = false, $status_code = 200, $tparams = false ) {
510
-		return Routes::load( $template, $tparams, $query, $status_code );
509
+	public static function load_view($template, $query = false, $status_code = 200, $tparams = false) {
510
+		return Routes::load($template, $tparams, $query, $status_code);
511 511
 	}
512 512
 
513 513
 
@@ -520,43 +520,43 @@  discard block
 block discarded – undo
520 520
 	 * @param array   $prefs
521 521
 	 * @return array mixed
522 522
 	 */
523
-	public static function get_pagination( $prefs = array() ) {
523
+	public static function get_pagination($prefs = array()) {
524 524
 		global $wp_query;
525 525
 		global $paged;
526 526
 		global $wp_rewrite;
527 527
 		$args = array();
528
-		$args['total'] = ceil( $wp_query->found_posts / $wp_query->query_vars['posts_per_page'] );
528
+		$args['total'] = ceil($wp_query->found_posts / $wp_query->query_vars['posts_per_page']);
529 529
 		if ( $wp_rewrite->using_permalinks() ) {
530
-			$url = explode( '?', get_pagenum_link( 0 ) );
531
-			if ( isset( $url[1] ) ) {
532
-				parse_str( $url[1], $query );
530
+			$url = explode('?', get_pagenum_link(0));
531
+			if ( isset($url[1]) ) {
532
+				parse_str($url[1], $query);
533 533
 				$args['add_args'] = $query;
534 534
 			}
535 535
 			$args['format'] = 'page/%#%';
536
-			$args['base'] = trailingslashit( $url[0] ).'%_%';
536
+			$args['base'] = trailingslashit($url[0]) . '%_%';
537 537
 		} else {
538 538
 			$big = 999999999;
539
-			$args['base'] = str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) );
539
+			$args['base'] = str_replace($big, '%#%', esc_url(get_pagenum_link($big)));
540 540
 		}
541 541
 		$args['type'] = 'array';
542
-		$args['current'] = max( 1, get_query_var( 'paged' ) );
543
-		$args['mid_size'] = max( 9 - $args['current'], 3 );
544
-		if ( is_int( $prefs ) ) {
542
+		$args['current'] = max(1, get_query_var('paged'));
543
+		$args['mid_size'] = max(9 - $args['current'], 3);
544
+		if ( is_int($prefs) ) {
545 545
 			$args['mid_size'] = $prefs - 2;
546 546
 		} else {
547
-			$args = array_merge( $args, $prefs );
547
+			$args = array_merge($args, $prefs);
548 548
 		}
549 549
 		$data = array();
550 550
 		$data['current'] = $args['current'];
551 551
 		$data['total'] = $args['total'];
552
-		$data['pages'] = TimberHelper::paginate_links( $args );
553
-		$next = get_next_posts_page_link( $args['total'] );
552
+		$data['pages'] = TimberHelper::paginate_links($args);
553
+		$next = get_next_posts_page_link($args['total']);
554 554
 		if ( $next ) {
555
-			$data['next'] = array( 'link' => untrailingslashit( $next ), 'class' => 'page-numbers next' );
555
+			$data['next'] = array('link' => untrailingslashit($next), 'class' => 'page-numbers next');
556 556
 		}
557
-		$prev = previous_posts( false );
557
+		$prev = previous_posts(false);
558 558
 		if ( $prev ) {
559
-			$data['prev'] = array( 'link' => untrailingslashit( $prev ), 'class' => 'page-numbers prev' );
559
+			$data['prev'] = array('link' => untrailingslashit($prev), 'class' => 'page-numbers prev');
560 560
 		}
561 561
 		if ( $paged < 2 ) {
562 562
 			$data['prev'] = '';
@@ -574,9 +574,9 @@  discard block
 block discarded – undo
574 574
 	 * @return string
575 575
 	 * @deprecated since 0.20.0
576 576
 	 */
577
-	public static function get_calling_script_path( $offset = 0 ) {
578
-		$dir = self::get_calling_script_dir( $offset );
579
-		return str_replace( ABSPATH, '', realpath( $dir ) );
577
+	public static function get_calling_script_path($offset = 0) {
578
+		$dir = self::get_calling_script_dir($offset);
579
+		return str_replace(ABSPATH, '', realpath($dir));
580 580
 	}
581 581
 
582 582
 	/**
@@ -584,10 +584,10 @@  discard block
 block discarded – undo
584 584
 	 *
585 585
 	 * @return string
586 586
 	 */
587
-	public static function get_calling_script_dir( $offset = 0 ) {
588
-		$caller = self::get_calling_script_file( $offset );
589
-		if ( !is_null( $caller ) ) {
590
-			$pathinfo = pathinfo( $caller );
587
+	public static function get_calling_script_dir($offset = 0) {
588
+		$caller = self::get_calling_script_file($offset);
589
+		if ( !is_null($caller) ) {
590
+			$pathinfo = pathinfo($caller);
591 591
 			$dir = $pathinfo['dirname'];
592 592
 			return $dir;
593 593
 		}
@@ -600,11 +600,11 @@  discard block
 block discarded – undo
600 600
 	 * @return string|null
601 601
 	 * @deprecated since 0.20.0
602 602
 	 */
603
-	public static function get_calling_script_file( $offset = 0 ) {
603
+	public static function get_calling_script_file($offset = 0) {
604 604
 		$caller = null;
605 605
 		$backtrace = debug_backtrace();
606 606
 		$i = 0;
607
-		foreach ( $backtrace as $trace ) {
607
+		foreach ($backtrace as $trace) {
608 608
 			if ( $trace['file'] != __FILE__ ) {
609 609
 				$caller = $trace['file'];
610 610
 				break;
@@ -624,8 +624,8 @@  discard block
 block discarded – undo
624 624
 	 * @return bool
625 625
 	 * @deprecated since 0.20.0
626 626
 	 */
627
-	public static function is_post_class_or_class_map( $args ) {
628
-		return TimberPostGetter::is_post_class_or_class_map( $args );
627
+	public static function is_post_class_or_class_map($args) {
628
+		return TimberPostGetter::is_post_class_or_class_map($args);
629 629
 	}
630 630
 
631 631
 }
Please login to merge, or discard this patch.
lib/cache/KeyGenerator.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -11,16 +11,16 @@
 block discarded – undo
11 11
 	 * @return string
12 12
 	 */
13 13
 	public function generateKey($value) {
14
-		if (is_a($value, 'TimberKeyGeneratorInterface')) {
14
+		if ( is_a($value, 'TimberKeyGeneratorInterface') ) {
15 15
 			return $value->_get_cache_key();
16 16
 		}
17 17
 
18
-		if (is_array($value) && isset($value['_cache_key'])) {
18
+		if ( is_array($value) && isset($value['_cache_key']) ) {
19 19
 			return $value['_cache_key'];
20 20
 		}
21 21
 
22 22
 		$key = md5(json_encode($value));
23
-		if (is_object($value)) {
23
+		if ( is_object($value) ) {
24 24
 			$key = get_class($value) . '|' . $key;
25 25
 		}
26 26
 
Please login to merge, or discard this patch.
lib/image/timber-image-operation-letterbox.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 *                    (ex: my-awesome-pic-lbox-300x200-FF3366.jpg) 
31 31
 	 */
32 32
 	public function filename($src_filename, $src_extension) {
33
-		$color = str_replace( '#', '', $this->color );
33
+		$color = str_replace('#', '', $this->color);
34 34
 		$newbase = $src_filename . '-lbox-' . $this->w . 'x' . $this->h . '-' . $color;
35 35
 		$new_name = $newbase . '.' . $src_extension;
36 36
 		return $new_name;
@@ -50,12 +50,12 @@  discard block
 block discarded – undo
50 50
 		$w = $this->w;
51 51
 		$h = $this->h;
52 52
 
53
-		$bg = imagecreatetruecolor( $w, $h );
54
-		$c = self::hexrgb( $this->color );
55
-		$bgColor = imagecolorallocate( $bg, $c['red'], $c['green'], $c['blue'] );
56
-		imagefill( $bg, 0, 0, $bgColor );
57
-		$image = wp_get_image_editor( $load_filename );
58
-		if ( !is_wp_error( $image ) ) {
53
+		$bg = imagecreatetruecolor($w, $h);
54
+		$c = self::hexrgb($this->color);
55
+		$bgColor = imagecolorallocate($bg, $c['red'], $c['green'], $c['blue']);
56
+		imagefill($bg, 0, 0, $bgColor);
57
+		$image = wp_get_image_editor($load_filename);
58
+		if ( !is_wp_error($image) ) {
59 59
 			$current_size = $image->get_size();
60 60
 			$quality = $image->get_quality();
61 61
 			$ow = $current_size['width'];
@@ -69,29 +69,29 @@  discard block
 block discarded – undo
69 69
 				$y = 0;
70 70
 				$x = $w / 2 - $owt / 2;
71 71
 				$oht = $h;
72
-				$image->crop( 0, 0, $ow, $oh, $owt, $oht );
72
+				$image->crop(0, 0, $ow, $oh, $owt, $oht);
73 73
 			} else {
74 74
 				$w_scale = $w / $ow;
75 75
 				$oht = $oh * $w_scale;
76 76
 				$x = 0;
77 77
 				$y = $h / 2 - $oht / 2;
78 78
 				$owt = $w;
79
-				$image->crop( 0, 0, $ow, $oh, $owt, $oht );
79
+				$image->crop(0, 0, $ow, $oh, $owt, $oht);
80 80
 			}
81
-			$image->save( $save_filename );
81
+			$image->save($save_filename);
82 82
 			$func = 'imagecreatefromjpeg';
83
-			$ext = pathinfo( $save_filename, PATHINFO_EXTENSION );
83
+			$ext = pathinfo($save_filename, PATHINFO_EXTENSION);
84 84
 			if ( $ext == 'gif' ) {
85 85
 				$func = 'imagecreatefromgif';
86 86
 			} else if ( $ext == 'png' ) {
87 87
 				$func = 'imagecreatefrompng';
88 88
 			}
89
-			$image = $func( $save_filename );
90
-			imagecopy( $bg, $image, $x, $y, 0, 0, $owt, $oht );
91
-			imagejpeg( $bg, $save_filename, $quality );
89
+			$image = $func($save_filename);
90
+			imagecopy($bg, $image, $x, $y, 0, 0, $owt, $oht);
91
+			imagejpeg($bg, $save_filename, $quality);
92 92
 			return true;
93 93
 		} else {
94
-			TimberHelper::error_log( $image );
94
+			TimberHelper::error_log($image);
95 95
 		}
96 96
 		return false;
97 97
 	}
Please login to merge, or discard this patch.
lib/image/timber-image-operation-retina.php 3 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@
 block discarded – undo
44 44
      *                               (ex: /src/var/www/wp-content/uploads/[email protected])
45 45
      * @return bool                  true if everything went fine, false otherwise
46 46
      */
47
-    function run($load_filename, $save_filename){
47
+    function run($load_filename, $save_filename) {
48 48
         $image = wp_get_image_editor( $load_filename );
49 49
         if ( !is_wp_error( $image ) ) {
50 50
             $current_size = $image->get_size();
Please login to merge, or discard this patch.
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Contains the class for running image retina-izing operations
4
- */
3
+	 * Contains the class for running image retina-izing operations
4
+	 */
5 5
 
6 6
 /**
7 7
  * Increases image size by a given factor
@@ -11,64 +11,64 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class TimberImageOperationRetina extends TimberImageOperation {
13 13
 
14
-    private $factor;
14
+	private $factor;
15 15
 
16
-    /**
17
-     * Construct our operation
18
-     * @param float   $factor to multiply original dimensions by
19
-     */
20
-    function __construct($factor) {
21
-        $this->factor = $factor;
22
-    }
16
+	/**
17
+	 * Construct our operation
18
+	 * @param float   $factor to multiply original dimensions by
19
+	 */
20
+	function __construct($factor) {
21
+		$this->factor = $factor;
22
+	}
23 23
 
24
-    /**
25
-     * Generates the final filename based on the source's name and extension
26
-     *
27
-     * @param   string    $src_filename     the basename of the file (ex: my-awesome-pic)
28
-     * @param   string    $src_extension    the extension (ex: .jpg)
29
-     * @return  string    the final filename to be used (ex: [email protected])
30
-     */
31
-    function filename($src_filename, $src_extension) {
32
-        $newbase = $src_filename . '@' . $this->factor . 'x'; // add @2x, @3x, @1.5x, etc.
33
-        $new_name = $newbase . '.' . $src_extension;
34
-        return $new_name;
35
-    }
24
+	/**
25
+	 * Generates the final filename based on the source's name and extension
26
+	 *
27
+	 * @param   string    $src_filename     the basename of the file (ex: my-awesome-pic)
28
+	 * @param   string    $src_extension    the extension (ex: .jpg)
29
+	 * @return  string    the final filename to be used (ex: [email protected])
30
+	 */
31
+	function filename($src_filename, $src_extension) {
32
+		$newbase = $src_filename . '@' . $this->factor . 'x'; // add @2x, @3x, @1.5x, etc.
33
+		$new_name = $newbase . '.' . $src_extension;
34
+		return $new_name;
35
+	}
36 36
 
37
-    /**
38
-     * Performs the actual image manipulation,
39
-     * including saving the target file.
40
-     *
41
-     * @param  string $load_filename filepath (not URL) to source file
42
-     *                               (ex: /src/var/www/wp-content/uploads/my-pic.jpg)
43
-     * @param  string $save_filename filepath (not URL) where result file should be saved
44
-     *                               (ex: /src/var/www/wp-content/uploads/[email protected])
45
-     * @return bool                  true if everything went fine, false otherwise
46
-     */
47
-    function run($load_filename, $save_filename){
48
-        $image = wp_get_image_editor( $load_filename );
49
-        if ( !is_wp_error( $image ) ) {
50
-            $current_size = $image->get_size();
51
-            $src_w = $current_size['width'];
52
-            $src_h = $current_size['height'];
53
-            // Get ratios
54
-            $w = $src_w * $this->factor;
55
-            $h = $src_h * $this->factor;
56
-            $image->crop( 0, 0, $src_w, $src_h, $w, $h );
57
-            $result = $image->save( $save_filename );
58
-            if ( is_wp_error( $result ) ) {
59
-            	// @codeCoverageIgnoreStart
37
+	/**
38
+	 * Performs the actual image manipulation,
39
+	 * including saving the target file.
40
+	 *
41
+	 * @param  string $load_filename filepath (not URL) to source file
42
+	 *                               (ex: /src/var/www/wp-content/uploads/my-pic.jpg)
43
+	 * @param  string $save_filename filepath (not URL) where result file should be saved
44
+	 *                               (ex: /src/var/www/wp-content/uploads/[email protected])
45
+	 * @return bool                  true if everything went fine, false otherwise
46
+	 */
47
+	function run($load_filename, $save_filename){
48
+		$image = wp_get_image_editor( $load_filename );
49
+		if ( !is_wp_error( $image ) ) {
50
+			$current_size = $image->get_size();
51
+			$src_w = $current_size['width'];
52
+			$src_h = $current_size['height'];
53
+			// Get ratios
54
+			$w = $src_w * $this->factor;
55
+			$h = $src_h * $this->factor;
56
+			$image->crop( 0, 0, $src_w, $src_h, $w, $h );
57
+			$result = $image->save( $save_filename );
58
+			if ( is_wp_error( $result ) ) {
59
+				// @codeCoverageIgnoreStart
60 60
 				TimberHelper::error_log( 'Error resizing image' );
61 61
 				TimberHelper::error_log( $result );
62 62
 				return false;
63 63
 				// @codeCoverageIgnoreEnd
64
-            } else {
65
-                return true;
66
-            }
67
-        } else if ( isset( $image->error_data['error_loading_image'] ) ) {
68
-            TimberHelper::error_log( 'Error loading ' . $image->error_data['error_loading_image'] );
69
-        } else {
70
-            TimberHelper::error_log( $image );
71
-        }
72
-        return false;
73
-    }
64
+			} else {
65
+				return true;
66
+			}
67
+		} else if ( isset( $image->error_data['error_loading_image'] ) ) {
68
+			TimberHelper::error_log( 'Error loading ' . $image->error_data['error_loading_image'] );
69
+		} else {
70
+			TimberHelper::error_log( $image );
71
+		}
72
+		return false;
73
+	}
74 74
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -44,30 +44,30 @@
 block discarded – undo
44 44
      *                               (ex: /src/var/www/wp-content/uploads/[email protected])
45 45
      * @return bool                  true if everything went fine, false otherwise
46 46
      */
47
-    function run($load_filename, $save_filename){
48
-        $image = wp_get_image_editor( $load_filename );
49
-        if ( !is_wp_error( $image ) ) {
47
+    function run($load_filename, $save_filename) {
48
+        $image = wp_get_image_editor($load_filename);
49
+        if ( !is_wp_error($image) ) {
50 50
             $current_size = $image->get_size();
51 51
             $src_w = $current_size['width'];
52 52
             $src_h = $current_size['height'];
53 53
             // Get ratios
54 54
             $w = $src_w * $this->factor;
55 55
             $h = $src_h * $this->factor;
56
-            $image->crop( 0, 0, $src_w, $src_h, $w, $h );
57
-            $result = $image->save( $save_filename );
58
-            if ( is_wp_error( $result ) ) {
56
+            $image->crop(0, 0, $src_w, $src_h, $w, $h);
57
+            $result = $image->save($save_filename);
58
+            if ( is_wp_error($result) ) {
59 59
             	// @codeCoverageIgnoreStart
60
-				TimberHelper::error_log( 'Error resizing image' );
61
-				TimberHelper::error_log( $result );
60
+				TimberHelper::error_log('Error resizing image');
61
+				TimberHelper::error_log($result);
62 62
 				return false;
63 63
 				// @codeCoverageIgnoreEnd
64 64
             } else {
65 65
                 return true;
66 66
             }
67
-        } else if ( isset( $image->error_data['error_loading_image'] ) ) {
68
-            TimberHelper::error_log( 'Error loading ' . $image->error_data['error_loading_image'] );
67
+        } else if ( isset($image->error_data['error_loading_image']) ) {
68
+            TimberHelper::error_log('Error loading ' . $image->error_data['error_loading_image']);
69 69
         } else {
70
-            TimberHelper::error_log( $image );
70
+            TimberHelper::error_log($image);
71 71
         }
72 72
         return false;
73 73
     }
Please login to merge, or discard this patch.
lib/image/timber-image-operation.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Each image filter is represented by a subclass of this class,m
4
- * and each filter call is a new instance, with call arguments as properties.
5
- * 
6
- * Only 3 methods need to be implemented:
7
- * - constructor, storing all filter arguments
8
- * - filename
9
- * - run
10
- */
3
+	 * Each image filter is represented by a subclass of this class,m
4
+	 * and each filter call is a new instance, with call arguments as properties.
5
+	 * 
6
+	 * Only 3 methods need to be implemented:
7
+	 * - constructor, storing all filter arguments
8
+	 * - filename
9
+	 * - run
10
+	 */
11 11
 abstract class TimberImageOperation {
12 12
 	/**
13 13
 	 * Builds the result filename, based on source filename and extension
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -36,14 +36,14 @@
 block discarded – undo
36 36
 	 * @return array          array('red', 'green', 'blue') to int
37 37
 	 *                        ex: array('red' => 255, 'green' => 20, 'blue' => 85);
38 38
 	 */
39
-	public static function hexrgb( $hexstr ) {
40
-		if ( !strstr( $hexstr, '#' ) ) {
39
+	public static function hexrgb($hexstr) {
40
+		if ( !strstr($hexstr, '#') ) {
41 41
 			$hexstr = '#' . $hexstr;
42 42
 		}
43
-		if ( strlen( $hexstr ) == 4 ) {
43
+		if ( strlen($hexstr) == 4 ) {
44 44
 			$hexstr = '#' . $hexstr[1] . $hexstr[1] . $hexstr[2] . $hexstr[2] . $hexstr[3] . $hexstr[3];
45 45
 		}
46
-		$int = hexdec( $hexstr );
47
-		return array( "red" => 0xFF & ( $int >> 0x10 ), "green" => 0xFF & ( $int >> 0x8 ), "blue" => 0xFF & $int );
46
+		$int = hexdec($hexstr);
47
+		return array("red" => 0xFF & ($int >> 0x10), "green" => 0xFF & ($int >> 0x8), "blue" => 0xFF & $int);
48 48
 	}
49 49
 }
50 50
\ No newline at end of file
Please login to merge, or discard this patch.
lib/integrations/acf-timber.php 2 patches
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -2,57 +2,57 @@
 block discarded – undo
2 2
 
3 3
 class ACFTimber {
4 4
 
5
-    function __construct() {
6
-        add_filter( 'timber_post_get_meta', array( $this, 'post_get_meta' ), 10, 2 );
7
-        add_filter( 'timber_post_get_meta_field', array( $this, 'post_get_meta_field' ), 10, 3 );
8
-        add_filter( 'timber_term_get_meta', array( $this, 'term_get_meta' ), 10, 3 );
9
-        add_filter( 'timber_term_get_meta_field', array( $this, 'term_get_meta_field' ), 10, 4 );
10
-        add_filter( 'timber_user_get_meta_field_pre', array( $this, 'user_get_meta_field' ), 10, 3 );
11
-        add_filter( 'timber_term_set_meta', array( $this, 'term_set_meta'), 10, 4 );
12
-    }
13
-
14
-    function post_get_meta( $customs, $post_id ) {
15
-        return $customs;
16
-    }
17
-
18
-    function post_get_meta_field( $value, $post_id, $field_name ) {
19
-        return get_field( $field_name, $post_id );
20
-    }
21
-
22
-    function term_get_meta_field( $value, $term_id, $field_name, $term ) {
23
-        $searcher = $term->taxonomy . "_" . $term->ID;
24
-        return get_field( $field_name, $searcher );
25
-    }
26
-
27
-    function term_set_meta( $value, $field, $term_id, $term ) {
28
-        $searcher = $term->taxonomy . "_" . $term->ID;
29
-        update_field( $field, $value, $searcher );
30
-        return $value;
31
-    }
32
-
33
-    function term_get_meta( $fields, $term_id, $term ) {
34
-        $searcher = $term->taxonomy . "_" . $term->ID; // save to a specific category
35
-        $fds = get_fields( $searcher );
36
-        if ( is_array( $fds ) ) {
37
-            foreach ( $fds as $key => $value ) {
38
-                $key = preg_replace( '/_/', '', $key, 1 );
39
-                $key = str_replace( $searcher, '', $key );
40
-                $key = preg_replace( '/_/', '', $key, 1 );
41
-                $field = get_field( $key, $searcher );
42
-                $fields[$key] = $field;
43
-            }
44
-            $fields = array_merge( $fields, $fds );
45
-        }
46
-        return $fields;
47
-    }
48
-
49
-    function user_get_meta( $fields, $user_id ) {
50
-        return $fields;
51
-    }
52
-
53
-    function user_get_meta_field( $value, $uid, $field ) {
54
-        return get_field( $field, 'user_' . $uid );
55
-    }
5
+	function __construct() {
6
+		add_filter( 'timber_post_get_meta', array( $this, 'post_get_meta' ), 10, 2 );
7
+		add_filter( 'timber_post_get_meta_field', array( $this, 'post_get_meta_field' ), 10, 3 );
8
+		add_filter( 'timber_term_get_meta', array( $this, 'term_get_meta' ), 10, 3 );
9
+		add_filter( 'timber_term_get_meta_field', array( $this, 'term_get_meta_field' ), 10, 4 );
10
+		add_filter( 'timber_user_get_meta_field_pre', array( $this, 'user_get_meta_field' ), 10, 3 );
11
+		add_filter( 'timber_term_set_meta', array( $this, 'term_set_meta'), 10, 4 );
12
+	}
13
+
14
+	function post_get_meta( $customs, $post_id ) {
15
+		return $customs;
16
+	}
17
+
18
+	function post_get_meta_field( $value, $post_id, $field_name ) {
19
+		return get_field( $field_name, $post_id );
20
+	}
21
+
22
+	function term_get_meta_field( $value, $term_id, $field_name, $term ) {
23
+		$searcher = $term->taxonomy . "_" . $term->ID;
24
+		return get_field( $field_name, $searcher );
25
+	}
26
+
27
+	function term_set_meta( $value, $field, $term_id, $term ) {
28
+		$searcher = $term->taxonomy . "_" . $term->ID;
29
+		update_field( $field, $value, $searcher );
30
+		return $value;
31
+	}
32
+
33
+	function term_get_meta( $fields, $term_id, $term ) {
34
+		$searcher = $term->taxonomy . "_" . $term->ID; // save to a specific category
35
+		$fds = get_fields( $searcher );
36
+		if ( is_array( $fds ) ) {
37
+			foreach ( $fds as $key => $value ) {
38
+				$key = preg_replace( '/_/', '', $key, 1 );
39
+				$key = str_replace( $searcher, '', $key );
40
+				$key = preg_replace( '/_/', '', $key, 1 );
41
+				$field = get_field( $key, $searcher );
42
+				$fields[$key] = $field;
43
+			}
44
+			$fields = array_merge( $fields, $fds );
45
+		}
46
+		return $fields;
47
+	}
48
+
49
+	function user_get_meta( $fields, $user_id ) {
50
+		return $fields;
51
+	}
52
+
53
+	function user_get_meta_field( $value, $uid, $field ) {
54
+		return get_field( $field, 'user_' . $uid );
55
+	}
56 56
 }
57 57
 
58 58
 
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -3,55 +3,55 @@
 block discarded – undo
3 3
 class ACFTimber {
4 4
 
5 5
     function __construct() {
6
-        add_filter( 'timber_post_get_meta', array( $this, 'post_get_meta' ), 10, 2 );
7
-        add_filter( 'timber_post_get_meta_field', array( $this, 'post_get_meta_field' ), 10, 3 );
8
-        add_filter( 'timber_term_get_meta', array( $this, 'term_get_meta' ), 10, 3 );
9
-        add_filter( 'timber_term_get_meta_field', array( $this, 'term_get_meta_field' ), 10, 4 );
10
-        add_filter( 'timber_user_get_meta_field_pre', array( $this, 'user_get_meta_field' ), 10, 3 );
11
-        add_filter( 'timber_term_set_meta', array( $this, 'term_set_meta'), 10, 4 );
6
+        add_filter('timber_post_get_meta', array($this, 'post_get_meta'), 10, 2);
7
+        add_filter('timber_post_get_meta_field', array($this, 'post_get_meta_field'), 10, 3);
8
+        add_filter('timber_term_get_meta', array($this, 'term_get_meta'), 10, 3);
9
+        add_filter('timber_term_get_meta_field', array($this, 'term_get_meta_field'), 10, 4);
10
+        add_filter('timber_user_get_meta_field_pre', array($this, 'user_get_meta_field'), 10, 3);
11
+        add_filter('timber_term_set_meta', array($this, 'term_set_meta'), 10, 4);
12 12
     }
13 13
 
14
-    function post_get_meta( $customs, $post_id ) {
14
+    function post_get_meta($customs, $post_id) {
15 15
         return $customs;
16 16
     }
17 17
 
18
-    function post_get_meta_field( $value, $post_id, $field_name ) {
19
-        return get_field( $field_name, $post_id );
18
+    function post_get_meta_field($value, $post_id, $field_name) {
19
+        return get_field($field_name, $post_id);
20 20
     }
21 21
 
22
-    function term_get_meta_field( $value, $term_id, $field_name, $term ) {
22
+    function term_get_meta_field($value, $term_id, $field_name, $term) {
23 23
         $searcher = $term->taxonomy . "_" . $term->ID;
24
-        return get_field( $field_name, $searcher );
24
+        return get_field($field_name, $searcher);
25 25
     }
26 26
 
27
-    function term_set_meta( $value, $field, $term_id, $term ) {
27
+    function term_set_meta($value, $field, $term_id, $term) {
28 28
         $searcher = $term->taxonomy . "_" . $term->ID;
29
-        update_field( $field, $value, $searcher );
29
+        update_field($field, $value, $searcher);
30 30
         return $value;
31 31
     }
32 32
 
33
-    function term_get_meta( $fields, $term_id, $term ) {
33
+    function term_get_meta($fields, $term_id, $term) {
34 34
         $searcher = $term->taxonomy . "_" . $term->ID; // save to a specific category
35
-        $fds = get_fields( $searcher );
36
-        if ( is_array( $fds ) ) {
37
-            foreach ( $fds as $key => $value ) {
38
-                $key = preg_replace( '/_/', '', $key, 1 );
39
-                $key = str_replace( $searcher, '', $key );
40
-                $key = preg_replace( '/_/', '', $key, 1 );
41
-                $field = get_field( $key, $searcher );
35
+        $fds = get_fields($searcher);
36
+        if ( is_array($fds) ) {
37
+            foreach ($fds as $key => $value) {
38
+                $key = preg_replace('/_/', '', $key, 1);
39
+                $key = str_replace($searcher, '', $key);
40
+                $key = preg_replace('/_/', '', $key, 1);
41
+                $field = get_field($key, $searcher);
42 42
                 $fields[$key] = $field;
43 43
             }
44
-            $fields = array_merge( $fields, $fds );
44
+            $fields = array_merge($fields, $fds);
45 45
         }
46 46
         return $fields;
47 47
     }
48 48
 
49
-    function user_get_meta( $fields, $user_id ) {
49
+    function user_get_meta($fields, $user_id) {
50 50
         return $fields;
51 51
     }
52 52
 
53
-    function user_get_meta_field( $value, $uid, $field ) {
54
-        return get_field( $field, 'user_' . $uid );
53
+    function user_get_meta_field($value, $uid, $field) {
54
+        return get_field($field, 'user_' . $uid);
55 55
     }
56 56
 }
57 57
 
Please login to merge, or discard this patch.
lib/integrations/timber-command.php 3 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -6,31 +6,31 @@
 block discarded – undo
6 6
  */
7 7
 class TimberCommand {
8 8
 
9
-    public static function clear_cache($mode = 'all'){
10
-        if (is_array($mode)){
11
-            $mode = reset($mode);
12
-        }
13
-        if ($mode == 'all') {
14
-            $twig_cache = self::clear_cache_twig();
15
-            $timber_cache = self::clear_cache_timber();
16
-            if ($twig_cache && $timber_cache){
17
-                return true;
18
-            }
19
-        } else if ($mode == 'twig') {
20
-            return self::clear_cache_twig();
21
-        } else if ($mode == 'timber') {
22
-            return self::clear_cache_timber();
23
-        }
24
-    }
9
+	public static function clear_cache($mode = 'all'){
10
+		if (is_array($mode)){
11
+			$mode = reset($mode);
12
+		}
13
+		if ($mode == 'all') {
14
+			$twig_cache = self::clear_cache_twig();
15
+			$timber_cache = self::clear_cache_timber();
16
+			if ($twig_cache && $timber_cache){
17
+				return true;
18
+			}
19
+		} else if ($mode == 'twig') {
20
+			return self::clear_cache_twig();
21
+		} else if ($mode == 'timber') {
22
+			return self::clear_cache_timber();
23
+		}
24
+	}
25 25
 
26
-    static function clear_cache_timber(){
27
-        $loader = new TimberLoader();
28
-        return $loader->clear_cache_timber();
29
-    }
26
+	static function clear_cache_timber(){
27
+		$loader = new TimberLoader();
28
+		return $loader->clear_cache_timber();
29
+	}
30 30
 
31
-    static function clear_cache_twig(){
32
-        $loader = new TimberLoader();
33
-        return $loader->clear_cache_twig();
34
-    }
31
+	static function clear_cache_twig(){
32
+		$loader = new TimberLoader();
33
+		return $loader->clear_cache_twig();
34
+	}
35 35
 
36 36
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -6,29 +6,29 @@
 block discarded – undo
6 6
  */
7 7
 class TimberCommand {
8 8
 
9
-    public static function clear_cache($mode = 'all'){
10
-        if (is_array($mode)){
9
+    public static function clear_cache($mode = 'all') {
10
+        if ( is_array($mode) ) {
11 11
             $mode = reset($mode);
12 12
         }
13
-        if ($mode == 'all') {
13
+        if ( $mode == 'all' ) {
14 14
             $twig_cache = self::clear_cache_twig();
15 15
             $timber_cache = self::clear_cache_timber();
16
-            if ($twig_cache && $timber_cache){
16
+            if ( $twig_cache && $timber_cache ) {
17 17
                 return true;
18 18
             }
19
-        } else if ($mode == 'twig') {
19
+        } else if ( $mode == 'twig' ) {
20 20
             return self::clear_cache_twig();
21
-        } else if ($mode == 'timber') {
21
+        } else if ( $mode == 'timber' ) {
22 22
             return self::clear_cache_timber();
23 23
         }
24 24
     }
25 25
 
26
-    static function clear_cache_timber(){
26
+    static function clear_cache_timber() {
27 27
         $loader = new TimberLoader();
28 28
         return $loader->clear_cache_timber();
29 29
     }
30 30
 
31
-    static function clear_cache_twig(){
31
+    static function clear_cache_twig() {
32 32
         $loader = new TimberLoader();
33 33
         return $loader->clear_cache_twig();
34 34
     }
Please login to merge, or discard this patch.
Braces   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -6,14 +6,14 @@  discard block
 block discarded – undo
6 6
  */
7 7
 class TimberCommand {
8 8
 
9
-    public static function clear_cache($mode = 'all'){
10
-        if (is_array($mode)){
9
+    public static function clear_cache($mode = 'all') {
10
+        if (is_array($mode)) {
11 11
             $mode = reset($mode);
12 12
         }
13 13
         if ($mode == 'all') {
14 14
             $twig_cache = self::clear_cache_twig();
15 15
             $timber_cache = self::clear_cache_timber();
16
-            if ($twig_cache && $timber_cache){
16
+            if ($twig_cache && $timber_cache) {
17 17
                 return true;
18 18
             }
19 19
         } else if ($mode == 'twig') {
@@ -23,12 +23,12 @@  discard block
 block discarded – undo
23 23
         }
24 24
     }
25 25
 
26
-    static function clear_cache_timber(){
26
+    static function clear_cache_timber() {
27 27
         $loader = new TimberLoader();
28 28
         return $loader->clear_cache_timber();
29 29
     }
30 30
 
31
-    static function clear_cache_twig(){
31
+    static function clear_cache_twig() {
32 32
         $loader = new TimberLoader();
33 33
         return $loader->clear_cache_twig();
34 34
     }
Please login to merge, or discard this patch.
lib/integrations/wpcli-timber.php 3 patches
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -5,53 +5,53 @@
 block discarded – undo
5 5
 
6 6
 class Timber_WP_CLI_Command extends WP_CLI_Command {
7 7
 
8
-    /**
9
-     * Clears Timber and Twig's Cache
10
-     *
11
-     * ## EXAMPLES
12
-     *
13
-     *    wp timber clear_cache
14
-     *
15
-     */
16
-    public function clear_cache($mode = 'all') {
17
-        TimberCommand::clear_cache($mode);
18
-    }
8
+	/**
9
+	 * Clears Timber and Twig's Cache
10
+	 *
11
+	 * ## EXAMPLES
12
+	 *
13
+	 *    wp timber clear_cache
14
+	 *
15
+	 */
16
+	public function clear_cache($mode = 'all') {
17
+		TimberCommand::clear_cache($mode);
18
+	}
19 19
 
20
-    /**
21
-     * Clears Twig's Cache
22
-     *
23
-     * ## EXAMPLES
24
-     *
25
-     *    wp timber clear_cache_twig
26
-     *
27
-     */
28
-    function clear_cache_twig(){
29
-        $clear = TimberCommand::clear_cache_twig();
30
-        if ($clear){
31
-            WP_CLI::success('Cleared contents of twig cache');
32
-        } else {
33
-            WP_CLI::warning('Failed to clear twig cache');
34
-        }
35
-    }
20
+	/**
21
+	 * Clears Twig's Cache
22
+	 *
23
+	 * ## EXAMPLES
24
+	 *
25
+	 *    wp timber clear_cache_twig
26
+	 *
27
+	 */
28
+	function clear_cache_twig(){
29
+		$clear = TimberCommand::clear_cache_twig();
30
+		if ($clear){
31
+			WP_CLI::success('Cleared contents of twig cache');
32
+		} else {
33
+			WP_CLI::warning('Failed to clear twig cache');
34
+		}
35
+	}
36 36
 
37
-    /**
38
-     * Clears Timber's Cache
39
-     *
40
-     * ## EXAMPLES
41
-     *
42
-     *    wp timber clear_cache_timber
43
-     *
44
-     */
45
-    function clear_cache_timber() {
46
-        $clear = TimberCommand::clear_cache_timber();
47
-        $message = 'Failed to clear timber cache';
48
-        if ($clear){
49
-            $message = "Cleared contents of Timber's Cache";
50
-            WP_CLI::success($message);
51
-        } else {
52
-            WP_CLI::warning($message);
53
-        }
54
-        return $message;
55
-    }
37
+	/**
38
+	 * Clears Timber's Cache
39
+	 *
40
+	 * ## EXAMPLES
41
+	 *
42
+	 *    wp timber clear_cache_timber
43
+	 *
44
+	 */
45
+	function clear_cache_timber() {
46
+		$clear = TimberCommand::clear_cache_timber();
47
+		$message = 'Failed to clear timber cache';
48
+		if ($clear){
49
+			$message = "Cleared contents of Timber's Cache";
50
+			WP_CLI::success($message);
51
+		} else {
52
+			WP_CLI::warning($message);
53
+		}
54
+		return $message;
55
+	}
56 56
 
57 57
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!class_exists('WP_CLI_Command')) {
2
+if ( !class_exists('WP_CLI_Command') ) {
3 3
 	return;
4 4
 }
5 5
 
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
      *    wp timber clear_cache_twig
26 26
      *
27 27
      */
28
-    function clear_cache_twig(){
28
+    function clear_cache_twig() {
29 29
         $clear = TimberCommand::clear_cache_twig();
30
-        if ($clear){
30
+        if ( $clear ) {
31 31
             WP_CLI::success('Cleared contents of twig cache');
32 32
         } else {
33 33
             WP_CLI::warning('Failed to clear twig cache');
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
     function clear_cache_timber() {
46 46
         $clear = TimberCommand::clear_cache_timber();
47 47
         $message = 'Failed to clear timber cache';
48
-        if ($clear){
48
+        if ( $clear ) {
49 49
             $message = "Cleared contents of Timber's Cache";
50 50
             WP_CLI::success($message);
51 51
         } else {
Please login to merge, or discard this patch.
Braces   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
      *    wp timber clear_cache_twig
26 26
      *
27 27
      */
28
-    function clear_cache_twig(){
28
+    function clear_cache_twig() {
29 29
         $clear = TimberCommand::clear_cache_twig();
30
-        if ($clear){
30
+        if ($clear) {
31 31
             WP_CLI::success('Cleared contents of twig cache');
32 32
         } else {
33 33
             WP_CLI::warning('Failed to clear twig cache');
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
     function clear_cache_timber() {
46 46
         $clear = TimberCommand::clear_cache_timber();
47 47
         $message = 'Failed to clear timber cache';
48
-        if ($clear){
48
+        if ($clear) {
49 49
             $message = "Cleared contents of Timber's Cache";
50 50
             WP_CLI::success($message);
51 51
         } else {
Please login to merge, or discard this patch.