@@ -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 $view 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,41 +302,41 @@ 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 | - elseif ( 'page' == $type ) : |
|
| 319 | + elseif ('page' == $type) : |
|
| 320 | 320 | |
| 321 | 321 | $id = get_queried_object_id(); |
| 322 | 322 | |
| 323 | - $pagename = get_query_var( 'pagename' ); |
|
| 323 | + $pagename = get_query_var('pagename'); |
|
| 324 | 324 | |
| 325 | - if ( ! $pagename && $id ) { |
|
| 325 | + if (!$pagename && $id) { |
|
| 326 | 326 | // If a static page is set as the front page, $pagename will not be set. Retrieve it from the queried object |
| 327 | 327 | $post = get_queried_object(); |
| 328 | 328 | |
| 329 | - if ( $post ) { |
|
| 329 | + if ($post) { |
|
| 330 | 330 | $pagename = $post->post_name; |
| 331 | 331 | } |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | - if ( $pagename ) { |
|
| 335 | - $views[] = 'page.' . $pagename; |
|
| 334 | + if ($pagename) { |
|
| 335 | + $views[] = 'page.'.$pagename; |
|
| 336 | 336 | } |
| 337 | 337 | |
| 338 | - if ( $id ) { |
|
| 339 | - $views[] = 'page.' . $id; |
|
| 338 | + if ($id) { |
|
| 339 | + $views[] = 'page.'.$id; |
|
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | $views[] = 'page.page'; |
@@ -378,9 +378,9 @@ discard block |
||
| 378 | 378 | |
| 379 | 379 | $template_slug = get_page_template_slug(); |
| 380 | 380 | |
| 381 | - preg_match( '/classy\-(.*)/', $template_slug, $matches ); |
|
| 381 | + preg_match('/classy\-(.*)/', $template_slug, $matches); |
|
| 382 | 382 | |
| 383 | - if ( $matches && isset( $matches[1] ) ) { return $matches[1]; } |
|
| 383 | + if ($matches && isset($matches[1])) { return $matches[1]; } |
|
| 384 | 384 | |
| 385 | 385 | return false; |
| 386 | 386 | |
@@ -16,21 +16,21 @@ discard block |
||
| 16 | 16 | * |
| 17 | 17 | * @return array |
| 18 | 18 | */ |
| 19 | - public static function get_scope( $view_name = null ) { |
|
| 19 | + public static function get_scope($view_name = null) { |
|
| 20 | 20 | |
| 21 | 21 | $scope = self::get_common_scope(); |
| 22 | 22 | |
| 23 | - if ( is_string( $view_name ) ) { |
|
| 23 | + if (is_string($view_name)) { |
|
| 24 | 24 | |
| 25 | - $scope = self::extend_scope( $scope, $view_name ); |
|
| 25 | + $scope = self::extend_scope($scope, $view_name); |
|
| 26 | 26 | |
| 27 | 27 | } else { |
| 28 | 28 | |
| 29 | 29 | $request = ClassyHierarchy::get_current_request(); |
| 30 | 30 | |
| 31 | - $file = ClassyHierarchy::get_available_file( 'scope', $request ); |
|
| 31 | + $file = ClassyHierarchy::get_available_file('scope', $request); |
|
| 32 | 32 | |
| 33 | - $scope = self::extend_scope( $scope, $file ); |
|
| 33 | + $scope = self::extend_scope($scope, $file); |
|
| 34 | 34 | |
| 35 | 35 | } |
| 36 | 36 | |
@@ -44,9 +44,9 @@ discard block |
||
| 44 | 44 | * |
| 45 | 45 | * @return array |
| 46 | 46 | */ |
| 47 | - public static function extend_scope( $scope, $view_name ) { |
|
| 47 | + public static function extend_scope($scope, $view_name) { |
|
| 48 | 48 | |
| 49 | - $scope = array_merge( $scope, self::require_scope( $view_name ) ); |
|
| 49 | + $scope = array_merge($scope, self::require_scope($view_name)); |
|
| 50 | 50 | |
| 51 | 51 | return $scope; |
| 52 | 52 | |
@@ -60,9 +60,9 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | public static function get_common_scope() { |
| 62 | 62 | |
| 63 | - if ( null === self::$common ) { |
|
| 63 | + if (null === self::$common) { |
|
| 64 | 64 | |
| 65 | - self::$common = self::require_scope( 'common' ); |
|
| 65 | + self::$common = self::require_scope('common'); |
|
| 66 | 66 | |
| 67 | 67 | } |
| 68 | 68 | |
@@ -76,19 +76,19 @@ discard block |
||
| 76 | 76 | * @param string $filename |
| 77 | 77 | * @return array |
| 78 | 78 | */ |
| 79 | - public static function require_scope( $filename ) { |
|
| 79 | + public static function require_scope($filename) { |
|
| 80 | 80 | |
| 81 | 81 | $_return = array(); |
| 82 | 82 | |
| 83 | - $file = ClassyHierarchy::get_file_path( 'scope', $filename ); |
|
| 83 | + $file = ClassyHierarchy::get_file_path('scope', $filename); |
|
| 84 | 84 | |
| 85 | - if ( file_exists( $file ) ) { |
|
| 85 | + if (file_exists($file)) { |
|
| 86 | 86 | |
| 87 | 87 | require $file; |
| 88 | 88 | |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - if ( isset( $data ) ) { |
|
| 91 | + if (isset($data)) { |
|
| 92 | 92 | |
| 93 | 93 | $_return = $data; |
| 94 | 94 | |