@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | * |
102 | 102 | * @param \WP_Comment $item WP_Comment object. |
103 | 103 | */ |
104 | - public function __construct( $item ) { |
|
105 | - if ( is_a( $item, '\WP_Comment' ) ) { |
|
106 | - $this->import( $item ); |
|
104 | + public function __construct($item) { |
|
105 | + if (is_a($item, '\WP_Comment')) { |
|
106 | + $this->import($item); |
|
107 | 107 | } |
108 | 108 | } |
109 | 109 | |
@@ -113,18 +113,18 @@ discard block |
||
113 | 113 | * @return \Classy\Models\User |
114 | 114 | */ |
115 | 115 | public function author() { |
116 | - if ( ! $this->user_id ) { |
|
116 | + if (!$this->user_id) { |
|
117 | 117 | |
118 | - $author = new Models\User( 0 ); |
|
118 | + $author = new Models\User(0); |
|
119 | 119 | |
120 | - if ( isset( $this->comment_author ) && $this->comment_author ) { |
|
120 | + if (isset($this->comment_author) && $this->comment_author) { |
|
121 | 121 | $author->name = $this->comment_author; |
122 | 122 | } |
123 | 123 | |
124 | 124 | return $author; |
125 | 125 | } |
126 | 126 | |
127 | - return new Models\User( $this->user_id ); |
|
127 | + return new Models\User($this->user_id); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * @return string |
134 | 134 | */ |
135 | 135 | public function content() { |
136 | - return apply_filters( 'get_comment_text ', $this->comment_content ); |
|
136 | + return apply_filters('get_comment_text ', $this->comment_content); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -152,11 +152,11 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @return string |
154 | 154 | */ |
155 | - public function date( $date_format = '' ) { |
|
156 | - $df = $date_format ? $date_format : get_option( 'date_format' ); |
|
157 | - $the_date = (string) mysql2date( $df, $this->comment_date ); |
|
155 | + public function date($date_format = '') { |
|
156 | + $df = $date_format ? $date_format : get_option('date_format'); |
|
157 | + $the_date = (string) mysql2date($df, $this->comment_date); |
|
158 | 158 | |
159 | - return apply_filters( 'get_comment_date ', $the_date, $df ); |
|
159 | + return apply_filters('get_comment_date ', $the_date, $df); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -176,25 +176,25 @@ discard block |
||
176 | 176 | * |
177 | 177 | * @return string |
178 | 178 | */ |
179 | - public function avatar( $size = 92, $default = '' ) { |
|
180 | - if ( ! get_option( 'show_avatars' ) ) { |
|
179 | + public function avatar($size = 92, $default = '') { |
|
180 | + if (!get_option('show_avatars')) { |
|
181 | 181 | return false; |
182 | 182 | } |
183 | 183 | |
184 | - if ( ! is_numeric( $size ) ) { $size = '92'; } |
|
184 | + if (!is_numeric($size)) { $size = '92'; } |
|
185 | 185 | |
186 | 186 | $email = $this->get_avatar_email(); |
187 | 187 | $email_hash = ''; |
188 | 188 | |
189 | - if ( ! empty( $email ) ) { |
|
190 | - $email_hash = md5( strtolower( trim( $email ) ) ); |
|
189 | + if (!empty($email)) { |
|
190 | + $email_hash = md5(strtolower(trim($email))); |
|
191 | 191 | } |
192 | 192 | |
193 | - $host = $this->get_avatar_host( $email_hash ); |
|
194 | - $default = $this->get_default_avatar( $default, $email, $size, $host ); |
|
193 | + $host = $this->get_avatar_host($email_hash); |
|
194 | + $default = $this->get_default_avatar($default, $email, $size, $host); |
|
195 | 195 | |
196 | - if ( ! empty( $email ) ) { |
|
197 | - $avatar = $this->get_avatar_url( $default, $host, $email_hash, $size ); |
|
196 | + if (!empty($email)) { |
|
197 | + $avatar = $this->get_avatar_url($default, $host, $email_hash, $size); |
|
198 | 198 | } else { |
199 | 199 | $avatar = $default; |
200 | 200 | } |
@@ -209,9 +209,9 @@ discard block |
||
209 | 209 | */ |
210 | 210 | protected function get_avatar_email() { |
211 | 211 | $id = (int) $this->user_id; |
212 | - $user = get_userdata( $id ); |
|
212 | + $user = get_userdata($id); |
|
213 | 213 | |
214 | - if ( $user ) { |
|
214 | + if ($user) { |
|
215 | 215 | $email = $user->user_email; |
216 | 216 | } else { |
217 | 217 | $email = $this->comment_author_email; |
@@ -229,31 +229,31 @@ discard block |
||
229 | 229 | * @param string $host |
230 | 230 | * @return string |
231 | 231 | */ |
232 | - protected function get_default_avatar( $default, $email, $size, $host ) { |
|
233 | - if ( '/' === substr( $default, 0, 1 ) ) { |
|
234 | - $default = home_url() . $default; |
|
232 | + protected function get_default_avatar($default, $email, $size, $host) { |
|
233 | + if ('/' === substr($default, 0, 1)) { |
|
234 | + $default = home_url().$default; |
|
235 | 235 | } |
236 | 236 | |
237 | - if ( empty( $default ) ) { |
|
238 | - $avatar_default = get_option( 'avatar_default' ); |
|
239 | - if ( empty( $avatar_default ) ) { |
|
237 | + if (empty($default)) { |
|
238 | + $avatar_default = get_option('avatar_default'); |
|
239 | + if (empty($avatar_default)) { |
|
240 | 240 | $default = 'mystery'; |
241 | 241 | } else { |
242 | 242 | $default = $avatar_default; |
243 | 243 | } |
244 | 244 | } |
245 | 245 | |
246 | - if ( 'mystery' === $default ) { |
|
247 | - $default = $host . '/avatar/ad516503a11cd5ca435acc9bb6523536?s=' . $size; |
|
246 | + if ('mystery' === $default) { |
|
247 | + $default = $host.'/avatar/ad516503a11cd5ca435acc9bb6523536?s='.$size; |
|
248 | 248 | // ad516503a11cd5ca435acc9bb6523536 == md5('[email protected]') |
249 | - } else if ( 'blank' === $default ) { |
|
250 | - $default = $email ? 'blank' : includes_url( 'images/blank.gif' ); |
|
251 | - } else if ( ! empty( $email ) && 'gravatar_default' === $default ) { |
|
249 | + } else if ('blank' === $default) { |
|
250 | + $default = $email ? 'blank' : includes_url('images/blank.gif'); |
|
251 | + } else if (!empty($email) && 'gravatar_default' === $default) { |
|
252 | 252 | $default = ''; |
253 | - } else if ( 'gravatar_default' === $default ) { |
|
254 | - $default = $host . '/avatar/?s=' . $size; |
|
255 | - } else if ( empty( $email ) && ! strstr( $default, 'http://' ) ) { |
|
256 | - $default = $host . '/avatar/?d=' . $default . '&s=' . $size; |
|
253 | + } else if ('gravatar_default' === $default) { |
|
254 | + $default = $host.'/avatar/?s='.$size; |
|
255 | + } else if (empty($email) && !strstr($default, 'http://')) { |
|
256 | + $default = $host.'/avatar/?d='.$default.'&s='.$size; |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | return $default; |
@@ -265,13 +265,13 @@ discard block |
||
265 | 265 | * @param string $email_hash |
266 | 266 | * @return string |
267 | 267 | */ |
268 | - protected function get_avatar_host( $email_hash ) { |
|
268 | + protected function get_avatar_host($email_hash) { |
|
269 | 269 | |
270 | - if ( is_ssl() ) { |
|
270 | + if (is_ssl()) { |
|
271 | 271 | $host = 'https://secure.gravatar.com'; |
272 | 272 | } else { |
273 | - if ( ! empty( $email_hash ) ) { |
|
274 | - $host = sprintf( 'http://%d.gravatar.com', (hexdec( $email_hash[0] ) % 2) ); |
|
273 | + if (!empty($email_hash)) { |
|
274 | + $host = sprintf('http://%d.gravatar.com', (hexdec($email_hash[0]) % 2)); |
|
275 | 275 | } else { |
276 | 276 | $host = 'http://0.gravatar.com'; |
277 | 277 | } |
@@ -289,15 +289,15 @@ discard block |
||
289 | 289 | * @param int $size |
290 | 290 | * @return string |
291 | 291 | */ |
292 | - protected function get_avatar_url( $default, $host, $email_hash, $size ) { |
|
293 | - $_return = $host . '/avatar/' . $email_hash . '?s=' . $size . '&d=' . urlencode( $default ); |
|
294 | - $rating = get_option( 'avatar_rating' ); |
|
292 | + protected function get_avatar_url($default, $host, $email_hash, $size) { |
|
293 | + $_return = $host.'/avatar/'.$email_hash.'?s='.$size.'&d='.urlencode($default); |
|
294 | + $rating = get_option('avatar_rating'); |
|
295 | 295 | |
296 | - if ( ! empty( $rating ) ) { |
|
297 | - $_return .= '&r=' . $rating; |
|
296 | + if (!empty($rating)) { |
|
297 | + $_return .= '&r='.$rating; |
|
298 | 298 | } |
299 | 299 | |
300 | - return str_replace( '&', '&', esc_url( $_return ) ); |
|
300 | + return str_replace('&', '&', esc_url($_return)); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | /** |
@@ -305,11 +305,11 @@ discard block |
||
305 | 305 | * |
306 | 306 | * @param Comment $comment |
307 | 307 | */ |
308 | - public function add_child( $comment ) { |
|
308 | + public function add_child($comment) { |
|
309 | 309 | $this->children[] = $comment; |
310 | 310 | $item->level = $this->level + 1; |
311 | 311 | |
312 | - if ( $item->children ) { |
|
312 | + if ($item->children) { |
|
313 | 313 | $this->update_child_levels(); |
314 | 314 | } |
315 | 315 | } |
@@ -320,8 +320,8 @@ discard block |
||
320 | 320 | * @return boolean |
321 | 321 | */ |
322 | 322 | protected function update_child_levels() { |
323 | - if ( is_array( $this->children ) ) { |
|
324 | - foreach ( $this->children as $child ) { |
|
323 | + if (is_array($this->children)) { |
|
324 | + foreach ($this->children as $child) { |
|
325 | 325 | $child->level = $this->level + 1; |
326 | 326 | $child->update_child_levels(); |
327 | 327 | } |
@@ -19,18 +19,18 @@ discard block |
||
19 | 19 | * |
20 | 20 | * @return \WP_Query |
21 | 21 | */ |
22 | - public static function find_query( $args = false ) { |
|
22 | + public static function find_query($args = false) { |
|
23 | 23 | $default_args = array(); |
24 | 24 | |
25 | - if ( ! $args ) { |
|
25 | + if (!$args) { |
|
26 | 26 | return self::get_current_query(); |
27 | 27 | } |
28 | 28 | |
29 | - if ( is_array( $args ) ) { |
|
30 | - return new \WP_Query( array_merge( $default_args, $args ) ); |
|
29 | + if (is_array($args)) { |
|
30 | + return new \WP_Query(array_merge($default_args, $args)); |
|
31 | 31 | } |
32 | 32 | |
33 | - return new \WP_Query( $default_args ); |
|
33 | + return new \WP_Query($default_args); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -40,8 +40,8 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public static function get_current_query() { |
42 | 42 | global $wp_query; |
43 | - $query =& $wp_query; |
|
44 | - $query = self::handle_maybe_custom_posts_page( $query ); |
|
43 | + $query = & $wp_query; |
|
44 | + $query = self::handle_maybe_custom_posts_page($query); |
|
45 | 45 | |
46 | 46 | return $query; |
47 | 47 | } |
@@ -53,13 +53,13 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @return \WP_Query |
55 | 55 | */ |
56 | - private static function handle_maybe_custom_posts_page( $query ) { |
|
57 | - if ( $custom_posts_page = get_option( 'page_for_posts' ) ) { |
|
56 | + private static function handle_maybe_custom_posts_page($query) { |
|
57 | + if ($custom_posts_page = get_option('page_for_posts')) { |
|
58 | 58 | if ( |
59 | - isset( $query->query['p'] ) && |
|
60 | - absint( $query->query['p'] ) === absint( $custom_posts_page ) |
|
59 | + isset($query->query['p']) && |
|
60 | + absint($query->query['p']) === absint($custom_posts_page) |
|
61 | 61 | ) { |
62 | - return new \WP_Query( array( 'post_type' => 'post' ) ); |
|
62 | + return new \WP_Query(array('post_type' => 'post')); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 |
@@ -19,21 +19,21 @@ |
||
19 | 19 | * |
20 | 20 | * @return void |
21 | 21 | */ |
22 | - protected function import( $data ) { |
|
23 | - if ( is_object( $data ) ) { |
|
24 | - $data = get_object_vars( $data ); |
|
22 | + protected function import($data) { |
|
23 | + if (is_object($data)) { |
|
24 | + $data = get_object_vars($data); |
|
25 | 25 | } |
26 | 26 | |
27 | - if ( is_array( $data ) ) { |
|
27 | + if (is_array($data)) { |
|
28 | 28 | // In case if we import WP_User object. |
29 | - if ( isset( $data['data'] ) ) { |
|
29 | + if (isset($data['data'])) { |
|
30 | 30 | $data = $data['data']; |
31 | 31 | } |
32 | 32 | |
33 | - foreach ( $data as $key => $value ) { |
|
34 | - if ( ! empty( $key ) ) { |
|
33 | + foreach ($data as $key => $value) { |
|
34 | + if (!empty($key)) { |
|
35 | 35 | $this->$key = $value; |
36 | - } else if ( ! empty( $key ) && ! method_exists( $this, $key ) ) { |
|
36 | + } else if (!empty($key) && !method_exists($this, $key)) { |
|
37 | 37 | $this->$key = $value; |
38 | 38 | } |
39 | 39 | } |
@@ -22,41 +22,41 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @return string Trimmed text. |
24 | 24 | */ |
25 | - public static function trim_words( $text, $num_words = 55, $more = null, $allowed_tags = 'p a span b i br blockquote' ) { |
|
26 | - if ( null === $more ) { |
|
27 | - $more = __( '…' ); |
|
25 | + public static function trim_words($text, $num_words = 55, $more = null, $allowed_tags = 'p a span b i br blockquote') { |
|
26 | + if (null === $more) { |
|
27 | + $more = __('…'); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | $original_text = $text; |
31 | 31 | $allowed_tag_string = ''; |
32 | 32 | |
33 | - foreach ( explode( ' ', $allowed_tags ) as $tag ) { |
|
34 | - $allowed_tag_string .= '<' . $tag . '>'; |
|
33 | + foreach (explode(' ', $allowed_tags) as $tag) { |
|
34 | + $allowed_tag_string .= '<'.$tag.'>'; |
|
35 | 35 | } |
36 | 36 | |
37 | - $text = strip_tags( $text, $allowed_tag_string ); |
|
37 | + $text = strip_tags($text, $allowed_tag_string); |
|
38 | 38 | |
39 | - if ( 'characters' === _x( 'words', 'word count: words or characters?' ) && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ) ) { |
|
40 | - $text = trim( preg_replace( "/[\n\r\t ]+/", ' ', $text ), ' ' ); |
|
41 | - preg_match_all( '/./u', $text, $words_array ); |
|
42 | - $words_array = array_slice( $words_array[0], 0, $num_words + 1 ); |
|
39 | + if ('characters' === _x('words', 'word count: words or characters?') && preg_match('/^utf\-?8$/i', get_option('blog_charset'))) { |
|
40 | + $text = trim(preg_replace("/[\n\r\t ]+/", ' ', $text), ' '); |
|
41 | + preg_match_all('/./u', $text, $words_array); |
|
42 | + $words_array = array_slice($words_array[0], 0, $num_words + 1); |
|
43 | 43 | $sep = ''; |
44 | 44 | } else { |
45 | - $words_array = preg_split( "/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY ); |
|
45 | + $words_array = preg_split("/[\n\r\t ]+/", $text, $num_words + 1, PREG_SPLIT_NO_EMPTY); |
|
46 | 46 | $sep = ' '; |
47 | 47 | } |
48 | 48 | |
49 | - if ( count( $words_array ) > $num_words ) { |
|
50 | - array_pop( $words_array ); |
|
51 | - $text = implode( $sep, $words_array ); |
|
52 | - $text = $text . $more; |
|
49 | + if (count($words_array) > $num_words) { |
|
50 | + array_pop($words_array); |
|
51 | + $text = implode($sep, $words_array); |
|
52 | + $text = $text.$more; |
|
53 | 53 | } else { |
54 | - $text = implode( $sep, $words_array ); |
|
54 | + $text = implode($sep, $words_array); |
|
55 | 55 | } |
56 | 56 | |
57 | - $text = self::close_tags( $text ); |
|
57 | + $text = self::close_tags($text); |
|
58 | 58 | |
59 | - return apply_filters( 'wp_trim_words', $text, $num_words, $more, $original_text ); |
|
59 | + return apply_filters('wp_trim_words', $text, $num_words, $more, $original_text); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -66,36 +66,36 @@ discard block |
||
66 | 66 | * |
67 | 67 | * @return string |
68 | 68 | */ |
69 | - public static function close_tags( $html ) { |
|
69 | + public static function close_tags($html) { |
|
70 | 70 | // Put all opened tags into an array. |
71 | - preg_match_all( '#<([a-z]+)(?: .*)?(?<![/|/ ])>#iU', $html, $result ); |
|
71 | + preg_match_all('#<([a-z]+)(?: .*)?(?<![/|/ ])>#iU', $html, $result); |
|
72 | 72 | |
73 | 73 | $openedtags = $result[1]; |
74 | 74 | |
75 | 75 | // Put all closed tags into an array. |
76 | - preg_match_all( '#</([a-z]+)>#iU', $html, $result ); |
|
76 | + preg_match_all('#</([a-z]+)>#iU', $html, $result); |
|
77 | 77 | |
78 | 78 | $closedtags = $result[1]; |
79 | - $len_opened = count( $openedtags ); |
|
79 | + $len_opened = count($openedtags); |
|
80 | 80 | |
81 | 81 | // All tags are closed. |
82 | - if ( count( $closedtags ) === $len_opened ) { |
|
82 | + if (count($closedtags) === $len_opened) { |
|
83 | 83 | return $html; |
84 | 84 | } |
85 | 85 | |
86 | - $openedtags = array_reverse( $openedtags ); |
|
86 | + $openedtags = array_reverse($openedtags); |
|
87 | 87 | |
88 | 88 | // Close tags. |
89 | - for ( $i = 0; $i < $len_opened; $i++ ) { |
|
90 | - if ( ! in_array( $openedtags[ $i ], $closedtags, true ) ) { |
|
91 | - $html .= '</' . $openedtags[ $i ] . '>'; |
|
89 | + for ($i = 0; $i < $len_opened; $i++) { |
|
90 | + if (!in_array($openedtags[$i], $closedtags, true)) { |
|
91 | + $html .= '</'.$openedtags[$i].'>'; |
|
92 | 92 | } else { |
93 | - unset( $closedtags[ array_search( $openedtags[ $i ], $closedtags ) ] ); |
|
93 | + unset($closedtags[array_search($openedtags[$i], $closedtags)]); |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 | |
97 | - $html = str_replace( array( '</br>', '</hr>', '</wbr>' ), '', $html ); |
|
98 | - $html = str_replace( array( '<br>', '<hr>', '<wbr>' ), array( '<br />', '<hr />', '<wbr />' ), $html ); |
|
97 | + $html = str_replace(array('</br>', '</hr>', '</wbr>'), '', $html); |
|
98 | + $html = str_replace(array('<br>', '<hr>', '<wbr>'), array('<br />', '<hr />', '<wbr />'), $html); |
|
99 | 99 | |
100 | 100 | return $html; |
101 | 101 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * |
108 | 108 | * @return array |
109 | 109 | */ |
110 | - public static function paginate_links( $args = '' ) { |
|
110 | + public static function paginate_links($args = '') { |
|
111 | 111 | $defaults = array( |
112 | 112 | 'base' => '%_%', // Example http://example.com/all_posts.php%_% : %_% is replaced by format (below). |
113 | 113 | 'format' => '?page=%#%', // Example ?page=%#% : %#% is replaced by the page number. |
@@ -115,44 +115,44 @@ discard block |
||
115 | 115 | 'current' => 0, |
116 | 116 | 'show_all' => false, |
117 | 117 | 'prev_next' => true, |
118 | - 'prev_text' => __( '« Previous' ), |
|
119 | - 'next_text' => __( 'Next »' ), |
|
118 | + 'prev_text' => __('« Previous'), |
|
119 | + 'next_text' => __('Next »'), |
|
120 | 120 | 'end_size' => 1, |
121 | 121 | 'mid_size' => 2, |
122 | 122 | 'type' => 'array', |
123 | 123 | 'add_args' => false, // Array of query args to add. |
124 | 124 | 'add_fragment' => '', |
125 | 125 | ); |
126 | - $args = wp_parse_args( $args, $defaults ); |
|
126 | + $args = wp_parse_args($args, $defaults); |
|
127 | 127 | |
128 | 128 | // Who knows what else people pass in $args. |
129 | - $args['total'] = intval( (int) $args['total'] ); |
|
130 | - if ( $args['total'] < 2 ) { |
|
129 | + $args['total'] = intval((int) $args['total']); |
|
130 | + if ($args['total'] < 2) { |
|
131 | 131 | return array(); |
132 | 132 | } |
133 | 133 | $args['current'] = (int) $args['current']; |
134 | 134 | $args['end_size'] = 0 < (int) $args['end_size'] ? (int) $args['end_size'] : 1; // Out of bounds? Make it the default. |
135 | 135 | $args['mid_size'] = 0 <= (int) $args['mid_size'] ? (int) $args['mid_size'] : 2; |
136 | - $args['add_args'] = is_array( $args['add_args'] ) ? $args['add_args'] : false; |
|
136 | + $args['add_args'] = is_array($args['add_args']) ? $args['add_args'] : false; |
|
137 | 137 | $page_links = array(); |
138 | 138 | $dots = false; |
139 | - if ( $args['prev_next'] && $args['current'] && 1 < $args['current'] ) { |
|
140 | - $link = str_replace( '%_%', 2 === absint( $args['current'] ) ? '' : $args['format'], $args['base'] ); |
|
141 | - $link = str_replace( '%#%', $args['current'] - 1, $link ); |
|
142 | - if ( $args['add_args'] ) { |
|
143 | - $link = add_query_arg( $args['add_args'], $link ); |
|
139 | + if ($args['prev_next'] && $args['current'] && 1 < $args['current']) { |
|
140 | + $link = str_replace('%_%', 2 === absint($args['current']) ? '' : $args['format'], $args['base']); |
|
141 | + $link = str_replace('%#%', $args['current'] - 1, $link); |
|
142 | + if ($args['add_args']) { |
|
143 | + $link = add_query_arg($args['add_args'], $link); |
|
144 | 144 | } |
145 | 145 | $link .= $args['add_fragment']; |
146 | - $link = untrailingslashit( $link ); |
|
146 | + $link = untrailingslashit($link); |
|
147 | 147 | $page_links[] = array( |
148 | 148 | 'class' => 'prev page-numbers', |
149 | - 'link' => esc_url( apply_filters( 'paginate_links', $link ) ), |
|
149 | + 'link' => esc_url(apply_filters('paginate_links', $link)), |
|
150 | 150 | 'title' => $args['prev_text'], |
151 | 151 | ); |
152 | 152 | } |
153 | - for ( $n = 1; $n <= $args['total']; $n++ ) { |
|
154 | - $n_display = number_format_i18n( $n ); |
|
155 | - if ( absint( $args['current'] ) === $n ) { |
|
153 | + for ($n = 1; $n <= $args['total']; $n++) { |
|
154 | + $n_display = number_format_i18n($n); |
|
155 | + if (absint($args['current']) === $n) { |
|
156 | 156 | $page_links[] = array( |
157 | 157 | 'class' => 'page-number page-numbers current', |
158 | 158 | 'title' => $n_display, |
@@ -162,42 +162,42 @@ discard block |
||
162 | 162 | ); |
163 | 163 | $dots = true; |
164 | 164 | } else { |
165 | - 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'] ) ) { |
|
166 | - $link = str_replace( '%_%', 1 === absint( $n ) ? '' : $args['format'], $args['base'] ); |
|
167 | - $link = str_replace( '%#%', $n, $link ); |
|
168 | - $link = trailingslashit( $link ) . ltrim( $args['add_fragment'], '/' ); |
|
169 | - if ( $args['add_args'] ) { |
|
170 | - $link = rtrim( add_query_arg( $args['add_args'], $link ), '/' ); |
|
165 | + 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'])) { |
|
166 | + $link = str_replace('%_%', 1 === absint($n) ? '' : $args['format'], $args['base']); |
|
167 | + $link = str_replace('%#%', $n, $link); |
|
168 | + $link = trailingslashit($link).ltrim($args['add_fragment'], '/'); |
|
169 | + if ($args['add_args']) { |
|
170 | + $link = rtrim(add_query_arg($args['add_args'], $link), '/'); |
|
171 | 171 | } |
172 | - $link = str_replace( ' ', '+', $link ); |
|
173 | - $link = untrailingslashit( $link ); |
|
172 | + $link = str_replace(' ', '+', $link); |
|
173 | + $link = untrailingslashit($link); |
|
174 | 174 | $page_links[] = array( |
175 | 175 | 'class' => 'page-number page-numbers', |
176 | - 'link' => esc_url( apply_filters( 'paginate_links', $link ) ), |
|
176 | + 'link' => esc_url(apply_filters('paginate_links', $link)), |
|
177 | 177 | 'title' => $n_display, |
178 | 178 | 'name' => $n_display, |
179 | - 'current' => absint( $args['current'] ) === $n, |
|
179 | + 'current' => absint($args['current']) === $n, |
|
180 | 180 | ); |
181 | 181 | $dots = true; |
182 | - } elseif ( $dots && ! $args['show_all'] ) { |
|
182 | + } elseif ($dots && !$args['show_all']) { |
|
183 | 183 | $page_links[] = array( |
184 | 184 | 'class' => 'dots', |
185 | - 'title' => __( '…' ), |
|
185 | + 'title' => __('…'), |
|
186 | 186 | ); |
187 | 187 | $dots = false; |
188 | 188 | } |
189 | 189 | } |
190 | 190 | } |
191 | - if ( $args['prev_next'] && $args['current'] && ( $args['current'] < $args['total'] || -1 === intval( $args['total'] ) ) ) { |
|
192 | - $link = str_replace( '%_%', $args['format'], $args['base'] ); |
|
193 | - $link = str_replace( '%#%', $args['current'] + 1, $link ); |
|
194 | - if ( $args['add_args'] ) { |
|
195 | - $link = add_query_arg( $args['add_args'], $link ); |
|
191 | + if ($args['prev_next'] && $args['current'] && ($args['current'] < $args['total'] || -1 === intval($args['total']))) { |
|
192 | + $link = str_replace('%_%', $args['format'], $args['base']); |
|
193 | + $link = str_replace('%#%', $args['current'] + 1, $link); |
|
194 | + if ($args['add_args']) { |
|
195 | + $link = add_query_arg($args['add_args'], $link); |
|
196 | 196 | } |
197 | - $link = untrailingslashit( trailingslashit( $link ) . $args['add_fragment'] ); |
|
197 | + $link = untrailingslashit(trailingslashit($link).$args['add_fragment']); |
|
198 | 198 | $page_links[] = array( |
199 | 199 | 'class' => 'next page-numbers', |
200 | - 'link' => esc_url( apply_filters( 'paginate_links', $link ) ), |
|
200 | + 'link' => esc_url(apply_filters('paginate_links', $link)), |
|
201 | 201 | 'title' => $args['next_text'], |
202 | 202 | ); |
203 | 203 | } |
@@ -211,13 +211,13 @@ discard block |
||
211 | 211 | * |
212 | 212 | * @return object |
213 | 213 | */ |
214 | - public static function array_to_object( $array ) { |
|
214 | + public static function array_to_object($array) { |
|
215 | 215 | $obj = new \stdClass; |
216 | 216 | |
217 | - foreach ( $array as $k => $v ) { |
|
218 | - if ( strlen( $k ) ) { |
|
219 | - if ( is_array( $v ) ) { |
|
220 | - $obj->{$k} = self::array_to_object( $v ); // Recursion. |
|
217 | + foreach ($array as $k => $v) { |
|
218 | + if (strlen($k)) { |
|
219 | + if (is_array($v)) { |
|
220 | + $obj->{$k} = self::array_to_object($v); // Recursion. |
|
221 | 221 | } else { |
222 | 222 | $obj->{$k} = $v; |
223 | 223 | } |
@@ -236,26 +236,26 @@ discard block |
||
236 | 236 | $textdomain = Classy::textdomain(); |
237 | 237 | $archives_title = ''; |
238 | 238 | |
239 | - if ( is_category() ) { |
|
240 | - $archives_title = single_cat_title( '', false ); |
|
241 | - } else if ( is_tag() ) { |
|
242 | - $archives_title = 'Tag: ' . single_tag_title( '', false ); |
|
243 | - } else if ( is_author() ) { |
|
244 | - if ( have_posts() ) { |
|
239 | + if (is_category()) { |
|
240 | + $archives_title = single_cat_title('', false); |
|
241 | + } else if (is_tag()) { |
|
242 | + $archives_title = 'Tag: '.single_tag_title('', false); |
|
243 | + } else if (is_author()) { |
|
244 | + if (have_posts()) { |
|
245 | 245 | the_post(); |
246 | - $archives_title = 'Author: ' . get_the_author(); |
|
246 | + $archives_title = 'Author: '.get_the_author(); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | rewind_posts(); |
250 | - } else if ( is_search() ) { |
|
251 | - $archives_title = sprintf( __( 'Search Results for: %s', $textdomain ), '<span>' . get_search_query() . '</span>' ); |
|
252 | - } else if ( is_archive() ) { |
|
253 | - if ( is_day() ) { |
|
250 | + } else if (is_search()) { |
|
251 | + $archives_title = sprintf(__('Search Results for: %s', $textdomain), '<span>'.get_search_query().'</span>'); |
|
252 | + } else if (is_archive()) { |
|
253 | + if (is_day()) { |
|
254 | 254 | $archives_title = get_the_date(); |
255 | - } elseif ( is_month() ) { |
|
256 | - $archives_title = get_the_date( _x( 'F Y', 'monthly archives date format', $textdomain ) ); |
|
257 | - } elseif ( is_year() ) { |
|
258 | - $archives_title = get_the_date( _x( 'Y', 'yearly archives date format', $textdomain ) ); |
|
255 | + } elseif (is_month()) { |
|
256 | + $archives_title = get_the_date(_x('F Y', 'monthly archives date format', $textdomain)); |
|
257 | + } elseif (is_year()) { |
|
258 | + $archives_title = get_the_date(_x('Y', 'yearly archives date format', $textdomain)); |
|
259 | 259 | } else { |
260 | 260 | $archives_title = 'Archives'; |
261 | 261 | } |
@@ -35,15 +35,15 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @return array |
37 | 37 | */ |
38 | - public static function get_scope( $view_name = null ) { |
|
38 | + public static function get_scope($view_name = null) { |
|
39 | 39 | $scope = self::get_common_scope(); |
40 | 40 | |
41 | - if ( is_string( $view_name ) ) { |
|
42 | - $scope = self::extend_scope( $scope, $view_name ); |
|
41 | + if (is_string($view_name)) { |
|
42 | + $scope = self::extend_scope($scope, $view_name); |
|
43 | 43 | } else { |
44 | 44 | $request = Hierarchy::get_current_request(); |
45 | - $file = Hierarchy::get_available_file( 'scope', $request ); |
|
46 | - $scope = self::extend_scope( $scope, $file ); |
|
45 | + $file = Hierarchy::get_available_file('scope', $request); |
|
46 | + $scope = self::extend_scope($scope, $file); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | return $scope; |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @return array |
59 | 59 | */ |
60 | - public static function extend_scope( $scope, $view_name ) { |
|
61 | - return array_merge( $scope, self::require_scope( $view_name ) ); |
|
60 | + public static function extend_scope($scope, $view_name) { |
|
61 | + return array_merge($scope, self::require_scope($view_name)); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -67,8 +67,8 @@ discard block |
||
67 | 67 | * @return array |
68 | 68 | */ |
69 | 69 | public static function get_common_scope() { |
70 | - if ( is_null( self::$common ) ) { |
|
71 | - self::$common = self::require_scope( 'common' ); |
|
70 | + if (is_null(self::$common)) { |
|
71 | + self::$common = self::require_scope('common'); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | return self::$common; |
@@ -81,16 +81,16 @@ discard block |
||
81 | 81 | * |
82 | 82 | * @return array |
83 | 83 | */ |
84 | - public static function require_scope( $filename ) { |
|
84 | + public static function require_scope($filename) { |
|
85 | 85 | $_return = array(); |
86 | 86 | |
87 | - $file = Hierarchy::get_file_path( 'scope', $filename ); |
|
87 | + $file = Hierarchy::get_file_path('scope', $filename); |
|
88 | 88 | |
89 | - if ( file_exists( $file ) ) { |
|
89 | + if (file_exists($file)) { |
|
90 | 90 | require $file; |
91 | 91 | } |
92 | 92 | |
93 | - if ( isset( $data ) ) { |
|
93 | + if (isset($data)) { |
|
94 | 94 | $_return = $data; |
95 | 95 | } |
96 | 96 |
@@ -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 | /* |
@@ -45,25 +45,25 @@ discard block |
||
45 | 45 | * @return array |
46 | 46 | */ |
47 | 47 | public static function get_vars() { |
48 | - if ( is_null( self::$vars ) ) { |
|
48 | + if (is_null(self::$vars)) { |
|
49 | 49 | // Check for a theme config. |
50 | - $config_file = CLASSY_THEME_FRAMEWORK_PATH . '/custom/config.php'; |
|
50 | + $config_file = CLASSY_THEME_FRAMEWORK_PATH.'/custom/config.php'; |
|
51 | 51 | |
52 | - if ( ! file_exists( $config_file ) ) { |
|
53 | - wp_die( sprintf( |
|
52 | + if (!file_exists($config_file)) { |
|
53 | + wp_die(sprintf( |
|
54 | 54 | 'There is no config file in %s custom/config.php', |
55 | - esc_html( CLASSY_THEME ) |
|
56 | - ) ); |
|
55 | + esc_html(CLASSY_THEME) |
|
56 | + )); |
|
57 | 57 | } |
58 | 58 | |
59 | - require_once( $config_file ); |
|
59 | + require_once($config_file); |
|
60 | 60 | $vars = self::get_allowed_variables(); |
61 | 61 | |
62 | - foreach ( $vars as $var ) { |
|
63 | - if ( isset( $$var ) ) { |
|
64 | - self::$vars[ $var ] = $$var; |
|
62 | + foreach ($vars as $var) { |
|
63 | + if (isset($$var)) { |
|
64 | + self::$vars[$var] = $$var; |
|
65 | 65 | |
66 | - unset( $$var ); // We don't require it anymore. |
|
66 | + unset($$var); // We don't require it anymore. |
|
67 | 67 | } |
68 | 68 | } |
69 | 69 | } |
@@ -78,23 +78,23 @@ discard block |
||
78 | 78 | $vars = self::get_vars(); |
79 | 79 | |
80 | 80 | // Init Post Types. |
81 | - if ( isset( $vars['post_types'] ) ) { |
|
82 | - self::init_post_types( $vars['post_types'] ); |
|
81 | + if (isset($vars['post_types'])) { |
|
82 | + self::init_post_types($vars['post_types']); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | // Init Taxonomies. |
86 | - if ( isset( $vars['taxonomies'] ) ) { |
|
87 | - self::init_taxonomies( $vars['taxonomies'] ); |
|
86 | + if (isset($vars['taxonomies'])) { |
|
87 | + self::init_taxonomies($vars['taxonomies']); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | // Init Post Formats. |
91 | - if ( isset( $vars['post_formats'] ) ) { |
|
92 | - self::init_post_formats( $vars['post_formats'] ); |
|
91 | + if (isset($vars['post_formats'])) { |
|
92 | + self::init_post_formats($vars['post_formats']); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | // Init Sidebars. |
96 | - if ( isset( $vars['sidebars'] ) ) { |
|
97 | - self::init_sidebars( $vars['sidebars'] ); |
|
96 | + if (isset($vars['sidebars'])) { |
|
97 | + self::init_sidebars($vars['sidebars']); |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
@@ -103,9 +103,9 @@ discard block |
||
103 | 103 | * |
104 | 104 | * @param array $post_types Custom post types to be registered. |
105 | 105 | */ |
106 | - private static function init_post_types( $post_types ) { |
|
107 | - if ( is_array( $post_types ) ) { |
|
108 | - foreach ( $post_types as $type => $options ) { |
|
106 | + private static function init_post_types($post_types) { |
|
107 | + if (is_array($post_types)) { |
|
108 | + foreach ($post_types as $type => $options) { |
|
109 | 109 | self::add_post_type( |
110 | 110 | $type, |
111 | 111 | $options['config'], |
@@ -124,25 +124,25 @@ discard block |
||
124 | 124 | * @param string $singular Optional. Default singular name. |
125 | 125 | * @param string $multiple Optional. Default multiple name. |
126 | 126 | */ |
127 | - private static function add_post_type( $name, $config, $singular = 'Entry', $multiple = 'Entries' ) { |
|
127 | + private static function add_post_type($name, $config, $singular = 'Entry', $multiple = 'Entries') { |
|
128 | 128 | $domain = Classy::textdomain(); |
129 | 129 | |
130 | - if ( ! isset( $config['labels'] ) ) { |
|
130 | + if (!isset($config['labels'])) { |
|
131 | 131 | $config['labels'] = array( |
132 | - 'name' => __( $multiple, $domain ), |
|
133 | - 'singular_name' => __( $singular, $domain ), |
|
134 | - 'not_found' => __( 'No ' . $multiple . ' Found', $domain ), |
|
135 | - 'not_found_in_trash' => __( 'No ' . $multiple . ' found in Trash', $domain ), |
|
136 | - 'edit_item' => __( 'Edit ', $singular, $domain ), |
|
137 | - 'search_items' => __( 'Search ' . $multiple, $domain ), |
|
138 | - 'view_item' => __( 'View ', $singular, $domain ), |
|
139 | - 'new_item' => __( 'New ' . $singular, $domain ), |
|
140 | - 'add_new' => __( 'Add New', $domain ), |
|
141 | - 'add_new_item' => __( 'Add New ' . $singular, $domain ), |
|
132 | + 'name' => __($multiple, $domain), |
|
133 | + 'singular_name' => __($singular, $domain), |
|
134 | + 'not_found' => __('No '.$multiple.' Found', $domain), |
|
135 | + 'not_found_in_trash' => __('No '.$multiple.' found in Trash', $domain), |
|
136 | + 'edit_item' => __('Edit ', $singular, $domain), |
|
137 | + 'search_items' => __('Search '.$multiple, $domain), |
|
138 | + 'view_item' => __('View ', $singular, $domain), |
|
139 | + 'new_item' => __('New '.$singular, $domain), |
|
140 | + 'add_new' => __('Add New', $domain), |
|
141 | + 'add_new_item' => __('Add New '.$singular, $domain), |
|
142 | 142 | ); |
143 | 143 | } |
144 | 144 | |
145 | - register_post_type( $name, $config ); |
|
145 | + register_post_type($name, $config); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -150,9 +150,9 @@ discard block |
||
150 | 150 | * |
151 | 151 | * @param array $taxonomies Taxonomies to be registered. |
152 | 152 | */ |
153 | - private static function init_taxonomies( $taxonomies ) { |
|
154 | - if ( is_array( $taxonomies ) ) { |
|
155 | - foreach ( $taxonomies as $type => $options ) { |
|
153 | + private static function init_taxonomies($taxonomies) { |
|
154 | + if (is_array($taxonomies)) { |
|
155 | + foreach ($taxonomies as $type => $options) { |
|
156 | 156 | self::add_taxonomy( |
157 | 157 | $type, |
158 | 158 | $options['for'], |
@@ -173,26 +173,26 @@ discard block |
||
173 | 173 | * @param string $singular Optional. Default singular name. |
174 | 174 | * @param string $multiple Optional. Default multiple name. |
175 | 175 | */ |
176 | - private static function add_taxonomy( $name, $object_type, $config, $singular = 'Entry', $multiple = 'Entries' ) { |
|
176 | + private static function add_taxonomy($name, $object_type, $config, $singular = 'Entry', $multiple = 'Entries') { |
|
177 | 177 | $domain = Classy::textdomain(); |
178 | 178 | |
179 | - if ( ! isset( $config['labels'] ) ) { |
|
179 | + if (!isset($config['labels'])) { |
|
180 | 180 | $config['labels'] = array( |
181 | - 'name' => __( $multiple, $domain ), |
|
182 | - 'singular_name' => __( $singular, $domain ), |
|
183 | - 'search_items' => __( 'Search ' . $multiple, $domain ), |
|
184 | - 'all_items' => __( 'All ' . $multiple, $domain ), |
|
185 | - 'parent_item' => __( 'Parent ' . $singular, $domain ), |
|
186 | - 'parent_item_colon' => __( 'Parent ' . $singular . ':', $domain ), |
|
187 | - 'edit_item' => __( 'Edit ' . $singular, $domain ), |
|
188 | - 'update_item' => __( 'Update ' . $singular, $domain ), |
|
189 | - 'add_new_item' => __( 'Add New ' . $singular, $domain ), |
|
190 | - 'new_item_name' => __( 'New ' . $singular . ' Name', $domain ), |
|
191 | - 'menu_name' => __( $singular, $domain ), |
|
181 | + 'name' => __($multiple, $domain), |
|
182 | + 'singular_name' => __($singular, $domain), |
|
183 | + 'search_items' => __('Search '.$multiple, $domain), |
|
184 | + 'all_items' => __('All '.$multiple, $domain), |
|
185 | + 'parent_item' => __('Parent '.$singular, $domain), |
|
186 | + 'parent_item_colon' => __('Parent '.$singular.':', $domain), |
|
187 | + 'edit_item' => __('Edit '.$singular, $domain), |
|
188 | + 'update_item' => __('Update '.$singular, $domain), |
|
189 | + 'add_new_item' => __('Add New '.$singular, $domain), |
|
190 | + 'new_item_name' => __('New '.$singular.' Name', $domain), |
|
191 | + 'menu_name' => __($singular, $domain), |
|
192 | 192 | ); |
193 | 193 | } |
194 | 194 | |
195 | - register_taxonomy( $name, $object_type, $config ); |
|
195 | + register_taxonomy($name, $object_type, $config); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | /** |
@@ -200,9 +200,9 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @param array $post_formats Array with available post formats. |
202 | 202 | */ |
203 | - private static function init_post_formats( $post_formats ) { |
|
204 | - if ( is_array( $post_formats ) ) { |
|
205 | - add_theme_support( 'post-formats', $post_formats ); |
|
203 | + private static function init_post_formats($post_formats) { |
|
204 | + if (is_array($post_formats)) { |
|
205 | + add_theme_support('post-formats', $post_formats); |
|
206 | 206 | } |
207 | 207 | } |
208 | 208 | |
@@ -211,16 +211,16 @@ discard block |
||
211 | 211 | * |
212 | 212 | * @param array $sidebars Sidebars to be registered. |
213 | 213 | */ |
214 | - private static function init_sidebars( $sidebars ) { |
|
214 | + private static function init_sidebars($sidebars) { |
|
215 | 215 | $domain = Classy::textdomain(); |
216 | 216 | |
217 | - if ( is_array( $sidebars ) ) { |
|
218 | - foreach ( $sidebars as $id => $title ) { |
|
217 | + if (is_array($sidebars)) { |
|
218 | + foreach ($sidebars as $id => $title) { |
|
219 | 219 | register_sidebar( |
220 | 220 | array( |
221 | 221 | 'id' => $id, |
222 | - 'name' => __( $title, $domain ), |
|
223 | - 'description' => __( $title, $domain ), |
|
222 | + 'name' => __($title, $domain), |
|
223 | + 'description' => __($title, $domain), |
|
224 | 224 | 'before_widget' => '<div id="%1$s" class="widget %2$s"><div class="widget-inner">', |
225 | 225 | 'after_widget' => '</div></div>', |
226 | 226 | 'before_title' => '<h3>', |
@@ -26,39 +26,39 @@ discard block |
||
26 | 26 | */ |
27 | 27 | protected static function check_request() { |
28 | 28 | |
29 | - if ( is_404() ) : return '404'; |
|
29 | + if (is_404()) : return '404'; |
|
30 | 30 | |
31 | - elseif ( is_search() ) : return 'search'; |
|
31 | + elseif (is_search()) : return 'search'; |
|
32 | 32 | |
33 | - elseif ( is_front_page() ) : return 'front-page'; |
|
33 | + elseif (is_front_page()) : return 'front-page'; |
|
34 | 34 | |
35 | - elseif ( is_home() ) : return 'home'; |
|
35 | + elseif (is_home()) : return 'home'; |
|
36 | 36 | |
37 | - elseif ( is_post_type_archive() ) : return 'post_type_archive'; |
|
37 | + elseif (is_post_type_archive()) : return 'post_type_archive'; |
|
38 | 38 | |
39 | - elseif ( is_tax() ) : return 'taxonomy'; |
|
39 | + elseif (is_tax()) : return 'taxonomy'; |
|
40 | 40 | |
41 | - elseif ( is_attachment() ) : return 'attachment'; |
|
41 | + elseif (is_attachment()) : return 'attachment'; |
|
42 | 42 | |
43 | - elseif ( is_single() ) : return 'single'; |
|
43 | + elseif (is_single()) : return 'single'; |
|
44 | 44 | |
45 | - elseif ( self::is_classy_template() ) : return 'classy-template'; |
|
45 | + elseif (self::is_classy_template()) : return 'classy-template'; |
|
46 | 46 | |
47 | - elseif ( is_page() ) : return 'page'; |
|
47 | + elseif (is_page()) : return 'page'; |
|
48 | 48 | |
49 | - elseif ( is_singular() ) : return 'singular'; |
|
49 | + elseif (is_singular()) : return 'singular'; |
|
50 | 50 | |
51 | - elseif ( is_category() ) : return 'category'; |
|
51 | + elseif (is_category()) : return 'category'; |
|
52 | 52 | |
53 | - elseif ( is_tag() ) : return 'tag'; |
|
53 | + elseif (is_tag()) : return 'tag'; |
|
54 | 54 | |
55 | - elseif ( is_author() ) : return 'author'; |
|
55 | + elseif (is_author()) : return 'author'; |
|
56 | 56 | |
57 | - elseif ( is_date() ) : return 'date'; |
|
57 | + elseif (is_date()) : return 'date'; |
|
58 | 58 | |
59 | - elseif ( is_archive() ) : return 'archive'; |
|
59 | + elseif (is_archive()) : return 'archive'; |
|
60 | 60 | |
61 | - elseif ( is_paged() ) : return 'paged'; |
|
61 | + elseif (is_paged()) : return 'paged'; |
|
62 | 62 | |
63 | 63 | else : |
64 | 64 | |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * @return string |
74 | 74 | */ |
75 | 75 | public static function get_current_request() { |
76 | - if ( is_null( self::$current_request ) ) { |
|
76 | + if (is_null(self::$current_request)) { |
|
77 | 77 | self::$current_request = self::check_request(); |
78 | 78 | } |
79 | 79 | |
@@ -89,13 +89,13 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @return string Full file path. |
91 | 91 | */ |
92 | - public static function get_file_path( $type = 'view', $view ) { |
|
93 | - $view = str_replace( '.', '/', $view ); |
|
92 | + public static function get_file_path($type = 'view', $view) { |
|
93 | + $view = str_replace('.', '/', $view); |
|
94 | 94 | |
95 | - if ( 'view' === $type ) { |
|
96 | - return CLASSY_THEME_PATH . View::$folder . '/' . $view . '.blade.php'; |
|
97 | - } elseif ( 'scope' === $type ) { |
|
98 | - return CLASSY_THEME_PATH . Scope::$folder . '/' . $view . '.php'; |
|
95 | + if ('view' === $type) { |
|
96 | + return CLASSY_THEME_PATH.View::$folder.'/'.$view.'.blade.php'; |
|
97 | + } elseif ('scope' === $type) { |
|
98 | + return CLASSY_THEME_PATH.Scope::$folder.'/'.$view.'.php'; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | return ''; |
@@ -109,9 +109,9 @@ discard block |
||
109 | 109 | * |
110 | 110 | * @return boolean true|false |
111 | 111 | */ |
112 | - public static function file_exists( $type = 'view', $file ) { |
|
112 | + public static function file_exists($type = 'view', $file) { |
|
113 | 113 | return file_exists( |
114 | - self::get_file_path( $type, str_replace( '.', '/', $file ) ) |
|
114 | + self::get_file_path($type, str_replace('.', '/', $file)) |
|
115 | 115 | ); |
116 | 116 | } |
117 | 117 | |
@@ -123,11 +123,11 @@ discard block |
||
123 | 123 | * |
124 | 124 | * @return array|bool |
125 | 125 | */ |
126 | - public static function get_available_file( $type = 'view', $page ) { |
|
127 | - $views = self::get_request_hierarchy_list( $page ); |
|
126 | + public static function get_available_file($type = 'view', $page) { |
|
127 | + $views = self::get_request_hierarchy_list($page); |
|
128 | 128 | |
129 | - foreach ( $views as $view ) { |
|
130 | - if ( self::file_exists( $type, $view ) ) { |
|
129 | + foreach ($views as $view) { |
|
130 | + if (self::file_exists($type, $view)) { |
|
131 | 131 | return $view; |
132 | 132 | } |
133 | 133 | } |
@@ -142,26 +142,26 @@ discard block |
||
142 | 142 | * |
143 | 143 | * @return array |
144 | 144 | */ |
145 | - private static function get_request_hierarchy_list( $type ) { |
|
145 | + private static function get_request_hierarchy_list($type) { |
|
146 | 146 | $views = array(); |
147 | 147 | |
148 | - if ( 'home' === $type ) : |
|
148 | + if ('home' === $type) : |
|
149 | 149 | $views[] = 'home'; |
150 | - elseif ( 'single' === $type ) : |
|
150 | + elseif ('single' === $type) : |
|
151 | 151 | |
152 | - $views[] = get_post_type() . '.single'; |
|
152 | + $views[] = get_post_type().'.single'; |
|
153 | 153 | $views[] = 'single'; |
154 | 154 | |
155 | - elseif ( 'post_type_archive' === $type ) : |
|
155 | + elseif ('post_type_archive' === $type) : |
|
156 | 156 | |
157 | - $views[] = get_post_type() . '.archive'; |
|
157 | + $views[] = get_post_type().'.archive'; |
|
158 | 158 | $views[] = 'archive'; |
159 | 159 | |
160 | - elseif ( 'taxonomy' === $type ) : |
|
160 | + elseif ('taxonomy' === $type) : |
|
161 | 161 | |
162 | 162 | $term = get_queried_object(); |
163 | 163 | |
164 | - if ( ! empty( $term->slug ) ) { |
|
164 | + if (!empty($term->slug)) { |
|
165 | 165 | $taxonomy = $term->taxonomy; |
166 | 166 | |
167 | 167 | $views[] = "taxonomy.$taxonomy-{$term->slug}"; |
@@ -171,11 +171,11 @@ discard block |
||
171 | 171 | $views[] = 'taxonomy.taxonomy'; |
172 | 172 | $views[] = 'taxonomy'; |
173 | 173 | |
174 | - elseif ( 'category' === $type ) : |
|
174 | + elseif ('category' === $type) : |
|
175 | 175 | |
176 | 176 | $category = get_queried_object(); |
177 | 177 | |
178 | - if ( ! empty( $category->slug ) ) { |
|
178 | + if (!empty($category->slug)) { |
|
179 | 179 | $views[] = "category.{$category->slug}"; |
180 | 180 | $views[] = "category.{$category->term_id}"; |
181 | 181 | } |
@@ -183,18 +183,18 @@ discard block |
||
183 | 183 | $views[] = 'category.category'; |
184 | 184 | $views[] = 'category'; |
185 | 185 | |
186 | - elseif ( 'attachment' === $type ) : |
|
186 | + elseif ('attachment' === $type) : |
|
187 | 187 | |
188 | 188 | $attachment = get_queried_object(); |
189 | 189 | |
190 | - if ( $attachment ) { |
|
191 | - if ( false !== strpos( $attachment->post_mime_type, '/' ) ) { |
|
192 | - list( $type, $subtype ) = explode( '/', $attachment->post_mime_type ); |
|
190 | + if ($attachment) { |
|
191 | + if (false !== strpos($attachment->post_mime_type, '/')) { |
|
192 | + list($type, $subtype) = explode('/', $attachment->post_mime_type); |
|
193 | 193 | } else { |
194 | - list( $type, $subtype ) = array( $attachment->post_mime_type, '' ); |
|
194 | + list($type, $subtype) = array($attachment->post_mime_type, ''); |
|
195 | 195 | } |
196 | 196 | |
197 | - if ( ! empty( $subtype ) ) { |
|
197 | + if (!empty($subtype)) { |
|
198 | 198 | $views[] = "attachment.{$type}.{$subtype}"; |
199 | 199 | $views[] = "attachment.{$subtype}"; |
200 | 200 | |
@@ -209,11 +209,11 @@ discard block |
||
209 | 209 | $views[] = 'attachment.attachment'; |
210 | 210 | $views[] = 'attachment'; |
211 | 211 | |
212 | - elseif ( 'tag' === $type ) : |
|
212 | + elseif ('tag' === $type) : |
|
213 | 213 | |
214 | 214 | $tag = get_queried_object(); |
215 | 215 | |
216 | - if ( ! empty( $tag->slug ) ) { |
|
216 | + if (!empty($tag->slug)) { |
|
217 | 217 | $views[] = "post.tag.{$tag->slug}"; |
218 | 218 | $views[] = "post.tag.{$tag->term_id}"; |
219 | 219 | |
@@ -224,11 +224,11 @@ discard block |
||
224 | 224 | $views[] = 'post.tag'; |
225 | 225 | $views[] = 'tag'; |
226 | 226 | |
227 | - elseif ( 'author' === $type ) : |
|
227 | + elseif ('author' === $type) : |
|
228 | 228 | |
229 | 229 | $author = get_queried_object(); |
230 | 230 | |
231 | - if ( $author instanceof \WP_User ) { |
|
231 | + if ($author instanceof \WP_User) { |
|
232 | 232 | $views[] = "post.author.{$author->user_nicename}"; |
233 | 233 | $views[] = "post.author.{$author->ID}"; |
234 | 234 | |
@@ -239,14 +239,14 @@ discard block |
||
239 | 239 | $views[] = 'post.author'; |
240 | 240 | $views[] = 'author'; |
241 | 241 | |
242 | - elseif ( 'front-page' === $type ) : |
|
242 | + elseif ('front-page' === $type) : |
|
243 | 243 | |
244 | 244 | $template = self::get_classy_template(); |
245 | 245 | |
246 | - if ( ! empty( $template ) ) { |
|
246 | + if (!empty($template)) { |
|
247 | 247 | $views[] = $template; |
248 | - $views[] = 'page.' . $template; |
|
249 | - $views[] = 'template.' . $template; |
|
248 | + $views[] = 'page.'.$template; |
|
249 | + $views[] = 'template.'.$template; |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | $views[] = 'front-page.front-page'; |
@@ -255,37 +255,37 @@ discard block |
||
255 | 255 | $views[] = 'home.home'; |
256 | 256 | $views[] = 'home'; |
257 | 257 | |
258 | - $views = array_merge( $views, self::get_request_hierarchy_list( 'post_type_archive' ) ); |
|
258 | + $views = array_merge($views, self::get_request_hierarchy_list('post_type_archive')); |
|
259 | 259 | |
260 | - elseif ( 'classy-template' === $type ) : |
|
260 | + elseif ('classy-template' === $type) : |
|
261 | 261 | |
262 | 262 | $template = self::get_classy_template(); |
263 | 263 | |
264 | 264 | $views[] = $template; |
265 | - $views[] = 'page.' . $template; |
|
266 | - $views[] = 'template.' . $template; |
|
265 | + $views[] = 'page.'.$template; |
|
266 | + $views[] = 'template.'.$template; |
|
267 | 267 | $views[] = 'page.page'; |
268 | 268 | $views[] = 'page'; |
269 | 269 | |
270 | - elseif ( 'page' === $type ) : |
|
270 | + elseif ('page' === $type) : |
|
271 | 271 | |
272 | 272 | $id = get_queried_object_id(); |
273 | 273 | |
274 | - $pagename = get_query_var( 'pagename' ); |
|
274 | + $pagename = get_query_var('pagename'); |
|
275 | 275 | |
276 | - if ( ! $pagename && $id ) { |
|
276 | + if (!$pagename && $id) { |
|
277 | 277 | // If a static page is set as the front page, $pagename will not be set. Retrieve it from the queried object. |
278 | - if ( $post = get_queried_object() ) { |
|
278 | + if ($post = get_queried_object()) { |
|
279 | 279 | $pagename = $post->post_name; |
280 | 280 | } |
281 | 281 | } |
282 | 282 | |
283 | - if ( $pagename ) { |
|
284 | - $views[] = 'page.' . $pagename; |
|
283 | + if ($pagename) { |
|
284 | + $views[] = 'page.'.$pagename; |
|
285 | 285 | } |
286 | 286 | |
287 | - if ( $id ) { |
|
288 | - $views[] = 'page.' . $id; |
|
287 | + if ($id) { |
|
288 | + $views[] = 'page.'.$id; |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | $views[] = 'page.page'; |
@@ -317,9 +317,9 @@ discard block |
||
317 | 317 | * @return mixed |
318 | 318 | */ |
319 | 319 | public static function get_classy_template() { |
320 | - preg_match( '/classy\-(.*)/', get_page_template_slug(), $matches ); |
|
320 | + preg_match('/classy\-(.*)/', get_page_template_slug(), $matches); |
|
321 | 321 | |
322 | - if ( ! empty( $matches ) && isset( $matches[1] ) ) { |
|
322 | + if (!empty($matches) && isset($matches[1])) { |
|
323 | 323 | return $matches[1]; |
324 | 324 | } |
325 | 325 |
@@ -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 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | |
61 | 61 | $this->load_custom_includes(); |
62 | 62 | |
63 | - add_filter( 'theme_page_templates', array( $this, 'filter_templates' ) ); |
|
63 | + add_filter('theme_page_templates', array($this, 'filter_templates')); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -74,20 +74,20 @@ discard block |
||
74 | 74 | * Load template functions. |
75 | 75 | */ |
76 | 76 | private function load_template_function() { |
77 | - require_once( CLASSY_THEME_FRAMEWORK_PATH . 'core/functions/template-functions.php' ); |
|
77 | + require_once(CLASSY_THEME_FRAMEWORK_PATH.'core/functions/template-functions.php'); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
81 | 81 | * Loads custom files specified in custom/config.php. |
82 | 82 | */ |
83 | 83 | private function load_custom_includes() { |
84 | - $include = self::get_config_var( 'include' ); |
|
84 | + $include = self::get_config_var('include'); |
|
85 | 85 | |
86 | - if ( is_array( $include ) ) { |
|
87 | - foreach ( $include as $file ) { |
|
88 | - $files = (array) glob( CLASSY_THEME_FRAMEWORK_PATH . 'custom/' . $file ); |
|
89 | - foreach ( $files as $filename ) { |
|
90 | - if ( is_readable( $filename ) ) { |
|
86 | + if (is_array($include)) { |
|
87 | + foreach ($include as $file) { |
|
88 | + $files = (array) glob(CLASSY_THEME_FRAMEWORK_PATH.'custom/'.$file); |
|
89 | + foreach ($files as $filename) { |
|
90 | + if (is_readable($filename)) { |
|
91 | 91 | require_once $filename; |
92 | 92 | } |
93 | 93 | } |
@@ -105,13 +105,13 @@ discard block |
||
105 | 105 | |
106 | 106 | $theme = wp_get_theme(); |
107 | 107 | |
108 | - define( 'CLASSY_THEME', $theme->template ); |
|
109 | - define( 'CLASSY_THEME_NAME', $theme->get( 'Name' ) ); |
|
110 | - define( 'CLASSY_THEME_PATH', get_template_directory() . '/' ); |
|
111 | - define( 'CLASSY_THEME_DIR', get_template_directory_uri() . '/' ); |
|
112 | - define( 'CLASSY_THEME_VERSION', $theme->get( 'Version' ) ); |
|
113 | - define( 'CLASSY_THEME_FRAMEWORK_PATH', CLASSY_THEME_PATH . 'app/' ); |
|
114 | - define( 'CLASSY_THEME_FRAMEWORK_DIR', CLASSY_THEME_DIR . 'app/' ); |
|
108 | + define('CLASSY_THEME', $theme->template); |
|
109 | + define('CLASSY_THEME_NAME', $theme->get('Name')); |
|
110 | + define('CLASSY_THEME_PATH', get_template_directory().'/'); |
|
111 | + define('CLASSY_THEME_DIR', get_template_directory_uri().'/'); |
|
112 | + define('CLASSY_THEME_VERSION', $theme->get('Version')); |
|
113 | + define('CLASSY_THEME_FRAMEWORK_PATH', CLASSY_THEME_PATH.'app/'); |
|
114 | + define('CLASSY_THEME_FRAMEWORK_DIR', CLASSY_THEME_DIR.'app/'); |
|
115 | 115 | |
116 | 116 | } |
117 | 117 | |
@@ -129,11 +129,11 @@ discard block |
||
129 | 129 | * |
130 | 130 | * @return array |
131 | 131 | */ |
132 | - public function filter_templates( $page_templates = array() ) { |
|
132 | + public function filter_templates($page_templates = array()) { |
|
133 | 133 | |
134 | 134 | $custom_templates = View::get_page_templates_list(); |
135 | 135 | |
136 | - return array_merge( $page_templates, $custom_templates ); |
|
136 | + return array_merge($page_templates, $custom_templates); |
|
137 | 137 | |
138 | 138 | } |
139 | 139 | |
@@ -144,11 +144,11 @@ discard block |
||
144 | 144 | * |
145 | 145 | * @return mixed|bool Return false if variable not found. |
146 | 146 | */ |
147 | - public static function get_config_var( $name ) { |
|
147 | + public static function get_config_var($name) { |
|
148 | 148 | |
149 | 149 | $vars = Config::get_vars(); |
150 | 150 | |
151 | - return ( isset( $vars[ $name ] ) ) ? $vars[ $name ] : false; |
|
151 | + return (isset($vars[$name])) ? $vars[$name] : false; |
|
152 | 152 | |
153 | 153 | } |
154 | 154 | |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | */ |
160 | 160 | public static function textdomain() { |
161 | 161 | |
162 | - $textdomain = Classy::get_config_var( 'textdomain' ); |
|
162 | + $textdomain = Classy::get_config_var('textdomain'); |
|
163 | 163 | |
164 | 164 | return $textdomain ? $textdomain : CLASSY_THEME; |
165 | 165 | |
@@ -174,17 +174,17 @@ discard block |
||
174 | 174 | * @param array|null $data Additional params. |
175 | 175 | * @return void |
176 | 176 | */ |
177 | - public static function render( $view = null, $data = null ) { |
|
177 | + public static function render($view = null, $data = null) { |
|
178 | 178 | |
179 | - $views = CLASSY_THEME_PATH . View::$folder; |
|
180 | - $cache = WP_CONTENT_DIR . '/viewcache'; |
|
179 | + $views = CLASSY_THEME_PATH.View::$folder; |
|
180 | + $cache = WP_CONTENT_DIR.'/viewcache'; |
|
181 | 181 | $common_scope = Scope::get_common_scope(); |
182 | 182 | |
183 | - if ( null !== $view && is_string( $view ) ) { |
|
183 | + if (null !== $view && is_string($view)) { |
|
184 | 184 | |
185 | - if ( $data && is_array( $data ) ) { |
|
185 | + if ($data && is_array($data)) { |
|
186 | 186 | |
187 | - $scope = array_merge( $common_scope, $data ); |
|
187 | + $scope = array_merge($common_scope, $data); |
|
188 | 188 | |
189 | 189 | } else { |
190 | 190 | |
@@ -199,11 +199,11 @@ discard block |
||
199 | 199 | |
200 | 200 | } |
201 | 201 | |
202 | - $renderer = new BladeRenderer( $views, array( 'cache_path' => $cache ) ); |
|
202 | + $renderer = new BladeRenderer($views, array('cache_path' => $cache)); |
|
203 | 203 | |
204 | - $html = $renderer->render( $view, $scope ); |
|
204 | + $html = $renderer->render($view, $scope); |
|
205 | 205 | |
206 | - echo self::maybe_minify( $html ); |
|
206 | + echo self::maybe_minify($html); |
|
207 | 207 | |
208 | 208 | } |
209 | 209 | |
@@ -213,13 +213,13 @@ discard block |
||
213 | 213 | * @param string $html HTML string. |
214 | 214 | * @return string |
215 | 215 | */ |
216 | - private static function maybe_minify( $html ) { |
|
216 | + private static function maybe_minify($html) { |
|
217 | 217 | |
218 | - $minify_html = self::get_config_var( 'minify_html' ); |
|
218 | + $minify_html = self::get_config_var('minify_html'); |
|
219 | 219 | |
220 | - if ( true === $minify_html ) { |
|
220 | + if (true === $minify_html) { |
|
221 | 221 | |
222 | - $html = self::minify_html( $html ); |
|
222 | + $html = self::minify_html($html); |
|
223 | 223 | |
224 | 224 | } |
225 | 225 | |
@@ -233,13 +233,13 @@ discard block |
||
233 | 233 | * @param string $html HTML string. |
234 | 234 | * @return string |
235 | 235 | */ |
236 | - private static function minify_html( $html ) { |
|
236 | + private static function minify_html($html) { |
|
237 | 237 | |
238 | 238 | $search = array( |
239 | 239 | "/\n/s", |
240 | - '/\>[^\S ]+/s', // Strip whitespaces after tags, except space. |
|
241 | - '/[^\S ]+\</s', // Strip whitespaces before tags, except space. |
|
242 | - '/(\s)+/s', // Shorten multiple whitespace sequences. |
|
240 | + '/\>[^\S ]+/s', // Strip whitespaces after tags, except space. |
|
241 | + '/[^\S ]+\</s', // Strip whitespaces before tags, except space. |
|
242 | + '/(\s)+/s', // Shorten multiple whitespace sequences. |
|
243 | 243 | '/<!--(.|\s)*?-->/', |
244 | 244 | ); |
245 | 245 | |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | '', |
252 | 252 | ); |
253 | 253 | |
254 | - return preg_replace( $search, $replace, $html ); |
|
254 | + return preg_replace($search, $replace, $html); |
|
255 | 255 | |
256 | 256 | } |
257 | 257 | |
@@ -276,27 +276,27 @@ discard block |
||
276 | 276 | * |
277 | 277 | * @return array |
278 | 278 | */ |
279 | - public static function get_posts( $args = false, $return = '\Classy\Models\Post' ) { |
|
279 | + public static function get_posts($args = false, $return = '\Classy\Models\Post') { |
|
280 | 280 | |
281 | 281 | $_return = array(); |
282 | 282 | |
283 | - $query = Query_Helper::find_query( $args ); |
|
283 | + $query = Query_Helper::find_query($args); |
|
284 | 284 | |
285 | - if ( isset( $query->posts ) ) { |
|
285 | + if (isset($query->posts)) { |
|
286 | 286 | |
287 | - foreach ( $query->posts as $post ) { |
|
287 | + foreach ($query->posts as $post) { |
|
288 | 288 | |
289 | - if ( 'id' === $return ) { |
|
289 | + if ('id' === $return) { |
|
290 | 290 | |
291 | 291 | $_return[] = $post->id; |
292 | 292 | |
293 | - } elseif ( 'object' === $return ) { |
|
293 | + } elseif ('object' === $return) { |
|
294 | 294 | |
295 | 295 | $_return[] = $post; |
296 | 296 | |
297 | - } elseif ( class_exists( $return ) ) { |
|
297 | + } elseif (class_exists($return)) { |
|
298 | 298 | |
299 | - $_return[] = new $return( $post ); |
|
299 | + $_return[] = new $return($post); |
|
300 | 300 | |
301 | 301 | } |
302 | 302 | } |
@@ -314,11 +314,11 @@ discard block |
||
314 | 314 | * |
315 | 315 | * @return mixed |
316 | 316 | */ |
317 | - public static function get_post( $args = false, $return_type = '\Classy\Models\Post' ) { |
|
317 | + public static function get_post($args = false, $return_type = '\Classy\Models\Post') { |
|
318 | 318 | |
319 | - $posts = self::get_posts( $args, $return_type ); |
|
319 | + $posts = self::get_posts($args, $return_type); |
|
320 | 320 | |
321 | - if ( $post = reset( $posts ) ) { |
|
321 | + if ($post = reset($posts)) { |
|
322 | 322 | return $post; |
323 | 323 | } |
324 | 324 | |
@@ -331,62 +331,62 @@ discard block |
||
331 | 331 | * |
332 | 332 | * @return array mixed |
333 | 333 | */ |
334 | - public static function get_pagination( $prefs = array() ) { |
|
334 | + public static function get_pagination($prefs = array()) { |
|
335 | 335 | |
336 | 336 | global $wp_query; |
337 | 337 | global $paged; |
338 | 338 | global $wp_rewrite; |
339 | 339 | |
340 | 340 | $args = array(); |
341 | - $args['total'] = ceil( $wp_query->found_posts / $wp_query->query_vars['posts_per_page'] ); |
|
341 | + $args['total'] = ceil($wp_query->found_posts / $wp_query->query_vars['posts_per_page']); |
|
342 | 342 | |
343 | - if ( $wp_rewrite->using_permalinks() ) { |
|
343 | + if ($wp_rewrite->using_permalinks()) { |
|
344 | 344 | |
345 | - $url = explode( '?', get_pagenum_link( 0 ) ); |
|
345 | + $url = explode('?', get_pagenum_link(0)); |
|
346 | 346 | |
347 | - if ( isset( $url[1] ) ) { |
|
348 | - parse_str( $url[1], $query ); |
|
347 | + if (isset($url[1])) { |
|
348 | + parse_str($url[1], $query); |
|
349 | 349 | $args['add_args'] = $query; |
350 | 350 | } |
351 | 351 | |
352 | 352 | $args['format'] = 'page/%#%'; |
353 | - $args['base'] = trailingslashit( $url[0] ).'%_%'; |
|
353 | + $args['base'] = trailingslashit($url[0]).'%_%'; |
|
354 | 354 | |
355 | 355 | } else { |
356 | 356 | $big = 999999999; |
357 | - $args['base'] = str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ); |
|
357 | + $args['base'] = str_replace($big, '%#%', esc_url(get_pagenum_link($big))); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | $args['type'] = 'array'; |
361 | - $args['current'] = max( 1, get_query_var( 'paged' ) ); |
|
362 | - $args['mid_size'] = max( 9 - $args['current'], 3 ); |
|
361 | + $args['current'] = max(1, get_query_var('paged')); |
|
362 | + $args['mid_size'] = max(9 - $args['current'], 3); |
|
363 | 363 | $args['prev_next'] = false; |
364 | 364 | |
365 | - if ( is_int( $prefs ) ) { |
|
365 | + if (is_int($prefs)) { |
|
366 | 366 | $args['mid_size'] = $prefs - 2; |
367 | 367 | } else { |
368 | - $args = array_merge( $args, $prefs ); |
|
368 | + $args = array_merge($args, $prefs); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | $data = array(); |
372 | - $data['pages'] = Helper::paginate_links( $args ); |
|
373 | - $next = get_next_posts_page_link( $args['total'] ); |
|
372 | + $data['pages'] = Helper::paginate_links($args); |
|
373 | + $next = get_next_posts_page_link($args['total']); |
|
374 | 374 | |
375 | - if ( $next ) { |
|
376 | - $data['next'] = array( 'link' => untrailingslashit( $next ), 'class' => 'page-numbers next' ); |
|
375 | + if ($next) { |
|
376 | + $data['next'] = array('link' => untrailingslashit($next), 'class' => 'page-numbers next'); |
|
377 | 377 | } |
378 | 378 | |
379 | - $prev = previous_posts( false ); |
|
379 | + $prev = previous_posts(false); |
|
380 | 380 | |
381 | - if ( $prev ) { |
|
382 | - $data['prev'] = array( 'link' => untrailingslashit( $prev ), 'class' => 'page-numbers prev' ); |
|
381 | + if ($prev) { |
|
382 | + $data['prev'] = array('link' => untrailingslashit($prev), 'class' => 'page-numbers prev'); |
|
383 | 383 | } |
384 | 384 | |
385 | - if ( $paged < 2 ) { |
|
385 | + if ($paged < 2) { |
|
386 | 386 | $data['prev'] = null; |
387 | 387 | } |
388 | 388 | |
389 | - return Helper::array_to_object( $data ); |
|
389 | + return Helper::array_to_object($data); |
|
390 | 390 | |
391 | 391 | } |
392 | 392 | } |