@@ -2,5 +2,5 @@ |
||
2 | 2 | /** |
3 | 3 | * Init our WordPress Theme. |
4 | 4 | */ |
5 | -require_once( __DIR__ . '/vendor/autoload.php' ); |
|
5 | +require_once(__DIR__.'/vendor/autoload.php'); |
|
6 | 6 | \Classy\Classy::get_instance(); |
@@ -2,4 +2,4 @@ |
||
2 | 2 | /** |
3 | 3 | * Theme header. |
4 | 4 | */ |
5 | -get_theme_framework()::render( 'layout.header' ); |
|
5 | +get_theme_framework()::render('layout.header'); |
@@ -2,4 +2,4 @@ |
||
2 | 2 | /** |
3 | 3 | * Theme footer. |
4 | 4 | */ |
5 | -get_theme_framework()::render( 'layout.footer' ); |
|
5 | +get_theme_framework()::render('layout.footer'); |
@@ -2,6 +2,6 @@ |
||
2 | 2 | |
3 | 3 | global $post; |
4 | 4 | |
5 | -$classypost = new \Classy\Models\Post( $post ); |
|
5 | +$classypost = new \Classy\Models\Post($post); |
|
6 | 6 | |
7 | -Classy\Classy::render( 'layout.comments', array( 'post' => $classypost ) ); |
|
7 | +Classy\Classy::render('layout.comments', array('post' => $classypost)); |
@@ -93,12 +93,12 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @param object|int $post WP_Post or WP_Post.ID. |
95 | 95 | */ |
96 | - public function __construct( $post = null ) { |
|
97 | - if ( is_integer( $post ) ) { |
|
96 | + public function __construct($post = null) { |
|
97 | + if (is_integer($post)) { |
|
98 | 98 | $this->ID = $post; |
99 | 99 | $this->init(); |
100 | - } elseif ( is_a( $post, '\WP_Post' ) ) { |
|
101 | - $this->import( $post ); |
|
100 | + } elseif (is_a($post, '\WP_Post')) { |
|
101 | + $this->import($post); |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | protected function init() { |
109 | 109 | $post = $this->get_object(); |
110 | 110 | |
111 | - if ( is_a( $post, '\WP_Post' ) ) { |
|
112 | - $this->import( $post ); |
|
111 | + if (is_a($post, '\WP_Post')) { |
|
112 | + $this->import($post); |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * @return \WP_Post |
120 | 120 | */ |
121 | 121 | public function get_object() { |
122 | - $object = get_post( $this->ID ); |
|
122 | + $object = get_post($this->ID); |
|
123 | 123 | |
124 | 124 | return $object; |
125 | 125 | } |
@@ -130,10 +130,10 @@ discard block |
||
130 | 130 | * @return boolean |
131 | 131 | */ |
132 | 132 | public function can_edit() { |
133 | - if ( ! function_exists( 'current_user_can' ) ) { |
|
133 | + if (!function_exists('current_user_can')) { |
|
134 | 134 | return false; |
135 | 135 | } |
136 | - if ( current_user_can( 'edit_post', $this->ID ) ) { |
|
136 | + if (current_user_can('edit_post', $this->ID)) { |
|
137 | 137 | return true; |
138 | 138 | } |
139 | 139 | |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | * @return string |
147 | 147 | */ |
148 | 148 | public function get_edit_url() { |
149 | - if ( $this->can_edit() ) { |
|
150 | - return get_edit_post_link( $this->ID ); |
|
149 | + if ($this->can_edit()) { |
|
150 | + return get_edit_post_link($this->ID); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | return ''; |
@@ -170,9 +170,9 @@ discard block |
||
170 | 170 | 'fields' => 'ids', |
171 | 171 | ); |
172 | 172 | |
173 | - $images = get_children( $attrs ); |
|
173 | + $images = get_children($attrs); |
|
174 | 174 | |
175 | - if ( ! count( $images ) ) { |
|
175 | + if (!count($images)) { |
|
176 | 176 | return false; |
177 | 177 | } |
178 | 178 | |
@@ -189,11 +189,11 @@ discard block |
||
189 | 189 | |
190 | 190 | $images = $this->get_attached_images(); |
191 | 191 | |
192 | - if ( $images ) { |
|
192 | + if ($images) { |
|
193 | 193 | |
194 | - foreach ( $images as $image_id ) { |
|
194 | + foreach ($images as $image_id) { |
|
195 | 195 | |
196 | - $_return[] = new Image( $image_id ); |
|
196 | + $_return[] = new Image($image_id); |
|
197 | 197 | |
198 | 198 | } |
199 | 199 | } |
@@ -219,13 +219,13 @@ discard block |
||
219 | 219 | 'fields' => 'ids', |
220 | 220 | ); |
221 | 221 | |
222 | - $images = get_children( $attrs ); |
|
222 | + $images = get_children($attrs); |
|
223 | 223 | |
224 | - if ( ! count( $images ) ) { |
|
224 | + if (!count($images)) { |
|
225 | 225 | return false; |
226 | 226 | } |
227 | 227 | |
228 | - $images = array_values( $images ); |
|
228 | + $images = array_values($images); |
|
229 | 229 | |
230 | 230 | return $images[0]; |
231 | 231 | } |
@@ -239,8 +239,8 @@ discard block |
||
239 | 239 | |
240 | 240 | $image_id = $this->get_first_attached_image_id(); |
241 | 241 | |
242 | - if ( $image_id ) { |
|
243 | - return new Image( $image_id ); |
|
242 | + if ($image_id) { |
|
243 | + return new Image($image_id); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | return new Image(); |
@@ -252,12 +252,12 @@ discard block |
||
252 | 252 | * @return Image |
253 | 253 | */ |
254 | 254 | public function thumbnail() { |
255 | - if ( function_exists( 'get_post_thumbnail_id' ) ) { |
|
256 | - $image_id = get_post_thumbnail_id( $this->ID ); |
|
255 | + if (function_exists('get_post_thumbnail_id')) { |
|
256 | + $image_id = get_post_thumbnail_id($this->ID); |
|
257 | 257 | |
258 | - if ( $image_id ) { |
|
258 | + if ($image_id) { |
|
259 | 259 | |
260 | - return new Image( $image_id ); |
|
260 | + return new Image($image_id); |
|
261 | 261 | |
262 | 262 | } |
263 | 263 | } |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | * @return string |
272 | 272 | */ |
273 | 273 | public function get_title() { |
274 | - return apply_filters( 'the_title', $this->post_title, $this->ID ); |
|
274 | + return apply_filters('the_title', $this->post_title, $this->ID); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | /** |
@@ -290,24 +290,24 @@ discard block |
||
290 | 290 | * |
291 | 291 | * @return string Post content |
292 | 292 | */ |
293 | - public function get_content( $page = 0 ) { |
|
294 | - if ( 0 === absint( $page ) && $this->post_content ) { |
|
293 | + public function get_content($page = 0) { |
|
294 | + if (0 === absint($page) && $this->post_content) { |
|
295 | 295 | return $this->post_content; |
296 | 296 | } |
297 | 297 | |
298 | 298 | $content = $this->post_content; |
299 | 299 | |
300 | - if ( $page ) { |
|
301 | - $contents = explode( '<!--nextpage-->', $content ); |
|
300 | + if ($page) { |
|
301 | + $contents = explode('<!--nextpage-->', $content); |
|
302 | 302 | |
303 | 303 | $page--; |
304 | 304 | |
305 | - if ( count( $contents ) > $page ) { |
|
306 | - $content = $contents[ $page ]; |
|
305 | + if (count($contents) > $page) { |
|
306 | + $content = $contents[$page]; |
|
307 | 307 | } |
308 | 308 | } |
309 | 309 | |
310 | - $content = apply_filters( 'the_content', ($content) ); |
|
310 | + $content = apply_filters('the_content', ($content)); |
|
311 | 311 | |
312 | 312 | return $content; |
313 | 313 | } |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | * @return object |
328 | 328 | */ |
329 | 329 | public function get_post_type() { |
330 | - return get_post_type_object( $this->post_type ); |
|
330 | + return get_post_type_object($this->post_type); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | /** |
@@ -336,11 +336,11 @@ discard block |
||
336 | 336 | * @return string |
337 | 337 | */ |
338 | 338 | public function get_permalink() { |
339 | - if ( isset( $this->permalink ) ) { |
|
339 | + if (isset($this->permalink)) { |
|
340 | 340 | return $this->permalink; |
341 | 341 | } |
342 | 342 | |
343 | - $this->permalink = get_permalink( $this->ID ); |
|
343 | + $this->permalink = get_permalink($this->ID); |
|
344 | 344 | |
345 | 345 | return $this->permalink; |
346 | 346 | } |
@@ -366,84 +366,84 @@ discard block |
||
366 | 366 | * |
367 | 367 | * @return string Post preview. |
368 | 368 | */ |
369 | - public function get_preview( $len = 50, $force = false, $readmore = 'Read More', $strip = true ) { |
|
369 | + public function get_preview($len = 50, $force = false, $readmore = 'Read More', $strip = true) { |
|
370 | 370 | $text = ''; |
371 | 371 | $trimmed = false; |
372 | 372 | |
373 | - if ( isset( $this->post_excerpt ) && strlen( $this->post_excerpt ) ) { |
|
373 | + if (isset($this->post_excerpt) && strlen($this->post_excerpt)) { |
|
374 | 374 | |
375 | - if ( $force ) { |
|
376 | - $text = Helper::trim_words( $this->post_excerpt, $len, false ); |
|
375 | + if ($force) { |
|
376 | + $text = Helper::trim_words($this->post_excerpt, $len, false); |
|
377 | 377 | $trimmed = true; |
378 | 378 | } else { |
379 | 379 | $text = $this->post_excerpt; |
380 | 380 | } |
381 | 381 | } |
382 | 382 | |
383 | - if ( ! strlen( $text ) && preg_match( '/<!--\s?more(.*?)?-->/', $this->post_content, $readmore_matches ) ) { |
|
383 | + if (!strlen($text) && preg_match('/<!--\s?more(.*?)?-->/', $this->post_content, $readmore_matches)) { |
|
384 | 384 | |
385 | - $pieces = explode( $readmore_matches[0], $this->post_content ); |
|
385 | + $pieces = explode($readmore_matches[0], $this->post_content); |
|
386 | 386 | $text = $pieces[0]; |
387 | 387 | |
388 | - if ( $force ) { |
|
389 | - $text = Helper::trim_words( $text, $len, false ); |
|
388 | + if ($force) { |
|
389 | + $text = Helper::trim_words($text, $len, false); |
|
390 | 390 | $trimmed = true; |
391 | 391 | } |
392 | 392 | |
393 | - $text = do_shortcode( $text ); |
|
393 | + $text = do_shortcode($text); |
|
394 | 394 | |
395 | 395 | } |
396 | 396 | |
397 | - if ( ! strlen( $text ) ) { |
|
397 | + if (!strlen($text)) { |
|
398 | 398 | |
399 | - $text = Helper::trim_words( $this->get_content(), $len, false ); |
|
399 | + $text = Helper::trim_words($this->get_content(), $len, false); |
|
400 | 400 | $trimmed = true; |
401 | 401 | |
402 | 402 | } |
403 | 403 | |
404 | - if ( ! strlen( trim( $text ) ) ) { |
|
404 | + if (!strlen(trim($text))) { |
|
405 | 405 | |
406 | - return trim( $text ); |
|
406 | + return trim($text); |
|
407 | 407 | |
408 | 408 | } |
409 | 409 | |
410 | - if ( $strip ) { |
|
410 | + if ($strip) { |
|
411 | 411 | |
412 | - $text = trim( strip_tags( $text ) ); |
|
412 | + $text = trim(strip_tags($text)); |
|
413 | 413 | |
414 | 414 | } |
415 | 415 | |
416 | - if ( strlen( $text ) ) { |
|
416 | + if (strlen($text)) { |
|
417 | 417 | |
418 | - $text = trim( $text ); |
|
419 | - $last = $text[ strlen( $text ) - 1 ]; |
|
418 | + $text = trim($text); |
|
419 | + $last = $text[strlen($text) - 1]; |
|
420 | 420 | |
421 | - if ( '.' !== $last && $trimmed ) { |
|
421 | + if ('.' !== $last && $trimmed) { |
|
422 | 422 | $text .= ' … '; |
423 | 423 | } |
424 | 424 | |
425 | - if ( ! $strip ) { |
|
426 | - $last_p_tag = strrpos( $text, '</p>' ); |
|
427 | - if ( false !== $last_p_tag ) { |
|
428 | - $text = substr( $text, 0, $last_p_tag ); |
|
425 | + if (!$strip) { |
|
426 | + $last_p_tag = strrpos($text, '</p>'); |
|
427 | + if (false !== $last_p_tag) { |
|
428 | + $text = substr($text, 0, $last_p_tag); |
|
429 | 429 | } |
430 | - if ( '.' !== $last && $trimmed ) { |
|
430 | + if ('.' !== $last && $trimmed) { |
|
431 | 431 | $text .= ' … '; |
432 | 432 | } |
433 | 433 | } |
434 | 434 | |
435 | - if ( $readmore && isset( $readmore_matches ) && ! empty( $readmore_matches[1] ) ) { |
|
436 | - $text .= ' <a href="' . $this->get_permalink() . '" class="read-more">' . trim( $readmore_matches[1] ) . '</a>'; |
|
437 | - } elseif ( $readmore ) { |
|
438 | - $text .= ' <a href="' . $this->get_permalink() . '" class="read-more">' . trim( $readmore ) . '</a>'; |
|
435 | + if ($readmore && isset($readmore_matches) && !empty($readmore_matches[1])) { |
|
436 | + $text .= ' <a href="'.$this->get_permalink().'" class="read-more">'.trim($readmore_matches[1]).'</a>'; |
|
437 | + } elseif ($readmore) { |
|
438 | + $text .= ' <a href="'.$this->get_permalink().'" class="read-more">'.trim($readmore).'</a>'; |
|
439 | 439 | } |
440 | 440 | |
441 | - if ( ! $strip ) { |
|
441 | + if (!$strip) { |
|
442 | 442 | $text .= '</p>'; |
443 | 443 | } |
444 | 444 | } |
445 | 445 | |
446 | - return trim( $text ); |
|
446 | + return trim($text); |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | /** |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | * |
455 | 455 | * @return array |
456 | 456 | */ |
457 | - public function get_comments( $status = 'approve', $order = 'DESC' ) { |
|
457 | + public function get_comments($status = 'approve', $order = 'DESC') { |
|
458 | 458 | |
459 | 459 | $_return = array(); |
460 | 460 | |
@@ -464,25 +464,25 @@ discard block |
||
464 | 464 | 'order' => $order, |
465 | 465 | ); |
466 | 466 | |
467 | - $comments = get_comments( $args ); |
|
467 | + $comments = get_comments($args); |
|
468 | 468 | |
469 | - foreach ( $comments as $comment ) { |
|
469 | + foreach ($comments as $comment) { |
|
470 | 470 | |
471 | - $_return[ $comment->comment_ID ] = new Comment( $comment ); |
|
471 | + $_return[$comment->comment_ID] = new Comment($comment); |
|
472 | 472 | |
473 | 473 | } |
474 | 474 | |
475 | - foreach ( $_return as $key => $comment ) { |
|
475 | + foreach ($_return as $key => $comment) { |
|
476 | 476 | |
477 | - if ( $comment->has_parent() ) { |
|
477 | + if ($comment->has_parent()) { |
|
478 | 478 | |
479 | - $_return[ $comment->comment_parent ]->add_child( $comment ); |
|
479 | + $_return[$comment->comment_parent]->add_child($comment); |
|
480 | 480 | |
481 | - unset( $_return[ $key ] ); |
|
481 | + unset($_return[$key]); |
|
482 | 482 | |
483 | 483 | } |
484 | 484 | } |
485 | 485 | |
486 | - return array_values( $_return ); |
|
486 | + return array_values($_return); |
|
487 | 487 | } |
488 | 488 | } |
@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | |
30 | 30 | $request = Hierarchy::get_current_request(); |
31 | 31 | |
32 | - $file = Hierarchy::get_available_file( 'view', $request ); |
|
32 | + $file = Hierarchy::get_available_file('view', $request); |
|
33 | 33 | |
34 | - $view = self::get_blade_view( $file ); |
|
34 | + $view = self::get_blade_view($file); |
|
35 | 35 | |
36 | 36 | return $view; |
37 | 37 | |
@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return string |
46 | 46 | */ |
47 | - public static function get_blade_view( $view ) { |
|
47 | + public static function get_blade_view($view) { |
|
48 | 48 | |
49 | - return str_replace( '/', '.', $view ); |
|
49 | + return str_replace('/', '.', $view); |
|
50 | 50 | |
51 | 51 | } |
52 | 52 | |
@@ -59,21 +59,21 @@ discard block |
||
59 | 59 | |
60 | 60 | $templates = array(); |
61 | 61 | |
62 | - $files = (array) glob( CLASSY_THEME_PATH . '/' . self::$folder . '/*/*.blade.php' ); |
|
62 | + $files = (array) glob(CLASSY_THEME_PATH.'/'.self::$folder.'/*/*.blade.php'); |
|
63 | 63 | |
64 | - foreach ( $files as $filename ) { |
|
64 | + foreach ($files as $filename) { |
|
65 | 65 | |
66 | - if ( ! empty( $filename ) ) { |
|
66 | + if (!empty($filename)) { |
|
67 | 67 | |
68 | - if ( ! preg_match( '/\{\{\-\-\s*Template Name:(.*)\s*\-\-\}\}/mi', file_get_contents( $filename ), $header ) ) { continue; } |
|
68 | + if (!preg_match('/\{\{\-\-\s*Template Name:(.*)\s*\-\-\}\}/mi', file_get_contents($filename), $header)) { continue; } |
|
69 | 69 | |
70 | - $template_name = trim( $header[1] ); |
|
70 | + $template_name = trim($header[1]); |
|
71 | 71 | |
72 | - preg_match( '/\/([^\/]*)\.blade.php$/is', $filename, $filename_match ); |
|
72 | + preg_match('/\/([^\/]*)\.blade.php$/is', $filename, $filename_match); |
|
73 | 73 | |
74 | - $template_file = 'classy-' . $filename_match[1]; |
|
74 | + $template_file = 'classy-'.$filename_match[1]; |
|
75 | 75 | |
76 | - $templates[ $template_file ] = $template_name; |
|
76 | + $templates[$template_file] = $template_name; |
|
77 | 77 | |
78 | 78 | } |
79 | 79 | } |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | * |
82 | 82 | * @param \WP_Comment $item |
83 | 83 | */ |
84 | - public function __construct( $item ) { |
|
84 | + public function __construct($item) { |
|
85 | 85 | |
86 | - if ( is_a( $item, '\WP_Comment' ) ) { |
|
86 | + if (is_a($item, '\WP_Comment')) { |
|
87 | 87 | |
88 | - $this->import( $item ); |
|
88 | + $this->import($item); |
|
89 | 89 | |
90 | 90 | } |
91 | 91 | |
@@ -98,15 +98,15 @@ discard block |
||
98 | 98 | */ |
99 | 99 | public function author() { |
100 | 100 | |
101 | - if ( $this->user_id ) { |
|
101 | + if ($this->user_id) { |
|
102 | 102 | |
103 | - return new Models\User( $this->user_id ); |
|
103 | + return new Models\User($this->user_id); |
|
104 | 104 | |
105 | 105 | } else { |
106 | 106 | |
107 | - $author = new Models\User( 0 ); |
|
107 | + $author = new Models\User(0); |
|
108 | 108 | |
109 | - if ( isset( $this->comment_author ) && $this->comment_author ) { |
|
109 | + if (isset($this->comment_author) && $this->comment_author) { |
|
110 | 110 | |
111 | 111 | $author->name = $this->comment_author; |
112 | 112 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * @return string |
124 | 124 | */ |
125 | 125 | public function content() { |
126 | - return apply_filters( 'get_comment_text ', $this->comment_content ); |
|
126 | + return apply_filters('get_comment_text ', $this->comment_content); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -141,11 +141,11 @@ discard block |
||
141 | 141 | * @param string $date_format |
142 | 142 | * @return string |
143 | 143 | */ |
144 | - public function date( $date_format = '' ) { |
|
145 | - $df = $date_format ? $date_format : get_option( 'date_format' ); |
|
146 | - $the_date = (string) mysql2date( $df, $this->comment_date ); |
|
144 | + public function date($date_format = '') { |
|
145 | + $df = $date_format ? $date_format : get_option('date_format'); |
|
146 | + $the_date = (string) mysql2date($df, $this->comment_date); |
|
147 | 147 | |
148 | - return apply_filters( 'get_comment_date ', $the_date, $df ); |
|
148 | + return apply_filters('get_comment_date ', $the_date, $df); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -164,26 +164,26 @@ discard block |
||
164 | 164 | * @param string $default |
165 | 165 | * @return string |
166 | 166 | */ |
167 | - public function avatar( $size = 92, $default = '' ) { |
|
167 | + public function avatar($size = 92, $default = '') { |
|
168 | 168 | |
169 | - if ( ! get_option( 'show_avatars' ) ) { |
|
169 | + if (!get_option('show_avatars')) { |
|
170 | 170 | return false; |
171 | 171 | } |
172 | 172 | |
173 | - if ( ! is_numeric( $size ) ) { $size = '92'; } |
|
173 | + if (!is_numeric($size)) { $size = '92'; } |
|
174 | 174 | |
175 | 175 | $email = $this->get_avatar_email(); |
176 | 176 | $email_hash = ''; |
177 | 177 | |
178 | - if ( ! empty( $email ) ) { |
|
179 | - $email_hash = md5( strtolower( trim( $email ) ) ); |
|
178 | + if (!empty($email)) { |
|
179 | + $email_hash = md5(strtolower(trim($email))); |
|
180 | 180 | } |
181 | 181 | |
182 | - $host = $this->get_avatar_host( $email_hash ); |
|
183 | - $default = $this->get_default_avatar( $default, $email, $size, $host ); |
|
182 | + $host = $this->get_avatar_host($email_hash); |
|
183 | + $default = $this->get_default_avatar($default, $email, $size, $host); |
|
184 | 184 | |
185 | - if ( ! empty( $email ) ) { |
|
186 | - $avatar = $this->get_avatar_url( $default, $host, $email_hash, $size ); |
|
185 | + if (!empty($email)) { |
|
186 | + $avatar = $this->get_avatar_url($default, $host, $email_hash, $size); |
|
187 | 187 | } else { |
188 | 188 | $avatar = $default; |
189 | 189 | } |
@@ -200,9 +200,9 @@ discard block |
||
200 | 200 | protected function get_avatar_email() { |
201 | 201 | |
202 | 202 | $id = (int) $this->user_id; |
203 | - $user = get_userdata( $id ); |
|
203 | + $user = get_userdata($id); |
|
204 | 204 | |
205 | - if ( $user ) { |
|
205 | + if ($user) { |
|
206 | 206 | $email = $user->user_email; |
207 | 207 | } else { |
208 | 208 | $email = $this->comment_author_email; |
@@ -221,32 +221,32 @@ discard block |
||
221 | 221 | * @param string $host |
222 | 222 | * @return string |
223 | 223 | */ |
224 | - protected function get_default_avatar( $default, $email, $size, $host ) { |
|
224 | + protected function get_default_avatar($default, $email, $size, $host) { |
|
225 | 225 | |
226 | - if ( '/' === substr( $default, 0, 1 ) ) { |
|
227 | - $default = home_url() . $default; |
|
226 | + if ('/' === substr($default, 0, 1)) { |
|
227 | + $default = home_url().$default; |
|
228 | 228 | } |
229 | 229 | |
230 | - if ( empty( $default ) ) { |
|
231 | - $avatar_default = get_option( 'avatar_default' ); |
|
232 | - if ( empty( $avatar_default ) ) { |
|
230 | + if (empty($default)) { |
|
231 | + $avatar_default = get_option('avatar_default'); |
|
232 | + if (empty($avatar_default)) { |
|
233 | 233 | $default = 'mystery'; |
234 | 234 | } else { |
235 | 235 | $default = $avatar_default; |
236 | 236 | } |
237 | 237 | } |
238 | 238 | |
239 | - if ( 'mystery' === $default ) { |
|
240 | - $default = $host . '/avatar/ad516503a11cd5ca435acc9bb6523536?s=' . $size; |
|
239 | + if ('mystery' === $default) { |
|
240 | + $default = $host.'/avatar/ad516503a11cd5ca435acc9bb6523536?s='.$size; |
|
241 | 241 | // ad516503a11cd5ca435acc9bb6523536 == md5('[email protected]') |
242 | - } else if ( 'blank' === $default ) { |
|
243 | - $default = $email ? 'blank' : includes_url( 'images/blank.gif' ); |
|
244 | - } else if ( ! empty( $email ) && 'gravatar_default' === $default ) { |
|
242 | + } else if ('blank' === $default) { |
|
243 | + $default = $email ? 'blank' : includes_url('images/blank.gif'); |
|
244 | + } else if (!empty($email) && 'gravatar_default' === $default) { |
|
245 | 245 | $default = ''; |
246 | - } else if ( 'gravatar_default' === $default ) { |
|
247 | - $default = $host . '/avatar/?s=' . $size; |
|
248 | - } else if ( empty( $email ) && ! strstr( $default, 'http://' ) ) { |
|
249 | - $default = $host . '/avatar/?d=' . $default . '&s=' . $size; |
|
246 | + } else if ('gravatar_default' === $default) { |
|
247 | + $default = $host.'/avatar/?s='.$size; |
|
248 | + } else if (empty($email) && !strstr($default, 'http://')) { |
|
249 | + $default = $host.'/avatar/?d='.$default.'&s='.$size; |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | return $default; |
@@ -259,13 +259,13 @@ discard block |
||
259 | 259 | * @param string $email_hash |
260 | 260 | * @return string |
261 | 261 | */ |
262 | - protected function get_avatar_host( $email_hash ) { |
|
262 | + protected function get_avatar_host($email_hash) { |
|
263 | 263 | |
264 | - if ( is_ssl() ) { |
|
264 | + if (is_ssl()) { |
|
265 | 265 | $host = 'https://secure.gravatar.com'; |
266 | 266 | } else { |
267 | - if ( ! empty( $email_hash ) ) { |
|
268 | - $host = sprintf( 'http://%d.gravatar.com', (hexdec( $email_hash[0] ) % 2) ); |
|
267 | + if (!empty($email_hash)) { |
|
268 | + $host = sprintf('http://%d.gravatar.com', (hexdec($email_hash[0]) % 2)); |
|
269 | 269 | } else { |
270 | 270 | $host = 'http://0.gravatar.com'; |
271 | 271 | } |
@@ -284,16 +284,16 @@ discard block |
||
284 | 284 | * @param int $size |
285 | 285 | * @return string |
286 | 286 | */ |
287 | - protected function get_avatar_url( $default, $host, $email_hash, $size ) { |
|
287 | + protected function get_avatar_url($default, $host, $email_hash, $size) { |
|
288 | 288 | |
289 | - $_return = $host . '/avatar/' . $email_hash . '?s=' . $size . '&d=' . urlencode( $default ); |
|
290 | - $rating = get_option( 'avatar_rating' ); |
|
289 | + $_return = $host.'/avatar/'.$email_hash.'?s='.$size.'&d='.urlencode($default); |
|
290 | + $rating = get_option('avatar_rating'); |
|
291 | 291 | |
292 | - if ( ! empty( $rating ) ) { |
|
293 | - $_return .= '&r=' . $rating; |
|
292 | + if (!empty($rating)) { |
|
293 | + $_return .= '&r='.$rating; |
|
294 | 294 | } |
295 | 295 | |
296 | - return str_replace( '&', '&', esc_url( $_return ) ); |
|
296 | + return str_replace('&', '&', esc_url($_return)); |
|
297 | 297 | |
298 | 298 | } |
299 | 299 | |
@@ -302,12 +302,12 @@ discard block |
||
302 | 302 | * |
303 | 303 | * @param Comment $comment |
304 | 304 | */ |
305 | - public function add_child( $comment ) { |
|
305 | + public function add_child($comment) { |
|
306 | 306 | |
307 | 307 | $this->children[] = $comment; |
308 | 308 | $item->level = $this->level + 1; |
309 | 309 | |
310 | - if ( $item->children ) { |
|
310 | + if ($item->children) { |
|
311 | 311 | $this->update_child_levels(); |
312 | 312 | } |
313 | 313 | |
@@ -321,9 +321,9 @@ discard block |
||
321 | 321 | */ |
322 | 322 | protected function update_child_levels() { |
323 | 323 | |
324 | - if ( is_array( $this->children ) ) { |
|
324 | + if (is_array($this->children)) { |
|
325 | 325 | |
326 | - foreach ( $this->children as $child ) { |
|
326 | + foreach ($this->children as $child) { |
|
327 | 327 | $child->level = $this->level + 1; |
328 | 328 | $child->update_child_levels(); |
329 | 329 | } |
@@ -9,23 +9,23 @@ discard block |
||
9 | 9 | * @param array|boolean $args |
10 | 10 | * @return object WP_Query |
11 | 11 | */ |
12 | - public static function find_query( $args = false ) { |
|
12 | + public static function find_query($args = false) { |
|
13 | 13 | |
14 | 14 | $default_args = array(); |
15 | 15 | |
16 | - if ( ! $args ) { |
|
16 | + if (!$args) { |
|
17 | 17 | |
18 | 18 | return self::get_current_query(); |
19 | 19 | |
20 | - } elseif ( is_array( $args ) ) { |
|
20 | + } elseif (is_array($args)) { |
|
21 | 21 | |
22 | - $args = array_merge( $default_args, $args ); |
|
22 | + $args = array_merge($default_args, $args); |
|
23 | 23 | |
24 | - return new \WP_Query( $args ); |
|
24 | + return new \WP_Query($args); |
|
25 | 25 | |
26 | 26 | } else { |
27 | 27 | |
28 | - return new \WP_Query( $default_args ); |
|
28 | + return new \WP_Query($default_args); |
|
29 | 29 | |
30 | 30 | } |
31 | 31 | } |
@@ -39,9 +39,9 @@ discard block |
||
39 | 39 | |
40 | 40 | global $wp_query; |
41 | 41 | |
42 | - $query =& $wp_query; |
|
42 | + $query = & $wp_query; |
|
43 | 43 | |
44 | - $query = self::handle_maybe_custom_posts_page( $query ); |
|
44 | + $query = self::handle_maybe_custom_posts_page($query); |
|
45 | 45 | |
46 | 46 | return $query; |
47 | 47 | |
@@ -53,13 +53,13 @@ discard block |
||
53 | 53 | * @param object $query WP_Query |
54 | 54 | * @return object WP_Query |
55 | 55 | */ |
56 | - private static function handle_maybe_custom_posts_page( $query ) { |
|
56 | + private static function handle_maybe_custom_posts_page($query) { |
|
57 | 57 | |
58 | - if ( $custom_posts_page = get_option( 'page_for_posts' ) ) { |
|
58 | + if ($custom_posts_page = get_option('page_for_posts')) { |
|
59 | 59 | |
60 | - if ( isset( $query->query['p'] ) && absint( $query->query['p'] ) === absint( $custom_posts_page ) ) { |
|
60 | + if (isset($query->query['p']) && absint($query->query['p']) === absint($custom_posts_page)) { |
|
61 | 61 | |
62 | - return new \WP_Query( array( 'post_type' => 'post' ) ); |
|
62 | + return new \WP_Query(array('post_type' => 'post')); |
|
63 | 63 | |
64 | 64 | } |
65 | 65 | } |
@@ -24,25 +24,25 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @param string $arg it can be menu id, slug or full name |
26 | 26 | */ |
27 | - public function __construct( $arg = null ) { |
|
27 | + public function __construct($arg = null) { |
|
28 | 28 | |
29 | - if ( is_numeric( $arg ) && 0 !== absint( $arg ) ) { |
|
29 | + if (is_numeric($arg) && 0 !== absint($arg)) { |
|
30 | 30 | |
31 | - $menu_id = $this->check_menu_id( $arg ); |
|
31 | + $menu_id = $this->check_menu_id($arg); |
|
32 | 32 | |
33 | - } elseif ( is_string( $arg ) ) { |
|
33 | + } elseif (is_string($arg)) { |
|
34 | 34 | |
35 | - $menu_id = $this->get_menu_id_by_name( $arg ); |
|
35 | + $menu_id = $this->get_menu_id_by_name($arg); |
|
36 | 36 | |
37 | 37 | } |
38 | 38 | |
39 | - if ( ! isset( $menu_id ) ) { |
|
39 | + if (!isset($menu_id)) { |
|
40 | 40 | |
41 | 41 | $menu_id = $this->get_first_menu_id(); |
42 | 42 | |
43 | 43 | } |
44 | 44 | |
45 | - if ( $menu_id ) { |
|
45 | + if ($menu_id) { |
|
46 | 46 | |
47 | 47 | $this->ID = $menu_id; |
48 | 48 | |
@@ -61,22 +61,22 @@ discard block |
||
61 | 61 | |
62 | 62 | $_return = array(); |
63 | 63 | |
64 | - $items = wp_get_nav_menu_items( $this->ID ); |
|
64 | + $items = wp_get_nav_menu_items($this->ID); |
|
65 | 65 | |
66 | - foreach ( $items as $item ) { |
|
66 | + foreach ($items as $item) { |
|
67 | 67 | |
68 | - $_return[ $item->ID ] = new Menu_Item( $item ); |
|
68 | + $_return[$item->ID] = new Menu_Item($item); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | // Apply nesting |
72 | 72 | |
73 | - foreach ( $_return as $item_id => $item ) { |
|
73 | + foreach ($_return as $item_id => $item) { |
|
74 | 74 | |
75 | - if ( isset( $item->menu_item_parent ) && $item->menu_item_parent && isset( $_return[ $item->menu_item_parent ] ) ) { |
|
75 | + if (isset($item->menu_item_parent) && $item->menu_item_parent && isset($_return[$item->menu_item_parent])) { |
|
76 | 76 | |
77 | - $_return[ $item->menu_item_parent ]->add_child( $item ); |
|
77 | + $_return[$item->menu_item_parent]->add_child($item); |
|
78 | 78 | |
79 | - unset( $_return[ $item_id ] ); |
|
79 | + unset($_return[$item_id]); |
|
80 | 80 | |
81 | 81 | } |
82 | 82 | } |
@@ -92,11 +92,11 @@ discard block |
||
92 | 92 | */ |
93 | 93 | protected function get_first_menu_id() { |
94 | 94 | |
95 | - $menus = get_terms( 'nav_menu', array( 'hide_empty' => true ) ); |
|
95 | + $menus = get_terms('nav_menu', array('hide_empty' => true)); |
|
96 | 96 | |
97 | - if ( is_array( $menus ) && count( $menus ) ) { |
|
97 | + if (is_array($menus) && count($menus)) { |
|
98 | 98 | |
99 | - if ( isset( $menus[0]->term_id ) ) { |
|
99 | + if (isset($menus[0]->term_id)) { |
|
100 | 100 | |
101 | 101 | return $menus[0]->term_id; |
102 | 102 | |
@@ -113,15 +113,15 @@ discard block |
||
113 | 113 | * @param int $menu_id |
114 | 114 | * @return int|boolean |
115 | 115 | */ |
116 | - protected function check_menu_id( $menu_id ) { |
|
116 | + protected function check_menu_id($menu_id) { |
|
117 | 117 | |
118 | - $menus = get_terms( 'nav_menu', array( 'hide_empty' => true ) ); |
|
118 | + $menus = get_terms('nav_menu', array('hide_empty' => true)); |
|
119 | 119 | |
120 | - if ( is_array( $menus ) && count( $menus ) ) { |
|
120 | + if (is_array($menus) && count($menus)) { |
|
121 | 121 | |
122 | - foreach ( $menus as $menu ) { |
|
122 | + foreach ($menus as $menu) { |
|
123 | 123 | |
124 | - if ( absint( $menu->term_id ) === absint( $menu_id ) ) { |
|
124 | + if (absint($menu->term_id) === absint($menu_id)) { |
|
125 | 125 | |
126 | 126 | return $menu_id; |
127 | 127 | |
@@ -139,17 +139,17 @@ discard block |
||
139 | 139 | * @param string $slug |
140 | 140 | * @return int |
141 | 141 | */ |
142 | - protected function get_menu_id_by_name( $slug = null ) { |
|
142 | + protected function get_menu_id_by_name($slug = null) { |
|
143 | 143 | |
144 | - if ( $slug && is_string( $slug ) ) { |
|
144 | + if ($slug && is_string($slug)) { |
|
145 | 145 | |
146 | - $menu_id = get_term_by( 'slug', $slug, 'nav_menu' ); |
|
146 | + $menu_id = get_term_by('slug', $slug, 'nav_menu'); |
|
147 | 147 | |
148 | - if ( $menu_id ) { return $menu_id; } |
|
148 | + if ($menu_id) { return $menu_id; } |
|
149 | 149 | |
150 | - $menu_id = get_term_by( 'name', $slug, 'nav_menu' ); |
|
150 | + $menu_id = get_term_by('name', $slug, 'nav_menu'); |
|
151 | 151 | |
152 | - if ( $menu_id ) { return $menu_id; } |
|
152 | + if ($menu_id) { return $menu_id; } |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | return false; |