@@ -259,7 +259,7 @@ |
||
259 | 259 | * |
260 | 260 | * @param array $prefs Args for paginate_links. |
261 | 261 | * |
262 | - * @return array mixed |
|
262 | + * @return \stdClass mixed |
|
263 | 263 | */ |
264 | 264 | public static function get_pagination( $prefs = array() ) { |
265 | 265 |
@@ -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 | } |
@@ -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 |
@@ -94,7 +94,7 @@ |
||
94 | 94 | /** |
95 | 95 | * Returns User object of comment author |
96 | 96 | * |
97 | - * @return object User |
|
97 | + * @return Models\User User |
|
98 | 98 | */ |
99 | 99 | public function author() { |
100 | 100 |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | * |
82 | 82 | * @param \WP_Comment $item |
83 | 83 | */ |
84 | - public function __construct( $item ) { |
|
84 | + public function __construct($item) { |
|
85 | 85 | |
86 | - if ( is_a( $item, '\WP_Comment' ) ) { |
|
86 | + if (is_a($item, '\WP_Comment')) { |
|
87 | 87 | |
88 | - $this->import( $item ); |
|
88 | + $this->import($item); |
|
89 | 89 | |
90 | 90 | } |
91 | 91 | |
@@ -98,15 +98,15 @@ discard block |
||
98 | 98 | */ |
99 | 99 | public function author() { |
100 | 100 | |
101 | - if ( $this->user_id ) { |
|
101 | + if ($this->user_id) { |
|
102 | 102 | |
103 | - return new Models\User( $this->user_id ); |
|
103 | + return new Models\User($this->user_id); |
|
104 | 104 | |
105 | 105 | } else { |
106 | 106 | |
107 | - $author = new Models\User( 0 ); |
|
107 | + $author = new Models\User(0); |
|
108 | 108 | |
109 | - if ( isset( $this->comment_author ) && $this->comment_author ) { |
|
109 | + if (isset($this->comment_author) && $this->comment_author) { |
|
110 | 110 | |
111 | 111 | $author->name = $this->comment_author; |
112 | 112 | |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | * @return string |
124 | 124 | */ |
125 | 125 | public function content() { |
126 | - return apply_filters( 'get_comment_text ', $this->comment_content ); |
|
126 | + return apply_filters('get_comment_text ', $this->comment_content); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -141,11 +141,11 @@ discard block |
||
141 | 141 | * @param string $date_format |
142 | 142 | * @return string |
143 | 143 | */ |
144 | - public function date( $date_format = '' ) { |
|
145 | - $df = $date_format ? $date_format : get_option( 'date_format' ); |
|
146 | - $the_date = (string) mysql2date( $df, $this->comment_date ); |
|
144 | + public function date($date_format = '') { |
|
145 | + $df = $date_format ? $date_format : get_option('date_format'); |
|
146 | + $the_date = (string) mysql2date($df, $this->comment_date); |
|
147 | 147 | |
148 | - return apply_filters( 'get_comment_date ', $the_date, $df ); |
|
148 | + return apply_filters('get_comment_date ', $the_date, $df); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -164,26 +164,26 @@ discard block |
||
164 | 164 | * @param string $default |
165 | 165 | * @return string |
166 | 166 | */ |
167 | - public function avatar( $size = 92, $default = '' ) { |
|
167 | + public function avatar($size = 92, $default = '') { |
|
168 | 168 | |
169 | - if ( ! get_option( 'show_avatars' ) ) { |
|
169 | + if (!get_option('show_avatars')) { |
|
170 | 170 | return false; |
171 | 171 | } |
172 | 172 | |
173 | - if ( ! is_numeric( $size ) ) { $size = '92'; } |
|
173 | + if (!is_numeric($size)) { $size = '92'; } |
|
174 | 174 | |
175 | 175 | $email = $this->get_avatar_email(); |
176 | 176 | $email_hash = ''; |
177 | 177 | |
178 | - if ( ! empty( $email ) ) { |
|
179 | - $email_hash = md5( strtolower( trim( $email ) ) ); |
|
178 | + if (!empty($email)) { |
|
179 | + $email_hash = md5(strtolower(trim($email))); |
|
180 | 180 | } |
181 | 181 | |
182 | - $host = $this->get_avatar_host( $email_hash ); |
|
183 | - $default = $this->get_default_avatar( $default, $email, $size, $host ); |
|
182 | + $host = $this->get_avatar_host($email_hash); |
|
183 | + $default = $this->get_default_avatar($default, $email, $size, $host); |
|
184 | 184 | |
185 | - if ( ! empty( $email ) ) { |
|
186 | - $avatar = $this->get_avatar_url( $default, $host, $email_hash, $size ); |
|
185 | + if (!empty($email)) { |
|
186 | + $avatar = $this->get_avatar_url($default, $host, $email_hash, $size); |
|
187 | 187 | } else { |
188 | 188 | $avatar = $default; |
189 | 189 | } |
@@ -200,9 +200,9 @@ discard block |
||
200 | 200 | protected function get_avatar_email() { |
201 | 201 | |
202 | 202 | $id = (int) $this->user_id; |
203 | - $user = get_userdata( $id ); |
|
203 | + $user = get_userdata($id); |
|
204 | 204 | |
205 | - if ( $user ) { |
|
205 | + if ($user) { |
|
206 | 206 | $email = $user->user_email; |
207 | 207 | } else { |
208 | 208 | $email = $this->comment_author_email; |
@@ -221,32 +221,32 @@ discard block |
||
221 | 221 | * @param string $host |
222 | 222 | * @return string |
223 | 223 | */ |
224 | - protected function get_default_avatar( $default, $email, $size, $host ) { |
|
224 | + protected function get_default_avatar($default, $email, $size, $host) { |
|
225 | 225 | |
226 | - if ( '/' === substr( $default, 0, 1 ) ) { |
|
227 | - $default = home_url() . $default; |
|
226 | + if ('/' === substr($default, 0, 1)) { |
|
227 | + $default = home_url().$default; |
|
228 | 228 | } |
229 | 229 | |
230 | - if ( empty( $default ) ) { |
|
231 | - $avatar_default = get_option( 'avatar_default' ); |
|
232 | - if ( empty( $avatar_default ) ) { |
|
230 | + if (empty($default)) { |
|
231 | + $avatar_default = get_option('avatar_default'); |
|
232 | + if (empty($avatar_default)) { |
|
233 | 233 | $default = 'mystery'; |
234 | 234 | } else { |
235 | 235 | $default = $avatar_default; |
236 | 236 | } |
237 | 237 | } |
238 | 238 | |
239 | - if ( 'mystery' === $default ) { |
|
240 | - $default = $host . '/avatar/ad516503a11cd5ca435acc9bb6523536?s=' . $size; |
|
239 | + if ('mystery' === $default) { |
|
240 | + $default = $host.'/avatar/ad516503a11cd5ca435acc9bb6523536?s='.$size; |
|
241 | 241 | // ad516503a11cd5ca435acc9bb6523536 == md5('[email protected]') |
242 | - } else if ( 'blank' === $default ) { |
|
243 | - $default = $email ? 'blank' : includes_url( 'images/blank.gif' ); |
|
244 | - } else if ( ! empty( $email ) && 'gravatar_default' === $default ) { |
|
242 | + } else if ('blank' === $default) { |
|
243 | + $default = $email ? 'blank' : includes_url('images/blank.gif'); |
|
244 | + } else if (!empty($email) && 'gravatar_default' === $default) { |
|
245 | 245 | $default = ''; |
246 | - } else if ( 'gravatar_default' === $default ) { |
|
247 | - $default = $host . '/avatar/?s=' . $size; |
|
248 | - } else if ( empty( $email ) && ! strstr( $default, 'http://' ) ) { |
|
249 | - $default = $host . '/avatar/?d=' . $default . '&s=' . $size; |
|
246 | + } else if ('gravatar_default' === $default) { |
|
247 | + $default = $host.'/avatar/?s='.$size; |
|
248 | + } else if (empty($email) && !strstr($default, 'http://')) { |
|
249 | + $default = $host.'/avatar/?d='.$default.'&s='.$size; |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | return $default; |
@@ -259,13 +259,13 @@ discard block |
||
259 | 259 | * @param string $email_hash |
260 | 260 | * @return string |
261 | 261 | */ |
262 | - protected function get_avatar_host( $email_hash ) { |
|
262 | + protected function get_avatar_host($email_hash) { |
|
263 | 263 | |
264 | - if ( is_ssl() ) { |
|
264 | + if (is_ssl()) { |
|
265 | 265 | $host = 'https://secure.gravatar.com'; |
266 | 266 | } else { |
267 | - if ( ! empty( $email_hash ) ) { |
|
268 | - $host = sprintf( 'http://%d.gravatar.com', (hexdec( $email_hash[0] ) % 2) ); |
|
267 | + if (!empty($email_hash)) { |
|
268 | + $host = sprintf('http://%d.gravatar.com', (hexdec($email_hash[0]) % 2)); |
|
269 | 269 | } else { |
270 | 270 | $host = 'http://0.gravatar.com'; |
271 | 271 | } |
@@ -284,16 +284,16 @@ discard block |
||
284 | 284 | * @param int $size |
285 | 285 | * @return string |
286 | 286 | */ |
287 | - protected function get_avatar_url( $default, $host, $email_hash, $size ) { |
|
287 | + protected function get_avatar_url($default, $host, $email_hash, $size) { |
|
288 | 288 | |
289 | - $_return = $host . '/avatar/' . $email_hash . '?s=' . $size . '&d=' . urlencode( $default ); |
|
290 | - $rating = get_option( 'avatar_rating' ); |
|
289 | + $_return = $host.'/avatar/'.$email_hash.'?s='.$size.'&d='.urlencode($default); |
|
290 | + $rating = get_option('avatar_rating'); |
|
291 | 291 | |
292 | - if ( ! empty( $rating ) ) { |
|
293 | - $_return .= '&r=' . $rating; |
|
292 | + if (!empty($rating)) { |
|
293 | + $_return .= '&r='.$rating; |
|
294 | 294 | } |
295 | 295 | |
296 | - return str_replace( '&', '&', esc_url( $_return ) ); |
|
296 | + return str_replace('&', '&', esc_url($_return)); |
|
297 | 297 | |
298 | 298 | } |
299 | 299 | |
@@ -302,12 +302,12 @@ discard block |
||
302 | 302 | * |
303 | 303 | * @param Comment $comment |
304 | 304 | */ |
305 | - public function add_child( $comment ) { |
|
305 | + public function add_child($comment) { |
|
306 | 306 | |
307 | 307 | $this->children[] = $comment; |
308 | 308 | $item->level = $this->level + 1; |
309 | 309 | |
310 | - if ( $item->children ) { |
|
310 | + if ($item->children) { |
|
311 | 311 | $this->update_child_levels(); |
312 | 312 | } |
313 | 313 | |
@@ -321,9 +321,9 @@ discard block |
||
321 | 321 | */ |
322 | 322 | protected function update_child_levels() { |
323 | 323 | |
324 | - if ( is_array( $this->children ) ) { |
|
324 | + if (is_array($this->children)) { |
|
325 | 325 | |
326 | - foreach ( $this->children as $child ) { |
|
326 | + foreach ($this->children as $child) { |
|
327 | 327 | $child->level = $this->level + 1; |
328 | 328 | $child->update_child_levels(); |
329 | 329 | } |
@@ -101,7 +101,8 @@ discard block |
||
101 | 101 | |
102 | 102 | return new ClassyUser( $this->user_id ); |
103 | 103 | |
104 | - } else { |
|
104 | + } |
|
105 | + else { |
|
105 | 106 | |
106 | 107 | $author = new ClassyUser( 0 ); |
107 | 108 | |
@@ -183,7 +184,8 @@ discard block |
||
183 | 184 | |
184 | 185 | if ( ! empty( $email ) ) { |
185 | 186 | $avatar = $this->get_avatar_url( $default, $host, $email_hash, $size ); |
186 | - } else { |
|
187 | + } |
|
188 | + else { |
|
187 | 189 | $avatar = $default; |
188 | 190 | } |
189 | 191 | |
@@ -203,7 +205,8 @@ discard block |
||
203 | 205 | |
204 | 206 | if ( $user ) { |
205 | 207 | $email = $user->user_email; |
206 | - } else { |
|
208 | + } |
|
209 | + else { |
|
207 | 210 | $email = $this->comment_author_email; |
208 | 211 | } |
209 | 212 | |
@@ -230,7 +233,8 @@ discard block |
||
230 | 233 | $avatar_default = get_option( 'avatar_default' ); |
231 | 234 | if ( empty( $avatar_default ) ) { |
232 | 235 | $default = 'mystery'; |
233 | - } else { |
|
236 | + } |
|
237 | + else { |
|
234 | 238 | $default = $avatar_default; |
235 | 239 | } |
236 | 240 | } |
@@ -238,13 +242,17 @@ discard block |
||
238 | 242 | if ( 'mystery' === $default ) { |
239 | 243 | $default = $host . '/avatar/ad516503a11cd5ca435acc9bb6523536?s=' . $size; |
240 | 244 | // ad516503a11cd5ca435acc9bb6523536 == md5('[email protected]') |
241 | - } else if ( 'blank' === $default ) { |
|
245 | + } |
|
246 | + else if ( 'blank' === $default ) { |
|
242 | 247 | $default = $email ? 'blank' : includes_url( 'images/blank.gif' ); |
243 | - } else if ( ! empty( $email ) && 'gravatar_default' === $default ) { |
|
248 | + } |
|
249 | + else if ( ! empty( $email ) && 'gravatar_default' === $default ) { |
|
244 | 250 | $default = ''; |
245 | - } else if ( 'gravatar_default' === $default ) { |
|
251 | + } |
|
252 | + else if ( 'gravatar_default' === $default ) { |
|
246 | 253 | $default = $host . '/avatar/?s=' . $size; |
247 | - } else if ( empty( $email ) && ! strstr( $default, 'http://' ) ) { |
|
254 | + } |
|
255 | + else if ( empty( $email ) && ! strstr( $default, 'http://' ) ) { |
|
248 | 256 | $default = $host . '/avatar/?d=' . $default . '&s=' . $size; |
249 | 257 | } |
250 | 258 | |
@@ -262,10 +270,12 @@ discard block |
||
262 | 270 | |
263 | 271 | if ( is_ssl() ) { |
264 | 272 | $host = 'https://secure.gravatar.com'; |
265 | - } else { |
|
273 | + } |
|
274 | + else { |
|
266 | 275 | if ( ! empty( $email_hash ) ) { |
267 | 276 | $host = sprintf( 'http://%d.gravatar.com', (hexdec( $email_hash[0] ) % 2) ); |
268 | - } else { |
|
277 | + } |
|
278 | + else { |
|
269 | 279 | $host = 'http://0.gravatar.com'; |
270 | 280 | } |
271 | 281 | } |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * |
14 | 14 | * @param string $text |
15 | 15 | * @param int $num_words |
16 | - * @param string|null|false $more text to appear in "Read more...". Null to use default, false to hide |
|
16 | + * @param boolean $more text to appear in "Read more...". Null to use default, false to hide |
|
17 | 17 | * @param string $allowed_tags |
18 | 18 | * @return string |
19 | 19 | */ |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | * Converts array to object recursively |
223 | 223 | * |
224 | 224 | * @param array $array |
225 | - * @return object |
|
225 | + * @return \stdClass |
|
226 | 226 | */ |
227 | 227 | public static function array_to_object( $array ) { |
228 | 228 | $obj = new \stdClass; |
@@ -247,57 +247,57 @@ |
||
247 | 247 | |
248 | 248 | $textdomain = Classy::textdomain(); |
249 | 249 | |
250 | - $archives_title = ''; |
|
250 | + $archives_title = ''; |
|
251 | 251 | |
252 | - if ( is_category() ) { |
|
252 | + if ( is_category() ) { |
|
253 | 253 | |
254 | - $archives_title = single_cat_title( '', false ); |
|
254 | + $archives_title = single_cat_title( '', false ); |
|
255 | 255 | |
256 | - } else if ( is_tag() ) { |
|
256 | + } else if ( is_tag() ) { |
|
257 | 257 | |
258 | - $archives_title = 'Tag: ' . single_tag_title( '', false ); |
|
258 | + $archives_title = 'Tag: ' . single_tag_title( '', false ); |
|
259 | 259 | |
260 | - } else if ( is_author() ) { |
|
260 | + } else if ( is_author() ) { |
|
261 | 261 | |
262 | - if ( have_posts() ) { |
|
262 | + if ( have_posts() ) { |
|
263 | 263 | |
264 | - the_post(); |
|
265 | - $archives_title = 'Author: ' . get_the_author(); |
|
264 | + the_post(); |
|
265 | + $archives_title = 'Author: ' . get_the_author(); |
|
266 | 266 | |
267 | - } |
|
267 | + } |
|
268 | 268 | |
269 | - rewind_posts(); |
|
269 | + rewind_posts(); |
|
270 | 270 | |
271 | - } else if ( is_search() ) { |
|
271 | + } else if ( is_search() ) { |
|
272 | 272 | |
273 | - $archives_title = sprintf( __( 'Search Results for: %s', $textdomain ), '<span>' . get_search_query() . '</span>' ); |
|
273 | + $archives_title = sprintf( __( 'Search Results for: %s', $textdomain ), '<span>' . get_search_query() . '</span>' ); |
|
274 | 274 | |
275 | - } else if ( is_archive() ) { |
|
275 | + } else if ( is_archive() ) { |
|
276 | 276 | |
277 | - if ( is_day() ) { |
|
277 | + if ( is_day() ) { |
|
278 | 278 | |
279 | - $archives_title = get_the_date(); |
|
279 | + $archives_title = get_the_date(); |
|
280 | 280 | |
281 | - } elseif ( is_month() ) { |
|
281 | + } elseif ( is_month() ) { |
|
282 | 282 | |
283 | - $archives_title = get_the_date( _x( 'F Y', 'monthly archives date format', $textdomain ) ); |
|
283 | + $archives_title = get_the_date( _x( 'F Y', 'monthly archives date format', $textdomain ) ); |
|
284 | 284 | |
285 | - } elseif ( is_year() ) { |
|
285 | + } elseif ( is_year() ) { |
|
286 | 286 | |
287 | - $archives_title = get_the_date( _x( 'Y', 'yearly archives date format', $textdomain ) ); |
|
287 | + $archives_title = get_the_date( _x( 'Y', 'yearly archives date format', $textdomain ) ); |
|
288 | 288 | |
289 | - } else { |
|
289 | + } else { |
|
290 | 290 | |
291 | - $archives_title = 'Archives'; |
|
291 | + $archives_title = 'Archives'; |
|
292 | 292 | |
293 | - } |
|
293 | + } |
|
294 | 294 | } else { |
295 | 295 | |
296 | - $archives_title = 'Archives'; |
|
296 | + $archives_title = 'Archives'; |
|
297 | 297 | |
298 | - } |
|
298 | + } |
|
299 | 299 | |
300 | - return $archives_title; |
|
300 | + return $archives_title; |
|
301 | 301 | |
302 | 302 | } |
303 | 303 | } |
@@ -15,44 +15,44 @@ discard block |
||
15 | 15 | * @param string $allowed_tags |
16 | 16 | * @return string |
17 | 17 | */ |
18 | - public static function trim_words( $text, $num_words = 55, $more = null, $allowed_tags = 'p a span b i br blockquote' ) { |
|
19 | - if ( null === $more ) { |
|
20 | - $more = __( '…' ); |
|
18 | + public static function trim_words($text, $num_words = 55, $more = null, $allowed_tags = 'p a span b i br blockquote') { |
|
19 | + if (null === $more) { |
|
20 | + $more = __('…'); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | $original_text = $text; |
24 | 24 | $allowed_tag_string = ''; |
25 | 25 | |
26 | - foreach ( explode( ' ', $allowed_tags ) as $tag ) { |
|
27 | - $allowed_tag_string .= '<' . $tag . '>'; |
|
26 | + foreach (explode(' ', $allowed_tags) as $tag) { |
|
27 | + $allowed_tag_string .= '<'.$tag.'>'; |
|
28 | 28 | } |
29 | 29 | |
30 | - $text = strip_tags( $text, $allowed_tag_string ); |
|
30 | + $text = strip_tags($text, $allowed_tag_string); |
|
31 | 31 | |
32 | 32 | /* translators: If your word count is based on single characters (East Asian characters), |
33 | 33 | enter 'characters'. Otherwise, enter 'words'. Do not translate into your own language. */ |
34 | 34 | |
35 | - if ( 'characters' === _x( 'words', 'word count: words or characters?' ) && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) { |
|
36 | - $text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $text ), ' ' ); |
|
37 | - preg_match_all( '/./u', $text, $words_array ); |
|
38 | - $words_array = array_slice( $words_array[0], 0, $num_words + 1 ); |
|
35 | + if ('characters' === _x('words', 'word count: words or characters?') && preg_match('/^utf\-?8$/i', get_option('blog_charset'))) { |
|
36 | + $text = trim(preg_replace("/[\n\r\t ]+/", ' ', $text), ' '); |
|
37 | + preg_match_all('/./u', $text, $words_array); |
|
38 | + $words_array = array_slice($words_array[0], 0, $num_words + 1); |
|
39 | 39 | $sep = ''; |
40 | 40 | } else { |
41 | - $words_array = preg_split( "/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY ); |
|
41 | + $words_array = preg_split("/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY); |
|
42 | 42 | $sep = ' '; |
43 | 43 | } |
44 | 44 | |
45 | - if ( count( $words_array ) > $num_words ) { |
|
46 | - array_pop( $words_array ); |
|
47 | - $text = implode( $sep, $words_array ); |
|
48 | - $text = $text . $more; |
|
45 | + if (count($words_array) > $num_words) { |
|
46 | + array_pop($words_array); |
|
47 | + $text = implode($sep, $words_array); |
|
48 | + $text = $text.$more; |
|
49 | 49 | } else { |
50 | - $text = implode( $sep, $words_array ); |
|
50 | + $text = implode($sep, $words_array); |
|
51 | 51 | } |
52 | 52 | |
53 | - $text = self::close_tags( $text ); |
|
53 | + $text = self::close_tags($text); |
|
54 | 54 | |
55 | - return apply_filters( 'wp_trim_words', $text, $num_words, $more, $original_text ); |
|
55 | + return apply_filters('wp_trim_words', $text, $num_words, $more, $original_text); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | |
@@ -62,36 +62,36 @@ discard block |
||
62 | 62 | * @param string $html |
63 | 63 | * @return string |
64 | 64 | */ |
65 | - public static function close_tags( $html ) { |
|
65 | + public static function close_tags($html) { |
|
66 | 66 | //put all opened tags into an array |
67 | - preg_match_all( '#<([a-z]+)(?: .*)?(?<![/|/ ])>#iU', $html, $result ); |
|
67 | + preg_match_all('#<([a-z]+)(?: .*)?(?<![/|/ ])>#iU', $html, $result); |
|
68 | 68 | |
69 | 69 | $openedtags = $result[1]; |
70 | 70 | |
71 | 71 | //put all closed tags into an array |
72 | - preg_match_all( '#</([a-z]+)>#iU', $html, $result ); |
|
72 | + preg_match_all('#</([a-z]+)>#iU', $html, $result); |
|
73 | 73 | |
74 | 74 | $closedtags = $result[1]; |
75 | - $len_opened = count( $openedtags ); |
|
75 | + $len_opened = count($openedtags); |
|
76 | 76 | |
77 | 77 | // all tags are closed |
78 | - if ( count( $closedtags ) === $len_opened ) { |
|
78 | + if (count($closedtags) === $len_opened) { |
|
79 | 79 | return $html; |
80 | 80 | } |
81 | 81 | |
82 | - $openedtags = array_reverse( $openedtags ); |
|
82 | + $openedtags = array_reverse($openedtags); |
|
83 | 83 | |
84 | 84 | // close tags |
85 | - for ( $i = 0; $i < $len_opened; $i++ ) { |
|
86 | - if ( ! in_array( $openedtags[ $i ], $closedtags, true ) ) { |
|
87 | - $html .= '</' . $openedtags[ $i ] . '>'; |
|
85 | + for ($i = 0; $i < $len_opened; $i++) { |
|
86 | + if (!in_array($openedtags[$i], $closedtags, true)) { |
|
87 | + $html .= '</'.$openedtags[$i].'>'; |
|
88 | 88 | } else { |
89 | - unset( $closedtags[ array_search( $openedtags[ $i ], $closedtags ) ] ); |
|
89 | + unset($closedtags[array_search($openedtags[$i], $closedtags)]); |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | |
93 | - $html = str_replace( array( '</br>', '</hr>', '</wbr>' ), '', $html ); |
|
94 | - $html = str_replace( array( '<br>', '<hr>', '<wbr>' ), array( '<br />', '<hr />', '<wbr />' ), $html ); |
|
93 | + $html = str_replace(array('</br>', '</hr>', '</wbr>'), '', $html); |
|
94 | + $html = str_replace(array('<br>', '<hr>', '<wbr>'), array('<br />', '<hr />', '<wbr />'), $html); |
|
95 | 95 | |
96 | 96 | return $html; |
97 | 97 | } |
@@ -103,14 +103,14 @@ discard block |
||
103 | 103 | * |
104 | 104 | * @return bool |
105 | 105 | */ |
106 | - public static function error_log( $arg ) { |
|
107 | - if ( ! WP_DEBUG ) { |
|
106 | + public static function error_log($arg) { |
|
107 | + if (!WP_DEBUG) { |
|
108 | 108 | return true; |
109 | 109 | } |
110 | - if ( is_object( $arg ) || is_array( $arg ) ) { |
|
111 | - $arg = print_r( $arg, true ); |
|
110 | + if (is_object($arg) || is_array($arg)) { |
|
111 | + $arg = print_r($arg, true); |
|
112 | 112 | } |
113 | - return error_log( $arg ); |
|
113 | + return error_log($arg); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * @param string $args |
120 | 120 | * @return array |
121 | 121 | */ |
122 | - public static function paginate_links( $args = '' ) { |
|
122 | + public static function paginate_links($args = '') { |
|
123 | 123 | $defaults = array( |
124 | 124 | 'base' => '%_%', // http://example.com/all_posts.php%_% : %_% is replaced by format (below) |
125 | 125 | 'format' => '?page=%#%', // ?page=%#% : %#% is replaced by the page number |
@@ -127,43 +127,43 @@ discard block |
||
127 | 127 | 'current' => 0, |
128 | 128 | 'show_all' => false, |
129 | 129 | 'prev_next' => true, |
130 | - 'prev_text' => __( '« Previous' ), |
|
131 | - 'next_text' => __( 'Next »' ), |
|
130 | + 'prev_text' => __('« Previous'), |
|
131 | + 'next_text' => __('Next »'), |
|
132 | 132 | 'end_size' => 1, |
133 | 133 | 'mid_size' => 2, |
134 | 134 | 'type' => 'array', |
135 | 135 | 'add_args' => false, // array of query args to add |
136 | 136 | 'add_fragment' => '', |
137 | 137 | ); |
138 | - $args = wp_parse_args( $args, $defaults ); |
|
138 | + $args = wp_parse_args($args, $defaults); |
|
139 | 139 | // Who knows what else people pass in $args |
140 | - $args['total'] = intval( (int) $args['total'] ); |
|
141 | - if ( $args['total'] < 2 ) { |
|
140 | + $args['total'] = intval((int) $args['total']); |
|
141 | + if ($args['total'] < 2) { |
|
142 | 142 | return array(); |
143 | 143 | } |
144 | 144 | $args['current'] = (int) $args['current']; |
145 | 145 | $args['end_size'] = 0 < (int) $args['end_size'] ? (int) $args['end_size'] : 1; // Out of bounds? Make it the default. |
146 | 146 | $args['mid_size'] = 0 <= (int) $args['mid_size'] ? (int) $args['mid_size'] : 2; |
147 | - $args['add_args'] = is_array( $args['add_args'] ) ? $args['add_args'] : false; |
|
147 | + $args['add_args'] = is_array($args['add_args']) ? $args['add_args'] : false; |
|
148 | 148 | $page_links = array(); |
149 | 149 | $dots = false; |
150 | - if ( $args['prev_next'] && $args['current'] && 1 < $args['current'] ) { |
|
151 | - $link = str_replace( '%_%', 2 === absint( $args['current'] ) ? '' : $args['format'], $args['base'] ); |
|
152 | - $link = str_replace( '%#%', $args['current'] - 1, $link ); |
|
153 | - if ( $args['add_args'] ) { |
|
154 | - $link = add_query_arg( $args['add_args'], $link ); |
|
150 | + if ($args['prev_next'] && $args['current'] && 1 < $args['current']) { |
|
151 | + $link = str_replace('%_%', 2 === absint($args['current']) ? '' : $args['format'], $args['base']); |
|
152 | + $link = str_replace('%#%', $args['current'] - 1, $link); |
|
153 | + if ($args['add_args']) { |
|
154 | + $link = add_query_arg($args['add_args'], $link); |
|
155 | 155 | } |
156 | 156 | $link .= $args['add_fragment']; |
157 | - $link = untrailingslashit( $link ); |
|
157 | + $link = untrailingslashit($link); |
|
158 | 158 | $page_links[] = array( |
159 | 159 | 'class' => 'prev page-numbers', |
160 | - 'link' => esc_url( apply_filters( 'paginate_links', $link ) ), |
|
160 | + 'link' => esc_url(apply_filters('paginate_links', $link)), |
|
161 | 161 | 'title' => $args['prev_text'], |
162 | 162 | ); |
163 | 163 | } |
164 | - for ( $n = 1; $n <= $args['total']; $n++ ) { |
|
165 | - $n_display = number_format_i18n( $n ); |
|
166 | - if ( absint( $args['current'] ) === $n ) { |
|
164 | + for ($n = 1; $n <= $args['total']; $n++) { |
|
165 | + $n_display = number_format_i18n($n); |
|
166 | + if (absint($args['current']) === $n) { |
|
167 | 167 | $page_links[] = array( |
168 | 168 | 'class' => 'page-number page-numbers current', |
169 | 169 | 'title' => $n_display, |
@@ -173,42 +173,42 @@ discard block |
||
173 | 173 | ); |
174 | 174 | $dots = true; |
175 | 175 | } else { |
176 | - if ( $args['show_all'] || ( $n <= $args['end_size'] || ( $args['current'] && $n >= $args['current'] - $args['mid_size'] && $n <= $args['current'] + $args['mid_size'] ) || $n > $args['total'] - $args['end_size'] ) ) { |
|
177 | - $link = str_replace( '%_%', 1 === absint( $n ) ? '' : $args['format'], $args['base'] ); |
|
178 | - $link = str_replace( '%#%', $n, $link ); |
|
179 | - $link = trailingslashit( $link ) . ltrim( $args['add_fragment'], '/' ); |
|
180 | - if ( $args['add_args'] ) { |
|
181 | - $link = rtrim( add_query_arg( $args['add_args'], $link ), '/' ); |
|
176 | + if ($args['show_all'] || ($n <= $args['end_size'] || ($args['current'] && $n >= $args['current'] - $args['mid_size'] && $n <= $args['current'] + $args['mid_size']) || $n > $args['total'] - $args['end_size'])) { |
|
177 | + $link = str_replace('%_%', 1 === absint($n) ? '' : $args['format'], $args['base']); |
|
178 | + $link = str_replace('%#%', $n, $link); |
|
179 | + $link = trailingslashit($link).ltrim($args['add_fragment'], '/'); |
|
180 | + if ($args['add_args']) { |
|
181 | + $link = rtrim(add_query_arg($args['add_args'], $link), '/'); |
|
182 | 182 | } |
183 | - $link = str_replace( ' ', '+', $link ); |
|
184 | - $link = untrailingslashit( $link ); |
|
183 | + $link = str_replace(' ', '+', $link); |
|
184 | + $link = untrailingslashit($link); |
|
185 | 185 | $page_links[] = array( |
186 | 186 | 'class' => 'page-number page-numbers', |
187 | - 'link' => esc_url( apply_filters( 'paginate_links', $link ) ), |
|
187 | + 'link' => esc_url(apply_filters('paginate_links', $link)), |
|
188 | 188 | 'title' => $n_display, |
189 | 189 | 'name' => $n_display, |
190 | - 'current' => absint( $args['current'] ) === $n, |
|
190 | + 'current' => absint($args['current']) === $n, |
|
191 | 191 | ); |
192 | 192 | $dots = true; |
193 | - } elseif ( $dots && ! $args['show_all'] ) { |
|
193 | + } elseif ($dots && !$args['show_all']) { |
|
194 | 194 | $page_links[] = array( |
195 | 195 | 'class' => 'dots', |
196 | - 'title' => __( '…' ), |
|
196 | + 'title' => __('…'), |
|
197 | 197 | ); |
198 | 198 | $dots = false; |
199 | 199 | } |
200 | 200 | } |
201 | 201 | } |
202 | - if ( $args['prev_next'] && $args['current'] && ( $args['current'] < $args['total'] || -1 === intval( $args['total'] ) ) ) { |
|
203 | - $link = str_replace( '%_%', $args['format'], $args['base'] ); |
|
204 | - $link = str_replace( '%#%', $args['current'] + 1, $link ); |
|
205 | - if ( $args['add_args'] ) { |
|
206 | - $link = add_query_arg( $args['add_args'], $link ); |
|
202 | + if ($args['prev_next'] && $args['current'] && ($args['current'] < $args['total'] || -1 === intval($args['total']))) { |
|
203 | + $link = str_replace('%_%', $args['format'], $args['base']); |
|
204 | + $link = str_replace('%#%', $args['current'] + 1, $link); |
|
205 | + if ($args['add_args']) { |
|
206 | + $link = add_query_arg($args['add_args'], $link); |
|
207 | 207 | } |
208 | - $link = untrailingslashit( trailingslashit( $link ) . $args['add_fragment'] ); |
|
208 | + $link = untrailingslashit(trailingslashit($link).$args['add_fragment']); |
|
209 | 209 | $page_links[] = array( |
210 | 210 | 'class' => 'next page-numbers', |
211 | - 'link' => esc_url( apply_filters( 'paginate_links', $link ) ), |
|
211 | + 'link' => esc_url(apply_filters('paginate_links', $link)), |
|
212 | 212 | 'title' => $args['next_text'], |
213 | 213 | ); |
214 | 214 | } |
@@ -222,13 +222,13 @@ discard block |
||
222 | 222 | * @param array $array |
223 | 223 | * @return object |
224 | 224 | */ |
225 | - public static function array_to_object( $array ) { |
|
225 | + public static function array_to_object($array) { |
|
226 | 226 | $obj = new stdClass; |
227 | 227 | |
228 | - foreach ( $array as $k => $v ) { |
|
229 | - if ( strlen( $k ) ) { |
|
230 | - if ( is_array( $v ) ) { |
|
231 | - $obj->{$k} = self::array_to_object( $v ); //RECURSION |
|
228 | + foreach ($array as $k => $v) { |
|
229 | + if (strlen($k)) { |
|
230 | + if (is_array($v)) { |
|
231 | + $obj->{$k} = self::array_to_object($v); //RECURSION |
|
232 | 232 | } else { |
233 | 233 | $obj->{$k} = $v; |
234 | 234 | } |
@@ -251,42 +251,42 @@ discard block |
||
251 | 251 | |
252 | 252 | $archives_title = ''; |
253 | 253 | |
254 | - if ( is_category() ) { |
|
254 | + if (is_category()) { |
|
255 | 255 | |
256 | - $archives_title = single_cat_title( '', false ); |
|
256 | + $archives_title = single_cat_title('', false); |
|
257 | 257 | |
258 | - } else if ( is_tag() ) { |
|
258 | + } else if (is_tag()) { |
|
259 | 259 | |
260 | - $archives_title = 'Tag: ' . single_tag_title( '', false ); |
|
260 | + $archives_title = 'Tag: '.single_tag_title('', false); |
|
261 | 261 | |
262 | - } else if ( is_author() ) { |
|
262 | + } else if (is_author()) { |
|
263 | 263 | |
264 | - if ( have_posts() ) { |
|
264 | + if (have_posts()) { |
|
265 | 265 | |
266 | 266 | the_post(); |
267 | - $archives_title = 'Author: ' . get_the_author(); |
|
267 | + $archives_title = 'Author: '.get_the_author(); |
|
268 | 268 | |
269 | 269 | } |
270 | 270 | |
271 | 271 | rewind_posts(); |
272 | 272 | |
273 | - } else if ( is_search() ) { |
|
273 | + } else if (is_search()) { |
|
274 | 274 | |
275 | - $archives_title = sprintf( __( 'Search Results for: %s', $textdomain ), '<span>' . get_search_query() . '</span>' ); |
|
275 | + $archives_title = sprintf(__('Search Results for: %s', $textdomain), '<span>'.get_search_query().'</span>'); |
|
276 | 276 | |
277 | - } else if ( is_archive() ) { |
|
277 | + } else if (is_archive()) { |
|
278 | 278 | |
279 | - if ( is_day() ) { |
|
279 | + if (is_day()) { |
|
280 | 280 | |
281 | 281 | $archives_title = get_the_date(); |
282 | 282 | |
283 | - } elseif ( is_month() ) { |
|
283 | + } elseif (is_month()) { |
|
284 | 284 | |
285 | - $archives_title = get_the_date( _x( 'F Y', 'monthly archives date format', $textdomain ) ); |
|
285 | + $archives_title = get_the_date(_x('F Y', 'monthly archives date format', $textdomain)); |
|
286 | 286 | |
287 | - } elseif ( is_year() ) { |
|
287 | + } elseif (is_year()) { |
|
288 | 288 | |
289 | - $archives_title = get_the_date( _x( 'Y', 'yearly archives date format', $textdomain ) ); |
|
289 | + $archives_title = get_the_date(_x('Y', 'yearly archives date format', $textdomain)); |
|
290 | 290 | |
291 | 291 | } else { |
292 | 292 |
@@ -37,7 +37,8 @@ discard block |
||
37 | 37 | preg_match_all( '/./u', $text, $words_array ); |
38 | 38 | $words_array = array_slice( $words_array[0], 0, $num_words + 1 ); |
39 | 39 | $sep = ''; |
40 | - } else { |
|
40 | + } |
|
41 | + else { |
|
41 | 42 | $words_array = preg_split( "/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY ); |
42 | 43 | $sep = ' '; |
43 | 44 | } |
@@ -46,7 +47,8 @@ discard block |
||
46 | 47 | array_pop( $words_array ); |
47 | 48 | $text = implode( $sep, $words_array ); |
48 | 49 | $text = $text . $more; |
49 | - } else { |
|
50 | + } |
|
51 | + else { |
|
50 | 52 | $text = implode( $sep, $words_array ); |
51 | 53 | } |
52 | 54 | |
@@ -85,7 +87,8 @@ discard block |
||
85 | 87 | for ( $i = 0; $i < $len_opened; $i++ ) { |
86 | 88 | if ( ! in_array( $openedtags[ $i ], $closedtags ) ) { |
87 | 89 | $html .= '</' . $openedtags[ $i ] . '>'; |
88 | - } else { |
|
90 | + } |
|
91 | + else { |
|
89 | 92 | unset( $closedtags[ array_search( $openedtags[ $i ], $closedtags ) ] ); |
90 | 93 | } |
91 | 94 | } |
@@ -170,7 +173,8 @@ discard block |
||
170 | 173 | 'current' => true, |
171 | 174 | ); |
172 | 175 | $dots = true; |
173 | - } else { |
|
176 | + } |
|
177 | + else { |
|
174 | 178 | if ( $args['show_all'] || ( $n <= $args['end_size'] || ( $args['current'] && $n >= $args['current'] - $args['mid_size'] && $n <= $args['current'] + $args['mid_size'] ) || $n > $args['total'] - $args['end_size'] ) ) { |
175 | 179 | $link = str_replace( '%_%', 1 == $n ? '' : $args['format'], $args['base'] ); |
176 | 180 | $link = str_replace( '%#%', $n, $link ); |
@@ -188,7 +192,8 @@ discard block |
||
188 | 192 | 'current' => $args['current'] == $n, |
189 | 193 | ); |
190 | 194 | $dots = true; |
191 | - } elseif ( $dots && ! $args['show_all'] ) { |
|
195 | + } |
|
196 | + elseif ( $dots && ! $args['show_all'] ) { |
|
192 | 197 | $page_links[] = array( |
193 | 198 | 'class' => 'dots', |
194 | 199 | 'title' => __( '…' ), |
@@ -227,7 +232,8 @@ discard block |
||
227 | 232 | if ( strlen( $k ) ) { |
228 | 233 | if ( is_array( $v ) ) { |
229 | 234 | $obj->{$k} = self::array_to_object( $v ); //RECURSION |
230 | - } else { |
|
235 | + } |
|
236 | + else { |
|
231 | 237 | $obj->{$k} = $v; |
232 | 238 | } |
233 | 239 | } |
@@ -253,11 +259,13 @@ discard block |
||
253 | 259 | |
254 | 260 | $archives_title = single_cat_title( '', false ); |
255 | 261 | |
256 | - } else if ( is_tag() ) { |
|
262 | + } |
|
263 | + else if ( is_tag() ) { |
|
257 | 264 | |
258 | 265 | $archives_title = 'Tag: ' . single_tag_title( '', false ); |
259 | 266 | |
260 | - } else if ( is_author() ) { |
|
267 | + } |
|
268 | + else if ( is_author() ) { |
|
261 | 269 | |
262 | 270 | if ( have_posts() ) { |
263 | 271 | |
@@ -268,30 +276,36 @@ discard block |
||
268 | 276 | |
269 | 277 | rewind_posts(); |
270 | 278 | |
271 | - } else if ( is_search() ) { |
|
279 | + } |
|
280 | + else if ( is_search() ) { |
|
272 | 281 | |
273 | 282 | $archives_title = sprintf( __( 'Search Results for: %s', $textdomain ), '<span>' . get_search_query() . '</span>' ); |
274 | 283 | |
275 | - } else if ( is_archive() ) { |
|
284 | + } |
|
285 | + else if ( is_archive() ) { |
|
276 | 286 | |
277 | 287 | if ( is_day() ) { |
278 | 288 | |
279 | 289 | $archives_title = get_the_date(); |
280 | 290 | |
281 | - } elseif ( is_month() ) { |
|
291 | + } |
|
292 | + elseif ( is_month() ) { |
|
282 | 293 | |
283 | 294 | $archives_title = get_the_date( _x( 'F Y', 'monthly archives date format', $textdomain ) ); |
284 | 295 | |
285 | - } elseif ( is_year() ) { |
|
296 | + } |
|
297 | + elseif ( is_year() ) { |
|
286 | 298 | |
287 | 299 | $archives_title = get_the_date( _x( 'Y', 'yearly archives date format', $textdomain ) ); |
288 | 300 | |
289 | - } else { |
|
301 | + } |
|
302 | + else { |
|
290 | 303 | |
291 | 304 | $archives_title = 'Archives'; |
292 | 305 | |
293 | 306 | } |
294 | - } else { |
|
307 | + } |
|
308 | + else { |
|
295 | 309 | |
296 | 310 | $archives_title = 'Archives'; |
297 | 311 |
@@ -131,7 +131,8 @@ discard block |
||
131 | 131 | * |
132 | 132 | * @param string $type view|scope |
133 | 133 | * @param string $type |
134 | - * @return array |
|
134 | + * @param string $page |
|
135 | + * @return string|false |
|
135 | 136 | */ |
136 | 137 | public static function get_available_file( $type = 'view', $page ) { |
137 | 138 | |
@@ -374,7 +375,7 @@ discard block |
||
374 | 375 | /** |
375 | 376 | * Returns classy template name or boolean if this is not classy template |
376 | 377 | * |
377 | - * @return mixed |
|
378 | + * @return string|false |
|
378 | 379 | */ |
379 | 380 | public static function get_classy_template() { |
380 | 381 |
@@ -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 CLASSY_THEME_PATH . $folder . '/' . $view . '.blade.php'; |
|
98 | + return CLASSY_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 CLASSY_THEME_PATH . $folder . '/' . $view . '.php'; |
|
104 | + return CLASSY_THEME_PATH.$folder.'/'.$view.'.php'; |
|
105 | 105 | |
106 | 106 | } |
107 | 107 | |
@@ -115,13 +115,13 @@ discard block |
||
115 | 115 | * @param string $file 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,45 +302,45 @@ 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 | 319 | $views[] = 'page.page'; |
320 | 320 | |
321 | 321 | $views[] = 'page'; |
322 | 322 | |
323 | - elseif ( 'page' === $type ) : |
|
323 | + elseif ('page' === $type) : |
|
324 | 324 | |
325 | 325 | $id = get_queried_object_id(); |
326 | 326 | |
327 | - $pagename = get_query_var( 'pagename' ); |
|
327 | + $pagename = get_query_var('pagename'); |
|
328 | 328 | |
329 | - if ( ! $pagename && $id ) { |
|
329 | + if (!$pagename && $id) { |
|
330 | 330 | // If a static page is set as the front page, $pagename will not be set. Retrieve it from the queried object |
331 | 331 | $post = get_queried_object(); |
332 | 332 | |
333 | - if ( $post ) { |
|
333 | + if ($post) { |
|
334 | 334 | $pagename = $post->post_name; |
335 | 335 | } |
336 | 336 | } |
337 | 337 | |
338 | - if ( $pagename ) { |
|
339 | - $views[] = 'page.' . $pagename; |
|
338 | + if ($pagename) { |
|
339 | + $views[] = 'page.'.$pagename; |
|
340 | 340 | } |
341 | 341 | |
342 | - if ( $id ) { |
|
343 | - $views[] = 'page.' . $id; |
|
342 | + if ($id) { |
|
343 | + $views[] = 'page.'.$id; |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | $views[] = 'page.page'; |
@@ -382,9 +382,9 @@ discard block |
||
382 | 382 | |
383 | 383 | $template_slug = get_page_template_slug(); |
384 | 384 | |
385 | - preg_match( '/classy\-(.*)/', $template_slug, $matches ); |
|
385 | + preg_match('/classy\-(.*)/', $template_slug, $matches); |
|
386 | 386 | |
387 | - if ( ! empty( $matches ) && isset( $matches[1] ) ) { return $matches[1]; } |
|
387 | + if (!empty($matches) && isset($matches[1])) { return $matches[1]; } |
|
388 | 388 | |
389 | 389 | return false; |
390 | 390 |
@@ -54,9 +54,11 @@ discard block |
||
54 | 54 | |
55 | 55 | elseif ( is_paged() ) : return 'paged'; |
56 | 56 | |
57 | - else : |
|
57 | + else { |
|
58 | + : |
|
58 | 59 | |
59 | 60 | return 'index'; |
61 | + } |
|
60 | 62 | |
61 | 63 | endif; |
62 | 64 | |
@@ -97,7 +99,8 @@ discard block |
||
97 | 99 | |
98 | 100 | return THEME_PATH . $folder . '/' . $view . '.blade.php'; |
99 | 101 | |
100 | - } elseif ( 'scope' === $type ) { |
|
102 | + } |
|
103 | + elseif ( 'scope' === $type ) { |
|
101 | 104 | |
102 | 105 | $folder = ClassyScope::$folder; |
103 | 106 | |
@@ -234,7 +237,8 @@ discard block |
||
234 | 237 | |
235 | 238 | list( $type, $subtype ) = explode( '/', $attachment->post_mime_type ); |
236 | 239 | |
237 | - } else { |
|
240 | + } |
|
241 | + else { |
|
238 | 242 | |
239 | 243 | list( $type, $subtype ) = array( $attachment->post_mime_type, '' ); |
240 | 244 | |
@@ -347,9 +351,11 @@ discard block |
||
347 | 351 | |
348 | 352 | // Default |
349 | 353 | |
350 | - else : |
|
354 | + else { |
|
355 | + : |
|
351 | 356 | |
352 | 357 | $views[] = $type; |
358 | + } |
|
353 | 359 | |
354 | 360 | endif; |
355 | 361 |
@@ -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 |
@@ -93,12 +93,12 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @param object|int $post WP_Post or WP_Post.ID. |
95 | 95 | */ |
96 | - public function __construct( $post = null ) { |
|
97 | - if ( is_integer( $post ) ) { |
|
96 | + public function __construct($post = null) { |
|
97 | + if (is_integer($post)) { |
|
98 | 98 | $this->ID = $post; |
99 | 99 | $this->init(); |
100 | - } elseif ( is_a( $post, '\WP_Post' ) ) { |
|
101 | - $this->import( $post ); |
|
100 | + } elseif (is_a($post, '\WP_Post')) { |
|
101 | + $this->import($post); |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | |
@@ -108,8 +108,8 @@ discard block |
||
108 | 108 | protected function init() { |
109 | 109 | $post = $this->get_object(); |
110 | 110 | |
111 | - if ( is_a( $post, '\WP_Post' ) ) { |
|
112 | - $this->import( $post ); |
|
111 | + if (is_a($post, '\WP_Post')) { |
|
112 | + $this->import($post); |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * @return \WP_Post |
120 | 120 | */ |
121 | 121 | public function get_object() { |
122 | - $object = get_post( $this->ID ); |
|
122 | + $object = get_post($this->ID); |
|
123 | 123 | |
124 | 124 | return $object; |
125 | 125 | } |
@@ -130,10 +130,10 @@ discard block |
||
130 | 130 | * @return boolean |
131 | 131 | */ |
132 | 132 | public function can_edit() { |
133 | - if ( ! function_exists( 'current_user_can' ) ) { |
|
133 | + if (!function_exists('current_user_can')) { |
|
134 | 134 | return false; |
135 | 135 | } |
136 | - if ( current_user_can( 'edit_post', $this->ID ) ) { |
|
136 | + if (current_user_can('edit_post', $this->ID)) { |
|
137 | 137 | return true; |
138 | 138 | } |
139 | 139 | |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | * @return string |
147 | 147 | */ |
148 | 148 | public function get_edit_url() { |
149 | - if ( $this->can_edit() ) { |
|
150 | - return get_edit_post_link( $this->ID ); |
|
149 | + if ($this->can_edit()) { |
|
150 | + return get_edit_post_link($this->ID); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | return ''; |
@@ -170,9 +170,9 @@ discard block |
||
170 | 170 | 'fields' => 'ids', |
171 | 171 | ); |
172 | 172 | |
173 | - $images = get_children( $attrs ); |
|
173 | + $images = get_children($attrs); |
|
174 | 174 | |
175 | - if ( ! count( $images ) ) { |
|
175 | + if (!count($images)) { |
|
176 | 176 | return false; |
177 | 177 | } |
178 | 178 | |
@@ -189,11 +189,11 @@ discard block |
||
189 | 189 | |
190 | 190 | $images = $this->get_attached_images(); |
191 | 191 | |
192 | - if ( $images ) { |
|
192 | + if ($images) { |
|
193 | 193 | |
194 | - foreach ( $images as $image_id ) { |
|
194 | + foreach ($images as $image_id) { |
|
195 | 195 | |
196 | - $_return[] = new Image( $image_id ); |
|
196 | + $_return[] = new Image($image_id); |
|
197 | 197 | |
198 | 198 | } |
199 | 199 | } |
@@ -219,13 +219,13 @@ discard block |
||
219 | 219 | 'fields' => 'ids', |
220 | 220 | ); |
221 | 221 | |
222 | - $images = get_children( $attrs ); |
|
222 | + $images = get_children($attrs); |
|
223 | 223 | |
224 | - if ( ! count( $images ) ) { |
|
224 | + if (!count($images)) { |
|
225 | 225 | return false; |
226 | 226 | } |
227 | 227 | |
228 | - $images = array_values( $images ); |
|
228 | + $images = array_values($images); |
|
229 | 229 | |
230 | 230 | return $images[0]; |
231 | 231 | } |
@@ -239,8 +239,8 @@ discard block |
||
239 | 239 | |
240 | 240 | $image_id = $this->get_first_attached_image_id(); |
241 | 241 | |
242 | - if ( $image_id ) { |
|
243 | - return new Image( $image_id ); |
|
242 | + if ($image_id) { |
|
243 | + return new Image($image_id); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | return new Image(); |
@@ -252,12 +252,12 @@ discard block |
||
252 | 252 | * @return Image |
253 | 253 | */ |
254 | 254 | public function thumbnail() { |
255 | - if ( function_exists( 'get_post_thumbnail_id' ) ) { |
|
256 | - $image_id = get_post_thumbnail_id( $this->ID ); |
|
255 | + if (function_exists('get_post_thumbnail_id')) { |
|
256 | + $image_id = get_post_thumbnail_id($this->ID); |
|
257 | 257 | |
258 | - if ( $image_id ) { |
|
258 | + if ($image_id) { |
|
259 | 259 | |
260 | - return new Image( $image_id ); |
|
260 | + return new Image($image_id); |
|
261 | 261 | |
262 | 262 | } |
263 | 263 | } |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | * @return string |
272 | 272 | */ |
273 | 273 | public function get_title() { |
274 | - return apply_filters( 'the_title', $this->post_title, $this->ID ); |
|
274 | + return apply_filters('the_title', $this->post_title, $this->ID); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | /** |
@@ -290,24 +290,24 @@ discard block |
||
290 | 290 | * |
291 | 291 | * @return string Post content |
292 | 292 | */ |
293 | - public function get_content( $page = 0 ) { |
|
294 | - if ( 0 === absint( $page ) && $this->post_content ) { |
|
293 | + public function get_content($page = 0) { |
|
294 | + if (0 === absint($page) && $this->post_content) { |
|
295 | 295 | return $this->post_content; |
296 | 296 | } |
297 | 297 | |
298 | 298 | $content = $this->post_content; |
299 | 299 | |
300 | - if ( $page ) { |
|
301 | - $contents = explode( '<!--nextpage-->', $content ); |
|
300 | + if ($page) { |
|
301 | + $contents = explode('<!--nextpage-->', $content); |
|
302 | 302 | |
303 | 303 | $page--; |
304 | 304 | |
305 | - if ( count( $contents ) > $page ) { |
|
306 | - $content = $contents[ $page ]; |
|
305 | + if (count($contents) > $page) { |
|
306 | + $content = $contents[$page]; |
|
307 | 307 | } |
308 | 308 | } |
309 | 309 | |
310 | - $content = apply_filters( 'the_content', ($content) ); |
|
310 | + $content = apply_filters('the_content', ($content)); |
|
311 | 311 | |
312 | 312 | return $content; |
313 | 313 | } |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | * @return object |
328 | 328 | */ |
329 | 329 | public function get_post_type() { |
330 | - return get_post_type_object( $this->post_type ); |
|
330 | + return get_post_type_object($this->post_type); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | /** |
@@ -336,11 +336,11 @@ discard block |
||
336 | 336 | * @return string |
337 | 337 | */ |
338 | 338 | public function get_permalink() { |
339 | - if ( isset( $this->permalink ) ) { |
|
339 | + if (isset($this->permalink)) { |
|
340 | 340 | return $this->permalink; |
341 | 341 | } |
342 | 342 | |
343 | - $this->permalink = get_permalink( $this->ID ); |
|
343 | + $this->permalink = get_permalink($this->ID); |
|
344 | 344 | |
345 | 345 | return $this->permalink; |
346 | 346 | } |
@@ -366,84 +366,84 @@ discard block |
||
366 | 366 | * |
367 | 367 | * @return string Post preview. |
368 | 368 | */ |
369 | - public function get_preview( $len = 50, $force = false, $readmore = 'Read More', $strip = true ) { |
|
369 | + public function get_preview($len = 50, $force = false, $readmore = 'Read More', $strip = true) { |
|
370 | 370 | $text = ''; |
371 | 371 | $trimmed = false; |
372 | 372 | |
373 | - if ( isset( $this->post_excerpt ) && strlen( $this->post_excerpt ) ) { |
|
373 | + if (isset($this->post_excerpt) && strlen($this->post_excerpt)) { |
|
374 | 374 | |
375 | - if ( $force ) { |
|
376 | - $text = Helper::trim_words( $this->post_excerpt, $len, false ); |
|
375 | + if ($force) { |
|
376 | + $text = Helper::trim_words($this->post_excerpt, $len, false); |
|
377 | 377 | $trimmed = true; |
378 | 378 | } else { |
379 | 379 | $text = $this->post_excerpt; |
380 | 380 | } |
381 | 381 | } |
382 | 382 | |
383 | - if ( ! strlen( $text ) && preg_match( '/<!--\s?more(.*?)?-->/', $this->post_content, $readmore_matches ) ) { |
|
383 | + if (!strlen($text) && preg_match('/<!--\s?more(.*?)?-->/', $this->post_content, $readmore_matches)) { |
|
384 | 384 | |
385 | - $pieces = explode( $readmore_matches[0], $this->post_content ); |
|
385 | + $pieces = explode($readmore_matches[0], $this->post_content); |
|
386 | 386 | $text = $pieces[0]; |
387 | 387 | |
388 | - if ( $force ) { |
|
389 | - $text = Helper::trim_words( $text, $len, false ); |
|
388 | + if ($force) { |
|
389 | + $text = Helper::trim_words($text, $len, false); |
|
390 | 390 | $trimmed = true; |
391 | 391 | } |
392 | 392 | |
393 | - $text = do_shortcode( $text ); |
|
393 | + $text = do_shortcode($text); |
|
394 | 394 | |
395 | 395 | } |
396 | 396 | |
397 | - if ( ! strlen( $text ) ) { |
|
397 | + if (!strlen($text)) { |
|
398 | 398 | |
399 | - $text = Helper::trim_words( $this->get_content(), $len, false ); |
|
399 | + $text = Helper::trim_words($this->get_content(), $len, false); |
|
400 | 400 | $trimmed = true; |
401 | 401 | |
402 | 402 | } |
403 | 403 | |
404 | - if ( ! strlen( trim( $text ) ) ) { |
|
404 | + if (!strlen(trim($text))) { |
|
405 | 405 | |
406 | - return trim( $text ); |
|
406 | + return trim($text); |
|
407 | 407 | |
408 | 408 | } |
409 | 409 | |
410 | - if ( $strip ) { |
|
410 | + if ($strip) { |
|
411 | 411 | |
412 | - $text = trim( strip_tags( $text ) ); |
|
412 | + $text = trim(strip_tags($text)); |
|
413 | 413 | |
414 | 414 | } |
415 | 415 | |
416 | - if ( strlen( $text ) ) { |
|
416 | + if (strlen($text)) { |
|
417 | 417 | |
418 | - $text = trim( $text ); |
|
419 | - $last = $text[ strlen( $text ) - 1 ]; |
|
418 | + $text = trim($text); |
|
419 | + $last = $text[strlen($text) - 1]; |
|
420 | 420 | |
421 | - if ( '.' !== $last && $trimmed ) { |
|
421 | + if ('.' !== $last && $trimmed) { |
|
422 | 422 | $text .= ' … '; |
423 | 423 | } |
424 | 424 | |
425 | - if ( ! $strip ) { |
|
426 | - $last_p_tag = strrpos( $text, '</p>' ); |
|
427 | - if ( false !== $last_p_tag ) { |
|
428 | - $text = substr( $text, 0, $last_p_tag ); |
|
425 | + if (!$strip) { |
|
426 | + $last_p_tag = strrpos($text, '</p>'); |
|
427 | + if (false !== $last_p_tag) { |
|
428 | + $text = substr($text, 0, $last_p_tag); |
|
429 | 429 | } |
430 | - if ( '.' !== $last && $trimmed ) { |
|
430 | + if ('.' !== $last && $trimmed) { |
|
431 | 431 | $text .= ' … '; |
432 | 432 | } |
433 | 433 | } |
434 | 434 | |
435 | - if ( $readmore && isset( $readmore_matches ) && ! empty( $readmore_matches[1] ) ) { |
|
436 | - $text .= ' <a href="' . $this->get_permalink() . '" class="read-more">' . trim( $readmore_matches[1] ) . '</a>'; |
|
437 | - } elseif ( $readmore ) { |
|
438 | - $text .= ' <a href="' . $this->get_permalink() . '" class="read-more">' . trim( $readmore ) . '</a>'; |
|
435 | + if ($readmore && isset($readmore_matches) && !empty($readmore_matches[1])) { |
|
436 | + $text .= ' <a href="'.$this->get_permalink().'" class="read-more">'.trim($readmore_matches[1]).'</a>'; |
|
437 | + } elseif ($readmore) { |
|
438 | + $text .= ' <a href="'.$this->get_permalink().'" class="read-more">'.trim($readmore).'</a>'; |
|
439 | 439 | } |
440 | 440 | |
441 | - if ( ! $strip ) { |
|
441 | + if (!$strip) { |
|
442 | 442 | $text .= '</p>'; |
443 | 443 | } |
444 | 444 | } |
445 | 445 | |
446 | - return trim( $text ); |
|
446 | + return trim($text); |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | /** |
@@ -454,7 +454,7 @@ discard block |
||
454 | 454 | * |
455 | 455 | * @return array |
456 | 456 | */ |
457 | - public function get_comments( $status = 'approve', $order = 'DESC' ) { |
|
457 | + public function get_comments($status = 'approve', $order = 'DESC') { |
|
458 | 458 | |
459 | 459 | $_return = array(); |
460 | 460 | |
@@ -464,25 +464,25 @@ discard block |
||
464 | 464 | 'order' => $order, |
465 | 465 | ); |
466 | 466 | |
467 | - $comments = get_comments( $args ); |
|
467 | + $comments = get_comments($args); |
|
468 | 468 | |
469 | - foreach ( $comments as $comment ) { |
|
469 | + foreach ($comments as $comment) { |
|
470 | 470 | |
471 | - $_return[ $comment->comment_ID ] = new Comment( $comment ); |
|
471 | + $_return[$comment->comment_ID] = new Comment($comment); |
|
472 | 472 | |
473 | 473 | } |
474 | 474 | |
475 | - foreach ( $_return as $key => $comment ) { |
|
475 | + foreach ($_return as $key => $comment) { |
|
476 | 476 | |
477 | - if ( $comment->has_parent() ) { |
|
477 | + if ($comment->has_parent()) { |
|
478 | 478 | |
479 | - $_return[ $comment->comment_parent ]->add_child( $comment ); |
|
479 | + $_return[$comment->comment_parent]->add_child($comment); |
|
480 | 480 | |
481 | - unset( $_return[ $key ] ); |
|
481 | + unset($_return[$key]); |
|
482 | 482 | |
483 | 483 | } |
484 | 484 | } |
485 | 485 | |
486 | - return array_values( $_return ); |
|
486 | + return array_values($_return); |
|
487 | 487 | } |
488 | 488 | } |
@@ -97,7 +97,8 @@ discard block |
||
97 | 97 | if ( is_integer( $post ) ) { |
98 | 98 | $this->ID = $post; |
99 | 99 | $this->init(); |
100 | - } elseif ( is_a( $post, '\WP_Post' ) ) { |
|
100 | + } |
|
101 | + elseif ( is_a( $post, '\WP_Post' ) ) { |
|
101 | 102 | $this->import( $post ); |
102 | 103 | } |
103 | 104 | } |
@@ -375,7 +376,8 @@ discard block |
||
375 | 376 | if ( $force ) { |
376 | 377 | $text = Helper::trim_words( $this->post_excerpt, $len, false ); |
377 | 378 | $trimmed = true; |
378 | - } else { |
|
379 | + } |
|
380 | + else { |
|
379 | 381 | $text = $this->post_excerpt; |
380 | 382 | } |
381 | 383 | } |
@@ -434,7 +436,8 @@ discard block |
||
434 | 436 | |
435 | 437 | if ( $readmore && isset( $readmore_matches ) && ! empty( $readmore_matches[1] ) ) { |
436 | 438 | $text .= ' <a href="' . $this->get_permalink() . '" class="read-more">' . trim( $readmore_matches[1] ) . '</a>'; |
437 | - } elseif ( $readmore ) { |
|
439 | + } |
|
440 | + elseif ( $readmore ) { |
|
438 | 441 | $text .= ' <a href="' . $this->get_permalink() . '" class="read-more">' . trim( $readmore ) . '</a>'; |
439 | 442 | } |
440 | 443 |
@@ -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)); |