@@ -26,39 +26,39 @@ discard block |
||
26 | 26 | */ |
27 | 27 | protected static function check_request() { |
28 | 28 | |
29 | - if ( is_404() ) : return '404'; |
|
29 | + if (is_404()) : return '404'; |
|
30 | 30 | |
31 | - elseif ( is_search() ) : return 'search'; |
|
31 | + elseif (is_search()) : return 'search'; |
|
32 | 32 | |
33 | - elseif ( is_front_page() ) : return 'front-page'; |
|
33 | + elseif (is_front_page()) : return 'front-page'; |
|
34 | 34 | |
35 | - elseif ( is_home() ) : return 'home'; |
|
35 | + elseif (is_home()) : return 'home'; |
|
36 | 36 | |
37 | - elseif ( is_post_type_archive() ) : return 'post_type_archive'; |
|
37 | + elseif (is_post_type_archive()) : return 'post_type_archive'; |
|
38 | 38 | |
39 | - elseif ( is_tax() ) : return 'taxonomy'; |
|
39 | + elseif (is_tax()) : return 'taxonomy'; |
|
40 | 40 | |
41 | - elseif ( is_attachment() ) : return 'attachment'; |
|
41 | + elseif (is_attachment()) : return 'attachment'; |
|
42 | 42 | |
43 | - elseif ( is_single() ) : return 'single'; |
|
43 | + elseif (is_single()) : return 'single'; |
|
44 | 44 | |
45 | - elseif ( self::is_classy_template() ) : return 'classy-template'; |
|
45 | + elseif (self::is_classy_template()) : return 'classy-template'; |
|
46 | 46 | |
47 | - elseif ( is_page() ) : return 'page'; |
|
47 | + elseif (is_page()) : return 'page'; |
|
48 | 48 | |
49 | - elseif ( is_singular() ) : return 'singular'; |
|
49 | + elseif (is_singular()) : return 'singular'; |
|
50 | 50 | |
51 | - elseif ( is_category() ) : return 'category'; |
|
51 | + elseif (is_category()) : return 'category'; |
|
52 | 52 | |
53 | - elseif ( is_tag() ) : return 'tag'; |
|
53 | + elseif (is_tag()) : return 'tag'; |
|
54 | 54 | |
55 | - elseif ( is_author() ) : return 'author'; |
|
55 | + elseif (is_author()) : return 'author'; |
|
56 | 56 | |
57 | - elseif ( is_date() ) : return 'date'; |
|
57 | + elseif (is_date()) : return 'date'; |
|
58 | 58 | |
59 | - elseif ( is_archive() ) : return 'archive'; |
|
59 | + elseif (is_archive()) : return 'archive'; |
|
60 | 60 | |
61 | - elseif ( is_paged() ) : return 'paged'; |
|
61 | + elseif (is_paged()) : return 'paged'; |
|
62 | 62 | |
63 | 63 | else : |
64 | 64 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * @return string |
74 | 74 | */ |
75 | 75 | public static function get_current_request() { |
76 | - if ( is_null( self::$current_request ) ) { |
|
76 | + if (is_null(self::$current_request)) { |
|
77 | 77 | self::$current_request = self::check_request(); |
78 | 78 | } |
79 | 79 | |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @return string Full file path. |
91 | 91 | */ |
92 | - public static function get_file_path( $type = 'view', $view ) { |
|
93 | - $view = str_replace( '.', '/', $view ); |
|
92 | + public static function get_file_path($type = 'view', $view) { |
|
93 | + $view = str_replace('.', '/', $view); |
|
94 | 94 | |
95 | - if ( 'view' === $type ) { |
|
96 | - return CLASSY_THEME_PATH . View::$folder . '/' . $view . '.blade.php'; |
|
97 | - } elseif ( 'scope' === $type ) { |
|
98 | - return CLASSY_THEME_PATH . Scope::$folder . '/' . $view . '.php'; |
|
95 | + if ('view' === $type) { |
|
96 | + return CLASSY_THEME_PATH.View::$folder.'/'.$view.'.blade.php'; |
|
97 | + } elseif ('scope' === $type) { |
|
98 | + return CLASSY_THEME_PATH.Scope::$folder.'/'.$view.'.php'; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | return ''; |
@@ -109,9 +109,9 @@ discard block |
||
109 | 109 | * |
110 | 110 | * @return boolean true|false |
111 | 111 | */ |
112 | - public static function file_exists( $type = 'view', $file ) { |
|
112 | + public static function file_exists($type = 'view', $file) { |
|
113 | 113 | return file_exists( |
114 | - self::get_file_path( $type, str_replace( '.', '/', $file ) ) |
|
114 | + self::get_file_path($type, str_replace('.', '/', $file)) |
|
115 | 115 | ); |
116 | 116 | } |
117 | 117 | |
@@ -123,11 +123,11 @@ discard block |
||
123 | 123 | * |
124 | 124 | * @return array|bool |
125 | 125 | */ |
126 | - public static function get_available_file( $type = 'view', $page ) { |
|
127 | - $views = self::get_request_hierarchy_list( $page ); |
|
126 | + public static function get_available_file($type = 'view', $page) { |
|
127 | + $views = self::get_request_hierarchy_list($page); |
|
128 | 128 | |
129 | - foreach ( $views as $view ) { |
|
130 | - if ( self::file_exists( $type, $view ) ) { |
|
129 | + foreach ($views as $view) { |
|
130 | + if (self::file_exists($type, $view)) { |
|
131 | 131 | return $view; |
132 | 132 | } |
133 | 133 | } |
@@ -142,26 +142,26 @@ discard block |
||
142 | 142 | * |
143 | 143 | * @return array |
144 | 144 | */ |
145 | - private static function get_request_hierarchy_list( $type ) { |
|
145 | + private static function get_request_hierarchy_list($type) { |
|
146 | 146 | $views = array(); |
147 | 147 | |
148 | - if ( 'home' === $type ) : |
|
148 | + if ('home' === $type) : |
|
149 | 149 | $views[] = 'home'; |
150 | - elseif ( 'single' === $type ) : |
|
150 | + elseif ('single' === $type) : |
|
151 | 151 | |
152 | - $views[] = get_post_type() . '.single'; |
|
152 | + $views[] = get_post_type().'.single'; |
|
153 | 153 | $views[] = 'single'; |
154 | 154 | |
155 | - elseif ( 'post_type_archive' === $type ) : |
|
155 | + elseif ('post_type_archive' === $type) : |
|
156 | 156 | |
157 | - $views[] = get_post_type() . '.archive'; |
|
157 | + $views[] = get_post_type().'.archive'; |
|
158 | 158 | $views[] = 'archive'; |
159 | 159 | |
160 | - elseif ( 'taxonomy' === $type ) : |
|
160 | + elseif ('taxonomy' === $type) : |
|
161 | 161 | |
162 | 162 | $term = get_queried_object(); |
163 | 163 | |
164 | - if ( ! empty( $term->slug ) ) { |
|
164 | + if (!empty($term->slug)) { |
|
165 | 165 | $taxonomy = $term->taxonomy; |
166 | 166 | |
167 | 167 | $views[] = "taxonomy.$taxonomy-{$term->slug}"; |
@@ -171,11 +171,11 @@ discard block |
||
171 | 171 | $views[] = 'taxonomy.taxonomy'; |
172 | 172 | $views[] = 'taxonomy'; |
173 | 173 | |
174 | - elseif ( 'category' === $type ) : |
|
174 | + elseif ('category' === $type) : |
|
175 | 175 | |
176 | 176 | $category = get_queried_object(); |
177 | 177 | |
178 | - if ( ! empty( $category->slug ) ) { |
|
178 | + if (!empty($category->slug)) { |
|
179 | 179 | $views[] = "category.{$category->slug}"; |
180 | 180 | $views[] = "category.{$category->term_id}"; |
181 | 181 | } |
@@ -183,18 +183,18 @@ discard block |
||
183 | 183 | $views[] = 'category.category'; |
184 | 184 | $views[] = 'category'; |
185 | 185 | |
186 | - elseif ( 'attachment' === $type ) : |
|
186 | + elseif ('attachment' === $type) : |
|
187 | 187 | |
188 | 188 | $attachment = get_queried_object(); |
189 | 189 | |
190 | - if ( $attachment ) { |
|
191 | - if ( false !== strpos( $attachment->post_mime_type, '/' ) ) { |
|
192 | - list( $type, $subtype ) = explode( '/', $attachment->post_mime_type ); |
|
190 | + if ($attachment) { |
|
191 | + if (false !== strpos($attachment->post_mime_type, '/')) { |
|
192 | + list($type, $subtype) = explode('/', $attachment->post_mime_type); |
|
193 | 193 | } else { |
194 | - list( $type, $subtype ) = array( $attachment->post_mime_type, '' ); |
|
194 | + list($type, $subtype) = array($attachment->post_mime_type, ''); |
|
195 | 195 | } |
196 | 196 | |
197 | - if ( ! empty( $subtype ) ) { |
|
197 | + if (!empty($subtype)) { |
|
198 | 198 | $views[] = "attachment.{$type}.{$subtype}"; |
199 | 199 | $views[] = "attachment.{$subtype}"; |
200 | 200 | |
@@ -209,11 +209,11 @@ discard block |
||
209 | 209 | $views[] = 'attachment.attachment'; |
210 | 210 | $views[] = 'attachment'; |
211 | 211 | |
212 | - elseif ( 'tag' === $type ) : |
|
212 | + elseif ('tag' === $type) : |
|
213 | 213 | |
214 | 214 | $tag = get_queried_object(); |
215 | 215 | |
216 | - if ( ! empty( $tag->slug ) ) { |
|
216 | + if (!empty($tag->slug)) { |
|
217 | 217 | $views[] = "post.tag.{$tag->slug}"; |
218 | 218 | $views[] = "post.tag.{$tag->term_id}"; |
219 | 219 | |
@@ -224,11 +224,11 @@ discard block |
||
224 | 224 | $views[] = 'post.tag'; |
225 | 225 | $views[] = 'tag'; |
226 | 226 | |
227 | - elseif ( 'author' === $type ) : |
|
227 | + elseif ('author' === $type) : |
|
228 | 228 | |
229 | 229 | $author = get_queried_object(); |
230 | 230 | |
231 | - if ( $author instanceof \WP_User ) { |
|
231 | + if ($author instanceof \WP_User) { |
|
232 | 232 | $views[] = "post.author.{$author->user_nicename}"; |
233 | 233 | $views[] = "post.author.{$author->ID}"; |
234 | 234 | |
@@ -239,14 +239,14 @@ discard block |
||
239 | 239 | $views[] = 'post.author'; |
240 | 240 | $views[] = 'author'; |
241 | 241 | |
242 | - elseif ( 'front-page' === $type ) : |
|
242 | + elseif ('front-page' === $type) : |
|
243 | 243 | |
244 | 244 | $template = self::get_classy_template(); |
245 | 245 | |
246 | - if ( ! empty( $template ) ) { |
|
246 | + if (!empty($template)) { |
|
247 | 247 | $views[] = $template; |
248 | - $views[] = 'page.' . $template; |
|
249 | - $views[] = 'template.' . $template; |
|
248 | + $views[] = 'page.'.$template; |
|
249 | + $views[] = 'template.'.$template; |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | $views[] = 'front-page.front-page'; |
@@ -255,37 +255,37 @@ discard block |
||
255 | 255 | $views[] = 'home.home'; |
256 | 256 | $views[] = 'home'; |
257 | 257 | |
258 | - $views = array_merge( $views, self::get_request_hierarchy_list( 'post_type_archive' ) ); |
|
258 | + $views = array_merge($views, self::get_request_hierarchy_list('post_type_archive')); |
|
259 | 259 | |
260 | - elseif ( 'classy-template' === $type ) : |
|
260 | + elseif ('classy-template' === $type) : |
|
261 | 261 | |
262 | 262 | $template = self::get_classy_template(); |
263 | 263 | |
264 | 264 | $views[] = $template; |
265 | - $views[] = 'page.' . $template; |
|
266 | - $views[] = 'template.' . $template; |
|
265 | + $views[] = 'page.'.$template; |
|
266 | + $views[] = 'template.'.$template; |
|
267 | 267 | $views[] = 'page.page'; |
268 | 268 | $views[] = 'page'; |
269 | 269 | |
270 | - elseif ( 'page' === $type ) : |
|
270 | + elseif ('page' === $type) : |
|
271 | 271 | |
272 | 272 | $id = get_queried_object_id(); |
273 | 273 | |
274 | - $pagename = get_query_var( 'pagename' ); |
|
274 | + $pagename = get_query_var('pagename'); |
|
275 | 275 | |
276 | - if ( ! $pagename && $id ) { |
|
276 | + if (!$pagename && $id) { |
|
277 | 277 | // If a static page is set as the front page, $pagename will not be set. Retrieve it from the queried object. |
278 | - if ( $post = get_queried_object() ) { |
|
278 | + if ($post = get_queried_object()) { |
|
279 | 279 | $pagename = $post->post_name; |
280 | 280 | } |
281 | 281 | } |
282 | 282 | |
283 | - if ( $pagename ) { |
|
284 | - $views[] = 'page.' . $pagename; |
|
283 | + if ($pagename) { |
|
284 | + $views[] = 'page.'.$pagename; |
|
285 | 285 | } |
286 | 286 | |
287 | - if ( $id ) { |
|
288 | - $views[] = 'page.' . $id; |
|
287 | + if ($id) { |
|
288 | + $views[] = 'page.'.$id; |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | $views[] = 'page.page'; |
@@ -317,9 +317,9 @@ discard block |
||
317 | 317 | * @return mixed |
318 | 318 | */ |
319 | 319 | public static function get_classy_template() { |
320 | - preg_match( '/classy\-(.*)/', get_page_template_slug(), $matches ); |
|
320 | + preg_match('/classy\-(.*)/', get_page_template_slug(), $matches); |
|
321 | 321 | |
322 | - if ( ! empty( $matches ) && isset( $matches[1] ) ) { |
|
322 | + if (!empty($matches) && isset($matches[1])) { |
|
323 | 323 | return $matches[1]; |
324 | 324 | } |
325 | 325 |