| @@ -176,7 +176,7 @@ discard block | ||
| 176 | 176 | * | 
| 177 | 177 | * | 
| 178 | 178 | * @param mixed $arg that you want to error_log | 
| 179 | - * @return void | |
| 179 | + * @return null|boolean | |
| 180 | 180 | */ | 
| 181 | 181 |  	public static function error_log( $arg ) { | 
| 182 | 182 |  		if ( !WP_DEBUG ) { | 
| @@ -208,7 +208,7 @@ discard block | ||
| 208 | 208 | * | 
| 209 | 209 | * @param string $text | 
| 210 | 210 | * @param int $num_words | 
| 211 | - * @param string|null|false $more text to appear in "Read more...". Null to use default, false to hide | |
| 211 | + * @param boolean $more text to appear in "Read more...". Null to use default, false to hide | |
| 212 | 212 | * @param string $allowed_tags | 
| 213 | 213 | * @return string | 
| 214 | 214 | */ | 
| @@ -48,8 +48,9 @@ | ||
| 48 | 48 | |
| 49 | 49 | // lock timeout shouldn't be higher than 5 seconds, unless | 
| 50 | 50 | // remote calls with high timeouts are made here | 
| 51 | - if ( $enable_transients ) | |
| 52 | - self::_lock_transient( $slug, $lock_timeout ); | |
| 51 | +			if ( $enable_transients ) { | |
| 52 | + self::_lock_transient( $slug, $lock_timeout ); | |
| 53 | + } | |
| 53 | 54 | |
| 54 | 55 | $data = $callback(); | 
| 55 | 56 | |
| @@ -25,18 +25,18 @@ discard block | ||
| 25 | 25 | * @param bool $force (optional) Force callback to be executed when transient is locked | 
| 26 | 26 | * @return mixed | 
| 27 | 27 | */ | 
| 28 | -	public static function transient( $slug, $callback, $transient_time = 0, $lock_timeout = 5, $force = false ) { | |
| 29 | - $slug = apply_filters( 'timber/transient/slug', $slug ); | |
| 28 | +	public static function transient($slug, $callback, $transient_time = 0, $lock_timeout = 5, $force = false) { | |
| 29 | +		$slug = apply_filters('timber/transient/slug', $slug); | |
| 30 | 30 | |
| 31 | - $enable_transients = ( $transient_time === false || ( defined( 'WP_DISABLE_TRANSIENTS' ) && WP_DISABLE_TRANSIENTS ) ) ? false : true; | |
| 32 | - $data = $enable_transients ? get_transient( $slug ) : false; | |
| 31 | +		$enable_transients = ($transient_time === false || (defined('WP_DISABLE_TRANSIENTS') && WP_DISABLE_TRANSIENTS)) ? false : true; | |
| 32 | + $data = $enable_transients ? get_transient($slug) : false; | |
| 33 | 33 | |
| 34 | 34 |  		if ( false === $data ) { | 
| 35 | 35 | |
| 36 | -			if ( $enable_transients && self::_is_transient_locked( $slug ) ) { | |
| 36 | +			if ( $enable_transients && self::_is_transient_locked($slug) ) { | |
| 37 | 37 | |
| 38 | - $force = apply_filters( 'timber_force_transients', $force ); | |
| 39 | - $force = apply_filters( 'timber_force_transient_' . $slug, $force ); | |
| 38 | +				$force = apply_filters('timber_force_transients', $force); | |
| 39 | +				$force = apply_filters('timber_force_transient_' . $slug, $force); | |
| 40 | 40 | |
| 41 | 41 |  				if ( !$force ) { | 
| 42 | 42 | //the server is currently executing the process. | 
| @@ -50,13 +50,13 @@ discard block | ||
| 50 | 50 | // lock timeout shouldn't be higher than 5 seconds, unless | 
| 51 | 51 | // remote calls with high timeouts are made here | 
| 52 | 52 | if ( $enable_transients ) | 
| 53 | - self::_lock_transient( $slug, $lock_timeout ); | |
| 53 | + self::_lock_transient($slug, $lock_timeout); | |
| 54 | 54 | |
| 55 | 55 | $data = $callback(); | 
| 56 | 56 | |
| 57 | 57 |  			if ( $enable_transients ) { | 
| 58 | - set_transient( $slug, $data, $transient_time ); | |
| 59 | - self::_unlock_transient( $slug ); | |
| 58 | + set_transient($slug, $data, $transient_time); | |
| 59 | + self::_unlock_transient($slug); | |
| 60 | 60 | } | 
| 61 | 61 | |
| 62 | 62 | } | 
| @@ -70,24 +70,24 @@ discard block | ||
| 70 | 70 | * @param string $slug | 
| 71 | 71 | * @param integer $lock_timeout | 
| 72 | 72 | */ | 
| 73 | -	static function _lock_transient( $slug, $lock_timeout ) { | |
| 74 | - set_transient( $slug . '_lock', true, $lock_timeout ); | |
| 73 | +	static function _lock_transient($slug, $lock_timeout) { | |
| 74 | + set_transient($slug . '_lock', true, $lock_timeout); | |
| 75 | 75 | } | 
| 76 | 76 | |
| 77 | 77 | /** | 
| 78 | 78 | * @internal | 
| 79 | 79 | * @param string $slug | 
| 80 | 80 | */ | 
| 81 | -	static function _unlock_transient( $slug ) { | |
| 82 | - delete_transient( $slug . '_lock', true ); | |
| 81 | +	static function _unlock_transient($slug) { | |
| 82 | + delete_transient($slug . '_lock', true); | |
| 83 | 83 | } | 
| 84 | 84 | |
| 85 | 85 | /** | 
| 86 | 86 | * @internal | 
| 87 | 87 | * @param string $slug | 
| 88 | 88 | */ | 
| 89 | -	static function _is_transient_locked( $slug ) { | |
| 90 | - return (bool)get_transient( $slug . '_lock' ); | |
| 89 | +	static function _is_transient_locked($slug) { | |
| 90 | + return (bool) get_transient($slug . '_lock'); | |
| 91 | 91 | } | 
| 92 | 92 | |
| 93 | 93 | /* These are for measuring page render time */ | 
| @@ -99,7 +99,7 @@ discard block | ||
| 99 | 99 | */ | 
| 100 | 100 |  	public static function start_timer() { | 
| 101 | 101 | $time = microtime(); | 
| 102 | - $time = explode( ' ', $time ); | |
| 102 | +		$time = explode(' ', $time); | |
| 103 | 103 | $time = $time[1] + $time[0]; | 
| 104 | 104 | return $time; | 
| 105 | 105 | } | 
| @@ -115,12 +115,12 @@ discard block | ||
| 115 | 115 | * @param int $start | 
| 116 | 116 | * @return string | 
| 117 | 117 | */ | 
| 118 | -	public static function stop_timer( $start ) { | |
| 118 | +	public static function stop_timer($start) { | |
| 119 | 119 | $time = microtime(); | 
| 120 | - $time = explode( ' ', $time ); | |
| 120 | +		$time = explode(' ', $time); | |
| 121 | 121 | $time = $time[1] + $time[0]; | 
| 122 | 122 | $finish = $time; | 
| 123 | - $total_time = round( ( $finish - $start ), 4 ); | |
| 123 | + $total_time = round(($finish - $start), 4); | |
| 124 | 124 | return $total_time . ' seconds.'; | 
| 125 | 125 | } | 
| 126 | 126 | |
| @@ -153,9 +153,9 @@ discard block | ||
| 153 | 153 | * @param array $args | 
| 154 | 154 | * @return string | 
| 155 | 155 | */ | 
| 156 | -	public static function ob_function( $function, $args = array( null ) ) { | |
| 156 | +	public static function ob_function($function, $args = array(null)) { | |
| 157 | 157 | ob_start(); | 
| 158 | - call_user_func_array( $function, $args ); | |
| 158 | + call_user_func_array($function, $args); | |
| 159 | 159 | $data = ob_get_contents(); | 
| 160 | 160 | ob_end_clean(); | 
| 161 | 161 | return $data; | 
| @@ -169,8 +169,8 @@ discard block | ||
| 169 | 169 | * @param bool $return_output_buffer | 
| 170 | 170 | * @return TimberFunctionWrapper | 
| 171 | 171 | */ | 
| 172 | -	public static function function_wrapper( $function_name, $defaults = array(), $return_output_buffer = false ) { | |
| 173 | - return new TimberFunctionWrapper( $function_name, $defaults, $return_output_buffer ); | |
| 172 | +	public static function function_wrapper($function_name, $defaults = array(), $return_output_buffer = false) { | |
| 173 | + return new TimberFunctionWrapper($function_name, $defaults, $return_output_buffer); | |
| 174 | 174 | } | 
| 175 | 175 | |
| 176 | 176 | /** | 
| @@ -179,14 +179,14 @@ discard block | ||
| 179 | 179 | * @param mixed $arg that you want to error_log | 
| 180 | 180 | * @return void | 
| 181 | 181 | */ | 
| 182 | -	public static function error_log( $arg ) { | |
| 182 | +	public static function error_log($arg) { | |
| 183 | 183 |  		if ( !WP_DEBUG ) { | 
| 184 | 184 | return; | 
| 185 | 185 | } | 
| 186 | -		if ( is_object( $arg ) || is_array( $arg ) ) { | |
| 187 | - $arg = print_r( $arg, true ); | |
| 186 | +		if ( is_object($arg) || is_array($arg) ) { | |
| 187 | + $arg = print_r($arg, true); | |
| 188 | 188 | } | 
| 189 | - return error_log( $arg ); | |
| 189 | + return error_log($arg); | |
| 190 | 190 | } | 
| 191 | 191 | |
| 192 | 192 | /** | 
| @@ -196,9 +196,9 @@ discard block | ||
| 196 | 196 | * @param string $seplocation | 
| 197 | 197 | * @return string | 
| 198 | 198 | */ | 
| 199 | -	public static function get_wp_title( $separator = ' ', $seplocation = 'left' ) { | |
| 200 | - $separator = apply_filters( 'timber_wp_title_seperator', $separator ); | |
| 201 | - return trim( wp_title( $separator, false, $seplocation ) ); | |
| 199 | +	public static function get_wp_title($separator = ' ', $seplocation = 'left') { | |
| 200 | +		$separator = apply_filters('timber_wp_title_seperator', $separator); | |
| 201 | + return trim(wp_title($separator, false, $seplocation)); | |
| 202 | 202 | } | 
| 203 | 203 | |
| 204 | 204 | /* Text Utilities | 
| @@ -213,35 +213,35 @@ discard block | ||
| 213 | 213 | * @param string $allowed_tags | 
| 214 | 214 | * @return string | 
| 215 | 215 | */ | 
| 216 | -	public static function trim_words( $text, $num_words = 55, $more = null, $allowed_tags = 'p a span b i br blockquote' ) { | |
| 216 | +	public static function trim_words($text, $num_words = 55, $more = null, $allowed_tags = 'p a span b i br blockquote') { | |
| 217 | 217 |  		if ( null === $more ) { | 
| 218 | - $more = __( '…' ); | |
| 218 | +			$more = __('…'); | |
| 219 | 219 | } | 
| 220 | 220 | $original_text = $text; | 
| 221 | 221 | $allowed_tag_string = ''; | 
| 222 | -		foreach ( explode( ' ', apply_filters( 'timber/trim_words/allowed_tags', $allowed_tags ) ) as $tag ) { | |
| 222 | +		foreach (explode(' ', apply_filters('timber/trim_words/allowed_tags', $allowed_tags)) as $tag) { | |
| 223 | 223 | $allowed_tag_string .= '<' . $tag . '>'; | 
| 224 | 224 | } | 
| 225 | - $text = strip_tags( $text, $allowed_tag_string ); | |
| 225 | + $text = strip_tags($text, $allowed_tag_string); | |
| 226 | 226 | /* translators: If your word count is based on single characters (East Asian characters), enter 'characters'. Otherwise, enter 'words'. Do not translate into your own language. */ | 
| 227 | -		if ( 'characters' == _x( 'words', 'word count: words or characters?' ) && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) { | |
| 228 | - $text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $text ), ' ' ); | |
| 229 | - preg_match_all( '/./u', $text, $words_array ); | |
| 230 | - $words_array = array_slice( $words_array[0], 0, $num_words + 1 ); | |
| 227 | +		if ( 'characters' == _x('words', 'word count: words or characters?') && preg_match('/^utf\-?8$/i', get_option('blog_charset')) ) { | |
| 228 | +			$text = trim(preg_replace("/[\n\r\t ]+/", ' ', $text), ' '); | |
| 229 | +			preg_match_all('/./u', $text, $words_array); | |
| 230 | + $words_array = array_slice($words_array[0], 0, $num_words + 1); | |
| 231 | 231 | $sep = ''; | 
| 232 | 232 |  		} else { | 
| 233 | - $words_array = preg_split( "/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY ); | |
| 233 | +			$words_array = preg_split("/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY); | |
| 234 | 234 | $sep = ' '; | 
| 235 | 235 | } | 
| 236 | -		if ( count( $words_array ) > $num_words ) { | |
| 237 | - array_pop( $words_array ); | |
| 238 | - $text = implode( $sep, $words_array ); | |
| 236 | +		if ( count($words_array) > $num_words ) { | |
| 237 | + array_pop($words_array); | |
| 238 | + $text = implode($sep, $words_array); | |
| 239 | 239 | $text = $text . $more; | 
| 240 | 240 |  		} else { | 
| 241 | - $text = implode( $sep, $words_array ); | |
| 241 | + $text = implode($sep, $words_array); | |
| 242 | 242 | } | 
| 243 | - $text = self::close_tags( $text ); | |
| 244 | - return apply_filters( 'wp_trim_words', $text, $num_words, $more, $original_text ); | |
| 243 | + $text = self::close_tags($text); | |
| 244 | +		return apply_filters('wp_trim_words', $text, $num_words, $more, $original_text); | |
| 245 | 245 | } | 
| 246 | 246 | |
| 247 | 247 | /** | 
| @@ -250,29 +250,29 @@ discard block | ||
| 250 | 250 | * @param string $html | 
| 251 | 251 | * @return string | 
| 252 | 252 | */ | 
| 253 | -	public static function close_tags( $html ) { | |
| 253 | +	public static function close_tags($html) { | |
| 254 | 254 | //put all opened tags into an array | 
| 255 | - preg_match_all( '#<([a-z]+)(?: .*)?(?<![/|/ ])>#iU', $html, $result ); | |
| 255 | +		preg_match_all('#<([a-z]+)(?: .*)?(?<![/|/ ])>#iU', $html, $result); | |
| 256 | 256 | $openedtags = $result[1]; | 
| 257 | 257 | //put all closed tags into an array | 
| 258 | - preg_match_all( '#</([a-z]+)>#iU', $html, $result ); | |
| 258 | +		preg_match_all('#</([a-z]+)>#iU', $html, $result); | |
| 259 | 259 | $closedtags = $result[1]; | 
| 260 | - $len_opened = count( $openedtags ); | |
| 260 | + $len_opened = count($openedtags); | |
| 261 | 261 | // all tags are closed | 
| 262 | -		if ( count( $closedtags ) == $len_opened ) { | |
| 262 | +		if ( count($closedtags) == $len_opened ) { | |
| 263 | 263 | return $html; | 
| 264 | 264 | } | 
| 265 | - $openedtags = array_reverse( $openedtags ); | |
| 265 | + $openedtags = array_reverse($openedtags); | |
| 266 | 266 | // close tags | 
| 267 | -		for ( $i = 0; $i < $len_opened; $i++ ) { | |
| 268 | -			if ( !in_array( $openedtags[$i], $closedtags ) ) { | |
| 267 | +		for ($i = 0; $i < $len_opened; $i++) { | |
| 268 | +			if ( !in_array($openedtags[$i], $closedtags) ) { | |
| 269 | 269 | $html .= '</' . $openedtags[$i] . '>'; | 
| 270 | 270 |  			} else { | 
| 271 | - unset( $closedtags[array_search( $openedtags[$i], $closedtags )] ); | |
| 271 | + unset($closedtags[array_search($openedtags[$i], $closedtags)]); | |
| 272 | 272 | } | 
| 273 | 273 | } | 
| 274 | -		$html = str_replace(array('</br>','</hr>','</wbr>'), '', $html); | |
| 275 | -		$html = str_replace(array('<br>','<hr>','<wbr>'), array('<br />','<hr />','<wbr />'), $html); | |
| 274 | +		$html = str_replace(array('</br>', '</hr>', '</wbr>'), '', $html); | |
| 275 | +		$html = str_replace(array('<br>', '<hr>', '<wbr>'), array('<br />', '<hr />', '<wbr />'), $html); | |
| 276 | 276 | return $html; | 
| 277 | 277 | } | 
| 278 | 278 | |
| @@ -285,17 +285,17 @@ discard block | ||
| 285 | 285 | * @return array|int | 
| 286 | 286 | * @deprecated 0.20.0 | 
| 287 | 287 | */ | 
| 288 | -	public static function get_posts_by_meta( $key, $value ) { | |
| 288 | +	public static function get_posts_by_meta($key, $value) { | |
| 289 | 289 | global $wpdb; | 
| 290 | - $query = $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %s", $key, $value ); | |
| 291 | - $results = $wpdb->get_col( $query ); | |
| 290 | +		$query = $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %s", $key, $value); | |
| 291 | + $results = $wpdb->get_col($query); | |
| 292 | 292 | $pids = array(); | 
| 293 | -		foreach ( $results as $result ) { | |
| 294 | -			if ( get_post( $result ) ) { | |
| 293 | +		foreach ($results as $result) { | |
| 294 | +			if ( get_post($result) ) { | |
| 295 | 295 | $pids[] = $result; | 
| 296 | 296 | } | 
| 297 | 297 | } | 
| 298 | -		if ( count( $pids ) ) { | |
| 298 | +		if ( count($pids) ) { | |
| 299 | 299 | return $pids; | 
| 300 | 300 | } | 
| 301 | 301 | return 0; | 
| @@ -309,12 +309,12 @@ discard block | ||
| 309 | 309 | * @return int | 
| 310 | 310 | * @deprecated 0.20.0 | 
| 311 | 311 | */ | 
| 312 | -	public static function get_post_by_meta( $key, $value ) { | |
| 312 | +	public static function get_post_by_meta($key, $value) { | |
| 313 | 313 | global $wpdb; | 
| 314 | - $query = $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %s ORDER BY post_id", $key, $value ); | |
| 315 | - $results = $wpdb->get_col( $query ); | |
| 316 | -		foreach ( $results as $result ) { | |
| 317 | -			if ( $result && get_post( $result ) ) { | |
| 314 | +		$query = $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %s ORDER BY post_id", $key, $value); | |
| 315 | + $results = $wpdb->get_col($query); | |
| 316 | +		foreach ($results as $result) { | |
| 317 | +			if ( $result && get_post($result) ) { | |
| 318 | 318 | return $result; | 
| 319 | 319 | } | 
| 320 | 320 | } | 
| @@ -327,10 +327,10 @@ discard block | ||
| 327 | 327 | * @param int $ttid | 
| 328 | 328 | * @return mixed | 
| 329 | 329 | */ | 
| 330 | -	public static function get_term_id_by_term_taxonomy_id( $ttid ) { | |
| 330 | +	public static function get_term_id_by_term_taxonomy_id($ttid) { | |
| 331 | 331 | global $wpdb; | 
| 332 | - $query = $wpdb->prepare( "SELECT term_id FROM $wpdb->term_taxonomy WHERE term_taxonomy_id = %s", $ttid ); | |
| 333 | - return $wpdb->get_var( $query ); | |
| 332 | +		$query = $wpdb->prepare("SELECT term_id FROM $wpdb->term_taxonomy WHERE term_taxonomy_id = %s", $ttid); | |
| 333 | + return $wpdb->get_var($query); | |
| 334 | 334 | } | 
| 335 | 335 | |
| 336 | 336 | /* Object Utilities | 
| @@ -343,8 +343,8 @@ discard block | ||
| 343 | 343 | * @param string $prop | 
| 344 | 344 | * @return void | 
| 345 | 345 | */ | 
| 346 | -	public static function osort( &$array, $prop ) { | |
| 347 | -		usort( $array, function ( $a, $b ) use ( $prop ) { | |
| 346 | +	public static function osort(&$array, $prop) { | |
| 347 | +		usort($array, function($a, $b) use ($prop) { | |
| 348 | 348 | return $a->$prop > $b->$prop ? 1 : -1; | 
| 349 | 349 | } ); | 
| 350 | 350 | } | 
| @@ -355,11 +355,11 @@ discard block | ||
| 355 | 355 | * @param array $arr | 
| 356 | 356 | * @return bool | 
| 357 | 357 | */ | 
| 358 | -	public static function is_array_assoc( $arr ) { | |
| 359 | -		if ( !is_array( $arr ) ) { | |
| 358 | +	public static function is_array_assoc($arr) { | |
| 359 | +		if ( !is_array($arr) ) { | |
| 360 | 360 | return false; | 
| 361 | 361 | } | 
| 362 | - return (bool)count( array_filter( array_keys( $arr ), 'is_string' ) ); | |
| 362 | + return (bool) count(array_filter(array_keys($arr), 'is_string')); | |
| 363 | 363 | } | 
| 364 | 364 | |
| 365 | 365 | /** | 
| @@ -368,11 +368,11 @@ discard block | ||
| 368 | 368 | * @param array $array | 
| 369 | 369 | * @return stdClass | 
| 370 | 370 | */ | 
| 371 | -	public static function array_to_object( $array ) { | |
| 371 | +	public static function array_to_object($array) { | |
| 372 | 372 | $obj = new stdClass; | 
| 373 | -		foreach ( $array as $k => $v ) { | |
| 374 | -			if ( is_array( $v ) ) { | |
| 375 | -				$obj->{$k} = self::array_to_object( $v ); //RECURSION | |
| 373 | +		foreach ($array as $k => $v) { | |
| 374 | +			if ( is_array($v) ) { | |
| 375 | +				$obj->{$k} = self::array_to_object($v); //RECURSION | |
| 376 | 376 |  			} else { | 
| 377 | 377 |  				$obj->{$k} = $v; | 
| 378 | 378 | } | 
| @@ -388,11 +388,11 @@ discard block | ||
| 388 | 388 | * @param mixed $value | 
| 389 | 389 | * @return bool|int | 
| 390 | 390 | */ | 
| 391 | -	public static function get_object_index_by_property( $array, $key, $value ) { | |
| 392 | -		if ( is_array( $array ) ) { | |
| 391 | +	public static function get_object_index_by_property($array, $key, $value) { | |
| 392 | +		if ( is_array($array) ) { | |
| 393 | 393 | $i = 0; | 
| 394 | -			foreach ( $array as $arr ) { | |
| 395 | -				if ( is_array( $arr ) ) { | |
| 394 | +			foreach ($array as $arr) { | |
| 395 | +				if ( is_array($arr) ) { | |
| 396 | 396 |  					if ( $arr[$key] == $value ) { | 
| 397 | 397 | return $i; | 
| 398 | 398 | } | 
| @@ -416,16 +416,16 @@ discard block | ||
| 416 | 416 | * @return array|null | 
| 417 | 417 | * @throws Exception | 
| 418 | 418 | */ | 
| 419 | -	public static function get_object_by_property( $array, $key, $value ) { | |
| 420 | -		if ( is_array( $array ) ) { | |
| 421 | -			foreach ( $array as $arr ) { | |
| 419 | +	public static function get_object_by_property($array, $key, $value) { | |
| 420 | +		if ( is_array($array) ) { | |
| 421 | +			foreach ($array as $arr) { | |
| 422 | 422 |  				if ( $arr->$key == $value ) { | 
| 423 | 423 | return $arr; | 
| 424 | 424 | } | 
| 425 | 425 | } | 
| 426 | 426 |  		} else { | 
| 427 | - throw new InvalidArgumentException( '$array is not an array, got:' ); | |
| 428 | - TimberHelper::error_log( $array ); | |
| 427 | +			throw new InvalidArgumentException('$array is not an array, got:'); | |
| 428 | + TimberHelper::error_log($array); | |
| 429 | 429 | } | 
| 430 | 430 | } | 
| 431 | 431 | |
| @@ -436,9 +436,9 @@ discard block | ||
| 436 | 436 | * @param int $len | 
| 437 | 437 | * @return array | 
| 438 | 438 | */ | 
| 439 | -	public static function array_truncate( $array, $len ) { | |
| 440 | -		if ( sizeof( $array ) > $len ) { | |
| 441 | - $array = array_splice( $array, 0, $len ); | |
| 439 | +	public static function array_truncate($array, $len) { | |
| 440 | +		if ( sizeof($array) > $len ) { | |
| 441 | + $array = array_splice($array, 0, $len); | |
| 442 | 442 | } | 
| 443 | 443 | return $array; | 
| 444 | 444 | } | 
| @@ -452,12 +452,12 @@ discard block | ||
| 452 | 452 | * @param mixed $value | 
| 453 | 453 | * @return bool | 
| 454 | 454 | */ | 
| 455 | -	public static function is_true( $value ) { | |
| 456 | -		if ( isset( $value ) ) { | |
| 457 | -			if (is_string($value)) { | |
| 455 | +	public static function is_true($value) { | |
| 456 | +		if ( isset($value) ) { | |
| 457 | +			if ( is_string($value) ) { | |
| 458 | 458 | $value = strtolower($value); | 
| 459 | 459 | } | 
| 460 | -			if ( ($value == 'true' || $value === 1 || $value === '1' || $value == true) && $value !== false && $value !== 'false') { | |
| 460 | +			if ( ($value == 'true' || $value === 1 || $value === '1' || $value == true) && $value !== false && $value !== 'false' ) { | |
| 461 | 461 | return true; | 
| 462 | 462 | } | 
| 463 | 463 | } | 
| @@ -470,8 +470,8 @@ discard block | ||
| 470 | 470 | * @param int $i | 
| 471 | 471 | * @return bool | 
| 472 | 472 | */ | 
| 473 | -	public static function iseven( $i ) { | |
| 474 | - return ( $i % 2 ) == 0; | |
| 473 | +	public static function iseven($i) { | |
| 474 | + return ($i % 2) == 0; | |
| 475 | 475 | } | 
| 476 | 476 | |
| 477 | 477 | /** | 
| @@ -480,8 +480,8 @@ discard block | ||
| 480 | 480 | * @param int $i | 
| 481 | 481 | * @return bool | 
| 482 | 482 | */ | 
| 483 | -	public static function isodd( $i ) { | |
| 484 | - return ( $i % 2 ) != 0; | |
| 483 | +	public static function isodd($i) { | |
| 484 | + return ($i % 2) != 0; | |
| 485 | 485 | } | 
| 486 | 486 | |
| 487 | 487 | /* Links, Forms, Etc. Utilities | 
| @@ -495,8 +495,8 @@ discard block | ||
| 495 | 495 | * @param array $args this $args thing is a fucking mess, [fix at some point](http://codex.wordpress.org/Function_Reference/comment_form) | 
| 496 | 496 | * @return string | 
| 497 | 497 | */ | 
| 498 | -	public static function get_comment_form( $post_id = null, $args = array() ) { | |
| 499 | - return self::ob_function( 'comment_form', array( $args, $post_id ) ); | |
| 498 | +	public static function get_comment_form($post_id = null, $args = array()) { | |
| 499 | +		return self::ob_function('comment_form', array($args, $post_id)); | |
| 500 | 500 | } | 
| 501 | 501 | |
| 502 | 502 | /** | 
| @@ -505,7 +505,7 @@ discard block | ||
| 505 | 505 | * @param string $args | 
| 506 | 506 | * @return array | 
| 507 | 507 | */ | 
| 508 | -	public static function paginate_links( $args = '' ) { | |
| 508 | +	public static function paginate_links($args = '') { | |
| 509 | 509 | $defaults = array( | 
| 510 | 510 | 'base' => '%_%', // http://example.com/all_posts.php%_% : %_% is replaced by format (below) | 
| 511 | 511 | 'format' => '?page=%#%', // ?page=%#% : %#% is replaced by the page number | 
| @@ -513,28 +513,28 @@ discard block | ||
| 513 | 513 | 'current' => 0, | 
| 514 | 514 | 'show_all' => false, | 
| 515 | 515 | 'prev_next' => false, | 
| 516 | - 'prev_text' => __( '« Previous' ), | |
| 517 | - 'next_text' => __( 'Next »' ), | |
| 516 | +			'prev_text' => __('« Previous'), | |
| 517 | +			'next_text' => __('Next »'), | |
| 518 | 518 | 'end_size' => 1, | 
| 519 | 519 | 'mid_size' => 2, | 
| 520 | 520 | 'type' => 'array', | 
| 521 | 521 | 'add_args' => false, // array of query args to add | 
| 522 | 522 | 'add_fragment' => '' | 
| 523 | 523 | ); | 
| 524 | - $args = wp_parse_args( $args, $defaults ); | |
| 524 | + $args = wp_parse_args($args, $defaults); | |
| 525 | 525 | // Who knows what else people pass in $args | 
| 526 | - $args['total'] = intval( (int)$args['total'] ); | |
| 526 | + $args['total'] = intval((int) $args['total']); | |
| 527 | 527 |  		if ( $args['total'] < 2 ) { | 
| 528 | 528 | return array(); | 
| 529 | 529 | } | 
| 530 | - $args['current'] = (int)$args['current']; | |
| 531 | - $args['end_size'] = 0 < (int)$args['end_size'] ? (int)$args['end_size'] : 1; // Out of bounds? Make it the default. | |
| 532 | - $args['mid_size'] = 0 <= (int)$args['mid_size'] ? (int)$args['mid_size'] : 2; | |
| 533 | - $args['add_args'] = is_array( $args['add_args'] ) ? $args['add_args'] : false; | |
| 530 | + $args['current'] = (int) $args['current']; | |
| 531 | + $args['end_size'] = 0 < (int) $args['end_size'] ? (int) $args['end_size'] : 1; // Out of bounds? Make it the default. | |
| 532 | + $args['mid_size'] = 0 <= (int) $args['mid_size'] ? (int) $args['mid_size'] : 2; | |
| 533 | + $args['add_args'] = is_array($args['add_args']) ? $args['add_args'] : false; | |
| 534 | 534 | $page_links = array(); | 
| 535 | 535 | $dots = false; | 
| 536 | -		for ( $n = 1; $n <= $args['total']; $n++ ) { | |
| 537 | - $n_display = number_format_i18n( $n ); | |
| 536 | +		for ($n = 1; $n <= $args['total']; $n++) { | |
| 537 | + $n_display = number_format_i18n($n); | |
| 538 | 538 |  			if ( $n == $args['current'] ) { | 
| 539 | 539 | $page_links[] = array( | 
| 540 | 540 | 'class' => 'page-number page-numbers current', | 
| @@ -545,18 +545,18 @@ discard block | ||
| 545 | 545 | ); | 
| 546 | 546 | $dots = true; | 
| 547 | 547 |  			} else { | 
| 548 | -				if ( $args['show_all'] || ( $n <= $args['end_size'] || ( $args['current'] && $n >= $args['current'] - $args['mid_size'] && $n <= $args['current'] + $args['mid_size'] ) || $n > $args['total'] - $args['end_size'] ) ) { | |
| 549 | - $link = str_replace( '%_%', 1 == $n ? '' : $args['format'], $args['base'] ); | |
| 550 | - $link = str_replace( '%#%', $n, $link ); | |
| 551 | - $link = trailingslashit( $link ) . ltrim( $args['add_fragment'], '/' ); | |
| 548 | +				if ( $args['show_all'] || ($n <= $args['end_size'] || ($args['current'] && $n >= $args['current'] - $args['mid_size'] && $n <= $args['current'] + $args['mid_size']) || $n > $args['total'] - $args['end_size']) ) { | |
| 549 | +					$link = str_replace('%_%', 1 == $n ? '' : $args['format'], $args['base']); | |
| 550 | +					$link = str_replace('%#%', $n, $link); | |
| 551 | + $link = trailingslashit($link) . ltrim($args['add_fragment'], '/'); | |
| 552 | 552 |  					if ( $args['add_args'] ) { | 
| 553 | - $link = rtrim( add_query_arg( $args['add_args'], $link ), '/' ); | |
| 553 | + $link = rtrim(add_query_arg($args['add_args'], $link), '/'); | |
| 554 | 554 | } | 
| 555 | 555 |  					$link = str_replace(' ', '+', $link); | 
| 556 | - $link = untrailingslashit( $link ); | |
| 556 | + $link = untrailingslashit($link); | |
| 557 | 557 | $page_links[] = array( | 
| 558 | 558 | 'class' => 'page-number page-numbers', | 
| 559 | - 'link' => esc_url( apply_filters( 'paginate_links', $link ) ), | |
| 559 | +						'link' => esc_url(apply_filters('paginate_links', $link)), | |
| 560 | 560 | 'title' => $n_display, | 
| 561 | 561 | 'name' => $n_display, | 
| 562 | 562 | 'current' => $args['current'] == $n | 
| @@ -565,7 +565,7 @@ discard block | ||
| 565 | 565 |  				} elseif ( $dots && !$args['show_all'] ) { | 
| 566 | 566 | $page_links[] = array( | 
| 567 | 567 | 'class' => 'dots', | 
| 568 | - 'title' => __( '…' ) | |
| 568 | +						'title' => __('…') | |
| 569 | 569 | ); | 
| 570 | 570 | $dots = false; | 
| 571 | 571 | } | 
| @@ -584,8 +584,8 @@ discard block | ||
| 584 | 584 | /** | 
| 585 | 585 | * @deprecated 0.18.0 | 
| 586 | 586 | */ | 
| 587 | -	static function is_url( $url ) { | |
| 588 | - return TimberURLHelper::is_url( $url ); | |
| 587 | +	static function is_url($url) { | |
| 588 | + return TimberURLHelper::is_url($url); | |
| 589 | 589 | } | 
| 590 | 590 | |
| 591 | 591 | /** | 
| @@ -598,71 +598,71 @@ discard block | ||
| 598 | 598 | /** | 
| 599 | 599 | * @deprecated 0.18.0 | 
| 600 | 600 | */ | 
| 601 | -	static function get_rel_url( $url, $force = false ) { | |
| 602 | - return TimberURLHelper::get_rel_url( $url, $force ); | |
| 601 | +	static function get_rel_url($url, $force = false) { | |
| 602 | + return TimberURLHelper::get_rel_url($url, $force); | |
| 603 | 603 | } | 
| 604 | 604 | |
| 605 | 605 | /** | 
| 606 | 606 | * @deprecated 0.18.0 | 
| 607 | 607 | */ | 
| 608 | -	static function is_local( $url ) { | |
| 609 | - return TimberURLHelper::is_local( $url ); | |
| 608 | +	static function is_local($url) { | |
| 609 | + return TimberURLHelper::is_local($url); | |
| 610 | 610 | } | 
| 611 | 611 | |
| 612 | 612 | /** | 
| 613 | 613 | * @deprecated 0.18.0 | 
| 614 | 614 | */ | 
| 615 | -	static function get_full_path( $src ) { | |
| 616 | - return TimberURLHelper::get_full_path( $src ); | |
| 615 | +	static function get_full_path($src) { | |
| 616 | + return TimberURLHelper::get_full_path($src); | |
| 617 | 617 | } | 
| 618 | 618 | |
| 619 | 619 | /** | 
| 620 | 620 | * @deprecated 0.18.0 | 
| 621 | 621 | */ | 
| 622 | -	static function get_rel_path( $src ) { | |
| 623 | - return TimberURLHelper::get_rel_path( $src ); | |
| 622 | +	static function get_rel_path($src) { | |
| 623 | + return TimberURLHelper::get_rel_path($src); | |
| 624 | 624 | } | 
| 625 | 625 | |
| 626 | 626 | /** | 
| 627 | 627 | * @deprecated 0.18.0 | 
| 628 | 628 | */ | 
| 629 | -	static function remove_double_slashes( $url ) { | |
| 630 | - return TimberURLHelper::remove_double_slashes( $url ); | |
| 629 | +	static function remove_double_slashes($url) { | |
| 630 | + return TimberURLHelper::remove_double_slashes($url); | |
| 631 | 631 | } | 
| 632 | 632 | |
| 633 | 633 | /** | 
| 634 | 634 | * @deprecated 0.18.0 | 
| 635 | 635 | */ | 
| 636 | -	static function prepend_to_url( $url, $path ) { | |
| 637 | - return TimberURLHelper::prepend_to_url( $url, $path ); | |
| 636 | +	static function prepend_to_url($url, $path) { | |
| 637 | + return TimberURLHelper::prepend_to_url($url, $path); | |
| 638 | 638 | } | 
| 639 | 639 | |
| 640 | 640 | /** | 
| 641 | 641 | * @deprecated 0.18.0 | 
| 642 | 642 | */ | 
| 643 | -	static function preslashit( $path ) { | |
| 644 | - return TimberURLHelper::preslashit( $path ); | |
| 643 | +	static function preslashit($path) { | |
| 644 | + return TimberURLHelper::preslashit($path); | |
| 645 | 645 | } | 
| 646 | 646 | |
| 647 | 647 | /** | 
| 648 | 648 | * @deprecated 0.18.0 | 
| 649 | 649 | */ | 
| 650 | -	static function is_external( $url ) { | |
| 651 | - return TimberURLHelper::is_external( $url ); | |
| 650 | +	static function is_external($url) { | |
| 651 | + return TimberURLHelper::is_external($url); | |
| 652 | 652 | } | 
| 653 | 653 | |
| 654 | 654 | /** | 
| 655 | 655 | * @deprecated 0.18.0 | 
| 656 | 656 | */ | 
| 657 | -	static function download_url( $url, $timeout = 300 ) { | |
| 658 | - return TimberURLHelper::download_url( $url, $timeout ); | |
| 657 | +	static function download_url($url, $timeout = 300) { | |
| 658 | + return TimberURLHelper::download_url($url, $timeout); | |
| 659 | 659 | } | 
| 660 | 660 | |
| 661 | 661 | /** | 
| 662 | 662 | * @deprecated 0.18.0 | 
| 663 | 663 | */ | 
| 664 | -	static function get_params( $i = -1 ) { | |
| 665 | - return TimberURLHelper::get_params( $i ); | |
| 664 | +	static function get_params($i = -1) { | |
| 665 | + return TimberURLHelper::get_params($i); | |
| 666 | 666 | } | 
| 667 | 667 | |
| 668 | 668 | } | 
| @@ -85,7 +85,7 @@ discard block | ||
| 85 | 85 | * Generates a new image with increased size, for display on Retina screens. | 
| 86 | 86 | * | 
| 87 | 87 | * @param string $src | 
| 88 | - * @param float $multiplier | |
| 88 | + * @param integer $multiplier | |
| 89 | 89 | * @param boolean $force | 
| 90 | 90 | * | 
| 91 | 91 | * @return string url to the new image | 
| @@ -136,7 +136,7 @@ discard block | ||
| 136 | 136 | * @param int $h | 
| 137 | 137 | * @param string $color | 
| 138 | 138 | * @param bool $force | 
| 139 | - * @return mixed|null|string | |
| 139 | + * @return string | |
| 140 | 140 | */ | 
| 141 | 141 |  	public static function letterbox( $src, $w, $h, $color = '#000000', $force = false ) { | 
| 142 | 142 | $op = new TimberImageOperationLetterbox($w, $h, $color); | 
| @@ -108,23 +108,23 @@ | ||
| 108 | 108 | //its a gif so test | 
| 109 | 109 |  		if(!($fh = @fopen($file, 'rb'))) { | 
| 110 | 110 | return false; | 
| 111 | - } | |
| 112 | - $count = 0; | |
| 113 | - //an animated gif contains multiple "frames", with each frame having a | |
| 114 | - //header made up of: | |
| 115 | - // * a static 4-byte sequence (\x00\x21\xF9\x04) | |
| 116 | - // * 4 variable bytes | |
| 117 | - // * a static 2-byte sequence (\x00\x2C) | |
| 111 | + } | |
| 112 | + $count = 0; | |
| 113 | + //an animated gif contains multiple "frames", with each frame having a | |
| 114 | + //header made up of: | |
| 115 | + // * a static 4-byte sequence (\x00\x21\xF9\x04) | |
| 116 | + // * 4 variable bytes | |
| 117 | + // * a static 2-byte sequence (\x00\x2C) | |
| 118 | 118 | |
| 119 | - // We read through the file til we reach the end of the file, or we've found | |
| 120 | - // at least 2 frame headers | |
| 121 | -	    while(!feof($fh) && $count < 2) { | |
| 122 | - $chunk = fread($fh, 1024 * 100); //read 100kb at a time | |
| 123 | -	        $count += preg_match_all('#\x00\x21\xF9\x04.{4}\x00[\x2C\x21]#s', $chunk, $matches); | |
| 124 | - } | |
| 119 | + // We read through the file til we reach the end of the file, or we've found | |
| 120 | + // at least 2 frame headers | |
| 121 | +		while(!feof($fh) && $count < 2) { | |
| 122 | + $chunk = fread($fh, 1024 * 100); //read 100kb at a time | |
| 123 | +			$count += preg_match_all('#\x00\x21\xF9\x04.{4}\x00[\x2C\x21]#s', $chunk, $matches); | |
| 124 | + } | |
| 125 | 125 | |
| 126 | - fclose($fh); | |
| 127 | - return $count > 1; | |
| 126 | + fclose($fh); | |
| 127 | + return $count > 1; | |
| 128 | 128 | } | 
| 129 | 129 | |
| 130 | 130 | /** | 
| @@ -325,7 +325,8 @@ | ||
| 325 | 325 | ); | 
| 326 | 326 | $upload_dir = wp_upload_dir(); | 
| 327 | 327 | $tmp = $url; | 
| 328 | -		if ( 0 === strpos($tmp, ABSPATH) ) { // we've been given a dir, not an url | |
| 328 | +		if ( 0 === strpos($tmp, ABSPATH) ) { | |
| 329 | +// we've been given a dir, not an url | |
| 329 | 330 | $result['absolute'] = true; | 
| 330 | 331 |  			if ( 0 === strpos($tmp, $upload_dir['basedir']) ) { | 
| 331 | 332 | $result['base']= self::BASE_UPLOADS; // upload based | 
| @@ -43,9 +43,9 @@ discard block | ||
| 43 | 43 | * ``` | 
| 44 | 44 | * @return string (ex: ) | 
| 45 | 45 | */ | 
| 46 | -	public static function resize( $src, $w, $h = 0, $crop = 'default', $force = false ) { | |
| 47 | -		if (!is_numeric($w) && is_string($w)) { | |
| 48 | -			if ($sizes = self::find_wp_dimensions($w)) { | |
| 46 | +	public static function resize($src, $w, $h = 0, $crop = 'default', $force = false) { | |
| 47 | +		if ( !is_numeric($w) && is_string($w) ) { | |
| 48 | +			if ( $sizes = self::find_wp_dimensions($w) ) { | |
| 49 | 49 | $w = $sizes['w']; | 
| 50 | 50 | $h = $sizes['h']; | 
| 51 | 51 |  			} else { | 
| @@ -66,16 +66,16 @@ discard block | ||
| 66 | 66 | * @type int h | 
| 67 | 67 | * } | 
| 68 | 68 | */ | 
| 69 | -	private static function find_wp_dimensions( $size ) { | |
| 69 | +	private static function find_wp_dimensions($size) { | |
| 70 | 70 | global $_wp_additional_image_sizes; | 
| 71 | -		if (isset($_wp_additional_image_sizes[$size])) { | |
| 71 | +		if ( isset($_wp_additional_image_sizes[$size]) ) { | |
| 72 | 72 | $w = $_wp_additional_image_sizes[$size]['width']; | 
| 73 | 73 | $h = $_wp_additional_image_sizes[$size]['height']; | 
| 74 | -		} else if (in_array($size, array('thumbnail', 'medium', 'large'))) { | |
| 75 | - $w = get_option($size.'_size_w'); | |
| 76 | - $h = get_option($size.'_size_h'); | |
| 74 | +		} else if ( in_array($size, array('thumbnail', 'medium', 'large')) ) { | |
| 75 | + $w = get_option($size . '_size_w'); | |
| 76 | + $h = get_option($size . '_size_h'); | |
| 77 | 77 | } | 
| 78 | -		if (isset($w) && isset($h) && ($w || $h)) { | |
| 78 | +		if ( isset($w) && isset($h) && ($w || $h) ) { | |
| 79 | 79 |  			return array('w' => $w, 'h' => $h); | 
| 80 | 80 | } | 
| 81 | 81 | return false; | 
| @@ -90,7 +90,7 @@ discard block | ||
| 90 | 90 | * | 
| 91 | 91 | * @return string url to the new image | 
| 92 | 92 | */ | 
| 93 | -	public static function retina_resize( $src, $multiplier = 2, $force = false ) { | |
| 93 | +	public static function retina_resize($src, $multiplier = 2, $force = false) { | |
| 94 | 94 | $op = new TimberImageOperationRetina($multiplier); | 
| 95 | 95 | return self::_operate($src, $op, $force); | 
| 96 | 96 | } | 
| @@ -100,13 +100,13 @@ discard block | ||
| 100 | 100 | * @param string $file local filepath to a file, not a URL | 
| 101 | 101 | * @return boolean true if it's an animated gif, false if not | 
| 102 | 102 | */ | 
| 103 | -	public static function is_animated_gif( $file ) { | |
| 103 | +	public static function is_animated_gif($file) { | |
| 104 | 104 |  		if ( strpos(strtolower($file), '.gif') == -1 ) { | 
| 105 | 105 | //doesn't have .gif, bail | 
| 106 | 106 | return false; | 
| 107 | 107 | } | 
| 108 | 108 | //its a gif so test | 
| 109 | -		if( !($fh = @fopen($file, 'rb')) ) { | |
| 109 | +		if ( !($fh = @fopen($file, 'rb')) ) { | |
| 110 | 110 | return false; | 
| 111 | 111 | } | 
| 112 | 112 | $count = 0; | 
| @@ -118,7 +118,7 @@ discard block | ||
| 118 | 118 | |
| 119 | 119 | // We read through the file til we reach the end of the file, or we've found | 
| 120 | 120 | // at least 2 frame headers | 
| 121 | -	    while(!feof($fh) && $count < 2) { | |
| 121 | +	    while (!feof($fh) && $count < 2) { | |
| 122 | 122 | $chunk = fread($fh, 1024 * 100); //read 100kb at a time | 
| 123 | 123 |  	        $count += preg_match_all('#\x00\x21\xF9\x04.{4}\x00[\x2C\x21]#s', $chunk, $matches); | 
| 124 | 124 | } | 
| @@ -138,7 +138,7 @@ discard block | ||
| 138 | 138 | * @param bool $force | 
| 139 | 139 | * @return mixed|null|string | 
| 140 | 140 | */ | 
| 141 | -	public static function letterbox( $src, $w, $h, $color = '#000000', $force = false ) { | |
| 141 | +	public static function letterbox($src, $w, $h, $color = '#000000', $force = false) { | |
| 142 | 142 | $op = new TimberImageOperationLetterbox($w, $h, $color); | 
| 143 | 143 | return self::_operate($src, $op, $force); | 
| 144 | 144 | } | 
| @@ -150,7 +150,7 @@ discard block | ||
| 150 | 150 | * @param string $bghex | 
| 151 | 151 | * @return string | 
| 152 | 152 | */ | 
| 153 | -	public static function img_to_jpg( $src, $bghex = '#FFFFFF', $force = false ) { | |
| 153 | +	public static function img_to_jpg($src, $bghex = '#FFFFFF', $force = false) { | |
| 154 | 154 | $op = new TimberImageOperationToJpg($bghex); | 
| 155 | 155 | return self::_operate($src, $op, $force); | 
| 156 | 156 | } | 
| @@ -159,13 +159,13 @@ discard block | ||
| 159 | 159 | * Deletes all resized versions of an image when the source is deleted | 
| 160 | 160 | */ | 
| 161 | 161 |  	protected static function add_actions() { | 
| 162 | -		add_action( 'delete_attachment', function ( $post_id ) { | |
| 163 | - $post = get_post( $post_id ); | |
| 164 | - $image_types = array( 'image/jpeg', 'image/png', 'image/gif', 'image/jpg' ); | |
| 165 | -			if ( in_array( $post->post_mime_type, $image_types ) ) { | |
| 166 | - $attachment = new TimberImage( $post_id ); | |
| 162 | +		add_action('delete_attachment', function($post_id) { | |
| 163 | + $post = get_post($post_id); | |
| 164 | +			$image_types = array('image/jpeg', 'image/png', 'image/gif', 'image/jpg'); | |
| 165 | +			if ( in_array($post->post_mime_type, $image_types) ) { | |
| 166 | + $attachment = new TimberImage($post_id); | |
| 167 | 167 |  				if ( $attachment->file_loc ) { | 
| 168 | - TimberImageHelper::delete_generated_files( $attachment->file_loc ); | |
| 168 | + TimberImageHelper::delete_generated_files($attachment->file_loc); | |
| 169 | 169 | } | 
| 170 | 170 | } | 
| 171 | 171 | } ); | 
| @@ -176,9 +176,9 @@ discard block | ||
| 176 | 176 | * for example /wp-content or /content | 
| 177 | 177 | */ | 
| 178 | 178 |  	protected static function add_constants() { | 
| 179 | -		if ( !defined( 'WP_CONTENT_SUBDIR' ) ) { | |
| 180 | - $wp_content_path = str_replace( home_url(), '', WP_CONTENT_URL ); | |
| 181 | - define( 'WP_CONTENT_SUBDIR', $wp_content_path ); | |
| 179 | +		if ( !defined('WP_CONTENT_SUBDIR') ) { | |
| 180 | + $wp_content_path = str_replace(home_url(), '', WP_CONTENT_URL); | |
| 181 | +			define('WP_CONTENT_SUBDIR', $wp_content_path); | |
| 182 | 182 | } | 
| 183 | 183 | } | 
| 184 | 184 | |
| @@ -188,8 +188,8 @@ discard block | ||
| 188 | 188 | * @return void | 
| 189 | 189 | */ | 
| 190 | 190 |  	static function add_filters() { | 
| 191 | -		add_filter( 'upload_dir', function ( $arr ) { | |
| 192 | - $arr['relative'] = str_replace( home_url(), '', $arr['baseurl'] ); | |
| 191 | +		add_filter('upload_dir', function($arr) { | |
| 192 | + $arr['relative'] = str_replace(home_url(), '', $arr['baseurl']); | |
| 193 | 193 | return $arr; | 
| 194 | 194 | } ); | 
| 195 | 195 | } | 
| @@ -200,16 +200,16 @@ discard block | ||
| 200 | 200 | * @param string $local_file ex: /var/www/wp-content/uploads/2015/my-pic.jpg | 
| 201 | 201 | * or: http://example.org/wp-content/uploads/2015/my-pic.jpg | 
| 202 | 202 | */ | 
| 203 | -	static function delete_generated_files( $local_file ) { | |
| 204 | -		if (TimberURLHelper::is_absolute( $local_file ) ) { | |
| 205 | - $local_file = TimberURLHelper::url_to_file_system( $local_file ); | |
| 203 | +	static function delete_generated_files($local_file) { | |
| 204 | +		if ( TimberURLHelper::is_absolute($local_file) ) { | |
| 205 | + $local_file = TimberURLHelper::url_to_file_system($local_file); | |
| 206 | 206 | } | 
| 207 | - $info = pathinfo( $local_file ); | |
| 207 | + $info = pathinfo($local_file); | |
| 208 | 208 | $dir = $info['dirname']; | 
| 209 | 209 | $ext = $info['extension']; | 
| 210 | 210 | $filename = $info['filename']; | 
| 211 | - self::process_delete_generated_files( $filename, $ext, $dir, '-[0-9999999]*', '-[0-9]*x[0-9]*-c-[a-z]*.' ); | |
| 212 | - self::process_delete_generated_files( $filename, $ext, $dir, '-lbox-[0-9999999]*', '-lbox-[0-9]*x[0-9]*-[a-zA-Z0-9]*.' ); | |
| 211 | + self::process_delete_generated_files($filename, $ext, $dir, '-[0-9999999]*', '-[0-9]*x[0-9]*-c-[a-z]*.'); | |
| 212 | + self::process_delete_generated_files($filename, $ext, $dir, '-lbox-[0-9999999]*', '-lbox-[0-9]*x[0-9]*-[a-zA-Z0-9]*.'); | |
| 213 | 213 | } | 
| 214 | 214 | |
| 215 | 215 | /** | 
| @@ -226,14 +226,14 @@ discard block | ||
| 226 | 226 | * @param string $search_pattern pattern of files to pluck from | 
| 227 | 227 | * @param string $match_pattern pattern of files to go forth and delete | 
| 228 | 228 | */ | 
| 229 | -	protected static function process_delete_generated_files( $filename, $ext, $dir, $search_pattern, $match_pattern ) { | |
| 229 | +	protected static function process_delete_generated_files($filename, $ext, $dir, $search_pattern, $match_pattern) { | |
| 230 | 230 | $searcher = '/' . $filename . $search_pattern; | 
| 231 | -		foreach ( glob( $dir . $searcher ) as $found_file ) { | |
| 232 | - $regexdir = str_replace( '/', '\/', $dir ); | |
| 233 | - $pattern = '/' . ( $regexdir ) . '\/' . $filename . $match_pattern . $ext . '/'; | |
| 234 | - $match = preg_match( $pattern, $found_file ); | |
| 231 | +		foreach (glob($dir . $searcher) as $found_file) { | |
| 232 | +			$regexdir = str_replace('/', '\/', $dir); | |
| 233 | + $pattern = '/' . ($regexdir) . '\/' . $filename . $match_pattern . $ext . '/'; | |
| 234 | + $match = preg_match($pattern, $found_file); | |
| 235 | 235 |  			if ( $match ) { | 
| 236 | - unlink( $found_file ); | |
| 236 | + unlink($found_file); | |
| 237 | 237 | } | 
| 238 | 238 | } | 
| 239 | 239 | } | 
| @@ -245,9 +245,9 @@ discard block | ||
| 245 | 245 | * @param string $url | 
| 246 | 246 | * @return string | 
| 247 | 247 | */ | 
| 248 | -	public static function get_server_location( $url ) { | |
| 248 | +	public static function get_server_location($url) { | |
| 249 | 249 | // if we're already an absolute dir, just return | 
| 250 | -		if ( 0 === strpos( $url, ABSPATH ) ) { | |
| 250 | +		if ( 0 === strpos($url, ABSPATH) ) { | |
| 251 | 251 | return $url; | 
| 252 | 252 | } | 
| 253 | 253 | // otherwise, analyze URL then build mapping path | 
| @@ -262,15 +262,15 @@ discard block | ||
| 262 | 262 | * @param string $file | 
| 263 | 263 | * @return string | 
| 264 | 264 | */ | 
| 265 | -	public static function get_sideloaded_file_loc( $file ) { | |
| 265 | +	public static function get_sideloaded_file_loc($file) { | |
| 266 | 266 | $upload = wp_upload_dir(); | 
| 267 | 267 | $dir = $upload['path']; | 
| 268 | 268 | $filename = $file; | 
| 269 | - $file = parse_url( $file ); | |
| 270 | - $path_parts = pathinfo( $file['path'] ); | |
| 271 | - $basename = md5( $filename ); | |
| 269 | + $file = parse_url($file); | |
| 270 | + $path_parts = pathinfo($file['path']); | |
| 271 | + $basename = md5($filename); | |
| 272 | 272 | $ext = 'jpg'; | 
| 273 | -		if ( isset( $path_parts['extension'] ) ) { | |
| 273 | +		if ( isset($path_parts['extension']) ) { | |
| 274 | 274 | $ext = $path_parts['extension']; | 
| 275 | 275 | } | 
| 276 | 276 | return $dir . '/' . $basename . '.' . $ext; | 
| @@ -282,28 +282,28 @@ discard block | ||
| 282 | 282 | * @param string $file the URL to the original file | 
| 283 | 283 | * @return string the URL to the downloaded file | 
| 284 | 284 | */ | 
| 285 | -	public static function sideload_image( $file ) { | |
| 286 | - $loc = self::get_sideloaded_file_loc( $file ); | |
| 287 | -		if ( file_exists( $loc ) ) { | |
| 288 | - return TimberURLHelper::preslashit( TimberURLHelper::get_rel_path( $loc ) ); | |
| 285 | +	public static function sideload_image($file) { | |
| 286 | + $loc = self::get_sideloaded_file_loc($file); | |
| 287 | +		if ( file_exists($loc) ) { | |
| 288 | + return TimberURLHelper::preslashit(TimberURLHelper::get_rel_path($loc)); | |
| 289 | 289 | } | 
| 290 | 290 | // Download file to temp location | 
| 291 | -		if ( !function_exists( 'download_url' ) ) { | |
| 291 | +		if ( !function_exists('download_url') ) { | |
| 292 | 292 | require_once ABSPATH . '/wp-admin/includes/file.php'; | 
| 293 | 293 | } | 
| 294 | - $tmp = download_url( $file ); | |
| 295 | - preg_match( '/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches ); | |
| 294 | + $tmp = download_url($file); | |
| 295 | +		preg_match('/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches); | |
| 296 | 296 | $file_array = array(); | 
| 297 | - $file_array['name'] = basename( $matches[0] ); | |
| 297 | + $file_array['name'] = basename($matches[0]); | |
| 298 | 298 | $file_array['tmp_name'] = $tmp; | 
| 299 | 299 | // If error storing temporarily, unlink | 
| 300 | -		if ( is_wp_error( $tmp ) ) { | |
| 301 | - @unlink( $file_array['tmp_name'] ); | |
| 300 | +		if ( is_wp_error($tmp) ) { | |
| 301 | + @unlink($file_array['tmp_name']); | |
| 302 | 302 | $file_array['tmp_name'] = ''; | 
| 303 | 303 | } | 
| 304 | 304 | // do the validation and storage stuff | 
| 305 | - $locinfo = pathinfo( $loc ); | |
| 306 | - $file = wp_upload_bits( $locinfo['basename'], null, file_get_contents( $file_array['tmp_name'] ) ); | |
| 305 | + $locinfo = pathinfo($loc); | |
| 306 | + $file = wp_upload_bits($locinfo['basename'], null, file_get_contents($file_array['tmp_name'])); | |
| 307 | 307 | return $file['url']; | 
| 308 | 308 | } | 
| 309 | 309 | |
| @@ -330,23 +330,23 @@ discard block | ||
| 330 | 330 |  		if ( 0 === strpos($tmp, ABSPATH) ) { // we've been given a dir, not an url | 
| 331 | 331 | $result['absolute'] = true; | 
| 332 | 332 |  			if ( 0 === strpos($tmp, $upload_dir['basedir']) ) { | 
| 333 | - $result['base']= self::BASE_UPLOADS; // upload based | |
| 333 | + $result['base'] = self::BASE_UPLOADS; // upload based | |
| 334 | 334 | $tmp = str_replace($upload_dir['basedir'], '', $tmp); | 
| 335 | 335 | } | 
| 336 | 336 |  			if ( 0 === strpos($tmp, WP_CONTENT_DIR) ) { | 
| 337 | - $result['base']= self::BASE_CONTENT; // content based | |
| 337 | + $result['base'] = self::BASE_CONTENT; // content based | |
| 338 | 338 | $tmp = str_replace(WP_CONTENT_DIR, '', $tmp); | 
| 339 | 339 | } | 
| 340 | 340 |  		} else { | 
| 341 | -			if (!$result['absolute']) { | |
| 342 | - $tmp = home_url().$tmp; | |
| 341 | +			if ( !$result['absolute'] ) { | |
| 342 | + $tmp = home_url() . $tmp; | |
| 343 | 343 | } | 
| 344 | -			if (0 === strpos($tmp, $upload_dir['baseurl'])) { | |
| 345 | - $result['base']= self::BASE_UPLOADS; // upload based | |
| 344 | +			if ( 0 === strpos($tmp, $upload_dir['baseurl']) ) { | |
| 345 | + $result['base'] = self::BASE_UPLOADS; // upload based | |
| 346 | 346 | $tmp = str_replace($upload_dir['baseurl'], '', $tmp); | 
| 347 | 347 | } | 
| 348 | -			if (0 === strpos($tmp, content_url())) { | |
| 349 | - $result['base']= self::BASE_CONTENT; // content-based | |
| 348 | +			if ( 0 === strpos($tmp, content_url()) ) { | |
| 349 | + $result['base'] = self::BASE_CONTENT; // content-based | |
| 350 | 350 | $tmp = str_replace(content_url(), '', $tmp); | 
| 351 | 351 | } | 
| 352 | 352 | } | 
| @@ -370,18 +370,18 @@ discard block | ||
| 370 | 370 | */ | 
| 371 | 371 |  	private static function _get_file_url($base, $subdir, $filename, $absolute) { | 
| 372 | 372 | $url = ''; | 
| 373 | -		if( self::BASE_UPLOADS == $base ) { | |
| 373 | +		if ( self::BASE_UPLOADS == $base ) { | |
| 374 | 374 | $upload_dir = wp_upload_dir(); | 
| 375 | 375 | $url = $upload_dir['baseurl']; | 
| 376 | 376 | } | 
| 377 | -		if( self::BASE_CONTENT == $base ) { | |
| 377 | +		if ( self::BASE_CONTENT == $base ) { | |
| 378 | 378 | $url = content_url(); | 
| 379 | 379 | } | 
| 380 | -		if(!empty($subdir)) { | |
| 380 | +		if ( !empty($subdir) ) { | |
| 381 | 381 | $url .= $subdir; | 
| 382 | 382 | } | 
| 383 | - $url .= '/'.$filename; | |
| 384 | -		if(!$absolute) { | |
| 383 | + $url .= '/' . $filename; | |
| 384 | +		if ( !$absolute ) { | |
| 385 | 385 | $url = str_replace(home_url(), '', $url); | 
| 386 | 386 | } | 
| 387 | 387 | // $url = TimberURLHelper::remove_double_slashes( $url); | 
| @@ -398,17 +398,17 @@ discard block | ||
| 398 | 398 | */ | 
| 399 | 399 |  	private static function _get_file_path($base, $subdir, $filename) { | 
| 400 | 400 | $path = ''; | 
| 401 | -		if(self::BASE_UPLOADS == $base) { | |
| 401 | +		if ( self::BASE_UPLOADS == $base ) { | |
| 402 | 402 | $upload_dir = wp_upload_dir(); | 
| 403 | 403 | $path = $upload_dir['basedir']; | 
| 404 | 404 | } | 
| 405 | -		if(self::BASE_CONTENT == $base) { | |
| 405 | +		if ( self::BASE_CONTENT == $base ) { | |
| 406 | 406 | $path = WP_CONTENT_DIR; | 
| 407 | 407 | } | 
| 408 | -		if(!empty($subdir)) { | |
| 408 | +		if ( !empty($subdir) ) { | |
| 409 | 409 | $path .= $subdir; | 
| 410 | 410 | } | 
| 411 | - $path .= '/'.$filename; | |
| 411 | + $path .= '/' . $filename; | |
| 412 | 412 | return $path; | 
| 413 | 413 | } | 
| 414 | 414 | |
| @@ -426,15 +426,15 @@ discard block | ||
| 426 | 426 | * @return string URL to the new image - or the source one if error | 
| 427 | 427 | * | 
| 428 | 428 | */ | 
| 429 | -	private static function _operate( $src, $op, $force = false ) { | |
| 430 | -		if ( empty( $src ) ) { | |
| 429 | +	private static function _operate($src, $op, $force = false) { | |
| 430 | +		if ( empty($src) ) { | |
| 431 | 431 | return ''; | 
| 432 | 432 | } | 
| 433 | 433 | $external = false; | 
| 434 | 434 | |
| 435 | 435 | // if external image, load it first | 
| 436 | -		if ( TimberURLHelper::is_external_content( $src ) ) { | |
| 437 | - $src = self::sideload_image( $src ); | |
| 436 | +		if ( TimberURLHelper::is_external_content($src) ) { | |
| 437 | + $src = self::sideload_image($src); | |
| 438 | 438 | $external = true; | 
| 439 | 439 | } | 
| 440 | 440 | // break down URL into components | 
| @@ -457,19 +457,19 @@ discard block | ||
| 457 | 457 | $au['basename'] | 
| 458 | 458 | ); | 
| 459 | 459 | // if already exists... | 
| 460 | -		if ( file_exists( $new_server_path ) ) { | |
| 460 | +		if ( file_exists($new_server_path) ) { | |
| 461 | 461 |  			if ( $force ) { | 
| 462 | 462 | // Force operation - warning: will regenerate the image on every pageload, use for testing purposes only! | 
| 463 | - unlink( $new_server_path ); | |
| 463 | + unlink($new_server_path); | |
| 464 | 464 |  			} else { | 
| 465 | 465 | // return existing file (caching) | 
| 466 | 466 | return $new_url; | 
| 467 | 467 | } | 
| 468 | 468 | } | 
| 469 | 469 | // otherwise generate result file | 
| 470 | -		if($op->run($old_server_path, $new_server_path)) { | |
| 471 | -			if( get_class( $op ) === 'TimberImageOperationResize' && $external ) { | |
| 472 | - $new_url = strtolower( $new_url ); | |
| 470 | +		if ( $op->run($old_server_path, $new_server_path) ) { | |
| 471 | +			if ( get_class($op) === 'TimberImageOperationResize' && $external ) { | |
| 472 | + $new_url = strtolower($new_url); | |
| 473 | 473 | } | 
| 474 | 474 | return $new_url; | 
| 475 | 475 |  		} else { | 
| @@ -492,7 +492,7 @@ discard block | ||
| 492 | 492 | ); | 
| 493 | 493 | return $new_url; | 
| 494 | 494 | } | 
| 495 | -	public static function get_letterbox_file_path($url, $w, $h, $color ) { | |
| 495 | +	public static function get_letterbox_file_path($url, $w, $h, $color) { | |
| 496 | 496 | $au = self::analyze_url($url); | 
| 497 | 497 | $op = new TimberImageOperationLetterbox($w, $h, $color); | 
| 498 | 498 | $new_path = self::_get_file_path( | 
| @@ -301,7 +301,7 @@ | ||
| 301 | 301 |  	 * 	   <img src="{{ post.thumbnail.src|resize(500) }}" alt="A sumo wrestler" /> | 
| 302 | 302 |  	 * {% endif %} | 
| 303 | 303 | * ``` | 
| 304 | - * @return float | |
| 304 | + * @return integer | |
| 305 | 305 | */ | 
| 306 | 306 |  	public function aspect() { | 
| 307 | 307 | $w = intval($this->width()); | 
| @@ -150,27 +150,27 @@ discard block | ||
| 150 | 150 | * @internal | 
| 151 | 151 | * @param int $iid the id number of the image in the WP database | 
| 152 | 152 | */ | 
| 153 | -	protected function get_image_info( $iid ) { | |
| 153 | +	protected function get_image_info($iid) { | |
| 154 | 154 | $image_info = $iid; | 
| 155 | -		if (is_numeric($iid)) { | |
| 155 | +		if ( is_numeric($iid) ) { | |
| 156 | 156 | $image_info = wp_get_attachment_metadata($iid); | 
| 157 | -			if (!is_array($image_info)) { | |
| 157 | +			if ( !is_array($image_info) ) { | |
| 158 | 158 | $image_info = array(); | 
| 159 | 159 | } | 
| 160 | 160 | $image_custom = get_post_custom($iid); | 
| 161 | 161 | $basic = get_post($iid); | 
| 162 | -			if ($basic) { | |
| 163 | -				if (isset($basic->post_excerpt)) { | |
| 162 | +			if ( $basic ) { | |
| 163 | +				if ( isset($basic->post_excerpt) ) { | |
| 164 | 164 | $this->caption = $basic->post_excerpt; | 
| 165 | 165 | } | 
| 166 | 166 | $image_custom = array_merge($image_custom, get_object_vars($basic)); | 
| 167 | 167 | } | 
| 168 | 168 | return array_merge($image_info, $image_custom); | 
| 169 | 169 | } | 
| 170 | -		if (is_array($image_info) && isset($image_info['image'])) { | |
| 170 | +		if ( is_array($image_info) && isset($image_info['image']) ) { | |
| 171 | 171 | return $image_info['image']; | 
| 172 | 172 | } | 
| 173 | -		if (is_object($image_info)) { | |
| 173 | +		if ( is_object($image_info) ) { | |
| 174 | 174 | return get_object_vars($image_info); | 
| 175 | 175 | } | 
| 176 | 176 | return $iid; | 
| @@ -202,9 +202,9 @@ discard block | ||
| 202 | 202 | * @internal | 
| 203 | 203 | * @param int $iid | 
| 204 | 204 | */ | 
| 205 | -	function init( $iid = false ) { | |
| 206 | -		if ( !is_numeric( $iid ) && is_string( $iid ) ) { | |
| 207 | -			if (strstr($iid, '://')) { | |
| 205 | +	function init($iid = false) { | |
| 206 | +		if ( !is_numeric($iid) && is_string($iid) ) { | |
| 207 | +			if ( strstr($iid, '://') ) { | |
| 208 | 208 | $this->init_with_url($iid); | 
| 209 | 209 | return; | 
| 210 | 210 | } | 
| @@ -215,15 +215,15 @@ discard block | ||
| 215 | 215 | |
| 216 | 216 | $relative = false; | 
| 217 | 217 | $iid_lower = strtolower($iid); | 
| 218 | -			foreach( $this->file_types as $type ) { if( strstr( $iid_lower, $type ) ) { $relative = true; break; } }; | |
| 218 | +			foreach ($this->file_types as $type) { if ( strstr($iid_lower, $type) ) { $relative = true; break; } }; | |
| 219 | 219 |  			if ( $relative ) { | 
| 220 | - $this->init_with_relative_path( $iid ); | |
| 220 | + $this->init_with_relative_path($iid); | |
| 221 | 221 | return; | 
| 222 | 222 | } | 
| 223 | 223 |  		} else if ( $iid instanceof WP_Post ) { | 
| 224 | 224 | $ref = new ReflectionClass($this); | 
| 225 | 225 | $post = $ref->getParentClass()->newInstance($iid->ID); | 
| 226 | -			if (isset($post->_thumbnail_id) && $post->_thumbnail_id) { | |
| 226 | +			if ( isset($post->_thumbnail_id) && $post->_thumbnail_id ) { | |
| 227 | 227 | return $this->init((int) $post->_thumbnail_id); | 
| 228 | 228 | } | 
| 229 | 229 | return $this->init($post->ID); | 
| @@ -265,9 +265,9 @@ discard block | ||
| 265 | 265 | * @internal | 
| 266 | 266 | * @param string $relative_path | 
| 267 | 267 | */ | 
| 268 | -	protected function init_with_relative_path( $relative_path ) { | |
| 269 | - $this->abs_url = home_url( $relative_path ); | |
| 270 | - $file_path = TimberURLHelper::get_full_path( $relative_path ); | |
| 268 | +	protected function init_with_relative_path($relative_path) { | |
| 269 | + $this->abs_url = home_url($relative_path); | |
| 270 | + $file_path = TimberURLHelper::get_full_path($relative_path); | |
| 271 | 271 | $this->file_loc = $file_path; | 
| 272 | 272 | $this->file = $file_path; | 
| 273 | 273 | } | 
| @@ -276,8 +276,8 @@ discard block | ||
| 276 | 276 | * @internal | 
| 277 | 277 | * @param string $file_path | 
| 278 | 278 | */ | 
| 279 | -	protected function init_with_file_path( $file_path ) { | |
| 280 | - $url = TimberURLHelper::file_system_to_url( $file_path ); | |
| 279 | +	protected function init_with_file_path($file_path) { | |
| 280 | + $url = TimberURLHelper::file_system_to_url($file_path); | |
| 281 | 281 | $this->abs_url = $url; | 
| 282 | 282 | $this->file_loc = $file_path; | 
| 283 | 283 | $this->file = $file_path; | 
| @@ -476,8 +476,8 @@ discard block | ||
| 476 | 476 | * @param string $size | 
| 477 | 477 | * @return bool|string | 
| 478 | 478 | */ | 
| 479 | -	function get_src( $size = '' ) { | |
| 480 | - return $this->src( $size ); | |
| 479 | +	function get_src($size = '') { | |
| 480 | + return $this->src($size); | |
| 481 | 481 | } | 
| 482 | 482 | |
| 483 | 483 | /** | 
| @@ -149,7 +149,7 @@ | ||
| 149 | 149 | /** | 
| 150 | 150 | * | 
| 151 | 151 | * @internal | 
| 152 | - * @return bool | |
| 152 | + * @return boolean|null | |
| 153 | 153 | */ | 
| 154 | 154 |  	function update_child_levels() { | 
| 155 | 155 |  		if (is_array($this->children)) { | 
| @@ -24,15 +24,15 @@ discard block | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | } | 
| @@ -73,7 +73,7 @@ | ||
| 73 | 73 | public $title; | 
| 74 | 74 | |
| 75 | 75 | /** | 
| 76 | - * @param int|string $slug | |
| 76 | + * @param integer $slug | |
| 77 | 77 | */ | 
| 78 | 78 |  	function __construct($slug = 0) { | 
| 79 | 79 | $locations = get_nav_menu_locations(); | 
| @@ -77,16 +77,16 @@ discard block | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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(); | 
| @@ -101,7 +101,7 @@ discard block | ||
| 101 | 101 | $menu = wp_get_nav_menu_items($menu_id); | 
| 102 | 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; | 
| @@ -123,7 +123,7 @@ discard block | ||
| 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; | 
| @@ -201,13 +201,13 @@ discard block | ||
| 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; | 
| @@ -225,7 +225,7 @@ discard block | ||
| 225 | 225 | /** | 
| 226 | 226 | * Initializes a TimberPost | 
| 227 | 227 | * @internal | 
| 228 | - * @param int|bool $pid | |
| 228 | + * @param integer $pid | |
| 229 | 229 | */ | 
| 230 | 230 |  	protected function init($pid = false) { | 
| 231 | 231 |  		if ( $pid === false ) { | 
| @@ -272,7 +272,7 @@ discard block | ||
| 272 | 272 | * takes a mix of integer (post ID), string (post slug), | 
| 273 | 273 | * or object to return a WordPress post object from WP's built-in get_post() function | 
| 274 | 274 | * @internal | 
| 275 | - * @param mixed $pid | |
| 275 | + * @param integer $pid | |
| 276 | 276 | * @return WP_Post on success | 
| 277 | 277 | */ | 
| 278 | 278 |  	protected function prepare_post_info( $pid = 0 ) { | 
| @@ -598,7 +598,7 @@ discard block | ||
| 598 | 598 | * Gets a User object from the author of the post | 
| 599 | 599 | * @internal | 
| 600 | 600 | * @see TimberPost::author | 
| 601 | - * @return bool|TimberUser | |
| 601 | + * @return TimberUser|null | |
| 602 | 602 | */ | 
| 603 | 603 |  	function get_author() { | 
| 604 | 604 |  		if ( isset($this->post_author) ) { | 
| @@ -608,7 +608,7 @@ discard block | ||
| 608 | 608 | |
| 609 | 609 | /** | 
| 610 | 610 | * @internal | 
| 611 | - * @return bool|TimberUser | |
| 611 | + * @return TimberUser|null | |
| 612 | 612 | */ | 
| 613 | 613 |  	function get_modified_author() { | 
| 614 | 614 | $user_id = get_post_meta($this->ID, '_edit_last', true); | 
| @@ -1073,7 +1073,7 @@ discard block | ||
| 1073 | 1073 |  	 *     <a href="{{post.author.link}}">{{post.author.name}}</a> | 
| 1074 | 1074 | * </p> | 
| 1075 | 1075 | * ``` | 
| 1076 | - * @return TimberUser|bool A TimberUser object if found, false if not | |
| 1076 | + * @return TimberUser|null A TimberUser object if found, false if not | |
| 1077 | 1077 | */ | 
| 1078 | 1078 |  	public function author() { | 
| 1079 | 1079 | return $this->get_author(); | 
| @@ -1088,7 +1088,7 @@ discard block | ||
| 1088 | 1088 | * ```html | 
| 1089 | 1089 | * Last updated by Harper Lee | 
| 1090 | 1090 | * ``` | 
| 1091 | - * @return TimberUser|bool A TimberUser object if found, false if not | |
| 1091 | + * @return TimberUser|null A TimberUser object if found, false if not | |
| 1092 | 1092 | */ | 
| 1093 | 1093 |  	public function modified_author() { | 
| 1094 | 1094 | return $this->get_modified_author(); | 
| @@ -188,13 +188,13 @@ discard block | ||
| 188 | 188 | && get_class($wp_query->queried_object) == 'WP_Post' | 
| 189 | 189 |  			) { | 
| 190 | 190 | $pid = $wp_query->queried_object_id; | 
| 191 | -		} else if ( $pid === null && $wp_query->is_home && isset($wp_query->queried_object_id) && $wp_query->queried_object_id )  { | |
| 191 | +		} else if ( $pid === null && $wp_query->is_home && isset($wp_query->queried_object_id) && $wp_query->queried_object_id ) { | |
| 192 | 192 | //hack for static page as home page | 
| 193 | 193 | $pid = $wp_query->queried_object_id; | 
| 194 | 194 |  		} else if ( $pid === null ) { | 
| 195 | 195 | $gtid = false; | 
| 196 | 196 | $maybe_post = get_post(); | 
| 197 | -			if ( isset($maybe_post->ID) ){ | |
| 197 | +			if ( isset($maybe_post->ID) ) { | |
| 198 | 198 | $gtid = true; | 
| 199 | 199 | } | 
| 200 | 200 |  			if ( $gtid ) { | 
| @@ -1028,7 +1028,7 @@ discard block | ||
| 1028 | 1028 | $post = $this; | 
| 1029 | 1029 | $class_array = get_post_class($class, $this->ID); | 
| 1030 | 1030 | $post = $old_global_post; | 
| 1031 | -		if ( is_array($class_array) ){ | |
| 1031 | +		if ( is_array($class_array) ) { | |
| 1032 | 1032 |  			return implode(' ', $class_array); | 
| 1033 | 1033 | } | 
| 1034 | 1034 | return $class_array; | 
| @@ -1248,7 +1248,7 @@ discard block | ||
| 1248 | 1248 | /** | 
| 1249 | 1249 | * @return string | 
| 1250 | 1250 | */ | 
| 1251 | -	public function name(){ | |
| 1251 | +	public function name() { | |
| 1252 | 1252 | return $this->title(); | 
| 1253 | 1253 | } | 
| 1254 | 1254 | |
| @@ -162,7 +162,7 @@ discard block | ||
| 162 | 162 | * @param mixed $pid | 
| 163 | 163 | */ | 
| 164 | 164 |  	public function __construct($pid = null) { | 
| 165 | - $pid = $this->determine_id( $pid ); | |
| 165 | + $pid = $this->determine_id($pid); | |
| 166 | 166 | $this->init($pid); | 
| 167 | 167 | } | 
| 168 | 168 | |
| @@ -181,18 +181,18 @@ discard block | ||
| 181 | 181 | && is_object($wp_query->queried_object) | 
| 182 | 182 | && get_class($wp_query->queried_object) == 'WP_Post' | 
| 183 | 183 |  			) { | 
| 184 | -				if( isset( $_GET['preview'] ) && isset( $_GET['preview_nonce'] ) && wp_verify_nonce( $_GET['preview_nonce'], 'post_preview_' . $wp_query->queried_object_id ) ) { | |
| 185 | - $pid = $this->get_post_preview_id( $wp_query ); | |
| 184 | +				if ( isset($_GET['preview']) && isset($_GET['preview_nonce']) && wp_verify_nonce($_GET['preview_nonce'], 'post_preview_' . $wp_query->queried_object_id) ) { | |
| 185 | + $pid = $this->get_post_preview_id($wp_query); | |
| 186 | 186 |  				} else if ( !$pid ) { | 
| 187 | 187 | $pid = $wp_query->queried_object_id; | 
| 188 | 188 | } | 
| 189 | -		} else if ( $pid === null && $wp_query->is_home && isset($wp_query->queried_object_id) && $wp_query->queried_object_id )  { | |
| 189 | +		} else if ( $pid === null && $wp_query->is_home && isset($wp_query->queried_object_id) && $wp_query->queried_object_id ) { | |
| 190 | 190 | //hack for static page as home page | 
| 191 | 191 | $pid = $wp_query->queried_object_id; | 
| 192 | 192 |  		} else if ( $pid === null ) { | 
| 193 | 193 | $gtid = false; | 
| 194 | 194 | $maybe_post = get_post(); | 
| 195 | -			if ( isset($maybe_post->ID) ){ | |
| 195 | +			if ( isset($maybe_post->ID) ) { | |
| 196 | 196 | $gtid = true; | 
| 197 | 197 | } | 
| 198 | 198 |  			if ( $gtid ) { | 
| @@ -219,7 +219,7 @@ discard block | ||
| 219 | 219 | return $this->title(); | 
| 220 | 220 | } | 
| 221 | 221 | |
| 222 | -	protected function get_post_preview_id( $query ) { | |
| 222 | +	protected function get_post_preview_id($query) { | |
| 223 | 223 | $can = array( | 
| 224 | 224 | 'edit_' . $query->queried_object->post_type . 's', | 
| 225 | 225 | ); | 
| @@ -230,17 +230,17 @@ discard block | ||
| 230 | 230 | |
| 231 | 231 | $continue = true; | 
| 232 | 232 | |
| 233 | -	 	foreach( $can as $type ) { | |
| 234 | -	 		if( !current_user_can( $type ) ) { | |
| 233 | +	 	foreach ($can as $type) { | |
| 234 | +	 		if ( !current_user_can($type) ) { | |
| 235 | 235 | $continue = false; | 
| 236 | 236 | break; | 
| 237 | 237 | } | 
| 238 | 238 | } | 
| 239 | 239 | |
| 240 | -		if( $continue ) { | |
| 241 | - $revisions = wp_get_post_revisions( $query->queried_object_id ); | |
| 240 | +		if ( $continue ) { | |
| 241 | + $revisions = wp_get_post_revisions($query->queried_object_id); | |
| 242 | 242 | |
| 243 | -			if( !empty( $revisions ) ) { | |
| 243 | +			if ( !empty($revisions) ) { | |
| 244 | 244 | $last = end($revisions); | 
| 245 | 245 | return $last->ID; | 
| 246 | 246 |  			} else { | 
| @@ -285,7 +285,7 @@ discard block | ||
| 285 | 285 | * @param string $field | 
| 286 | 286 | * @param mixed $value | 
| 287 | 287 | */ | 
| 288 | -	public function update( $field, $value ) { | |
| 288 | +	public function update($field, $value) { | |
| 289 | 289 |  		if ( isset($this->ID) ) { | 
| 290 | 290 | update_post_meta($this->ID, $field, $value); | 
| 291 | 291 | $this->$field = $value; | 
| @@ -300,7 +300,7 @@ discard block | ||
| 300 | 300 | * @param mixed $pid | 
| 301 | 301 | * @return WP_Post on success | 
| 302 | 302 | */ | 
| 303 | -	protected function prepare_post_info( $pid = 0 ) { | |
| 303 | +	protected function prepare_post_info($pid = 0) { | |
| 304 | 304 |  		if ( is_string($pid) || is_numeric($pid) || (is_object($pid) && !isset($pid->post_title)) || $pid === 0 ) { | 
| 305 | 305 | $pid = self::check_post_id($pid); | 
| 306 | 306 | $post = get_post($pid); | 
| @@ -319,7 +319,7 @@ discard block | ||
| 319 | 319 | * @internal | 
| 320 | 320 | * @return integer ID number of a post | 
| 321 | 321 | */ | 
| 322 | -	protected function check_post_id( $pid ) { | |
| 322 | +	protected function check_post_id($pid) { | |
| 323 | 323 |  		if ( is_numeric($pid) && $pid === 0 ) { | 
| 324 | 324 | $pid = get_the_ID(); | 
| 325 | 325 | return $pid; | 
| @@ -345,7 +345,7 @@ discard block | ||
| 345 | 345 | global $wpdb; | 
| 346 | 346 |  		$query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_name = %s LIMIT 1", $post_name); | 
| 347 | 347 | $result = $wpdb->get_row($query); | 
| 348 | -		if (!$result) { | |
| 348 | +		if ( !$result ) { | |
| 349 | 349 | return null; | 
| 350 | 350 | } | 
| 351 | 351 | return $result->ID; | 
| @@ -385,7 +385,7 @@ discard block | ||
| 385 | 385 | $text = TimberHelper::trim_words($text, $len, false); | 
| 386 | 386 | $trimmed = true; | 
| 387 | 387 | } | 
| 388 | - $text = do_shortcode( $text ); | |
| 388 | + $text = do_shortcode($text); | |
| 389 | 389 | } | 
| 390 | 390 |  		if ( !strlen($text) ) { | 
| 391 | 391 | $text = TimberHelper::trim_words($this->get_content(), $len, false); | 
| @@ -414,11 +414,11 @@ discard block | ||
| 414 | 414 | } | 
| 415 | 415 |  			$read_more_class = apply_filters('timber/post/get_preview/read_more_class', "read-more"); | 
| 416 | 416 |  			if ( $readmore && isset($readmore_matches) && !empty($readmore_matches[1]) ) { | 
| 417 | - $text .= ' <a href="' . $this->get_permalink() . '" class="'.$read_more_class .'">' . trim($readmore_matches[1]) . '</a>'; | |
| 417 | + $text .= ' <a href="' . $this->get_permalink() . '" class="' . $read_more_class . '">' . trim($readmore_matches[1]) . '</a>'; | |
| 418 | 418 |  			} elseif ( $readmore ) { | 
| 419 | - $text .= ' <a href="' . $this->get_permalink() . '" class="'.$read_more_class .'">' . trim($readmore) . '</a>'; | |
| 419 | + $text .= ' <a href="' . $this->get_permalink() . '" class="' . $read_more_class . '">' . trim($readmore) . '</a>'; | |
| 420 | 420 | } | 
| 421 | -			if ( !$strip && $last_p_tag && ( strpos($text, '<p>') || strpos($text, '<p ') ) ) { | |
| 421 | +			if ( !$strip && $last_p_tag && (strpos($text, '<p>') || strpos($text, '<p ')) ) { | |
| 422 | 422 | $text .= '</p>'; | 
| 423 | 423 | } | 
| 424 | 424 | } | 
| @@ -430,7 +430,7 @@ discard block | ||
| 430 | 430 | * @internal | 
| 431 | 431 | * @param bool|int $pid a post ID number | 
| 432 | 432 | */ | 
| 433 | -	function import_custom( $pid = false ) { | |
| 433 | +	function import_custom($pid = false) { | |
| 434 | 434 |  		if ( !$pid ) { | 
| 435 | 435 | $pid = $this->ID; | 
| 436 | 436 | } | 
| @@ -445,13 +445,13 @@ discard block | ||
| 445 | 445 | * @param int $pid | 
| 446 | 446 | * @return array | 
| 447 | 447 | */ | 
| 448 | -	protected function get_post_custom( $pid ) { | |
| 448 | +	protected function get_post_custom($pid) { | |
| 449 | 449 |  		apply_filters('timber_post_get_meta_pre', array(), $pid, $this); | 
| 450 | 450 | $customs = get_post_custom($pid); | 
| 451 | 451 |  		if ( !is_array($customs) || empty($customs) ) { | 
| 452 | 452 | return array(); | 
| 453 | 453 | } | 
| 454 | -		foreach ( $customs as $key => $value ) { | |
| 454 | +		foreach ($customs as $key => $value) { | |
| 455 | 455 |  			if ( is_array($value) && count($value) == 1 && isset($value[0]) ) { | 
| 456 | 456 | $value = $value[0]; | 
| 457 | 457 | } | 
| @@ -505,7 +505,7 @@ discard block | ||
| 505 | 505 | * @param bool $taxonomy | 
| 506 | 506 | * @return TimberPost|boolean | 
| 507 | 507 | */ | 
| 508 | -	function get_next( $taxonomy = false ) { | |
| 508 | +	function get_next($taxonomy = false) { | |
| 509 | 509 |  		if ( !isset($this->_next) || !isset($this->_next[$taxonomy]) ) { | 
| 510 | 510 | global $post; | 
| 511 | 511 | $this->_next = array(); | 
| @@ -536,7 +536,7 @@ discard block | ||
| 536 | 536 | $post = $this; | 
| 537 | 537 | $ret = array(); | 
| 538 | 538 |  		if ( $multipage ) { | 
| 539 | -			for ( $i = 1; $i <= $numpages; $i++ ) { | |
| 539 | +			for ($i = 1; $i <= $numpages; $i++) { | |
| 540 | 540 | $link = self::get_wp_link_page($i); | 
| 541 | 541 |  				$data = array('name' => $i, 'title' => $i, 'text' => $i, 'link' => $link); | 
| 542 | 542 |  				if ( $i == $page ) { | 
| @@ -588,7 +588,7 @@ discard block | ||
| 588 | 588 | * @param bool $taxonomy | 
| 589 | 589 | * @return TimberPost|boolean | 
| 590 | 590 | */ | 
| 591 | -	function get_prev( $taxonomy = false ) { | |
| 591 | +	function get_prev($taxonomy = false) { | |
| 592 | 592 |  		if ( isset($this->_prev) && isset($this->_prev[$taxonomy]) ) { | 
| 593 | 593 | return $this->_prev[$taxonomy]; | 
| 594 | 594 | } | 
| @@ -655,7 +655,7 @@ discard block | ||
| 655 | 655 | $post->slug = $post->post_name; | 
| 656 | 656 | $customs = $this->get_post_custom($post->ID); | 
| 657 | 657 | $post->custom = $customs; | 
| 658 | - $post = (object) array_merge((array)$customs, (array)$post); | |
| 658 | + $post = (object) array_merge((array) $customs, (array) $post); | |
| 659 | 659 | return $post; | 
| 660 | 660 | } | 
| 661 | 661 | |
| @@ -665,9 +665,9 @@ discard block | ||
| 665 | 665 | * @param string $date_format | 
| 666 | 666 | * @return string | 
| 667 | 667 | */ | 
| 668 | -	function get_date( $date_format = '' ) { | |
| 668 | +	function get_date($date_format = '') { | |
| 669 | 669 |  		$df = $date_format ? $date_format : get_option('date_format'); | 
| 670 | - $the_date = (string)mysql2date($df, $this->post_date); | |
| 670 | + $the_date = (string) mysql2date($df, $this->post_date); | |
| 671 | 671 |  		return apply_filters('get_the_date', $the_date, $df); | 
| 672 | 672 | } | 
| 673 | 673 | |
| @@ -676,7 +676,7 @@ discard block | ||
| 676 | 676 | * @param string $date_format | 
| 677 | 677 | * @return string | 
| 678 | 678 | */ | 
| 679 | -	function get_modified_date( $date_format = '' ) { | |
| 679 | +	function get_modified_date($date_format = '') { | |
| 680 | 680 |  		$df = $date_format ? $date_format : get_option('date_format'); | 
| 681 | 681 | $the_time = $this->get_modified_time($df); | 
| 682 | 682 |  		return apply_filters('get_the_modified_date', $the_time, $date_format); | 
| @@ -687,7 +687,7 @@ discard block | ||
| 687 | 687 | * @param string $time_format | 
| 688 | 688 | * @return string | 
| 689 | 689 | */ | 
| 690 | -	function get_modified_time( $time_format = '' ) { | |
| 690 | +	function get_modified_time($time_format = '') { | |
| 691 | 691 |  		$tf = $time_format ? $time_format : get_option('time_format'); | 
| 692 | 692 | $the_time = get_post_modified_time($tf, false, $this->ID, true); | 
| 693 | 693 |  		return apply_filters('get_the_modified_time', $the_time, $time_format); | 
| @@ -700,7 +700,7 @@ discard block | ||
| 700 | 700 | * @param bool|string $childPostClass | 
| 701 | 701 | * @return array | 
| 702 | 702 | */ | 
| 703 | -	function get_children( $post_type = 'any', $childPostClass = false ) { | |
| 703 | +	function get_children($post_type = 'any', $childPostClass = false) { | |
| 704 | 704 |  		if ( $childPostClass === false ) { | 
| 705 | 705 | $childPostClass = $this->PostClass; | 
| 706 | 706 | } | 
| @@ -708,7 +708,7 @@ discard block | ||
| 708 | 708 | $post_type = $this->post_type; | 
| 709 | 709 | } | 
| 710 | 710 |  		$children = get_children('post_parent=' . $this->ID . '&post_type=' . $post_type . '&numberposts=-1&orderby=menu_order title&order=ASC'); | 
| 711 | -		foreach ( $children as &$child ) { | |
| 711 | +		foreach ($children as &$child) { | |
| 712 | 712 | $child = new $childPostClass($child->ID); | 
| 713 | 713 | } | 
| 714 | 714 | $children = array_values($children); | 
| @@ -745,42 +745,42 @@ discard block | ||
| 745 | 745 | } | 
| 746 | 746 | |
| 747 | 747 |  		if ( $user_ID ) { | 
| 748 | - $args['include_unapproved'] = array( $user_ID ); | |
| 749 | -		} elseif ( ! empty( $comment_author_email ) ) { | |
| 750 | - $args['include_unapproved'] = array( $comment_author_email ); | |
| 748 | + $args['include_unapproved'] = array($user_ID); | |
| 749 | +		} elseif ( !empty($comment_author_email) ) { | |
| 750 | + $args['include_unapproved'] = array($comment_author_email); | |
| 751 | 751 | } | 
| 752 | 752 | |
| 753 | 753 | $comments = get_comments($args); | 
| 754 | 754 | $timber_comments = array(); | 
| 755 | 755 | |
| 756 | 756 |  		if ( '' == get_query_var('cpage') && get_option('page_comments') ) { | 
| 757 | -			set_query_var( 'cpage', 'newest' == get_option('default_comments_page') ? get_comment_pages_count() : 1 ); | |
| 757 | +			set_query_var('cpage', 'newest' == get_option('default_comments_page') ? get_comment_pages_count() : 1); | |
| 758 | 758 | $overridden_cpage = true; | 
| 759 | 759 | } | 
| 760 | 760 | |
| 761 | -		foreach($comments as $key => &$comment) { | |
| 761 | +		foreach ($comments as $key => &$comment) { | |
| 762 | 762 | $timber_comment = new $CommentClass($comment); | 
| 763 | 763 | $timber_comments[$timber_comment->id] = $timber_comment; | 
| 764 | 764 | } | 
| 765 | 765 | |
| 766 | 766 | // Build a flattened (depth=1) comment tree | 
| 767 | 767 | $comments_tree = array(); | 
| 768 | -		foreach( $timber_comments as $key => $comment ) { | |
| 769 | -			if ( ! $comment->is_child() ) { | |
| 768 | +		foreach ($timber_comments as $key => $comment) { | |
| 769 | +			if ( !$comment->is_child() ) { | |
| 770 | 770 | continue; | 
| 771 | 771 | } | 
| 772 | 772 | |
| 773 | 773 | $tree_element = $comment; | 
| 774 | 774 |  			do { | 
| 775 | 775 | $tree_element = $timber_comments[$tree_element->comment_parent]; | 
| 776 | - } while( $tree_element->is_child() ); | |
| 776 | + } while ($tree_element->is_child()); | |
| 777 | 777 | |
| 778 | 778 | $comments_tree[$tree_element->id][] = $comment->id; | 
| 779 | 779 | } | 
| 780 | 780 | |
| 781 | 781 | // Add child comments to the relative "super parents" | 
| 782 | -		foreach($comments_tree as $comment_parent => $comment_children) { | |
| 783 | -			foreach($comment_children as $comment_child) { | |
| 782 | +		foreach ($comments_tree as $comment_parent => $comment_children) { | |
| 783 | +			foreach ($comment_children as $comment_child) { | |
| 784 | 784 | $timber_comments[$comment_parent]->children[] = $timber_comments[$comment_child]; | 
| 785 | 785 | unset($timber_comments[$comment_child]); | 
| 786 | 786 | } | 
| @@ -820,7 +820,7 @@ discard block | ||
| 820 | 820 | * @param string $TermClass | 
| 821 | 821 | * @return array | 
| 822 | 822 | */ | 
| 823 | -	function get_terms( $tax = '', $merge = true, $TermClass = '' ) { | |
| 823 | +	function get_terms($tax = '', $merge = true, $TermClass = '') { | |
| 824 | 824 | |
| 825 | 825 | $TermClass = $TermClass ?: $this->TermClass; | 
| 826 | 826 | |
| @@ -831,7 +831,7 @@ discard block | ||
| 831 | 831 | $taxonomies = $tax; | 
| 832 | 832 | } | 
| 833 | 833 |  		if ( is_string($tax) ) { | 
| 834 | -			if ( in_array($tax, array('all','any','')) ) { | |
| 834 | +			if ( in_array($tax, array('all', 'any', '')) ) { | |
| 835 | 835 | $taxonomies = get_object_taxonomies($this->post_type); | 
| 836 | 836 |  			} else { | 
| 837 | 837 | $taxonomies = array($tax); | 
| @@ -840,8 +840,8 @@ discard block | ||
| 840 | 840 | |
| 841 | 841 | $term_class_objects = array(); | 
| 842 | 842 | |
| 843 | -		foreach ( $taxonomies as $taxonomy ) { | |
| 844 | -			if ( in_array($taxonomy, array('tag','tags')) ) { | |
| 843 | +		foreach ($taxonomies as $taxonomy) { | |
| 844 | +			if ( in_array($taxonomy, array('tag', 'tags')) ) { | |
| 845 | 845 | $taxonomy = 'post_tag'; | 
| 846 | 846 | } | 
| 847 | 847 |  			if ( $taxonomy == 'categories' ) { | 
| @@ -878,11 +878,11 @@ discard block | ||
| 878 | 878 | * @param string $taxonomy | 
| 879 | 879 | * @return bool | 
| 880 | 880 | */ | 
| 881 | -	function has_term( $term_name_or_id, $taxonomy = 'all' ) { | |
| 881 | +	function has_term($term_name_or_id, $taxonomy = 'all') { | |
| 882 | 882 |  		if ( $taxonomy == 'all' || $taxonomy == 'any' ) { | 
| 883 | 883 | $taxes = get_object_taxonomies($this->post_type, 'names'); | 
| 884 | 884 | $ret = false; | 
| 885 | -			foreach ( $taxes as $tax ) { | |
| 885 | +			foreach ($taxes as $tax) { | |
| 886 | 886 |  				if ( has_term($term_name_or_id, $tax, $this->ID) ) { | 
| 887 | 887 | $ret = true; | 
| 888 | 888 | break; | 
| @@ -897,7 +897,7 @@ discard block | ||
| 897 | 897 | * @param string $field | 
| 898 | 898 | * @return TimberImage | 
| 899 | 899 | */ | 
| 900 | -	function get_image( $field ) { | |
| 900 | +	function get_image($field) { | |
| 901 | 901 | return new $this->ImageClass($this->$field); | 
| 902 | 902 | } | 
| 903 | 903 | |
| @@ -947,7 +947,7 @@ discard block | ||
| 947 | 947 | * @param int $page | 
| 948 | 948 | * @return string | 
| 949 | 949 | */ | 
| 950 | -	function get_content( $len = 0, $page = 0 ) { | |
| 950 | +	function get_content($len = 0, $page = 0) { | |
| 951 | 951 |  		if ( $len == 0 && $page == 0 && $this->_content ) { | 
| 952 | 952 | return $this->_content; | 
| 953 | 953 | } | 
| @@ -1004,7 +1004,7 @@ discard block | ||
| 1004 | 1004 | * @param string $field_name | 
| 1005 | 1005 | * @return mixed | 
| 1006 | 1006 | */ | 
| 1007 | -	public function get_field( $field_name ) { | |
| 1007 | +	public function get_field($field_name) { | |
| 1008 | 1008 |  		$value = apply_filters('timber_post_get_meta_field_pre', null, $this->ID, $field_name, $this); | 
| 1009 | 1009 |  		if ( $value === null ) { | 
| 1010 | 1010 | $value = get_post_meta($this->ID, $field_name); | 
| @@ -1022,7 +1022,7 @@ discard block | ||
| 1022 | 1022 | /** | 
| 1023 | 1023 | * @param string $field_name | 
| 1024 | 1024 | */ | 
| 1025 | -	function import_field( $field_name ) { | |
| 1025 | +	function import_field($field_name) { | |
| 1026 | 1026 | $this->$field_name = $this->get_field($field_name); | 
| 1027 | 1027 | } | 
| 1028 | 1028 | |
| @@ -1053,13 +1053,13 @@ discard block | ||
| 1053 | 1053 | * ``` | 
| 1054 | 1054 | * @return string a space-seperated list of classes | 
| 1055 | 1055 | */ | 
| 1056 | -	public function post_class( $class='' ) { | |
| 1056 | +	public function post_class($class = '') { | |
| 1057 | 1057 | global $post; | 
| 1058 | 1058 | $old_global_post = $post; | 
| 1059 | 1059 | $post = $this; | 
| 1060 | 1060 | $class_array = get_post_class($class, $this->ID); | 
| 1061 | 1061 | $post = $old_global_post; | 
| 1062 | -		if ( is_array($class_array) ){ | |
| 1062 | +		if ( is_array($class_array) ) { | |
| 1063 | 1063 |  			return implode(' ', $class_array); | 
| 1064 | 1064 | } | 
| 1065 | 1065 | return $class_array; | 
| @@ -1161,8 +1161,8 @@ discard block | ||
| 1161 | 1161 | * @param string|bool $childPostClass _optional_ a custom post class (ex: 'MyTimberPost') to return the objects as. By default (false) it will use TimberPost::$post_class value. | 
| 1162 | 1162 | * @return array | 
| 1163 | 1163 | */ | 
| 1164 | -	public function children( $post_type = 'any', $childPostClass = false ) { | |
| 1165 | - return $this->get_children( $post_type, $childPostClass ); | |
| 1164 | +	public function children($post_type = 'any', $childPostClass = false) { | |
| 1165 | + return $this->get_children($post_type, $childPostClass); | |
| 1166 | 1166 | } | 
| 1167 | 1167 | |
| 1168 | 1168 | /** | 
| @@ -1186,7 +1186,7 @@ discard block | ||
| 1186 | 1186 | * ``` | 
| 1187 | 1187 | * @return bool|array | 
| 1188 | 1188 | */ | 
| 1189 | -	public function comments( $count = 0, $order = 'wp', $type = 'comment', $status = 'approve', $CommentClass = 'TimberComment' ) { | |
| 1189 | +	public function comments($count = 0, $order = 'wp', $type = 'comment', $status = 'approve', $CommentClass = 'TimberComment') { | |
| 1190 | 1190 | return $this->get_comments($count, $order, $type, $status, $CommentClass); | 
| 1191 | 1191 | } | 
| 1192 | 1192 | |
| @@ -1203,7 +1203,7 @@ discard block | ||
| 1203 | 1203 | * @param int $page | 
| 1204 | 1204 | * @return string | 
| 1205 | 1205 | */ | 
| 1206 | -	public function content( $page = 0 ) { | |
| 1206 | +	public function content($page = 0) { | |
| 1207 | 1207 | return $this->get_content(0, $page); | 
| 1208 | 1208 | } | 
| 1209 | 1209 | |
| @@ -1232,7 +1232,7 @@ discard block | ||
| 1232 | 1232 | * @param string $date_format | 
| 1233 | 1233 | * @return string | 
| 1234 | 1234 | */ | 
| 1235 | -	public function date( $date_format = '' ) { | |
| 1235 | +	public function date($date_format = '') { | |
| 1236 | 1236 | return $this->get_date($date_format); | 
| 1237 | 1237 | } | 
| 1238 | 1238 | |
| @@ -1254,9 +1254,9 @@ discard block | ||
| 1254 | 1254 | * @param string $time_format | 
| 1255 | 1255 | * @return string | 
| 1256 | 1256 | */ | 
| 1257 | -	public function time( $time_format = '' ) { | |
| 1257 | +	public function time($time_format = '') { | |
| 1258 | 1258 |  		$tf = $time_format ? $time_format : get_option('time_format'); | 
| 1259 | - $the_time = (string)mysql2date($tf, $this->post_date); | |
| 1259 | + $the_time = (string) mysql2date($tf, $this->post_date); | |
| 1260 | 1260 |  	 	return apply_filters('get_the_time', $the_time, $tf); | 
| 1261 | 1261 | } | 
| 1262 | 1262 | |
| @@ -1292,7 +1292,7 @@ discard block | ||
| 1292 | 1292 | * @param string $field_name | 
| 1293 | 1293 | * @return mixed | 
| 1294 | 1294 | */ | 
| 1295 | -	public function meta( $field_name = null ) { | |
| 1295 | +	public function meta($field_name = null) { | |
| 1296 | 1296 |  		if ( $field_name === null ) { | 
| 1297 | 1297 | //on the off-chance the field is actually named meta | 
| 1298 | 1298 | $field_name = 'meta'; | 
| @@ -1303,7 +1303,7 @@ discard block | ||
| 1303 | 1303 | /** | 
| 1304 | 1304 | * @return string | 
| 1305 | 1305 | */ | 
| 1306 | -	public function name(){ | |
| 1306 | +	public function name() { | |
| 1307 | 1307 | return $this->title(); | 
| 1308 | 1308 | } | 
| 1309 | 1309 | |
| @@ -1311,7 +1311,7 @@ discard block | ||
| 1311 | 1311 | * @param string $date_format | 
| 1312 | 1312 | * @return string | 
| 1313 | 1313 | */ | 
| 1314 | -	public function modified_date( $date_format = '' ) { | |
| 1314 | +	public function modified_date($date_format = '') { | |
| 1315 | 1315 | return $this->get_modified_date($date_format); | 
| 1316 | 1316 | } | 
| 1317 | 1317 | |
| @@ -1319,7 +1319,7 @@ discard block | ||
| 1319 | 1319 | * @param string $time_format | 
| 1320 | 1320 | * @return string | 
| 1321 | 1321 | */ | 
| 1322 | -	public function modified_time( $time_format = '' ) { | |
| 1322 | +	public function modified_time($time_format = '') { | |
| 1323 | 1323 | return $this->get_modified_time($time_format); | 
| 1324 | 1324 | } | 
| 1325 | 1325 | |
| @@ -1328,7 +1328,7 @@ discard block | ||
| 1328 | 1328 | * @param bool $in_same_cat | 
| 1329 | 1329 | * @return mixed | 
| 1330 | 1330 | */ | 
| 1331 | -	public function next( $in_same_cat = false ) { | |
| 1331 | +	public function next($in_same_cat = false) { | |
| 1332 | 1332 | return $this->get_next($in_same_cat); | 
| 1333 | 1333 | } | 
| 1334 | 1334 | |
| @@ -1386,7 +1386,7 @@ discard block | ||
| 1386 | 1386 | * @param bool $in_same_cat | 
| 1387 | 1387 | * @return mixed | 
| 1388 | 1388 | */ | 
| 1389 | -	public function prev( $in_same_cat = false ) { | |
| 1389 | +	public function prev($in_same_cat = false) { | |
| 1390 | 1390 | return $this->get_prev($in_same_cat); | 
| 1391 | 1391 | } | 
| 1392 | 1392 | |
| @@ -1398,7 +1398,7 @@ discard block | ||
| 1398 | 1398 | * @param bool $merge Should the resulting array be one big one (true)? Or should it be an array of sub-arrays for each taxonomy (false)? | 
| 1399 | 1399 | * @return array | 
| 1400 | 1400 | */ | 
| 1401 | -	public function terms( $tax = '', $merge = true ) { | |
| 1401 | +	public function terms($tax = '', $merge = true) { | |
| 1402 | 1402 | return $this->get_terms($tax, $merge); | 
| 1403 | 1403 | } | 
| 1404 | 1404 | |
| @@ -4,6 +4,7 @@ discard block | ||
| 4 | 4 | |
| 5 | 5 | /** | 
| 6 | 6 | * @deprecated since 0.21.1 use Upstatement/routes instead | 
| 7 | + * @param Timber $timber | |
| 7 | 8 | */ | 
| 8 | 9 |  	public static function init( $timber ) { | 
| 9 | 10 | // Install ourselves in Timber | 
| @@ -24,7 +25,7 @@ discard block | ||
| 24 | 25 | * @param mixed $query | 
| 25 | 26 | * @param int $status_code | 
| 26 | 27 | * @param bool $tparams | 
| 27 | - * @return bool | |
| 28 | + * @return boolean|null | |
| 28 | 29 | * @deprecated since 0.21.1 use Upstatement/routes instead | 
| 29 | 30 | */ | 
| 30 | 31 |  	public static function load_view($template, $query = false, $status_code = 200, $tparams = false) { | 
| @@ -5,7 +5,7 @@ | ||
| 5 | 5 | /** | 
| 6 | 6 | * @deprecated since 0.21.1 use Upstatement/routes instead | 
| 7 | 7 | */ | 
| 8 | -	public static function init( $timber ) { | |
| 8 | +	public static function init($timber) { | |
| 9 | 9 | // Install ourselves in Timber | 
| 10 | 10 | $timber->routes = new TimberRoutes(); | 
| 11 | 11 | } | 
| @@ -136,6 +136,9 @@ discard block | ||
| 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 | ||
| 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 | ||
| 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: | 
| @@ -9,8 +9,8 @@ discard block | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | ||
| 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 | } | 
| @@ -267,8 +267,9 @@ | ||
| 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 | |
| @@ -11,16 +11,16 @@ | ||
| 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 | |