@@ -186,7 +186,7 @@ |
||
186 | 186 | /** |
187 | 187 | * Returns first attached image id |
188 | 188 | * |
189 | - * @return int/boolean |
|
189 | + * @return integer|null |
|
190 | 190 | */ |
191 | 191 | public function get_first_attached_image_id() { |
192 | 192 |
@@ -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 | |
@@ -219,12 +219,12 @@ discard block |
||
219 | 219 | * |
220 | 220 | * @return ClassyImage |
221 | 221 | */ |
222 | - public function first_attached_image( $size = 'thumbnail' ) { |
|
222 | + public function first_attached_image($size = 'thumbnail') { |
|
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 == $page && $this->post_content ) { |
|
281 | + public function get_content($page = 0) { |
|
282 | + if (0 == $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,91 +355,91 @@ 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 | /** |
439 | 439 | * Returns comments array |
440 | 440 | * @return array |
441 | 441 | */ |
442 | - public function get_comments( $status = 'approve', $order = 'DESC' ) { |
|
442 | + public function get_comments($status = 'approve', $order = 'DESC') { |
|
443 | 443 | |
444 | 444 | $_return = array(); |
445 | 445 | |
@@ -449,26 +449,26 @@ discard block |
||
449 | 449 | 'order' => $order, |
450 | 450 | ); |
451 | 451 | |
452 | - $comments = get_comments( $args ); |
|
452 | + $comments = get_comments($args); |
|
453 | 453 | |
454 | - foreach ( $comments as $comment ) { |
|
454 | + foreach ($comments as $comment) { |
|
455 | 455 | |
456 | - $_return[ $comment->comment_ID ] = new ClassyComment( $comment ); |
|
456 | + $_return[$comment->comment_ID] = new ClassyComment($comment); |
|
457 | 457 | |
458 | 458 | } |
459 | 459 | |
460 | - foreach ( $_return as $key => $comment ) { |
|
460 | + foreach ($_return as $key => $comment) { |
|
461 | 461 | |
462 | - if ( $comment->has_parent() ) { |
|
462 | + if ($comment->has_parent()) { |
|
463 | 463 | |
464 | - $_return[ $comment->comment_parent ]->add_child( $comment ); |
|
464 | + $_return[$comment->comment_parent]->add_child($comment); |
|
465 | 465 | |
466 | - unset( $_return[ $key ] ); |
|
466 | + unset($_return[$key]); |
|
467 | 467 | |
468 | 468 | } |
469 | 469 | } |
470 | 470 | |
471 | - return array_values( $_return ); |
|
471 | + return array_values($_return); |
|
472 | 472 | |
473 | 473 | } |
474 | 474 | } |
@@ -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 ); |
|
247 | + echo $renderer->render($view, $scope); |
|
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 |
@@ -12,10 +12,10 @@ discard block |
||
12 | 12 | * Main constructor function. Requires image id |
13 | 13 | * @param int $pid |
14 | 14 | */ |
15 | - public function __construct( $pid = null ) { |
|
15 | + public function __construct($pid = null) { |
|
16 | 16 | |
17 | 17 | // Checks if image with this id exists |
18 | - if ( $pid && wp_get_attachment_image_src( $pid ) ) { |
|
18 | + if ($pid && wp_get_attachment_image_src($pid)) { |
|
19 | 19 | |
20 | 20 | $this->ID = $pid; |
21 | 21 | |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | public static function get_default_image() { |
34 | 34 | |
35 | 35 | // You can put here any url |
36 | - return THEME_DIR . '/assets/noimage.png'; |
|
36 | + return THEME_DIR.'/assets/noimage.png'; |
|
37 | 37 | |
38 | 38 | } |
39 | 39 | |
@@ -42,11 +42,11 @@ discard block |
||
42 | 42 | * @param string $size |
43 | 43 | * @return string |
44 | 44 | */ |
45 | - public function src( $size = 'medium' ) { |
|
45 | + public function src($size = 'medium') { |
|
46 | 46 | |
47 | - if ( $this->ID ) { |
|
47 | + if ($this->ID) { |
|
48 | 48 | |
49 | - $thumb = wp_get_attachment_image_src( $this->ID, $size ); |
|
49 | + $thumb = wp_get_attachment_image_src($this->ID, $size); |
|
50 | 50 | |
51 | 51 | return $thumb[0]; |
52 | 52 |
@@ -19,7 +19,8 @@ discard block |
||
19 | 19 | |
20 | 20 | $this->ID = $pid; |
21 | 21 | |
22 | - } else { |
|
22 | + } |
|
23 | + else { |
|
23 | 24 | |
24 | 25 | $this->ID = 0; |
25 | 26 | |
@@ -50,7 +51,8 @@ discard block |
||
50 | 51 | |
51 | 52 | return $thumb[0]; |
52 | 53 | |
53 | - } else { |
|
54 | + } |
|
55 | + else { |
|
54 | 56 | |
55 | 57 | return self::get_default_image(); |
56 | 58 |