Completed
Pull Request — master (#783)
by Jared
03:14
created
lib/timber-archives.php 1 patch
Spacing   +25 added lines, -25 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,18 +91,18 @@  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) {
104
+		if ( $results ) {
105
+			foreach ((array) $results as $result) {
106 106
 				$url = get_year_link($result->year);
107 107
 				$text = sprintf('%d', $result->year);
108 108
 				$output[] = $this->get_archives_link($url, $text);
@@ -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.
lib/timber-core-interface.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -2,15 +2,15 @@
 block discarded – undo
2 2
 
3 3
 interface TimberCoreInterface {
4 4
 
5
-	public function __call( $field, $args );
5
+	public function __call($field, $args);
6 6
 
7
-	public function __get( $field );
7
+	public function __get($field);
8 8
 
9 9
 	/**
10 10
 	 * @return boolean
11 11
 	 */
12
-	public function __isset( $field );
12
+	public function __isset($field);
13 13
 
14
-	public function meta( $key );
14
+	public function meta($key);
15 15
 
16 16
 }
Please login to merge, or discard this patch.
lib/timber-core.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -11,8 +11,8 @@  discard block
 block discarded – undo
11 11
      *
12 12
      * @return boolean
13 13
      */
14
-    function __isset( $field ) {
15
-        if ( isset( $this->$field ) ) {
14
+    function __isset($field) {
15
+        if ( isset($this->$field) ) {
16 16
             return $this->$field;
17 17
         }
18 18
         return false;
@@ -22,8 +22,8 @@  discard block
 block discarded – undo
22 22
      * This is helpful for twig to return properties and methods see: https://github.com/fabpot/Twig/issues/2
23 23
      * @return mixed
24 24
      */
25
-    function __call( $field, $args ) {
26
-        return $this->__get( $field );
25
+    function __call($field, $args) {
26
+        return $this->__get($field);
27 27
     }
28 28
 
29 29
     /**
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
      *
32 32
      * @return mixed
33 33
      */
34
-    function __get( $field ) {
34
+    function __get($field) {
35 35
     	if ( property_exists($this, $field) ) {
36 36
     		return $this->$field;
37 37
     	}
38
-        if ( method_exists($this, 'meta') && $meta_value = $this->meta( $field ) ) {
38
+        if ( method_exists($this, 'meta') && $meta_value = $this->meta($field) ) {
39 39
             return $this->$field = $meta_value;
40 40
         }
41 41
         if ( method_exists($this, $field) ) {
@@ -55,15 +55,15 @@  discard block
 block discarded – undo
55 55
      * ```
56 56
      * @param array|object $info an object or array you want to grab data from to attach to the Timber object
57 57
      */
58
-    function import( $info, $force = false ) {
59
-        if ( is_object( $info ) ) {
60
-            $info = get_object_vars( $info );
58
+    function import($info, $force = false) {
59
+        if ( is_object($info) ) {
60
+            $info = get_object_vars($info);
61 61
         }
62
-        if ( is_array( $info ) ) {
63
-            foreach ( $info as $key => $value ) {
64
-                if ( !empty( $key ) && $force ) {
62
+        if ( is_array($info) ) {
63
+            foreach ($info as $key => $value) {
64
+                if ( !empty($key) && $force ) {
65 65
                     $this->$key = $value;
66
-                } else if ( !empty( $key ) && !method_exists($this, $key) ){
66
+                } else if ( !empty($key) && !method_exists($this, $key) ) {
67 67
                     $this->$key = $value;
68 68
                 }
69 69
             }
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
      * @param string  $key
77 77
      * @param mixed   $value
78 78
      */
79
-    function update( $key, $value ) {
80
-        update_metadata( $this->object_type, $this->ID, $key, $value );
79
+    function update($key, $value) {
80
+        update_metadata($this->object_type, $this->ID, $key, $value);
81 81
     }
82 82
 
83 83
     /**
@@ -94,10 +94,10 @@  discard block
 block discarded – undo
94 94
      * @return bool
95 95
      */
96 96
     function can_edit() {
97
-        if ( !function_exists( 'current_user_can' ) ) {
97
+        if ( !function_exists('current_user_can') ) {
98 98
             return false;
99 99
         }
100
-        if ( current_user_can( 'edit_post', $this->ID ) ) {
100
+        if ( current_user_can('edit_post', $this->ID) ) {
101 101
             return true;
102 102
         }
103 103
         return false;
Please login to merge, or discard this patch.
lib/timber-function-wrapper.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 	private $_use_ob;
8 8
 
9 9
 	public function __toString() {
10
-		return (string)$this->call();
10
+		return (string) $this->call();
11 11
 	}
12 12
 
13 13
 	/**
@@ -17,12 +17,12 @@  discard block
 block discarded – undo
17 17
 	 * @param array   $args
18 18
 	 * @param bool    $return_output_buffer
19 19
 	 */
20
-	public function __construct( $function, $args = array(), $return_output_buffer = false ) {
20
+	public function __construct($function, $args = array(), $return_output_buffer = false) {
21 21
 		$this->_function = $function;
22 22
 		$this->_args = $args;
23 23
 		$this->_use_ob = $return_output_buffer;
24 24
 
25
-		add_filter( 'get_twig', array( &$this, 'add_to_twig' ) );
25
+		add_filter('get_twig', array(&$this, 'add_to_twig'));
26 26
 	}
27 27
 
28 28
 	/**
@@ -31,12 +31,12 @@  discard block
 block discarded – undo
31 31
 	 * @param Twig_Environment $twig
32 32
 	 * @return Twig_Environment
33 33
 	 */
34
-	public function add_to_twig( $twig ) {
34
+	public function add_to_twig($twig) {
35 35
 		$wrapper = $this;
36 36
 
37
-		$twig->addFunction( new Twig_SimpleFunction( $this->_function, function () use ( $wrapper ) {
38
-					return call_user_func_array( array( $wrapper, 'call' ), func_get_args() );
39
-				} ) );
37
+		$twig->addFunction(new Twig_SimpleFunction($this->_function, function() use ($wrapper) {
38
+					return call_user_func_array(array($wrapper, 'call'), func_get_args());
39
+				} ));
40 40
 
41 41
 		return $twig;
42 42
 	}
@@ -47,12 +47,12 @@  discard block
 block discarded – undo
47 47
 	 * @return string
48 48
 	 */
49 49
 	public function call() {
50
-		$args = $this->_parse_args( func_get_args(), $this->_args );
50
+		$args = $this->_parse_args(func_get_args(), $this->_args);
51 51
 
52 52
 		if ( $this->_use_ob ) {
53
-			return TimberHelper::ob_function( $this->_function, $args );
53
+			return TimberHelper::ob_function($this->_function, $args);
54 54
 		} else {
55
-			return call_user_func_array( $this->_function, $args );
55
+			return call_user_func_array($this->_function, $args);
56 56
 		}
57 57
 	}
58 58
 
@@ -63,12 +63,12 @@  discard block
 block discarded – undo
63 63
 	 * @param array   $defaults
64 64
 	 * @return array
65 65
 	 */
66
-	private function _parse_args( $args, $defaults ) {
67
-		$_arg = reset( $defaults );
66
+	private function _parse_args($args, $defaults) {
67
+		$_arg = reset($defaults);
68 68
 
69
-		foreach ( $args as $index => $arg ) {
70
-			$defaults[$index] = is_null( $arg ) ? $_arg : $arg;
71
-			$_arg = next( $defaults );
69
+		foreach ($args as $index => $arg) {
70
+			$defaults[$index] = is_null($arg) ? $_arg : $arg;
71
+			$_arg = next($defaults);
72 72
 		}
73 73
 
74 74
 		return $defaults;
Please login to merge, or discard this patch.
lib/timber-image.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 * @return string the src of the file
88 88
 	 */
89 89
 	public function __toString() {
90
-		if ($this->get_src()) {
90
+		if ( $this->get_src() ) {
91 91
 			return $this->get_src();
92 92
 		}
93 93
 		return '';
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	 * @return array|int
108 108
 	 */
109 109
 	protected function get_dimensions($dim = null) {
110
-		if (isset($this->_dimensions)) {
110
+		if ( isset($this->_dimensions) ) {
111 111
 			return $this->get_dimensions_loaded($dim);
112 112
 		}
113 113
 		if ( file_exists($this->file_loc) && filesize($this->file_loc) ) {
@@ -125,13 +125,13 @@  discard block
 block discarded – undo
125 125
 	 * @return array|int
126 126
 	 */
127 127
 	protected function get_dimensions_loaded($dim) {
128
-		if ($dim === null) {
128
+		if ( $dim === null ) {
129 129
 			return $this->_dimensions;
130 130
 		}
131
-		if ($dim == 'w' || $dim == 'width') {
131
+		if ( $dim == 'w' || $dim == 'width' ) {
132 132
 			return $this->_dimensions[0];
133 133
 		}
134
-		if ($dim == 'h' || $dim == 'height') {
134
+		if ( $dim == 'h' || $dim == 'height' ) {
135 135
 			return $this->_dimensions[1];
136 136
 		}
137 137
 		return null;
@@ -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;
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 	 * @return string with http/https corrected depending on what's appropriate for server
174 174
 	 */
175 175
 	protected static function _maybe_secure_url($url) {
176
-		if (is_ssl() && strpos($url, 'https') !== 0 && strpos($url, 'http') === 0) {
176
+		if ( is_ssl() && strpos($url, 'https') !== 0 && strpos($url, 'http') === 0 ) {
177 177
 			$url = 'https' . substr($url, strlen('http'));
178 178
 		}
179 179
 		return $url;
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 	public static function wp_upload_dir() {
183 183
 		static $wp_upload_dir = false;
184 184
 
185
-		if (!$wp_upload_dir) {
185
+		if ( !$wp_upload_dir ) {
186 186
 			$wp_upload_dir = wp_upload_dir();
187 187
 		}
188 188
 
@@ -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
 			}
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 				$this->init_with_file_path($iid);
204 204
 				return;
205 205
 			}
206
-			if (strstr(strtolower($iid), '.jpg')) {
206
+			if ( strstr(strtolower($iid), '.jpg') ) {
207 207
 				$this->init_with_relative_path($iid);
208 208
 				return;
209 209
 			}
@@ -214,24 +214,24 @@  discard block
 block discarded – undo
214 214
 		$this->import($image_info);
215 215
 		$basedir = self::wp_upload_dir();
216 216
 		$basedir = $basedir['basedir'];
217
-		if (isset($this->file)) {
217
+		if ( isset($this->file) ) {
218 218
 			$this->file_loc = $basedir . DIRECTORY_SEPARATOR . $this->file;
219
-		} else if (isset($this->_wp_attached_file)) {
219
+		} else if ( isset($this->_wp_attached_file) ) {
220 220
 			$this->file = reset($this->_wp_attached_file);
221 221
 			$this->file_loc = $basedir . DIRECTORY_SEPARATOR . $this->file;
222 222
 		}
223
-		if (isset($image_info['id'])) {
223
+		if ( isset($image_info['id']) ) {
224 224
 			$this->ID = $image_info['id'];
225
-		} else if (is_numeric($iid)) {
225
+		} else if ( is_numeric($iid) ) {
226 226
 			$this->ID = $iid;
227 227
 		}
228
-		if (isset($this->ID)) {
228
+		if ( isset($this->ID) ) {
229 229
 			$custom = get_post_custom($this->ID);
230 230
 			foreach ($custom as $key => $value) {
231 231
 				$this->$key = $value[0];
232 232
 			}
233 233
 		} else {
234
-			if (is_array($iid) || is_object($iid)) {
234
+			if ( is_array($iid) || is_object($iid) ) {
235 235
 				TimberHelper::error_log('Not able to init in TimberImage with iid=');
236 236
 				TimberHelper::error_log($iid);
237 237
 			} else {
@@ -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;
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 	 */
269 269
 	protected function init_with_url($url) {
270 270
 		$this->abs_url = $url;
271
-		if (TimberURLHelper::is_local($url)) {
271
+		if ( TimberURLHelper::is_local($url) ) {
272 272
 			$this->file = ABSPATH . TimberURLHelper::get_rel_url($url);
273 273
 			$this->file_loc = ABSPATH . TimberURLHelper::get_rel_url($url);
274 274
 		}
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 	 * ```
337 337
 	 */
338 338
 	public function link() {
339
-		if (strlen($this->abs_url)) {
339
+		if ( strlen($this->abs_url) ) {
340 340
 			return $this->abs_url;
341 341
 		}
342 342
 		return get_permalink($this->ID);
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 	 * @return bool|TimberPost
348 348
 	 */
349 349
 	public function parent() {
350
-		if (!$this->post_parent) {
350
+		if ( !$this->post_parent ) {
351 351
 			return false;
352 352
 		}
353 353
 		return new $this->PostClass($this->post_parent);
@@ -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/timber-integrations.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -7,16 +7,16 @@
 block discarded – undo
7 7
 class TimberIntegrations {
8 8
     public static function init() {
9 9
 
10
-        add_action( 'init', array( __CLASS__, 'maybe_init_acftimber' ) );
10
+        add_action('init', array(__CLASS__, 'maybe_init_acftimber'));
11 11
 
12
-        if ( class_exists( 'WP_CLI_Command' ) ) {
13
-            WP_CLI::add_command( 'timber', 'Timber_WP_CLI_Command' );
12
+        if ( class_exists('WP_CLI_Command') ) {
13
+            WP_CLI::add_command('timber', 'Timber_WP_CLI_Command');
14 14
         }
15 15
     }
16 16
 
17 17
     public static function maybe_init_acftimber() {
18 18
 
19
-        if ( class_exists( 'ACF' ) ) {
19
+        if ( class_exists('ACF') ) {
20 20
             new ACFTimber();
21 21
         }
22 22
 
Please login to merge, or discard this patch.
lib/timber-menu-item.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -24,15 +24,15 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @param array|object $data
26 26
 	 */
27
-	public function __construct( $data ) {
27
+	public function __construct($data) {
28 28
 		$data = (object) $data;
29
-		$this->import( $data );
30
-		$this->import_classes( $data );
31
-		if ( isset( $this->name ) ) {
29
+		$this->import($data);
30
+		$this->import_classes($data);
31
+		if ( isset($this->name) ) {
32 32
 			$this->_name = $this->name;
33 33
 		}
34 34
 		$this->name = $this->name();
35
-		$this->add_class( 'menu-item-' . $this->ID );
35
+		$this->add_class('menu-item-' . $this->ID);
36 36
 		$this->menu_object = $data;
37 37
 	}
38 38
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	 * add a class the menu item should have
48 48
 	 * @param string  $class_name to be added
49 49
 	 */
50
-	public function add_class( $class_name ) {
50
+	public function add_class($class_name) {
51 51
 		$this->classes[] = $class_name;
52 52
 		$this->class .= ' ' . $class_name;
53 53
 	}
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 		if ( $title = $this->title() ) {
62 62
 			return $title;
63 63
 		}
64
-		if ( isset( $this->_name ) ) {
64
+		if ( isset($this->_name) ) {
65 65
 			return $this->_name;
66 66
 		}
67 67
 		return '';
@@ -82,10 +82,10 @@  discard block
 block discarded – undo
82 82
 	 * @return string the slug of the menu item kinda-like-this
83 83
 	 */
84 84
 	public function slug() {
85
-		if ( !isset( $this->master_object ) ) {
85
+		if ( !isset($this->master_object) ) {
86 86
 			$this->master_object = $this->get_master_object();
87 87
 		}
88
-		if ( isset( $this->master_object->post_name ) && $this->master_object->post_name ) {
88
+		if ( isset($this->master_object->post_name) && $this->master_object->post_name ) {
89 89
 			return $this->master_object->post_name;
90 90
 		}
91 91
 		return $this->post_name;
@@ -96,8 +96,8 @@  discard block
 block discarded – undo
96 96
 	 * @return mixed whatever object (Post, Term, etc.) the menu item represents
97 97
 	 */
98 98
 	protected function get_master_object() {
99
-		if ( isset( $this->_menu_item_object_id ) ) {
100
-			return new $this->PostClass( $this->_menu_item_object_id );
99
+		if ( isset($this->_menu_item_object_id) ) {
100
+			return new $this->PostClass($this->_menu_item_object_id);
101 101
 		}
102 102
 	}
103 103
 
@@ -107,10 +107,10 @@  discard block
 block discarded – undo
107 107
 	 * @return string an absolute URL http://example.org/my-page
108 108
 	 */
109 109
 	function get_link() {
110
-		if ( !isset( $this->url ) || !$this->url ) {
111
-			if ( isset( $this->_menu_item_type ) && $this->_menu_item_type == 'custom' ) {
110
+		if ( !isset($this->url) || !$this->url ) {
111
+			if ( isset($this->_menu_item_type) && $this->_menu_item_type == 'custom' ) {
112 112
 				$this->url = $this->_menu_item_url;
113
-			} else if ( isset( $this->menu_object ) && method_exists( $this->menu_object, 'get_link' ) ) {
113
+			} else if ( isset($this->menu_object) && method_exists($this->menu_object, 'get_link') ) {
114 114
 					$this->url = $this->menu_object->get_link();
115 115
 				}
116 116
 		}
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 	 * @return string a relative url /my-page
124 124
 	 */
125 125
 	function get_path() {
126
-		return TimberURLHelper::get_rel_url( $this->get_link() );
126
+		return TimberURLHelper::get_rel_url($this->get_link());
127 127
 	}
128 128
 
129 129
 	/**
@@ -131,17 +131,17 @@  discard block
 block discarded – undo
131 131
 	 *
132 132
 	 * @param TimberMenuItem $item
133 133
 	 */
134
-	function add_child( $item ) {
134
+	function add_child($item) {
135 135
 		if ( !$this->has_child_class ) {
136
-			$this->add_class( 'menu-item-has-children' );
136
+			$this->add_class('menu-item-has-children');
137 137
 			$this->has_child_class = true;
138 138
 		}
139
-		if ( !isset( $this->children ) ) {
139
+		if ( !isset($this->children) ) {
140 140
 			$this->children = array();
141 141
 		}
142 142
 		$this->children[] = $item;
143 143
 		$item->level = $this->level + 1;
144
-		if ($item->children) {
144
+		if ( $item->children ) {
145 145
 			$this->update_child_levels();
146 146
 		}
147 147
 	}
@@ -152,8 +152,8 @@  discard block
 block discarded – undo
152 152
 	 * @return bool 
153 153
 	 */
154 154
 	function update_child_levels() {
155
-		if (is_array($this->children)) {
156
-			foreach( $this->children as $child ) {
155
+		if ( is_array($this->children) ) {
156
+			foreach ($this->children as $child) {
157 157
 				$child->level = $this->level + 1;
158 158
 				$child->update_child_levels();
159 159
 			}
@@ -166,14 +166,14 @@  discard block
 block discarded – undo
166 166
 	 * @internal
167 167
 	 * @param array|object  $data
168 168
 	 */
169
-	function import_classes( $data ) {
169
+	function import_classes($data) {
170 170
 		if ( is_array($data) ) {
171 171
 			$data = (object) $data;
172 172
 		}
173
-		$this->classes = array_merge( $this->classes, $data->classes );
174
-		$this->classes = array_unique( $this->classes );
175
-		$this->classes = apply_filters( 'nav_menu_css_class', $this->classes, $this );
176
-		$this->class = trim( implode( ' ', $this->classes ) );
173
+		$this->classes = array_merge($this->classes, $data->classes);
174
+		$this->classes = array_unique($this->classes);
175
+		$this->classes = apply_filters('nav_menu_css_class', $this->classes, $this);
176
+		$this->class = trim(implode(' ', $this->classes));
177 177
 	}
178 178
 
179 179
 	/**
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 	 * @return array|bool
183 183
 	 */
184 184
 	function get_children() {
185
-		if ( isset( $this->children ) ) {
185
+		if ( isset($this->children) ) {
186 186
 			return $this->children;
187 187
 		}
188 188
 		return false;
@@ -201,18 +201,18 @@  discard block
 block discarded – undo
201 201
 		if ( $this->type != 'custom' ) {
202 202
 			return false;
203 203
 		}
204
-		return TimberURLHelper::is_external( $this->url );
204
+		return TimberURLHelper::is_external($this->url);
205 205
 	}
206 206
 
207 207
 	/**
208 208
 	 * @param string $key lookup key
209 209
 	 * @return mixed whatever value is storied in the database
210 210
 	 */
211
-	public function meta( $key ) {
212
-		if ( is_object( $this->menu_object ) && method_exists( $this->menu_object, 'meta' ) ) {
213
-			return $this->menu_object->meta( $key );
211
+	public function meta($key) {
212
+		if ( is_object($this->menu_object) && method_exists($this->menu_object, 'meta') ) {
213
+			return $this->menu_object->meta($key);
214 214
 		}
215
-		if ( isset( $this->$key ) ) {
215
+		if ( isset($this->$key) ) {
216 216
 			return $this->$key;
217 217
 		}
218 218
 	}
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 	 * @return string the public label like Foo
300 300
 	 */
301 301
 	public function title() {
302
-		if ( isset( $this->__title ) ) {
302
+		if ( isset($this->__title) ) {
303 303
 			return $this->__title;
304 304
 		}
305 305
 	}
Please login to merge, or discard this patch.
lib/timber-menu.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -77,16 +77,16 @@  discard block
 block discarded – undo
77 77
 	 */
78 78
 	function __construct($slug = 0) {
79 79
 		$locations = get_nav_menu_locations();
80
-		if ($slug != 0 && is_numeric($slug)) {
80
+		if ( $slug != 0 && is_numeric($slug) ) {
81 81
 			$menu_id = $slug;
82
-		} else if (is_array($locations) && count($locations)) {
82
+		} else if ( is_array($locations) && count($locations) ) {
83 83
 			$menu_id = $this->get_menu_id_from_locations($slug, $locations);
84
-		} else if ($slug === false) {
84
+		} else if ( $slug === false ) {
85 85
 			$menu_id = false;
86 86
 		} else {
87 87
 			$menu_id = $this->get_menu_id_from_terms($slug);
88 88
 		}
89
-		if ($menu_id) {
89
+		if ( $menu_id ) {
90 90
 			$this->init($menu_id);
91 91
 		} else {
92 92
 			$this->init_as_page_menu();
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
 	 */
100 100
 	protected function init($menu_id) {
101 101
 		$menu = wp_get_nav_menu_items($menu_id);
102
-		if ($menu) {
102
+		if ( $menu ) {
103 103
 			_wp_menu_item_classes_by_context($menu);
104
-			if (is_array($menu)){
104
+			if ( is_array($menu) ) {
105 105
 				$menu = self::order_children($menu);
106 106
 			}
107 107
 			$this->items = $menu;
@@ -118,12 +118,12 @@  discard block
 block discarded – undo
118 118
 	 */
119 119
 	protected function init_as_page_menu() {
120 120
 		$menu = get_pages();
121
-		if ($menu) {
122
-			foreach($menu as $mi) {
121
+		if ( $menu ) {
122
+			foreach ($menu as $mi) {
123 123
 				$mi->__title = $mi->post_title;
124 124
 			}
125 125
 			_wp_menu_item_classes_by_context($menu);
126
-			if (is_array($menu)){
126
+			if ( is_array($menu) ) {
127 127
 				$menu = self::order_children($menu);
128 128
 			}
129 129
 			$this->items = $menu;
@@ -137,13 +137,13 @@  discard block
 block discarded – undo
137 137
 	 * @return integer
138 138
 	 */
139 139
 	protected function get_menu_id_from_locations($slug, $locations) {
140
-		if ($slug === 0) {
140
+		if ( $slug === 0 ) {
141 141
 			$slug = $this->get_menu_id_from_terms($slug);
142 142
 		}
143
-		if (is_numeric($slug)) {
143
+		if ( is_numeric($slug) ) {
144 144
 			$slug = array_search($slug, $locations);
145 145
 		}
146
-		if (isset($locations[$slug])) {
146
+		if ( isset($locations[$slug]) ) {
147 147
 			return $locations[$slug];
148 148
 		}
149 149
 	}
@@ -154,20 +154,20 @@  discard block
 block discarded – undo
154 154
 	 * @return int
155 155
 	 */
156 156
 	protected function get_menu_id_from_terms($slug = 0) {
157
-		if (!is_numeric($slug) && is_string($slug)) {
157
+		if ( !is_numeric($slug) && is_string($slug) ) {
158 158
 			//we have a string so lets search for that
159 159
 			$menu_id = get_term_by('slug', $slug, 'nav_menu');
160
-			if ($menu_id) {
160
+			if ( $menu_id ) {
161 161
 				return $menu_id;
162 162
 			}
163 163
 			$menu_id = get_term_by('name', $slug, 'nav_menu');
164
-			if ($menu_id) {
164
+			if ( $menu_id ) {
165 165
 				return $menu_id;
166 166
 			}
167 167
 		}
168 168
 		$menus = get_terms('nav_menu', array('hide_empty' => true));
169
-		if (is_array($menus) && count($menus)) {
170
-			if (isset($menus[0]->term_id)) {
169
+		if ( is_array($menus) && count($menus) ) {
170
+			if ( isset($menus[0]->term_id) ) {
171 171
 				return $menus[0]->term_id;
172 172
 			}
173 173
 		}
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	 */
182 182
 	function find_parent_item_in_menu($menu_items, $parent_id) {
183 183
 		foreach ($menu_items as &$item) {
184
-			if ($item->ID == $parent_id) {
184
+			if ( $item->ID == $parent_id ) {
185 185
 				return $item;
186 186
 			}
187 187
 		}
@@ -196,25 +196,25 @@  discard block
 block discarded – undo
196 196
 		$index = array();
197 197
 		$menu = array();
198 198
 		foreach ($items as $item) {
199
-			if (isset($item->title)) {
199
+			if ( isset($item->title) ) {
200 200
 				//items from wp can come with a $title property which conflicts with methods
201 201
 				$item->__title = $item->title;
202 202
 				unset($item->title);
203 203
 			}
204
-			if(isset($item->ID)){
205
-				if (is_object($item) && get_class($item) == 'WP_Post'){
204
+			if ( isset($item->ID) ) {
205
+				if ( is_object($item) && get_class($item) == 'WP_Post' ) {
206 206
 					$old_menu_item = $item;
207 207
 					$item = new $this->PostClass($item);
208 208
 				}
209 209
 				$menu_item = new $this->MenuItemClass($item);
210
-				if (isset($old_menu_item)){
210
+				if ( isset($old_menu_item) ) {
211 211
 					$menu_item->import_classes($old_menu_item);
212 212
 				}
213 213
 				$index[$item->ID] = $menu_item;
214 214
 			}
215 215
 		}
216 216
 		foreach ($index as $item) {
217
-			if (isset($item->menu_item_parent) && $item->menu_item_parent && isset($index[$item->menu_item_parent])) {
217
+			if ( isset($item->menu_item_parent) && $item->menu_item_parent && isset($index[$item->menu_item_parent]) ) {
218 218
 				$index[$item->menu_item_parent]->add_child($item);
219 219
 			} else {
220 220
 				$menu[] = $item;
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 	 * @return array
228 228
 	 */
229 229
 	function get_items() {
230
-		if (is_array($this->items)) {
230
+		if ( is_array($this->items) ) {
231 231
 			return $this->items;
232 232
 		}
233 233
 		return array();
Please login to merge, or discard this patch.
lib/timber-post-getter.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -8,19 +8,19 @@  discard block
 block discarded – undo
8 8
 	 * @return array|bool|null
9 9
 	 */
10 10
 	static function get_post($query = false, $PostClass = 'TimberPost') {
11
-		$posts = self::get_posts( $query, $PostClass );
12
-		if ( $post = reset($posts ) ) {
11
+		$posts = self::get_posts($query, $PostClass);
12
+		if ( $post = reset($posts) ) {
13 13
 			return $post;
14 14
 		}
15 15
 	}
16 16
 
17
-	static function get_posts( $query = false, $PostClass = 'TimberPost', $return_collection = false ) {
18
-		$posts = self::query_posts( $query, $PostClass );
19
-		return apply_filters('timber_post_getter_get_posts', $posts->get_posts( $return_collection ));
17
+	static function get_posts($query = false, $PostClass = 'TimberPost', $return_collection = false) {
18
+		$posts = self::query_posts($query, $PostClass);
19
+		return apply_filters('timber_post_getter_get_posts', $posts->get_posts($return_collection));
20 20
 	}
21 21
 
22
-	static function query_post( $query = false, $PostClass = 'TimberPost' ) {
23
-		$posts = self::query_posts( $query, $PostClass );
22
+	static function query_post($query = false, $PostClass = 'TimberPost') {
23
+		$posts = self::query_posts($query, $PostClass);
24 24
 		if ( method_exists($posts, 'current') && $post = $posts->current() ) {
25 25
 			return $post;
26 26
 		}
@@ -31,32 +31,32 @@  discard block
 block discarded – undo
31 31
 	 * @param string $PostClass
32 32
 	 * @return array|bool|null
33 33
 	 */
34
-	static function query_posts($query = false, $PostClass = 'TimberPost' ) {
35
-		if (self::is_post_class_or_class_map($query)) {
34
+	static function query_posts($query = false, $PostClass = 'TimberPost') {
35
+		if ( self::is_post_class_or_class_map($query) ) {
36 36
 			$PostClass = $query;
37 37
 			$query = false;
38 38
 		}
39 39
 
40
-		if (is_object($query) && !is_a($query, 'WP_Query') ){
40
+		if ( is_object($query) && !is_a($query, 'WP_Query') ) {
41 41
 			// The only object other than a query is a type of post object
42
-			$query = array( $query );
42
+			$query = array($query);
43 43
 		}
44 44
 
45
-		if ( is_array( $query ) && count( $query ) && isset( $query[0] ) && is_object( $query[0] ) ) {
45
+		if ( is_array($query) && count($query) && isset($query[0]) && is_object($query[0]) ) {
46 46
 			// We have an array of post objects that already have data
47
-			return new TimberPostsCollection( $query, $PostClass );
47
+			return new TimberPostsCollection($query, $PostClass);
48 48
 		} else {
49 49
 			// We have a query (of sorts) to work with
50
-			$tqi = new TimberQueryIterator( $query, $PostClass );
50
+			$tqi = new TimberQueryIterator($query, $PostClass);
51 51
 			return $tqi;
52 52
 		}
53 53
 	}
54 54
 
55
-	static function get_pids($query){
55
+	static function get_pids($query) {
56 56
 		$posts = self::get_posts($query);
57 57
 		$pids = array();
58
-		foreach($posts as $post){
59
-			if (isset($post->ID)){
58
+		foreach ($posts as $post) {
59
+			if ( isset($post->ID) ) {
60 60
 				$pids[] = $post->ID;
61 61
 			}
62 62
 		}
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	}
65 65
 
66 66
 	static function loop_to_id() {
67
-		if (!self::wp_query_has_posts()) { return false; }
67
+		if ( !self::wp_query_has_posts() ) { return false; }
68 68
 
69 69
 		global $wp_query;
70 70
 		$post_num = property_exists($wp_query, 'current_post')
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 				  : 0
73 73
 				  ;
74 74
 
75
-		if (!isset($wp_query->posts[$post_num])) { return false; }
75
+		if ( !isset($wp_query->posts[$post_num]) ) { return false; }
76 76
 
77 77
 		return $wp_query->posts[$post_num]->ID;
78 78
 	}
@@ -89,13 +89,13 @@  discard block
 block discarded – undo
89 89
 	 * @param string|array $arg
90 90
 	 * @return bool
91 91
 	 */
92
-	static function is_post_class_or_class_map($arg){
93
-		if (is_string($arg) && class_exists($arg)) {
92
+	static function is_post_class_or_class_map($arg) {
93
+		if ( is_string($arg) && class_exists($arg) ) {
94 94
 			return true;
95 95
 		}
96
-		if (is_array($arg)) {
96
+		if ( is_array($arg) ) {
97 97
 			foreach ($arg as $item) {
98
-				if (is_string($item) && class_exists($item)) {
98
+				if ( is_string($item) && class_exists($item) ) {
99 99
 					return true;
100 100
 				}
101 101
 			}
Please login to merge, or discard this patch.