@@ -73,12 +73,12 @@ discard block |
||
73 | 73 | * Main constructor function. If ID won't be provided we will try to find it, based on your query |
74 | 74 | * @param object/int $post |
75 | 75 | */ |
76 | - public function __construct( $post = null ) { |
|
77 | - if ( is_integer( $post ) ) { |
|
76 | + public function __construct($post = null) { |
|
77 | + if (is_integer($post)) { |
|
78 | 78 | $this->ID = $post; |
79 | 79 | $this->init(); |
80 | - } elseif ( is_a( $post, 'WP_Post' ) ) { |
|
81 | - $this->import( $post ); |
|
80 | + } elseif (is_a($post, 'WP_Post')) { |
|
81 | + $this->import($post); |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | protected function init() { |
89 | 89 | $post = $this->get_object(); |
90 | 90 | |
91 | - if ( is_a( $post, 'WP_Post' ) ) { |
|
92 | - $this->import( $post ); |
|
91 | + if (is_a($post, 'WP_Post')) { |
|
92 | + $this->import($post); |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | |
102 | 102 | public function get_object() { |
103 | - $object = get_post( $this->ID ); |
|
103 | + $object = get_post($this->ID); |
|
104 | 104 | |
105 | 105 | return $object; |
106 | 106 | } |
@@ -111,10 +111,10 @@ discard block |
||
111 | 111 | * @return boolean |
112 | 112 | */ |
113 | 113 | public function can_edit() { |
114 | - if ( ! function_exists( 'current_user_can' ) ) { |
|
114 | + if (!function_exists('current_user_can')) { |
|
115 | 115 | return false; |
116 | 116 | } |
117 | - if ( current_user_can( 'edit_post', $this->ID ) ) { |
|
117 | + if (current_user_can('edit_post', $this->ID)) { |
|
118 | 118 | return true; |
119 | 119 | } |
120 | 120 | return false; |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | * @return string |
127 | 127 | */ |
128 | 128 | public function get_edit_url() { |
129 | - if ( $this->can_edit() ) { |
|
130 | - return get_edit_post_link( $this->ID ); |
|
129 | + if ($this->can_edit()) { |
|
130 | + return get_edit_post_link($this->ID); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | |
@@ -149,9 +149,9 @@ discard block |
||
149 | 149 | 'fields' => 'ids', |
150 | 150 | ); |
151 | 151 | |
152 | - $images = get_children( $attrs ); |
|
152 | + $images = get_children($attrs); |
|
153 | 153 | |
154 | - if ( ! count( $images ) ) { |
|
154 | + if (!count($images)) { |
|
155 | 155 | return false; |
156 | 156 | } |
157 | 157 | |
@@ -170,11 +170,11 @@ discard block |
||
170 | 170 | |
171 | 171 | $images = $this->get_attached_images(); |
172 | 172 | |
173 | - if ( $images ) { |
|
173 | + if ($images) { |
|
174 | 174 | |
175 | - foreach ( $images as $image_id ) { |
|
175 | + foreach ($images as $image_id) { |
|
176 | 176 | |
177 | - $_return[] = new ClassyImage( $image_id ); |
|
177 | + $_return[] = new ClassyImage($image_id); |
|
178 | 178 | |
179 | 179 | } |
180 | 180 | } |
@@ -201,13 +201,13 @@ discard block |
||
201 | 201 | 'fields' => 'ids', |
202 | 202 | ); |
203 | 203 | |
204 | - $images = get_children( $attrs ); |
|
204 | + $images = get_children($attrs); |
|
205 | 205 | |
206 | - if ( ! count( $images ) ) { |
|
206 | + if (!count($images)) { |
|
207 | 207 | return false; |
208 | 208 | } |
209 | 209 | |
210 | - $images = array_values( $images ); |
|
210 | + $images = array_values($images); |
|
211 | 211 | |
212 | 212 | return $images[0]; |
213 | 213 | |
@@ -223,8 +223,8 @@ discard block |
||
223 | 223 | |
224 | 224 | $image_id = $this->get_first_attached_image_id(); |
225 | 225 | |
226 | - if ( $image_id ) { |
|
227 | - return new ClassyImage( $image_id ); |
|
226 | + if ($image_id) { |
|
227 | + return new ClassyImage($image_id); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | return new ClassyImage(); |
@@ -238,12 +238,12 @@ discard block |
||
238 | 238 | */ |
239 | 239 | public function thumbnail() { |
240 | 240 | |
241 | - if ( function_exists( 'get_post_thumbnail_id' ) ) { |
|
242 | - $image_id = get_post_thumbnail_id( $this->ID ); |
|
241 | + if (function_exists('get_post_thumbnail_id')) { |
|
242 | + $image_id = get_post_thumbnail_id($this->ID); |
|
243 | 243 | |
244 | - if ( $image_id ) { |
|
244 | + if ($image_id) { |
|
245 | 245 | |
246 | - return new ClassyImage( $image_id ); |
|
246 | + return new ClassyImage($image_id); |
|
247 | 247 | |
248 | 248 | } |
249 | 249 | } |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | * @return string |
260 | 260 | */ |
261 | 261 | public function get_title() { |
262 | - return apply_filters( 'the_title', $this->post_title, $this->ID ); |
|
262 | + return apply_filters('the_title', $this->post_title, $this->ID); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | /** |
@@ -278,24 +278,24 @@ discard block |
||
278 | 278 | * @param integer $page Page number, in case our post has <!--nextpage--> tags |
279 | 279 | * @return string Post content |
280 | 280 | */ |
281 | - public function get_content( $page = 0 ) { |
|
282 | - if ( 0 === absint( $page ) && $this->post_content ) { |
|
281 | + public function get_content($page = 0) { |
|
282 | + if (0 === absint($page) && $this->post_content) { |
|
283 | 283 | return $this->post_content; |
284 | 284 | } |
285 | 285 | |
286 | 286 | $content = $this->post_content; |
287 | 287 | |
288 | - if ( $page ) { |
|
289 | - $contents = explode( '<!--nextpage-->', $content ); |
|
288 | + if ($page) { |
|
289 | + $contents = explode('<!--nextpage-->', $content); |
|
290 | 290 | |
291 | 291 | $page--; |
292 | 292 | |
293 | - if ( count( $contents ) > $page ) { |
|
294 | - $content = $contents[ $page ]; |
|
293 | + if (count($contents) > $page) { |
|
294 | + $content = $contents[$page]; |
|
295 | 295 | } |
296 | 296 | } |
297 | 297 | |
298 | - $content = apply_filters( 'the_content', ($content) ); |
|
298 | + $content = apply_filters('the_content', ($content)); |
|
299 | 299 | |
300 | 300 | return $content; |
301 | 301 | } |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | * @return object |
317 | 317 | */ |
318 | 318 | public function get_post_type() { |
319 | - return get_post_type_object( $this->post_type ); |
|
319 | + return get_post_type_object($this->post_type); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | /** |
@@ -325,11 +325,11 @@ discard block |
||
325 | 325 | * @return string |
326 | 326 | */ |
327 | 327 | public function get_permalink() { |
328 | - if ( isset( $this->permalink ) ) { |
|
328 | + if (isset($this->permalink)) { |
|
329 | 329 | return $this->permalink; |
330 | 330 | } |
331 | 331 | |
332 | - $this->permalink = get_permalink( $this->ID ); |
|
332 | + $this->permalink = get_permalink($this->ID); |
|
333 | 333 | |
334 | 334 | return $this->permalink; |
335 | 335 | } |
@@ -355,84 +355,84 @@ discard block |
||
355 | 355 | * @param boolean $strip Should we strip tags? |
356 | 356 | * @return string Post preview |
357 | 357 | */ |
358 | - public function get_preview( $len = 50, $force = false, $readmore = 'Read More', $strip = true ) { |
|
358 | + public function get_preview($len = 50, $force = false, $readmore = 'Read More', $strip = true) { |
|
359 | 359 | $text = ''; |
360 | 360 | $trimmed = false; |
361 | 361 | |
362 | - if ( isset( $this->post_excerpt ) && strlen( $this->post_excerpt ) ) { |
|
362 | + if (isset($this->post_excerpt) && strlen($this->post_excerpt)) { |
|
363 | 363 | |
364 | - if ( $force ) { |
|
365 | - $text = ClassyHelper::trim_words( $this->post_excerpt, $len, false ); |
|
364 | + if ($force) { |
|
365 | + $text = ClassyHelper::trim_words($this->post_excerpt, $len, false); |
|
366 | 366 | $trimmed = true; |
367 | 367 | } else { |
368 | 368 | $text = $this->post_excerpt; |
369 | 369 | } |
370 | 370 | } |
371 | 371 | |
372 | - if ( ! strlen( $text ) && preg_match( '/<!--\s?more(.*?)?-->/', $this->post_content, $readmore_matches ) ) { |
|
372 | + if (!strlen($text) && preg_match('/<!--\s?more(.*?)?-->/', $this->post_content, $readmore_matches)) { |
|
373 | 373 | |
374 | - $pieces = explode( $readmore_matches[0], $this->post_content ); |
|
374 | + $pieces = explode($readmore_matches[0], $this->post_content); |
|
375 | 375 | $text = $pieces[0]; |
376 | 376 | |
377 | - if ( $force ) { |
|
378 | - $text = ClassyHelper::trim_words( $text, $len, false ); |
|
377 | + if ($force) { |
|
378 | + $text = ClassyHelper::trim_words($text, $len, false); |
|
379 | 379 | $trimmed = true; |
380 | 380 | } |
381 | 381 | |
382 | - $text = do_shortcode( $text ); |
|
382 | + $text = do_shortcode($text); |
|
383 | 383 | |
384 | 384 | } |
385 | 385 | |
386 | - if ( ! strlen( $text ) ) { |
|
386 | + if (!strlen($text)) { |
|
387 | 387 | |
388 | - $text = ClassyHelper::trim_words( $this->get_content(), $len, false ); |
|
388 | + $text = ClassyHelper::trim_words($this->get_content(), $len, false); |
|
389 | 389 | $trimmed = true; |
390 | 390 | |
391 | 391 | } |
392 | 392 | |
393 | - if ( ! strlen( trim( $text ) ) ) { |
|
393 | + if (!strlen(trim($text))) { |
|
394 | 394 | |
395 | - return trim( $text ); |
|
395 | + return trim($text); |
|
396 | 396 | |
397 | 397 | } |
398 | 398 | |
399 | - if ( $strip ) { |
|
399 | + if ($strip) { |
|
400 | 400 | |
401 | - $text = trim( strip_tags( $text ) ); |
|
401 | + $text = trim(strip_tags($text)); |
|
402 | 402 | |
403 | 403 | } |
404 | 404 | |
405 | - if ( strlen( $text ) ) { |
|
405 | + if (strlen($text)) { |
|
406 | 406 | |
407 | - $text = trim( $text ); |
|
408 | - $last = $text[ strlen( $text ) - 1 ]; |
|
407 | + $text = trim($text); |
|
408 | + $last = $text[strlen($text) - 1]; |
|
409 | 409 | |
410 | - if ( '.' !== $last && $trimmed ) { |
|
410 | + if ('.' !== $last && $trimmed) { |
|
411 | 411 | $text .= ' … '; |
412 | 412 | } |
413 | 413 | |
414 | - if ( ! $strip ) { |
|
415 | - $last_p_tag = strrpos( $text, '</p>' ); |
|
416 | - if ( false !== $last_p_tag ) { |
|
417 | - $text = substr( $text, 0, $last_p_tag ); |
|
414 | + if (!$strip) { |
|
415 | + $last_p_tag = strrpos($text, '</p>'); |
|
416 | + if (false !== $last_p_tag) { |
|
417 | + $text = substr($text, 0, $last_p_tag); |
|
418 | 418 | } |
419 | - if ( '.' !== $last && $trimmed ) { |
|
419 | + if ('.' !== $last && $trimmed) { |
|
420 | 420 | $text .= ' … '; |
421 | 421 | } |
422 | 422 | } |
423 | 423 | |
424 | - if ( $readmore && isset( $readmore_matches ) && ! empty( $readmore_matches[1] ) ) { |
|
425 | - $text .= ' <a href="' . $this->get_permalink() . '" class="read-more">' . trim( $readmore_matches[1] ) . '</a>'; |
|
426 | - } elseif ( $readmore ) { |
|
427 | - $text .= ' <a href="' . $this->get_permalink() . '" class="read-more">' . trim( $readmore ) . '</a>'; |
|
424 | + if ($readmore && isset($readmore_matches) && !empty($readmore_matches[1])) { |
|
425 | + $text .= ' <a href="'.$this->get_permalink().'" class="read-more">'.trim($readmore_matches[1]).'</a>'; |
|
426 | + } elseif ($readmore) { |
|
427 | + $text .= ' <a href="'.$this->get_permalink().'" class="read-more">'.trim($readmore).'</a>'; |
|
428 | 428 | } |
429 | 429 | |
430 | - if ( ! $strip ) { |
|
430 | + if (!$strip) { |
|
431 | 431 | $text .= '</p>'; |
432 | 432 | } |
433 | 433 | } |
434 | 434 | |
435 | - return trim( $text ); |
|
435 | + return trim($text); |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | /** |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | * |
444 | 444 | * @return array |
445 | 445 | */ |
446 | - public function get_comments( $status = 'approve', $order = 'DESC' ) { |
|
446 | + public function get_comments($status = 'approve', $order = 'DESC') { |
|
447 | 447 | |
448 | 448 | $_return = array(); |
449 | 449 | |
@@ -453,26 +453,26 @@ discard block |
||
453 | 453 | 'order' => $order, |
454 | 454 | ); |
455 | 455 | |
456 | - $comments = get_comments( $args ); |
|
456 | + $comments = get_comments($args); |
|
457 | 457 | |
458 | - foreach ( $comments as $comment ) { |
|
458 | + foreach ($comments as $comment) { |
|
459 | 459 | |
460 | - $_return[ $comment->comment_ID ] = new ClassyComment( $comment ); |
|
460 | + $_return[$comment->comment_ID] = new ClassyComment($comment); |
|
461 | 461 | |
462 | 462 | } |
463 | 463 | |
464 | - foreach ( $_return as $key => $comment ) { |
|
464 | + foreach ($_return as $key => $comment) { |
|
465 | 465 | |
466 | - if ( $comment->has_parent() ) { |
|
466 | + if ($comment->has_parent()) { |
|
467 | 467 | |
468 | - $_return[ $comment->comment_parent ]->add_child( $comment ); |
|
468 | + $_return[$comment->comment_parent]->add_child($comment); |
|
469 | 469 | |
470 | - unset( $_return[ $key ] ); |
|
470 | + unset($_return[$key]); |
|
471 | 471 | |
472 | 472 | } |
473 | 473 | } |
474 | 474 | |
475 | - return array_values( $_return ); |
|
475 | + return array_values($_return); |
|
476 | 476 | |
477 | 477 | } |
478 | 478 | } |
@@ -8,23 +8,23 @@ discard block |
||
8 | 8 | * @param array|boolean $args |
9 | 9 | * @return object WP_Query |
10 | 10 | */ |
11 | - public static function find_query( $args = false ) { |
|
11 | + public static function find_query($args = false) { |
|
12 | 12 | |
13 | 13 | $default_args = array(); |
14 | 14 | |
15 | - if ( ! $args ) { |
|
15 | + if (!$args) { |
|
16 | 16 | |
17 | 17 | return self::get_current_query(); |
18 | 18 | |
19 | - } elseif ( is_array( $args ) ) { |
|
19 | + } elseif (is_array($args)) { |
|
20 | 20 | |
21 | - $args = array_merge( $default_args, $args ); |
|
21 | + $args = array_merge($default_args, $args); |
|
22 | 22 | |
23 | - return new WP_Query( $args ); |
|
23 | + return new WP_Query($args); |
|
24 | 24 | |
25 | 25 | } else { |
26 | 26 | |
27 | - return new WP_Query( $default_args ); |
|
27 | + return new WP_Query($default_args); |
|
28 | 28 | |
29 | 29 | } |
30 | 30 | } |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | |
39 | 39 | global $wp_query; |
40 | 40 | |
41 | - $query =& $wp_query; |
|
41 | + $query = & $wp_query; |
|
42 | 42 | |
43 | - $query = self::handle_maybe_custom_posts_page( $query ); |
|
43 | + $query = self::handle_maybe_custom_posts_page($query); |
|
44 | 44 | |
45 | 45 | return $query; |
46 | 46 | |
@@ -52,13 +52,13 @@ discard block |
||
52 | 52 | * @param object $query WP_Query |
53 | 53 | * @return object WP_Query |
54 | 54 | */ |
55 | - private static function handle_maybe_custom_posts_page( $query ) { |
|
55 | + private static function handle_maybe_custom_posts_page($query) { |
|
56 | 56 | |
57 | - if ( $custom_posts_page = get_option( 'page_for_posts' ) ) { |
|
57 | + if ($custom_posts_page = get_option('page_for_posts')) { |
|
58 | 58 | |
59 | - if ( isset( $query->query['p'] ) && absint( $query->query['p'] ) === absint( $custom_posts_page ) ) { |
|
59 | + if (isset($query->query['p']) && absint($query->query['p']) === absint($custom_posts_page)) { |
|
60 | 60 | |
61 | - return new WP_Query( array( 'post_type' => 'post' ) ); |
|
61 | + return new WP_Query(array('post_type' => 'post')); |
|
62 | 62 | |
63 | 63 | } |
64 | 64 | } |
@@ -23,25 +23,25 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @param string $arg it can be menu id, slug or full name |
25 | 25 | */ |
26 | - public function __construct( $arg = null ) { |
|
26 | + public function __construct($arg = null) { |
|
27 | 27 | |
28 | - if ( is_numeric( $arg ) && 0 !== absint( $arg ) ) { |
|
28 | + if (is_numeric($arg) && 0 !== absint($arg)) { |
|
29 | 29 | |
30 | - $menu_id = $this->check_menu_id( $arg ); |
|
30 | + $menu_id = $this->check_menu_id($arg); |
|
31 | 31 | |
32 | - } elseif ( is_string( $arg ) ) { |
|
32 | + } elseif (is_string($arg)) { |
|
33 | 33 | |
34 | - $menu_id = $this->get_menu_id_by_name( $arg ); |
|
34 | + $menu_id = $this->get_menu_id_by_name($arg); |
|
35 | 35 | |
36 | 36 | } |
37 | 37 | |
38 | - if ( ! isset( $menu_id ) ) { |
|
38 | + if (!isset($menu_id)) { |
|
39 | 39 | |
40 | 40 | $menu_id = $this->get_first_menu_id(); |
41 | 41 | |
42 | 42 | } |
43 | 43 | |
44 | - if ( $menu_id ) { |
|
44 | + if ($menu_id) { |
|
45 | 45 | |
46 | 46 | $this->ID = $menu_id; |
47 | 47 | |
@@ -60,22 +60,22 @@ discard block |
||
60 | 60 | |
61 | 61 | $_return = array(); |
62 | 62 | |
63 | - $items = wp_get_nav_menu_items( $this->ID ); |
|
63 | + $items = wp_get_nav_menu_items($this->ID); |
|
64 | 64 | |
65 | - foreach ( $items as $item ) { |
|
65 | + foreach ($items as $item) { |
|
66 | 66 | |
67 | - $_return[ $item->ID ] = new ClassyMenuItem( $item ); |
|
67 | + $_return[$item->ID] = new ClassyMenuItem($item); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | // Apply nesting |
71 | 71 | |
72 | - foreach ( $_return as $item_id => $item ) { |
|
72 | + foreach ($_return as $item_id => $item) { |
|
73 | 73 | |
74 | - if ( isset( $item->menu_item_parent ) && $item->menu_item_parent && isset( $_return[ $item->menu_item_parent ] ) ) { |
|
74 | + if (isset($item->menu_item_parent) && $item->menu_item_parent && isset($_return[$item->menu_item_parent])) { |
|
75 | 75 | |
76 | - $_return[ $item->menu_item_parent ]->add_child( $item ); |
|
76 | + $_return[$item->menu_item_parent]->add_child($item); |
|
77 | 77 | |
78 | - unset( $_return[ $item_id ] ); |
|
78 | + unset($_return[$item_id]); |
|
79 | 79 | |
80 | 80 | } |
81 | 81 | } |
@@ -91,11 +91,11 @@ discard block |
||
91 | 91 | */ |
92 | 92 | protected function get_first_menu_id() { |
93 | 93 | |
94 | - $menus = get_terms( 'nav_menu', array( 'hide_empty' => true ) ); |
|
94 | + $menus = get_terms('nav_menu', array('hide_empty' => true)); |
|
95 | 95 | |
96 | - if ( is_array( $menus ) && count( $menus ) ) { |
|
96 | + if (is_array($menus) && count($menus)) { |
|
97 | 97 | |
98 | - if ( isset( $menus[0]->term_id ) ) { |
|
98 | + if (isset($menus[0]->term_id)) { |
|
99 | 99 | |
100 | 100 | return $menus[0]->term_id; |
101 | 101 | |
@@ -112,15 +112,15 @@ discard block |
||
112 | 112 | * @param int $menu_id |
113 | 113 | * @return int|boolean |
114 | 114 | */ |
115 | - protected function check_menu_id( $menu_id ) { |
|
115 | + protected function check_menu_id($menu_id) { |
|
116 | 116 | |
117 | - $menus = get_terms( 'nav_menu', array( 'hide_empty' => true ) ); |
|
117 | + $menus = get_terms('nav_menu', array('hide_empty' => true)); |
|
118 | 118 | |
119 | - if ( is_array( $menus ) && count( $menus ) ) { |
|
119 | + if (is_array($menus) && count($menus)) { |
|
120 | 120 | |
121 | - foreach ( $menus as $menu ) { |
|
121 | + foreach ($menus as $menu) { |
|
122 | 122 | |
123 | - if ( absint( $menu->term_id ) === absint( $menu_id ) ) { |
|
123 | + if (absint($menu->term_id) === absint($menu_id)) { |
|
124 | 124 | |
125 | 125 | return $menu_id; |
126 | 126 | |
@@ -138,17 +138,17 @@ discard block |
||
138 | 138 | * @param string $slug |
139 | 139 | * @return int |
140 | 140 | */ |
141 | - protected function get_menu_id_by_name( $slug = null ) { |
|
141 | + protected function get_menu_id_by_name($slug = null) { |
|
142 | 142 | |
143 | - if ( $slug && is_string( $slug ) ) { |
|
143 | + if ($slug && is_string($slug)) { |
|
144 | 144 | |
145 | - $menu_id = get_term_by( 'slug', $slug, 'nav_menu' ); |
|
145 | + $menu_id = get_term_by('slug', $slug, 'nav_menu'); |
|
146 | 146 | |
147 | - if ( $menu_id ) { return $menu_id; } |
|
147 | + if ($menu_id) { return $menu_id; } |
|
148 | 148 | |
149 | - $menu_id = get_term_by( 'name', $slug, 'nav_menu' ); |
|
149 | + $menu_id = get_term_by('name', $slug, 'nav_menu'); |
|
150 | 150 | |
151 | - if ( $menu_id ) { return $menu_id; } |
|
151 | + if ($menu_id) { return $menu_id; } |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | return false; |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @param WP_Comment $item |
82 | 82 | */ |
83 | - public function __construct( $item ) { |
|
83 | + public function __construct($item) { |
|
84 | 84 | |
85 | - if ( is_a( $item, 'WP_Comment' ) ) { |
|
85 | + if (is_a($item, 'WP_Comment')) { |
|
86 | 86 | |
87 | - $this->import( $item ); |
|
87 | + $this->import($item); |
|
88 | 88 | |
89 | 89 | } |
90 | 90 | |
@@ -97,15 +97,15 @@ discard block |
||
97 | 97 | */ |
98 | 98 | public function author() { |
99 | 99 | |
100 | - if ( $this->user_id ) { |
|
100 | + if ($this->user_id) { |
|
101 | 101 | |
102 | - return new ClassyUser( $this->user_id ); |
|
102 | + return new ClassyUser($this->user_id); |
|
103 | 103 | |
104 | 104 | } else { |
105 | 105 | |
106 | - $author = new ClassyUser( 0 ); |
|
106 | + $author = new ClassyUser(0); |
|
107 | 107 | |
108 | - if ( isset( $this->comment_author ) && $this->comment_author ) { |
|
108 | + if (isset($this->comment_author) && $this->comment_author) { |
|
109 | 109 | |
110 | 110 | $author->name = $this->comment_author; |
111 | 111 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | * @return string |
123 | 123 | */ |
124 | 124 | public function content() { |
125 | - return apply_filters( 'get_comment_text ', $this->comment_content ); |
|
125 | + return apply_filters('get_comment_text ', $this->comment_content); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -140,11 +140,11 @@ discard block |
||
140 | 140 | * @param string $date_format |
141 | 141 | * @return string |
142 | 142 | */ |
143 | - public function date( $date_format = '' ) { |
|
144 | - $df = $date_format ? $date_format : get_option( 'date_format' ); |
|
145 | - $the_date = (string) mysql2date( $df, $this->comment_date ); |
|
143 | + public function date($date_format = '') { |
|
144 | + $df = $date_format ? $date_format : get_option('date_format'); |
|
145 | + $the_date = (string) mysql2date($df, $this->comment_date); |
|
146 | 146 | |
147 | - return apply_filters( 'get_comment_date ', $the_date, $df ); |
|
147 | + return apply_filters('get_comment_date ', $the_date, $df); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -163,26 +163,26 @@ discard block |
||
163 | 163 | * @param string $default |
164 | 164 | * @return string |
165 | 165 | */ |
166 | - public function avatar( $size = 92, $default = '' ) { |
|
166 | + public function avatar($size = 92, $default = '') { |
|
167 | 167 | |
168 | - if ( ! get_option( 'show_avatars' ) ) { |
|
168 | + if (!get_option('show_avatars')) { |
|
169 | 169 | return false; |
170 | 170 | } |
171 | 171 | |
172 | - if ( ! is_numeric( $size ) ) { $size = '92'; } |
|
172 | + if (!is_numeric($size)) { $size = '92'; } |
|
173 | 173 | |
174 | 174 | $email = $this->get_avatar_email(); |
175 | 175 | $email_hash = ''; |
176 | 176 | |
177 | - if ( ! empty( $email ) ) { |
|
178 | - $email_hash = md5( strtolower( trim( $email ) ) ); |
|
177 | + if (!empty($email)) { |
|
178 | + $email_hash = md5(strtolower(trim($email))); |
|
179 | 179 | } |
180 | 180 | |
181 | - $host = $this->get_avatar_host( $email_hash ); |
|
182 | - $default = $this->get_default_avatar( $default, $email, $size, $host ); |
|
181 | + $host = $this->get_avatar_host($email_hash); |
|
182 | + $default = $this->get_default_avatar($default, $email, $size, $host); |
|
183 | 183 | |
184 | - if ( ! empty( $email ) ) { |
|
185 | - $avatar = $this->get_avatar_url( $default, $host, $email_hash, $size ); |
|
184 | + if (!empty($email)) { |
|
185 | + $avatar = $this->get_avatar_url($default, $host, $email_hash, $size); |
|
186 | 186 | } else { |
187 | 187 | $avatar = $default; |
188 | 188 | } |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | protected function get_avatar_email() { |
200 | 200 | |
201 | 201 | $id = (int) $this->user_id; |
202 | - $user = get_userdata( $id ); |
|
202 | + $user = get_userdata($id); |
|
203 | 203 | |
204 | - if ( $user ) { |
|
204 | + if ($user) { |
|
205 | 205 | $email = $user->user_email; |
206 | 206 | } else { |
207 | 207 | $email = $this->comment_author_email; |
@@ -220,32 +220,32 @@ discard block |
||
220 | 220 | * @param string $host |
221 | 221 | * @return string |
222 | 222 | */ |
223 | - protected function get_default_avatar( $default, $email, $size, $host ) { |
|
223 | + protected function get_default_avatar($default, $email, $size, $host) { |
|
224 | 224 | |
225 | - if ( '/' === substr( $default, 0, 1 ) ) { |
|
226 | - $default = home_url() . $default; |
|
225 | + if ('/' === substr($default, 0, 1)) { |
|
226 | + $default = home_url().$default; |
|
227 | 227 | } |
228 | 228 | |
229 | - if ( empty( $default ) ) { |
|
230 | - $avatar_default = get_option( 'avatar_default' ); |
|
231 | - if ( empty( $avatar_default ) ) { |
|
229 | + if (empty($default)) { |
|
230 | + $avatar_default = get_option('avatar_default'); |
|
231 | + if (empty($avatar_default)) { |
|
232 | 232 | $default = 'mystery'; |
233 | 233 | } else { |
234 | 234 | $default = $avatar_default; |
235 | 235 | } |
236 | 236 | } |
237 | 237 | |
238 | - if ( 'mystery' === $default ) { |
|
239 | - $default = $host . '/avatar/ad516503a11cd5ca435acc9bb6523536?s=' . $size; |
|
238 | + if ('mystery' === $default) { |
|
239 | + $default = $host.'/avatar/ad516503a11cd5ca435acc9bb6523536?s='.$size; |
|
240 | 240 | // ad516503a11cd5ca435acc9bb6523536 == md5('[email protected]') |
241 | - } else if ( 'blank' === $default ) { |
|
242 | - $default = $email ? 'blank' : includes_url( 'images/blank.gif' ); |
|
243 | - } else if ( ! empty( $email ) && 'gravatar_default' === $default ) { |
|
241 | + } else if ('blank' === $default) { |
|
242 | + $default = $email ? 'blank' : includes_url('images/blank.gif'); |
|
243 | + } else if (!empty($email) && 'gravatar_default' === $default) { |
|
244 | 244 | $default = ''; |
245 | - } else if ( 'gravatar_default' === $default ) { |
|
246 | - $default = $host . '/avatar/?s=' . $size; |
|
247 | - } else if ( empty( $email ) && ! strstr( $default, 'http://' ) ) { |
|
248 | - $default = $host . '/avatar/?d=' . $default . '&s=' . $size; |
|
245 | + } else if ('gravatar_default' === $default) { |
|
246 | + $default = $host.'/avatar/?s='.$size; |
|
247 | + } else if (empty($email) && !strstr($default, 'http://')) { |
|
248 | + $default = $host.'/avatar/?d='.$default.'&s='.$size; |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | return $default; |
@@ -258,13 +258,13 @@ discard block |
||
258 | 258 | * @param string $email_hash |
259 | 259 | * @return string |
260 | 260 | */ |
261 | - protected function get_avatar_host( $email_hash ) { |
|
261 | + protected function get_avatar_host($email_hash) { |
|
262 | 262 | |
263 | - if ( is_ssl() ) { |
|
263 | + if (is_ssl()) { |
|
264 | 264 | $host = 'https://secure.gravatar.com'; |
265 | 265 | } else { |
266 | - if ( ! empty( $email_hash ) ) { |
|
267 | - $host = sprintf( 'http://%d.gravatar.com', (hexdec( $email_hash[0] ) % 2) ); |
|
266 | + if (!empty($email_hash)) { |
|
267 | + $host = sprintf('http://%d.gravatar.com', (hexdec($email_hash[0]) % 2)); |
|
268 | 268 | } else { |
269 | 269 | $host = 'http://0.gravatar.com'; |
270 | 270 | } |
@@ -283,16 +283,16 @@ discard block |
||
283 | 283 | * @param int $size |
284 | 284 | * @return string |
285 | 285 | */ |
286 | - protected function get_avatar_url( $default, $host, $email_hash, $size ) { |
|
286 | + protected function get_avatar_url($default, $host, $email_hash, $size) { |
|
287 | 287 | |
288 | - $_return = $host . '/avatar/' . $email_hash . '?s=' . $size . '&d=' . urlencode( $default ); |
|
289 | - $rating = get_option( 'avatar_rating' ); |
|
288 | + $_return = $host.'/avatar/'.$email_hash.'?s='.$size.'&d='.urlencode($default); |
|
289 | + $rating = get_option('avatar_rating'); |
|
290 | 290 | |
291 | - if ( ! empty( $rating ) ) { |
|
292 | - $_return .= '&r=' . $rating; |
|
291 | + if (!empty($rating)) { |
|
292 | + $_return .= '&r='.$rating; |
|
293 | 293 | } |
294 | 294 | |
295 | - return str_replace( '&', '&', esc_url( $_return ) ); |
|
295 | + return str_replace('&', '&', esc_url($_return)); |
|
296 | 296 | |
297 | 297 | } |
298 | 298 | |
@@ -301,12 +301,12 @@ discard block |
||
301 | 301 | * |
302 | 302 | * @param ClassyComment $comment |
303 | 303 | */ |
304 | - public function add_child( $comment ) { |
|
304 | + public function add_child($comment) { |
|
305 | 305 | |
306 | 306 | $this->children[] = $comment; |
307 | 307 | $item->level = $this->level + 1; |
308 | 308 | |
309 | - if ( $item->children ) { |
|
309 | + if ($item->children) { |
|
310 | 310 | $this->update_child_levels(); |
311 | 311 | } |
312 | 312 | |
@@ -320,9 +320,9 @@ discard block |
||
320 | 320 | */ |
321 | 321 | protected function update_child_levels() { |
322 | 322 | |
323 | - if ( is_array( $this->children ) ) { |
|
323 | + if (is_array($this->children)) { |
|
324 | 324 | |
325 | - foreach ( $this->children as $child ) { |
|
325 | + foreach ($this->children as $child) { |
|
326 | 326 | $child->level = $this->level + 1; |
327 | 327 | $child->update_child_levels(); |
328 | 328 | } |
@@ -101,7 +101,8 @@ discard block |
||
101 | 101 | |
102 | 102 | return new ClassyUser( $this->user_id ); |
103 | 103 | |
104 | - } else { |
|
104 | + } |
|
105 | + else { |
|
105 | 106 | |
106 | 107 | $author = new ClassyUser( 0 ); |
107 | 108 | |
@@ -183,7 +184,8 @@ discard block |
||
183 | 184 | |
184 | 185 | if ( ! empty( $email ) ) { |
185 | 186 | $avatar = $this->get_avatar_url( $default, $host, $email_hash, $size ); |
186 | - } else { |
|
187 | + } |
|
188 | + else { |
|
187 | 189 | $avatar = $default; |
188 | 190 | } |
189 | 191 | |
@@ -203,7 +205,8 @@ discard block |
||
203 | 205 | |
204 | 206 | if ( $user ) { |
205 | 207 | $email = $user->user_email; |
206 | - } else { |
|
208 | + } |
|
209 | + else { |
|
207 | 210 | $email = $this->comment_author_email; |
208 | 211 | } |
209 | 212 | |
@@ -230,7 +233,8 @@ discard block |
||
230 | 233 | $avatar_default = get_option( 'avatar_default' ); |
231 | 234 | if ( empty( $avatar_default ) ) { |
232 | 235 | $default = 'mystery'; |
233 | - } else { |
|
236 | + } |
|
237 | + else { |
|
234 | 238 | $default = $avatar_default; |
235 | 239 | } |
236 | 240 | } |
@@ -238,13 +242,17 @@ discard block |
||
238 | 242 | if ( 'mystery' === $default ) { |
239 | 243 | $default = $host . '/avatar/ad516503a11cd5ca435acc9bb6523536?s=' . $size; |
240 | 244 | // ad516503a11cd5ca435acc9bb6523536 == md5('[email protected]') |
241 | - } else if ( 'blank' === $default ) { |
|
245 | + } |
|
246 | + else if ( 'blank' === $default ) { |
|
242 | 247 | $default = $email ? 'blank' : includes_url( 'images/blank.gif' ); |
243 | - } else if ( ! empty( $email ) && 'gravatar_default' === $default ) { |
|
248 | + } |
|
249 | + else if ( ! empty( $email ) && 'gravatar_default' === $default ) { |
|
244 | 250 | $default = ''; |
245 | - } else if ( 'gravatar_default' === $default ) { |
|
251 | + } |
|
252 | + else if ( 'gravatar_default' === $default ) { |
|
246 | 253 | $default = $host . '/avatar/?s=' . $size; |
247 | - } else if ( empty( $email ) && ! strstr( $default, 'http://' ) ) { |
|
254 | + } |
|
255 | + else if ( empty( $email ) && ! strstr( $default, 'http://' ) ) { |
|
248 | 256 | $default = $host . '/avatar/?d=' . $default . '&s=' . $size; |
249 | 257 | } |
250 | 258 | |
@@ -262,10 +270,12 @@ discard block |
||
262 | 270 | |
263 | 271 | if ( is_ssl() ) { |
264 | 272 | $host = 'https://secure.gravatar.com'; |
265 | - } else { |
|
273 | + } |
|
274 | + else { |
|
266 | 275 | if ( ! empty( $email_hash ) ) { |
267 | 276 | $host = sprintf( 'http://%d.gravatar.com', (hexdec( $email_hash[0] ) % 2) ); |
268 | - } else { |
|
277 | + } |
|
278 | + else { |
|
269 | 279 | $host = 'http://0.gravatar.com'; |
270 | 280 | } |
271 | 281 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | */ |
30 | 30 | public static function get_instance() { |
31 | 31 | |
32 | - if ( null === self::$single_instance ) { |
|
32 | + if (null === self::$single_instance) { |
|
33 | 33 | |
34 | 34 | self::$single_instance = new self(); |
35 | 35 | |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | |
57 | 57 | $this->init_config(); |
58 | 58 | |
59 | - add_filter( 'theme_page_templates', array( $this, 'filter_templates' ), 3 ); |
|
59 | + add_filter('theme_page_templates', array($this, 'filter_templates'), 3); |
|
60 | 60 | |
61 | 61 | } |
62 | 62 | |
@@ -66,11 +66,11 @@ discard block |
||
66 | 66 | * @param string |
67 | 67 | * @param string |
68 | 68 | */ |
69 | - private function define( $name, $value ) { |
|
69 | + private function define($name, $value) { |
|
70 | 70 | |
71 | - if ( ! defined( $name ) ) { |
|
71 | + if (!defined($name)) { |
|
72 | 72 | |
73 | - define( $name, $value ); |
|
73 | + define($name, $value); |
|
74 | 74 | |
75 | 75 | } |
76 | 76 | |
@@ -86,13 +86,13 @@ discard block |
||
86 | 86 | |
87 | 87 | $theme = wp_get_theme(); |
88 | 88 | |
89 | - $this->define( 'THEME', $theme->template ); |
|
90 | - $this->define( 'THEME_NAME', $theme->get( 'Name' ) ); |
|
91 | - $this->define( 'THEME_PATH', get_template_directory() . '/' ); |
|
92 | - $this->define( 'THEME_DIR', get_template_directory_uri() . '/' ); |
|
93 | - $this->define( 'THEME_VERSION', $theme->get( 'Version' ) ); |
|
94 | - $this->define( 'THEME_FRAMEWORK_PATH', THEME_PATH . 'app/' ); |
|
95 | - $this->define( 'THEME_FRAMEWORK_DIR', THEME_DIR . 'app/' ); |
|
89 | + $this->define('THEME', $theme->template); |
|
90 | + $this->define('THEME_NAME', $theme->get('Name')); |
|
91 | + $this->define('THEME_PATH', get_template_directory().'/'); |
|
92 | + $this->define('THEME_DIR', get_template_directory_uri().'/'); |
|
93 | + $this->define('THEME_VERSION', $theme->get('Version')); |
|
94 | + $this->define('THEME_FRAMEWORK_PATH', THEME_PATH.'app/'); |
|
95 | + $this->define('THEME_FRAMEWORK_DIR', THEME_DIR.'app/'); |
|
96 | 96 | |
97 | 97 | } |
98 | 98 | |
@@ -101,40 +101,40 @@ discard block |
||
101 | 101 | */ |
102 | 102 | private function include_core_files() { |
103 | 103 | |
104 | - require_once THEME_PATH . 'vendor/autoload.php'; |
|
104 | + require_once THEME_PATH.'vendor/autoload.php'; |
|
105 | 105 | |
106 | 106 | // Basis Class |
107 | - require_once THEME_FRAMEWORK_PATH . 'classy/classy-basis.php'; |
|
107 | + require_once THEME_FRAMEWORK_PATH.'classy/classy-basis.php'; |
|
108 | 108 | |
109 | 109 | // Hierarchy |
110 | - require_once THEME_FRAMEWORK_PATH . 'classy/classy-hierarchy.php'; |
|
110 | + require_once THEME_FRAMEWORK_PATH.'classy/classy-hierarchy.php'; |
|
111 | 111 | |
112 | 112 | // Theme Config |
113 | - require_once THEME_FRAMEWORK_PATH . 'classy/classy-config.php'; |
|
113 | + require_once THEME_FRAMEWORK_PATH.'classy/classy-config.php'; |
|
114 | 114 | |
115 | 115 | // Scope |
116 | - require_once THEME_FRAMEWORK_PATH . 'classy/classy-scope.php'; |
|
116 | + require_once THEME_FRAMEWORK_PATH.'classy/classy-scope.php'; |
|
117 | 117 | |
118 | 118 | // View Loader |
119 | - require_once THEME_FRAMEWORK_PATH . 'classy/classy-view.php'; |
|
119 | + require_once THEME_FRAMEWORK_PATH.'classy/classy-view.php'; |
|
120 | 120 | |
121 | 121 | // Helper functions |
122 | - require_once THEME_FRAMEWORK_PATH . 'classy/classy-helper.php'; |
|
122 | + require_once THEME_FRAMEWORK_PATH.'classy/classy-helper.php'; |
|
123 | 123 | |
124 | 124 | // Query Helper |
125 | - require_once THEME_FRAMEWORK_PATH . 'classy/classy-query-helper.php'; |
|
125 | + require_once THEME_FRAMEWORK_PATH.'classy/classy-query-helper.php'; |
|
126 | 126 | |
127 | 127 | // Menu |
128 | - require_once THEME_FRAMEWORK_PATH . 'classy/classy-menu.php'; |
|
128 | + require_once THEME_FRAMEWORK_PATH.'classy/classy-menu.php'; |
|
129 | 129 | |
130 | 130 | // Menu Item |
131 | - require_once THEME_FRAMEWORK_PATH . 'classy/classy-menu-item.php'; |
|
131 | + require_once THEME_FRAMEWORK_PATH.'classy/classy-menu-item.php'; |
|
132 | 132 | |
133 | 133 | // Comment |
134 | - require_once THEME_FRAMEWORK_PATH . 'classy/classy-comment.php'; |
|
134 | + require_once THEME_FRAMEWORK_PATH.'classy/classy-comment.php'; |
|
135 | 135 | |
136 | 136 | // Appearance |
137 | - require_once THEME_FRAMEWORK_PATH . 'appearance.php'; |
|
137 | + require_once THEME_FRAMEWORK_PATH.'appearance.php'; |
|
138 | 138 | |
139 | 139 | } |
140 | 140 | |
@@ -143,11 +143,11 @@ discard block |
||
143 | 143 | */ |
144 | 144 | private function include_models() { |
145 | 145 | |
146 | - $files = (array) glob( THEME_FRAMEWORK_PATH . '/models/*.php' ); |
|
146 | + $files = (array) glob(THEME_FRAMEWORK_PATH.'/models/*.php'); |
|
147 | 147 | |
148 | - foreach ( $files as $filename ) { |
|
148 | + foreach ($files as $filename) { |
|
149 | 149 | |
150 | - if ( ! empty( $filename ) ) { |
|
150 | + if (!empty($filename)) { |
|
151 | 151 | |
152 | 152 | require_once $filename; |
153 | 153 | |
@@ -171,11 +171,11 @@ discard block |
||
171 | 171 | * @return array |
172 | 172 | */ |
173 | 173 | |
174 | - public function filter_templates( $page_templates = array(), $object = null, $post = null ) { |
|
174 | + public function filter_templates($page_templates = array(), $object = null, $post = null) { |
|
175 | 175 | |
176 | 176 | $custom_templates = ClassyView::get_page_templates_list(); |
177 | 177 | |
178 | - return array_merge( $page_templates, $custom_templates ); |
|
178 | + return array_merge($page_templates, $custom_templates); |
|
179 | 179 | |
180 | 180 | } |
181 | 181 | |
@@ -185,11 +185,11 @@ discard block |
||
185 | 185 | * @param string $name |
186 | 186 | * @return any |
187 | 187 | */ |
188 | - public static function get_config_var( $name ) { |
|
188 | + public static function get_config_var($name) { |
|
189 | 189 | |
190 | 190 | $vars = ClassyConfig::get_vars(); |
191 | 191 | |
192 | - if ( isset( $vars[ $name ] ) ) { return $vars[ $name ]; } |
|
192 | + if (isset($vars[$name])) { return $vars[$name]; } |
|
193 | 193 | |
194 | 194 | return false; |
195 | 195 | |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | */ |
203 | 203 | public static function textdomain() { |
204 | 204 | |
205 | - $textdomain = Classy::get_config_var( 'textdomain' ); |
|
205 | + $textdomain = Classy::get_config_var('textdomain'); |
|
206 | 206 | |
207 | 207 | return $textdomain ? $textdomain : THEME; |
208 | 208 | |
@@ -217,17 +217,17 @@ discard block |
||
217 | 217 | * @param array|null $data Additional params |
218 | 218 | * @return void |
219 | 219 | */ |
220 | - public static function render( $view = null, $data = null ) { |
|
220 | + public static function render($view = null, $data = null) { |
|
221 | 221 | |
222 | - $views = THEME_PATH . ClassyView::$folder; |
|
223 | - $cache = WP_CONTENT_DIR . '/viewcache'; |
|
222 | + $views = THEME_PATH.ClassyView::$folder; |
|
223 | + $cache = WP_CONTENT_DIR.'/viewcache'; |
|
224 | 224 | $common_scope = ClassyScope::get_common_scope(); |
225 | 225 | |
226 | - if ( null !== $view && is_string( $view ) ) { |
|
226 | + if (null !== $view && is_string($view)) { |
|
227 | 227 | |
228 | - if ( $data && is_array( $data ) ) { |
|
228 | + if ($data && is_array($data)) { |
|
229 | 229 | |
230 | - $scope = array_merge( $common_scope, $data ); |
|
230 | + $scope = array_merge($common_scope, $data); |
|
231 | 231 | |
232 | 232 | } else { |
233 | 233 | |
@@ -242,9 +242,9 @@ discard block |
||
242 | 242 | |
243 | 243 | } |
244 | 244 | |
245 | - $renderer = new BladeRenderer( $views, array( 'cache_path' => $cache ) ); |
|
245 | + $renderer = new BladeRenderer($views, array('cache_path' => $cache)); |
|
246 | 246 | |
247 | - echo $renderer->render( $view, $scope ); // XSS: xss ok. |
|
247 | + echo $renderer->render($view, $scope); // XSS: xss ok. |
|
248 | 248 | |
249 | 249 | } |
250 | 250 | |
@@ -269,27 +269,27 @@ discard block |
||
269 | 269 | * @param string $return object/id/ClassyPost |
270 | 270 | * @return mixed |
271 | 271 | */ |
272 | - public static function get_posts( $args = false, $return = 'ClassyPost' ) { |
|
272 | + public static function get_posts($args = false, $return = 'ClassyPost') { |
|
273 | 273 | |
274 | 274 | $_return = array(); |
275 | 275 | |
276 | - $query = ClassyQueryHelper::find_query( $args ); |
|
276 | + $query = ClassyQueryHelper::find_query($args); |
|
277 | 277 | |
278 | - if ( isset( $query->posts ) ) { |
|
278 | + if (isset($query->posts)) { |
|
279 | 279 | |
280 | - foreach ( $query->posts as $post ) { |
|
280 | + foreach ($query->posts as $post) { |
|
281 | 281 | |
282 | - if ( 'id' === $return ) { |
|
282 | + if ('id' === $return) { |
|
283 | 283 | |
284 | 284 | $_return[] = $post->id; |
285 | 285 | |
286 | - } elseif ( 'object' === $return ) { |
|
286 | + } elseif ('object' === $return) { |
|
287 | 287 | |
288 | 288 | $_return[] = $post; |
289 | 289 | |
290 | - } elseif ( class_exists( $return ) ) { |
|
290 | + } elseif (class_exists($return)) { |
|
291 | 291 | |
292 | - $_return[] = new $return( $post ); |
|
292 | + $_return[] = new $return($post); |
|
293 | 293 | |
294 | 294 | } |
295 | 295 | } |
@@ -306,11 +306,11 @@ discard block |
||
306 | 306 | * @param string $return_type ClassyPost/object/id |
307 | 307 | * @return mixed |
308 | 308 | */ |
309 | - public static function get_post( $args = false, $return_type = 'ClassyPost' ) { |
|
309 | + public static function get_post($args = false, $return_type = 'ClassyPost') { |
|
310 | 310 | |
311 | - $posts = self::get_posts( $args, $return_type ); |
|
311 | + $posts = self::get_posts($args, $return_type); |
|
312 | 312 | |
313 | - if ( $post = reset( $posts ) ) { |
|
313 | + if ($post = reset($posts)) { |
|
314 | 314 | return $post; |
315 | 315 | } |
316 | 316 | |
@@ -320,62 +320,62 @@ discard block |
||
320 | 320 | * @param array $prefs |
321 | 321 | * @return array mixed |
322 | 322 | */ |
323 | - public static function get_pagination( $prefs = array() ) { |
|
323 | + public static function get_pagination($prefs = array()) { |
|
324 | 324 | |
325 | 325 | global $wp_query; |
326 | 326 | global $paged; |
327 | 327 | global $wp_rewrite; |
328 | 328 | |
329 | 329 | $args = array(); |
330 | - $args['total'] = ceil( $wp_query->found_posts / $wp_query->query_vars['posts_per_page'] ); |
|
330 | + $args['total'] = ceil($wp_query->found_posts / $wp_query->query_vars['posts_per_page']); |
|
331 | 331 | |
332 | - if ( $wp_rewrite->using_permalinks() ) { |
|
332 | + if ($wp_rewrite->using_permalinks()) { |
|
333 | 333 | |
334 | - $url = explode( '?', get_pagenum_link( 0 ) ); |
|
334 | + $url = explode('?', get_pagenum_link(0)); |
|
335 | 335 | |
336 | - if ( isset( $url[1] ) ) { |
|
337 | - parse_str( $url[1], $query ); |
|
336 | + if (isset($url[1])) { |
|
337 | + parse_str($url[1], $query); |
|
338 | 338 | $args['add_args'] = $query; |
339 | 339 | } |
340 | 340 | |
341 | 341 | $args['format'] = 'page/%#%'; |
342 | - $args['base'] = trailingslashit( $url[0] ).'%_%'; |
|
342 | + $args['base'] = trailingslashit($url[0]).'%_%'; |
|
343 | 343 | |
344 | 344 | } else { |
345 | 345 | $big = 999999999; |
346 | - $args['base'] = str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ); |
|
346 | + $args['base'] = str_replace($big, '%#%', esc_url(get_pagenum_link($big))); |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | $args['type'] = 'array'; |
350 | - $args['current'] = max( 1, get_query_var( 'paged' ) ); |
|
351 | - $args['mid_size'] = max( 9 - $args['current'], 3 ); |
|
350 | + $args['current'] = max(1, get_query_var('paged')); |
|
351 | + $args['mid_size'] = max(9 - $args['current'], 3); |
|
352 | 352 | $args['prev_next'] = false; |
353 | 353 | |
354 | - if ( is_int( $prefs ) ) { |
|
354 | + if (is_int($prefs)) { |
|
355 | 355 | $args['mid_size'] = $prefs - 2; |
356 | 356 | } else { |
357 | - $args = array_merge( $args, $prefs ); |
|
357 | + $args = array_merge($args, $prefs); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | $data = array(); |
361 | - $data['pages'] = ClassyHelper::paginate_links( $args ); |
|
362 | - $next = get_next_posts_page_link( $args['total'] ); |
|
361 | + $data['pages'] = ClassyHelper::paginate_links($args); |
|
362 | + $next = get_next_posts_page_link($args['total']); |
|
363 | 363 | |
364 | - if ( $next ) { |
|
365 | - $data['next'] = array( 'link' => untrailingslashit( $next ), 'class' => 'page-numbers next' ); |
|
364 | + if ($next) { |
|
365 | + $data['next'] = array('link' => untrailingslashit($next), 'class' => 'page-numbers next'); |
|
366 | 366 | } |
367 | 367 | |
368 | - $prev = previous_posts( false ); |
|
368 | + $prev = previous_posts(false); |
|
369 | 369 | |
370 | - if ( $prev ) { |
|
371 | - $data['prev'] = array( 'link' => untrailingslashit( $prev ), 'class' => 'page-numbers prev' ); |
|
370 | + if ($prev) { |
|
371 | + $data['prev'] = array('link' => untrailingslashit($prev), 'class' => 'page-numbers prev'); |
|
372 | 372 | } |
373 | 373 | |
374 | - if ( $paged < 2 ) { |
|
374 | + if ($paged < 2) { |
|
375 | 375 | $data['prev'] = null; |
376 | 376 | } |
377 | 377 | |
378 | - return ClassyHelper::array_to_object( $data ); |
|
378 | + return ClassyHelper::array_to_object($data); |
|
379 | 379 | |
380 | 380 | } |
381 | 381 | } |
@@ -229,12 +229,14 @@ discard block |
||
229 | 229 | |
230 | 230 | $scope = array_merge( $common_scope, $data ); |
231 | 231 | |
232 | - } else { |
|
232 | + } |
|
233 | + else { |
|
233 | 234 | |
234 | 235 | $scope = $common_scope; |
235 | 236 | |
236 | 237 | } |
237 | - } else { |
|
238 | + } |
|
239 | + else { |
|
238 | 240 | |
239 | 241 | $view = ClassyView::get_view(); |
240 | 242 | |
@@ -283,11 +285,13 @@ discard block |
||
283 | 285 | |
284 | 286 | $_return[] = $post->id; |
285 | 287 | |
286 | - } elseif ( 'object' === $return ) { |
|
288 | + } |
|
289 | + elseif ( 'object' === $return ) { |
|
287 | 290 | |
288 | 291 | $_return[] = $post; |
289 | 292 | |
290 | - } elseif ( class_exists( $return ) ) { |
|
293 | + } |
|
294 | + elseif ( class_exists( $return ) ) { |
|
291 | 295 | |
292 | 296 | $_return[] = new $return( $post ); |
293 | 297 | |
@@ -341,7 +345,8 @@ discard block |
||
341 | 345 | $args['format'] = 'page/%#%'; |
342 | 346 | $args['base'] = trailingslashit( $url[0] ).'%_%'; |
343 | 347 | |
344 | - } else { |
|
348 | + } |
|
349 | + else { |
|
345 | 350 | $big = 999999999; |
346 | 351 | $args['base'] = str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ); |
347 | 352 | } |
@@ -353,7 +358,8 @@ discard block |
||
353 | 358 | |
354 | 359 | if ( is_int( $prefs ) ) { |
355 | 360 | $args['mid_size'] = $prefs - 2; |
356 | - } else { |
|
361 | + } |
|
362 | + else { |
|
357 | 363 | $args = array_merge( $args, $prefs ); |
358 | 364 | } |
359 | 365 |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | */ |
17 | 17 | private static function get_allowed_variables() { |
18 | 18 | |
19 | - return array( 'environment', 'textdomain', 'post_types', 'taxonomies', 'post_formats', 'sidebars' ); |
|
19 | + return array('environment', 'textdomain', 'post_types', 'taxonomies', 'post_formats', 'sidebars'); |
|
20 | 20 | |
21 | 21 | } |
22 | 22 | |
@@ -27,33 +27,33 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public static function get_vars() { |
29 | 29 | |
30 | - if ( null === self::$vars ) { |
|
30 | + if (null === self::$vars) { |
|
31 | 31 | |
32 | 32 | // Check for a theme config |
33 | - $config_file = THEME_FRAMEWORK_PATH . 'config.php'; |
|
33 | + $config_file = THEME_FRAMEWORK_PATH.'config.php'; |
|
34 | 34 | |
35 | - if ( file_exists( $config_file ) ) { |
|
35 | + if (file_exists($config_file)) { |
|
36 | 36 | |
37 | - require_once THEME_FRAMEWORK_PATH . 'config.php'; |
|
37 | + require_once THEME_FRAMEWORK_PATH.'config.php'; |
|
38 | 38 | |
39 | 39 | $vars = self::get_allowed_variables(); |
40 | 40 | |
41 | - foreach ( $vars as $var ) { |
|
41 | + foreach ($vars as $var) { |
|
42 | 42 | |
43 | - if ( isset( $$var ) ) { |
|
43 | + if (isset($$var)) { |
|
44 | 44 | |
45 | - self::$vars[ $var ] = $$var; |
|
45 | + self::$vars[$var] = $$var; |
|
46 | 46 | |
47 | - unset( $$var ); // We don't require it anymore |
|
47 | + unset($$var); // We don't require it anymore |
|
48 | 48 | |
49 | 49 | } |
50 | 50 | } |
51 | 51 | } else { |
52 | 52 | |
53 | - wp_die( sprintf( |
|
53 | + wp_die(sprintf( |
|
54 | 54 | 'There is no config file in %s custom/config.php', |
55 | - esc_html( THEME ) |
|
56 | - ) ); |
|
55 | + esc_html(THEME) |
|
56 | + )); |
|
57 | 57 | |
58 | 58 | } |
59 | 59 | } |
@@ -72,16 +72,16 @@ discard block |
||
72 | 72 | $vars = self::get_vars(); |
73 | 73 | |
74 | 74 | // Init Post Types |
75 | - if ( isset( $vars['post_types'] ) ) { self::init_post_types( $vars['post_types'] ); } |
|
75 | + if (isset($vars['post_types'])) { self::init_post_types($vars['post_types']); } |
|
76 | 76 | |
77 | 77 | // Init Taxonomies |
78 | - if ( isset( $vars['taxonomies'] ) ) { self::init_taxonomies( $vars['taxonomies'] ); } |
|
78 | + if (isset($vars['taxonomies'])) { self::init_taxonomies($vars['taxonomies']); } |
|
79 | 79 | |
80 | 80 | // Init Post Formats |
81 | - if ( isset( $vars['post_formats'] ) ) { self::init_post_formats( $vars['post_formats'] ); } |
|
81 | + if (isset($vars['post_formats'])) { self::init_post_formats($vars['post_formats']); } |
|
82 | 82 | |
83 | 83 | // Init Sidebars |
84 | - if ( isset( $vars['sidebars'] ) ) { self::init_sidebars( $vars['sidebars'] ); } |
|
84 | + if (isset($vars['sidebars'])) { self::init_sidebars($vars['sidebars']); } |
|
85 | 85 | |
86 | 86 | } |
87 | 87 | |
@@ -92,13 +92,13 @@ discard block |
||
92 | 92 | * |
93 | 93 | * @param array $post_types |
94 | 94 | */ |
95 | - private static function init_post_types( $post_types ) { |
|
95 | + private static function init_post_types($post_types) { |
|
96 | 96 | |
97 | - if ( is_array( $post_types ) ) { |
|
97 | + if (is_array($post_types)) { |
|
98 | 98 | |
99 | - foreach ( $post_types as $type => $options ) { |
|
99 | + foreach ($post_types as $type => $options) { |
|
100 | 100 | |
101 | - self::add_post_type( $type, $options['config'], $options['singular'], $options['multiple'] ); |
|
101 | + self::add_post_type($type, $options['config'], $options['singular'], $options['multiple']); |
|
102 | 102 | |
103 | 103 | } |
104 | 104 | } |
@@ -114,28 +114,28 @@ discard block |
||
114 | 114 | * @param string $singular |
115 | 115 | * @param string $multiple |
116 | 116 | */ |
117 | - private static function add_post_type( $name, $config, $singular = 'Entry', $multiple = 'Entries' ) { |
|
117 | + private static function add_post_type($name, $config, $singular = 'Entry', $multiple = 'Entries') { |
|
118 | 118 | |
119 | 119 | $domain = Classy::textdomain(); |
120 | 120 | |
121 | - if ( ! isset( $config['labels'] ) ) { |
|
121 | + if (!isset($config['labels'])) { |
|
122 | 122 | |
123 | 123 | $config['labels'] = array( |
124 | - 'name' => __( $multiple, $domain ), |
|
125 | - 'singular_name' => __( $singular, $domain ), |
|
126 | - 'not_found' => __( 'No ' . $multiple . ' Found', $domain ), |
|
127 | - 'not_found_in_trash' => __( 'No ' . $multiple . ' found in Trash', $domain ), |
|
128 | - 'edit_item' => __( 'Edit ', $singular, $domain ), |
|
129 | - 'search_items' => __( 'Search ' . $multiple, $domain ), |
|
130 | - 'view_item' => __( 'View ', $singular, $domain ), |
|
131 | - 'new_item' => __( 'New ' . $singular, $domain ), |
|
132 | - 'add_new' => __( 'Add New', $domain ), |
|
133 | - 'add_new_item' => __( 'Add New ' . $singular, $domain ), |
|
124 | + 'name' => __($multiple, $domain), |
|
125 | + 'singular_name' => __($singular, $domain), |
|
126 | + 'not_found' => __('No '.$multiple.' Found', $domain), |
|
127 | + 'not_found_in_trash' => __('No '.$multiple.' found in Trash', $domain), |
|
128 | + 'edit_item' => __('Edit ', $singular, $domain), |
|
129 | + 'search_items' => __('Search '.$multiple, $domain), |
|
130 | + 'view_item' => __('View ', $singular, $domain), |
|
131 | + 'new_item' => __('New '.$singular, $domain), |
|
132 | + 'add_new' => __('Add New', $domain), |
|
133 | + 'add_new_item' => __('Add New '.$singular, $domain), |
|
134 | 134 | ); |
135 | 135 | |
136 | 136 | } |
137 | 137 | |
138 | - register_post_type( $name, $config ); |
|
138 | + register_post_type($name, $config); |
|
139 | 139 | |
140 | 140 | } |
141 | 141 | |
@@ -144,13 +144,13 @@ discard block |
||
144 | 144 | * |
145 | 145 | * @param array $taxonomies |
146 | 146 | */ |
147 | - private static function init_taxonomies( $taxonomies ) { |
|
147 | + private static function init_taxonomies($taxonomies) { |
|
148 | 148 | |
149 | - if ( is_array( $taxonomies ) ) { |
|
149 | + if (is_array($taxonomies)) { |
|
150 | 150 | |
151 | - foreach ( $taxonomies as $type => $options ) { |
|
151 | + foreach ($taxonomies as $type => $options) { |
|
152 | 152 | |
153 | - self::add_taxonomy( $type, $options['for'], $options['config'], $options['singular'], $options['multiple'] ); |
|
153 | + self::add_taxonomy($type, $options['for'], $options['config'], $options['singular'], $options['multiple']); |
|
154 | 154 | |
155 | 155 | } |
156 | 156 | } |
@@ -166,29 +166,29 @@ discard block |
||
166 | 166 | * @param string $singular |
167 | 167 | * @param string $multiple |
168 | 168 | */ |
169 | - private static function add_taxonomy( $name, $object_type, $config, $singular = 'Entry', $multiple = 'Entries' ) { |
|
169 | + private static function add_taxonomy($name, $object_type, $config, $singular = 'Entry', $multiple = 'Entries') { |
|
170 | 170 | |
171 | 171 | $domain = Classy::textdomain(); |
172 | 172 | |
173 | - if ( ! isset( $config['labels'] ) ) { |
|
173 | + if (!isset($config['labels'])) { |
|
174 | 174 | |
175 | 175 | $config['labels'] = array( |
176 | - 'name' => __( $multiple, $domain ), |
|
177 | - 'singular_name' => __( $singular, $domain ), |
|
178 | - 'search_items' => __( 'Search ' . $multiple, $domain ), |
|
179 | - 'all_items' => __( 'All ' . $multiple, $domain ), |
|
180 | - 'parent_item' => __( 'Parent ' . $singular, $domain ), |
|
181 | - 'parent_item_colon' => __( 'Parent ' . $singular . ':', $domain ), |
|
182 | - 'edit_item' => __( 'Edit ' . $singular, $domain ), |
|
183 | - 'update_item' => __( 'Update ' . $singular, $domain ), |
|
184 | - 'add_new_item' => __( 'Add New ' . $singular, $domain ), |
|
185 | - 'new_item_name' => __( 'New ' . $singular . ' Name', $domain ), |
|
186 | - 'menu_name' => __( $singular, $domain ), |
|
176 | + 'name' => __($multiple, $domain), |
|
177 | + 'singular_name' => __($singular, $domain), |
|
178 | + 'search_items' => __('Search '.$multiple, $domain), |
|
179 | + 'all_items' => __('All '.$multiple, $domain), |
|
180 | + 'parent_item' => __('Parent '.$singular, $domain), |
|
181 | + 'parent_item_colon' => __('Parent '.$singular.':', $domain), |
|
182 | + 'edit_item' => __('Edit '.$singular, $domain), |
|
183 | + 'update_item' => __('Update '.$singular, $domain), |
|
184 | + 'add_new_item' => __('Add New '.$singular, $domain), |
|
185 | + 'new_item_name' => __('New '.$singular.' Name', $domain), |
|
186 | + 'menu_name' => __($singular, $domain), |
|
187 | 187 | ); |
188 | 188 | |
189 | 189 | } |
190 | 190 | |
191 | - register_taxonomy( $name, $object_type, $config ); |
|
191 | + register_taxonomy($name, $object_type, $config); |
|
192 | 192 | |
193 | 193 | } |
194 | 194 | |
@@ -197,11 +197,11 @@ discard block |
||
197 | 197 | * |
198 | 198 | * @param array $post_formats |
199 | 199 | */ |
200 | - private static function init_post_formats( $post_formats ) { |
|
200 | + private static function init_post_formats($post_formats) { |
|
201 | 201 | |
202 | - if ( is_array( $post_formats ) ) { |
|
202 | + if (is_array($post_formats)) { |
|
203 | 203 | |
204 | - add_theme_support( 'post-formats', $post_formats ); |
|
204 | + add_theme_support('post-formats', $post_formats); |
|
205 | 205 | |
206 | 206 | } |
207 | 207 | |
@@ -212,19 +212,19 @@ discard block |
||
212 | 212 | * |
213 | 213 | * @param array $sidebars |
214 | 214 | */ |
215 | - private static function init_sidebars( $sidebars ) { |
|
215 | + private static function init_sidebars($sidebars) { |
|
216 | 216 | |
217 | 217 | $domain = Classy::textdomain(); |
218 | 218 | |
219 | - if ( is_array( $sidebars ) ) { |
|
219 | + if (is_array($sidebars)) { |
|
220 | 220 | |
221 | - foreach ( $sidebars as $id => $title ) { |
|
221 | + foreach ($sidebars as $id => $title) { |
|
222 | 222 | |
223 | 223 | register_sidebar( |
224 | 224 | array( |
225 | 225 | 'id' => $id, |
226 | - 'name' => __( $title, $domain ), |
|
227 | - 'description' => __( $title, $domain ), |
|
226 | + 'name' => __($title, $domain), |
|
227 | + 'description' => __($title, $domain), |
|
228 | 228 | 'before_widget' => '<div id="%1$s" class="widget %2$s"><div class="widget-inner">', |
229 | 229 | 'after_widget' => '</div></div>', |
230 | 230 | 'before_title' => '<h3>', |
@@ -15,44 +15,44 @@ discard block |
||
15 | 15 | * @param string $allowed_tags |
16 | 16 | * @return string |
17 | 17 | */ |
18 | - public static function trim_words( $text, $num_words = 55, $more = null, $allowed_tags = 'p a span b i br blockquote' ) { |
|
19 | - if ( null === $more ) { |
|
20 | - $more = __( '…' ); |
|
18 | + public static function trim_words($text, $num_words = 55, $more = null, $allowed_tags = 'p a span b i br blockquote') { |
|
19 | + if (null === $more) { |
|
20 | + $more = __('…'); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | $original_text = $text; |
24 | 24 | $allowed_tag_string = ''; |
25 | 25 | |
26 | - foreach ( explode( ' ', $allowed_tags ) as $tag ) { |
|
27 | - $allowed_tag_string .= '<' . $tag . '>'; |
|
26 | + foreach (explode(' ', $allowed_tags) as $tag) { |
|
27 | + $allowed_tag_string .= '<'.$tag.'>'; |
|
28 | 28 | } |
29 | 29 | |
30 | - $text = strip_tags( $text, $allowed_tag_string ); |
|
30 | + $text = strip_tags($text, $allowed_tag_string); |
|
31 | 31 | |
32 | 32 | /* translators: If your word count is based on single characters (East Asian characters), |
33 | 33 | enter 'characters'. Otherwise, enter 'words'. Do not translate into your own language. */ |
34 | 34 | |
35 | - if ( 'characters' === _x( 'words', 'word count: words or characters?' ) && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) { |
|
36 | - $text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $text ), ' ' ); |
|
37 | - preg_match_all( '/./u', $text, $words_array ); |
|
38 | - $words_array = array_slice( $words_array[0], 0, $num_words + 1 ); |
|
35 | + if ('characters' === _x('words', 'word count: words or characters?') && preg_match('/^utf\-?8$/i', get_option('blog_charset'))) { |
|
36 | + $text = trim(preg_replace("/[\n\r\t ]+/", ' ', $text), ' '); |
|
37 | + preg_match_all('/./u', $text, $words_array); |
|
38 | + $words_array = array_slice($words_array[0], 0, $num_words + 1); |
|
39 | 39 | $sep = ''; |
40 | 40 | } else { |
41 | - $words_array = preg_split( "/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY ); |
|
41 | + $words_array = preg_split("/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY); |
|
42 | 42 | $sep = ' '; |
43 | 43 | } |
44 | 44 | |
45 | - if ( count( $words_array ) > $num_words ) { |
|
46 | - array_pop( $words_array ); |
|
47 | - $text = implode( $sep, $words_array ); |
|
48 | - $text = $text . $more; |
|
45 | + if (count($words_array) > $num_words) { |
|
46 | + array_pop($words_array); |
|
47 | + $text = implode($sep, $words_array); |
|
48 | + $text = $text.$more; |
|
49 | 49 | } else { |
50 | - $text = implode( $sep, $words_array ); |
|
50 | + $text = implode($sep, $words_array); |
|
51 | 51 | } |
52 | 52 | |
53 | - $text = self::close_tags( $text ); |
|
53 | + $text = self::close_tags($text); |
|
54 | 54 | |
55 | - return apply_filters( 'wp_trim_words', $text, $num_words, $more, $original_text ); |
|
55 | + return apply_filters('wp_trim_words', $text, $num_words, $more, $original_text); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | |
@@ -62,36 +62,36 @@ discard block |
||
62 | 62 | * @param string $html |
63 | 63 | * @return string |
64 | 64 | */ |
65 | - public static function close_tags( $html ) { |
|
65 | + public static function close_tags($html) { |
|
66 | 66 | //put all opened tags into an array |
67 | - preg_match_all( '#<([a-z]+)(?: .*)?(?<![/|/ ])>#iU', $html, $result ); |
|
67 | + preg_match_all('#<([a-z]+)(?: .*)?(?<![/|/ ])>#iU', $html, $result); |
|
68 | 68 | |
69 | 69 | $openedtags = $result[1]; |
70 | 70 | |
71 | 71 | //put all closed tags into an array |
72 | - preg_match_all( '#</([a-z]+)>#iU', $html, $result ); |
|
72 | + preg_match_all('#</([a-z]+)>#iU', $html, $result); |
|
73 | 73 | |
74 | 74 | $closedtags = $result[1]; |
75 | - $len_opened = count( $openedtags ); |
|
75 | + $len_opened = count($openedtags); |
|
76 | 76 | |
77 | 77 | // all tags are closed |
78 | - if ( count( $closedtags ) === $len_opened ) { |
|
78 | + if (count($closedtags) === $len_opened) { |
|
79 | 79 | return $html; |
80 | 80 | } |
81 | 81 | |
82 | - $openedtags = array_reverse( $openedtags ); |
|
82 | + $openedtags = array_reverse($openedtags); |
|
83 | 83 | |
84 | 84 | // close tags |
85 | - for ( $i = 0; $i < $len_opened; $i++ ) { |
|
86 | - if ( ! in_array( $openedtags[ $i ], $closedtags, true ) ) { |
|
87 | - $html .= '</' . $openedtags[ $i ] . '>'; |
|
85 | + for ($i = 0; $i < $len_opened; $i++) { |
|
86 | + if (!in_array($openedtags[$i], $closedtags, true)) { |
|
87 | + $html .= '</'.$openedtags[$i].'>'; |
|
88 | 88 | } else { |
89 | - unset( $closedtags[ array_search( $openedtags[ $i ], $closedtags ) ] ); |
|
89 | + unset($closedtags[array_search($openedtags[$i], $closedtags)]); |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | |
93 | - $html = str_replace( array( '</br>', '</hr>', '</wbr>' ), '', $html ); |
|
94 | - $html = str_replace( array( '<br>', '<hr>', '<wbr>' ), array( '<br />', '<hr />', '<wbr />' ), $html ); |
|
93 | + $html = str_replace(array('</br>', '</hr>', '</wbr>'), '', $html); |
|
94 | + $html = str_replace(array('<br>', '<hr>', '<wbr>'), array('<br />', '<hr />', '<wbr />'), $html); |
|
95 | 95 | |
96 | 96 | return $html; |
97 | 97 | } |
@@ -103,14 +103,14 @@ discard block |
||
103 | 103 | * |
104 | 104 | * @return bool |
105 | 105 | */ |
106 | - public static function error_log( $arg ) { |
|
107 | - if ( ! WP_DEBUG ) { |
|
106 | + public static function error_log($arg) { |
|
107 | + if (!WP_DEBUG) { |
|
108 | 108 | return true; |
109 | 109 | } |
110 | - if ( is_object( $arg ) || is_array( $arg ) ) { |
|
111 | - $arg = print_r( $arg, true ); |
|
110 | + if (is_object($arg) || is_array($arg)) { |
|
111 | + $arg = print_r($arg, true); |
|
112 | 112 | } |
113 | - return error_log( $arg ); |
|
113 | + return error_log($arg); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * @param string $args |
120 | 120 | * @return array |
121 | 121 | */ |
122 | - public static function paginate_links( $args = '' ) { |
|
122 | + public static function paginate_links($args = '') { |
|
123 | 123 | $defaults = array( |
124 | 124 | 'base' => '%_%', // http://example.com/all_posts.php%_% : %_% is replaced by format (below) |
125 | 125 | 'format' => '?page=%#%', // ?page=%#% : %#% is replaced by the page number |
@@ -127,43 +127,43 @@ discard block |
||
127 | 127 | 'current' => 0, |
128 | 128 | 'show_all' => false, |
129 | 129 | 'prev_next' => true, |
130 | - 'prev_text' => __( '« Previous' ), |
|
131 | - 'next_text' => __( 'Next »' ), |
|
130 | + 'prev_text' => __('« Previous'), |
|
131 | + 'next_text' => __('Next »'), |
|
132 | 132 | 'end_size' => 1, |
133 | 133 | 'mid_size' => 2, |
134 | 134 | 'type' => 'array', |
135 | 135 | 'add_args' => false, // array of query args to add |
136 | 136 | 'add_fragment' => '', |
137 | 137 | ); |
138 | - $args = wp_parse_args( $args, $defaults ); |
|
138 | + $args = wp_parse_args($args, $defaults); |
|
139 | 139 | // Who knows what else people pass in $args |
140 | - $args['total'] = intval( (int) $args['total'] ); |
|
141 | - if ( $args['total'] < 2 ) { |
|
140 | + $args['total'] = intval((int) $args['total']); |
|
141 | + if ($args['total'] < 2) { |
|
142 | 142 | return array(); |
143 | 143 | } |
144 | 144 | $args['current'] = (int) $args['current']; |
145 | 145 | $args['end_size'] = 0 < (int) $args['end_size'] ? (int) $args['end_size'] : 1; // Out of bounds? Make it the default. |
146 | 146 | $args['mid_size'] = 0 <= (int) $args['mid_size'] ? (int) $args['mid_size'] : 2; |
147 | - $args['add_args'] = is_array( $args['add_args'] ) ? $args['add_args'] : false; |
|
147 | + $args['add_args'] = is_array($args['add_args']) ? $args['add_args'] : false; |
|
148 | 148 | $page_links = array(); |
149 | 149 | $dots = false; |
150 | - if ( $args['prev_next'] && $args['current'] && 1 < $args['current'] ) { |
|
151 | - $link = str_replace( '%_%', 2 === absint( $args['current'] ) ? '' : $args['format'], $args['base'] ); |
|
152 | - $link = str_replace( '%#%', $args['current'] - 1, $link ); |
|
153 | - if ( $args['add_args'] ) { |
|
154 | - $link = add_query_arg( $args['add_args'], $link ); |
|
150 | + if ($args['prev_next'] && $args['current'] && 1 < $args['current']) { |
|
151 | + $link = str_replace('%_%', 2 === absint($args['current']) ? '' : $args['format'], $args['base']); |
|
152 | + $link = str_replace('%#%', $args['current'] - 1, $link); |
|
153 | + if ($args['add_args']) { |
|
154 | + $link = add_query_arg($args['add_args'], $link); |
|
155 | 155 | } |
156 | 156 | $link .= $args['add_fragment']; |
157 | - $link = untrailingslashit( $link ); |
|
157 | + $link = untrailingslashit($link); |
|
158 | 158 | $page_links[] = array( |
159 | 159 | 'class' => 'prev page-numbers', |
160 | - 'link' => esc_url( apply_filters( 'paginate_links', $link ) ), |
|
160 | + 'link' => esc_url(apply_filters('paginate_links', $link)), |
|
161 | 161 | 'title' => $args['prev_text'], |
162 | 162 | ); |
163 | 163 | } |
164 | - for ( $n = 1; $n <= $args['total']; $n++ ) { |
|
165 | - $n_display = number_format_i18n( $n ); |
|
166 | - if ( absint( $args['current'] ) === $n ) { |
|
164 | + for ($n = 1; $n <= $args['total']; $n++) { |
|
165 | + $n_display = number_format_i18n($n); |
|
166 | + if (absint($args['current']) === $n) { |
|
167 | 167 | $page_links[] = array( |
168 | 168 | 'class' => 'page-number page-numbers current', |
169 | 169 | 'title' => $n_display, |
@@ -173,42 +173,42 @@ discard block |
||
173 | 173 | ); |
174 | 174 | $dots = true; |
175 | 175 | } else { |
176 | - 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'] ) ) { |
|
177 | - $link = str_replace( '%_%', 1 === absint( $n ) ? '' : $args['format'], $args['base'] ); |
|
178 | - $link = str_replace( '%#%', $n, $link ); |
|
179 | - $link = trailingslashit( $link ) . ltrim( $args['add_fragment'], '/' ); |
|
180 | - if ( $args['add_args'] ) { |
|
181 | - $link = rtrim( add_query_arg( $args['add_args'], $link ), '/' ); |
|
176 | + 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'])) { |
|
177 | + $link = str_replace('%_%', 1 === absint($n) ? '' : $args['format'], $args['base']); |
|
178 | + $link = str_replace('%#%', $n, $link); |
|
179 | + $link = trailingslashit($link).ltrim($args['add_fragment'], '/'); |
|
180 | + if ($args['add_args']) { |
|
181 | + $link = rtrim(add_query_arg($args['add_args'], $link), '/'); |
|
182 | 182 | } |
183 | - $link = str_replace( ' ', '+', $link ); |
|
184 | - $link = untrailingslashit( $link ); |
|
183 | + $link = str_replace(' ', '+', $link); |
|
184 | + $link = untrailingslashit($link); |
|
185 | 185 | $page_links[] = array( |
186 | 186 | 'class' => 'page-number page-numbers', |
187 | - 'link' => esc_url( apply_filters( 'paginate_links', $link ) ), |
|
187 | + 'link' => esc_url(apply_filters('paginate_links', $link)), |
|
188 | 188 | 'title' => $n_display, |
189 | 189 | 'name' => $n_display, |
190 | - 'current' => absint( $args['current'] ) === $n, |
|
190 | + 'current' => absint($args['current']) === $n, |
|
191 | 191 | ); |
192 | 192 | $dots = true; |
193 | - } elseif ( $dots && ! $args['show_all'] ) { |
|
193 | + } elseif ($dots && !$args['show_all']) { |
|
194 | 194 | $page_links[] = array( |
195 | 195 | 'class' => 'dots', |
196 | - 'title' => __( '…' ), |
|
196 | + 'title' => __('…'), |
|
197 | 197 | ); |
198 | 198 | $dots = false; |
199 | 199 | } |
200 | 200 | } |
201 | 201 | } |
202 | - if ( $args['prev_next'] && $args['current'] && ( $args['current'] < $args['total'] || -1 === intval( $args['total'] ) ) ) { |
|
203 | - $link = str_replace( '%_%', $args['format'], $args['base'] ); |
|
204 | - $link = str_replace( '%#%', $args['current'] + 1, $link ); |
|
205 | - if ( $args['add_args'] ) { |
|
206 | - $link = add_query_arg( $args['add_args'], $link ); |
|
202 | + if ($args['prev_next'] && $args['current'] && ($args['current'] < $args['total'] || -1 === intval($args['total']))) { |
|
203 | + $link = str_replace('%_%', $args['format'], $args['base']); |
|
204 | + $link = str_replace('%#%', $args['current'] + 1, $link); |
|
205 | + if ($args['add_args']) { |
|
206 | + $link = add_query_arg($args['add_args'], $link); |
|
207 | 207 | } |
208 | - $link = untrailingslashit( trailingslashit( $link ) . $args['add_fragment'] ); |
|
208 | + $link = untrailingslashit(trailingslashit($link).$args['add_fragment']); |
|
209 | 209 | $page_links[] = array( |
210 | 210 | 'class' => 'next page-numbers', |
211 | - 'link' => esc_url( apply_filters( 'paginate_links', $link ) ), |
|
211 | + 'link' => esc_url(apply_filters('paginate_links', $link)), |
|
212 | 212 | 'title' => $args['next_text'], |
213 | 213 | ); |
214 | 214 | } |
@@ -222,13 +222,13 @@ discard block |
||
222 | 222 | * @param array $array |
223 | 223 | * @return object |
224 | 224 | */ |
225 | - public static function array_to_object( $array ) { |
|
225 | + public static function array_to_object($array) { |
|
226 | 226 | $obj = new stdClass; |
227 | 227 | |
228 | - foreach ( $array as $k => $v ) { |
|
229 | - if ( strlen( $k ) ) { |
|
230 | - if ( is_array( $v ) ) { |
|
231 | - $obj->{$k} = self::array_to_object( $v ); //RECURSION |
|
228 | + foreach ($array as $k => $v) { |
|
229 | + if (strlen($k)) { |
|
230 | + if (is_array($v)) { |
|
231 | + $obj->{$k} = self::array_to_object($v); //RECURSION |
|
232 | 232 | } else { |
233 | 233 | $obj->{$k} = $v; |
234 | 234 | } |
@@ -251,42 +251,42 @@ discard block |
||
251 | 251 | |
252 | 252 | $archives_title = ''; |
253 | 253 | |
254 | - if ( is_category() ) { |
|
254 | + if (is_category()) { |
|
255 | 255 | |
256 | - $archives_title = single_cat_title( '', false ); |
|
256 | + $archives_title = single_cat_title('', false); |
|
257 | 257 | |
258 | - } else if ( is_tag() ) { |
|
258 | + } else if (is_tag()) { |
|
259 | 259 | |
260 | - $archives_title = 'Tag: ' . single_tag_title( '', false ); |
|
260 | + $archives_title = 'Tag: '.single_tag_title('', false); |
|
261 | 261 | |
262 | - } else if ( is_author() ) { |
|
262 | + } else if (is_author()) { |
|
263 | 263 | |
264 | - if ( have_posts() ) { |
|
264 | + if (have_posts()) { |
|
265 | 265 | |
266 | 266 | the_post(); |
267 | - $archives_title = 'Author: ' . get_the_author(); |
|
267 | + $archives_title = 'Author: '.get_the_author(); |
|
268 | 268 | |
269 | 269 | } |
270 | 270 | |
271 | 271 | rewind_posts(); |
272 | 272 | |
273 | - } else if ( is_search() ) { |
|
273 | + } else if (is_search()) { |
|
274 | 274 | |
275 | - $archives_title = sprintf( __( 'Search Results for: %s', $textdomain ), '<span>' . get_search_query() . '</span>' ); |
|
275 | + $archives_title = sprintf(__('Search Results for: %s', $textdomain), '<span>'.get_search_query().'</span>'); |
|
276 | 276 | |
277 | - } else if ( is_archive() ) { |
|
277 | + } else if (is_archive()) { |
|
278 | 278 | |
279 | - if ( is_day() ) { |
|
279 | + if (is_day()) { |
|
280 | 280 | |
281 | 281 | $archives_title = get_the_date(); |
282 | 282 | |
283 | - } elseif ( is_month() ) { |
|
283 | + } elseif (is_month()) { |
|
284 | 284 | |
285 | - $archives_title = get_the_date( _x( 'F Y', 'monthly archives date format', $textdomain ) ); |
|
285 | + $archives_title = get_the_date(_x('F Y', 'monthly archives date format', $textdomain)); |
|
286 | 286 | |
287 | - } elseif ( is_year() ) { |
|
287 | + } elseif (is_year()) { |
|
288 | 288 | |
289 | - $archives_title = get_the_date( _x( 'Y', 'yearly archives date format', $textdomain ) ); |
|
289 | + $archives_title = get_the_date(_x('Y', 'yearly archives date format', $textdomain)); |
|
290 | 290 | |
291 | 291 | } else { |
292 | 292 |
@@ -20,39 +20,39 @@ discard block |
||
20 | 20 | */ |
21 | 21 | protected static function check_request() { |
22 | 22 | |
23 | - if ( is_404() ) : return '404'; |
|
23 | + if (is_404()) : return '404'; |
|
24 | 24 | |
25 | - elseif ( is_search() ) : return 'search'; |
|
25 | + elseif (is_search()) : return 'search'; |
|
26 | 26 | |
27 | - elseif ( is_front_page() ) : return 'front-page'; |
|
27 | + elseif (is_front_page()) : return 'front-page'; |
|
28 | 28 | |
29 | - elseif ( is_home() ) : return 'home'; |
|
29 | + elseif (is_home()) : return 'home'; |
|
30 | 30 | |
31 | - elseif ( is_post_type_archive() ) : return 'post_type_archive'; |
|
31 | + elseif (is_post_type_archive()) : return 'post_type_archive'; |
|
32 | 32 | |
33 | - elseif ( is_tax() ) : return 'taxonomy'; |
|
33 | + elseif (is_tax()) : return 'taxonomy'; |
|
34 | 34 | |
35 | - elseif ( is_attachment() ) : return 'attachment'; |
|
35 | + elseif (is_attachment()) : return 'attachment'; |
|
36 | 36 | |
37 | - elseif ( is_single() ) : return 'single'; |
|
37 | + elseif (is_single()) : return 'single'; |
|
38 | 38 | |
39 | - elseif ( self::is_classy_template() ) : return 'classy-template'; |
|
39 | + elseif (self::is_classy_template()) : return 'classy-template'; |
|
40 | 40 | |
41 | - elseif ( is_page() ) : return 'page'; |
|
41 | + elseif (is_page()) : return 'page'; |
|
42 | 42 | |
43 | - elseif ( is_singular() ) : return 'singular'; |
|
43 | + elseif (is_singular()) : return 'singular'; |
|
44 | 44 | |
45 | - elseif ( is_category() ) : return 'category'; |
|
45 | + elseif (is_category()) : return 'category'; |
|
46 | 46 | |
47 | - elseif ( is_tag() ) : return 'tag'; |
|
47 | + elseif (is_tag()) : return 'tag'; |
|
48 | 48 | |
49 | - elseif ( is_author() ) : return 'author'; |
|
49 | + elseif (is_author()) : return 'author'; |
|
50 | 50 | |
51 | - elseif ( is_date() ) : return 'date'; |
|
51 | + elseif (is_date()) : return 'date'; |
|
52 | 52 | |
53 | - elseif ( is_archive() ) : return 'archive'; |
|
53 | + elseif (is_archive()) : return 'archive'; |
|
54 | 54 | |
55 | - elseif ( is_paged() ) : return 'paged'; |
|
55 | + elseif (is_paged()) : return 'paged'; |
|
56 | 56 | |
57 | 57 | else : |
58 | 58 | |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public static function get_current_request() { |
71 | 71 | |
72 | - if ( null === self::$current_request ) { |
|
72 | + if (null === self::$current_request) { |
|
73 | 73 | |
74 | 74 | self::$current_request = self::check_request(); |
75 | 75 | |
@@ -87,21 +87,21 @@ discard block |
||
87 | 87 | * @param string $view path to view ex: "post/archive" |
88 | 88 | * @return string full fule path |
89 | 89 | */ |
90 | - public static function get_file_path( $type = 'view', $view ) { |
|
90 | + public static function get_file_path($type = 'view', $view) { |
|
91 | 91 | |
92 | - $view = str_replace( '.', '/', $view ); |
|
92 | + $view = str_replace('.', '/', $view); |
|
93 | 93 | |
94 | - if ( 'view' === $type ) { |
|
94 | + if ('view' === $type) { |
|
95 | 95 | |
96 | 96 | $folder = ClassyView::$folder; |
97 | 97 | |
98 | - return THEME_PATH . $folder . '/' . $view . '.blade.php'; |
|
98 | + return THEME_PATH.$folder.'/'.$view.'.blade.php'; |
|
99 | 99 | |
100 | - } elseif ( 'scope' === $type ) { |
|
100 | + } elseif ('scope' === $type) { |
|
101 | 101 | |
102 | 102 | $folder = ClassyScope::$folder; |
103 | 103 | |
104 | - return THEME_PATH . $folder . '/' . $view . '.php'; |
|
104 | + return THEME_PATH.$folder.'/'.$view.'.php'; |
|
105 | 105 | |
106 | 106 | } |
107 | 107 | |
@@ -115,13 +115,13 @@ discard block |
||
115 | 115 | * @param string $file in blade path format, ex: layout|header |
116 | 116 | * @return boolean true|false |
117 | 117 | */ |
118 | - public static function file_exists( $type = 'view', $file ) { |
|
118 | + public static function file_exists($type = 'view', $file) { |
|
119 | 119 | |
120 | - $file = str_replace( '.', '/', $file ); |
|
120 | + $file = str_replace('.', '/', $file); |
|
121 | 121 | |
122 | - $file_path = self::get_file_path( $type, $file ); |
|
122 | + $file_path = self::get_file_path($type, $file); |
|
123 | 123 | |
124 | - return file_exists( $file_path ); |
|
124 | + return file_exists($file_path); |
|
125 | 125 | |
126 | 126 | } |
127 | 127 | |
@@ -133,13 +133,13 @@ discard block |
||
133 | 133 | * @param string $type |
134 | 134 | * @return array |
135 | 135 | */ |
136 | - public static function get_available_file( $type = 'view', $page ) { |
|
136 | + public static function get_available_file($type = 'view', $page) { |
|
137 | 137 | |
138 | - $views = self::get_request_hierarchy_list( $page ); |
|
138 | + $views = self::get_request_hierarchy_list($page); |
|
139 | 139 | |
140 | - foreach ( $views as $view ) { |
|
140 | + foreach ($views as $view) { |
|
141 | 141 | |
142 | - if ( self::file_exists( $type, $view ) ) : |
|
142 | + if (self::file_exists($type, $view)) : |
|
143 | 143 | |
144 | 144 | return $view; |
145 | 145 | |
@@ -158,43 +158,43 @@ discard block |
||
158 | 158 | * @param string $type |
159 | 159 | * @return array |
160 | 160 | */ |
161 | - private static function get_request_hierarchy_list( $type ) { |
|
161 | + private static function get_request_hierarchy_list($type) { |
|
162 | 162 | |
163 | 163 | $views = array(); |
164 | 164 | |
165 | 165 | // Home |
166 | 166 | |
167 | - if ( 'home' === $type ) : |
|
167 | + if ('home' === $type) : |
|
168 | 168 | |
169 | 169 | $views[] = 'home'; |
170 | 170 | |
171 | 171 | // Single |
172 | 172 | |
173 | - elseif ( 'single' === $type ) : |
|
173 | + elseif ('single' === $type) : |
|
174 | 174 | |
175 | 175 | $post_type = get_post_type(); |
176 | 176 | |
177 | - $views[] = $post_type . '.single'; |
|
177 | + $views[] = $post_type.'.single'; |
|
178 | 178 | |
179 | 179 | $views[] = 'single'; |
180 | 180 | |
181 | 181 | // Post type |
182 | 182 | |
183 | - elseif ( 'post_type_archive' === $type ) : |
|
183 | + elseif ('post_type_archive' === $type) : |
|
184 | 184 | |
185 | 185 | $post_type = get_post_type(); |
186 | 186 | |
187 | - $views[] = $post_type . '.archive'; |
|
187 | + $views[] = $post_type.'.archive'; |
|
188 | 188 | |
189 | 189 | $views[] = 'archive'; |
190 | 190 | |
191 | 191 | // Taxonomy |
192 | 192 | |
193 | - elseif ( 'taxonomy' === $type ) : |
|
193 | + elseif ('taxonomy' === $type) : |
|
194 | 194 | |
195 | 195 | $term = get_queried_object(); |
196 | 196 | |
197 | - if ( ! empty( $term->slug ) ) { |
|
197 | + if (!empty($term->slug)) { |
|
198 | 198 | |
199 | 199 | $taxonomy = $term->taxonomy; |
200 | 200 | |
@@ -209,11 +209,11 @@ discard block |
||
209 | 209 | |
210 | 210 | // Category |
211 | 211 | |
212 | - elseif ( 'category' === $type ) : |
|
212 | + elseif ('category' === $type) : |
|
213 | 213 | |
214 | 214 | $category = get_queried_object(); |
215 | 215 | |
216 | - if ( ! empty( $category->slug ) ) { |
|
216 | + if (!empty($category->slug)) { |
|
217 | 217 | $views[] = "category.{$category->slug}"; |
218 | 218 | $views[] = "category.{$category->term_id}"; |
219 | 219 | } |
@@ -224,23 +224,23 @@ discard block |
||
224 | 224 | |
225 | 225 | // Attachment |
226 | 226 | |
227 | - elseif ( 'attachment' === $type ) : |
|
227 | + elseif ('attachment' === $type) : |
|
228 | 228 | |
229 | 229 | $attachment = get_queried_object(); |
230 | 230 | |
231 | - if ( $attachment ) { |
|
231 | + if ($attachment) { |
|
232 | 232 | |
233 | - if ( false !== strpos( $attachment->post_mime_type, '/' ) ) { |
|
233 | + if (false !== strpos($attachment->post_mime_type, '/')) { |
|
234 | 234 | |
235 | - list( $type, $subtype ) = explode( '/', $attachment->post_mime_type ); |
|
235 | + list($type, $subtype) = explode('/', $attachment->post_mime_type); |
|
236 | 236 | |
237 | 237 | } else { |
238 | 238 | |
239 | - list( $type, $subtype ) = array( $attachment->post_mime_type, '' ); |
|
239 | + list($type, $subtype) = array($attachment->post_mime_type, ''); |
|
240 | 240 | |
241 | 241 | } |
242 | 242 | |
243 | - if ( ! empty( $subtype ) ) { |
|
243 | + if (!empty($subtype)) { |
|
244 | 244 | $views[] = "attachment.{$type}.{$subtype}"; |
245 | 245 | $views[] = "attachment.{$subtype}"; |
246 | 246 | |
@@ -259,11 +259,11 @@ discard block |
||
259 | 259 | |
260 | 260 | // Tag |
261 | 261 | |
262 | - elseif ( 'tag' === $type ) : |
|
262 | + elseif ('tag' === $type) : |
|
263 | 263 | |
264 | 264 | $tag = get_queried_object(); |
265 | 265 | |
266 | - if ( ! empty( $tag->slug ) ) { |
|
266 | + if (!empty($tag->slug)) { |
|
267 | 267 | $views[] = "post.tag.{$tag->slug}"; |
268 | 268 | $views[] = "post.tag.{$tag->term_id}"; |
269 | 269 | |
@@ -276,11 +276,11 @@ discard block |
||
276 | 276 | |
277 | 277 | // Author |
278 | 278 | |
279 | - elseif ( 'author' === $type ) : |
|
279 | + elseif ('author' === $type) : |
|
280 | 280 | |
281 | 281 | $author = get_queried_object(); |
282 | 282 | |
283 | - if ( $author instanceof WP_User ) { |
|
283 | + if ($author instanceof WP_User) { |
|
284 | 284 | $views[] = "post.author.{$author->user_nicename}"; |
285 | 285 | $views[] = "post.author.{$author->ID}"; |
286 | 286 | |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | |
295 | 295 | // Front Page |
296 | 296 | |
297 | - elseif ( 'front-page' === $type ) : |
|
297 | + elseif ('front-page' === $type) : |
|
298 | 298 | |
299 | 299 | $views[] = 'front-page.front-page'; |
300 | 300 | $views[] = 'front-page'; |
@@ -302,43 +302,43 @@ discard block |
||
302 | 302 | $views[] = 'home.home'; |
303 | 303 | $views[] = 'home'; |
304 | 304 | |
305 | - $views = array_merge( $views, self::get_request_hierarchy_list( 'post_type_archive' ) ); |
|
305 | + $views = array_merge($views, self::get_request_hierarchy_list('post_type_archive')); |
|
306 | 306 | |
307 | 307 | // Page |
308 | 308 | |
309 | - elseif ( 'classy-template' === $type ) : |
|
309 | + elseif ('classy-template' === $type) : |
|
310 | 310 | |
311 | 311 | $template = self::get_classy_template(); |
312 | 312 | |
313 | 313 | $views[] = $template; |
314 | 314 | |
315 | - $views[] = 'page.' . $template; |
|
315 | + $views[] = 'page.'.$template; |
|
316 | 316 | |
317 | - $views[] = 'template.' . $template; |
|
317 | + $views[] = 'template.'.$template; |
|
318 | 318 | |
319 | 319 | $views[] = 'page'; |
320 | 320 | |
321 | - elseif ( 'page' === $type ) : |
|
321 | + elseif ('page' === $type) : |
|
322 | 322 | |
323 | 323 | $id = get_queried_object_id(); |
324 | 324 | |
325 | - $pagename = get_query_var( 'pagename' ); |
|
325 | + $pagename = get_query_var('pagename'); |
|
326 | 326 | |
327 | - if ( ! $pagename && $id ) { |
|
327 | + if (!$pagename && $id) { |
|
328 | 328 | // If a static page is set as the front page, $pagename will not be set. Retrieve it from the queried object |
329 | 329 | $post = get_queried_object(); |
330 | 330 | |
331 | - if ( $post ) { |
|
331 | + if ($post) { |
|
332 | 332 | $pagename = $post->post_name; |
333 | 333 | } |
334 | 334 | } |
335 | 335 | |
336 | - if ( $pagename ) { |
|
337 | - $views[] = 'page.' . $pagename; |
|
336 | + if ($pagename) { |
|
337 | + $views[] = 'page.'.$pagename; |
|
338 | 338 | } |
339 | 339 | |
340 | - if ( $id ) { |
|
341 | - $views[] = 'page.' . $id; |
|
340 | + if ($id) { |
|
341 | + $views[] = 'page.'.$id; |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | $views[] = 'page.page'; |
@@ -380,9 +380,9 @@ discard block |
||
380 | 380 | |
381 | 381 | $template_slug = get_page_template_slug(); |
382 | 382 | |
383 | - preg_match( '/classy\-(.*)/', $template_slug, $matches ); |
|
383 | + preg_match('/classy\-(.*)/', $template_slug, $matches); |
|
384 | 384 | |
385 | - if ( ! empty( $matches ) && isset( $matches[1] ) ) { return $matches[1]; } |
|
385 | + if (!empty($matches) && isset($matches[1])) { return $matches[1]; } |
|
386 | 386 | |
387 | 387 | return false; |
388 | 388 |
@@ -54,9 +54,11 @@ discard block |
||
54 | 54 | |
55 | 55 | elseif ( is_paged() ) : return 'paged'; |
56 | 56 | |
57 | - else : |
|
57 | + else { |
|
58 | + : |
|
58 | 59 | |
59 | 60 | return 'index'; |
61 | + } |
|
60 | 62 | |
61 | 63 | endif; |
62 | 64 | |
@@ -97,7 +99,8 @@ discard block |
||
97 | 99 | |
98 | 100 | return THEME_PATH . $folder . '/' . $view . '.blade.php'; |
99 | 101 | |
100 | - } elseif ( 'scope' === $type ) { |
|
102 | + } |
|
103 | + elseif ( 'scope' === $type ) { |
|
101 | 104 | |
102 | 105 | $folder = ClassyScope::$folder; |
103 | 106 | |
@@ -234,7 +237,8 @@ discard block |
||
234 | 237 | |
235 | 238 | list( $type, $subtype ) = explode( '/', $attachment->post_mime_type ); |
236 | 239 | |
237 | - } else { |
|
240 | + } |
|
241 | + else { |
|
238 | 242 | |
239 | 243 | list( $type, $subtype ) = array( $attachment->post_mime_type, '' ); |
240 | 244 | |
@@ -347,9 +351,11 @@ discard block |
||
347 | 351 | |
348 | 352 | // Default |
349 | 353 | |
350 | - else : |
|
354 | + else { |
|
355 | + : |
|
351 | 356 | |
352 | 357 | $views[] = $type; |
358 | + } |
|
353 | 359 | |
354 | 360 | endif; |
355 | 361 |
@@ -12,13 +12,13 @@ discard block |
||
12 | 12 | */ |
13 | 13 | public function __construct() { |
14 | 14 | |
15 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) ); |
|
15 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_styles')); |
|
16 | 16 | |
17 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); |
|
17 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts')); |
|
18 | 18 | |
19 | - add_action( 'wp_print_scripts', array( $this, 'init_js_vars' ) ); |
|
19 | + add_action('wp_print_scripts', array($this, 'init_js_vars')); |
|
20 | 20 | |
21 | - add_action( 'after_setup_theme', array( $this, 'setup_theme' ) ); |
|
21 | + add_action('after_setup_theme', array($this, 'setup_theme')); |
|
22 | 22 | |
23 | 23 | } |
24 | 24 | |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function enqueue_styles() { |
29 | 29 | |
30 | - wp_register_style( 'general_css', THEME_DIR . 'assets/css/general.css', array(), THEME_VERSION, 'all' ); |
|
30 | + wp_register_style('general_css', THEME_DIR.'assets/css/general.css', array(), THEME_VERSION, 'all'); |
|
31 | 31 | |
32 | 32 | } |
33 | 33 | |
@@ -36,13 +36,13 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function enqueue_scripts() { |
38 | 38 | |
39 | - if ( 'production' === Classy::get_config_var( 'environment' ) ) { |
|
39 | + if ('production' === Classy::get_config_var('environment')) { |
|
40 | 40 | |
41 | - wp_register_script( 'theme_scripts', THEME_DIR . 'assets/js/min/production.js', array( 'jquery' ), THEME_VERSION, true ); |
|
41 | + wp_register_script('theme_scripts', THEME_DIR.'assets/js/min/production.js', array('jquery'), THEME_VERSION, true); |
|
42 | 42 | |
43 | 43 | } else { |
44 | 44 | |
45 | - wp_register_script( 'theme_scripts', THEME_DIR . 'assets/js/scripts.js', array( 'jquery' ), THEME_VERSION, true ); |
|
45 | + wp_register_script('theme_scripts', THEME_DIR.'assets/js/scripts.js', array('jquery'), THEME_VERSION, true); |
|
46 | 46 | |
47 | 47 | } |
48 | 48 | |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | public function init_js_vars() { |
55 | 55 | |
56 | 56 | $options = array( |
57 | - 'base_url' => home_url( '' ), |
|
58 | - 'blog_url' => home_url( 'archives/' ), |
|
57 | + 'base_url' => home_url(''), |
|
58 | + 'blog_url' => home_url('archives/'), |
|
59 | 59 | 'template_dir' => THEME_DIR, |
60 | - 'ajax_load_url' => admin_url( 'admin-ajax.php' ), |
|
60 | + 'ajax_load_url' => admin_url('admin-ajax.php'), |
|
61 | 61 | 'is_mobile' => (int) wp_is_mobile(), |
62 | 62 | ); |
63 | 63 | |
@@ -85,12 +85,12 @@ discard block |
||
85 | 85 | * @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails |
86 | 86 | */ |
87 | 87 | |
88 | - add_theme_support( 'post-thumbnails' ); |
|
88 | + add_theme_support('post-thumbnails'); |
|
89 | 89 | |
90 | 90 | // This theme uses wp_nav_menu() in one location. |
91 | 91 | register_nav_menus(array( |
92 | - 'header-menu' => __( 'Header Menu', Classy::textdomain() ), |
|
93 | - 'footer-menu' => __( 'Footer Menu', Classy::textdomain() ), |
|
92 | + 'header-menu' => __('Header Menu', Classy::textdomain()), |
|
93 | + 'footer-menu' => __('Footer Menu', Classy::textdomain()), |
|
94 | 94 | )); |
95 | 95 | |
96 | 96 | /* |