@@ -44,30 +44,30 @@ |
||
| 44 | 44 | * (ex: /src/var/www/wp-content/uploads/[email protected]) |
| 45 | 45 | * @return bool true if everything went fine, false otherwise |
| 46 | 46 | */ |
| 47 | - function run($load_filename, $save_filename){ |
|
| 48 | - $image = wp_get_image_editor( $load_filename ); |
|
| 49 | - if ( !is_wp_error( $image ) ) { |
|
| 47 | + function run($load_filename, $save_filename) { |
|
| 48 | + $image = wp_get_image_editor($load_filename); |
|
| 49 | + if ( !is_wp_error($image) ) { |
|
| 50 | 50 | $current_size = $image->get_size(); |
| 51 | 51 | $src_w = $current_size['width']; |
| 52 | 52 | $src_h = $current_size['height']; |
| 53 | 53 | // Get ratios |
| 54 | 54 | $w = $src_w * $this->factor; |
| 55 | 55 | $h = $src_h * $this->factor; |
| 56 | - $image->crop( 0, 0, $src_w, $src_h, $w, $h ); |
|
| 57 | - $result = $image->save( $save_filename ); |
|
| 58 | - if ( is_wp_error( $result ) ) { |
|
| 56 | + $image->crop(0, 0, $src_w, $src_h, $w, $h); |
|
| 57 | + $result = $image->save($save_filename); |
|
| 58 | + if ( is_wp_error($result) ) { |
|
| 59 | 59 | // @codeCoverageIgnoreStart |
| 60 | - TimberHelper::error_log( 'Error resizing image' ); |
|
| 61 | - TimberHelper::error_log( $result ); |
|
| 60 | + TimberHelper::error_log('Error resizing image'); |
|
| 61 | + TimberHelper::error_log($result); |
|
| 62 | 62 | return false; |
| 63 | 63 | // @codeCoverageIgnoreEnd |
| 64 | 64 | } else { |
| 65 | 65 | return true; |
| 66 | 66 | } |
| 67 | - } else if ( isset( $image->error_data['error_loading_image'] ) ) { |
|
| 68 | - TimberHelper::error_log( 'Error loading ' . $image->error_data['error_loading_image'] ); |
|
| 67 | + } else if ( isset($image->error_data['error_loading_image']) ) { |
|
| 68 | + TimberHelper::error_log('Error loading ' . $image->error_data['error_loading_image']); |
|
| 69 | 69 | } else { |
| 70 | - TimberHelper::error_log( $image ); |
|
| 70 | + TimberHelper::error_log($image); |
|
| 71 | 71 | } |
| 72 | 72 | return false; |
| 73 | 73 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | function init($cid) { |
| 56 | 56 | $comment_data = $cid; |
| 57 | - if (is_integer($cid)) { |
|
| 57 | + if ( is_integer($cid) ) { |
|
| 58 | 58 | $comment_data = get_comment($cid); |
| 59 | 59 | } |
| 60 | 60 | $this->import($comment_data); |
@@ -86,11 +86,11 @@ discard block |
||
| 86 | 86 | * @return TimberUser |
| 87 | 87 | */ |
| 88 | 88 | public function author() { |
| 89 | - if ($this->user_id) { |
|
| 89 | + if ( $this->user_id ) { |
|
| 90 | 90 | return new TimberUser($this->user_id); |
| 91 | 91 | } else { |
| 92 | 92 | $author = new TimberUser(0); |
| 93 | - if (isset($this->comment_author) && $this->comment_author) { |
|
| 93 | + if ( isset($this->comment_author) && $this->comment_author ) { |
|
| 94 | 94 | $author->name = $this->comment_author; |
| 95 | 95 | } else { |
| 96 | 96 | $author->name = 'Anonymous'; |
@@ -114,21 +114,21 @@ discard block |
||
| 114 | 114 | * @return bool|mixed|string |
| 115 | 115 | */ |
| 116 | 116 | public function avatar($size = 92, $default = '') { |
| 117 | - if (!get_option('show_avatars')) { |
|
| 117 | + if ( !get_option('show_avatars') ) { |
|
| 118 | 118 | return false; |
| 119 | 119 | } |
| 120 | - if (!is_numeric($size)) { |
|
| 120 | + if ( !is_numeric($size) ) { |
|
| 121 | 121 | $size = '92'; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | $email = $this->avatar_email(); |
| 125 | 125 | $email_hash = ''; |
| 126 | - if (!empty($email)) { |
|
| 126 | + if ( !empty($email) ) { |
|
| 127 | 127 | $email_hash = md5(strtolower(trim($email))); |
| 128 | 128 | } |
| 129 | 129 | $host = $this->avatar_host($email_hash); |
| 130 | 130 | $default = $this->avatar_default($default, $email, $size, $host); |
| 131 | - if (!empty($email)) { |
|
| 131 | + if ( !empty($email) ) { |
|
| 132 | 132 | $avatar = $this->avatar_out($default, $host, $email_hash, $size); |
| 133 | 133 | } else { |
| 134 | 134 | $avatar = $default; |
@@ -179,9 +179,9 @@ discard block |
||
| 179 | 179 | * ``` |
| 180 | 180 | * @return string |
| 181 | 181 | */ |
| 182 | - public function date( $date_format = '' ) { |
|
| 182 | + public function date($date_format = '') { |
|
| 183 | 183 | $df = $date_format ? $date_format : get_option('date_format'); |
| 184 | - $the_date = (string)mysql2date($df, $this->comment_date); |
|
| 184 | + $the_date = (string) mysql2date($df, $this->comment_date); |
|
| 185 | 185 | return apply_filters('get_comment_date ', $the_date, $df); |
| 186 | 186 | } |
| 187 | 187 | |
@@ -204,9 +204,9 @@ discard block |
||
| 204 | 204 | * ``` |
| 205 | 205 | * @return string |
| 206 | 206 | */ |
| 207 | - public function time( $time_format = '' ) { |
|
| 207 | + public function time($time_format = '') { |
|
| 208 | 208 | $tf = $time_format ? $time_format : get_option('time_format'); |
| 209 | - $the_time = (string)mysql2date($tf, $this->comment_date); |
|
| 209 | + $the_time = (string) mysql2date($tf, $this->comment_date); |
|
| 210 | 210 | return apply_filters('get_comment_time', $the_time, $tf); |
| 211 | 211 | } |
| 212 | 212 | |
@@ -232,14 +232,14 @@ discard block |
||
| 232 | 232 | * @return mixed |
| 233 | 233 | */ |
| 234 | 234 | protected function get_meta_fields($comment_id = null) { |
| 235 | - if ($comment_id === null) { |
|
| 235 | + if ( $comment_id === null ) { |
|
| 236 | 236 | $comment_id = $this->ID; |
| 237 | 237 | } |
| 238 | 238 | //Could not find a WP function to fetch all comment meta data, so I made one. |
| 239 | 239 | apply_filters('timber_comment_get_meta_pre', array(), $comment_id); |
| 240 | 240 | $comment_metas = get_comment_meta($comment_id); |
| 241 | 241 | foreach ($comment_metas as &$cm) { |
| 242 | - if (is_array($cm) && count($cm) == 1) { |
|
| 242 | + if ( is_array($cm) && count($cm) == 1 ) { |
|
| 243 | 243 | $cm = $cm[0]; |
| 244 | 244 | } |
| 245 | 245 | } |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | */ |
| 255 | 255 | protected function get_meta_field($field_name) { |
| 256 | 256 | $value = apply_filters('timber_comment_get_meta_field_pre', null, $this->ID, $field_name, $this); |
| 257 | - if ($value === null) { |
|
| 257 | + if ( $value === null ) { |
|
| 258 | 258 | $value = get_comment_meta($this->ID, $field_name, true); |
| 259 | 259 | } |
| 260 | 260 | $value = apply_filters('timber_comment_get_meta_field', $value, $this->ID, $field_name, $this); |
@@ -267,9 +267,9 @@ discard block |
||
| 267 | 267 | * @api |
| 268 | 268 | * @return string |
| 269 | 269 | */ |
| 270 | - public function reply_link( $reply_text = 'Reply' ) { |
|
| 270 | + public function reply_link($reply_text = 'Reply') { |
|
| 271 | 271 | if ( is_singular() && comments_open() && get_option('thread_comments') ) { |
| 272 | - wp_enqueue_script( 'comment-reply' ); |
|
| 272 | + wp_enqueue_script('comment-reply'); |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | // Get the comments depth option from the admin panel |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | 'max_depth' => $max_depth, |
| 285 | 285 | ); |
| 286 | 286 | |
| 287 | - return get_comment_reply_link( $args, $this->ID, $this->post_id ); |
|
| 287 | + return get_comment_reply_link($args, $this->ID, $this->post_id); |
|
| 288 | 288 | } |
| 289 | 289 | |
| 290 | 290 | /* AVATAR Stuff |
@@ -295,9 +295,9 @@ discard block |
||
| 295 | 295 | * @return string |
| 296 | 296 | */ |
| 297 | 297 | protected function avatar_email() { |
| 298 | - $id = (int)$this->user_id; |
|
| 298 | + $id = (int) $this->user_id; |
|
| 299 | 299 | $user = get_userdata($id); |
| 300 | - if ($user) { |
|
| 300 | + if ( $user ) { |
|
| 301 | 301 | $email = $user->user_email; |
| 302 | 302 | } else { |
| 303 | 303 | $email = $this->comment_author_email; |
@@ -311,10 +311,10 @@ discard block |
||
| 311 | 311 | * @return string |
| 312 | 312 | */ |
| 313 | 313 | protected function avatar_host($email_hash) { |
| 314 | - if (is_ssl()) { |
|
| 314 | + if ( is_ssl() ) { |
|
| 315 | 315 | $host = 'https://secure.gravatar.com'; |
| 316 | 316 | } else { |
| 317 | - if (!empty($email_hash)) { |
|
| 317 | + if ( !empty($email_hash) ) { |
|
| 318 | 318 | $host = sprintf("http://%d.gravatar.com", (hexdec($email_hash[0]) % 2)); |
| 319 | 319 | } else { |
| 320 | 320 | $host = 'http://0.gravatar.com'; |
@@ -333,28 +333,28 @@ discard block |
||
| 333 | 333 | * @return string |
| 334 | 334 | */ |
| 335 | 335 | protected function avatar_default($default, $email, $size, $host) { |
| 336 | - if (substr($default, 0, 1) == '/') { |
|
| 336 | + if ( substr($default, 0, 1) == '/' ) { |
|
| 337 | 337 | $default = home_url() . $default; |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | - if (empty($default)) { |
|
| 340 | + if ( empty($default) ) { |
|
| 341 | 341 | $avatar_default = get_option('avatar_default'); |
| 342 | - if (empty($avatar_default)) { |
|
| 342 | + if ( empty($avatar_default) ) { |
|
| 343 | 343 | $default = 'mystery'; |
| 344 | 344 | } else { |
| 345 | 345 | $default = $avatar_default; |
| 346 | 346 | } |
| 347 | 347 | } |
| 348 | - if ('mystery' == $default) { |
|
| 348 | + if ( 'mystery' == $default ) { |
|
| 349 | 349 | $default = $host . '/avatar/ad516503a11cd5ca435acc9bb6523536?s=' . $size; |
| 350 | 350 | // ad516503a11cd5ca435acc9bb6523536 == md5('[email protected]') |
| 351 | - } else if ('blank' == $default) { |
|
| 351 | + } else if ( 'blank' == $default ) { |
|
| 352 | 352 | $default = $email ? 'blank' : includes_url('images/blank.gif'); |
| 353 | - } else if (!empty($email) && 'gravatar_default' == $default) { |
|
| 353 | + } else if ( !empty($email) && 'gravatar_default' == $default ) { |
|
| 354 | 354 | $default = ''; |
| 355 | - } else if ('gravatar_default' == $default) { |
|
| 355 | + } else if ( 'gravatar_default' == $default ) { |
|
| 356 | 356 | $default = $host . '/avatar/?s=' . $size; |
| 357 | - } else if (empty($email) && !strstr($default, 'http://')) { |
|
| 357 | + } else if ( empty($email) && !strstr($default, 'http://') ) { |
|
| 358 | 358 | $default = $host . '/avatar/?d=' . $default . '&s=' . $size; |
| 359 | 359 | } |
| 360 | 360 | return $default; |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | protected function avatar_out($default, $host, $email_hash, $size) { |
| 372 | 372 | $out = $host . '/avatar/' . $email_hash . '?s=' . $size . '&d=' . urlencode($default); |
| 373 | 373 | $rating = get_option('avatar_rating'); |
| 374 | - if (!empty($rating)) { |
|
| 374 | + if ( !empty($rating) ) { |
|
| 375 | 375 | $out .= '&r=' . $rating; |
| 376 | 376 | } |
| 377 | 377 | return str_replace('&', '&', esc_url($out)); |
@@ -36,14 +36,14 @@ discard block |
||
| 36 | 36 | * @return bool true if everything went fine, false otherwise |
| 37 | 37 | */ |
| 38 | 38 | function run($load_filename, $save_filename) { |
| 39 | - $input = self::image_create( $load_filename ); |
|
| 40 | - list( $width, $height ) = getimagesize( $load_filename ); |
|
| 41 | - $output = imagecreatetruecolor( $width, $height ); |
|
| 42 | - $c = self::hexrgb( $this->color ); |
|
| 43 | - $color = imagecolorallocate( $output, $c['red'], $c['green'], $c['blue'] ); |
|
| 44 | - imagefilledrectangle( $output, 0, 0, $width, $height, $color ); |
|
| 45 | - imagecopy( $output, $input, 0, 0, 0, 0, $width, $height ); |
|
| 46 | - imagejpeg( $output, $save_filename ); |
|
| 39 | + $input = self::image_create($load_filename); |
|
| 40 | + list($width, $height) = getimagesize($load_filename); |
|
| 41 | + $output = imagecreatetruecolor($width, $height); |
|
| 42 | + $c = self::hexrgb($this->color); |
|
| 43 | + $color = imagecolorallocate($output, $c['red'], $c['green'], $c['blue']); |
|
| 44 | + imagefilledrectangle($output, 0, 0, $width, $height, $color); |
|
| 45 | + imagecopy($output, $input, 0, 0, 0, 0, $width, $height); |
|
| 46 | + imagejpeg($output, $save_filename); |
|
| 47 | 47 | return true; |
| 48 | 48 | } |
| 49 | 49 | |
@@ -52,10 +52,10 @@ discard block |
||
| 52 | 52 | * @return resource an image identifier representing the image obtained from the given filename |
| 53 | 53 | * will return the same data type regardless of whether the source is gif or png |
| 54 | 54 | */ |
| 55 | - function image_create( $filename, $ext = 'auto' ) { |
|
| 55 | + function image_create($filename, $ext = 'auto') { |
|
| 56 | 56 | if ( $ext == 'auto' ) { |
| 57 | 57 | $ext = wp_check_filetype($filename); |
| 58 | - if (isset($ext['ext'])) { |
|
| 58 | + if ( isset($ext['ext']) ) { |
|
| 59 | 59 | $ext = $ext['ext']; |
| 60 | 60 | } |
| 61 | 61 | } |
@@ -69,6 +69,6 @@ discard block |
||
| 69 | 69 | if ( $ext == 'jpg' || $ext == 'jpeg' ) { |
| 70 | 70 | return imagecreatefromjpeg($filename); |
| 71 | 71 | } |
| 72 | - throw new InvalidArgumentException( 'image_create only accepts PNG, GIF and JPGs. File extension was: '.$ext ); |
|
| 72 | + throw new InvalidArgumentException('image_create only accepts PNG, GIF and JPGs. File extension was: ' . $ext); |
|
| 73 | 73 | } |
| 74 | 74 | } |
@@ -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 | } |
@@ -246,14 +246,14 @@ discard block |
||
| 246 | 246 | $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"; |
| 247 | 247 | $key = md5($query); |
| 248 | 248 | $key = "wp_get_archives:$key:$last_changed"; |
| 249 | - if (!$results = wp_cache_get($key, 'posts')) { |
|
| 249 | + if ( !$results = wp_cache_get($key, 'posts') ) { |
|
| 250 | 250 | $results = $wpdb->get_results($query); |
| 251 | 251 | $cache = array(); |
| 252 | 252 | $cache[$key] = $results; |
| 253 | 253 | wp_cache_set($key, $results, 'posts'); |
| 254 | 254 | } |
| 255 | 255 | if ( $results ) { |
| 256 | - foreach ( (array)$results as $result ) { |
|
| 256 | + foreach ((array) $results as $result) { |
|
| 257 | 257 | $url = get_day_link($result->year, $result->month, $result->dayofmonth); |
| 258 | 258 | $date = sprintf('%1$d-%2$02d-%3$02d 00:00:00', $result->year, $result->month, $result->dayofmonth); |
| 259 | 259 | $text = mysql2date($archive_day_date_format, $date); |
@@ -266,13 +266,13 @@ discard block |
||
| 266 | 266 | . "count( `ID` ) AS `posts` FROM `$wpdb->posts` $join $where GROUP BY $week, YEAR( `post_date` ) ORDER BY `post_date` $order $limit"; |
| 267 | 267 | $key = md5($query); |
| 268 | 268 | $key = "wp_get_archives:$key:$last_changed"; |
| 269 | - if (!$results = wp_cache_get($key, 'posts')) { |
|
| 269 | + if ( !$results = wp_cache_get($key, 'posts') ) { |
|
| 270 | 270 | $results = $wpdb->get_results($query); |
| 271 | 271 | wp_cache_set($key, $results, 'posts'); |
| 272 | 272 | } |
| 273 | 273 | $arc_w_last = ''; |
| 274 | 274 | if ( $results ) { |
| 275 | - foreach ( (array)$results as $result ) { |
|
| 275 | + foreach ((array) $results as $result) { |
|
| 276 | 276 | if ( $result->week != $arc_w_last ) { |
| 277 | 277 | $arc_year = $result->yr; |
| 278 | 278 | $arc_w_last = $result->week; |
@@ -295,10 +295,10 @@ discard block |
||
| 295 | 295 | wp_cache_set($key, $results, 'posts'); |
| 296 | 296 | } |
| 297 | 297 | if ( $results ) { |
| 298 | - foreach ( (array)$results as $result ) { |
|
| 299 | - if ($result->post_date != '0000-00-00 00:00:00') { |
|
| 298 | + foreach ((array) $results as $result) { |
|
| 299 | + if ( $result->post_date != '0000-00-00 00:00:00' ) { |
|
| 300 | 300 | $url = get_permalink($result); |
| 301 | - if ($result->post_title) { |
|
| 301 | + if ( $result->post_title ) { |
|
| 302 | 302 | /** This filter is documented in wp-includes/post-template.php */ |
| 303 | 303 | $text = strip_tags(apply_filters('the_title', $result->post_title, $result->ID)); |
| 304 | 304 | } else { |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * (ex: my-awesome-pic-lbox-300x200-FF3366.jpg) |
| 31 | 31 | */ |
| 32 | 32 | public function filename($src_filename, $src_extension) { |
| 33 | - $color = str_replace( '#', '', $this->color ); |
|
| 33 | + $color = str_replace('#', '', $this->color); |
|
| 34 | 34 | $newbase = $src_filename . '-lbox-' . $this->w . 'x' . $this->h . '-' . $color; |
| 35 | 35 | $new_name = $newbase . '.' . $src_extension; |
| 36 | 36 | return $new_name; |
@@ -50,12 +50,12 @@ discard block |
||
| 50 | 50 | $w = $this->w; |
| 51 | 51 | $h = $this->h; |
| 52 | 52 | |
| 53 | - $bg = imagecreatetruecolor( $w, $h ); |
|
| 54 | - $c = self::hexrgb( $this->color ); |
|
| 55 | - $bgColor = imagecolorallocate( $bg, $c['red'], $c['green'], $c['blue'] ); |
|
| 56 | - imagefill( $bg, 0, 0, $bgColor ); |
|
| 57 | - $image = wp_get_image_editor( $load_filename ); |
|
| 58 | - if ( !is_wp_error( $image ) ) { |
|
| 53 | + $bg = imagecreatetruecolor($w, $h); |
|
| 54 | + $c = self::hexrgb($this->color); |
|
| 55 | + $bgColor = imagecolorallocate($bg, $c['red'], $c['green'], $c['blue']); |
|
| 56 | + imagefill($bg, 0, 0, $bgColor); |
|
| 57 | + $image = wp_get_image_editor($load_filename); |
|
| 58 | + if ( !is_wp_error($image) ) { |
|
| 59 | 59 | $current_size = $image->get_size(); |
| 60 | 60 | $quality = $image->get_quality(); |
| 61 | 61 | $ow = $current_size['width']; |
@@ -69,38 +69,38 @@ discard block |
||
| 69 | 69 | $y = 0; |
| 70 | 70 | $x = $w / 2 - $owt / 2; |
| 71 | 71 | $oht = $h; |
| 72 | - $image->crop( 0, 0, $ow, $oh, $owt, $oht ); |
|
| 72 | + $image->crop(0, 0, $ow, $oh, $owt, $oht); |
|
| 73 | 73 | } else { |
| 74 | 74 | $w_scale = $w / $ow; |
| 75 | 75 | $oht = $oh * $w_scale; |
| 76 | 76 | $x = 0; |
| 77 | 77 | $y = $h / 2 - $oht / 2; |
| 78 | 78 | $owt = $w; |
| 79 | - $image->crop( 0, 0, $ow, $oh, $owt, $oht ); |
|
| 79 | + $image->crop(0, 0, $ow, $oh, $owt, $oht); |
|
| 80 | 80 | } |
| 81 | - $result = $image->save( $save_filename ); |
|
| 81 | + $result = $image->save($save_filename); |
|
| 82 | 82 | $func = 'imagecreatefromjpeg'; |
| 83 | 83 | $save_func = 'imagejpeg'; |
| 84 | - $ext = pathinfo( $save_filename, PATHINFO_EXTENSION ); |
|
| 84 | + $ext = pathinfo($save_filename, PATHINFO_EXTENSION); |
|
| 85 | 85 | if ( $ext == 'gif' ) { |
| 86 | 86 | $func = 'imagecreatefromgif'; |
| 87 | 87 | $save_func = 'imagegif'; |
| 88 | 88 | } else if ( $ext == 'png' ) { |
| 89 | 89 | $func = 'imagecreatefrompng'; |
| 90 | 90 | $save_func = 'imagepng'; |
| 91 | - if ($quality > 9) { |
|
| 92 | - $quality = $quality/10; |
|
| 91 | + if ( $quality > 9 ) { |
|
| 92 | + $quality = $quality / 10; |
|
| 93 | 93 | $quality = round(10 - $quality); |
| 94 | 94 | } |
| 95 | 95 | } |
| 96 | - $image = $func( $save_filename ); |
|
| 97 | - imagecopy( $bg, $image, $x, $y, 0, 0, $owt, $oht ); |
|
| 98 | - if ($save_func === 'imagegif') { |
|
| 99 | - return $save_func( $bg, $save_filename ); |
|
| 96 | + $image = $func($save_filename); |
|
| 97 | + imagecopy($bg, $image, $x, $y, 0, 0, $owt, $oht); |
|
| 98 | + if ( $save_func === 'imagegif' ) { |
|
| 99 | + return $save_func($bg, $save_filename); |
|
| 100 | 100 | } |
| 101 | - return $save_func( $bg, $save_filename, $quality ); |
|
| 101 | + return $save_func($bg, $save_filename, $quality); |
|
| 102 | 102 | } else { |
| 103 | - TimberHelper::error_log( $image ); |
|
| 103 | + TimberHelper::error_log($image); |
|
| 104 | 104 | } |
| 105 | 105 | return false; |
| 106 | 106 | } |
@@ -14,11 +14,11 @@ |
||
| 14 | 14 | // we look for Composer files first in the plugins dir. |
| 15 | 15 | // then in the wp-content dir (site install). |
| 16 | 16 | // and finally in the current themes directories. |
| 17 | -if ( file_exists( $composer_autoload = __DIR__ . '/vendor/autoload.php' ) /* check in self */ |
|
| 18 | - || file_exists( $composer_autoload = WP_CONTENT_DIR.'/vendor/autoload.php') /* check in wp-content */ |
|
| 19 | - || file_exists( $composer_autoload = plugin_dir_path( __FILE__ ).'vendor/autoload.php') /* check in plugin directory */ |
|
| 20 | - || file_exists( $composer_autoload = get_stylesheet_directory().'/vendor/autoload.php') /* check in child theme */ |
|
| 21 | - || file_exists( $composer_autoload = get_template_directory().'/vendor/autoload.php') /* check in parent theme */ |
|
| 17 | +if ( file_exists($composer_autoload = __DIR__ . '/vendor/autoload.php') /* check in self */ |
|
| 18 | + || file_exists($composer_autoload = WP_CONTENT_DIR . '/vendor/autoload.php') /* check in wp-content */ |
|
| 19 | + || file_exists($composer_autoload = plugin_dir_path(__FILE__) . 'vendor/autoload.php') /* check in plugin directory */ |
|
| 20 | + || file_exists($composer_autoload = get_stylesheet_directory() . '/vendor/autoload.php') /* check in child theme */ |
|
| 21 | + || file_exists($composer_autoload = get_template_directory() . '/vendor/autoload.php') /* check in parent theme */ |
|
| 22 | 22 | ) { |
| 23 | 23 | require_once $composer_autoload; |
| 24 | 24 | } |
@@ -8,19 +8,19 @@ discard block |
||
| 8 | 8 | * @return array|bool|null |
| 9 | 9 | */ |
| 10 | 10 | static function get_post($query = false, $PostClass = 'TimberPost') { |
| 11 | - $posts = self::get_posts( $query, $PostClass ); |
|
| 12 | - if ( $post = reset($posts ) ) { |
|
| 11 | + $posts = self::get_posts($query, $PostClass); |
|
| 12 | + if ( $post = reset($posts) ) { |
|
| 13 | 13 | return $post; |
| 14 | 14 | } |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | - static function get_posts( $query = false, $PostClass = 'TimberPost', $return_collection = false ) { |
|
| 18 | - $posts = self::query_posts( $query, $PostClass ); |
|
| 19 | - return apply_filters('timber_post_getter_get_posts', $posts->get_posts( $return_collection )); |
|
| 17 | + static function get_posts($query = false, $PostClass = 'TimberPost', $return_collection = false) { |
|
| 18 | + $posts = self::query_posts($query, $PostClass); |
|
| 19 | + return apply_filters('timber_post_getter_get_posts', $posts->get_posts($return_collection)); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - static function query_post( $query = false, $PostClass = 'TimberPost' ) { |
|
| 23 | - $posts = self::query_posts( $query, $PostClass ); |
|
| 22 | + static function query_post($query = false, $PostClass = 'TimberPost') { |
|
| 23 | + $posts = self::query_posts($query, $PostClass); |
|
| 24 | 24 | if ( method_exists($posts, 'current') && $post = $posts->current() ) { |
| 25 | 25 | return $post; |
| 26 | 26 | } |
@@ -31,32 +31,32 @@ discard block |
||
| 31 | 31 | * @param string $PostClass |
| 32 | 32 | * @return array|bool|null |
| 33 | 33 | */ |
| 34 | - static function query_posts($query = false, $PostClass = 'TimberPost' ) { |
|
| 35 | - if (self::is_post_class_or_class_map($query)) { |
|
| 34 | + static function query_posts($query = false, $PostClass = 'TimberPost') { |
|
| 35 | + if ( self::is_post_class_or_class_map($query) ) { |
|
| 36 | 36 | $PostClass = $query; |
| 37 | 37 | $query = false; |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - if (is_object($query) && !is_a($query, 'WP_Query') ){ |
|
| 40 | + if ( is_object($query) && !is_a($query, 'WP_Query') ) { |
|
| 41 | 41 | // The only object other than a query is a type of post object |
| 42 | - $query = array( $query ); |
|
| 42 | + $query = array($query); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - if ( is_array( $query ) && count( $query ) && isset( $query[0] ) && is_object( $query[0] ) ) { |
|
| 45 | + if ( is_array($query) && count($query) && isset($query[0]) && is_object($query[0]) ) { |
|
| 46 | 46 | // We have an array of post objects that already have data |
| 47 | - return new TimberPostsCollection( $query, $PostClass ); |
|
| 47 | + return new TimberPostsCollection($query, $PostClass); |
|
| 48 | 48 | } else { |
| 49 | 49 | // We have a query (of sorts) to work with |
| 50 | - $tqi = new TimberQueryIterator( $query, $PostClass ); |
|
| 50 | + $tqi = new TimberQueryIterator($query, $PostClass); |
|
| 51 | 51 | return $tqi; |
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - static function get_pids($query){ |
|
| 55 | + static function get_pids($query) { |
|
| 56 | 56 | $posts = self::get_posts($query); |
| 57 | 57 | $pids = array(); |
| 58 | - foreach($posts as $post){ |
|
| 59 | - if (isset($post->ID)){ |
|
| 58 | + foreach ($posts as $post) { |
|
| 59 | + if ( isset($post->ID) ) { |
|
| 60 | 60 | $pids[] = $post->ID; |
| 61 | 61 | } |
| 62 | 62 | } |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | static function loop_to_id() { |
| 67 | - if (!self::wp_query_has_posts()) { return false; } |
|
| 67 | + if ( !self::wp_query_has_posts() ) { return false; } |
|
| 68 | 68 | |
| 69 | 69 | global $wp_query; |
| 70 | 70 | $post_num = property_exists($wp_query, 'current_post') |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | : 0 |
| 73 | 73 | ; |
| 74 | 74 | |
| 75 | - if (!isset($wp_query->posts[$post_num])) { return false; } |
|
| 75 | + if ( !isset($wp_query->posts[$post_num]) ) { return false; } |
|
| 76 | 76 | |
| 77 | 77 | return $wp_query->posts[$post_num]->ID; |
| 78 | 78 | } |
@@ -89,13 +89,13 @@ discard block |
||
| 89 | 89 | * @param string|array $arg |
| 90 | 90 | * @return bool |
| 91 | 91 | */ |
| 92 | - static function is_post_class_or_class_map($arg){ |
|
| 93 | - if (is_string($arg) && class_exists($arg)) { |
|
| 92 | + static function is_post_class_or_class_map($arg) { |
|
| 93 | + if ( is_string($arg) && class_exists($arg) ) { |
|
| 94 | 94 | return true; |
| 95 | 95 | } |
| 96 | - if (is_array($arg)) { |
|
| 96 | + if ( is_array($arg) ) { |
|
| 97 | 97 | foreach ($arg as $item) { |
| 98 | - if (is_string($item) && (class_exists($item) && is_subclass_of($item, 'TimberPost'))) { |
|
| 98 | + if ( is_string($item) && (class_exists($item) && is_subclass_of($item, 'TimberPost')) ) { |
|
| 99 | 99 | return true; |
| 100 | 100 | } |
| 101 | 101 | } |
@@ -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 | } |
@@ -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 | /** |