@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | * } |
| 55 | 55 | * @param string $base any additional paths that need to be prepended to the URLs that are generated, for example: "tags" |
| 56 | 56 | */ |
| 57 | - function __construct( $args = null, $base = '' ) { |
|
| 57 | + function __construct($args = null, $base = '') { |
|
| 58 | 58 | $this->init($args, $base); |
| 59 | 59 | } |
| 60 | 60 | |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | * @param array|string $args |
| 64 | 64 | * @param string $base |
| 65 | 65 | */ |
| 66 | - function init( $args = null, $base = '' ) { |
|
| 66 | + function init($args = null, $base = '') { |
|
| 67 | 67 | $this->base = $base; |
| 68 | 68 | $this->items = $this->get_items($args); |
| 69 | 69 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * @param string $text |
| 75 | 75 | * @return mixed |
| 76 | 76 | */ |
| 77 | - protected function get_archives_link( $url, $text ) { |
|
| 77 | + protected function get_archives_link($url, $text) { |
|
| 78 | 78 | $ret = array(); |
| 79 | 79 | $ret['text'] = $ret['title'] = $ret['name'] = wptexturize($text); |
| 80 | 80 | $ret['url'] = $ret['link'] = esc_url(TimberURLHelper::prepend_to_url($url, $this->base)); |
@@ -91,19 +91,19 @@ discard block |
||
| 91 | 91 | * @param string $limit |
| 92 | 92 | * @return array |
| 93 | 93 | */ |
| 94 | - protected function get_items_yearly( $args, $last_changed, $join, $where, $order, $limit ) { |
|
| 94 | + protected function get_items_yearly($args, $last_changed, $join, $where, $order, $limit) { |
|
| 95 | 95 | global $wpdb; |
| 96 | 96 | $output = array(); |
| 97 | 97 | $query = "SELECT YEAR(post_date) AS `year`, count(ID) as posts FROM {$wpdb->posts} $join $where GROUP BY YEAR(post_date) ORDER BY post_date $order $limit"; |
| 98 | 98 | $key = md5($query); |
| 99 | 99 | $key = "wp_get_archives:$key:$last_changed"; |
| 100 | - if (!$results = wp_cache_get($key, 'posts')) { |
|
| 100 | + if ( !$results = wp_cache_get($key, 'posts') ) { |
|
| 101 | 101 | $results = $wpdb->get_results($query); |
| 102 | 102 | wp_cache_set($key, $results, 'posts'); |
| 103 | 103 | } |
| 104 | - if ($results) { |
|
| 105 | - foreach ( (array)$results as $result ) { |
|
| 106 | - $url = get_year_link( $result->year ); |
|
| 104 | + if ( $results ) { |
|
| 105 | + foreach ((array) $results as $result) { |
|
| 106 | + $url = get_year_link($result->year); |
|
| 107 | 107 | $text = sprintf('%d', $result->year); |
| 108 | 108 | $output[] = $this->get_archives_link($url, $text); |
| 109 | 109 | } |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | * @param bool $nested |
| 123 | 123 | * @return array |
| 124 | 124 | */ |
| 125 | - protected function get_items_monthly( $args, $last_changed, $join, $where, $order, $limit = 1000, $nested = true ) { |
|
| 125 | + protected function get_items_monthly($args, $last_changed, $join, $where, $order, $limit = 1000, $nested = true) { |
|
| 126 | 126 | global $wpdb, $wp_locale; |
| 127 | 127 | $output = array(); |
| 128 | 128 | $defaults = array( |
@@ -137,26 +137,26 @@ discard block |
||
| 137 | 137 | . "ORDER BY post_date $order $limit"; |
| 138 | 138 | $key = md5($query); |
| 139 | 139 | $key = "wp_get_archives:$key:$last_changed"; |
| 140 | - if (!$results = wp_cache_get($key, 'posts')) { |
|
| 140 | + if ( !$results = wp_cache_get($key, 'posts') ) { |
|
| 141 | 141 | $results = $wpdb->get_results($query); |
| 142 | 142 | wp_cache_set($key, $results, 'posts'); |
| 143 | 143 | } |
| 144 | - if ($results) { |
|
| 145 | - foreach ((array)$results as $result) { |
|
| 144 | + if ( $results ) { |
|
| 145 | + foreach ((array) $results as $result) { |
|
| 146 | 146 | $url = get_month_link($result->year, $result->month); |
| 147 | - if ($show_year && !$nested) { |
|
| 147 | + if ( $show_year && !$nested ) { |
|
| 148 | 148 | $text = sprintf(__('%1$s %2$d'), $wp_locale->get_month($result->month), $result->year); |
| 149 | 149 | } else { |
| 150 | 150 | $text = sprintf(__('%1$s'), $wp_locale->get_month($result->month)); |
| 151 | 151 | } |
| 152 | - if ($nested) { |
|
| 152 | + if ( $nested ) { |
|
| 153 | 153 | $output[$result->year][] = $this->get_archives_link($url, $text); |
| 154 | 154 | } else { |
| 155 | 155 | $output[] = $this->get_archives_link($url, $text); |
| 156 | 156 | } |
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | - if ($nested) { |
|
| 159 | + if ( $nested ) { |
|
| 160 | 160 | $out2 = array(); |
| 161 | 161 | foreach ($output as $year => $months) { |
| 162 | 162 | $out2[] = array('name' => $year, 'children' => $months); |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | * @param array|string $args |
| 172 | 172 | * @return array|string |
| 173 | 173 | */ |
| 174 | - function get_items( $args = null ) { |
|
| 174 | + function get_items($args = null) { |
|
| 175 | 175 | global $wpdb; |
| 176 | 176 | |
| 177 | 177 | $defaults = array( |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | $archive_week_start_date_format = 'Y/m/d'; |
| 221 | 221 | $archive_week_end_date_format = 'Y/m/d'; |
| 222 | 222 | |
| 223 | - if (!$archive_date_format_over_ride) { |
|
| 223 | + if ( !$archive_date_format_over_ride ) { |
|
| 224 | 224 | $archive_day_date_format = get_option('date_format'); |
| 225 | 225 | $archive_week_start_date_format = get_option('date_format'); |
| 226 | 226 | $archive_week_end_date_format = get_option('date_format'); |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | |
| 233 | 233 | $output = array(); |
| 234 | 234 | $last_changed = wp_cache_get('last_changed', 'posts'); |
| 235 | - if (!$last_changed) { |
|
| 235 | + if ( !$last_changed ) { |
|
| 236 | 236 | $last_changed = microtime(); |
| 237 | 237 | wp_cache_set('last_changed', $last_changed, 'posts'); |
| 238 | 238 | } |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | $output = $this->get_items_yearly($args, $last_changed, $join, $where, $order, $limit); |
| 243 | 243 | } elseif ( 'monthly-nested' == $type ) { |
| 244 | 244 | $years = $this->get_items_yearly($args, $last_changed, $join, $where, $order, $limit); |
| 245 | - foreach ( $years as &$year ) { |
|
| 245 | + foreach ($years as &$year) { |
|
| 246 | 246 | $args = array('show_year' => false); |
| 247 | 247 | $year['children'] = $this->get_items_monthly($args, $last_changed, $join, $where, $order, $limit); |
| 248 | 248 | } |
@@ -251,14 +251,14 @@ discard block |
||
| 251 | 251 | $query = "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date $order $limit"; |
| 252 | 252 | $key = md5($query); |
| 253 | 253 | $key = "wp_get_archives:$key:$last_changed"; |
| 254 | - if (!$results = wp_cache_get($key, 'posts')) { |
|
| 254 | + if ( !$results = wp_cache_get($key, 'posts') ) { |
|
| 255 | 255 | $results = $wpdb->get_results($query); |
| 256 | 256 | $cache = array(); |
| 257 | 257 | $cache[$key] = $results; |
| 258 | 258 | wp_cache_set($key, $results, 'posts'); |
| 259 | 259 | } |
| 260 | 260 | if ( $results ) { |
| 261 | - foreach ( (array)$results as $result ) { |
|
| 261 | + foreach ((array) $results as $result) { |
|
| 262 | 262 | $url = get_day_link($result->year, $result->month, $result->dayofmonth); |
| 263 | 263 | $date = sprintf('%1$d-%2$02d-%3$02d 00:00:00', $result->year, $result->month, $result->dayofmonth); |
| 264 | 264 | $text = mysql2date($archive_day_date_format, $date); |
@@ -271,13 +271,13 @@ discard block |
||
| 271 | 271 | . "count( `ID` ) AS `posts` FROM `$wpdb->posts` $join $where GROUP BY $week, YEAR( `post_date` ) ORDER BY `post_date` $order $limit"; |
| 272 | 272 | $key = md5($query); |
| 273 | 273 | $key = "wp_get_archives:$key:$last_changed"; |
| 274 | - if (!$results = wp_cache_get($key, 'posts')) { |
|
| 274 | + if ( !$results = wp_cache_get($key, 'posts') ) { |
|
| 275 | 275 | $results = $wpdb->get_results($query); |
| 276 | 276 | wp_cache_set($key, $results, 'posts'); |
| 277 | 277 | } |
| 278 | 278 | $arc_w_last = ''; |
| 279 | 279 | if ( $results ) { |
| 280 | - foreach ( (array)$results as $result ) { |
|
| 280 | + foreach ((array) $results as $result) { |
|
| 281 | 281 | if ( $result->week != $arc_w_last ) { |
| 282 | 282 | $arc_year = $result->yr; |
| 283 | 283 | $arc_w_last = $result->week; |
@@ -300,10 +300,10 @@ discard block |
||
| 300 | 300 | wp_cache_set($key, $results, 'posts'); |
| 301 | 301 | } |
| 302 | 302 | if ( $results ) { |
| 303 | - foreach ( (array)$results as $result ) { |
|
| 304 | - if ($result->post_date != '0000-00-00 00:00:00') { |
|
| 303 | + foreach ((array) $results as $result) { |
|
| 304 | + if ( $result->post_date != '0000-00-00 00:00:00' ) { |
|
| 305 | 305 | $url = get_permalink($result); |
| 306 | - if ($result->post_title) { |
|
| 306 | + if ( $result->post_title ) { |
|
| 307 | 307 | /** This filter is documented in wp-includes/post-template.php */ |
| 308 | 308 | $text = strip_tags(apply_filters('the_title', $result->post_title, $result->ID)); |
| 309 | 309 | } else { |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | * @param mixed $pid |
| 169 | 169 | */ |
| 170 | 170 | public function __construct($pid = null) { |
| 171 | - $pid = $this->determine_id( $pid ); |
|
| 171 | + $pid = $this->determine_id($pid); |
|
| 172 | 172 | $this->init($pid); |
| 173 | 173 | } |
| 174 | 174 | |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | * @param string $field |
| 261 | 261 | * @param mixed $value |
| 262 | 262 | */ |
| 263 | - public function update( $field, $value ) { |
|
| 263 | + public function update($field, $value) { |
|
| 264 | 264 | if ( isset($this->ID) ) { |
| 265 | 265 | update_post_meta($this->ID, $field, $value); |
| 266 | 266 | $this->$field = $value; |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | * @param mixed $pid |
| 276 | 276 | * @return WP_Post on success |
| 277 | 277 | */ |
| 278 | - protected function prepare_post_info( $pid = 0 ) { |
|
| 278 | + protected function prepare_post_info($pid = 0) { |
|
| 279 | 279 | if ( is_string($pid) || is_numeric($pid) || (is_object($pid) && !isset($pid->post_title)) || $pid === 0 ) { |
| 280 | 280 | $pid = self::check_post_id($pid); |
| 281 | 281 | $post = get_post($pid); |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | * @internal |
| 295 | 295 | * @return integer ID number of a post |
| 296 | 296 | */ |
| 297 | - protected function check_post_id( $pid ) { |
|
| 297 | + protected function check_post_id($pid) { |
|
| 298 | 298 | if ( is_numeric($pid) && $pid === 0 ) { |
| 299 | 299 | $pid = get_the_ID(); |
| 300 | 300 | return $pid; |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | global $wpdb; |
| 321 | 321 | $query = $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_name = %s LIMIT 1", $post_name); |
| 322 | 322 | $result = $wpdb->get_row($query); |
| 323 | - if (!$result) { |
|
| 323 | + if ( !$result ) { |
|
| 324 | 324 | return null; |
| 325 | 325 | } |
| 326 | 326 | return $result->ID; |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | $text = TimberHelper::trim_words($text, $len, false); |
| 360 | 360 | $trimmed = true; |
| 361 | 361 | } |
| 362 | - $text = do_shortcode( $text ); |
|
| 362 | + $text = do_shortcode($text); |
|
| 363 | 363 | } |
| 364 | 364 | if ( !strlen($text) ) { |
| 365 | 365 | $text = TimberHelper::trim_words($this->get_content(), $len, false); |
@@ -388,11 +388,11 @@ discard block |
||
| 388 | 388 | } |
| 389 | 389 | $read_more_class = apply_filters('timber/post/get_preview/read_more_class', "read-more"); |
| 390 | 390 | if ( $readmore && isset($readmore_matches) && !empty($readmore_matches[1]) ) { |
| 391 | - $text .= ' <a href="' . $this->get_permalink() . '" class="'.$read_more_class .'">' . trim($readmore_matches[1]) . '</a>'; |
|
| 391 | + $text .= ' <a href="' . $this->get_permalink() . '" class="' . $read_more_class . '">' . trim($readmore_matches[1]) . '</a>'; |
|
| 392 | 392 | } elseif ( $readmore ) { |
| 393 | - $text .= ' <a href="' . $this->get_permalink() . '" class="'.$read_more_class .'">' . trim($readmore) . '</a>'; |
|
| 393 | + $text .= ' <a href="' . $this->get_permalink() . '" class="' . $read_more_class . '">' . trim($readmore) . '</a>'; |
|
| 394 | 394 | } |
| 395 | - if ( !$strip && $last_p_tag && ( strpos($text, '<p>') || strpos($text, '<p ') ) ) { |
|
| 395 | + if ( !$strip && $last_p_tag && (strpos($text, '<p>') || strpos($text, '<p ')) ) { |
|
| 396 | 396 | $text .= '</p>'; |
| 397 | 397 | } |
| 398 | 398 | } |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | * @internal |
| 405 | 405 | * @param bool|int $pid a post ID number |
| 406 | 406 | */ |
| 407 | - function import_custom( $pid = false ) { |
|
| 407 | + function import_custom($pid = false) { |
|
| 408 | 408 | if ( !$pid ) { |
| 409 | 409 | $pid = $this->ID; |
| 410 | 410 | } |
@@ -419,13 +419,13 @@ discard block |
||
| 419 | 419 | * @param int $pid |
| 420 | 420 | * @return array |
| 421 | 421 | */ |
| 422 | - protected function get_post_custom( $pid ) { |
|
| 422 | + protected function get_post_custom($pid) { |
|
| 423 | 423 | apply_filters('timber_post_get_meta_pre', array(), $pid, $this); |
| 424 | 424 | $customs = get_post_custom($pid); |
| 425 | 425 | if ( !is_array($customs) || empty($customs) ) { |
| 426 | 426 | return array(); |
| 427 | 427 | } |
| 428 | - foreach ( $customs as $key => $value ) { |
|
| 428 | + foreach ($customs as $key => $value) { |
|
| 429 | 429 | if ( is_array($value) && count($value) == 1 && isset($value[0]) ) { |
| 430 | 430 | $value = $value[0]; |
| 431 | 431 | } |
@@ -479,7 +479,7 @@ discard block |
||
| 479 | 479 | * @param bool $taxonomy |
| 480 | 480 | * @return TimberPost|boolean |
| 481 | 481 | */ |
| 482 | - function get_next( $taxonomy = false ) { |
|
| 482 | + function get_next($taxonomy = false) { |
|
| 483 | 483 | if ( !isset($this->_next) || !isset($this->_next[$taxonomy]) ) { |
| 484 | 484 | global $post; |
| 485 | 485 | $this->_next = array(); |
@@ -510,7 +510,7 @@ discard block |
||
| 510 | 510 | $post = $this; |
| 511 | 511 | $ret = array(); |
| 512 | 512 | if ( $multipage ) { |
| 513 | - for ( $i = 1; $i <= $numpages; $i++ ) { |
|
| 513 | + for ($i = 1; $i <= $numpages; $i++) { |
|
| 514 | 514 | $link = self::get_wp_link_page($i); |
| 515 | 515 | $data = array('name' => $i, 'title' => $i, 'text' => $i, 'link' => $link); |
| 516 | 516 | if ( $i == $page ) { |
@@ -562,7 +562,7 @@ discard block |
||
| 562 | 562 | * @param bool $taxonomy |
| 563 | 563 | * @return TimberPost|boolean |
| 564 | 564 | */ |
| 565 | - function get_prev( $taxonomy = false ) { |
|
| 565 | + function get_prev($taxonomy = false) { |
|
| 566 | 566 | if ( isset($this->_prev) && isset($this->_prev[$taxonomy]) ) { |
| 567 | 567 | return $this->_prev[$taxonomy]; |
| 568 | 568 | } |
@@ -629,7 +629,7 @@ discard block |
||
| 629 | 629 | $post->slug = $post->post_name; |
| 630 | 630 | $customs = $this->get_post_custom($post->ID); |
| 631 | 631 | $post->custom = $customs; |
| 632 | - $post = (object) array_merge((array)$customs, (array)$post); |
|
| 632 | + $post = (object) array_merge((array) $customs, (array) $post); |
|
| 633 | 633 | return $post; |
| 634 | 634 | } |
| 635 | 635 | |
@@ -640,7 +640,7 @@ discard block |
||
| 640 | 640 | * @param string $use |
| 641 | 641 | * @return string |
| 642 | 642 | */ |
| 643 | - function get_display_date( $use = 'post_date' ) { |
|
| 643 | + function get_display_date($use = 'post_date') { |
|
| 644 | 644 | return date(get_option('date_format'), strtotime($this->$use)); |
| 645 | 645 | } |
| 646 | 646 | |
@@ -650,9 +650,9 @@ discard block |
||
| 650 | 650 | * @param string $date_format |
| 651 | 651 | * @return string |
| 652 | 652 | */ |
| 653 | - function get_date( $date_format = '' ) { |
|
| 653 | + function get_date($date_format = '') { |
|
| 654 | 654 | $df = $date_format ? $date_format : get_option('date_format'); |
| 655 | - $the_date = (string)mysql2date($df, $this->post_date); |
|
| 655 | + $the_date = (string) mysql2date($df, $this->post_date); |
|
| 656 | 656 | return apply_filters('get_the_date', $the_date, $df); |
| 657 | 657 | } |
| 658 | 658 | |
@@ -661,7 +661,7 @@ discard block |
||
| 661 | 661 | * @param string $date_format |
| 662 | 662 | * @return string |
| 663 | 663 | */ |
| 664 | - function get_modified_date( $date_format = '' ) { |
|
| 664 | + function get_modified_date($date_format = '') { |
|
| 665 | 665 | $df = $date_format ? $date_format : get_option('date_format'); |
| 666 | 666 | $the_time = $this->get_modified_time($df); |
| 667 | 667 | return apply_filters('get_the_modified_date', $the_time, $date_format); |
@@ -672,7 +672,7 @@ discard block |
||
| 672 | 672 | * @param string $time_format |
| 673 | 673 | * @return string |
| 674 | 674 | */ |
| 675 | - function get_modified_time( $time_format = '' ) { |
|
| 675 | + function get_modified_time($time_format = '') { |
|
| 676 | 676 | $tf = $time_format ? $time_format : get_option('time_format'); |
| 677 | 677 | $the_time = get_post_modified_time($tf, false, $this->ID, true); |
| 678 | 678 | return apply_filters('get_the_modified_time', $the_time, $time_format); |
@@ -685,7 +685,7 @@ discard block |
||
| 685 | 685 | * @param bool|string $childPostClass |
| 686 | 686 | * @return array |
| 687 | 687 | */ |
| 688 | - function get_children( $post_type = 'any', $childPostClass = false ) { |
|
| 688 | + function get_children($post_type = 'any', $childPostClass = false) { |
|
| 689 | 689 | if ( $childPostClass === false ) { |
| 690 | 690 | $childPostClass = $this->PostClass; |
| 691 | 691 | } |
@@ -693,7 +693,7 @@ discard block |
||
| 693 | 693 | $post_type = $this->post_type; |
| 694 | 694 | } |
| 695 | 695 | $children = get_children('post_parent=' . $this->ID . '&post_type=' . $post_type . '&numberposts=-1&orderby=menu_order title&order=ASC'); |
| 696 | - foreach ( $children as &$child ) { |
|
| 696 | + foreach ($children as &$child) { |
|
| 697 | 697 | $child = new $childPostClass($child->ID); |
| 698 | 698 | } |
| 699 | 699 | $children = array_values($children); |
@@ -709,8 +709,8 @@ discard block |
||
| 709 | 709 | * @return mixed |
| 710 | 710 | */ |
| 711 | 711 | function TimberComment_reply_link($comment_id, $post_id) { |
| 712 | - if (is_singular() && comments_open() && get_option('thread_comments')) { |
|
| 713 | - wp_enqueue_script( 'comment-reply' ); |
|
| 712 | + if ( is_singular() && comments_open() && get_option('thread_comments') ) { |
|
| 713 | + wp_enqueue_script('comment-reply'); |
|
| 714 | 714 | } |
| 715 | 715 | |
| 716 | 716 | // Get the comments depth option from the admin panel |
@@ -725,7 +725,7 @@ discard block |
||
| 725 | 725 | 'max_depth' => $max_depth, |
| 726 | 726 | ); |
| 727 | 727 | |
| 728 | - $reply_link = get_comment_reply_link( $args, $comment_id, $post_id ); |
|
| 728 | + $reply_link = get_comment_reply_link($args, $comment_id, $post_id); |
|
| 729 | 729 | |
| 730 | 730 | return $reply_link; |
| 731 | 731 | } |
@@ -759,20 +759,20 @@ discard block |
||
| 759 | 759 | } |
| 760 | 760 | |
| 761 | 761 | if ( $user_ID ) { |
| 762 | - $args['include_unapproved'] = array( $user_ID ); |
|
| 763 | - } elseif ( ! empty( $comment_author_email ) ) { |
|
| 764 | - $args['include_unapproved'] = array( $comment_author_email ); |
|
| 762 | + $args['include_unapproved'] = array($user_ID); |
|
| 763 | + } elseif ( !empty($comment_author_email) ) { |
|
| 764 | + $args['include_unapproved'] = array($comment_author_email); |
|
| 765 | 765 | } |
| 766 | 766 | |
| 767 | 767 | $comments = get_comments($args); |
| 768 | 768 | $timber_comments = array(); |
| 769 | 769 | |
| 770 | 770 | if ( '' == get_query_var('cpage') && get_option('page_comments') ) { |
| 771 | - set_query_var( 'cpage', 'newest' == get_option('default_comments_page') ? get_comment_pages_count() : 1 ); |
|
| 771 | + set_query_var('cpage', 'newest' == get_option('default_comments_page') ? get_comment_pages_count() : 1); |
|
| 772 | 772 | $overridden_cpage = true; |
| 773 | 773 | } |
| 774 | 774 | |
| 775 | - foreach($comments as $key => &$comment) { |
|
| 775 | + foreach ($comments as $key => &$comment) { |
|
| 776 | 776 | $timber_comment = new $CommentClass($comment); |
| 777 | 777 | $timber_comment->reply_link = $this->TimberComment_reply_link($comment->comment_ID, $this->ID); |
| 778 | 778 | $timber_comments[$timber_comment->id] = $timber_comment; |
@@ -780,22 +780,22 @@ discard block |
||
| 780 | 780 | |
| 781 | 781 | // Build a flattened (depth=1) comment tree |
| 782 | 782 | $comments_tree = array(); |
| 783 | - foreach( $timber_comments as $key => $comment ) { |
|
| 784 | - if ( ! $comment->is_child() ) { |
|
| 783 | + foreach ($timber_comments as $key => $comment) { |
|
| 784 | + if ( !$comment->is_child() ) { |
|
| 785 | 785 | continue; |
| 786 | 786 | } |
| 787 | 787 | |
| 788 | 788 | $tree_element = $comment; |
| 789 | 789 | do { |
| 790 | 790 | $tree_element = $timber_comments[$tree_element->comment_parent]; |
| 791 | - } while( $tree_element->is_child() ); |
|
| 791 | + } while ($tree_element->is_child()); |
|
| 792 | 792 | |
| 793 | 793 | $comments_tree[$tree_element->id][] = $comment->id; |
| 794 | 794 | } |
| 795 | 795 | |
| 796 | 796 | // Add child comments to the relative "super parents" |
| 797 | - foreach($comments_tree as $comment_parent => $comment_children) { |
|
| 798 | - foreach($comment_children as $comment_child) { |
|
| 797 | + foreach ($comments_tree as $comment_parent => $comment_children) { |
|
| 798 | + foreach ($comment_children as $comment_child) { |
|
| 799 | 799 | $timber_comments[$comment_parent]->children[] = $timber_comments[$comment_child]; |
| 800 | 800 | unset($timber_comments[$comment_child]); |
| 801 | 801 | } |
@@ -835,7 +835,7 @@ discard block |
||
| 835 | 835 | * @param string $TermClass |
| 836 | 836 | * @return array |
| 837 | 837 | */ |
| 838 | - function get_terms( $tax = '', $merge = true, $TermClass = '' ) { |
|
| 838 | + function get_terms($tax = '', $merge = true, $TermClass = '') { |
|
| 839 | 839 | |
| 840 | 840 | $TermClass = $TermClass ?: $this->TermClass; |
| 841 | 841 | |
@@ -846,7 +846,7 @@ discard block |
||
| 846 | 846 | $taxonomies = $tax; |
| 847 | 847 | } |
| 848 | 848 | if ( is_string($tax) ) { |
| 849 | - if ( in_array($tax, array('all','any','')) ) { |
|
| 849 | + if ( in_array($tax, array('all', 'any', '')) ) { |
|
| 850 | 850 | $taxonomies = get_object_taxonomies($this->post_type); |
| 851 | 851 | } else { |
| 852 | 852 | $taxonomies = array($tax); |
@@ -855,8 +855,8 @@ discard block |
||
| 855 | 855 | |
| 856 | 856 | $term_class_objects = array(); |
| 857 | 857 | |
| 858 | - foreach ( $taxonomies as $taxonomy ) { |
|
| 859 | - if ( in_array($taxonomy, array('tag','tags')) ) { |
|
| 858 | + foreach ($taxonomies as $taxonomy) { |
|
| 859 | + if ( in_array($taxonomy, array('tag', 'tags')) ) { |
|
| 860 | 860 | $taxonomy = 'post_tag'; |
| 861 | 861 | } |
| 862 | 862 | if ( $taxonomy == 'categories' ) { |
@@ -893,11 +893,11 @@ discard block |
||
| 893 | 893 | * @param string $taxonomy |
| 894 | 894 | * @return bool |
| 895 | 895 | */ |
| 896 | - function has_term( $term_name_or_id, $taxonomy = 'all' ) { |
|
| 896 | + function has_term($term_name_or_id, $taxonomy = 'all') { |
|
| 897 | 897 | if ( $taxonomy == 'all' || $taxonomy == 'any' ) { |
| 898 | 898 | $taxes = get_object_taxonomies($this->post_type, 'names'); |
| 899 | 899 | $ret = false; |
| 900 | - foreach ( $taxes as $tax ) { |
|
| 900 | + foreach ($taxes as $tax) { |
|
| 901 | 901 | if ( has_term($term_name_or_id, $tax, $this->ID) ) { |
| 902 | 902 | $ret = true; |
| 903 | 903 | break; |
@@ -912,7 +912,7 @@ discard block |
||
| 912 | 912 | * @param string $field |
| 913 | 913 | * @return TimberImage |
| 914 | 914 | */ |
| 915 | - function get_image( $field ) { |
|
| 915 | + function get_image($field) { |
|
| 916 | 916 | return new $this->ImageClass($this->$field); |
| 917 | 917 | } |
| 918 | 918 | |
@@ -962,7 +962,7 @@ discard block |
||
| 962 | 962 | * @param int $page |
| 963 | 963 | * @return string |
| 964 | 964 | */ |
| 965 | - function get_content( $len = 0, $page = 0 ) { |
|
| 965 | + function get_content($len = 0, $page = 0) { |
|
| 966 | 966 | if ( $len == 0 && $page == 0 && $this->_content ) { |
| 967 | 967 | return $this->_content; |
| 968 | 968 | } |
@@ -1019,7 +1019,7 @@ discard block |
||
| 1019 | 1019 | * @param string $field_name |
| 1020 | 1020 | * @return mixed |
| 1021 | 1021 | */ |
| 1022 | - public function get_field( $field_name ) { |
|
| 1022 | + public function get_field($field_name) { |
|
| 1023 | 1023 | $value = apply_filters('timber_post_get_meta_field_pre', null, $this->ID, $field_name, $this); |
| 1024 | 1024 | if ( $value === null ) { |
| 1025 | 1025 | $value = get_post_meta($this->ID, $field_name); |
@@ -1037,7 +1037,7 @@ discard block |
||
| 1037 | 1037 | /** |
| 1038 | 1038 | * @param string $field_name |
| 1039 | 1039 | */ |
| 1040 | - function import_field( $field_name ) { |
|
| 1040 | + function import_field($field_name) { |
|
| 1041 | 1041 | $this->$field_name = $this->get_field($field_name); |
| 1042 | 1042 | } |
| 1043 | 1043 | |
@@ -1068,7 +1068,7 @@ discard block |
||
| 1068 | 1068 | * ``` |
| 1069 | 1069 | * @return string a space-seperated list of classes |
| 1070 | 1070 | */ |
| 1071 | - public function post_class( $class='' ) { |
|
| 1071 | + public function post_class($class = '') { |
|
| 1072 | 1072 | global $post; |
| 1073 | 1073 | $old_global_post = $post; |
| 1074 | 1074 | $post = $this; |
@@ -1176,8 +1176,8 @@ discard block |
||
| 1176 | 1176 | * @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. |
| 1177 | 1177 | * @return array |
| 1178 | 1178 | */ |
| 1179 | - public function children( $post_type = 'any', $childPostClass = false ) { |
|
| 1180 | - return $this->get_children( $post_type, $childPostClass ); |
|
| 1179 | + public function children($post_type = 'any', $childPostClass = false) { |
|
| 1180 | + return $this->get_children($post_type, $childPostClass); |
|
| 1181 | 1181 | } |
| 1182 | 1182 | |
| 1183 | 1183 | /** |
@@ -1201,7 +1201,7 @@ discard block |
||
| 1201 | 1201 | * ``` |
| 1202 | 1202 | * @return bool|array |
| 1203 | 1203 | */ |
| 1204 | - public function comments( $count = 0, $order = 'wp', $type = 'comment', $status = 'approve', $CommentClass = 'TimberComment' ) { |
|
| 1204 | + public function comments($count = 0, $order = 'wp', $type = 'comment', $status = 'approve', $CommentClass = 'TimberComment') { |
|
| 1205 | 1205 | return $this->get_comments($count, $order, $type, $status, $CommentClass); |
| 1206 | 1206 | } |
| 1207 | 1207 | |
@@ -1218,7 +1218,7 @@ discard block |
||
| 1218 | 1218 | * @param int $page |
| 1219 | 1219 | * @return string |
| 1220 | 1220 | */ |
| 1221 | - public function content( $page = 0 ) { |
|
| 1221 | + public function content($page = 0) { |
|
| 1222 | 1222 | return $this->get_content(0, $page); |
| 1223 | 1223 | } |
| 1224 | 1224 | |
@@ -1247,7 +1247,7 @@ discard block |
||
| 1247 | 1247 | * @param string $date_format |
| 1248 | 1248 | * @return string |
| 1249 | 1249 | */ |
| 1250 | - public function date( $date_format = '' ) { |
|
| 1250 | + public function date($date_format = '') { |
|
| 1251 | 1251 | return $this->get_date($date_format); |
| 1252 | 1252 | } |
| 1253 | 1253 | |
@@ -1269,9 +1269,9 @@ discard block |
||
| 1269 | 1269 | * @param string $time_format |
| 1270 | 1270 | * @return string |
| 1271 | 1271 | */ |
| 1272 | - public function time( $time_format = '' ) { |
|
| 1272 | + public function time($time_format = '') { |
|
| 1273 | 1273 | $tf = $time_format ? $time_format : get_option('time_format'); |
| 1274 | - $the_time = (string)mysql2date($tf, $this->post_date); |
|
| 1274 | + $the_time = (string) mysql2date($tf, $this->post_date); |
|
| 1275 | 1275 | return apply_filters('get_the_time', $the_time, $tf); |
| 1276 | 1276 | } |
| 1277 | 1277 | |
@@ -1307,7 +1307,7 @@ discard block |
||
| 1307 | 1307 | * @param string $field_name |
| 1308 | 1308 | * @return mixed |
| 1309 | 1309 | */ |
| 1310 | - public function meta( $field_name = null ) { |
|
| 1310 | + public function meta($field_name = null) { |
|
| 1311 | 1311 | if ( $field_name === null ) { |
| 1312 | 1312 | //on the off-chance the field is actually named meta |
| 1313 | 1313 | $field_name = 'meta'; |
@@ -1326,7 +1326,7 @@ discard block |
||
| 1326 | 1326 | * @param string $date_format |
| 1327 | 1327 | * @return string |
| 1328 | 1328 | */ |
| 1329 | - public function modified_date( $date_format = '' ) { |
|
| 1329 | + public function modified_date($date_format = '') { |
|
| 1330 | 1330 | return $this->get_modified_date($date_format); |
| 1331 | 1331 | } |
| 1332 | 1332 | |
@@ -1334,7 +1334,7 @@ discard block |
||
| 1334 | 1334 | * @param string $time_format |
| 1335 | 1335 | * @return string |
| 1336 | 1336 | */ |
| 1337 | - public function modified_time( $time_format = '' ) { |
|
| 1337 | + public function modified_time($time_format = '') { |
|
| 1338 | 1338 | return $this->get_modified_time($time_format); |
| 1339 | 1339 | } |
| 1340 | 1340 | |
@@ -1343,7 +1343,7 @@ discard block |
||
| 1343 | 1343 | * @param bool $in_same_cat |
| 1344 | 1344 | * @return mixed |
| 1345 | 1345 | */ |
| 1346 | - public function next( $in_same_cat = false ) { |
|
| 1346 | + public function next($in_same_cat = false) { |
|
| 1347 | 1347 | return $this->get_next($in_same_cat); |
| 1348 | 1348 | } |
| 1349 | 1349 | |
@@ -1401,7 +1401,7 @@ discard block |
||
| 1401 | 1401 | * @param bool $in_same_cat |
| 1402 | 1402 | * @return mixed |
| 1403 | 1403 | */ |
| 1404 | - public function prev( $in_same_cat = false ) { |
|
| 1404 | + public function prev($in_same_cat = false) { |
|
| 1405 | 1405 | return $this->get_prev($in_same_cat); |
| 1406 | 1406 | } |
| 1407 | 1407 | |
@@ -1413,7 +1413,7 @@ discard block |
||
| 1413 | 1413 | * @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)? |
| 1414 | 1414 | * @return array |
| 1415 | 1415 | */ |
| 1416 | - public function terms( $tax = '', $merge = true ) { |
|
| 1416 | + public function terms($tax = '', $merge = true) { |
|
| 1417 | 1417 | return $this->get_terms($tax, $merge); |
| 1418 | 1418 | } |
| 1419 | 1419 | |