@@ -2,5 +2,5 @@ |
||
2 | 2 | /** |
3 | 3 | * Init our WordPress Theme. |
4 | 4 | */ |
5 | -require_once( __DIR__ . '/vendor/autoload.php' ); |
|
5 | +require_once(__DIR__.'/vendor/autoload.php'); |
|
6 | 6 | \Classy\Classy::get_instance(); |
@@ -2,4 +2,4 @@ |
||
2 | 2 | /** |
3 | 3 | * Theme header. |
4 | 4 | */ |
5 | -get_theme_framework()::render( 'layout.header' ); |
|
5 | +get_theme_framework()::render('layout.header'); |
@@ -2,4 +2,4 @@ |
||
2 | 2 | /** |
3 | 3 | * Theme footer. |
4 | 4 | */ |
5 | -get_theme_framework()::render( 'layout.footer' ); |
|
5 | +get_theme_framework()::render('layout.footer'); |
@@ -2,6 +2,6 @@ |
||
2 | 2 | |
3 | 3 | global $post; |
4 | 4 | |
5 | -$classypost = new \Classy\Models\Post( $post ); |
|
5 | +$classypost = new \Classy\Models\Post($post); |
|
6 | 6 | |
7 | -Classy\Classy::render( 'layout.comments', array( 'post' => $classypost ) ); |
|
7 | +Classy\Classy::render('layout.comments', array('post' => $classypost)); |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @param int $uid User id. |
68 | 68 | */ |
69 | - public function __construct( $uid = null ) { |
|
70 | - $this->ID = $this->verify_id( $uid ); |
|
69 | + public function __construct($uid = null) { |
|
70 | + $this->ID = $this->verify_id($uid); |
|
71 | 71 | |
72 | 72 | $this->init(); |
73 | 73 | } |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @return int |
81 | 81 | */ |
82 | - private function verify_id( $uid ) { |
|
82 | + private function verify_id($uid) { |
|
83 | 83 | // @todo: Realize this method. |
84 | 84 | return $uid; |
85 | 85 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | private function init() { |
91 | 91 | $this->object = $this->get_object(); |
92 | 92 | |
93 | - $this->import( $this->object ); |
|
93 | + $this->import($this->object); |
|
94 | 94 | |
95 | 95 | $this->setup_user_name(); |
96 | 96 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @return object |
102 | 102 | */ |
103 | 103 | private function get_object() { |
104 | - return get_user_by( 'id', $this->ID ); |
|
104 | + return get_user_by('id', $this->ID); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | /** |
@@ -155,8 +155,8 @@ discard block |
||
155 | 155 | * @return string |
156 | 156 | */ |
157 | 157 | public function link() { |
158 | - if ( ! $this->link ) { |
|
159 | - $this->link = get_author_posts_url( $this->ID ); |
|
158 | + if (!$this->link) { |
|
159 | + $this->link = get_author_posts_url($this->ID); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | return $this->link; |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | */ |
168 | 168 | private function setup_user_name() { |
169 | 169 | $this->name = 'Anonymous'; |
170 | - if ( isset( $this->object->first_name ) && isset( $this->object->last_name ) ) { |
|
171 | - $this->name = $this->object->first_name . ' ' . $this->object->last_name; |
|
170 | + if (isset($this->object->first_name) && isset($this->object->last_name)) { |
|
171 | + $this->name = $this->object->first_name.' '.$this->object->last_name; |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | $this->display_name = $this->object->display_name; |
@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | |
30 | 30 | $request = Hierarchy::get_current_request(); |
31 | 31 | |
32 | - $file = Hierarchy::get_available_file( 'view', $request ); |
|
32 | + $file = Hierarchy::get_available_file('view', $request); |
|
33 | 33 | |
34 | - $view = self::get_blade_view( $file ); |
|
34 | + $view = self::get_blade_view($file); |
|
35 | 35 | |
36 | 36 | return $view; |
37 | 37 | |
@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return string |
46 | 46 | */ |
47 | - public static function get_blade_view( $view ) { |
|
47 | + public static function get_blade_view($view) { |
|
48 | 48 | |
49 | - return str_replace( '/', '.', $view ); |
|
49 | + return str_replace('/', '.', $view); |
|
50 | 50 | |
51 | 51 | } |
52 | 52 | |
@@ -59,21 +59,21 @@ discard block |
||
59 | 59 | |
60 | 60 | $templates = array(); |
61 | 61 | |
62 | - $files = (array) glob( CLASSY_THEME_PATH . '/' . self::$folder . '/*/*.blade.php' ); |
|
62 | + $files = (array) glob(CLASSY_THEME_PATH.'/'.self::$folder.'/*/*.blade.php'); |
|
63 | 63 | |
64 | - foreach ( $files as $filename ) { |
|
64 | + foreach ($files as $filename) { |
|
65 | 65 | |
66 | - if ( ! empty( $filename ) ) { |
|
66 | + if (!empty($filename)) { |
|
67 | 67 | |
68 | - if ( ! preg_match( '/\{\{\-\-\s*Template Name:(.*)\s*\-\-\}\}/mi', file_get_contents( $filename ), $header ) ) { continue; } |
|
68 | + if (!preg_match('/\{\{\-\-\s*Template Name:(.*)\s*\-\-\}\}/mi', file_get_contents($filename), $header)) { continue; } |
|
69 | 69 | |
70 | - $template_name = trim( $header[1] ); |
|
70 | + $template_name = trim($header[1]); |
|
71 | 71 | |
72 | - preg_match( '/\/([^\/]*)\.blade.php$/is', $filename, $filename_match ); |
|
72 | + preg_match('/\/([^\/]*)\.blade.php$/is', $filename, $filename_match); |
|
73 | 73 | |
74 | - $template_file = 'classy-' . $filename_match[1]; |
|
74 | + $template_file = 'classy-'.$filename_match[1]; |
|
75 | 75 | |
76 | - $templates[ $template_file ] = $template_name; |
|
76 | + $templates[$template_file] = $template_name; |
|
77 | 77 | |
78 | 78 | } |
79 | 79 | } |
@@ -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', CLASSY_THEME_DIR . 'assets/css/general.css', array(), CLASSY_THEME_VERSION, 'all' ); |
|
30 | + wp_register_style('general_css', CLASSY_THEME_DIR.'assets/css/general.css', array(), CLASSY_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', CLASSY_THEME_DIR . 'assets/js/min/production.js', array( 'jquery' ), CLASSY_THEME_VERSION, true ); |
|
41 | + wp_register_script('theme_scripts', CLASSY_THEME_DIR.'assets/js/min/production.js', array('jquery'), CLASSY_THEME_VERSION, true); |
|
42 | 42 | |
43 | 43 | } else { |
44 | 44 | |
45 | - wp_register_script( 'theme_scripts', CLASSY_THEME_DIR . 'assets/js/scripts.js', array( 'jquery' ), CLASSY_THEME_VERSION, true ); |
|
45 | + wp_register_script('theme_scripts', CLASSY_THEME_DIR.'assets/js/scripts.js', array('jquery'), CLASSY_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' => CLASSY_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 | /* |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public static function get_instance() { |
34 | 34 | |
35 | - if ( null === self::$single_instance ) { |
|
35 | + if (null === self::$single_instance) { |
|
36 | 36 | |
37 | 37 | self::$single_instance = new self(); |
38 | 38 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | |
59 | 59 | $this->init_config(); |
60 | 60 | |
61 | - add_filter( 'theme_page_templates', array( $this, 'filter_templates' ) ); |
|
61 | + add_filter('theme_page_templates', array($this, 'filter_templates')); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * Load template functions. |
73 | 73 | */ |
74 | 74 | private function load_template_function() { |
75 | - require_once( CLASSY_THEME_PATH . 'app/functions/template-functions.php' ); |
|
75 | + require_once(CLASSY_THEME_PATH.'app/functions/template-functions.php'); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -85,13 +85,13 @@ discard block |
||
85 | 85 | |
86 | 86 | $theme = wp_get_theme(); |
87 | 87 | |
88 | - define( 'CLASSY_THEME', $theme->template ); |
|
89 | - define( 'CLASSY_THEME_NAME', $theme->get( 'Name' ) ); |
|
90 | - define( 'CLASSY_THEME_PATH', get_template_directory() . '/' ); |
|
91 | - define( 'CLASSY_THEME_DIR', get_template_directory_uri() . '/' ); |
|
92 | - define( 'CLASSY_THEME_VERSION', $theme->get( 'Version' ) ); |
|
93 | - define( 'CLASSY_THEME_FRAMEWORK_PATH', CLASSY_THEME_PATH . 'app/' ); |
|
94 | - define( 'CLASSY_THEME_FRAMEWORK_DIR', CLASSY_THEME_DIR . 'app/' ); |
|
88 | + define('CLASSY_THEME', $theme->template); |
|
89 | + define('CLASSY_THEME_NAME', $theme->get('Name')); |
|
90 | + define('CLASSY_THEME_PATH', get_template_directory().'/'); |
|
91 | + define('CLASSY_THEME_DIR', get_template_directory_uri().'/'); |
|
92 | + define('CLASSY_THEME_VERSION', $theme->get('Version')); |
|
93 | + define('CLASSY_THEME_FRAMEWORK_PATH', CLASSY_THEME_PATH.'app/'); |
|
94 | + define('CLASSY_THEME_FRAMEWORK_DIR', CLASSY_THEME_DIR.'app/'); |
|
95 | 95 | |
96 | 96 | } |
97 | 97 | |
@@ -109,11 +109,11 @@ discard block |
||
109 | 109 | * |
110 | 110 | * @return array |
111 | 111 | */ |
112 | - public function filter_templates( $page_templates = array() ) { |
|
112 | + public function filter_templates($page_templates = array()) { |
|
113 | 113 | |
114 | 114 | $custom_templates = View::get_page_templates_list(); |
115 | 115 | |
116 | - return array_merge( $page_templates, $custom_templates ); |
|
116 | + return array_merge($page_templates, $custom_templates); |
|
117 | 117 | |
118 | 118 | } |
119 | 119 | |
@@ -124,11 +124,11 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @return mixed|bool Return false if variable not found. |
126 | 126 | */ |
127 | - public static function get_config_var( $name ) { |
|
127 | + public static function get_config_var($name) { |
|
128 | 128 | |
129 | 129 | $vars = Config::get_vars(); |
130 | 130 | |
131 | - return ( isset( $vars[ $name ] ) ) ? $vars[ $name ] : false; |
|
131 | + return (isset($vars[$name])) ? $vars[$name] : false; |
|
132 | 132 | |
133 | 133 | } |
134 | 134 | |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | */ |
140 | 140 | public static function textdomain() { |
141 | 141 | |
142 | - $textdomain = Classy::get_config_var( 'textdomain' ); |
|
142 | + $textdomain = Classy::get_config_var('textdomain'); |
|
143 | 143 | |
144 | 144 | return $textdomain ? $textdomain : CLASSY_THEME; |
145 | 145 | |
@@ -154,17 +154,17 @@ discard block |
||
154 | 154 | * @param array|null $data Additional params. |
155 | 155 | * @return void |
156 | 156 | */ |
157 | - public static function render( $view = null, $data = null ) { |
|
157 | + public static function render($view = null, $data = null) { |
|
158 | 158 | |
159 | - $views = CLASSY_THEME_PATH . View::$folder; |
|
160 | - $cache = WP_CONTENT_DIR . '/viewcache'; |
|
159 | + $views = CLASSY_THEME_PATH.View::$folder; |
|
160 | + $cache = WP_CONTENT_DIR.'/viewcache'; |
|
161 | 161 | $common_scope = Scope::get_common_scope(); |
162 | 162 | |
163 | - if ( null !== $view && is_string( $view ) ) { |
|
163 | + if (null !== $view && is_string($view)) { |
|
164 | 164 | |
165 | - if ( $data && is_array( $data ) ) { |
|
165 | + if ($data && is_array($data)) { |
|
166 | 166 | |
167 | - $scope = array_merge( $common_scope, $data ); |
|
167 | + $scope = array_merge($common_scope, $data); |
|
168 | 168 | |
169 | 169 | } else { |
170 | 170 | |
@@ -179,9 +179,9 @@ discard block |
||
179 | 179 | |
180 | 180 | } |
181 | 181 | |
182 | - $renderer = new BladeRenderer( $views, array( 'cache_path' => $cache ) ); |
|
182 | + $renderer = new BladeRenderer($views, array('cache_path' => $cache)); |
|
183 | 183 | |
184 | - echo $renderer->render( $view, $scope ); // XSS: xss ok. |
|
184 | + echo $renderer->render($view, $scope); // XSS: xss ok. |
|
185 | 185 | |
186 | 186 | } |
187 | 187 | |
@@ -206,27 +206,27 @@ discard block |
||
206 | 206 | * |
207 | 207 | * @return array |
208 | 208 | */ |
209 | - public static function get_posts( $args = false, $return = '\Classy\Models\Post' ) { |
|
209 | + public static function get_posts($args = false, $return = '\Classy\Models\Post') { |
|
210 | 210 | |
211 | 211 | $_return = array(); |
212 | 212 | |
213 | - $query = Query_Helper::find_query( $args ); |
|
213 | + $query = Query_Helper::find_query($args); |
|
214 | 214 | |
215 | - if ( isset( $query->posts ) ) { |
|
215 | + if (isset($query->posts)) { |
|
216 | 216 | |
217 | - foreach ( $query->posts as $post ) { |
|
217 | + foreach ($query->posts as $post) { |
|
218 | 218 | |
219 | - if ( 'id' === $return ) { |
|
219 | + if ('id' === $return) { |
|
220 | 220 | |
221 | 221 | $_return[] = $post->id; |
222 | 222 | |
223 | - } elseif ( 'object' === $return ) { |
|
223 | + } elseif ('object' === $return) { |
|
224 | 224 | |
225 | 225 | $_return[] = $post; |
226 | 226 | |
227 | - } elseif ( class_exists( $return ) ) { |
|
227 | + } elseif (class_exists($return)) { |
|
228 | 228 | |
229 | - $_return[] = new $return( $post ); |
|
229 | + $_return[] = new $return($post); |
|
230 | 230 | |
231 | 231 | } |
232 | 232 | } |
@@ -244,11 +244,11 @@ discard block |
||
244 | 244 | * |
245 | 245 | * @return mixed |
246 | 246 | */ |
247 | - public static function get_post( $args = false, $return_type = '\Classy\Models\Post' ) { |
|
247 | + public static function get_post($args = false, $return_type = '\Classy\Models\Post') { |
|
248 | 248 | |
249 | - $posts = self::get_posts( $args, $return_type ); |
|
249 | + $posts = self::get_posts($args, $return_type); |
|
250 | 250 | |
251 | - if ( $post = reset( $posts ) ) { |
|
251 | + if ($post = reset($posts)) { |
|
252 | 252 | return $post; |
253 | 253 | } |
254 | 254 | |
@@ -261,62 +261,62 @@ discard block |
||
261 | 261 | * |
262 | 262 | * @return array mixed |
263 | 263 | */ |
264 | - public static function get_pagination( $prefs = array() ) { |
|
264 | + public static function get_pagination($prefs = array()) { |
|
265 | 265 | |
266 | 266 | global $wp_query; |
267 | 267 | global $paged; |
268 | 268 | global $wp_rewrite; |
269 | 269 | |
270 | 270 | $args = array(); |
271 | - $args['total'] = ceil( $wp_query->found_posts / $wp_query->query_vars['posts_per_page'] ); |
|
271 | + $args['total'] = ceil($wp_query->found_posts / $wp_query->query_vars['posts_per_page']); |
|
272 | 272 | |
273 | - if ( $wp_rewrite->using_permalinks() ) { |
|
273 | + if ($wp_rewrite->using_permalinks()) { |
|
274 | 274 | |
275 | - $url = explode( '?', get_pagenum_link( 0 ) ); |
|
275 | + $url = explode('?', get_pagenum_link(0)); |
|
276 | 276 | |
277 | - if ( isset( $url[1] ) ) { |
|
278 | - parse_str( $url[1], $query ); |
|
277 | + if (isset($url[1])) { |
|
278 | + parse_str($url[1], $query); |
|
279 | 279 | $args['add_args'] = $query; |
280 | 280 | } |
281 | 281 | |
282 | 282 | $args['format'] = 'page/%#%'; |
283 | - $args['base'] = trailingslashit( $url[0] ).'%_%'; |
|
283 | + $args['base'] = trailingslashit($url[0]).'%_%'; |
|
284 | 284 | |
285 | 285 | } else { |
286 | 286 | $big = 999999999; |
287 | - $args['base'] = str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ); |
|
287 | + $args['base'] = str_replace($big, '%#%', esc_url(get_pagenum_link($big))); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | $args['type'] = 'array'; |
291 | - $args['current'] = max( 1, get_query_var( 'paged' ) ); |
|
292 | - $args['mid_size'] = max( 9 - $args['current'], 3 ); |
|
291 | + $args['current'] = max(1, get_query_var('paged')); |
|
292 | + $args['mid_size'] = max(9 - $args['current'], 3); |
|
293 | 293 | $args['prev_next'] = false; |
294 | 294 | |
295 | - if ( is_int( $prefs ) ) { |
|
295 | + if (is_int($prefs)) { |
|
296 | 296 | $args['mid_size'] = $prefs - 2; |
297 | 297 | } else { |
298 | - $args = array_merge( $args, $prefs ); |
|
298 | + $args = array_merge($args, $prefs); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | $data = array(); |
302 | - $data['pages'] = Helper::paginate_links( $args ); |
|
303 | - $next = get_next_posts_page_link( $args['total'] ); |
|
302 | + $data['pages'] = Helper::paginate_links($args); |
|
303 | + $next = get_next_posts_page_link($args['total']); |
|
304 | 304 | |
305 | - if ( $next ) { |
|
306 | - $data['next'] = array( 'link' => untrailingslashit( $next ), 'class' => 'page-numbers next' ); |
|
305 | + if ($next) { |
|
306 | + $data['next'] = array('link' => untrailingslashit($next), 'class' => 'page-numbers next'); |
|
307 | 307 | } |
308 | 308 | |
309 | - $prev = previous_posts( false ); |
|
309 | + $prev = previous_posts(false); |
|
310 | 310 | |
311 | - if ( $prev ) { |
|
312 | - $data['prev'] = array( 'link' => untrailingslashit( $prev ), 'class' => 'page-numbers prev' ); |
|
311 | + if ($prev) { |
|
312 | + $data['prev'] = array('link' => untrailingslashit($prev), 'class' => 'page-numbers prev'); |
|
313 | 313 | } |
314 | 314 | |
315 | - if ( $paged < 2 ) { |
|
315 | + if ($paged < 2) { |
|
316 | 316 | $data['prev'] = null; |
317 | 317 | } |
318 | 318 | |
319 | - return Helper::array_to_object( $data ); |
|
319 | + return Helper::array_to_object($data); |
|
320 | 320 | |
321 | 321 | } |
322 | 322 | } |
@@ -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,7 +239,7 @@ 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 | $views[] = 'front-page.front-page'; |
245 | 245 | $views[] = 'front-page'; |
@@ -247,37 +247,37 @@ discard block |
||
247 | 247 | $views[] = 'home.home'; |
248 | 248 | $views[] = 'home'; |
249 | 249 | |
250 | - $views = array_merge( $views, self::get_request_hierarchy_list( 'post_type_archive' ) ); |
|
250 | + $views = array_merge($views, self::get_request_hierarchy_list('post_type_archive')); |
|
251 | 251 | |
252 | - elseif ( 'classy-template' === $type ) : |
|
252 | + elseif ('classy-template' === $type) : |
|
253 | 253 | |
254 | 254 | $template = self::get_classy_template(); |
255 | 255 | |
256 | 256 | $views[] = $template; |
257 | - $views[] = 'page.' . $template; |
|
258 | - $views[] = 'template.' . $template; |
|
257 | + $views[] = 'page.'.$template; |
|
258 | + $views[] = 'template.'.$template; |
|
259 | 259 | $views[] = 'page.page'; |
260 | 260 | $views[] = 'page'; |
261 | 261 | |
262 | - elseif ( 'page' === $type ) : |
|
262 | + elseif ('page' === $type) : |
|
263 | 263 | |
264 | 264 | $id = get_queried_object_id(); |
265 | 265 | |
266 | - $pagename = get_query_var( 'pagename' ); |
|
266 | + $pagename = get_query_var('pagename'); |
|
267 | 267 | |
268 | - if ( ! $pagename && $id ) { |
|
268 | + if (!$pagename && $id) { |
|
269 | 269 | // If a static page is set as the front page, $pagename will not be set. Retrieve it from the queried object. |
270 | - if ( $post = get_queried_object() ) { |
|
270 | + if ($post = get_queried_object()) { |
|
271 | 271 | $pagename = $post->post_name; |
272 | 272 | } |
273 | 273 | } |
274 | 274 | |
275 | - if ( $pagename ) { |
|
276 | - $views[] = 'page.' . $pagename; |
|
275 | + if ($pagename) { |
|
276 | + $views[] = 'page.'.$pagename; |
|
277 | 277 | } |
278 | 278 | |
279 | - if ( $id ) { |
|
280 | - $views[] = 'page.' . $id; |
|
279 | + if ($id) { |
|
280 | + $views[] = 'page.'.$id; |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | $views[] = 'page.page'; |
@@ -309,9 +309,9 @@ discard block |
||
309 | 309 | * @return mixed |
310 | 310 | */ |
311 | 311 | public static function get_classy_template() { |
312 | - preg_match( '/classy\-(.*)/', get_page_template_slug(), $matches ); |
|
312 | + preg_match('/classy\-(.*)/', get_page_template_slug(), $matches); |
|
313 | 313 | |
314 | - if ( ! empty( $matches ) && isset( $matches[1] ) ) { |
|
314 | + if (!empty($matches) && isset($matches[1])) { |
|
315 | 315 | return $matches[1]; |
316 | 316 | } |
317 | 317 |