@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * Checks if view exists |
| 112 | 112 | * |
| 113 | 113 | * @param string $type view/scope |
| 114 | - * @param string $view in blade path format, ex: layout/header |
|
| 114 | + * @param string|false $file |
|
| 115 | 115 | * @return boolean true/false |
| 116 | 116 | */ |
| 117 | 117 | public static function file_exists($type = 'view', $file) { |
@@ -129,8 +129,9 @@ discard block |
||
| 129 | 129 | * Returns view name for render, based on type of request |
| 130 | 130 | * |
| 131 | 131 | * @param string $type view/scope |
| 132 | - * @param string $type |
|
| 133 | - * @return array |
|
| 132 | + * @param string $type |
|
| 133 | + * @param string $page |
|
| 134 | + * @return string|false |
|
| 134 | 135 | */ |
| 135 | 136 | public static function get_available_file($type = 'view', $page) { |
| 136 | 137 | |
@@ -378,7 +379,7 @@ discard block |
||
| 378 | 379 | /** |
| 379 | 380 | * Returns classy template name or boolean if this is not classy template |
| 380 | 381 | * |
| 381 | - * @return mixed |
|
| 382 | + * @return string|false |
|
| 382 | 383 | */ |
| 383 | 384 | public static function get_classy_template() { |
| 384 | 385 | |
@@ -21,39 +21,39 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | protected static function check_request() { |
| 23 | 23 | |
| 24 | - if ( is_404()) : return '404'; |
|
| 24 | + if (is_404()) : return '404'; |
|
| 25 | 25 | |
| 26 | - elseif ( is_search() ) : return 'search'; |
|
| 26 | + elseif (is_search()) : return 'search'; |
|
| 27 | 27 | |
| 28 | - elseif ( is_front_page() ) : return 'front-page'; |
|
| 28 | + elseif (is_front_page()) : return 'front-page'; |
|
| 29 | 29 | |
| 30 | - elseif ( is_home() ) : return 'home'; |
|
| 30 | + elseif (is_home()) : return 'home'; |
|
| 31 | 31 | |
| 32 | - elseif ( is_post_type_archive() ) : return 'post_type_archive'; |
|
| 32 | + elseif (is_post_type_archive()) : return 'post_type_archive'; |
|
| 33 | 33 | |
| 34 | - elseif ( is_tax() ) : return 'taxonomy'; |
|
| 34 | + elseif (is_tax()) : return 'taxonomy'; |
|
| 35 | 35 | |
| 36 | - elseif ( is_attachment() ) : return 'attachment'; |
|
| 36 | + elseif (is_attachment()) : return 'attachment'; |
|
| 37 | 37 | |
| 38 | - elseif ( is_single() ) : return 'single'; |
|
| 38 | + elseif (is_single()) : return 'single'; |
|
| 39 | 39 | |
| 40 | - elseif ( self::is_classy_template() ) : return 'classy-template'; |
|
| 40 | + elseif (self::is_classy_template()) : return 'classy-template'; |
|
| 41 | 41 | |
| 42 | - elseif ( is_page() ) : return 'page'; |
|
| 42 | + elseif (is_page()) : return 'page'; |
|
| 43 | 43 | |
| 44 | - elseif ( is_singular() ) : return 'singular'; |
|
| 44 | + elseif (is_singular()) : return 'singular'; |
|
| 45 | 45 | |
| 46 | - elseif ( is_category() ) : return 'category'; |
|
| 46 | + elseif (is_category()) : return 'category'; |
|
| 47 | 47 | |
| 48 | - elseif ( is_tag() ) : return 'tag'; |
|
| 48 | + elseif (is_tag()) : return 'tag'; |
|
| 49 | 49 | |
| 50 | - elseif ( is_author() ) : return 'author'; |
|
| 50 | + elseif (is_author()) : return 'author'; |
|
| 51 | 51 | |
| 52 | - elseif ( is_date() ) : return 'date'; |
|
| 52 | + elseif (is_date()) : return 'date'; |
|
| 53 | 53 | |
| 54 | - elseif ( is_archive() ) : return 'archive'; |
|
| 54 | + elseif (is_archive()) : return 'archive'; |
|
| 55 | 55 | |
| 56 | - elseif ( is_paged() ) : return 'paged'; |
|
| 56 | + elseif (is_paged()) : return 'paged'; |
|
| 57 | 57 | |
| 58 | 58 | else : |
| 59 | 59 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | public static function get_current_request() { |
| 72 | 72 | |
| 73 | - if ( null === self::$current_request ) { |
|
| 73 | + if (null === self::$current_request) { |
|
| 74 | 74 | |
| 75 | 75 | self::$current_request = self::check_request(); |
| 76 | 76 | |
@@ -94,13 +94,13 @@ discard block |
||
| 94 | 94 | |
| 95 | 95 | $folder = ClassyView::$folder; |
| 96 | 96 | |
| 97 | - return THEME_PATH . $folder . '/' . $view . '.blade.php'; |
|
| 97 | + return THEME_PATH.$folder.'/'.$view.'.blade.php'; |
|
| 98 | 98 | |
| 99 | 99 | } elseif ($type == 'scope') { |
| 100 | 100 | |
| 101 | 101 | $folder = ClassyScope::$folder; |
| 102 | 102 | |
| 103 | - return THEME_PATH . $folder . '/' . $view . '.php'; |
|
| 103 | + return THEME_PATH.$folder.'/'.$view.'.php'; |
|
| 104 | 104 | |
| 105 | 105 | } |
| 106 | 106 | |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | |
| 139 | 139 | foreach ($views as $view) { |
| 140 | 140 | |
| 141 | - if ( self::file_exists($type, $view) ): |
|
| 141 | + if (self::file_exists($type, $view)): |
|
| 142 | 142 | |
| 143 | 143 | return $view; |
| 144 | 144 | |
@@ -163,38 +163,38 @@ discard block |
||
| 163 | 163 | |
| 164 | 164 | // Home |
| 165 | 165 | |
| 166 | - if ( $type == 'home' ) : |
|
| 166 | + if ($type == 'home') : |
|
| 167 | 167 | |
| 168 | 168 | $views[] = 'home'; |
| 169 | 169 | |
| 170 | 170 | // Single |
| 171 | 171 | |
| 172 | - elseif ( $type == 'single' ) : |
|
| 172 | + elseif ($type == 'single') : |
|
| 173 | 173 | |
| 174 | 174 | $post_type = get_post_type(); |
| 175 | 175 | |
| 176 | - $views[] = $post_type . '.single'; |
|
| 176 | + $views[] = $post_type.'.single'; |
|
| 177 | 177 | |
| 178 | 178 | $views[] = 'single'; |
| 179 | 179 | |
| 180 | 180 | // Post type |
| 181 | 181 | |
| 182 | - elseif ( $type == 'post_type_archive' ) : |
|
| 182 | + elseif ($type == 'post_type_archive') : |
|
| 183 | 183 | |
| 184 | 184 | $post_type = get_post_type(); |
| 185 | 185 | |
| 186 | - $views[] = $post_type . '.archive'; |
|
| 186 | + $views[] = $post_type.'.archive'; |
|
| 187 | 187 | |
| 188 | 188 | $views[] = 'archive'; |
| 189 | 189 | |
| 190 | 190 | |
| 191 | 191 | // Taxonomy |
| 192 | 192 | |
| 193 | - elseif ( $type == 'taxonomy' ): |
|
| 193 | + elseif ($type == 'taxonomy'): |
|
| 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 ( $type == 'category' ): |
|
| 212 | + elseif ($type == 'category'): |
|
| 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 | } |
@@ -225,23 +225,23 @@ discard block |
||
| 225 | 225 | |
| 226 | 226 | // Attachment |
| 227 | 227 | |
| 228 | - elseif ( $type == 'attachment' ): |
|
| 228 | + elseif ($type == 'attachment'): |
|
| 229 | 229 | |
| 230 | 230 | $attachment = get_queried_object(); |
| 231 | 231 | |
| 232 | - if ( $attachment ) { |
|
| 232 | + if ($attachment) { |
|
| 233 | 233 | |
| 234 | - if ( false !== strpos( $attachment->post_mime_type, '/' ) ) { |
|
| 234 | + if (false !== strpos($attachment->post_mime_type, '/')) { |
|
| 235 | 235 | |
| 236 | - list( $type, $subtype ) = explode( '/', $attachment->post_mime_type ); |
|
| 236 | + list($type, $subtype) = explode('/', $attachment->post_mime_type); |
|
| 237 | 237 | |
| 238 | 238 | } else { |
| 239 | 239 | |
| 240 | - list( $type, $subtype ) = array( $attachment->post_mime_type, '' ); |
|
| 240 | + list($type, $subtype) = array($attachment->post_mime_type, ''); |
|
| 241 | 241 | |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | - if ( ! empty( $subtype ) ) { |
|
| 244 | + if (!empty($subtype)) { |
|
| 245 | 245 | $views[] = "attachment.{$type}.{$subtype}"; |
| 246 | 246 | $views[] = "attachment.{$subtype}"; |
| 247 | 247 | |
@@ -261,11 +261,11 @@ discard block |
||
| 261 | 261 | |
| 262 | 262 | // Tag |
| 263 | 263 | |
| 264 | - elseif ( $type == 'tag' ): |
|
| 264 | + elseif ($type == 'tag'): |
|
| 265 | 265 | |
| 266 | 266 | $tag = get_queried_object(); |
| 267 | 267 | |
| 268 | - if ( ! empty( $tag->slug ) ) { |
|
| 268 | + if (!empty($tag->slug)) { |
|
| 269 | 269 | $views[] = "post.tag.{$tag->slug}"; |
| 270 | 270 | $views[] = "post.tag.{$tag->term_id}"; |
| 271 | 271 | |
@@ -279,11 +279,11 @@ discard block |
||
| 279 | 279 | |
| 280 | 280 | // Author |
| 281 | 281 | |
| 282 | - elseif ( $type == 'author' ): |
|
| 282 | + elseif ($type == 'author'): |
|
| 283 | 283 | |
| 284 | 284 | $author = get_queried_object(); |
| 285 | 285 | |
| 286 | - if ( $author instanceof WP_User ) { |
|
| 286 | + if ($author instanceof WP_User) { |
|
| 287 | 287 | $views[] = "post.author.{$author->user_nicename}"; |
| 288 | 288 | $views[] = "post.author.{$author->ID}"; |
| 289 | 289 | |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | |
| 299 | 299 | // Front Page |
| 300 | 300 | |
| 301 | - elseif ( $type == 'front-page' ): |
|
| 301 | + elseif ($type == 'front-page'): |
|
| 302 | 302 | |
| 303 | 303 | $views[] = 'front-page.front-page'; |
| 304 | 304 | $views[] = 'front-page'; |
@@ -310,38 +310,38 @@ discard block |
||
| 310 | 310 | |
| 311 | 311 | // Page |
| 312 | 312 | |
| 313 | - elseif ( $type == 'classy-template' ): |
|
| 313 | + elseif ($type == 'classy-template'): |
|
| 314 | 314 | |
| 315 | 315 | $template = self::get_classy_template(); |
| 316 | 316 | |
| 317 | 317 | $views[] = $template; |
| 318 | 318 | |
| 319 | - $views[] = 'page.' . $template; |
|
| 319 | + $views[] = 'page.'.$template; |
|
| 320 | 320 | |
| 321 | - $views[] = 'template.' . $template; |
|
| 321 | + $views[] = 'template.'.$template; |
|
| 322 | 322 | |
| 323 | 323 | |
| 324 | - elseif ( $type == 'page' ): |
|
| 324 | + elseif ($type == 'page'): |
|
| 325 | 325 | |
| 326 | 326 | $id = get_queried_object_id(); |
| 327 | 327 | |
| 328 | 328 | $pagename = get_query_var('pagename'); |
| 329 | 329 | |
| 330 | - if ( ! $pagename && $id ) { |
|
| 330 | + if (!$pagename && $id) { |
|
| 331 | 331 | // If a static page is set as the front page, $pagename will not be set. Retrieve it from the queried object |
| 332 | 332 | $post = get_queried_object(); |
| 333 | 333 | |
| 334 | - if ( $post ) { |
|
| 334 | + if ($post) { |
|
| 335 | 335 | $pagename = $post->post_name; |
| 336 | 336 | } |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | - if ( $pagename ) { |
|
| 340 | - $views[] = 'page.' . $pagename; |
|
| 339 | + if ($pagename) { |
|
| 340 | + $views[] = 'page.'.$pagename; |
|
| 341 | 341 | } |
| 342 | 342 | |
| 343 | - if ( $id ) { |
|
| 344 | - $views[] = 'page.' . $id; |
|
| 343 | + if ($id) { |
|
| 344 | + $views[] = 'page.'.$id; |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | $views[] = 'page.page'; |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | |
| 387 | 387 | preg_match('/classy\-(.*)/', $template_slug, $matches); |
| 388 | 388 | |
| 389 | - if ( $matches && isset($matches[1]) ) return $matches[1]; |
|
| 389 | + if ($matches && isset($matches[1])) return $matches[1]; |
|
| 390 | 390 | |
| 391 | 391 | return false; |
| 392 | 392 | |
@@ -55,9 +55,11 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | elseif ( is_paged() ) : return 'paged'; |
| 57 | 57 | |
| 58 | - else : |
|
| 58 | + else { |
|
| 59 | + : |
|
| 59 | 60 | |
| 60 | 61 | return 'index'; |
| 62 | + } |
|
| 61 | 63 | |
| 62 | 64 | endif; |
| 63 | 65 | |
@@ -96,7 +98,8 @@ discard block |
||
| 96 | 98 | |
| 97 | 99 | return THEME_PATH . $folder . '/' . $view . '.blade.php'; |
| 98 | 100 | |
| 99 | - } elseif ($type == 'scope') { |
|
| 101 | + } |
|
| 102 | + elseif ($type == 'scope') { |
|
| 100 | 103 | |
| 101 | 104 | $folder = ClassyScope::$folder; |
| 102 | 105 | |
@@ -235,7 +238,8 @@ discard block |
||
| 235 | 238 | |
| 236 | 239 | list( $type, $subtype ) = explode( '/', $attachment->post_mime_type ); |
| 237 | 240 | |
| 238 | - } else { |
|
| 241 | + } |
|
| 242 | + else { |
|
| 239 | 243 | |
| 240 | 244 | list( $type, $subtype ) = array( $attachment->post_mime_type, '' ); |
| 241 | 245 | |
@@ -351,9 +355,11 @@ discard block |
||
| 351 | 355 | |
| 352 | 356 | // Default |
| 353 | 357 | |
| 354 | - else: |
|
| 358 | + else { |
|
| 359 | + : |
|
| 355 | 360 | |
| 356 | 361 | $views[] = $type; |
| 362 | + } |
|
| 357 | 363 | |
| 358 | 364 | endif; |
| 359 | 365 | |
@@ -386,7 +392,9 @@ discard block |
||
| 386 | 392 | |
| 387 | 393 | preg_match('/classy\-(.*)/', $template_slug, $matches); |
| 388 | 394 | |
| 389 | - if ( $matches && isset($matches[1]) ) return $matches[1]; |
|
| 395 | + if ( $matches && isset($matches[1]) ) { |
|
| 396 | + return $matches[1]; |
|
| 397 | + } |
|
| 390 | 398 | |
| 391 | 399 | return false; |
| 392 | 400 | |
@@ -43,6 +43,7 @@ |
||
| 43 | 43 | /** |
| 44 | 44 | * Extends Scope with scope that is defined in theme_name/scope folder |
| 45 | 45 | * |
| 46 | + * @param string|false $view_name |
|
| 46 | 47 | * @return array |
| 47 | 48 | */ |
| 48 | 49 | public static function extend_scope($scope, $view_name) { |
@@ -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 | |
@@ -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 | |
@@ -220,8 +220,8 @@ discard block |
||
| 220 | 220 | */ |
| 221 | 221 | public static function render($view = null, $data = null) { |
| 222 | 222 | |
| 223 | - $views = THEME_PATH . ClassyView::$folder; |
|
| 224 | - $cache = WP_CONTENT_DIR . '/viewcache'; |
|
| 223 | + $views = THEME_PATH.ClassyView::$folder; |
|
| 224 | + $cache = WP_CONTENT_DIR.'/viewcache'; |
|
| 225 | 225 | $common_scope = ClassyScope::get_common_scope(); |
| 226 | 226 | |
| 227 | 227 | if ($view !== null && is_string($view)) { |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | |
| 286 | 286 | $_return[] = new ClassyPost($post_id); |
| 287 | 287 | |
| 288 | - } elseif($return_type == 'object') { |
|
| 288 | + } elseif ($return_type == 'object') { |
|
| 289 | 289 | |
| 290 | 290 | $_return[] = get_post($post_id); |
| 291 | 291 | |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | |
| 314 | 314 | $posts = self::get_posts($args, $return_type); |
| 315 | 315 | |
| 316 | - if ( $post = reset($posts ) ) { |
|
| 316 | + if ($post = reset($posts)) { |
|
| 317 | 317 | return $post; |
| 318 | 318 | } |
| 319 | 319 | |
@@ -323,58 +323,58 @@ discard block |
||
| 323 | 323 | * @param array $prefs |
| 324 | 324 | * @return array mixed |
| 325 | 325 | */ |
| 326 | - public static function get_pagination( $prefs = array() ) { |
|
| 326 | + public static function get_pagination($prefs = array()) { |
|
| 327 | 327 | |
| 328 | 328 | global $wp_query; |
| 329 | 329 | global $paged; |
| 330 | 330 | global $wp_rewrite; |
| 331 | 331 | |
| 332 | 332 | $args = array(); |
| 333 | - $args['total'] = ceil( $wp_query->found_posts / $wp_query->query_vars['posts_per_page'] ); |
|
| 333 | + $args['total'] = ceil($wp_query->found_posts / $wp_query->query_vars['posts_per_page']); |
|
| 334 | 334 | |
| 335 | - if ( $wp_rewrite->using_permalinks() ) { |
|
| 335 | + if ($wp_rewrite->using_permalinks()) { |
|
| 336 | 336 | |
| 337 | - $url = explode( '?', get_pagenum_link( 0 ) ); |
|
| 337 | + $url = explode('?', get_pagenum_link(0)); |
|
| 338 | 338 | |
| 339 | - if ( isset( $url[1] ) ) { |
|
| 340 | - parse_str( $url[1], $query ); |
|
| 339 | + if (isset($url[1])) { |
|
| 340 | + parse_str($url[1], $query); |
|
| 341 | 341 | $args['add_args'] = $query; |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | $args['format'] = 'page/%#%'; |
| 345 | - $args['base'] = trailingslashit( $url[0] ).'%_%'; |
|
| 345 | + $args['base'] = trailingslashit($url[0]).'%_%'; |
|
| 346 | 346 | |
| 347 | 347 | } else { |
| 348 | 348 | $big = 999999999; |
| 349 | - $args['base'] = str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ); |
|
| 349 | + $args['base'] = str_replace($big, '%#%', esc_url(get_pagenum_link($big))); |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | $args['type'] = 'array'; |
| 353 | - $args['current'] = max( 1, get_query_var( 'paged' ) ); |
|
| 354 | - $args['mid_size'] = max( 9 - $args['current'], 3 ); |
|
| 353 | + $args['current'] = max(1, get_query_var('paged')); |
|
| 354 | + $args['mid_size'] = max(9 - $args['current'], 3); |
|
| 355 | 355 | $args['prev_next'] = false; |
| 356 | 356 | |
| 357 | - if ( is_int( $prefs ) ) { |
|
| 357 | + if (is_int($prefs)) { |
|
| 358 | 358 | $args['mid_size'] = $prefs - 2; |
| 359 | 359 | } else { |
| 360 | - $args = array_merge( $args, $prefs ); |
|
| 360 | + $args = array_merge($args, $prefs); |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | $data = array(); |
| 364 | - $data['pages'] = ClassyHelper::paginate_links( $args ); |
|
| 365 | - $next = get_next_posts_page_link( $args['total'] ); |
|
| 364 | + $data['pages'] = ClassyHelper::paginate_links($args); |
|
| 365 | + $next = get_next_posts_page_link($args['total']); |
|
| 366 | 366 | |
| 367 | - if ( $next ) { |
|
| 368 | - $data['next'] = array( 'link' => untrailingslashit( $next ), 'class' => 'page-numbers next' ); |
|
| 367 | + if ($next) { |
|
| 368 | + $data['next'] = array('link' => untrailingslashit($next), 'class' => 'page-numbers next'); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | - $prev = previous_posts( false ); |
|
| 371 | + $prev = previous_posts(false); |
|
| 372 | 372 | |
| 373 | - if ( $prev ) { |
|
| 374 | - $data['prev'] = array( 'link' => untrailingslashit( $prev ), 'class' => 'page-numbers prev' ); |
|
| 373 | + if ($prev) { |
|
| 374 | + $data['prev'] = array('link' => untrailingslashit($prev), 'class' => 'page-numbers prev'); |
|
| 375 | 375 | } |
| 376 | 376 | |
| 377 | - if ( $paged < 2 ) { |
|
| 377 | + if ($paged < 2) { |
|
| 378 | 378 | $data['prev'] = null; |
| 379 | 379 | } |
| 380 | 380 | |