@@ -1,8 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Loads the correct template based on the visitor's url |
|
4 | - * @package WordPress |
|
5 | - */ |
|
3 | + * Loads the correct template based on the visitor's url |
|
4 | + * @package WordPress |
|
5 | + */ |
|
6 | 6 | if ( defined('WP_USE_THEMES') && WP_USE_THEMES ) |
7 | 7 | /** |
8 | 8 | * Fires before determining which template to load. |
@@ -3,13 +3,13 @@ discard block |
||
3 | 3 | * Loads the correct template based on the visitor's url |
4 | 4 | * @package WordPress |
5 | 5 | */ |
6 | -if ( defined('WP_USE_THEMES') && WP_USE_THEMES ) |
|
6 | +if (defined('WP_USE_THEMES') && WP_USE_THEMES) |
|
7 | 7 | /** |
8 | 8 | * Fires before determining which template to load. |
9 | 9 | * |
10 | 10 | * @since 1.5.0 |
11 | 11 | */ |
12 | - do_action( 'template_redirect' ); |
|
12 | + do_action('template_redirect'); |
|
13 | 13 | |
14 | 14 | /** |
15 | 15 | * Filter whether to allow 'HEAD' requests to generate content. |
@@ -21,46 +21,46 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param bool $exit Whether to exit without generating any content for 'HEAD' requests. Default true. |
23 | 23 | */ |
24 | -if ( 'HEAD' === $_SERVER['REQUEST_METHOD'] && apply_filters( 'exit_on_http_head', true ) ) |
|
24 | +if ('HEAD' === $_SERVER['REQUEST_METHOD'] && apply_filters('exit_on_http_head', true)) |
|
25 | 25 | exit(); |
26 | 26 | |
27 | 27 | // Process feeds and trackbacks even if not using themes. |
28 | -if ( is_robots() ) : |
|
28 | +if (is_robots()) : |
|
29 | 29 | /** |
30 | 30 | * Fired when the template loader determines a robots.txt request. |
31 | 31 | * |
32 | 32 | * @since 2.1.0 |
33 | 33 | */ |
34 | - do_action( 'do_robots' ); |
|
34 | + do_action('do_robots'); |
|
35 | 35 | return; |
36 | -elseif ( is_feed() ) : |
|
36 | +elseif (is_feed()) : |
|
37 | 37 | do_feed(); |
38 | 38 | return; |
39 | -elseif ( is_trackback() ) : |
|
40 | - include( ABSPATH . 'wp-trackback.php' ); |
|
39 | +elseif (is_trackback()) : |
|
40 | + include(ABSPATH.'wp-trackback.php'); |
|
41 | 41 | return; |
42 | 42 | endif; |
43 | 43 | |
44 | -if ( defined('WP_USE_THEMES') && WP_USE_THEMES ) : |
|
44 | +if (defined('WP_USE_THEMES') && WP_USE_THEMES) : |
|
45 | 45 | $template = false; |
46 | - if ( is_embed() && $template = get_embed_template() ) : |
|
47 | - elseif ( is_404() && $template = get_404_template() ) : |
|
48 | - elseif ( is_search() && $template = get_search_template() ) : |
|
49 | - elseif ( is_front_page() && $template = get_front_page_template() ) : |
|
50 | - elseif ( is_home() && $template = get_home_template() ) : |
|
51 | - elseif ( is_post_type_archive() && $template = get_post_type_archive_template() ) : |
|
52 | - elseif ( is_tax() && $template = get_taxonomy_template() ) : |
|
53 | - elseif ( is_attachment() && $template = get_attachment_template() ) : |
|
46 | + if (is_embed() && $template = get_embed_template()) : |
|
47 | + elseif (is_404() && $template = get_404_template()) : |
|
48 | + elseif (is_search() && $template = get_search_template()) : |
|
49 | + elseif (is_front_page() && $template = get_front_page_template()) : |
|
50 | + elseif (is_home() && $template = get_home_template()) : |
|
51 | + elseif (is_post_type_archive() && $template = get_post_type_archive_template()) : |
|
52 | + elseif (is_tax() && $template = get_taxonomy_template()) : |
|
53 | + elseif (is_attachment() && $template = get_attachment_template()) : |
|
54 | 54 | remove_filter('the_content', 'prepend_attachment'); |
55 | - elseif ( is_single() && $template = get_single_template() ) : |
|
56 | - elseif ( is_page() && $template = get_page_template() ) : |
|
57 | - elseif ( is_singular() && $template = get_singular_template() ) : |
|
58 | - elseif ( is_category() && $template = get_category_template() ) : |
|
59 | - elseif ( is_tag() && $template = get_tag_template() ) : |
|
60 | - elseif ( is_author() && $template = get_author_template() ) : |
|
61 | - elseif ( is_date() && $template = get_date_template() ) : |
|
62 | - elseif ( is_archive() && $template = get_archive_template() ) : |
|
63 | - elseif ( is_paged() && $template = get_paged_template() ) : |
|
55 | + elseif (is_single() && $template = get_single_template()) : |
|
56 | + elseif (is_page() && $template = get_page_template()) : |
|
57 | + elseif (is_singular() && $template = get_singular_template()) : |
|
58 | + elseif (is_category() && $template = get_category_template()) : |
|
59 | + elseif (is_tag() && $template = get_tag_template()) : |
|
60 | + elseif (is_author() && $template = get_author_template()) : |
|
61 | + elseif (is_date() && $template = get_date_template()) : |
|
62 | + elseif (is_archive() && $template = get_archive_template()) : |
|
63 | + elseif (is_paged() && $template = get_paged_template()) : |
|
64 | 64 | else : |
65 | 65 | $template = get_index_template(); |
66 | 66 | endif; |
@@ -71,12 +71,12 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @param string $template The path of the template to include. |
73 | 73 | */ |
74 | - if ( $template = apply_filters( 'template_include', $template ) ) { |
|
75 | - include( $template ); |
|
76 | - } elseif ( current_user_can( 'switch_themes' ) ) { |
|
74 | + if ($template = apply_filters('template_include', $template)) { |
|
75 | + include($template); |
|
76 | + } elseif (current_user_can('switch_themes')) { |
|
77 | 77 | $theme = wp_get_theme(); |
78 | - if ( $theme->errors() ) { |
|
79 | - wp_die( $theme->errors() ); |
|
78 | + if ($theme->errors()) { |
|
79 | + wp_die($theme->errors()); |
|
80 | 80 | } |
81 | 81 | } |
82 | 82 | return; |
@@ -3,13 +3,14 @@ discard block |
||
3 | 3 | * Loads the correct template based on the visitor's url |
4 | 4 | * @package WordPress |
5 | 5 | */ |
6 | -if ( defined('WP_USE_THEMES') && WP_USE_THEMES ) |
|
6 | +if ( defined('WP_USE_THEMES') && WP_USE_THEMES ) { |
|
7 | 7 | /** |
8 | 8 | * Fires before determining which template to load. |
9 | 9 | * |
10 | 10 | * @since 1.5.0 |
11 | 11 | */ |
12 | 12 | do_action( 'template_redirect' ); |
13 | +} |
|
13 | 14 | |
14 | 15 | /** |
15 | 16 | * Filter whether to allow 'HEAD' requests to generate content. |
@@ -21,8 +22,9 @@ discard block |
||
21 | 22 | * |
22 | 23 | * @param bool $exit Whether to exit without generating any content for 'HEAD' requests. Default true. |
23 | 24 | */ |
24 | -if ( 'HEAD' === $_SERVER['REQUEST_METHOD'] && apply_filters( 'exit_on_http_head', true ) ) |
|
25 | +if ( 'HEAD' === $_SERVER['REQUEST_METHOD'] && apply_filters( 'exit_on_http_head', true ) ) { |
|
25 | 26 | exit(); |
27 | +} |
|
26 | 28 | |
27 | 29 | // Process feeds and trackbacks even if not using themes. |
28 | 30 | if ( is_robots() ) : |
@@ -61,8 +63,10 @@ discard block |
||
61 | 63 | elseif ( is_date() && $template = get_date_template() ) : |
62 | 64 | elseif ( is_archive() && $template = get_archive_template() ) : |
63 | 65 | elseif ( is_paged() && $template = get_paged_template() ) : |
64 | - else : |
|
66 | + else { |
|
67 | + : |
|
65 | 68 | $template = get_index_template(); |
69 | + } |
|
66 | 70 | endif; |
67 | 71 | /** |
68 | 72 | * Filter the path of the current template before including it. |
@@ -1,14 +1,14 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Author Template functions for use in themes. |
|
4 | - * |
|
5 | - * These functions must be used within the WordPress Loop. |
|
6 | - * |
|
7 | - * @link https://codex.wordpress.org/Author_Templates |
|
8 | - * |
|
9 | - * @package WordPress |
|
10 | - * @subpackage Template |
|
11 | - */ |
|
3 | + * Author Template functions for use in themes. |
|
4 | + * |
|
5 | + * These functions must be used within the WordPress Loop. |
|
6 | + * |
|
7 | + * @link https://codex.wordpress.org/Author_Templates |
|
8 | + * |
|
9 | + * @package WordPress |
|
10 | + * @subpackage Template |
|
11 | + */ |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * Retrieve the author of the current post. |
@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | function get_the_author($deprecated = '') { |
24 | 24 | global $authordata; |
25 | 25 | |
26 | - if ( !empty( $deprecated ) ) |
|
27 | - _deprecated_argument( __FUNCTION__, '2.1' ); |
|
26 | + if ( ! empty($deprecated)) |
|
27 | + _deprecated_argument(__FUNCTION__, '2.1'); |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * Filter the display name of the current post's author. |
@@ -55,21 +55,21 @@ discard block |
||
55 | 55 | * @param string $deprecated_echo Deprecated. Use get_the_author(). Echo the string or return it. |
56 | 56 | * @return string|null The author's display name, from get_the_author(). |
57 | 57 | */ |
58 | -function the_author( $deprecated = '', $deprecated_echo = true ) { |
|
59 | - if ( ! empty( $deprecated ) ) { |
|
60 | - _deprecated_argument( __FUNCTION__, '2.1' ); |
|
58 | +function the_author($deprecated = '', $deprecated_echo = true) { |
|
59 | + if ( ! empty($deprecated)) { |
|
60 | + _deprecated_argument(__FUNCTION__, '2.1'); |
|
61 | 61 | } |
62 | 62 | |
63 | - if ( true !== $deprecated_echo ) { |
|
64 | - _deprecated_argument( __FUNCTION__, '1.5', |
|
63 | + if (true !== $deprecated_echo) { |
|
64 | + _deprecated_argument(__FUNCTION__, '1.5', |
|
65 | 65 | /* translators: %s: get_the_author() */ |
66 | - sprintf( __( 'Use %s instead if you do not want the value echoed.' ), |
|
66 | + sprintf(__('Use %s instead if you do not want the value echoed.'), |
|
67 | 67 | '<code>get_the_author()</code>' |
68 | 68 | ) |
69 | 69 | ); |
70 | 70 | } |
71 | 71 | |
72 | - if ( $deprecated_echo ) { |
|
72 | + if ($deprecated_echo) { |
|
73 | 73 | echo get_the_author(); |
74 | 74 | } |
75 | 75 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @return string|void The author's display name. |
85 | 85 | */ |
86 | 86 | function get_the_modified_author() { |
87 | - if ( $last_id = get_post_meta( get_post()->ID, '_edit_last', true) ) { |
|
87 | + if ($last_id = get_post_meta(get_post()->ID, '_edit_last', true)) { |
|
88 | 88 | $last_user = get_userdata($last_id); |
89 | 89 | |
90 | 90 | /** |
@@ -121,20 +121,20 @@ discard block |
||
121 | 121 | * @param int $user_id Optional. User ID. |
122 | 122 | * @return string The author's field from the current author's DB object. |
123 | 123 | */ |
124 | -function get_the_author_meta( $field = '', $user_id = false ) { |
|
124 | +function get_the_author_meta($field = '', $user_id = false) { |
|
125 | 125 | $original_user_id = $user_id; |
126 | 126 | |
127 | - if ( ! $user_id ) { |
|
127 | + if ( ! $user_id) { |
|
128 | 128 | global $authordata; |
129 | - $user_id = isset( $authordata->ID ) ? $authordata->ID : 0; |
|
129 | + $user_id = isset($authordata->ID) ? $authordata->ID : 0; |
|
130 | 130 | } else { |
131 | - $authordata = get_userdata( $user_id ); |
|
131 | + $authordata = get_userdata($user_id); |
|
132 | 132 | } |
133 | 133 | |
134 | - if ( in_array( $field, array( 'login', 'pass', 'nicename', 'email', 'url', 'registered', 'activation_key', 'status' ) ) ) |
|
135 | - $field = 'user_' . $field; |
|
134 | + if (in_array($field, array('login', 'pass', 'nicename', 'email', 'url', 'registered', 'activation_key', 'status'))) |
|
135 | + $field = 'user_'.$field; |
|
136 | 136 | |
137 | - $value = isset( $authordata->$field ) ? $authordata->$field : ''; |
|
137 | + $value = isset($authordata->$field) ? $authordata->$field : ''; |
|
138 | 138 | |
139 | 139 | /** |
140 | 140 | * Filter the value of the requested user metadata. |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * @param int $user_id The user ID for the value. |
149 | 149 | * @param int|bool $original_user_id The original user ID, as passed to the function. |
150 | 150 | */ |
151 | - return apply_filters( 'get_the_author_' . $field, $value, $user_id, $original_user_id ); |
|
151 | + return apply_filters('get_the_author_'.$field, $value, $user_id, $original_user_id); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
@@ -161,8 +161,8 @@ discard block |
||
161 | 161 | * @param string $field selects the field of the users record. |
162 | 162 | * @param int $user_id Optional. User ID. |
163 | 163 | */ |
164 | -function the_author_meta( $field = '', $user_id = false ) { |
|
165 | - $author_meta = get_the_author_meta( $field, $user_id ); |
|
164 | +function the_author_meta($field = '', $user_id = false) { |
|
165 | + $author_meta = get_the_author_meta($field, $user_id); |
|
166 | 166 | |
167 | 167 | /** |
168 | 168 | * The value of the requested user metadata. |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * @param string $author_meta The value of the metadata. |
175 | 175 | * @param int $user_id The user ID. |
176 | 176 | */ |
177 | - echo apply_filters( 'the_author_' . $field, $author_meta, $user_id ); |
|
177 | + echo apply_filters('the_author_'.$field, $author_meta, $user_id); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | /** |
@@ -187,8 +187,8 @@ discard block |
||
187 | 187 | * else the result of get_the_author(). |
188 | 188 | */ |
189 | 189 | function get_the_author_link() { |
190 | - if ( get_the_author_meta('url') ) { |
|
191 | - return '<a href="' . esc_url( get_the_author_meta('url') ) . '" title="' . esc_attr( sprintf(__("Visit %s’s website"), get_the_author()) ) . '" rel="author external">' . get_the_author() . '</a>'; |
|
190 | + if (get_the_author_meta('url')) { |
|
191 | + return '<a href="'.esc_url(get_the_author_meta('url')).'" title="'.esc_attr(sprintf(__("Visit %s’s website"), get_the_author())).'" rel="author external">'.get_the_author().'</a>'; |
|
192 | 192 | } else { |
193 | 193 | return get_the_author(); |
194 | 194 | } |
@@ -217,10 +217,10 @@ discard block |
||
217 | 217 | */ |
218 | 218 | function get_the_author_posts() { |
219 | 219 | $post = get_post(); |
220 | - if ( ! $post ) { |
|
220 | + if ( ! $post) { |
|
221 | 221 | return 0; |
222 | 222 | } |
223 | - return count_user_posts( $post->post_author, $post->post_type ); |
|
223 | + return count_user_posts($post->post_author, $post->post_type); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | /** |
@@ -246,14 +246,14 @@ discard block |
||
246 | 246 | */ |
247 | 247 | function get_the_author_posts_link() { |
248 | 248 | global $authordata; |
249 | - if ( ! is_object( $authordata ) ) { |
|
249 | + if ( ! is_object($authordata)) { |
|
250 | 250 | return; |
251 | 251 | } |
252 | 252 | |
253 | 253 | $link = sprintf( |
254 | 254 | '<a href="%1$s" title="%2$s" rel="author">%3$s</a>', |
255 | - esc_url( get_author_posts_url( $authordata->ID, $authordata->user_nicename ) ), |
|
256 | - esc_attr( sprintf( __( 'Posts by %s' ), get_the_author() ) ), |
|
255 | + esc_url(get_author_posts_url($authordata->ID, $authordata->user_nicename)), |
|
256 | + esc_attr(sprintf(__('Posts by %s'), get_the_author())), |
|
257 | 257 | get_the_author() |
258 | 258 | ); |
259 | 259 | |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | * |
265 | 265 | * @param string $link HTML link. |
266 | 266 | */ |
267 | - return apply_filters( 'the_author_posts_link', $link ); |
|
267 | + return apply_filters('the_author_posts_link', $link); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | /** |
@@ -275,9 +275,9 @@ discard block |
||
275 | 275 | * |
276 | 276 | * @param string $deprecated Unused. |
277 | 277 | */ |
278 | -function the_author_posts_link( $deprecated = '' ) { |
|
279 | - if ( ! empty( $deprecated ) ) { |
|
280 | - _deprecated_argument( __FUNCTION__, '2.1' ); |
|
278 | +function the_author_posts_link($deprecated = '') { |
|
279 | + if ( ! empty($deprecated)) { |
|
280 | + _deprecated_argument(__FUNCTION__, '2.1'); |
|
281 | 281 | } |
282 | 282 | echo get_the_author_posts_link(); |
283 | 283 | } |
@@ -293,22 +293,22 @@ discard block |
||
293 | 293 | * @param string $author_nicename Optional. The author's nicename (slug). Default empty. |
294 | 294 | * @return string The URL to the author's page. |
295 | 295 | */ |
296 | -function get_author_posts_url( $author_id, $author_nicename = '' ) { |
|
296 | +function get_author_posts_url($author_id, $author_nicename = '') { |
|
297 | 297 | global $wp_rewrite; |
298 | 298 | $auth_ID = (int) $author_id; |
299 | 299 | $link = $wp_rewrite->get_author_permastruct(); |
300 | 300 | |
301 | - if ( empty($link) ) { |
|
302 | - $file = home_url( '/' ); |
|
303 | - $link = $file . '?author=' . $auth_ID; |
|
301 | + if (empty($link)) { |
|
302 | + $file = home_url('/'); |
|
303 | + $link = $file.'?author='.$auth_ID; |
|
304 | 304 | } else { |
305 | - if ( '' == $author_nicename ) { |
|
305 | + if ('' == $author_nicename) { |
|
306 | 306 | $user = get_userdata($author_id); |
307 | - if ( !empty($user->user_nicename) ) |
|
307 | + if ( ! empty($user->user_nicename)) |
|
308 | 308 | $author_nicename = $user->user_nicename; |
309 | 309 | } |
310 | 310 | $link = str_replace('%author%', $author_nicename, $link); |
311 | - $link = home_url( user_trailingslashit( $link ) ); |
|
311 | + $link = home_url(user_trailingslashit($link)); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | /** |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | * @param int $author_id The author's id. |
321 | 321 | * @param string $author_nicename The author's nice name. |
322 | 322 | */ |
323 | - $link = apply_filters( 'author_link', $link, $author_id, $author_nicename ); |
|
323 | + $link = apply_filters('author_link', $link, $author_id, $author_nicename); |
|
324 | 324 | |
325 | 325 | return $link; |
326 | 326 | } |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | * } |
361 | 361 | * @return string|void The output, if echo is set to false. |
362 | 362 | */ |
363 | -function wp_list_authors( $args = '' ) { |
|
363 | +function wp_list_authors($args = '') { |
|
364 | 364 | global $wpdb; |
365 | 365 | |
366 | 366 | $defaults = array( |
@@ -371,89 +371,89 @@ discard block |
||
371 | 371 | 'style' => 'list', 'html' => true, 'exclude' => '', 'include' => '' |
372 | 372 | ); |
373 | 373 | |
374 | - $args = wp_parse_args( $args, $defaults ); |
|
374 | + $args = wp_parse_args($args, $defaults); |
|
375 | 375 | |
376 | 376 | $return = ''; |
377 | 377 | |
378 | - $query_args = wp_array_slice_assoc( $args, array( 'orderby', 'order', 'number', 'exclude', 'include' ) ); |
|
378 | + $query_args = wp_array_slice_assoc($args, array('orderby', 'order', 'number', 'exclude', 'include')); |
|
379 | 379 | $query_args['fields'] = 'ids'; |
380 | - $authors = get_users( $query_args ); |
|
380 | + $authors = get_users($query_args); |
|
381 | 381 | |
382 | 382 | $author_count = array(); |
383 | - foreach ( (array) $wpdb->get_results( "SELECT DISTINCT post_author, COUNT(ID) AS count FROM $wpdb->posts WHERE " . get_private_posts_cap_sql( 'post' ) . " GROUP BY post_author" ) as $row ) { |
|
383 | + foreach ((array) $wpdb->get_results("SELECT DISTINCT post_author, COUNT(ID) AS count FROM $wpdb->posts WHERE ".get_private_posts_cap_sql('post')." GROUP BY post_author") as $row) { |
|
384 | 384 | $author_count[$row->post_author] = $row->count; |
385 | 385 | } |
386 | - foreach ( $authors as $author_id ) { |
|
387 | - $author = get_userdata( $author_id ); |
|
386 | + foreach ($authors as $author_id) { |
|
387 | + $author = get_userdata($author_id); |
|
388 | 388 | |
389 | - if ( $args['exclude_admin'] && 'admin' == $author->display_name ) { |
|
389 | + if ($args['exclude_admin'] && 'admin' == $author->display_name) { |
|
390 | 390 | continue; |
391 | 391 | } |
392 | 392 | |
393 | - $posts = isset( $author_count[$author->ID] ) ? $author_count[$author->ID] : 0; |
|
393 | + $posts = isset($author_count[$author->ID]) ? $author_count[$author->ID] : 0; |
|
394 | 394 | |
395 | - if ( ! $posts && $args['hide_empty'] ) { |
|
395 | + if ( ! $posts && $args['hide_empty']) { |
|
396 | 396 | continue; |
397 | 397 | } |
398 | 398 | |
399 | - if ( $args['show_fullname'] && $author->first_name && $author->last_name ) { |
|
399 | + if ($args['show_fullname'] && $author->first_name && $author->last_name) { |
|
400 | 400 | $name = "$author->first_name $author->last_name"; |
401 | 401 | } else { |
402 | 402 | $name = $author->display_name; |
403 | 403 | } |
404 | 404 | |
405 | - if ( ! $args['html'] ) { |
|
406 | - $return .= $name . ', '; |
|
405 | + if ( ! $args['html']) { |
|
406 | + $return .= $name.', '; |
|
407 | 407 | |
408 | 408 | continue; // No need to go further to process HTML. |
409 | 409 | } |
410 | 410 | |
411 | - if ( 'list' == $args['style'] ) { |
|
411 | + if ('list' == $args['style']) { |
|
412 | 412 | $return .= '<li>'; |
413 | 413 | } |
414 | 414 | |
415 | - $link = '<a href="' . get_author_posts_url( $author->ID, $author->user_nicename ) . '" title="' . esc_attr( sprintf(__("Posts by %s"), $author->display_name) ) . '">' . $name . '</a>'; |
|
415 | + $link = '<a href="'.get_author_posts_url($author->ID, $author->user_nicename).'" title="'.esc_attr(sprintf(__("Posts by %s"), $author->display_name)).'">'.$name.'</a>'; |
|
416 | 416 | |
417 | - if ( ! empty( $args['feed_image'] ) || ! empty( $args['feed'] ) ) { |
|
417 | + if ( ! empty($args['feed_image']) || ! empty($args['feed'])) { |
|
418 | 418 | $link .= ' '; |
419 | - if ( empty( $args['feed_image'] ) ) { |
|
419 | + if (empty($args['feed_image'])) { |
|
420 | 420 | $link .= '('; |
421 | 421 | } |
422 | 422 | |
423 | - $link .= '<a href="' . get_author_feed_link( $author->ID, $args['feed_type'] ) . '"'; |
|
423 | + $link .= '<a href="'.get_author_feed_link($author->ID, $args['feed_type']).'"'; |
|
424 | 424 | |
425 | 425 | $alt = ''; |
426 | - if ( ! empty( $args['feed'] ) ) { |
|
427 | - $alt = ' alt="' . esc_attr( $args['feed'] ) . '"'; |
|
426 | + if ( ! empty($args['feed'])) { |
|
427 | + $alt = ' alt="'.esc_attr($args['feed']).'"'; |
|
428 | 428 | $name = $args['feed']; |
429 | 429 | } |
430 | 430 | |
431 | 431 | $link .= '>'; |
432 | 432 | |
433 | - if ( ! empty( $args['feed_image'] ) ) { |
|
434 | - $link .= '<img src="' . esc_url( $args['feed_image'] ) . '" style="border: none;"' . $alt . ' />'; |
|
433 | + if ( ! empty($args['feed_image'])) { |
|
434 | + $link .= '<img src="'.esc_url($args['feed_image']).'" style="border: none;"'.$alt.' />'; |
|
435 | 435 | } else { |
436 | 436 | $link .= $name; |
437 | 437 | } |
438 | 438 | |
439 | 439 | $link .= '</a>'; |
440 | 440 | |
441 | - if ( empty( $args['feed_image'] ) ) { |
|
441 | + if (empty($args['feed_image'])) { |
|
442 | 442 | $link .= ')'; |
443 | 443 | } |
444 | 444 | } |
445 | 445 | |
446 | - if ( $args['optioncount'] ) { |
|
447 | - $link .= ' ('. $posts . ')'; |
|
446 | + if ($args['optioncount']) { |
|
447 | + $link .= ' ('.$posts.')'; |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | $return .= $link; |
451 | - $return .= ( 'list' == $args['style'] ) ? '</li>' : ', '; |
|
451 | + $return .= ('list' == $args['style']) ? '</li>' : ', '; |
|
452 | 452 | } |
453 | 453 | |
454 | - $return = rtrim( $return, ', ' ); |
|
454 | + $return = rtrim($return, ', '); |
|
455 | 455 | |
456 | - if ( ! $args['echo'] ) { |
|
456 | + if ( ! $args['echo']) { |
|
457 | 457 | return $return; |
458 | 458 | } |
459 | 459 | echo $return; |
@@ -473,10 +473,10 @@ discard block |
||
473 | 473 | function is_multi_author() { |
474 | 474 | global $wpdb; |
475 | 475 | |
476 | - if ( false === ( $is_multi_author = get_transient( 'is_multi_author' ) ) ) { |
|
476 | + if (false === ($is_multi_author = get_transient('is_multi_author'))) { |
|
477 | 477 | $rows = (array) $wpdb->get_col("SELECT DISTINCT post_author FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 2"); |
478 | - $is_multi_author = 1 < count( $rows ) ? 1 : 0; |
|
479 | - set_transient( 'is_multi_author', $is_multi_author ); |
|
478 | + $is_multi_author = 1 < count($rows) ? 1 : 0; |
|
479 | + set_transient('is_multi_author', $is_multi_author); |
|
480 | 480 | } |
481 | 481 | |
482 | 482 | /** |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | * |
487 | 487 | * @param bool $is_multi_author Whether $is_multi_author should evaluate as true. |
488 | 488 | */ |
489 | - return apply_filters( 'is_multi_author', (bool) $is_multi_author ); |
|
489 | + return apply_filters('is_multi_author', (bool) $is_multi_author); |
|
490 | 490 | } |
491 | 491 | |
492 | 492 | /** |
@@ -495,5 +495,5 @@ discard block |
||
495 | 495 | * @private |
496 | 496 | */ |
497 | 497 | function __clear_multi_author_cache() { |
498 | - delete_transient( 'is_multi_author' ); |
|
498 | + delete_transient('is_multi_author'); |
|
499 | 499 | } |
@@ -23,8 +23,9 @@ discard block |
||
23 | 23 | function get_the_author($deprecated = '') { |
24 | 24 | global $authordata; |
25 | 25 | |
26 | - if ( !empty( $deprecated ) ) |
|
27 | - _deprecated_argument( __FUNCTION__, '2.1' ); |
|
26 | + if ( !empty( $deprecated ) ) { |
|
27 | + _deprecated_argument( __FUNCTION__, '2.1' ); |
|
28 | + } |
|
28 | 29 | |
29 | 30 | /** |
30 | 31 | * Filter the display name of the current post's author. |
@@ -131,8 +132,9 @@ discard block |
||
131 | 132 | $authordata = get_userdata( $user_id ); |
132 | 133 | } |
133 | 134 | |
134 | - if ( in_array( $field, array( 'login', 'pass', 'nicename', 'email', 'url', 'registered', 'activation_key', 'status' ) ) ) |
|
135 | - $field = 'user_' . $field; |
|
135 | + if ( in_array( $field, array( 'login', 'pass', 'nicename', 'email', 'url', 'registered', 'activation_key', 'status' ) ) ) { |
|
136 | + $field = 'user_' . $field; |
|
137 | + } |
|
136 | 138 | |
137 | 139 | $value = isset( $authordata->$field ) ? $authordata->$field : ''; |
138 | 140 | |
@@ -304,8 +306,9 @@ discard block |
||
304 | 306 | } else { |
305 | 307 | if ( '' == $author_nicename ) { |
306 | 308 | $user = get_userdata($author_id); |
307 | - if ( !empty($user->user_nicename) ) |
|
308 | - $author_nicename = $user->user_nicename; |
|
309 | + if ( !empty($user->user_nicename) ) { |
|
310 | + $author_nicename = $user->user_nicename; |
|
311 | + } |
|
309 | 312 | } |
310 | 313 | $link = str_replace('%author%', $author_nicename, $link); |
311 | 314 | $link = home_url( user_trailingslashit( $link ) ); |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * WordPress Rewrite API |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Rewrite |
|
7 | - */ |
|
3 | + * WordPress Rewrite API |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Rewrite |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Add a straight rewrite rule. |
@@ -109,14 +109,14 @@ discard block |
||
109 | 109 | * |
110 | 110 | * @since 3.7.0 |
111 | 111 | */ |
112 | -define( 'EP_ALL_ARCHIVES', EP_DATE | EP_YEAR | EP_MONTH | EP_DAY | EP_CATEGORIES | EP_TAGS | EP_AUTHORS ); |
|
112 | +define('EP_ALL_ARCHIVES', EP_DATE | EP_YEAR | EP_MONTH | EP_DAY | EP_CATEGORIES | EP_TAGS | EP_AUTHORS); |
|
113 | 113 | |
114 | 114 | /** |
115 | 115 | * Endpoint Mask for everything. |
116 | 116 | * |
117 | 117 | * @since 2.1.0 |
118 | 118 | */ |
119 | -define( 'EP_ALL', EP_PERMALINK | EP_ATTACHMENT | EP_ROOT | EP_COMMENTS | EP_SEARCH | EP_PAGES | EP_ALL_ARCHIVES ); |
|
119 | +define('EP_ALL', EP_PERMALINK | EP_ATTACHMENT | EP_ROOT | EP_COMMENTS | EP_SEARCH | EP_PAGES | EP_ALL_ARCHIVES); |
|
120 | 120 | |
121 | 121 | /** |
122 | 122 | * Adds a rewrite rule that transforms a URL structure to a set of query vars. |
@@ -134,10 +134,10 @@ discard block |
||
134 | 134 | * @param string $after Optional. Priority of the new rule. Accepts 'top' |
135 | 135 | * or 'bottom'. Default 'bottom'. |
136 | 136 | */ |
137 | -function add_rewrite_rule( $regex, $query, $after = 'bottom' ) { |
|
137 | +function add_rewrite_rule($regex, $query, $after = 'bottom') { |
|
138 | 138 | global $wp_rewrite; |
139 | 139 | |
140 | - $wp_rewrite->add_rule( $regex, $query, $after ); |
|
140 | + $wp_rewrite->add_rule($regex, $query, $after); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -156,20 +156,20 @@ discard block |
||
156 | 156 | * @param string $regex Regular expression to substitute the tag for in rewrite rules. |
157 | 157 | * @param string $query Optional. String to append to the rewritten query. Must end in '='. Default empty. |
158 | 158 | */ |
159 | -function add_rewrite_tag( $tag, $regex, $query = '' ) { |
|
159 | +function add_rewrite_tag($tag, $regex, $query = '') { |
|
160 | 160 | // validate the tag's name |
161 | - if ( strlen( $tag ) < 3 || $tag[0] != '%' || $tag[ strlen($tag) - 1 ] != '%' ) |
|
161 | + if (strlen($tag) < 3 || $tag[0] != '%' || $tag[strlen($tag) - 1] != '%') |
|
162 | 162 | return; |
163 | 163 | |
164 | 164 | global $wp_rewrite, $wp; |
165 | 165 | |
166 | - if ( empty( $query ) ) { |
|
167 | - $qv = trim( $tag, '%' ); |
|
168 | - $wp->add_query_var( $qv ); |
|
169 | - $query = $qv . '='; |
|
166 | + if (empty($query)) { |
|
167 | + $qv = trim($tag, '%'); |
|
168 | + $wp->add_query_var($qv); |
|
169 | + $query = $qv.'='; |
|
170 | 170 | } |
171 | 171 | |
172 | - $wp_rewrite->add_rewrite_tag( $tag, $regex, $query ); |
|
172 | + $wp_rewrite->add_rewrite_tag($tag, $regex, $query); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
@@ -181,9 +181,9 @@ discard block |
||
181 | 181 | * |
182 | 182 | * @param string $tag Name of the rewrite tag. |
183 | 183 | */ |
184 | -function remove_rewrite_tag( $tag ) { |
|
184 | +function remove_rewrite_tag($tag) { |
|
185 | 185 | global $wp_rewrite; |
186 | - $wp_rewrite->remove_rewrite_tag( $tag ); |
|
186 | + $wp_rewrite->remove_rewrite_tag($tag); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
@@ -199,16 +199,16 @@ discard block |
||
199 | 199 | * @param array $args Optional. Arguments for building the rules from the permalink structure, |
200 | 200 | * see WP_Rewrite::add_permastruct() for full details. Default empty array. |
201 | 201 | */ |
202 | -function add_permastruct( $name, $struct, $args = array() ) { |
|
202 | +function add_permastruct($name, $struct, $args = array()) { |
|
203 | 203 | global $wp_rewrite; |
204 | 204 | |
205 | 205 | // backwards compatibility for the old parameters: $with_front and $ep_mask |
206 | - if ( ! is_array( $args ) ) |
|
207 | - $args = array( 'with_front' => $args ); |
|
208 | - if ( func_num_args() == 4 ) |
|
209 | - $args['ep_mask'] = func_get_arg( 3 ); |
|
206 | + if ( ! is_array($args)) |
|
207 | + $args = array('with_front' => $args); |
|
208 | + if (func_num_args() == 4) |
|
209 | + $args['ep_mask'] = func_get_arg(3); |
|
210 | 210 | |
211 | - $wp_rewrite->add_permastruct( $name, $struct, $args ); |
|
211 | + $wp_rewrite->add_permastruct($name, $struct, $args); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | /** |
@@ -224,10 +224,10 @@ discard block |
||
224 | 224 | * |
225 | 225 | * @param string $name Name for permalink structure. |
226 | 226 | */ |
227 | -function remove_permastruct( $name ) { |
|
227 | +function remove_permastruct($name) { |
|
228 | 228 | global $wp_rewrite; |
229 | 229 | |
230 | - $wp_rewrite->remove_permastruct( $name ); |
|
230 | + $wp_rewrite->remove_permastruct($name); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | /** |
@@ -241,19 +241,19 @@ discard block |
||
241 | 241 | * @param callable $function Callback to run on feed display. |
242 | 242 | * @return string Feed action name. |
243 | 243 | */ |
244 | -function add_feed( $feedname, $function ) { |
|
244 | +function add_feed($feedname, $function) { |
|
245 | 245 | global $wp_rewrite; |
246 | 246 | |
247 | - if ( ! in_array( $feedname, $wp_rewrite->feeds ) ) { |
|
247 | + if ( ! in_array($feedname, $wp_rewrite->feeds)) { |
|
248 | 248 | $wp_rewrite->feeds[] = $feedname; |
249 | 249 | } |
250 | 250 | |
251 | - $hook = 'do_feed_' . $feedname; |
|
251 | + $hook = 'do_feed_'.$feedname; |
|
252 | 252 | |
253 | 253 | // Remove default function hook |
254 | - remove_action( $hook, $hook ); |
|
254 | + remove_action($hook, $hook); |
|
255 | 255 | |
256 | - add_action( $hook, $function, 10, 2 ); |
|
256 | + add_action($hook, $function, 10, 2); |
|
257 | 257 | |
258 | 258 | return $hook; |
259 | 259 | } |
@@ -268,9 +268,9 @@ discard block |
||
268 | 268 | * @param bool $hard Whether to update .htaccess (hard flush) or just update |
269 | 269 | * rewrite_rules transient (soft flush). Default is true (hard). |
270 | 270 | */ |
271 | -function flush_rewrite_rules( $hard = true ) { |
|
271 | +function flush_rewrite_rules($hard = true) { |
|
272 | 272 | global $wp_rewrite; |
273 | - $wp_rewrite->flush_rules( $hard ); |
|
273 | + $wp_rewrite->flush_rules($hard); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | /** |
@@ -305,9 +305,9 @@ discard block |
||
305 | 305 | * @param string|bool $query_var Name of the corresponding query variable. Pass `false` to skip registering a query_var |
306 | 306 | * for this endpoint. Defaults to the value of `$name`. |
307 | 307 | */ |
308 | -function add_rewrite_endpoint( $name, $places, $query_var = true ) { |
|
308 | +function add_rewrite_endpoint($name, $places, $query_var = true) { |
|
309 | 309 | global $wp_rewrite; |
310 | - $wp_rewrite->add_endpoint( $name, $places, $query_var ); |
|
310 | + $wp_rewrite->add_endpoint($name, $places, $query_var); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | /** |
@@ -321,10 +321,10 @@ discard block |
||
321 | 321 | * @param string $base The taxonomy base that we're going to filter |
322 | 322 | * @return string |
323 | 323 | */ |
324 | -function _wp_filter_taxonomy_base( $base ) { |
|
325 | - if ( !empty( $base ) ) { |
|
326 | - $base = preg_replace( '|^/index\.php/|', '', $base ); |
|
327 | - $base = trim( $base, '/' ); |
|
324 | +function _wp_filter_taxonomy_base($base) { |
|
325 | + if ( ! empty($base)) { |
|
326 | + $base = preg_replace('|^/index\.php/|', '', $base); |
|
327 | + $base = trim($base, '/'); |
|
328 | 328 | } |
329 | 329 | return $base; |
330 | 330 | } |
@@ -351,16 +351,16 @@ discard block |
||
351 | 351 | * WP::parse_request(). Default empty array. |
352 | 352 | * @return array Returns the original array of query vars, with date/post conflicts resolved. |
353 | 353 | */ |
354 | -function wp_resolve_numeric_slug_conflicts( $query_vars = array() ) { |
|
355 | - if ( ! isset( $query_vars['year'] ) && ! isset( $query_vars['monthnum'] ) && ! isset( $query_vars['day'] ) ) { |
|
354 | +function wp_resolve_numeric_slug_conflicts($query_vars = array()) { |
|
355 | + if ( ! isset($query_vars['year']) && ! isset($query_vars['monthnum']) && ! isset($query_vars['day'])) { |
|
356 | 356 | return $query_vars; |
357 | 357 | } |
358 | 358 | |
359 | 359 | // Identify the 'postname' position in the permastruct array. |
360 | - $permastructs = array_values( array_filter( explode( '/', get_option( 'permalink_structure' ) ) ) ); |
|
361 | - $postname_index = array_search( '%postname%', $permastructs ); |
|
360 | + $permastructs = array_values(array_filter(explode('/', get_option('permalink_structure')))); |
|
361 | + $postname_index = array_search('%postname%', $permastructs); |
|
362 | 362 | |
363 | - if ( false === $postname_index ) { |
|
363 | + if (false === $postname_index) { |
|
364 | 364 | return $query_vars; |
365 | 365 | } |
366 | 366 | |
@@ -371,35 +371,35 @@ discard block |
||
371 | 371 | * for month-slug clashes when `is_month` *or* `is_day`. |
372 | 372 | */ |
373 | 373 | $compare = ''; |
374 | - if ( 0 === $postname_index && ( isset( $query_vars['year'] ) || isset( $query_vars['monthnum'] ) ) ) { |
|
374 | + if (0 === $postname_index && (isset($query_vars['year']) || isset($query_vars['monthnum']))) { |
|
375 | 375 | $compare = 'year'; |
376 | - } elseif ( '%year%' === $permastructs[ $postname_index - 1 ] && ( isset( $query_vars['monthnum'] ) || isset( $query_vars['day'] ) ) ) { |
|
376 | + } elseif ('%year%' === $permastructs[$postname_index - 1] && (isset($query_vars['monthnum']) || isset($query_vars['day']))) { |
|
377 | 377 | $compare = 'monthnum'; |
378 | - } elseif ( '%monthnum%' === $permastructs[ $postname_index - 1 ] && isset( $query_vars['day'] ) ) { |
|
378 | + } elseif ('%monthnum%' === $permastructs[$postname_index - 1] && isset($query_vars['day'])) { |
|
379 | 379 | $compare = 'day'; |
380 | 380 | } |
381 | 381 | |
382 | - if ( ! $compare ) { |
|
382 | + if ( ! $compare) { |
|
383 | 383 | return $query_vars; |
384 | 384 | } |
385 | 385 | |
386 | 386 | // This is the potentially clashing slug. |
387 | - $value = $query_vars[ $compare ]; |
|
387 | + $value = $query_vars[$compare]; |
|
388 | 388 | |
389 | - $post = get_page_by_path( $value, OBJECT, 'post' ); |
|
390 | - if ( ! ( $post instanceof WP_Post ) ) { |
|
389 | + $post = get_page_by_path($value, OBJECT, 'post'); |
|
390 | + if ( ! ($post instanceof WP_Post)) { |
|
391 | 391 | return $query_vars; |
392 | 392 | } |
393 | 393 | |
394 | 394 | // If the date of the post doesn't match the date specified in the URL, resolve to the date archive. |
395 | - if ( preg_match( '/^([0-9]{4})\-([0-9]{2})/', $post->post_date, $matches ) && isset( $query_vars['year'] ) && ( 'monthnum' === $compare || 'day' === $compare ) ) { |
|
395 | + if (preg_match('/^([0-9]{4})\-([0-9]{2})/', $post->post_date, $matches) && isset($query_vars['year']) && ('monthnum' === $compare || 'day' === $compare)) { |
|
396 | 396 | // $matches[1] is the year the post was published. |
397 | - if ( intval( $query_vars['year'] ) !== intval( $matches[1] ) ) { |
|
397 | + if (intval($query_vars['year']) !== intval($matches[1])) { |
|
398 | 398 | return $query_vars; |
399 | 399 | } |
400 | 400 | |
401 | 401 | // $matches[2] is the month the post was published. |
402 | - if ( 'day' === $compare && isset( $query_vars['monthnum'] ) && intval( $query_vars['monthnum'] ) !== intval( $matches[2] ) ) { |
|
402 | + if ('day' === $compare && isset($query_vars['monthnum']) && intval($query_vars['monthnum']) !== intval($matches[2])) { |
|
403 | 403 | return $query_vars; |
404 | 404 | } |
405 | 405 | } |
@@ -409,35 +409,35 @@ discard block |
||
409 | 409 | * intended as the page number. Verify that it's a valid page before resolving to it. |
410 | 410 | */ |
411 | 411 | $maybe_page = ''; |
412 | - if ( 'year' === $compare && isset( $query_vars['monthnum'] ) ) { |
|
412 | + if ('year' === $compare && isset($query_vars['monthnum'])) { |
|
413 | 413 | $maybe_page = $query_vars['monthnum']; |
414 | - } elseif ( 'monthnum' === $compare && isset( $query_vars['day'] ) ) { |
|
414 | + } elseif ('monthnum' === $compare && isset($query_vars['day'])) { |
|
415 | 415 | $maybe_page = $query_vars['day']; |
416 | 416 | } |
417 | 417 | // Bug found in #11694 - 'page' was returning '/4' |
418 | - $maybe_page = (int) trim( $maybe_page, '/' ); |
|
418 | + $maybe_page = (int) trim($maybe_page, '/'); |
|
419 | 419 | |
420 | - $post_page_count = substr_count( $post->post_content, '<!--nextpage-->' ) + 1; |
|
420 | + $post_page_count = substr_count($post->post_content, '<!--nextpage-->') + 1; |
|
421 | 421 | |
422 | 422 | // If the post doesn't have multiple pages, but a 'page' candidate is found, resolve to the date archive. |
423 | - if ( 1 === $post_page_count && $maybe_page ) { |
|
423 | + if (1 === $post_page_count && $maybe_page) { |
|
424 | 424 | return $query_vars; |
425 | 425 | } |
426 | 426 | |
427 | 427 | // If the post has multiple pages and the 'page' number isn't valid, resolve to the date archive. |
428 | - if ( $post_page_count > 1 && $maybe_page > $post_page_count ) { |
|
428 | + if ($post_page_count > 1 && $maybe_page > $post_page_count) { |
|
429 | 429 | return $query_vars; |
430 | 430 | } |
431 | 431 | |
432 | 432 | // If we've gotten to this point, we have a slug/date clash. First, adjust for nextpage. |
433 | - if ( '' !== $maybe_page ) { |
|
434 | - $query_vars['page'] = intval( $maybe_page ); |
|
433 | + if ('' !== $maybe_page) { |
|
434 | + $query_vars['page'] = intval($maybe_page); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | // Next, unset autodetected date-related query vars. |
438 | - unset( $query_vars['year'] ); |
|
439 | - unset( $query_vars['monthnum'] ); |
|
440 | - unset( $query_vars['day'] ); |
|
438 | + unset($query_vars['year']); |
|
439 | + unset($query_vars['monthnum']); |
|
440 | + unset($query_vars['day']); |
|
441 | 441 | |
442 | 442 | // Then, set the identified post. |
443 | 443 | $query_vars['name'] = $post->post_name; |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | * @param string $url Permalink to check. |
460 | 460 | * @return int Post ID, or 0 on failure. |
461 | 461 | */ |
462 | -function url_to_postid( $url ) { |
|
462 | +function url_to_postid($url) { |
|
463 | 463 | global $wp_rewrite; |
464 | 464 | |
465 | 465 | /** |
@@ -469,12 +469,12 @@ discard block |
||
469 | 469 | * |
470 | 470 | * @param string $url The URL to derive the post ID from. |
471 | 471 | */ |
472 | - $url = apply_filters( 'url_to_postid', $url ); |
|
472 | + $url = apply_filters('url_to_postid', $url); |
|
473 | 473 | |
474 | 474 | // First, check to see if there is a 'p=N' or 'page_id=N' to match against |
475 | - if ( preg_match('#[?&](p|page_id|attachment_id)=(\d+)#', $url, $values) ) { |
|
475 | + if (preg_match('#[?&](p|page_id|attachment_id)=(\d+)#', $url, $values)) { |
|
476 | 476 | $id = absint($values[2]); |
477 | - if ( $id ) |
|
477 | + if ($id) |
|
478 | 478 | return $id; |
479 | 479 | } |
480 | 480 | |
@@ -487,21 +487,21 @@ discard block |
||
487 | 487 | $url = $url_split[0]; |
488 | 488 | |
489 | 489 | // Set the correct URL scheme. |
490 | - $scheme = parse_url( home_url(), PHP_URL_SCHEME ); |
|
491 | - $url = set_url_scheme( $url, $scheme ); |
|
490 | + $scheme = parse_url(home_url(), PHP_URL_SCHEME); |
|
491 | + $url = set_url_scheme($url, $scheme); |
|
492 | 492 | |
493 | 493 | // Add 'www.' if it is absent and should be there |
494 | - if ( false !== strpos(home_url(), '://www.') && false === strpos($url, '://www.') ) |
|
494 | + if (false !== strpos(home_url(), '://www.') && false === strpos($url, '://www.')) |
|
495 | 495 | $url = str_replace('://', '://www.', $url); |
496 | 496 | |
497 | 497 | // Strip 'www.' if it is present and shouldn't be |
498 | - if ( false === strpos(home_url(), '://www.') ) |
|
498 | + if (false === strpos(home_url(), '://www.')) |
|
499 | 499 | $url = str_replace('://www.', '://', $url); |
500 | 500 | |
501 | - if ( trim( $url, '/' ) === home_url() && 'page' == get_option( 'show_on_front' ) ) { |
|
502 | - $page_on_front = get_option( 'page_on_front' ); |
|
501 | + if (trim($url, '/') === home_url() && 'page' == get_option('show_on_front')) { |
|
502 | + $page_on_front = get_option('page_on_front'); |
|
503 | 503 | |
504 | - if ( $page_on_front && get_post( $page_on_front ) instanceof WP_Post ) { |
|
504 | + if ($page_on_front && get_post($page_on_front) instanceof WP_Post) { |
|
505 | 505 | return (int) $page_on_front; |
506 | 506 | } |
507 | 507 | } |
@@ -510,21 +510,21 @@ discard block |
||
510 | 510 | $rewrite = $wp_rewrite->wp_rewrite_rules(); |
511 | 511 | |
512 | 512 | // Not using rewrite rules, and 'p=N' and 'page_id=N' methods failed, so we're out of options |
513 | - if ( empty($rewrite) ) |
|
513 | + if (empty($rewrite)) |
|
514 | 514 | return 0; |
515 | 515 | |
516 | 516 | // Strip 'index.php/' if we're not using path info permalinks |
517 | - if ( !$wp_rewrite->using_index_permalinks() ) |
|
518 | - $url = str_replace( $wp_rewrite->index . '/', '', $url ); |
|
517 | + if ( ! $wp_rewrite->using_index_permalinks()) |
|
518 | + $url = str_replace($wp_rewrite->index.'/', '', $url); |
|
519 | 519 | |
520 | - if ( false !== strpos( trailingslashit( $url ), home_url( '/' ) ) ) { |
|
520 | + if (false !== strpos(trailingslashit($url), home_url('/'))) { |
|
521 | 521 | // Chop off http://domain.com/[path] |
522 | 522 | $url = str_replace(home_url(), '', $url); |
523 | 523 | } else { |
524 | 524 | // Chop off /path/to/blog |
525 | - $home_path = parse_url( home_url( '/' ) ); |
|
526 | - $home_path = isset( $home_path['path'] ) ? $home_path['path'] : '' ; |
|
527 | - $url = preg_replace( sprintf( '#^%s#', preg_quote( $home_path ) ), '', trailingslashit( $url ) ); |
|
525 | + $home_path = parse_url(home_url('/')); |
|
526 | + $home_path = isset($home_path['path']) ? $home_path['path'] : ''; |
|
527 | + $url = preg_replace(sprintf('#^%s#', preg_quote($home_path)), '', trailingslashit($url)); |
|
528 | 528 | } |
529 | 529 | |
530 | 530 | // Trim leading and lagging slashes |
@@ -533,32 +533,32 @@ discard block |
||
533 | 533 | $request = $url; |
534 | 534 | $post_type_query_vars = array(); |
535 | 535 | |
536 | - foreach ( get_post_types( array() , 'objects' ) as $post_type => $t ) { |
|
537 | - if ( ! empty( $t->query_var ) ) |
|
538 | - $post_type_query_vars[ $t->query_var ] = $post_type; |
|
536 | + foreach (get_post_types(array(), 'objects') as $post_type => $t) { |
|
537 | + if ( ! empty($t->query_var)) |
|
538 | + $post_type_query_vars[$t->query_var] = $post_type; |
|
539 | 539 | } |
540 | 540 | |
541 | 541 | // Look for matches. |
542 | 542 | $request_match = $request; |
543 | - foreach ( (array)$rewrite as $match => $query) { |
|
543 | + foreach ((array) $rewrite as $match => $query) { |
|
544 | 544 | |
545 | 545 | // If the requesting file is the anchor of the match, prepend it |
546 | 546 | // to the path info. |
547 | - if ( !empty($url) && ($url != $request) && (strpos($match, $url) === 0) ) |
|
548 | - $request_match = $url . '/' . $request; |
|
547 | + if ( ! empty($url) && ($url != $request) && (strpos($match, $url) === 0)) |
|
548 | + $request_match = $url.'/'.$request; |
|
549 | 549 | |
550 | - if ( preg_match("#^$match#", $request_match, $matches) ) { |
|
550 | + if (preg_match("#^$match#", $request_match, $matches)) { |
|
551 | 551 | |
552 | - if ( $wp_rewrite->use_verbose_page_rules && preg_match( '/pagename=\$matches\[([0-9]+)\]/', $query, $varmatch ) ) { |
|
552 | + if ($wp_rewrite->use_verbose_page_rules && preg_match('/pagename=\$matches\[([0-9]+)\]/', $query, $varmatch)) { |
|
553 | 553 | // This is a verbose page match, let's check to be sure about it. |
554 | - $page = get_page_by_path( $matches[ $varmatch[1] ] ); |
|
555 | - if ( ! $page ) { |
|
554 | + $page = get_page_by_path($matches[$varmatch[1]]); |
|
555 | + if ( ! $page) { |
|
556 | 556 | continue; |
557 | 557 | } |
558 | 558 | |
559 | - $post_status_obj = get_post_status_object( $page->post_status ); |
|
559 | + $post_status_obj = get_post_status_object($page->post_status); |
|
560 | 560 | if ( ! $post_status_obj->public && ! $post_status_obj->protected |
561 | - && ! $post_status_obj->private && $post_status_obj->exclude_from_search ) { |
|
561 | + && ! $post_status_obj->private && $post_status_obj->exclude_from_search) { |
|
562 | 562 | continue; |
563 | 563 | } |
564 | 564 | } |
@@ -572,12 +572,12 @@ discard block |
||
572 | 572 | |
573 | 573 | // Filter out non-public query vars |
574 | 574 | global $wp; |
575 | - parse_str( $query, $query_vars ); |
|
575 | + parse_str($query, $query_vars); |
|
576 | 576 | $query = array(); |
577 | - foreach ( (array) $query_vars as $key => $value ) { |
|
578 | - if ( in_array( $key, $wp->public_query_vars ) ){ |
|
577 | + foreach ((array) $query_vars as $key => $value) { |
|
578 | + if (in_array($key, $wp->public_query_vars)) { |
|
579 | 579 | $query[$key] = $value; |
580 | - if ( isset( $post_type_query_vars[$key] ) ) { |
|
580 | + if (isset($post_type_query_vars[$key])) { |
|
581 | 581 | $query['post_type'] = $post_type_query_vars[$key]; |
582 | 582 | $query['name'] = $value; |
583 | 583 | } |
@@ -585,11 +585,11 @@ discard block |
||
585 | 585 | } |
586 | 586 | |
587 | 587 | // Resolve conflicts between posts with numeric slugs and date archive queries. |
588 | - $query = wp_resolve_numeric_slug_conflicts( $query ); |
|
588 | + $query = wp_resolve_numeric_slug_conflicts($query); |
|
589 | 589 | |
590 | 590 | // Do the query |
591 | - $query = new WP_Query( $query ); |
|
592 | - if ( ! empty( $query->posts ) && $query->is_singular ) |
|
591 | + $query = new WP_Query($query); |
|
592 | + if ( ! empty($query->posts) && $query->is_singular) |
|
593 | 593 | return $query->post->ID; |
594 | 594 | else |
595 | 595 | return 0; |
@@ -158,8 +158,9 @@ discard block |
||
158 | 158 | */ |
159 | 159 | function add_rewrite_tag( $tag, $regex, $query = '' ) { |
160 | 160 | // validate the tag's name |
161 | - if ( strlen( $tag ) < 3 || $tag[0] != '%' || $tag[ strlen($tag) - 1 ] != '%' ) |
|
162 | - return; |
|
161 | + if ( strlen( $tag ) < 3 || $tag[0] != '%' || $tag[ strlen($tag) - 1 ] != '%' ) { |
|
162 | + return; |
|
163 | + } |
|
163 | 164 | |
164 | 165 | global $wp_rewrite, $wp; |
165 | 166 | |
@@ -203,10 +204,12 @@ discard block |
||
203 | 204 | global $wp_rewrite; |
204 | 205 | |
205 | 206 | // backwards compatibility for the old parameters: $with_front and $ep_mask |
206 | - if ( ! is_array( $args ) ) |
|
207 | - $args = array( 'with_front' => $args ); |
|
208 | - if ( func_num_args() == 4 ) |
|
209 | - $args['ep_mask'] = func_get_arg( 3 ); |
|
207 | + if ( ! is_array( $args ) ) { |
|
208 | + $args = array( 'with_front' => $args ); |
|
209 | + } |
|
210 | + if ( func_num_args() == 4 ) { |
|
211 | + $args['ep_mask'] = func_get_arg( 3 ); |
|
212 | + } |
|
210 | 213 | |
211 | 214 | $wp_rewrite->add_permastruct( $name, $struct, $args ); |
212 | 215 | } |
@@ -474,8 +477,9 @@ discard block |
||
474 | 477 | // First, check to see if there is a 'p=N' or 'page_id=N' to match against |
475 | 478 | if ( preg_match('#[?&](p|page_id|attachment_id)=(\d+)#', $url, $values) ) { |
476 | 479 | $id = absint($values[2]); |
477 | - if ( $id ) |
|
478 | - return $id; |
|
480 | + if ( $id ) { |
|
481 | + return $id; |
|
482 | + } |
|
479 | 483 | } |
480 | 484 | |
481 | 485 | // Get rid of the #anchor |
@@ -491,12 +495,14 @@ discard block |
||
491 | 495 | $url = set_url_scheme( $url, $scheme ); |
492 | 496 | |
493 | 497 | // Add 'www.' if it is absent and should be there |
494 | - if ( false !== strpos(home_url(), '://www.') && false === strpos($url, '://www.') ) |
|
495 | - $url = str_replace('://', '://www.', $url); |
|
498 | + if ( false !== strpos(home_url(), '://www.') && false === strpos($url, '://www.') ) { |
|
499 | + $url = str_replace('://', '://www.', $url); |
|
500 | + } |
|
496 | 501 | |
497 | 502 | // Strip 'www.' if it is present and shouldn't be |
498 | - if ( false === strpos(home_url(), '://www.') ) |
|
499 | - $url = str_replace('://www.', '://', $url); |
|
503 | + if ( false === strpos(home_url(), '://www.') ) { |
|
504 | + $url = str_replace('://www.', '://', $url); |
|
505 | + } |
|
500 | 506 | |
501 | 507 | if ( trim( $url, '/' ) === home_url() && 'page' == get_option( 'show_on_front' ) ) { |
502 | 508 | $page_on_front = get_option( 'page_on_front' ); |
@@ -510,12 +516,14 @@ discard block |
||
510 | 516 | $rewrite = $wp_rewrite->wp_rewrite_rules(); |
511 | 517 | |
512 | 518 | // Not using rewrite rules, and 'p=N' and 'page_id=N' methods failed, so we're out of options |
513 | - if ( empty($rewrite) ) |
|
514 | - return 0; |
|
519 | + if ( empty($rewrite) ) { |
|
520 | + return 0; |
|
521 | + } |
|
515 | 522 | |
516 | 523 | // Strip 'index.php/' if we're not using path info permalinks |
517 | - if ( !$wp_rewrite->using_index_permalinks() ) |
|
518 | - $url = str_replace( $wp_rewrite->index . '/', '', $url ); |
|
524 | + if ( !$wp_rewrite->using_index_permalinks() ) { |
|
525 | + $url = str_replace( $wp_rewrite->index . '/', '', $url ); |
|
526 | + } |
|
519 | 527 | |
520 | 528 | if ( false !== strpos( trailingslashit( $url ), home_url( '/' ) ) ) { |
521 | 529 | // Chop off http://domain.com/[path] |
@@ -534,8 +542,9 @@ discard block |
||
534 | 542 | $post_type_query_vars = array(); |
535 | 543 | |
536 | 544 | foreach ( get_post_types( array() , 'objects' ) as $post_type => $t ) { |
537 | - if ( ! empty( $t->query_var ) ) |
|
538 | - $post_type_query_vars[ $t->query_var ] = $post_type; |
|
545 | + if ( ! empty( $t->query_var ) ) { |
|
546 | + $post_type_query_vars[ $t->query_var ] = $post_type; |
|
547 | + } |
|
539 | 548 | } |
540 | 549 | |
541 | 550 | // Look for matches. |
@@ -544,8 +553,9 @@ discard block |
||
544 | 553 | |
545 | 554 | // If the requesting file is the anchor of the match, prepend it |
546 | 555 | // to the path info. |
547 | - if ( !empty($url) && ($url != $request) && (strpos($match, $url) === 0) ) |
|
548 | - $request_match = $url . '/' . $request; |
|
556 | + if ( !empty($url) && ($url != $request) && (strpos($match, $url) === 0) ) { |
|
557 | + $request_match = $url . '/' . $request; |
|
558 | + } |
|
549 | 559 | |
550 | 560 | if ( preg_match("#^$match#", $request_match, $matches) ) { |
551 | 561 | |
@@ -589,10 +599,11 @@ discard block |
||
589 | 599 | |
590 | 600 | // Do the query |
591 | 601 | $query = new WP_Query( $query ); |
592 | - if ( ! empty( $query->posts ) && $query->is_singular ) |
|
593 | - return $query->post->ID; |
|
594 | - else |
|
595 | - return 0; |
|
602 | + if ( ! empty( $query->posts ) && $query->is_singular ) { |
|
603 | + return $query->post->ID; |
|
604 | + } else { |
|
605 | + return 0; |
|
606 | + } |
|
596 | 607 | } |
597 | 608 | } |
598 | 609 | return 0; |
@@ -1,9 +1,9 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Abstract class for managing user session tokens. |
|
4 | - * |
|
5 | - * @since 4.0.0 |
|
6 | - */ |
|
3 | + * Abstract class for managing user session tokens. |
|
4 | + * |
|
5 | + * @since 4.0.0 |
|
6 | + */ |
|
7 | 7 | abstract class WP_Session_Tokens { |
8 | 8 | |
9 | 9 | /** |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @param int $user_id User whose session to manage. |
24 | 24 | */ |
25 | - protected function __construct( $user_id ) { |
|
25 | + protected function __construct($user_id) { |
|
26 | 26 | $this->user_id = $user_id; |
27 | 27 | } |
28 | 28 | |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @param int $user_id User whose session to manage. |
40 | 40 | */ |
41 | - final public static function get_instance( $user_id ) { |
|
41 | + final public static function get_instance($user_id) { |
|
42 | 42 | /** |
43 | 43 | * Filter the session token manager used. |
44 | 44 | * |
@@ -47,8 +47,8 @@ discard block |
||
47 | 47 | * @param string $session Name of class to use as the manager. |
48 | 48 | * Default 'WP_User_Meta_Session_Tokens'. |
49 | 49 | */ |
50 | - $manager = apply_filters( 'session_token_manager', 'WP_User_Meta_Session_Tokens' ); |
|
51 | - return new $manager( $user_id ); |
|
50 | + $manager = apply_filters('session_token_manager', 'WP_User_Meta_Session_Tokens'); |
|
51 | + return new $manager($user_id); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -60,12 +60,12 @@ discard block |
||
60 | 60 | * @param string $token Session token to hash. |
61 | 61 | * @return string A hash of the session token (a verifier). |
62 | 62 | */ |
63 | - final private function hash_token( $token ) { |
|
63 | + final private function hash_token($token) { |
|
64 | 64 | // If ext/hash is not present, use sha1() instead. |
65 | - if ( function_exists( 'hash' ) ) { |
|
66 | - return hash( 'sha256', $token ); |
|
65 | + if (function_exists('hash')) { |
|
66 | + return hash('sha256', $token); |
|
67 | 67 | } else { |
68 | - return sha1( $token ); |
|
68 | + return sha1($token); |
|
69 | 69 | } |
70 | 70 | } |
71 | 71 | |
@@ -78,9 +78,9 @@ discard block |
||
78 | 78 | * @param string $token Session token |
79 | 79 | * @return array User session |
80 | 80 | */ |
81 | - final public function get( $token ) { |
|
82 | - $verifier = $this->hash_token( $token ); |
|
83 | - return $this->get_session( $verifier ); |
|
81 | + final public function get($token) { |
|
82 | + $verifier = $this->hash_token($token); |
|
83 | + return $this->get_session($verifier); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | * @param string $token Token to verify. |
95 | 95 | * @return bool Whether the token is valid for the user. |
96 | 96 | */ |
97 | - final public function verify( $token ) { |
|
98 | - $verifier = $this->hash_token( $token ); |
|
99 | - return (bool) $this->get_session( $verifier ); |
|
97 | + final public function verify($token) { |
|
98 | + $verifier = $this->hash_token($token); |
|
99 | + return (bool) $this->get_session($verifier); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * @param int $expiration Session expiration timestamp. |
117 | 117 | * @return string Session token. |
118 | 118 | */ |
119 | - final public function create( $expiration ) { |
|
119 | + final public function create($expiration) { |
|
120 | 120 | /** |
121 | 121 | * Filter the information attached to the newly created session. |
122 | 122 | * |
@@ -128,25 +128,25 @@ discard block |
||
128 | 128 | * @param array $session Array of extra data. |
129 | 129 | * @param int $user_id User ID. |
130 | 130 | */ |
131 | - $session = apply_filters( 'attach_session_information', array(), $this->user_id ); |
|
131 | + $session = apply_filters('attach_session_information', array(), $this->user_id); |
|
132 | 132 | $session['expiration'] = $expiration; |
133 | 133 | |
134 | 134 | // IP address. |
135 | - if ( !empty( $_SERVER['REMOTE_ADDR'] ) ) { |
|
135 | + if ( ! empty($_SERVER['REMOTE_ADDR'])) { |
|
136 | 136 | $session['ip'] = $_SERVER['REMOTE_ADDR']; |
137 | 137 | } |
138 | 138 | |
139 | 139 | // User-agent. |
140 | - if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
141 | - $session['ua'] = wp_unslash( $_SERVER['HTTP_USER_AGENT'] ); |
|
140 | + if ( ! empty($_SERVER['HTTP_USER_AGENT'])) { |
|
141 | + $session['ua'] = wp_unslash($_SERVER['HTTP_USER_AGENT']); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | // Timestamp |
145 | 145 | $session['login'] = time(); |
146 | 146 | |
147 | - $token = wp_generate_password( 43, false, false ); |
|
147 | + $token = wp_generate_password(43, false, false); |
|
148 | 148 | |
149 | - $this->update( $token, $session ); |
|
149 | + $this->update($token, $session); |
|
150 | 150 | |
151 | 151 | return $token; |
152 | 152 | } |
@@ -160,9 +160,9 @@ discard block |
||
160 | 160 | * @param string $token Session token to update. |
161 | 161 | * @param array $session Session information. |
162 | 162 | */ |
163 | - final public function update( $token, $session ) { |
|
164 | - $verifier = $this->hash_token( $token ); |
|
165 | - $this->update_session( $verifier, $session ); |
|
163 | + final public function update($token, $session) { |
|
164 | + $verifier = $this->hash_token($token); |
|
165 | + $this->update_session($verifier, $session); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -173,9 +173,9 @@ discard block |
||
173 | 173 | * |
174 | 174 | * @param string $token Session token to destroy. |
175 | 175 | */ |
176 | - final public function destroy( $token ) { |
|
177 | - $verifier = $this->hash_token( $token ); |
|
178 | - $this->update_session( $verifier, null ); |
|
176 | + final public function destroy($token) { |
|
177 | + $verifier = $this->hash_token($token); |
|
178 | + $this->update_session($verifier, null); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -187,11 +187,11 @@ discard block |
||
187 | 187 | * |
188 | 188 | * @param string $token_to_keep Session token to keep. |
189 | 189 | */ |
190 | - final public function destroy_others( $token_to_keep ) { |
|
191 | - $verifier = $this->hash_token( $token_to_keep ); |
|
192 | - $session = $this->get_session( $verifier ); |
|
193 | - if ( $session ) { |
|
194 | - $this->destroy_other_sessions( $verifier ); |
|
190 | + final public function destroy_others($token_to_keep) { |
|
191 | + $verifier = $this->hash_token($token_to_keep); |
|
192 | + $session = $this->get_session($verifier); |
|
193 | + if ($session) { |
|
194 | + $this->destroy_other_sessions($verifier); |
|
195 | 195 | } else { |
196 | 196 | $this->destroy_all_sessions(); |
197 | 197 | } |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * @param array $session Session to check. |
208 | 208 | * @return bool Whether session is valid. |
209 | 209 | */ |
210 | - final protected function is_still_valid( $session ) { |
|
210 | + final protected function is_still_valid($session) { |
|
211 | 211 | return $session['expiration'] >= time(); |
212 | 212 | } |
213 | 213 | |
@@ -229,8 +229,8 @@ discard block |
||
229 | 229 | * @static |
230 | 230 | */ |
231 | 231 | final public static function destroy_all_for_all_users() { |
232 | - $manager = apply_filters( 'session_token_manager', 'WP_User_Meta_Session_Tokens' ); |
|
233 | - call_user_func( array( $manager, 'drop_sessions' ) ); |
|
232 | + $manager = apply_filters('session_token_manager', 'WP_User_Meta_Session_Tokens'); |
|
233 | + call_user_func(array($manager, 'drop_sessions')); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | /** |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * @return array Sessions of a user. |
243 | 243 | */ |
244 | 244 | final public function get_all() { |
245 | - return array_values( $this->get_sessions() ); |
|
245 | + return array_values($this->get_sessions()); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | /** |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | * @param string $verifier Verifier of the session to retrieve. |
265 | 265 | * @return array|null The session, or null if it does not exist. |
266 | 266 | */ |
267 | - abstract protected function get_session( $verifier ); |
|
267 | + abstract protected function get_session($verifier); |
|
268 | 268 | |
269 | 269 | /** |
270 | 270 | * This method should update a session by its verifier. |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | * |
277 | 277 | * @param string $verifier Verifier of the session to update. |
278 | 278 | */ |
279 | - abstract protected function update_session( $verifier, $session = null ); |
|
279 | + abstract protected function update_session($verifier, $session = null); |
|
280 | 280 | |
281 | 281 | /** |
282 | 282 | * This method should destroy all session tokens for this user, |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | * |
288 | 288 | * @param string $verifier Verifier of the session to keep. |
289 | 289 | */ |
290 | - abstract protected function destroy_other_sessions( $verifier ); |
|
290 | + abstract protected function destroy_other_sessions($verifier); |
|
291 | 291 | |
292 | 292 | /** |
293 | 293 | * This method should destroy all sessions for a user. |
@@ -323,14 +323,14 @@ discard block |
||
323 | 323 | * @return array Sessions of a user. |
324 | 324 | */ |
325 | 325 | protected function get_sessions() { |
326 | - $sessions = get_user_meta( $this->user_id, 'session_tokens', true ); |
|
326 | + $sessions = get_user_meta($this->user_id, 'session_tokens', true); |
|
327 | 327 | |
328 | - if ( ! is_array( $sessions ) ) { |
|
328 | + if ( ! is_array($sessions)) { |
|
329 | 329 | return array(); |
330 | 330 | } |
331 | 331 | |
332 | - $sessions = array_map( array( $this, 'prepare_session' ), $sessions ); |
|
333 | - return array_filter( $sessions, array( $this, 'is_still_valid' ) ); |
|
332 | + $sessions = array_map(array($this, 'prepare_session'), $sessions); |
|
333 | + return array_filter($sessions, array($this, 'is_still_valid')); |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | /** |
@@ -339,9 +339,9 @@ discard block |
||
339 | 339 | * @param mixed $session Session or expiration. |
340 | 340 | * @return array Session. |
341 | 341 | */ |
342 | - protected function prepare_session( $session ) { |
|
343 | - if ( is_int( $session ) ) { |
|
344 | - return array( 'expiration' => $session ); |
|
342 | + protected function prepare_session($session) { |
|
343 | + if (is_int($session)) { |
|
344 | + return array('expiration' => $session); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | return $session; |
@@ -356,11 +356,11 @@ discard block |
||
356 | 356 | * @param string $verifier Verifier of the session to retrieve. |
357 | 357 | * @return array|null The session, or null if it does not exist |
358 | 358 | */ |
359 | - protected function get_session( $verifier ) { |
|
359 | + protected function get_session($verifier) { |
|
360 | 360 | $sessions = $this->get_sessions(); |
361 | 361 | |
362 | - if ( isset( $sessions[ $verifier ] ) ) { |
|
363 | - return $sessions[ $verifier ]; |
|
362 | + if (isset($sessions[$verifier])) { |
|
363 | + return $sessions[$verifier]; |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | return null; |
@@ -375,16 +375,16 @@ discard block |
||
375 | 375 | * @param string $verifier Verifier of the session to update. |
376 | 376 | * @param array $session Optional. Session. Omitting this argument destroys the session. |
377 | 377 | */ |
378 | - protected function update_session( $verifier, $session = null ) { |
|
378 | + protected function update_session($verifier, $session = null) { |
|
379 | 379 | $sessions = $this->get_sessions(); |
380 | 380 | |
381 | - if ( $session ) { |
|
382 | - $sessions[ $verifier ] = $session; |
|
381 | + if ($session) { |
|
382 | + $sessions[$verifier] = $session; |
|
383 | 383 | } else { |
384 | - unset( $sessions[ $verifier ] ); |
|
384 | + unset($sessions[$verifier]); |
|
385 | 385 | } |
386 | 386 | |
387 | - $this->update_sessions( $sessions ); |
|
387 | + $this->update_sessions($sessions); |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | /** |
@@ -395,11 +395,11 @@ discard block |
||
395 | 395 | * |
396 | 396 | * @param array $sessions Sessions. |
397 | 397 | */ |
398 | - protected function update_sessions( $sessions ) { |
|
399 | - if ( $sessions ) { |
|
400 | - update_user_meta( $this->user_id, 'session_tokens', $sessions ); |
|
398 | + protected function update_sessions($sessions) { |
|
399 | + if ($sessions) { |
|
400 | + update_user_meta($this->user_id, 'session_tokens', $sessions); |
|
401 | 401 | } else { |
402 | - delete_user_meta( $this->user_id, 'session_tokens' ); |
|
402 | + delete_user_meta($this->user_id, 'session_tokens'); |
|
403 | 403 | } |
404 | 404 | } |
405 | 405 | |
@@ -411,9 +411,9 @@ discard block |
||
411 | 411 | * |
412 | 412 | * @param string $verifier Verifier of the session to keep. |
413 | 413 | */ |
414 | - protected function destroy_other_sessions( $verifier ) { |
|
415 | - $session = $this->get_session( $verifier ); |
|
416 | - $this->update_sessions( array( $verifier => $session ) ); |
|
414 | + protected function destroy_other_sessions($verifier) { |
|
415 | + $session = $this->get_session($verifier); |
|
416 | + $this->update_sessions(array($verifier => $session)); |
|
417 | 417 | } |
418 | 418 | |
419 | 419 | /** |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | * @access protected |
424 | 424 | */ |
425 | 425 | protected function destroy_all_sessions() { |
426 | - $this->update_sessions( array() ); |
|
426 | + $this->update_sessions(array()); |
|
427 | 427 | } |
428 | 428 | |
429 | 429 | /** |
@@ -434,6 +434,6 @@ discard block |
||
434 | 434 | * @static |
435 | 435 | */ |
436 | 436 | public static function drop_sessions() { |
437 | - delete_metadata( 'user', 0, 'session_tokens', false, true ); |
|
437 | + delete_metadata('user', 0, 'session_tokens', false, true); |
|
438 | 438 | } |
439 | 439 | } |
@@ -1,9 +1,9 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * RSS 0.92 Feed Template for displaying RSS 0.92 Posts feed. |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - */ |
|
3 | + * RSS 0.92 Feed Template for displaying RSS 0.92 Posts feed. |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + */ |
|
7 | 7 | |
8 | 8 | header('Content-Type: ' . feed_content_type('rss') . '; charset=' . get_option('blog_charset'), true); |
9 | 9 | $more = 1; |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * @package WordPress |
6 | 6 | */ |
7 | 7 | |
8 | -header('Content-Type: ' . feed_content_type('rss') . '; charset=' . get_option('blog_charset'), true); |
|
8 | +header('Content-Type: '.feed_content_type('rss').'; charset='.get_option('blog_charset'), true); |
|
9 | 9 | $more = 1; |
10 | 10 | |
11 | 11 | echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; ?> |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | <description><?php bloginfo_rss('description') ?></description> |
17 | 17 | <lastBuildDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></lastBuildDate> |
18 | 18 | <docs>http://backend.userland.com/rss092</docs> |
19 | - <language><?php bloginfo_rss( 'language' ); ?></language> |
|
19 | + <language><?php bloginfo_rss('language'); ?></language> |
|
20 | 20 | |
21 | 21 | <?php |
22 | 22 | /** |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @since 2.0.0 |
26 | 26 | */ |
27 | - do_action( 'rss_head' ); |
|
27 | + do_action('rss_head'); |
|
28 | 28 | ?> |
29 | 29 | |
30 | 30 | <?php while (have_posts()) : the_post(); ?> |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @since 2.0.0 |
40 | 40 | */ |
41 | - do_action( 'rss_item' ); |
|
41 | + do_action('rss_item'); |
|
42 | 42 | ?> |
43 | 43 | </item> |
44 | 44 | <?php endwhile; ?> |
@@ -21,8 +21,9 @@ discard block |
||
21 | 21 | function _wp_admin_bar_init() { |
22 | 22 | global $wp_admin_bar; |
23 | 23 | |
24 | - if ( ! is_admin_bar_showing() ) |
|
25 | - return false; |
|
24 | + if ( ! is_admin_bar_showing() ) { |
|
25 | + return false; |
|
26 | + } |
|
26 | 27 | |
27 | 28 | /* Load the admin bar class code ready for instantiation */ |
28 | 29 | require_once( ABSPATH . WPINC . '/class-wp-admin-bar.php' ); |
@@ -37,10 +38,11 @@ discard block |
||
37 | 38 | * @param string $wp_admin_bar_class Admin bar class to use. Default 'WP_Admin_Bar'. |
38 | 39 | */ |
39 | 40 | $admin_bar_class = apply_filters( 'wp_admin_bar_class', 'WP_Admin_Bar' ); |
40 | - if ( class_exists( $admin_bar_class ) ) |
|
41 | - $wp_admin_bar = new $admin_bar_class; |
|
42 | - else |
|
43 | - return false; |
|
41 | + if ( class_exists( $admin_bar_class ) ) { |
|
42 | + $wp_admin_bar = new $admin_bar_class; |
|
43 | + } else { |
|
44 | + return false; |
|
45 | + } |
|
44 | 46 | |
45 | 47 | $wp_admin_bar->initialize(); |
46 | 48 | $wp_admin_bar->add_menus(); |
@@ -64,8 +66,9 @@ discard block |
||
64 | 66 | function wp_admin_bar_render() { |
65 | 67 | global $wp_admin_bar; |
66 | 68 | |
67 | - if ( ! is_admin_bar_showing() || ! is_object( $wp_admin_bar ) ) |
|
68 | - return; |
|
69 | + if ( ! is_admin_bar_showing() || ! is_object( $wp_admin_bar ) ) { |
|
70 | + return; |
|
71 | + } |
|
69 | 72 | |
70 | 73 | /** |
71 | 74 | * Load all necessary admin bar items. |
@@ -181,8 +184,9 @@ discard block |
||
181 | 184 | $current_user = wp_get_current_user(); |
182 | 185 | $profile_url = get_edit_profile_url( $user_id ); |
183 | 186 | |
184 | - if ( ! $user_id ) |
|
185 | - return; |
|
187 | + if ( ! $user_id ) { |
|
188 | + return; |
|
189 | + } |
|
186 | 190 | |
187 | 191 | $avatar = get_avatar( $user_id, 26 ); |
188 | 192 | $howdy = sprintf( __('Howdy, %1$s'), $current_user->display_name ); |
@@ -211,8 +215,9 @@ discard block |
||
211 | 215 | $current_user = wp_get_current_user(); |
212 | 216 | $profile_url = get_edit_profile_url( $user_id ); |
213 | 217 | |
214 | - if ( ! $user_id ) |
|
215 | - return; |
|
218 | + if ( ! $user_id ) { |
|
219 | + return; |
|
220 | + } |
|
216 | 221 | |
217 | 222 | $wp_admin_bar->add_group( array( |
218 | 223 | 'parent' => 'my-account', |
@@ -222,8 +227,9 @@ discard block |
||
222 | 227 | $user_info = get_avatar( $user_id, 64 ); |
223 | 228 | $user_info .= "<span class='display-name'>{$current_user->display_name}</span>"; |
224 | 229 | |
225 | - if ( $current_user->display_name !== $current_user->user_login ) |
|
226 | - $user_info .= "<span class='username'>{$current_user->user_login}</span>"; |
|
230 | + if ( $current_user->display_name !== $current_user->user_login ) { |
|
231 | + $user_info .= "<span class='username'>{$current_user->user_login}</span>"; |
|
232 | + } |
|
227 | 233 | |
228 | 234 | $wp_admin_bar->add_menu( array( |
229 | 235 | 'parent' => 'user-actions', |
@@ -257,12 +263,14 @@ discard block |
||
257 | 263 | */ |
258 | 264 | function wp_admin_bar_site_menu( $wp_admin_bar ) { |
259 | 265 | // Don't show for logged out users. |
260 | - if ( ! is_user_logged_in() ) |
|
261 | - return; |
|
266 | + if ( ! is_user_logged_in() ) { |
|
267 | + return; |
|
268 | + } |
|
262 | 269 | |
263 | 270 | // Show only when the user is a member of this site, or they're a super admin. |
264 | - if ( ! is_user_member_of_blog() && ! is_super_admin() ) |
|
265 | - return; |
|
271 | + if ( ! is_user_member_of_blog() && ! is_super_admin() ) { |
|
272 | + return; |
|
273 | + } |
|
266 | 274 | |
267 | 275 | $blogname = get_bloginfo('name'); |
268 | 276 | |
@@ -354,12 +362,14 @@ discard block |
||
354 | 362 | */ |
355 | 363 | function wp_admin_bar_my_sites_menu( $wp_admin_bar ) { |
356 | 364 | // Don't show for logged out users or single site mode. |
357 | - if ( ! is_user_logged_in() || ! is_multisite() ) |
|
358 | - return; |
|
365 | + if ( ! is_user_logged_in() || ! is_multisite() ) { |
|
366 | + return; |
|
367 | + } |
|
359 | 368 | |
360 | 369 | // Show only when the user has at least one site, or they're a super admin. |
361 | - if ( count( $wp_admin_bar->user->blogs ) < 1 && ! is_super_admin() ) |
|
362 | - return; |
|
370 | + if ( count( $wp_admin_bar->user->blogs ) < 1 && ! is_super_admin() ) { |
|
371 | + return; |
|
372 | + } |
|
363 | 373 | |
364 | 374 | if ( $wp_admin_bar->user->active_blog ) { |
365 | 375 | $my_sites_url = get_admin_url( $wp_admin_bar->user->active_blog->blog_id, 'my-sites.php' ); |
@@ -494,8 +504,9 @@ discard block |
||
494 | 504 | $short = wp_get_shortlink( 0, 'query' ); |
495 | 505 | $id = 'get-shortlink'; |
496 | 506 | |
497 | - if ( empty( $short ) ) |
|
498 | - return; |
|
507 | + if ( empty( $short ) ) { |
|
508 | + return; |
|
509 | + } |
|
499 | 510 | |
500 | 511 | $html = '<input class="shortlink-input" type="text" readonly="readonly" value="' . esc_attr( $short ) . '" />'; |
501 | 512 | |
@@ -562,8 +573,9 @@ discard block |
||
562 | 573 | } else { |
563 | 574 | $current_object = $wp_the_query->get_queried_object(); |
564 | 575 | |
565 | - if ( empty( $current_object ) ) |
|
566 | - return; |
|
576 | + if ( empty( $current_object ) ) { |
|
577 | + return; |
|
578 | + } |
|
567 | 579 | |
568 | 580 | if ( ! empty( $current_object->post_type ) |
569 | 581 | && ( $post_type_object = get_post_type_object( $current_object->post_type ) ) |
@@ -603,37 +615,45 @@ discard block |
||
603 | 615 | |
604 | 616 | $cpts = (array) get_post_types( array( 'show_in_admin_bar' => true ), 'objects' ); |
605 | 617 | |
606 | - if ( isset( $cpts['post'] ) && current_user_can( $cpts['post']->cap->create_posts ) ) |
|
607 | - $actions[ 'post-new.php' ] = array( $cpts['post']->labels->name_admin_bar, 'new-post' ); |
|
618 | + if ( isset( $cpts['post'] ) && current_user_can( $cpts['post']->cap->create_posts ) ) { |
|
619 | + $actions[ 'post-new.php' ] = array( $cpts['post']->labels->name_admin_bar, 'new-post' ); |
|
620 | + } |
|
608 | 621 | |
609 | - if ( isset( $cpts['attachment'] ) && current_user_can( 'upload_files' ) ) |
|
610 | - $actions[ 'media-new.php' ] = array( $cpts['attachment']->labels->name_admin_bar, 'new-media' ); |
|
622 | + if ( isset( $cpts['attachment'] ) && current_user_can( 'upload_files' ) ) { |
|
623 | + $actions[ 'media-new.php' ] = array( $cpts['attachment']->labels->name_admin_bar, 'new-media' ); |
|
624 | + } |
|
611 | 625 | |
612 | - if ( current_user_can( 'manage_links' ) ) |
|
613 | - $actions[ 'link-add.php' ] = array( _x( 'Link', 'add new from admin bar' ), 'new-link' ); |
|
626 | + if ( current_user_can( 'manage_links' ) ) { |
|
627 | + $actions[ 'link-add.php' ] = array( _x( 'Link', 'add new from admin bar' ), 'new-link' ); |
|
628 | + } |
|
614 | 629 | |
615 | - if ( isset( $cpts['page'] ) && current_user_can( $cpts['page']->cap->create_posts ) ) |
|
616 | - $actions[ 'post-new.php?post_type=page' ] = array( $cpts['page']->labels->name_admin_bar, 'new-page' ); |
|
630 | + if ( isset( $cpts['page'] ) && current_user_can( $cpts['page']->cap->create_posts ) ) { |
|
631 | + $actions[ 'post-new.php?post_type=page' ] = array( $cpts['page']->labels->name_admin_bar, 'new-page' ); |
|
632 | + } |
|
617 | 633 | |
618 | 634 | unset( $cpts['post'], $cpts['page'], $cpts['attachment'] ); |
619 | 635 | |
620 | 636 | // Add any additional custom post types. |
621 | 637 | foreach ( $cpts as $cpt ) { |
622 | - if ( ! current_user_can( $cpt->cap->create_posts ) ) |
|
623 | - continue; |
|
638 | + if ( ! current_user_can( $cpt->cap->create_posts ) ) { |
|
639 | + continue; |
|
640 | + } |
|
624 | 641 | |
625 | 642 | $key = 'post-new.php?post_type=' . $cpt->name; |
626 | 643 | $actions[ $key ] = array( $cpt->labels->name_admin_bar, 'new-' . $cpt->name ); |
627 | 644 | } |
628 | 645 | // Avoid clash with parent node and a 'content' post type. |
629 | - if ( isset( $actions['post-new.php?post_type=content'] ) ) |
|
630 | - $actions['post-new.php?post_type=content'][1] = 'add-new-content'; |
|
646 | + if ( isset( $actions['post-new.php?post_type=content'] ) ) { |
|
647 | + $actions['post-new.php?post_type=content'][1] = 'add-new-content'; |
|
648 | + } |
|
631 | 649 | |
632 | - if ( current_user_can( 'create_users' ) || current_user_can( 'promote_users' ) ) |
|
633 | - $actions[ 'user-new.php' ] = array( _x( 'User', 'add new from admin bar' ), 'new-user' ); |
|
650 | + if ( current_user_can( 'create_users' ) || current_user_can( 'promote_users' ) ) { |
|
651 | + $actions[ 'user-new.php' ] = array( _x( 'User', 'add new from admin bar' ), 'new-user' ); |
|
652 | + } |
|
634 | 653 | |
635 | - if ( ! $actions ) |
|
636 | - return; |
|
654 | + if ( ! $actions ) { |
|
655 | + return; |
|
656 | + } |
|
637 | 657 | |
638 | 658 | $title = '<span class="ab-icon"></span><span class="ab-label">' . _x( 'New', 'admin bar menu group label' ) . '</span>'; |
639 | 659 | |
@@ -663,8 +683,9 @@ discard block |
||
663 | 683 | * @param WP_Admin_Bar $wp_admin_bar |
664 | 684 | */ |
665 | 685 | function wp_admin_bar_comments_menu( $wp_admin_bar ) { |
666 | - if ( !current_user_can('edit_posts') ) |
|
667 | - return; |
|
686 | + if ( !current_user_can('edit_posts') ) { |
|
687 | + return; |
|
688 | + } |
|
668 | 689 | |
669 | 690 | $awaiting_mod = wp_count_comments(); |
670 | 691 | $awaiting_mod = $awaiting_mod->moderated; |
@@ -713,8 +734,9 @@ discard block |
||
713 | 734 | ) ); |
714 | 735 | } |
715 | 736 | |
716 | - if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) ) |
|
717 | - $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'menus', 'title' => __('Menus'), 'href' => admin_url('nav-menus.php') ) ); |
|
737 | + if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) ) { |
|
738 | + $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'menus', 'title' => __('Menus'), 'href' => admin_url('nav-menus.php') ) ); |
|
739 | + } |
|
718 | 740 | |
719 | 741 | if ( current_theme_supports( 'custom-background' ) ) { |
720 | 742 | $wp_admin_bar->add_menu( array( |
@@ -753,8 +775,9 @@ discard block |
||
753 | 775 | |
754 | 776 | $update_data = wp_get_update_data(); |
755 | 777 | |
756 | - if ( !$update_data['counts']['total'] ) |
|
757 | - return; |
|
778 | + if ( !$update_data['counts']['total'] ) { |
|
779 | + return; |
|
780 | + } |
|
758 | 781 | |
759 | 782 | $title = '<span class="ab-icon"></span><span class="ab-label">' . number_format_i18n( $update_data['counts']['total'] ) . '</span>'; |
760 | 783 | $title .= '<span class="screen-reader-text">' . $update_data['title'] . '</span>'; |
@@ -777,8 +800,9 @@ discard block |
||
777 | 800 | * @param WP_Admin_Bar $wp_admin_bar |
778 | 801 | */ |
779 | 802 | function wp_admin_bar_search_menu( $wp_admin_bar ) { |
780 | - if ( is_admin() ) |
|
781 | - return; |
|
803 | + if ( is_admin() ) { |
|
804 | + return; |
|
805 | + } |
|
782 | 806 | |
783 | 807 | $form = '<form action="' . esc_url( home_url( '/' ) ) . '" method="get" id="adminbarsearch">'; |
784 | 808 | $form .= '<input class="adminbar-input" name="s" id="adminbar-search" type="text" value="" maxlength="150" />'; |
@@ -878,12 +902,14 @@ discard block |
||
878 | 902 | global $show_admin_bar, $pagenow; |
879 | 903 | |
880 | 904 | // For all these types of requests, we never want an admin bar. |
881 | - if ( defined('XMLRPC_REQUEST') || defined('DOING_AJAX') || defined('IFRAME_REQUEST') ) |
|
882 | - return false; |
|
905 | + if ( defined('XMLRPC_REQUEST') || defined('DOING_AJAX') || defined('IFRAME_REQUEST') ) { |
|
906 | + return false; |
|
907 | + } |
|
883 | 908 | |
884 | 909 | // Integrated into the admin. |
885 | - if ( is_admin() ) |
|
886 | - return true; |
|
910 | + if ( is_admin() ) { |
|
911 | + return true; |
|
912 | + } |
|
887 | 913 | |
888 | 914 | if ( ! isset( $show_admin_bar ) ) { |
889 | 915 | if ( ! is_user_logged_in() || 'wp-login.php' == $pagenow ) { |
@@ -921,8 +947,9 @@ discard block |
||
921 | 947 | */ |
922 | 948 | function _get_admin_bar_pref( $context = 'front', $user = 0 ) { |
923 | 949 | $pref = get_user_option( "show_admin_bar_{$context}", $user ); |
924 | - if ( false === $pref ) |
|
925 | - return true; |
|
950 | + if ( false === $pref ) { |
|
951 | + return true; |
|
952 | + } |
|
926 | 953 | |
927 | 954 | return 'true' === $pref; |
928 | 955 | } |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Toolbar API: Top-level Toolbar functionality |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Toolbar |
|
7 | - * @since 3.1.0 |
|
8 | - */ |
|
3 | + * Toolbar API: Top-level Toolbar functionality |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Toolbar |
|
7 | + * @since 3.1.0 |
|
8 | + */ |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * Instantiate the admin bar object and set it up as a global for access elsewhere. |
@@ -23,11 +23,11 @@ discard block |
||
23 | 23 | function _wp_admin_bar_init() { |
24 | 24 | global $wp_admin_bar; |
25 | 25 | |
26 | - if ( ! is_admin_bar_showing() ) |
|
26 | + if ( ! is_admin_bar_showing()) |
|
27 | 27 | return false; |
28 | 28 | |
29 | 29 | /* Load the admin bar class code ready for instantiation */ |
30 | - require_once( ABSPATH . WPINC . '/class-wp-admin-bar.php' ); |
|
30 | + require_once(ABSPATH.WPINC.'/class-wp-admin-bar.php'); |
|
31 | 31 | |
32 | 32 | /* Instantiate the admin bar */ |
33 | 33 | |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @param string $wp_admin_bar_class Admin bar class to use. Default 'WP_Admin_Bar'. |
40 | 40 | */ |
41 | - $admin_bar_class = apply_filters( 'wp_admin_bar_class', 'WP_Admin_Bar' ); |
|
42 | - if ( class_exists( $admin_bar_class ) ) |
|
41 | + $admin_bar_class = apply_filters('wp_admin_bar_class', 'WP_Admin_Bar'); |
|
42 | + if (class_exists($admin_bar_class)) |
|
43 | 43 | $wp_admin_bar = new $admin_bar_class; |
44 | 44 | else |
45 | 45 | return false; |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | function wp_admin_bar_render() { |
67 | 67 | global $wp_admin_bar; |
68 | 68 | |
69 | - if ( ! is_admin_bar_showing() || ! is_object( $wp_admin_bar ) ) |
|
69 | + if ( ! is_admin_bar_showing() || ! is_object($wp_admin_bar)) |
|
70 | 70 | return; |
71 | 71 | |
72 | 72 | /** |
@@ -78,14 +78,14 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @param WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance, passed by reference |
80 | 80 | */ |
81 | - do_action_ref_array( 'admin_bar_menu', array( &$wp_admin_bar ) ); |
|
81 | + do_action_ref_array('admin_bar_menu', array(&$wp_admin_bar)); |
|
82 | 82 | |
83 | 83 | /** |
84 | 84 | * Fires before the admin bar is rendered. |
85 | 85 | * |
86 | 86 | * @since 3.1.0 |
87 | 87 | */ |
88 | - do_action( 'wp_before_admin_bar_render' ); |
|
88 | + do_action('wp_before_admin_bar_render'); |
|
89 | 89 | |
90 | 90 | $wp_admin_bar->render(); |
91 | 91 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * |
95 | 95 | * @since 3.1.0 |
96 | 96 | */ |
97 | - do_action( 'wp_after_admin_bar_render' ); |
|
97 | + do_action('wp_after_admin_bar_render'); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -104,54 +104,54 @@ discard block |
||
104 | 104 | * |
105 | 105 | * @param WP_Admin_Bar $wp_admin_bar |
106 | 106 | */ |
107 | -function wp_admin_bar_wp_menu( $wp_admin_bar ) { |
|
108 | - $wp_admin_bar->add_menu( array( |
|
107 | +function wp_admin_bar_wp_menu($wp_admin_bar) { |
|
108 | + $wp_admin_bar->add_menu(array( |
|
109 | 109 | 'id' => 'wp-logo', |
110 | - 'title' => '<span class="ab-icon"></span><span class="screen-reader-text">' . __( 'About WordPress' ) . '</span>', |
|
111 | - 'href' => self_admin_url( 'about.php' ), |
|
112 | - ) ); |
|
110 | + 'title' => '<span class="ab-icon"></span><span class="screen-reader-text">'.__('About WordPress').'</span>', |
|
111 | + 'href' => self_admin_url('about.php'), |
|
112 | + )); |
|
113 | 113 | |
114 | - if ( is_user_logged_in() ) { |
|
114 | + if (is_user_logged_in()) { |
|
115 | 115 | // Add "About WordPress" link |
116 | - $wp_admin_bar->add_menu( array( |
|
116 | + $wp_admin_bar->add_menu(array( |
|
117 | 117 | 'parent' => 'wp-logo', |
118 | 118 | 'id' => 'about', |
119 | 119 | 'title' => __('About WordPress'), |
120 | - 'href' => self_admin_url( 'about.php' ), |
|
121 | - ) ); |
|
120 | + 'href' => self_admin_url('about.php'), |
|
121 | + )); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | // Add WordPress.org link |
125 | - $wp_admin_bar->add_menu( array( |
|
125 | + $wp_admin_bar->add_menu(array( |
|
126 | 126 | 'parent' => 'wp-logo-external', |
127 | 127 | 'id' => 'wporg', |
128 | 128 | 'title' => __('WordPress.org'), |
129 | 129 | 'href' => __('https://wordpress.org/'), |
130 | - ) ); |
|
130 | + )); |
|
131 | 131 | |
132 | 132 | // Add codex link |
133 | - $wp_admin_bar->add_menu( array( |
|
133 | + $wp_admin_bar->add_menu(array( |
|
134 | 134 | 'parent' => 'wp-logo-external', |
135 | 135 | 'id' => 'documentation', |
136 | 136 | 'title' => __('Documentation'), |
137 | 137 | 'href' => __('https://codex.wordpress.org/'), |
138 | - ) ); |
|
138 | + )); |
|
139 | 139 | |
140 | 140 | // Add forums link |
141 | - $wp_admin_bar->add_menu( array( |
|
141 | + $wp_admin_bar->add_menu(array( |
|
142 | 142 | 'parent' => 'wp-logo-external', |
143 | 143 | 'id' => 'support-forums', |
144 | 144 | 'title' => __('Support Forums'), |
145 | 145 | 'href' => __('https://wordpress.org/support/'), |
146 | - ) ); |
|
146 | + )); |
|
147 | 147 | |
148 | 148 | // Add feedback link |
149 | - $wp_admin_bar->add_menu( array( |
|
149 | + $wp_admin_bar->add_menu(array( |
|
150 | 150 | 'parent' => 'wp-logo-external', |
151 | 151 | 'id' => 'feedback', |
152 | 152 | 'title' => __('Feedback'), |
153 | 153 | 'href' => __('https://wordpress.org/support/forum/requests-and-feedback'), |
154 | - ) ); |
|
154 | + )); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -161,13 +161,13 @@ discard block |
||
161 | 161 | * |
162 | 162 | * @param WP_Admin_Bar $wp_admin_bar |
163 | 163 | */ |
164 | -function wp_admin_bar_sidebar_toggle( $wp_admin_bar ) { |
|
165 | - if ( is_admin() ) { |
|
166 | - $wp_admin_bar->add_menu( array( |
|
164 | +function wp_admin_bar_sidebar_toggle($wp_admin_bar) { |
|
165 | + if (is_admin()) { |
|
166 | + $wp_admin_bar->add_menu(array( |
|
167 | 167 | 'id' => 'menu-toggle', |
168 | - 'title' => '<span class="ab-icon"></span><span class="screen-reader-text">' . __( 'Menu' ) . '</span>', |
|
168 | + 'title' => '<span class="ab-icon"></span><span class="screen-reader-text">'.__('Menu').'</span>', |
|
169 | 169 | 'href' => '#', |
170 | - ) ); |
|
170 | + )); |
|
171 | 171 | } |
172 | 172 | } |
173 | 173 | |
@@ -178,34 +178,34 @@ discard block |
||
178 | 178 | * |
179 | 179 | * @param WP_Admin_Bar $wp_admin_bar |
180 | 180 | */ |
181 | -function wp_admin_bar_my_account_item( $wp_admin_bar ) { |
|
181 | +function wp_admin_bar_my_account_item($wp_admin_bar) { |
|
182 | 182 | $user_id = get_current_user_id(); |
183 | 183 | $current_user = wp_get_current_user(); |
184 | 184 | |
185 | - if ( ! $user_id ) |
|
185 | + if ( ! $user_id) |
|
186 | 186 | return; |
187 | 187 | |
188 | - if ( current_user_can( 'read' ) ) { |
|
189 | - $profile_url = get_edit_profile_url( $user_id ); |
|
190 | - } elseif ( is_multisite() ) { |
|
191 | - $profile_url = get_dashboard_url( $user_id, 'profile.php' ); |
|
188 | + if (current_user_can('read')) { |
|
189 | + $profile_url = get_edit_profile_url($user_id); |
|
190 | + } elseif (is_multisite()) { |
|
191 | + $profile_url = get_dashboard_url($user_id, 'profile.php'); |
|
192 | 192 | } else { |
193 | 193 | $profile_url = false; |
194 | 194 | } |
195 | 195 | |
196 | - $avatar = get_avatar( $user_id, 26 ); |
|
197 | - $howdy = sprintf( __('Howdy, %1$s'), $current_user->display_name ); |
|
198 | - $class = empty( $avatar ) ? '' : 'with-avatar'; |
|
196 | + $avatar = get_avatar($user_id, 26); |
|
197 | + $howdy = sprintf(__('Howdy, %1$s'), $current_user->display_name); |
|
198 | + $class = empty($avatar) ? '' : 'with-avatar'; |
|
199 | 199 | |
200 | - $wp_admin_bar->add_menu( array( |
|
200 | + $wp_admin_bar->add_menu(array( |
|
201 | 201 | 'id' => 'my-account', |
202 | 202 | 'parent' => 'top-secondary', |
203 | - 'title' => $howdy . $avatar, |
|
203 | + 'title' => $howdy.$avatar, |
|
204 | 204 | 'href' => $profile_url, |
205 | 205 | 'meta' => array( |
206 | 206 | 'class' => $class, |
207 | 207 | ), |
208 | - ) ); |
|
208 | + )); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | /** |
@@ -215,33 +215,33 @@ discard block |
||
215 | 215 | * |
216 | 216 | * @param WP_Admin_Bar $wp_admin_bar |
217 | 217 | */ |
218 | -function wp_admin_bar_my_account_menu( $wp_admin_bar ) { |
|
218 | +function wp_admin_bar_my_account_menu($wp_admin_bar) { |
|
219 | 219 | $user_id = get_current_user_id(); |
220 | 220 | $current_user = wp_get_current_user(); |
221 | 221 | |
222 | - if ( ! $user_id ) |
|
222 | + if ( ! $user_id) |
|
223 | 223 | return; |
224 | 224 | |
225 | - if ( current_user_can( 'read' ) ) { |
|
226 | - $profile_url = get_edit_profile_url( $user_id ); |
|
227 | - } elseif ( is_multisite() ) { |
|
228 | - $profile_url = get_dashboard_url( $user_id, 'profile.php' ); |
|
225 | + if (current_user_can('read')) { |
|
226 | + $profile_url = get_edit_profile_url($user_id); |
|
227 | + } elseif (is_multisite()) { |
|
228 | + $profile_url = get_dashboard_url($user_id, 'profile.php'); |
|
229 | 229 | } else { |
230 | 230 | $profile_url = false; |
231 | 231 | } |
232 | 232 | |
233 | - $wp_admin_bar->add_group( array( |
|
233 | + $wp_admin_bar->add_group(array( |
|
234 | 234 | 'parent' => 'my-account', |
235 | 235 | 'id' => 'user-actions', |
236 | - ) ); |
|
236 | + )); |
|
237 | 237 | |
238 | - $user_info = get_avatar( $user_id, 64 ); |
|
238 | + $user_info = get_avatar($user_id, 64); |
|
239 | 239 | $user_info .= "<span class='display-name'>{$current_user->display_name}</span>"; |
240 | 240 | |
241 | - if ( $current_user->display_name !== $current_user->user_login ) |
|
241 | + if ($current_user->display_name !== $current_user->user_login) |
|
242 | 242 | $user_info .= "<span class='username'>{$current_user->user_login}</span>"; |
243 | 243 | |
244 | - $wp_admin_bar->add_menu( array( |
|
244 | + $wp_admin_bar->add_menu(array( |
|
245 | 245 | 'parent' => 'user-actions', |
246 | 246 | 'id' => 'user-info', |
247 | 247 | 'title' => $user_info, |
@@ -249,23 +249,23 @@ discard block |
||
249 | 249 | 'meta' => array( |
250 | 250 | 'tabindex' => -1, |
251 | 251 | ), |
252 | - ) ); |
|
252 | + )); |
|
253 | 253 | |
254 | - if ( false !== $profile_url ) { |
|
255 | - $wp_admin_bar->add_menu( array( |
|
254 | + if (false !== $profile_url) { |
|
255 | + $wp_admin_bar->add_menu(array( |
|
256 | 256 | 'parent' => 'user-actions', |
257 | 257 | 'id' => 'edit-profile', |
258 | - 'title' => __( 'Edit My Profile' ), |
|
258 | + 'title' => __('Edit My Profile'), |
|
259 | 259 | 'href' => $profile_url, |
260 | - ) ); |
|
260 | + )); |
|
261 | 261 | } |
262 | 262 | |
263 | - $wp_admin_bar->add_menu( array( |
|
263 | + $wp_admin_bar->add_menu(array( |
|
264 | 264 | 'parent' => 'user-actions', |
265 | 265 | 'id' => 'logout', |
266 | - 'title' => __( 'Log Out' ), |
|
266 | + 'title' => __('Log Out'), |
|
267 | 267 | 'href' => wp_logout_url(), |
268 | - ) ); |
|
268 | + )); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | /** |
@@ -275,66 +275,66 @@ discard block |
||
275 | 275 | * |
276 | 276 | * @param WP_Admin_Bar $wp_admin_bar |
277 | 277 | */ |
278 | -function wp_admin_bar_site_menu( $wp_admin_bar ) { |
|
278 | +function wp_admin_bar_site_menu($wp_admin_bar) { |
|
279 | 279 | // Don't show for logged out users. |
280 | - if ( ! is_user_logged_in() ) |
|
280 | + if ( ! is_user_logged_in()) |
|
281 | 281 | return; |
282 | 282 | |
283 | 283 | // Show only when the user is a member of this site, or they're a super admin. |
284 | - if ( ! is_user_member_of_blog() && ! is_super_admin() ) |
|
284 | + if ( ! is_user_member_of_blog() && ! is_super_admin()) |
|
285 | 285 | return; |
286 | 286 | |
287 | 287 | $blogname = get_bloginfo('name'); |
288 | 288 | |
289 | - if ( ! $blogname ) { |
|
290 | - $blogname = preg_replace( '#^(https?://)?(www.)?#', '', get_home_url() ); |
|
289 | + if ( ! $blogname) { |
|
290 | + $blogname = preg_replace('#^(https?://)?(www.)?#', '', get_home_url()); |
|
291 | 291 | } |
292 | 292 | |
293 | - if ( is_network_admin() ) { |
|
294 | - $blogname = sprintf( __('Network Admin: %s'), esc_html( get_current_site()->site_name ) ); |
|
295 | - } elseif ( is_user_admin() ) { |
|
296 | - $blogname = sprintf( __('User Dashboard: %s'), esc_html( get_current_site()->site_name ) ); |
|
293 | + if (is_network_admin()) { |
|
294 | + $blogname = sprintf(__('Network Admin: %s'), esc_html(get_current_site()->site_name)); |
|
295 | + } elseif (is_user_admin()) { |
|
296 | + $blogname = sprintf(__('User Dashboard: %s'), esc_html(get_current_site()->site_name)); |
|
297 | 297 | } |
298 | 298 | |
299 | - $title = wp_html_excerpt( $blogname, 40, '…' ); |
|
299 | + $title = wp_html_excerpt($blogname, 40, '…'); |
|
300 | 300 | |
301 | - $wp_admin_bar->add_menu( array( |
|
301 | + $wp_admin_bar->add_menu(array( |
|
302 | 302 | 'id' => 'site-name', |
303 | 303 | 'title' => $title, |
304 | - 'href' => ( is_admin() || ! current_user_can( 'read' ) ) ? home_url( '/' ) : admin_url(), |
|
305 | - ) ); |
|
304 | + 'href' => (is_admin() || ! current_user_can('read')) ? home_url('/') : admin_url(), |
|
305 | + )); |
|
306 | 306 | |
307 | 307 | // Create submenu items. |
308 | 308 | |
309 | - if ( is_admin() ) { |
|
309 | + if (is_admin()) { |
|
310 | 310 | // Add an option to visit the site. |
311 | - $wp_admin_bar->add_menu( array( |
|
311 | + $wp_admin_bar->add_menu(array( |
|
312 | 312 | 'parent' => 'site-name', |
313 | 313 | 'id' => 'view-site', |
314 | - 'title' => __( 'Visit Site' ), |
|
315 | - 'href' => home_url( '/' ), |
|
316 | - ) ); |
|
314 | + 'title' => __('Visit Site'), |
|
315 | + 'href' => home_url('/'), |
|
316 | + )); |
|
317 | 317 | |
318 | - if ( is_blog_admin() && is_multisite() && current_user_can( 'manage_sites' ) ) { |
|
319 | - $wp_admin_bar->add_menu( array( |
|
318 | + if (is_blog_admin() && is_multisite() && current_user_can('manage_sites')) { |
|
319 | + $wp_admin_bar->add_menu(array( |
|
320 | 320 | 'parent' => 'site-name', |
321 | 321 | 'id' => 'edit-site', |
322 | - 'title' => __( 'Edit Site' ), |
|
323 | - 'href' => network_admin_url( 'site-info.php?id=' . get_current_blog_id() ), |
|
324 | - ) ); |
|
322 | + 'title' => __('Edit Site'), |
|
323 | + 'href' => network_admin_url('site-info.php?id='.get_current_blog_id()), |
|
324 | + )); |
|
325 | 325 | } |
326 | 326 | |
327 | - } else if ( current_user_can( 'read' ) ) { |
|
327 | + } else if (current_user_can('read')) { |
|
328 | 328 | // We're on the front end, link to the Dashboard. |
329 | - $wp_admin_bar->add_menu( array( |
|
329 | + $wp_admin_bar->add_menu(array( |
|
330 | 330 | 'parent' => 'site-name', |
331 | 331 | 'id' => 'dashboard', |
332 | - 'title' => __( 'Dashboard' ), |
|
332 | + 'title' => __('Dashboard'), |
|
333 | 333 | 'href' => admin_url(), |
334 | - ) ); |
|
334 | + )); |
|
335 | 335 | |
336 | 336 | // Add the appearance submenu items. |
337 | - wp_admin_bar_appearance_menu( $wp_admin_bar ); |
|
337 | + wp_admin_bar_appearance_menu($wp_admin_bar); |
|
338 | 338 | } |
339 | 339 | } |
340 | 340 | |
@@ -345,24 +345,24 @@ discard block |
||
345 | 345 | * |
346 | 346 | * @param WP_Admin_Bar $wp_admin_bar WP_Admin_Bar instance. |
347 | 347 | */ |
348 | -function wp_admin_bar_customize_menu( $wp_admin_bar ) { |
|
348 | +function wp_admin_bar_customize_menu($wp_admin_bar) { |
|
349 | 349 | // Don't show for users who can't access the customizer or when in the admin. |
350 | - if ( ! current_user_can( 'customize' ) || is_admin() ) { |
|
350 | + if ( ! current_user_can('customize') || is_admin()) { |
|
351 | 351 | return; |
352 | 352 | } |
353 | 353 | |
354 | - $current_url = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
|
355 | - $customize_url = add_query_arg( 'url', urlencode( $current_url ), wp_customize_url() ); |
|
354 | + $current_url = (is_ssl() ? 'https://' : 'http://').$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; |
|
355 | + $customize_url = add_query_arg('url', urlencode($current_url), wp_customize_url()); |
|
356 | 356 | |
357 | - $wp_admin_bar->add_menu( array( |
|
357 | + $wp_admin_bar->add_menu(array( |
|
358 | 358 | 'id' => 'customize', |
359 | - 'title' => __( 'Customize' ), |
|
359 | + 'title' => __('Customize'), |
|
360 | 360 | 'href' => $customize_url, |
361 | 361 | 'meta' => array( |
362 | 362 | 'class' => 'hide-if-no-customize', |
363 | 363 | ), |
364 | - ) ); |
|
365 | - add_action( 'wp_before_admin_bar_render', 'wp_customize_support_script' ); |
|
364 | + )); |
|
365 | + add_action('wp_before_admin_bar_render', 'wp_customize_support_script'); |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | /** |
@@ -372,138 +372,138 @@ discard block |
||
372 | 372 | * |
373 | 373 | * @param WP_Admin_Bar $wp_admin_bar |
374 | 374 | */ |
375 | -function wp_admin_bar_my_sites_menu( $wp_admin_bar ) { |
|
375 | +function wp_admin_bar_my_sites_menu($wp_admin_bar) { |
|
376 | 376 | // Don't show for logged out users or single site mode. |
377 | - if ( ! is_user_logged_in() || ! is_multisite() ) |
|
377 | + if ( ! is_user_logged_in() || ! is_multisite()) |
|
378 | 378 | return; |
379 | 379 | |
380 | 380 | // Show only when the user has at least one site, or they're a super admin. |
381 | - if ( count( $wp_admin_bar->user->blogs ) < 1 && ! is_super_admin() ) |
|
381 | + if (count($wp_admin_bar->user->blogs) < 1 && ! is_super_admin()) |
|
382 | 382 | return; |
383 | 383 | |
384 | - if ( $wp_admin_bar->user->active_blog ) { |
|
385 | - $my_sites_url = get_admin_url( $wp_admin_bar->user->active_blog->blog_id, 'my-sites.php' ); |
|
384 | + if ($wp_admin_bar->user->active_blog) { |
|
385 | + $my_sites_url = get_admin_url($wp_admin_bar->user->active_blog->blog_id, 'my-sites.php'); |
|
386 | 386 | } else { |
387 | - $my_sites_url = admin_url( 'my-sites.php' ); |
|
387 | + $my_sites_url = admin_url('my-sites.php'); |
|
388 | 388 | } |
389 | 389 | |
390 | - $wp_admin_bar->add_menu( array( |
|
390 | + $wp_admin_bar->add_menu(array( |
|
391 | 391 | 'id' => 'my-sites', |
392 | - 'title' => __( 'My Sites' ), |
|
392 | + 'title' => __('My Sites'), |
|
393 | 393 | 'href' => $my_sites_url, |
394 | - ) ); |
|
394 | + )); |
|
395 | 395 | |
396 | - if ( is_super_admin() ) { |
|
397 | - $wp_admin_bar->add_group( array( |
|
396 | + if (is_super_admin()) { |
|
397 | + $wp_admin_bar->add_group(array( |
|
398 | 398 | 'parent' => 'my-sites', |
399 | 399 | 'id' => 'my-sites-super-admin', |
400 | - ) ); |
|
400 | + )); |
|
401 | 401 | |
402 | - $wp_admin_bar->add_menu( array( |
|
402 | + $wp_admin_bar->add_menu(array( |
|
403 | 403 | 'parent' => 'my-sites-super-admin', |
404 | 404 | 'id' => 'network-admin', |
405 | 405 | 'title' => __('Network Admin'), |
406 | 406 | 'href' => network_admin_url(), |
407 | - ) ); |
|
407 | + )); |
|
408 | 408 | |
409 | - $wp_admin_bar->add_menu( array( |
|
409 | + $wp_admin_bar->add_menu(array( |
|
410 | 410 | 'parent' => 'network-admin', |
411 | 411 | 'id' => 'network-admin-d', |
412 | - 'title' => __( 'Dashboard' ), |
|
412 | + 'title' => __('Dashboard'), |
|
413 | 413 | 'href' => network_admin_url(), |
414 | - ) ); |
|
415 | - $wp_admin_bar->add_menu( array( |
|
414 | + )); |
|
415 | + $wp_admin_bar->add_menu(array( |
|
416 | 416 | 'parent' => 'network-admin', |
417 | 417 | 'id' => 'network-admin-s', |
418 | - 'title' => __( 'Sites' ), |
|
419 | - 'href' => network_admin_url( 'sites.php' ), |
|
420 | - ) ); |
|
421 | - $wp_admin_bar->add_menu( array( |
|
418 | + 'title' => __('Sites'), |
|
419 | + 'href' => network_admin_url('sites.php'), |
|
420 | + )); |
|
421 | + $wp_admin_bar->add_menu(array( |
|
422 | 422 | 'parent' => 'network-admin', |
423 | 423 | 'id' => 'network-admin-u', |
424 | - 'title' => __( 'Users' ), |
|
425 | - 'href' => network_admin_url( 'users.php' ), |
|
426 | - ) ); |
|
427 | - $wp_admin_bar->add_menu( array( |
|
424 | + 'title' => __('Users'), |
|
425 | + 'href' => network_admin_url('users.php'), |
|
426 | + )); |
|
427 | + $wp_admin_bar->add_menu(array( |
|
428 | 428 | 'parent' => 'network-admin', |
429 | 429 | 'id' => 'network-admin-t', |
430 | - 'title' => __( 'Themes' ), |
|
431 | - 'href' => network_admin_url( 'themes.php' ), |
|
432 | - ) ); |
|
433 | - $wp_admin_bar->add_menu( array( |
|
430 | + 'title' => __('Themes'), |
|
431 | + 'href' => network_admin_url('themes.php'), |
|
432 | + )); |
|
433 | + $wp_admin_bar->add_menu(array( |
|
434 | 434 | 'parent' => 'network-admin', |
435 | 435 | 'id' => 'network-admin-p', |
436 | - 'title' => __( 'Plugins' ), |
|
437 | - 'href' => network_admin_url( 'plugins.php' ), |
|
438 | - ) ); |
|
439 | - $wp_admin_bar->add_menu( array( |
|
436 | + 'title' => __('Plugins'), |
|
437 | + 'href' => network_admin_url('plugins.php'), |
|
438 | + )); |
|
439 | + $wp_admin_bar->add_menu(array( |
|
440 | 440 | 'parent' => 'network-admin', |
441 | 441 | 'id' => 'network-admin-o', |
442 | - 'title' => __( 'Settings' ), |
|
443 | - 'href' => network_admin_url( 'settings.php' ), |
|
444 | - ) ); |
|
442 | + 'title' => __('Settings'), |
|
443 | + 'href' => network_admin_url('settings.php'), |
|
444 | + )); |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | // Add site links |
448 | - $wp_admin_bar->add_group( array( |
|
448 | + $wp_admin_bar->add_group(array( |
|
449 | 449 | 'parent' => 'my-sites', |
450 | 450 | 'id' => 'my-sites-list', |
451 | 451 | 'meta' => array( |
452 | 452 | 'class' => is_super_admin() ? 'ab-sub-secondary' : '', |
453 | 453 | ), |
454 | - ) ); |
|
454 | + )); |
|
455 | 455 | |
456 | - foreach ( (array) $wp_admin_bar->user->blogs as $blog ) { |
|
457 | - switch_to_blog( $blog->userblog_id ); |
|
456 | + foreach ((array) $wp_admin_bar->user->blogs as $blog) { |
|
457 | + switch_to_blog($blog->userblog_id); |
|
458 | 458 | |
459 | 459 | $blavatar = '<div class="blavatar"></div>'; |
460 | 460 | |
461 | 461 | $blogname = $blog->blogname; |
462 | 462 | |
463 | - if ( ! $blogname ) { |
|
464 | - $blogname = preg_replace( '#^(https?://)?(www.)?#', '', get_home_url() ); |
|
463 | + if ( ! $blogname) { |
|
464 | + $blogname = preg_replace('#^(https?://)?(www.)?#', '', get_home_url()); |
|
465 | 465 | } |
466 | 466 | |
467 | - $menu_id = 'blog-' . $blog->userblog_id; |
|
467 | + $menu_id = 'blog-'.$blog->userblog_id; |
|
468 | 468 | |
469 | - $wp_admin_bar->add_menu( array( |
|
469 | + $wp_admin_bar->add_menu(array( |
|
470 | 470 | 'parent' => 'my-sites-list', |
471 | 471 | 'id' => $menu_id, |
472 | - 'title' => $blavatar . $blogname, |
|
472 | + 'title' => $blavatar.$blogname, |
|
473 | 473 | 'href' => admin_url(), |
474 | - ) ); |
|
474 | + )); |
|
475 | 475 | |
476 | - $wp_admin_bar->add_menu( array( |
|
476 | + $wp_admin_bar->add_menu(array( |
|
477 | 477 | 'parent' => $menu_id, |
478 | - 'id' => $menu_id . '-d', |
|
479 | - 'title' => __( 'Dashboard' ), |
|
478 | + 'id' => $menu_id.'-d', |
|
479 | + 'title' => __('Dashboard'), |
|
480 | 480 | 'href' => admin_url(), |
481 | - ) ); |
|
481 | + )); |
|
482 | 482 | |
483 | - if ( current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) { |
|
484 | - $wp_admin_bar->add_menu( array( |
|
483 | + if (current_user_can(get_post_type_object('post')->cap->create_posts)) { |
|
484 | + $wp_admin_bar->add_menu(array( |
|
485 | 485 | 'parent' => $menu_id, |
486 | - 'id' => $menu_id . '-n', |
|
487 | - 'title' => __( 'New Post' ), |
|
488 | - 'href' => admin_url( 'post-new.php' ), |
|
489 | - ) ); |
|
486 | + 'id' => $menu_id.'-n', |
|
487 | + 'title' => __('New Post'), |
|
488 | + 'href' => admin_url('post-new.php'), |
|
489 | + )); |
|
490 | 490 | } |
491 | 491 | |
492 | - if ( current_user_can( 'edit_posts' ) ) { |
|
493 | - $wp_admin_bar->add_menu( array( |
|
492 | + if (current_user_can('edit_posts')) { |
|
493 | + $wp_admin_bar->add_menu(array( |
|
494 | 494 | 'parent' => $menu_id, |
495 | - 'id' => $menu_id . '-c', |
|
496 | - 'title' => __( 'Manage Comments' ), |
|
497 | - 'href' => admin_url( 'edit-comments.php' ), |
|
498 | - ) ); |
|
495 | + 'id' => $menu_id.'-c', |
|
496 | + 'title' => __('Manage Comments'), |
|
497 | + 'href' => admin_url('edit-comments.php'), |
|
498 | + )); |
|
499 | 499 | } |
500 | 500 | |
501 | - $wp_admin_bar->add_menu( array( |
|
501 | + $wp_admin_bar->add_menu(array( |
|
502 | 502 | 'parent' => $menu_id, |
503 | - 'id' => $menu_id . '-v', |
|
504 | - 'title' => __( 'Visit Site' ), |
|
505 | - 'href' => home_url( '/' ), |
|
506 | - ) ); |
|
503 | + 'id' => $menu_id.'-v', |
|
504 | + 'title' => __('Visit Site'), |
|
505 | + 'href' => home_url('/'), |
|
506 | + )); |
|
507 | 507 | |
508 | 508 | restore_current_blog(); |
509 | 509 | } |
@@ -516,21 +516,21 @@ discard block |
||
516 | 516 | * |
517 | 517 | * @param WP_Admin_Bar $wp_admin_bar |
518 | 518 | */ |
519 | -function wp_admin_bar_shortlink_menu( $wp_admin_bar ) { |
|
520 | - $short = wp_get_shortlink( 0, 'query' ); |
|
519 | +function wp_admin_bar_shortlink_menu($wp_admin_bar) { |
|
520 | + $short = wp_get_shortlink(0, 'query'); |
|
521 | 521 | $id = 'get-shortlink'; |
522 | 522 | |
523 | - if ( empty( $short ) ) |
|
523 | + if (empty($short)) |
|
524 | 524 | return; |
525 | 525 | |
526 | - $html = '<input class="shortlink-input" type="text" readonly="readonly" value="' . esc_attr( $short ) . '" />'; |
|
526 | + $html = '<input class="shortlink-input" type="text" readonly="readonly" value="'.esc_attr($short).'" />'; |
|
527 | 527 | |
528 | - $wp_admin_bar->add_menu( array( |
|
528 | + $wp_admin_bar->add_menu(array( |
|
529 | 529 | 'id' => $id, |
530 | - 'title' => __( 'Shortlink' ), |
|
530 | + 'title' => __('Shortlink'), |
|
531 | 531 | 'href' => $short, |
532 | - 'meta' => array( 'html' => $html ), |
|
533 | - ) ); |
|
532 | + 'meta' => array('html' => $html), |
|
533 | + )); |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | /** |
@@ -543,73 +543,73 @@ discard block |
||
543 | 543 | * |
544 | 544 | * @param WP_Admin_Bar $wp_admin_bar |
545 | 545 | */ |
546 | -function wp_admin_bar_edit_menu( $wp_admin_bar ) { |
|
546 | +function wp_admin_bar_edit_menu($wp_admin_bar) { |
|
547 | 547 | global $tag, $wp_the_query; |
548 | 548 | |
549 | - if ( is_admin() ) { |
|
549 | + if (is_admin()) { |
|
550 | 550 | $current_screen = get_current_screen(); |
551 | 551 | $post = get_post(); |
552 | 552 | |
553 | - if ( 'post' == $current_screen->base |
|
553 | + if ('post' == $current_screen->base |
|
554 | 554 | && 'add' != $current_screen->action |
555 | - && ( $post_type_object = get_post_type_object( $post->post_type ) ) |
|
556 | - && current_user_can( 'read_post', $post->ID ) |
|
557 | - && ( $post_type_object->public ) |
|
558 | - && ( $post_type_object->show_in_admin_bar ) ) |
|
555 | + && ($post_type_object = get_post_type_object($post->post_type)) |
|
556 | + && current_user_can('read_post', $post->ID) |
|
557 | + && ($post_type_object->public) |
|
558 | + && ($post_type_object->show_in_admin_bar)) |
|
559 | 559 | { |
560 | - if ( 'draft' == $post->post_status ) { |
|
561 | - $preview_link = get_preview_post_link( $post ); |
|
562 | - $wp_admin_bar->add_menu( array( |
|
560 | + if ('draft' == $post->post_status) { |
|
561 | + $preview_link = get_preview_post_link($post); |
|
562 | + $wp_admin_bar->add_menu(array( |
|
563 | 563 | 'id' => 'preview', |
564 | 564 | 'title' => $post_type_object->labels->view_item, |
565 | - 'href' => esc_url( $preview_link ), |
|
566 | - 'meta' => array( 'target' => 'wp-preview-' . $post->ID ), |
|
567 | - ) ); |
|
565 | + 'href' => esc_url($preview_link), |
|
566 | + 'meta' => array('target' => 'wp-preview-'.$post->ID), |
|
567 | + )); |
|
568 | 568 | } else { |
569 | - $wp_admin_bar->add_menu( array( |
|
569 | + $wp_admin_bar->add_menu(array( |
|
570 | 570 | 'id' => 'view', |
571 | 571 | 'title' => $post_type_object->labels->view_item, |
572 | - 'href' => get_permalink( $post->ID ) |
|
573 | - ) ); |
|
572 | + 'href' => get_permalink($post->ID) |
|
573 | + )); |
|
574 | 574 | } |
575 | - } elseif ( 'term' == $current_screen->base |
|
576 | - && isset( $tag ) && is_object( $tag ) && ! is_wp_error( $tag ) |
|
577 | - && ( $tax = get_taxonomy( $tag->taxonomy ) ) |
|
578 | - && $tax->public ) |
|
575 | + } elseif ('term' == $current_screen->base |
|
576 | + && isset($tag) && is_object($tag) && ! is_wp_error($tag) |
|
577 | + && ($tax = get_taxonomy($tag->taxonomy)) |
|
578 | + && $tax->public) |
|
579 | 579 | { |
580 | - $wp_admin_bar->add_menu( array( |
|
580 | + $wp_admin_bar->add_menu(array( |
|
581 | 581 | 'id' => 'view', |
582 | 582 | 'title' => $tax->labels->view_item, |
583 | - 'href' => get_term_link( $tag ) |
|
584 | - ) ); |
|
583 | + 'href' => get_term_link($tag) |
|
584 | + )); |
|
585 | 585 | } |
586 | 586 | } else { |
587 | 587 | $current_object = $wp_the_query->get_queried_object(); |
588 | 588 | |
589 | - if ( empty( $current_object ) ) |
|
589 | + if (empty($current_object)) |
|
590 | 590 | return; |
591 | 591 | |
592 | - if ( ! empty( $current_object->post_type ) |
|
593 | - && ( $post_type_object = get_post_type_object( $current_object->post_type ) ) |
|
594 | - && current_user_can( 'edit_post', $current_object->ID ) |
|
592 | + if ( ! empty($current_object->post_type) |
|
593 | + && ($post_type_object = get_post_type_object($current_object->post_type)) |
|
594 | + && current_user_can('edit_post', $current_object->ID) |
|
595 | 595 | && $post_type_object->show_in_admin_bar |
596 | - && $edit_post_link = get_edit_post_link( $current_object->ID ) ) |
|
596 | + && $edit_post_link = get_edit_post_link($current_object->ID)) |
|
597 | 597 | { |
598 | - $wp_admin_bar->add_menu( array( |
|
598 | + $wp_admin_bar->add_menu(array( |
|
599 | 599 | 'id' => 'edit', |
600 | 600 | 'title' => $post_type_object->labels->edit_item, |
601 | 601 | 'href' => $edit_post_link |
602 | - ) ); |
|
603 | - } elseif ( ! empty( $current_object->taxonomy ) |
|
604 | - && ( $tax = get_taxonomy( $current_object->taxonomy ) ) |
|
605 | - && current_user_can( $tax->cap->edit_terms ) |
|
606 | - && $edit_term_link = get_edit_term_link( $current_object->term_id, $current_object->taxonomy ) ) |
|
602 | + )); |
|
603 | + } elseif ( ! empty($current_object->taxonomy) |
|
604 | + && ($tax = get_taxonomy($current_object->taxonomy)) |
|
605 | + && current_user_can($tax->cap->edit_terms) |
|
606 | + && $edit_term_link = get_edit_term_link($current_object->term_id, $current_object->taxonomy)) |
|
607 | 607 | { |
608 | - $wp_admin_bar->add_menu( array( |
|
608 | + $wp_admin_bar->add_menu(array( |
|
609 | 609 | 'id' => 'edit', |
610 | 610 | 'title' => $tax->labels->edit_item, |
611 | 611 | 'href' => $edit_term_link |
612 | - ) ); |
|
612 | + )); |
|
613 | 613 | } |
614 | 614 | } |
615 | 615 | } |
@@ -621,60 +621,60 @@ discard block |
||
621 | 621 | * |
622 | 622 | * @param WP_Admin_Bar $wp_admin_bar |
623 | 623 | */ |
624 | -function wp_admin_bar_new_content_menu( $wp_admin_bar ) { |
|
624 | +function wp_admin_bar_new_content_menu($wp_admin_bar) { |
|
625 | 625 | $actions = array(); |
626 | 626 | |
627 | - $cpts = (array) get_post_types( array( 'show_in_admin_bar' => true ), 'objects' ); |
|
627 | + $cpts = (array) get_post_types(array('show_in_admin_bar' => true), 'objects'); |
|
628 | 628 | |
629 | - if ( isset( $cpts['post'] ) && current_user_can( $cpts['post']->cap->create_posts ) ) |
|
630 | - $actions[ 'post-new.php' ] = array( $cpts['post']->labels->name_admin_bar, 'new-post' ); |
|
629 | + if (isset($cpts['post']) && current_user_can($cpts['post']->cap->create_posts)) |
|
630 | + $actions['post-new.php'] = array($cpts['post']->labels->name_admin_bar, 'new-post'); |
|
631 | 631 | |
632 | - if ( isset( $cpts['attachment'] ) && current_user_can( 'upload_files' ) ) |
|
633 | - $actions[ 'media-new.php' ] = array( $cpts['attachment']->labels->name_admin_bar, 'new-media' ); |
|
632 | + if (isset($cpts['attachment']) && current_user_can('upload_files')) |
|
633 | + $actions['media-new.php'] = array($cpts['attachment']->labels->name_admin_bar, 'new-media'); |
|
634 | 634 | |
635 | - if ( current_user_can( 'manage_links' ) ) |
|
636 | - $actions[ 'link-add.php' ] = array( _x( 'Link', 'add new from admin bar' ), 'new-link' ); |
|
635 | + if (current_user_can('manage_links')) |
|
636 | + $actions['link-add.php'] = array(_x('Link', 'add new from admin bar'), 'new-link'); |
|
637 | 637 | |
638 | - if ( isset( $cpts['page'] ) && current_user_can( $cpts['page']->cap->create_posts ) ) |
|
639 | - $actions[ 'post-new.php?post_type=page' ] = array( $cpts['page']->labels->name_admin_bar, 'new-page' ); |
|
638 | + if (isset($cpts['page']) && current_user_can($cpts['page']->cap->create_posts)) |
|
639 | + $actions['post-new.php?post_type=page'] = array($cpts['page']->labels->name_admin_bar, 'new-page'); |
|
640 | 640 | |
641 | - unset( $cpts['post'], $cpts['page'], $cpts['attachment'] ); |
|
641 | + unset($cpts['post'], $cpts['page'], $cpts['attachment']); |
|
642 | 642 | |
643 | 643 | // Add any additional custom post types. |
644 | - foreach ( $cpts as $cpt ) { |
|
645 | - if ( ! current_user_can( $cpt->cap->create_posts ) ) |
|
644 | + foreach ($cpts as $cpt) { |
|
645 | + if ( ! current_user_can($cpt->cap->create_posts)) |
|
646 | 646 | continue; |
647 | 647 | |
648 | - $key = 'post-new.php?post_type=' . $cpt->name; |
|
649 | - $actions[ $key ] = array( $cpt->labels->name_admin_bar, 'new-' . $cpt->name ); |
|
648 | + $key = 'post-new.php?post_type='.$cpt->name; |
|
649 | + $actions[$key] = array($cpt->labels->name_admin_bar, 'new-'.$cpt->name); |
|
650 | 650 | } |
651 | 651 | // Avoid clash with parent node and a 'content' post type. |
652 | - if ( isset( $actions['post-new.php?post_type=content'] ) ) |
|
652 | + if (isset($actions['post-new.php?post_type=content'])) |
|
653 | 653 | $actions['post-new.php?post_type=content'][1] = 'add-new-content'; |
654 | 654 | |
655 | - if ( current_user_can( 'create_users' ) || current_user_can( 'promote_users' ) ) |
|
656 | - $actions[ 'user-new.php' ] = array( _x( 'User', 'add new from admin bar' ), 'new-user' ); |
|
655 | + if (current_user_can('create_users') || current_user_can('promote_users')) |
|
656 | + $actions['user-new.php'] = array(_x('User', 'add new from admin bar'), 'new-user'); |
|
657 | 657 | |
658 | - if ( ! $actions ) |
|
658 | + if ( ! $actions) |
|
659 | 659 | return; |
660 | 660 | |
661 | - $title = '<span class="ab-icon"></span><span class="ab-label">' . _x( 'New', 'admin bar menu group label' ) . '</span>'; |
|
661 | + $title = '<span class="ab-icon"></span><span class="ab-label">'._x('New', 'admin bar menu group label').'</span>'; |
|
662 | 662 | |
663 | - $wp_admin_bar->add_menu( array( |
|
663 | + $wp_admin_bar->add_menu(array( |
|
664 | 664 | 'id' => 'new-content', |
665 | 665 | 'title' => $title, |
666 | - 'href' => admin_url( current( array_keys( $actions ) ) ), |
|
667 | - ) ); |
|
666 | + 'href' => admin_url(current(array_keys($actions))), |
|
667 | + )); |
|
668 | 668 | |
669 | - foreach ( $actions as $link => $action ) { |
|
670 | - list( $title, $id ) = $action; |
|
669 | + foreach ($actions as $link => $action) { |
|
670 | + list($title, $id) = $action; |
|
671 | 671 | |
672 | - $wp_admin_bar->add_menu( array( |
|
672 | + $wp_admin_bar->add_menu(array( |
|
673 | 673 | 'parent' => 'new-content', |
674 | 674 | 'id' => $id, |
675 | 675 | 'title' => $title, |
676 | - 'href' => admin_url( $link ) |
|
677 | - ) ); |
|
676 | + 'href' => admin_url($link) |
|
677 | + )); |
|
678 | 678 | } |
679 | 679 | } |
680 | 680 | |
@@ -685,23 +685,23 @@ discard block |
||
685 | 685 | * |
686 | 686 | * @param WP_Admin_Bar $wp_admin_bar |
687 | 687 | */ |
688 | -function wp_admin_bar_comments_menu( $wp_admin_bar ) { |
|
689 | - if ( !current_user_can('edit_posts') ) |
|
688 | +function wp_admin_bar_comments_menu($wp_admin_bar) { |
|
689 | + if ( ! current_user_can('edit_posts')) |
|
690 | 690 | return; |
691 | 691 | |
692 | 692 | $awaiting_mod = wp_count_comments(); |
693 | 693 | $awaiting_mod = $awaiting_mod->moderated; |
694 | - $awaiting_text = sprintf( _n( '%s comment awaiting moderation', '%s comments awaiting moderation', $awaiting_mod ), number_format_i18n( $awaiting_mod ) ); |
|
694 | + $awaiting_text = sprintf(_n('%s comment awaiting moderation', '%s comments awaiting moderation', $awaiting_mod), number_format_i18n($awaiting_mod)); |
|
695 | 695 | |
696 | 696 | $icon = '<span class="ab-icon"></span>'; |
697 | - $title = '<span id="ab-awaiting-mod" class="ab-label awaiting-mod pending-count count-' . $awaiting_mod . '" aria-hidden="true">' . number_format_i18n( $awaiting_mod ) . '</span>'; |
|
698 | - $title .= '<span class="screen-reader-text">' . $awaiting_text . '</span>'; |
|
697 | + $title = '<span id="ab-awaiting-mod" class="ab-label awaiting-mod pending-count count-'.$awaiting_mod.'" aria-hidden="true">'.number_format_i18n($awaiting_mod).'</span>'; |
|
698 | + $title .= '<span class="screen-reader-text">'.$awaiting_text.'</span>'; |
|
699 | 699 | |
700 | - $wp_admin_bar->add_menu( array( |
|
700 | + $wp_admin_bar->add_menu(array( |
|
701 | 701 | 'id' => 'comments', |
702 | - 'title' => $icon . $title, |
|
702 | + 'title' => $icon.$title, |
|
703 | 703 | 'href' => admin_url('edit-comments.php'), |
704 | - ) ); |
|
704 | + )); |
|
705 | 705 | } |
706 | 706 | |
707 | 707 | /** |
@@ -711,56 +711,56 @@ discard block |
||
711 | 711 | * |
712 | 712 | * @param WP_Admin_Bar $wp_admin_bar |
713 | 713 | */ |
714 | -function wp_admin_bar_appearance_menu( $wp_admin_bar ) { |
|
715 | - $wp_admin_bar->add_group( array( 'parent' => 'site-name', 'id' => 'appearance' ) ); |
|
714 | +function wp_admin_bar_appearance_menu($wp_admin_bar) { |
|
715 | + $wp_admin_bar->add_group(array('parent' => 'site-name', 'id' => 'appearance')); |
|
716 | 716 | |
717 | - if ( current_user_can( 'switch_themes' ) ) { |
|
718 | - $wp_admin_bar->add_menu( array( |
|
717 | + if (current_user_can('switch_themes')) { |
|
718 | + $wp_admin_bar->add_menu(array( |
|
719 | 719 | 'parent' => 'appearance', |
720 | 720 | 'id' => 'themes', |
721 | - 'title' => __( 'Themes' ), |
|
722 | - 'href' => admin_url( 'themes.php' ), |
|
723 | - ) ); |
|
721 | + 'title' => __('Themes'), |
|
722 | + 'href' => admin_url('themes.php'), |
|
723 | + )); |
|
724 | 724 | } |
725 | 725 | |
726 | - if ( ! current_user_can( 'edit_theme_options' ) ) { |
|
726 | + if ( ! current_user_can('edit_theme_options')) { |
|
727 | 727 | return; |
728 | 728 | } |
729 | 729 | |
730 | - if ( current_theme_supports( 'widgets' ) ) { |
|
731 | - $wp_admin_bar->add_menu( array( |
|
730 | + if (current_theme_supports('widgets')) { |
|
731 | + $wp_admin_bar->add_menu(array( |
|
732 | 732 | 'parent' => 'appearance', |
733 | 733 | 'id' => 'widgets', |
734 | - 'title' => __( 'Widgets' ), |
|
735 | - 'href' => admin_url( 'widgets.php' ), |
|
736 | - ) ); |
|
734 | + 'title' => __('Widgets'), |
|
735 | + 'href' => admin_url('widgets.php'), |
|
736 | + )); |
|
737 | 737 | } |
738 | 738 | |
739 | - if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) ) |
|
740 | - $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'menus', 'title' => __('Menus'), 'href' => admin_url('nav-menus.php') ) ); |
|
739 | + if (current_theme_supports('menus') || current_theme_supports('widgets')) |
|
740 | + $wp_admin_bar->add_menu(array('parent' => 'appearance', 'id' => 'menus', 'title' => __('Menus'), 'href' => admin_url('nav-menus.php'))); |
|
741 | 741 | |
742 | - if ( current_theme_supports( 'custom-background' ) ) { |
|
743 | - $wp_admin_bar->add_menu( array( |
|
742 | + if (current_theme_supports('custom-background')) { |
|
743 | + $wp_admin_bar->add_menu(array( |
|
744 | 744 | 'parent' => 'appearance', |
745 | 745 | 'id' => 'background', |
746 | - 'title' => __( 'Background' ), |
|
747 | - 'href' => admin_url( 'themes.php?page=custom-background' ), |
|
746 | + 'title' => __('Background'), |
|
747 | + 'href' => admin_url('themes.php?page=custom-background'), |
|
748 | 748 | 'meta' => array( |
749 | 749 | 'class' => 'hide-if-customize', |
750 | 750 | ), |
751 | - ) ); |
|
751 | + )); |
|
752 | 752 | } |
753 | 753 | |
754 | - if ( current_theme_supports( 'custom-header' ) ) { |
|
755 | - $wp_admin_bar->add_menu( array( |
|
754 | + if (current_theme_supports('custom-header')) { |
|
755 | + $wp_admin_bar->add_menu(array( |
|
756 | 756 | 'parent' => 'appearance', |
757 | 757 | 'id' => 'header', |
758 | - 'title' => __( 'Header' ), |
|
759 | - 'href' => admin_url( 'themes.php?page=custom-header' ), |
|
758 | + 'title' => __('Header'), |
|
759 | + 'href' => admin_url('themes.php?page=custom-header'), |
|
760 | 760 | 'meta' => array( |
761 | 761 | 'class' => 'hide-if-customize', |
762 | 762 | ), |
763 | - ) ); |
|
763 | + )); |
|
764 | 764 | } |
765 | 765 | |
766 | 766 | } |
@@ -772,24 +772,24 @@ discard block |
||
772 | 772 | * |
773 | 773 | * @param WP_Admin_Bar $wp_admin_bar |
774 | 774 | */ |
775 | -function wp_admin_bar_updates_menu( $wp_admin_bar ) { |
|
775 | +function wp_admin_bar_updates_menu($wp_admin_bar) { |
|
776 | 776 | |
777 | 777 | $update_data = wp_get_update_data(); |
778 | 778 | |
779 | - if ( !$update_data['counts']['total'] ) |
|
779 | + if ( ! $update_data['counts']['total']) |
|
780 | 780 | return; |
781 | 781 | |
782 | - $title = '<span class="ab-icon"></span><span class="ab-label">' . number_format_i18n( $update_data['counts']['total'] ) . '</span>'; |
|
783 | - $title .= '<span class="screen-reader-text">' . $update_data['title'] . '</span>'; |
|
782 | + $title = '<span class="ab-icon"></span><span class="ab-label">'.number_format_i18n($update_data['counts']['total']).'</span>'; |
|
783 | + $title .= '<span class="screen-reader-text">'.$update_data['title'].'</span>'; |
|
784 | 784 | |
785 | - $wp_admin_bar->add_menu( array( |
|
785 | + $wp_admin_bar->add_menu(array( |
|
786 | 786 | 'id' => 'updates', |
787 | 787 | 'title' => $title, |
788 | - 'href' => network_admin_url( 'update-core.php' ), |
|
788 | + 'href' => network_admin_url('update-core.php'), |
|
789 | 789 | 'meta' => array( |
790 | 790 | 'title' => $update_data['title'], |
791 | 791 | ), |
792 | - ) ); |
|
792 | + )); |
|
793 | 793 | } |
794 | 794 | |
795 | 795 | /** |
@@ -799,17 +799,17 @@ discard block |
||
799 | 799 | * |
800 | 800 | * @param WP_Admin_Bar $wp_admin_bar |
801 | 801 | */ |
802 | -function wp_admin_bar_search_menu( $wp_admin_bar ) { |
|
803 | - if ( is_admin() ) |
|
802 | +function wp_admin_bar_search_menu($wp_admin_bar) { |
|
803 | + if (is_admin()) |
|
804 | 804 | return; |
805 | 805 | |
806 | - $form = '<form action="' . esc_url( home_url( '/' ) ) . '" method="get" id="adminbarsearch">'; |
|
806 | + $form = '<form action="'.esc_url(home_url('/')).'" method="get" id="adminbarsearch">'; |
|
807 | 807 | $form .= '<input class="adminbar-input" name="s" id="adminbar-search" type="text" value="" maxlength="150" />'; |
808 | - $form .= '<label for="adminbar-search" class="screen-reader-text">' . __( 'Search' ) . '</label>'; |
|
809 | - $form .= '<input type="submit" class="adminbar-button" value="' . __('Search') . '"/>'; |
|
808 | + $form .= '<label for="adminbar-search" class="screen-reader-text">'.__('Search').'</label>'; |
|
809 | + $form .= '<input type="submit" class="adminbar-button" value="'.__('Search').'"/>'; |
|
810 | 810 | $form .= '</form>'; |
811 | 811 | |
812 | - $wp_admin_bar->add_menu( array( |
|
812 | + $wp_admin_bar->add_menu(array( |
|
813 | 813 | 'parent' => 'top-secondary', |
814 | 814 | 'id' => 'search', |
815 | 815 | 'title' => $form, |
@@ -817,7 +817,7 @@ discard block |
||
817 | 817 | 'class' => 'admin-bar-search', |
818 | 818 | 'tabindex' => -1, |
819 | 819 | ) |
820 | - ) ); |
|
820 | + )); |
|
821 | 821 | } |
822 | 822 | |
823 | 823 | /** |
@@ -827,21 +827,21 @@ discard block |
||
827 | 827 | * |
828 | 828 | * @param WP_Admin_Bar $wp_admin_bar |
829 | 829 | */ |
830 | -function wp_admin_bar_add_secondary_groups( $wp_admin_bar ) { |
|
831 | - $wp_admin_bar->add_group( array( |
|
830 | +function wp_admin_bar_add_secondary_groups($wp_admin_bar) { |
|
831 | + $wp_admin_bar->add_group(array( |
|
832 | 832 | 'id' => 'top-secondary', |
833 | 833 | 'meta' => array( |
834 | 834 | 'class' => 'ab-top-secondary', |
835 | 835 | ), |
836 | - ) ); |
|
836 | + )); |
|
837 | 837 | |
838 | - $wp_admin_bar->add_group( array( |
|
838 | + $wp_admin_bar->add_group(array( |
|
839 | 839 | 'parent' => 'wp-logo', |
840 | 840 | 'id' => 'wp-logo-external', |
841 | 841 | 'meta' => array( |
842 | 842 | 'class' => 'ab-sub-secondary', |
843 | 843 | ), |
844 | - ) ); |
|
844 | + )); |
|
845 | 845 | } |
846 | 846 | |
847 | 847 | /** |
@@ -882,7 +882,7 @@ discard block |
||
882 | 882 | * |
883 | 883 | * @param bool $show Whether to allow the admin bar to show. |
884 | 884 | */ |
885 | -function show_admin_bar( $show ) { |
|
885 | +function show_admin_bar($show) { |
|
886 | 886 | global $show_admin_bar; |
887 | 887 | $show_admin_bar = (bool) $show; |
888 | 888 | } |
@@ -901,19 +901,19 @@ discard block |
||
901 | 901 | global $show_admin_bar, $pagenow; |
902 | 902 | |
903 | 903 | // For all these types of requests, we never want an admin bar. |
904 | - if ( defined('XMLRPC_REQUEST') || defined('DOING_AJAX') || defined('IFRAME_REQUEST') ) |
|
904 | + if (defined('XMLRPC_REQUEST') || defined('DOING_AJAX') || defined('IFRAME_REQUEST')) |
|
905 | 905 | return false; |
906 | 906 | |
907 | - if ( is_embed() ) { |
|
907 | + if (is_embed()) { |
|
908 | 908 | return false; |
909 | 909 | } |
910 | 910 | |
911 | 911 | // Integrated into the admin. |
912 | - if ( is_admin() ) |
|
912 | + if (is_admin()) |
|
913 | 913 | return true; |
914 | 914 | |
915 | - if ( ! isset( $show_admin_bar ) ) { |
|
916 | - if ( ! is_user_logged_in() || 'wp-login.php' == $pagenow ) { |
|
915 | + if ( ! isset($show_admin_bar)) { |
|
916 | + if ( ! is_user_logged_in() || 'wp-login.php' == $pagenow) { |
|
917 | 917 | $show_admin_bar = false; |
918 | 918 | } else { |
919 | 919 | $show_admin_bar = _get_admin_bar_pref(); |
@@ -930,7 +930,7 @@ discard block |
||
930 | 930 | * |
931 | 931 | * @param bool $show_admin_bar Whether the admin bar should be shown. Default false. |
932 | 932 | */ |
933 | - $show_admin_bar = apply_filters( 'show_admin_bar', $show_admin_bar ); |
|
933 | + $show_admin_bar = apply_filters('show_admin_bar', $show_admin_bar); |
|
934 | 934 | |
935 | 935 | return $show_admin_bar; |
936 | 936 | } |
@@ -946,9 +946,9 @@ discard block |
||
946 | 946 | * @param int $user Optional. ID of the user to check, defaults to 0 for current user. |
947 | 947 | * @return bool Whether the admin bar should be showing for this user. |
948 | 948 | */ |
949 | -function _get_admin_bar_pref( $context = 'front', $user = 0 ) { |
|
950 | - $pref = get_user_option( "show_admin_bar_{$context}", $user ); |
|
951 | - if ( false === $pref ) |
|
949 | +function _get_admin_bar_pref($context = 'front', $user = 0) { |
|
950 | + $pref = get_user_option("show_admin_bar_{$context}", $user); |
|
951 | + if (false === $pref) |
|
952 | 952 | return true; |
953 | 953 | |
954 | 954 | return 'true' === $pref; |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * } |
49 | 49 | * @return string Formatted output in HTML |
50 | 50 | */ |
51 | -function _walk_bookmarks( $bookmarks, $args = '' ) { |
|
51 | +function _walk_bookmarks($bookmarks, $args = '') { |
|
52 | 52 | $defaults = array( |
53 | 53 | 'show_updated' => 0, 'show_description' => 0, |
54 | 54 | 'show_images' => 1, 'show_name' => 0, |
@@ -56,63 +56,63 @@ discard block |
||
56 | 56 | 'show_rating' => 0, 'link_before' => '', 'link_after' => '' |
57 | 57 | ); |
58 | 58 | |
59 | - $r = wp_parse_args( $args, $defaults ); |
|
59 | + $r = wp_parse_args($args, $defaults); |
|
60 | 60 | |
61 | 61 | $output = ''; // Blank string to start with. |
62 | 62 | |
63 | - foreach ( (array) $bookmarks as $bookmark ) { |
|
64 | - if ( ! isset( $bookmark->recently_updated ) ) { |
|
63 | + foreach ((array) $bookmarks as $bookmark) { |
|
64 | + if ( ! isset($bookmark->recently_updated)) { |
|
65 | 65 | $bookmark->recently_updated = false; |
66 | 66 | } |
67 | 67 | $output .= $r['before']; |
68 | - if ( $r['show_updated'] && $bookmark->recently_updated ) { |
|
68 | + if ($r['show_updated'] && $bookmark->recently_updated) { |
|
69 | 69 | $output .= '<em>'; |
70 | 70 | } |
71 | 71 | $the_link = '#'; |
72 | - if ( ! empty( $bookmark->link_url ) ) { |
|
73 | - $the_link = esc_url( $bookmark->link_url ); |
|
72 | + if ( ! empty($bookmark->link_url)) { |
|
73 | + $the_link = esc_url($bookmark->link_url); |
|
74 | 74 | } |
75 | - $desc = esc_attr( sanitize_bookmark_field( 'link_description', $bookmark->link_description, $bookmark->link_id, 'display' ) ); |
|
76 | - $name = esc_attr( sanitize_bookmark_field( 'link_name', $bookmark->link_name, $bookmark->link_id, 'display' ) ); |
|
75 | + $desc = esc_attr(sanitize_bookmark_field('link_description', $bookmark->link_description, $bookmark->link_id, 'display')); |
|
76 | + $name = esc_attr(sanitize_bookmark_field('link_name', $bookmark->link_name, $bookmark->link_id, 'display')); |
|
77 | 77 | $title = $desc; |
78 | 78 | |
79 | - if ( $r['show_updated'] ) { |
|
80 | - if ( '00' != substr( $bookmark->link_updated_f, 0, 2 ) ) { |
|
79 | + if ($r['show_updated']) { |
|
80 | + if ('00' != substr($bookmark->link_updated_f, 0, 2)) { |
|
81 | 81 | $title .= ' ('; |
82 | 82 | $title .= sprintf( |
83 | 83 | __('Last updated: %s'), |
84 | 84 | date( |
85 | - get_option( 'links_updated_date_format' ), |
|
86 | - $bookmark->link_updated_f + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ) |
|
85 | + get_option('links_updated_date_format'), |
|
86 | + $bookmark->link_updated_f + (get_option('gmt_offset') * HOUR_IN_SECONDS) |
|
87 | 87 | ) |
88 | 88 | ); |
89 | 89 | $title .= ')'; |
90 | 90 | } |
91 | 91 | } |
92 | - $alt = ' alt="' . $name . ( $r['show_description'] ? ' ' . $title : '' ) . '"'; |
|
92 | + $alt = ' alt="'.$name.($r['show_description'] ? ' '.$title : '').'"'; |
|
93 | 93 | |
94 | - if ( '' != $title ) { |
|
95 | - $title = ' title="' . $title . '"'; |
|
94 | + if ('' != $title) { |
|
95 | + $title = ' title="'.$title.'"'; |
|
96 | 96 | } |
97 | 97 | $rel = $bookmark->link_rel; |
98 | - if ( '' != $rel ) { |
|
99 | - $rel = ' rel="' . esc_attr($rel) . '"'; |
|
98 | + if ('' != $rel) { |
|
99 | + $rel = ' rel="'.esc_attr($rel).'"'; |
|
100 | 100 | } |
101 | 101 | $target = $bookmark->link_target; |
102 | - if ( '' != $target ) { |
|
103 | - $target = ' target="' . $target . '"'; |
|
102 | + if ('' != $target) { |
|
103 | + $target = ' target="'.$target.'"'; |
|
104 | 104 | } |
105 | - $output .= '<a href="' . $the_link . '"' . $rel . $title . $target . '>'; |
|
105 | + $output .= '<a href="'.$the_link.'"'.$rel.$title.$target.'>'; |
|
106 | 106 | |
107 | 107 | $output .= $r['link_before']; |
108 | 108 | |
109 | - if ( $bookmark->link_image != null && $r['show_images'] ) { |
|
110 | - if ( strpos( $bookmark->link_image, 'http' ) === 0 ) { |
|
109 | + if ($bookmark->link_image != null && $r['show_images']) { |
|
110 | + if (strpos($bookmark->link_image, 'http') === 0) { |
|
111 | 111 | $output .= "<img src=\"$bookmark->link_image\" $alt $title />"; |
112 | 112 | } else { // If it's a relative path |
113 | - $output .= "<img src=\"" . get_option('siteurl') . "$bookmark->link_image\" $alt $title />"; |
|
113 | + $output .= "<img src=\"".get_option('siteurl')."$bookmark->link_image\" $alt $title />"; |
|
114 | 114 | } |
115 | - if ( $r['show_name'] ) { |
|
115 | + if ($r['show_name']) { |
|
116 | 116 | $output .= " $name"; |
117 | 117 | } |
118 | 118 | } else { |
@@ -123,23 +123,23 @@ discard block |
||
123 | 123 | |
124 | 124 | $output .= '</a>'; |
125 | 125 | |
126 | - if ( $r['show_updated'] && $bookmark->recently_updated ) { |
|
126 | + if ($r['show_updated'] && $bookmark->recently_updated) { |
|
127 | 127 | $output .= '</em>'; |
128 | 128 | } |
129 | 129 | |
130 | - if ( $r['show_description'] && '' != $desc ) { |
|
131 | - $output .= $r['between'] . $desc; |
|
130 | + if ($r['show_description'] && '' != $desc) { |
|
131 | + $output .= $r['between'].$desc; |
|
132 | 132 | } |
133 | 133 | |
134 | - if ( $r['show_rating'] ) { |
|
135 | - $output .= $r['between'] . sanitize_bookmark_field( |
|
134 | + if ($r['show_rating']) { |
|
135 | + $output .= $r['between'].sanitize_bookmark_field( |
|
136 | 136 | 'link_rating', |
137 | 137 | $bookmark->link_rating, |
138 | 138 | $bookmark->link_id, |
139 | 139 | 'display' |
140 | 140 | ); |
141 | 141 | } |
142 | - $output .= $r['after'] . "\n"; |
|
142 | + $output .= $r['after']."\n"; |
|
143 | 143 | } // end while |
144 | 144 | |
145 | 145 | return $output; |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * } |
198 | 198 | * @return string|void Will only return if echo option is set to not echo. Default is not return anything. |
199 | 199 | */ |
200 | -function wp_list_bookmarks( $args = '' ) { |
|
200 | +function wp_list_bookmarks($args = '') { |
|
201 | 201 | $defaults = array( |
202 | 202 | 'orderby' => 'name', 'order' => 'ASC', |
203 | 203 | 'limit' => -1, 'category' => '', 'exclude_category' => '', |
@@ -210,41 +210,41 @@ discard block |
||
210 | 210 | 'category_after' => '</li>' |
211 | 211 | ); |
212 | 212 | |
213 | - $r = wp_parse_args( $args, $defaults ); |
|
213 | + $r = wp_parse_args($args, $defaults); |
|
214 | 214 | |
215 | 215 | $output = ''; |
216 | 216 | |
217 | - if ( ! is_array( $r['class'] ) ) { |
|
218 | - $r['class'] = explode( ' ', $r['class'] ); |
|
217 | + if ( ! is_array($r['class'])) { |
|
218 | + $r['class'] = explode(' ', $r['class']); |
|
219 | 219 | } |
220 | - $r['class'] = array_map( 'sanitize_html_class', $r['class'] ); |
|
221 | - $r['class'] = trim( join( ' ', $r['class'] ) ); |
|
220 | + $r['class'] = array_map('sanitize_html_class', $r['class']); |
|
221 | + $r['class'] = trim(join(' ', $r['class'])); |
|
222 | 222 | |
223 | - if ( $r['categorize'] ) { |
|
224 | - $cats = get_terms( 'link_category', array( |
|
223 | + if ($r['categorize']) { |
|
224 | + $cats = get_terms('link_category', array( |
|
225 | 225 | 'name__like' => $r['category_name'], |
226 | 226 | 'include' => $r['category'], |
227 | 227 | 'exclude' => $r['exclude_category'], |
228 | 228 | 'orderby' => $r['category_orderby'], |
229 | 229 | 'order' => $r['category_order'], |
230 | 230 | 'hierarchical' => 0 |
231 | - ) ); |
|
232 | - if ( empty( $cats ) ) { |
|
231 | + )); |
|
232 | + if (empty($cats)) { |
|
233 | 233 | $r['categorize'] = false; |
234 | 234 | } |
235 | 235 | } |
236 | 236 | |
237 | - if ( $r['categorize'] ) { |
|
237 | + if ($r['categorize']) { |
|
238 | 238 | // Split the bookmarks into ul's for each category |
239 | - foreach ( (array) $cats as $cat ) { |
|
240 | - $params = array_merge( $r, array( 'category' => $cat->term_id ) ); |
|
241 | - $bookmarks = get_bookmarks( $params ); |
|
242 | - if ( empty( $bookmarks ) ) { |
|
239 | + foreach ((array) $cats as $cat) { |
|
240 | + $params = array_merge($r, array('category' => $cat->term_id)); |
|
241 | + $bookmarks = get_bookmarks($params); |
|
242 | + if (empty($bookmarks)) { |
|
243 | 243 | continue; |
244 | 244 | } |
245 | 245 | $output .= str_replace( |
246 | - array( '%id', '%class' ), |
|
247 | - array( "linkcat-$cat->term_id", $r['class'] ), |
|
246 | + array('%id', '%class'), |
|
247 | + array("linkcat-$cat->term_id", $r['class']), |
|
248 | 248 | $r['category_before'] |
249 | 249 | ); |
250 | 250 | /** |
@@ -254,36 +254,36 @@ discard block |
||
254 | 254 | * |
255 | 255 | * @param string $cat_name The category name of bookmarks. |
256 | 256 | */ |
257 | - $catname = apply_filters( 'link_category', $cat->name ); |
|
257 | + $catname = apply_filters('link_category', $cat->name); |
|
258 | 258 | |
259 | 259 | $output .= $r['title_before']; |
260 | 260 | $output .= $catname; |
261 | 261 | $output .= $r['title_after']; |
262 | 262 | $output .= "\n\t<ul class='xoxo blogroll'>\n"; |
263 | - $output .= _walk_bookmarks( $bookmarks, $r ); |
|
263 | + $output .= _walk_bookmarks($bookmarks, $r); |
|
264 | 264 | $output .= "\n\t</ul>\n"; |
265 | - $output .= $r['category_after'] . "\n"; |
|
265 | + $output .= $r['category_after']."\n"; |
|
266 | 266 | } |
267 | 267 | } else { |
268 | 268 | //output one single list using title_li for the title |
269 | - $bookmarks = get_bookmarks( $r ); |
|
269 | + $bookmarks = get_bookmarks($r); |
|
270 | 270 | |
271 | - if ( ! empty( $bookmarks ) ) { |
|
272 | - if ( ! empty( $r['title_li'] ) ) { |
|
271 | + if ( ! empty($bookmarks)) { |
|
272 | + if ( ! empty($r['title_li'])) { |
|
273 | 273 | $output .= str_replace( |
274 | - array( '%id', '%class' ), |
|
275 | - array( "linkcat-" . $r['category'], $r['class'] ), |
|
274 | + array('%id', '%class'), |
|
275 | + array("linkcat-".$r['category'], $r['class']), |
|
276 | 276 | $r['category_before'] |
277 | 277 | ); |
278 | 278 | $output .= $r['title_before']; |
279 | 279 | $output .= $r['title_li']; |
280 | 280 | $output .= $r['title_after']; |
281 | 281 | $output .= "\n\t<ul class='xoxo blogroll'>\n"; |
282 | - $output .= _walk_bookmarks( $bookmarks, $r ); |
|
282 | + $output .= _walk_bookmarks($bookmarks, $r); |
|
283 | 283 | $output .= "\n\t</ul>\n"; |
284 | - $output .= $r['category_after'] . "\n"; |
|
284 | + $output .= $r['category_after']."\n"; |
|
285 | 285 | } else { |
286 | - $output .= _walk_bookmarks( $bookmarks, $r ); |
|
286 | + $output .= _walk_bookmarks($bookmarks, $r); |
|
287 | 287 | } |
288 | 288 | } |
289 | 289 | } |
@@ -295,9 +295,9 @@ discard block |
||
295 | 295 | * |
296 | 296 | * @param string $html The HTML list of bookmarks. |
297 | 297 | */ |
298 | - $html = apply_filters( 'wp_list_bookmarks', $output ); |
|
298 | + $html = apply_filters('wp_list_bookmarks', $output); |
|
299 | 299 | |
300 | - if ( ! $r['echo'] ) { |
|
300 | + if ( ! $r['echo']) { |
|
301 | 301 | return $html; |
302 | 302 | } |
303 | 303 | echo $html; |
@@ -1,15 +1,15 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Deprecated pluggable functions from past WordPress versions. You shouldn't use these |
|
4 | - * functions and look for the alternatives instead. The functions will be removed in a |
|
5 | - * later version. |
|
6 | - * |
|
7 | - * Deprecated warnings are also thrown if one of these functions is being defined by a plugin. |
|
8 | - * |
|
9 | - * @package WordPress |
|
10 | - * @subpackage Deprecated |
|
11 | - * @see pluggable.php |
|
12 | - */ |
|
3 | + * Deprecated pluggable functions from past WordPress versions. You shouldn't use these |
|
4 | + * functions and look for the alternatives instead. The functions will be removed in a |
|
5 | + * later version. |
|
6 | + * |
|
7 | + * Deprecated warnings are also thrown if one of these functions is being defined by a plugin. |
|
8 | + * |
|
9 | + * @package WordPress |
|
10 | + * @subpackage Deprecated |
|
11 | + * @see pluggable.php |
|
12 | + */ |
|
13 | 13 | |
14 | 14 | /* |
15 | 15 | * Deprecated functions come here to die. |
@@ -88,9 +88,10 @@ discard block |
||
88 | 88 | _deprecated_function( __FUNCTION__, '2.5', 'wp_set_auth_cookie()' ); |
89 | 89 | $user = get_user_by('login', $username); |
90 | 90 | wp_set_auth_cookie($user->ID, $remember); |
91 | -} |
|
92 | -else : |
|
91 | +} else { |
|
92 | + : |
|
93 | 93 | _deprecated_function( 'wp_setcookie', '2.5', 'wp_set_auth_cookie()' ); |
94 | +} |
|
94 | 95 | endif; |
95 | 96 | |
96 | 97 | if ( !function_exists('wp_clearcookie') ) : |
@@ -104,9 +105,10 @@ discard block |
||
104 | 105 | function wp_clearcookie() { |
105 | 106 | _deprecated_function( __FUNCTION__, '2.5', 'wp_clear_auth_cookie()' ); |
106 | 107 | wp_clear_auth_cookie(); |
107 | -} |
|
108 | -else : |
|
108 | +} else { |
|
109 | + : |
|
109 | 110 | _deprecated_function( 'wp_clearcookie', '2.5', 'wp_clear_auth_cookie()' ); |
111 | +} |
|
110 | 112 | endif; |
111 | 113 | |
112 | 114 | if ( !function_exists('wp_get_cookie_login') ): |
@@ -124,9 +126,10 @@ discard block |
||
124 | 126 | function wp_get_cookie_login() { |
125 | 127 | _deprecated_function( __FUNCTION__, '2.5' ); |
126 | 128 | return false; |
127 | -} |
|
128 | -else : |
|
129 | +} else { |
|
130 | + : |
|
129 | 131 | _deprecated_function( 'wp_get_cookie_login', '2.5' ); |
132 | +} |
|
130 | 133 | endif; |
131 | 134 | |
132 | 135 | if ( !function_exists('wp_login') ) : |
@@ -157,14 +160,16 @@ discard block |
||
157 | 160 | |
158 | 161 | $user = wp_authenticate($username, $password); |
159 | 162 | |
160 | - if ( ! is_wp_error($user) ) |
|
161 | - return true; |
|
163 | + if ( ! is_wp_error($user) ) { |
|
164 | + return true; |
|
165 | + } |
|
162 | 166 | |
163 | 167 | $error = $user->get_error_message(); |
164 | 168 | return false; |
165 | -} |
|
166 | -else : |
|
169 | +} else { |
|
170 | + : |
|
167 | 171 | _deprecated_function( 'wp_login', '2.5', 'wp_signon()' ); |
172 | +} |
|
168 | 173 | endif; |
169 | 174 | |
170 | 175 | /** |
@@ -43,7 +43,7 @@ |
||
43 | 43 | * @deprecated 4.5.0 Use wp_get_current_user() |
44 | 44 | * @see wp_get_current_user() |
45 | 45 | * |
46 | - * @return bool|WP_User False on XMLRPC Request and invalid auth cookie, WP_User instance otherwise. |
|
46 | + * @return WP_User False on XMLRPC Request and invalid auth cookie, WP_User instance otherwise. |
|
47 | 47 | */ |
48 | 48 | function get_currentuserinfo() { |
49 | 49 | _deprecated_function( __FUNCTION__, '4.5', 'wp_get_current_user()' ); |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * Deprecated functions come here to die. |
16 | 16 | */ |
17 | 17 | |
18 | -if ( !function_exists('set_current_user') ) : |
|
18 | +if ( ! function_exists('set_current_user')) : |
|
19 | 19 | /** |
20 | 20 | * Changes the current user by ID or name. |
21 | 21 | * |
@@ -30,12 +30,12 @@ discard block |
||
30 | 30 | * @return WP_User returns wp_set_current_user() |
31 | 31 | */ |
32 | 32 | function set_current_user($id, $name = '') { |
33 | - _deprecated_function( __FUNCTION__, '3.0', 'wp_set_current_user()' ); |
|
33 | + _deprecated_function(__FUNCTION__, '3.0', 'wp_set_current_user()'); |
|
34 | 34 | return wp_set_current_user($id, $name); |
35 | 35 | } |
36 | 36 | endif; |
37 | 37 | |
38 | -if ( !function_exists('get_currentuserinfo') ) : |
|
38 | +if ( ! function_exists('get_currentuserinfo')) : |
|
39 | 39 | /** |
40 | 40 | * Populate global variables with information about the currently logged in user. |
41 | 41 | * |
@@ -46,13 +46,13 @@ discard block |
||
46 | 46 | * @return bool|WP_User False on XMLRPC Request and invalid auth cookie, WP_User instance otherwise. |
47 | 47 | */ |
48 | 48 | function get_currentuserinfo() { |
49 | - _deprecated_function( __FUNCTION__, '4.5', 'wp_get_current_user()' ); |
|
49 | + _deprecated_function(__FUNCTION__, '4.5', 'wp_get_current_user()'); |
|
50 | 50 | |
51 | 51 | return _wp_get_current_user(); |
52 | 52 | } |
53 | 53 | endif; |
54 | 54 | |
55 | -if ( !function_exists('get_userdatabylogin') ) : |
|
55 | +if ( ! function_exists('get_userdatabylogin')) : |
|
56 | 56 | /** |
57 | 57 | * Retrieve user info by login name. |
58 | 58 | * |
@@ -64,12 +64,12 @@ discard block |
||
64 | 64 | * @return bool|object False on failure, User DB row object |
65 | 65 | */ |
66 | 66 | function get_userdatabylogin($user_login) { |
67 | - _deprecated_function( __FUNCTION__, '3.3', "get_user_by('login')" ); |
|
67 | + _deprecated_function(__FUNCTION__, '3.3', "get_user_by('login')"); |
|
68 | 68 | return get_user_by('login', $user_login); |
69 | 69 | } |
70 | 70 | endif; |
71 | 71 | |
72 | -if ( !function_exists('get_user_by_email') ) : |
|
72 | +if ( ! function_exists('get_user_by_email')) : |
|
73 | 73 | /** |
74 | 74 | * Retrieve user info by email. |
75 | 75 | * |
@@ -81,12 +81,12 @@ discard block |
||
81 | 81 | * @return bool|object False on failure, User DB row object |
82 | 82 | */ |
83 | 83 | function get_user_by_email($email) { |
84 | - _deprecated_function( __FUNCTION__, '3.3', "get_user_by('email')" ); |
|
84 | + _deprecated_function(__FUNCTION__, '3.3', "get_user_by('email')"); |
|
85 | 85 | return get_user_by('email', $email); |
86 | 86 | } |
87 | 87 | endif; |
88 | 88 | |
89 | -if ( !function_exists('wp_setcookie') ) : |
|
89 | +if ( ! function_exists('wp_setcookie')) : |
|
90 | 90 | /** |
91 | 91 | * Sets a cookie for a user who just logged in. This function is deprecated. |
92 | 92 | * |
@@ -102,15 +102,15 @@ discard block |
||
102 | 102 | * @param bool $remember Optional. Remember that the user is logged in |
103 | 103 | */ |
104 | 104 | function wp_setcookie($username, $password = '', $already_md5 = false, $home = '', $siteurl = '', $remember = false) { |
105 | - _deprecated_function( __FUNCTION__, '2.5', 'wp_set_auth_cookie()' ); |
|
105 | + _deprecated_function(__FUNCTION__, '2.5', 'wp_set_auth_cookie()'); |
|
106 | 106 | $user = get_user_by('login', $username); |
107 | 107 | wp_set_auth_cookie($user->ID, $remember); |
108 | 108 | } |
109 | 109 | else : |
110 | - _deprecated_function( 'wp_setcookie', '2.5', 'wp_set_auth_cookie()' ); |
|
110 | + _deprecated_function('wp_setcookie', '2.5', 'wp_set_auth_cookie()'); |
|
111 | 111 | endif; |
112 | 112 | |
113 | -if ( !function_exists('wp_clearcookie') ) : |
|
113 | +if ( ! function_exists('wp_clearcookie')) : |
|
114 | 114 | /** |
115 | 115 | * Clears the authentication cookie, logging the user out. This function is deprecated. |
116 | 116 | * |
@@ -119,14 +119,14 @@ discard block |
||
119 | 119 | * @see wp_clear_auth_cookie() |
120 | 120 | */ |
121 | 121 | function wp_clearcookie() { |
122 | - _deprecated_function( __FUNCTION__, '2.5', 'wp_clear_auth_cookie()' ); |
|
122 | + _deprecated_function(__FUNCTION__, '2.5', 'wp_clear_auth_cookie()'); |
|
123 | 123 | wp_clear_auth_cookie(); |
124 | 124 | } |
125 | 125 | else : |
126 | - _deprecated_function( 'wp_clearcookie', '2.5', 'wp_clear_auth_cookie()' ); |
|
126 | + _deprecated_function('wp_clearcookie', '2.5', 'wp_clear_auth_cookie()'); |
|
127 | 127 | endif; |
128 | 128 | |
129 | -if ( !function_exists('wp_get_cookie_login') ): |
|
129 | +if ( ! function_exists('wp_get_cookie_login')): |
|
130 | 130 | /** |
131 | 131 | * Gets the user cookie login. This function is deprecated. |
132 | 132 | * |
@@ -139,14 +139,14 @@ discard block |
||
139 | 139 | * @return bool Always returns false |
140 | 140 | */ |
141 | 141 | function wp_get_cookie_login() { |
142 | - _deprecated_function( __FUNCTION__, '2.5' ); |
|
142 | + _deprecated_function(__FUNCTION__, '2.5'); |
|
143 | 143 | return false; |
144 | 144 | } |
145 | 145 | else : |
146 | - _deprecated_function( 'wp_get_cookie_login', '2.5' ); |
|
146 | + _deprecated_function('wp_get_cookie_login', '2.5'); |
|
147 | 147 | endif; |
148 | 148 | |
149 | -if ( !function_exists('wp_login') ) : |
|
149 | +if ( ! function_exists('wp_login')) : |
|
150 | 150 | /** |
151 | 151 | * Checks a users login information and logs them in if it checks out. This function is deprecated. |
152 | 152 | * |
@@ -169,19 +169,19 @@ discard block |
||
169 | 169 | * @return bool False on login failure, true on successful check |
170 | 170 | */ |
171 | 171 | function wp_login($username, $password, $deprecated = '') { |
172 | - _deprecated_function( __FUNCTION__, '2.5', 'wp_signon()' ); |
|
172 | + _deprecated_function(__FUNCTION__, '2.5', 'wp_signon()'); |
|
173 | 173 | global $error; |
174 | 174 | |
175 | 175 | $user = wp_authenticate($username, $password); |
176 | 176 | |
177 | - if ( ! is_wp_error($user) ) |
|
177 | + if ( ! is_wp_error($user)) |
|
178 | 178 | return true; |
179 | 179 | |
180 | 180 | $error = $user->get_error_message(); |
181 | 181 | return false; |
182 | 182 | } |
183 | 183 | else : |
184 | - _deprecated_function( 'wp_login', '2.5', 'wp_signon()' ); |
|
184 | + _deprecated_function('wp_login', '2.5', 'wp_signon()'); |
|
185 | 185 | endif; |
186 | 186 | |
187 | 187 | /** |
@@ -195,14 +195,14 @@ discard block |
||
195 | 195 | * |
196 | 196 | * @link https://wordpress.org/plugins/atom-publishing-protocol/ |
197 | 197 | */ |
198 | -if ( ! class_exists( 'wp_atom_server', false ) ) { |
|
198 | +if ( ! class_exists('wp_atom_server', false)) { |
|
199 | 199 | class wp_atom_server { |
200 | - public function __call( $name, $arguments ) { |
|
201 | - _deprecated_function( __CLASS__ . '::' . $name, '3.5', 'the Atom Publishing Protocol plugin' ); |
|
200 | + public function __call($name, $arguments) { |
|
201 | + _deprecated_function(__CLASS__.'::'.$name, '3.5', 'the Atom Publishing Protocol plugin'); |
|
202 | 202 | } |
203 | 203 | |
204 | - public static function __callStatic( $name, $arguments ) { |
|
205 | - _deprecated_function( __CLASS__ . '::' . $name, '3.5', 'the Atom Publishing Protocol plugin' ); |
|
204 | + public static function __callStatic($name, $arguments) { |
|
205 | + _deprecated_function(__CLASS__.'::'.$name, '3.5', 'the Atom Publishing Protocol plugin'); |
|
206 | 206 | } |
207 | 207 | } |
208 | 208 | } |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * WordPress Customize Control classes |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Customize |
|
7 | - * @since 3.4.0 |
|
8 | - */ |
|
3 | + * WordPress Customize Control classes |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Customize |
|
7 | + * @since 3.4.0 |
|
8 | + */ |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * Customize Control class. |
@@ -209,7 +209,7 @@ |
||
209 | 209 | * @since 4.1.0 |
210 | 210 | * @access public |
211 | 211 | * |
212 | - * @return true Always true. |
|
212 | + * @return boolean Always true. |
|
213 | 213 | */ |
214 | 214 | public function active_callback() { |
215 | 215 | return true; |
@@ -182,34 +182,34 @@ discard block |
||
182 | 182 | * 'date' are supported implicitly. Default 'text'. |
183 | 183 | * } |
184 | 184 | */ |
185 | - public function __construct( $manager, $id, $args = array() ) { |
|
186 | - $keys = array_keys( get_object_vars( $this ) ); |
|
187 | - foreach ( $keys as $key ) { |
|
188 | - if ( isset( $args[ $key ] ) ) { |
|
189 | - $this->$key = $args[ $key ]; |
|
185 | + public function __construct($manager, $id, $args = array()) { |
|
186 | + $keys = array_keys(get_object_vars($this)); |
|
187 | + foreach ($keys as $key) { |
|
188 | + if (isset($args[$key])) { |
|
189 | + $this->$key = $args[$key]; |
|
190 | 190 | } |
191 | 191 | } |
192 | 192 | |
193 | 193 | $this->manager = $manager; |
194 | 194 | $this->id = $id; |
195 | - if ( empty( $this->active_callback ) ) { |
|
196 | - $this->active_callback = array( $this, 'active_callback' ); |
|
195 | + if (empty($this->active_callback)) { |
|
196 | + $this->active_callback = array($this, 'active_callback'); |
|
197 | 197 | } |
198 | 198 | self::$instance_count += 1; |
199 | 199 | $this->instance_number = self::$instance_count; |
200 | 200 | |
201 | 201 | // Process settings. |
202 | - if ( ! isset( $this->settings ) ) { |
|
202 | + if ( ! isset($this->settings)) { |
|
203 | 203 | $this->settings = $id; |
204 | 204 | } |
205 | 205 | |
206 | 206 | $settings = array(); |
207 | - if ( is_array( $this->settings ) ) { |
|
208 | - foreach ( $this->settings as $key => $setting ) { |
|
209 | - $settings[ $key ] = $this->manager->get_setting( $setting ); |
|
207 | + if (is_array($this->settings)) { |
|
208 | + foreach ($this->settings as $key => $setting) { |
|
209 | + $settings[$key] = $this->manager->get_setting($setting); |
|
210 | 210 | } |
211 | - } else if ( is_string( $this->settings ) ) { |
|
212 | - $this->setting = $this->manager->get_setting( $this->settings ); |
|
211 | + } else if (is_string($this->settings)) { |
|
212 | + $this->setting = $this->manager->get_setting($this->settings); |
|
213 | 213 | $settings['default'] = $this->setting; |
214 | 214 | } |
215 | 215 | $this->settings = $settings; |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | */ |
233 | 233 | final public function active() { |
234 | 234 | $control = $this; |
235 | - $active = call_user_func( $this->active_callback, $this ); |
|
235 | + $active = call_user_func($this->active_callback, $this); |
|
236 | 236 | |
237 | 237 | /** |
238 | 238 | * Filter response of WP_Customize_Control::active(). |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * @param bool $active Whether the Customizer control is active. |
243 | 243 | * @param WP_Customize_Control $control WP_Customize_Control instance. |
244 | 244 | */ |
245 | - $active = apply_filters( 'customize_control_active', $active, $control ); |
|
245 | + $active = apply_filters('customize_control_active', $active, $control); |
|
246 | 246 | |
247 | 247 | return $active; |
248 | 248 | } |
@@ -271,9 +271,9 @@ discard block |
||
271 | 271 | * @param string $setting_key |
272 | 272 | * @return mixed The requested setting's value, if the setting exists. |
273 | 273 | */ |
274 | - final public function value( $setting_key = 'default' ) { |
|
275 | - if ( isset( $this->settings[ $setting_key ] ) ) { |
|
276 | - return $this->settings[ $setting_key ]->value(); |
|
274 | + final public function value($setting_key = 'default') { |
|
275 | + if (isset($this->settings[$setting_key])) { |
|
276 | + return $this->settings[$setting_key]->value(); |
|
277 | 277 | } |
278 | 278 | } |
279 | 279 | |
@@ -284,8 +284,8 @@ discard block |
||
284 | 284 | */ |
285 | 285 | public function to_json() { |
286 | 286 | $this->json['settings'] = array(); |
287 | - foreach ( $this->settings as $key => $setting ) { |
|
288 | - $this->json['settings'][ $key ] = $setting->id; |
|
287 | + foreach ($this->settings as $key => $setting) { |
|
288 | + $this->json['settings'][$key] = $setting->id; |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | $this->json['type'] = $this->type; |
@@ -323,18 +323,18 @@ discard block |
||
323 | 323 | * @return bool False if theme doesn't support the control or user doesn't have the required permissions, otherwise true. |
324 | 324 | */ |
325 | 325 | final public function check_capabilities() { |
326 | - if ( ! empty( $this->capability ) && ! current_user_can( $this->capability ) ) { |
|
326 | + if ( ! empty($this->capability) && ! current_user_can($this->capability)) { |
|
327 | 327 | return false; |
328 | 328 | } |
329 | 329 | |
330 | - foreach ( $this->settings as $setting ) { |
|
331 | - if ( ! $setting || ! $setting->check_capabilities() ) { |
|
330 | + foreach ($this->settings as $setting) { |
|
331 | + if ( ! $setting || ! $setting->check_capabilities()) { |
|
332 | 332 | return false; |
333 | 333 | } |
334 | 334 | } |
335 | 335 | |
336 | - $section = $this->manager->get_section( $this->section ); |
|
337 | - if ( isset( $section ) && ! $section->check_capabilities() ) { |
|
336 | + $section = $this->manager->get_section($this->section); |
|
337 | + if (isset($section) && ! $section->check_capabilities()) { |
|
338 | 338 | return false; |
339 | 339 | } |
340 | 340 | |
@@ -351,7 +351,7 @@ discard block |
||
351 | 351 | final public function get_content() { |
352 | 352 | ob_start(); |
353 | 353 | $this->maybe_render(); |
354 | - return trim( ob_get_clean() ); |
|
354 | + return trim(ob_get_clean()); |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | /** |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | * @uses WP_Customize_Control::render() |
362 | 362 | */ |
363 | 363 | final public function maybe_render() { |
364 | - if ( ! $this->check_capabilities() ) |
|
364 | + if ( ! $this->check_capabilities()) |
|
365 | 365 | return; |
366 | 366 | |
367 | 367 | /** |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | * |
372 | 372 | * @param WP_Customize_Control $this WP_Customize_Control instance. |
373 | 373 | */ |
374 | - do_action( 'customize_render_control', $this ); |
|
374 | + do_action('customize_render_control', $this); |
|
375 | 375 | |
376 | 376 | /** |
377 | 377 | * Fires just before a specific Customizer control is rendered. |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | * |
384 | 384 | * @param WP_Customize_Control $this {@see WP_Customize_Control} instance. |
385 | 385 | */ |
386 | - do_action( 'customize_render_control_' . $this->id, $this ); |
|
386 | + do_action('customize_render_control_'.$this->id, $this); |
|
387 | 387 | |
388 | 388 | $this->render(); |
389 | 389 | } |
@@ -394,10 +394,10 @@ discard block |
||
394 | 394 | * @since 3.4.0 |
395 | 395 | */ |
396 | 396 | protected function render() { |
397 | - $id = 'customize-control-' . str_replace( array( '[', ']' ), array( '-', '' ), $this->id ); |
|
398 | - $class = 'customize-control customize-control-' . $this->type; |
|
397 | + $id = 'customize-control-'.str_replace(array('[', ']'), array('-', ''), $this->id); |
|
398 | + $class = 'customize-control customize-control-'.$this->type; |
|
399 | 399 | |
400 | - ?><li id="<?php echo esc_attr( $id ); ?>" class="<?php echo esc_attr( $class ); ?>"> |
|
400 | + ?><li id="<?php echo esc_attr($id); ?>" class="<?php echo esc_attr($class); ?>"> |
|
401 | 401 | <?php $this->render_content(); ?> |
402 | 402 | </li><?php |
403 | 403 | } |
@@ -410,11 +410,11 @@ discard block |
||
410 | 410 | * @param string $setting_key |
411 | 411 | * @return string Data link parameter, if $setting_key is a valid setting, empty string otherwise. |
412 | 412 | */ |
413 | - public function get_link( $setting_key = 'default' ) { |
|
414 | - if ( ! isset( $this->settings[ $setting_key ] ) ) |
|
413 | + public function get_link($setting_key = 'default') { |
|
414 | + if ( ! isset($this->settings[$setting_key])) |
|
415 | 415 | return ''; |
416 | 416 | |
417 | - return 'data-customize-setting-link="' . esc_attr( $this->settings[ $setting_key ]->id ) . '"'; |
|
417 | + return 'data-customize-setting-link="'.esc_attr($this->settings[$setting_key]->id).'"'; |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | /** |
@@ -425,8 +425,8 @@ discard block |
||
425 | 425 | * |
426 | 426 | * @param string $setting_key |
427 | 427 | */ |
428 | - public function link( $setting_key = 'default' ) { |
|
429 | - echo $this->get_link( $setting_key ); |
|
428 | + public function link($setting_key = 'default') { |
|
429 | + echo $this->get_link($setting_key); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | /** |
@@ -436,8 +436,8 @@ discard block |
||
436 | 436 | * @access public |
437 | 437 | */ |
438 | 438 | public function input_attrs() { |
439 | - foreach ( $this->input_attrs as $attr => $value ) { |
|
440 | - echo $attr . '="' . esc_attr( $value ) . '" '; |
|
439 | + foreach ($this->input_attrs as $attr => $value) { |
|
440 | + echo $attr.'="'.esc_attr($value).'" '; |
|
441 | 441 | } |
442 | 442 | } |
443 | 443 | |
@@ -454,57 +454,57 @@ discard block |
||
454 | 454 | * @since 3.4.0 |
455 | 455 | */ |
456 | 456 | protected function render_content() { |
457 | - switch( $this->type ) { |
|
457 | + switch ($this->type) { |
|
458 | 458 | case 'checkbox': |
459 | 459 | ?> |
460 | 460 | <label> |
461 | - <input type="checkbox" value="<?php echo esc_attr( $this->value() ); ?>" <?php $this->link(); checked( $this->value() ); ?> /> |
|
462 | - <?php echo esc_html( $this->label ); ?> |
|
463 | - <?php if ( ! empty( $this->description ) ) : ?> |
|
461 | + <input type="checkbox" value="<?php echo esc_attr($this->value()); ?>" <?php $this->link(); checked($this->value()); ?> /> |
|
462 | + <?php echo esc_html($this->label); ?> |
|
463 | + <?php if ( ! empty($this->description)) : ?> |
|
464 | 464 | <span class="description customize-control-description"><?php echo $this->description; ?></span> |
465 | 465 | <?php endif; ?> |
466 | 466 | </label> |
467 | 467 | <?php |
468 | 468 | break; |
469 | 469 | case 'radio': |
470 | - if ( empty( $this->choices ) ) |
|
470 | + if (empty($this->choices)) |
|
471 | 471 | return; |
472 | 472 | |
473 | - $name = '_customize-radio-' . $this->id; |
|
473 | + $name = '_customize-radio-'.$this->id; |
|
474 | 474 | |
475 | - if ( ! empty( $this->label ) ) : ?> |
|
476 | - <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span> |
|
475 | + if ( ! empty($this->label)) : ?> |
|
476 | + <span class="customize-control-title"><?php echo esc_html($this->label); ?></span> |
|
477 | 477 | <?php endif; |
478 | - if ( ! empty( $this->description ) ) : ?> |
|
479 | - <span class="description customize-control-description"><?php echo $this->description ; ?></span> |
|
478 | + if ( ! empty($this->description)) : ?> |
|
479 | + <span class="description customize-control-description"><?php echo $this->description; ?></span> |
|
480 | 480 | <?php endif; |
481 | 481 | |
482 | - foreach ( $this->choices as $value => $label ) : |
|
482 | + foreach ($this->choices as $value => $label) : |
|
483 | 483 | ?> |
484 | 484 | <label> |
485 | - <input type="radio" value="<?php echo esc_attr( $value ); ?>" name="<?php echo esc_attr( $name ); ?>" <?php $this->link(); checked( $this->value(), $value ); ?> /> |
|
486 | - <?php echo esc_html( $label ); ?><br/> |
|
485 | + <input type="radio" value="<?php echo esc_attr($value); ?>" name="<?php echo esc_attr($name); ?>" <?php $this->link(); checked($this->value(), $value); ?> /> |
|
486 | + <?php echo esc_html($label); ?><br/> |
|
487 | 487 | </label> |
488 | 488 | <?php |
489 | 489 | endforeach; |
490 | 490 | break; |
491 | 491 | case 'select': |
492 | - if ( empty( $this->choices ) ) |
|
492 | + if (empty($this->choices)) |
|
493 | 493 | return; |
494 | 494 | |
495 | 495 | ?> |
496 | 496 | <label> |
497 | - <?php if ( ! empty( $this->label ) ) : ?> |
|
498 | - <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span> |
|
497 | + <?php if ( ! empty($this->label)) : ?> |
|
498 | + <span class="customize-control-title"><?php echo esc_html($this->label); ?></span> |
|
499 | 499 | <?php endif; |
500 | - if ( ! empty( $this->description ) ) : ?> |
|
500 | + if ( ! empty($this->description)) : ?> |
|
501 | 501 | <span class="description customize-control-description"><?php echo $this->description; ?></span> |
502 | 502 | <?php endif; ?> |
503 | 503 | |
504 | 504 | <select <?php $this->link(); ?>> |
505 | 505 | <?php |
506 | - foreach ( $this->choices as $value => $label ) |
|
507 | - echo '<option value="' . esc_attr( $value ) . '"' . selected( $this->value(), $value, false ) . '>' . $label . '</option>'; |
|
506 | + foreach ($this->choices as $value => $label) |
|
507 | + echo '<option value="'.esc_attr($value).'"'.selected($this->value(), $value, false).'>'.$label.'</option>'; |
|
508 | 508 | ?> |
509 | 509 | </select> |
510 | 510 | </label> |
@@ -513,38 +513,38 @@ discard block |
||
513 | 513 | case 'textarea': |
514 | 514 | ?> |
515 | 515 | <label> |
516 | - <?php if ( ! empty( $this->label ) ) : ?> |
|
517 | - <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span> |
|
516 | + <?php if ( ! empty($this->label)) : ?> |
|
517 | + <span class="customize-control-title"><?php echo esc_html($this->label); ?></span> |
|
518 | 518 | <?php endif; |
519 | - if ( ! empty( $this->description ) ) : ?> |
|
519 | + if ( ! empty($this->description)) : ?> |
|
520 | 520 | <span class="description customize-control-description"><?php echo $this->description; ?></span> |
521 | 521 | <?php endif; ?> |
522 | - <textarea rows="5" <?php $this->link(); ?>><?php echo esc_textarea( $this->value() ); ?></textarea> |
|
522 | + <textarea rows="5" <?php $this->link(); ?>><?php echo esc_textarea($this->value()); ?></textarea> |
|
523 | 523 | </label> |
524 | 524 | <?php |
525 | 525 | break; |
526 | 526 | case 'dropdown-pages': |
527 | 527 | ?> |
528 | 528 | <label> |
529 | - <?php if ( ! empty( $this->label ) ) : ?> |
|
530 | - <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span> |
|
529 | + <?php if ( ! empty($this->label)) : ?> |
|
530 | + <span class="customize-control-title"><?php echo esc_html($this->label); ?></span> |
|
531 | 531 | <?php endif; |
532 | - if ( ! empty( $this->description ) ) : ?> |
|
532 | + if ( ! empty($this->description)) : ?> |
|
533 | 533 | <span class="description customize-control-description"><?php echo $this->description; ?></span> |
534 | 534 | <?php endif; ?> |
535 | 535 | |
536 | 536 | <?php $dropdown = wp_dropdown_pages( |
537 | 537 | array( |
538 | - 'name' => '_customize-dropdown-pages-' . $this->id, |
|
538 | + 'name' => '_customize-dropdown-pages-'.$this->id, |
|
539 | 539 | 'echo' => 0, |
540 | - 'show_option_none' => __( '— Select —' ), |
|
540 | + 'show_option_none' => __('— Select —'), |
|
541 | 541 | 'option_none_value' => '0', |
542 | 542 | 'selected' => $this->value(), |
543 | 543 | ) |
544 | 544 | ); |
545 | 545 | |
546 | 546 | // Hackily add in the data link parameter. |
547 | - $dropdown = str_replace( '<select', '<select ' . $this->get_link(), $dropdown ); |
|
547 | + $dropdown = str_replace('<select', '<select '.$this->get_link(), $dropdown); |
|
548 | 548 | echo $dropdown; |
549 | 549 | ?> |
550 | 550 | </label> |
@@ -553,13 +553,13 @@ discard block |
||
553 | 553 | default: |
554 | 554 | ?> |
555 | 555 | <label> |
556 | - <?php if ( ! empty( $this->label ) ) : ?> |
|
557 | - <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span> |
|
556 | + <?php if ( ! empty($this->label)) : ?> |
|
557 | + <span class="customize-control-title"><?php echo esc_html($this->label); ?></span> |
|
558 | 558 | <?php endif; |
559 | - if ( ! empty( $this->description ) ) : ?> |
|
559 | + if ( ! empty($this->description)) : ?> |
|
560 | 560 | <span class="description customize-control-description"><?php echo $this->description; ?></span> |
561 | 561 | <?php endif; ?> |
562 | - <input type="<?php echo esc_attr( $this->type ); ?>" <?php $this->input_attrs(); ?> value="<?php echo esc_attr( $this->value() ); ?>" <?php $this->link(); ?> /> |
|
562 | + <input type="<?php echo esc_attr($this->type); ?>" <?php $this->input_attrs(); ?> value="<?php echo esc_attr($this->value()); ?>" <?php $this->link(); ?> /> |
|
563 | 563 | </label> |
564 | 564 | <?php |
565 | 565 | break; |
@@ -600,52 +600,52 @@ discard block |
||
600 | 600 | } |
601 | 601 | |
602 | 602 | /** WP_Customize_Color_Control class */ |
603 | -require_once( ABSPATH . WPINC . '/customize/class-wp-customize-color-control.php' ); |
|
603 | +require_once(ABSPATH.WPINC.'/customize/class-wp-customize-color-control.php'); |
|
604 | 604 | |
605 | 605 | /** WP_Customize_Media_Control class */ |
606 | -require_once( ABSPATH . WPINC . '/customize/class-wp-customize-media-control.php' ); |
|
606 | +require_once(ABSPATH.WPINC.'/customize/class-wp-customize-media-control.php'); |
|
607 | 607 | |
608 | 608 | /** WP_Customize_Upload_Control class */ |
609 | -require_once( ABSPATH . WPINC . '/customize/class-wp-customize-upload-control.php' ); |
|
609 | +require_once(ABSPATH.WPINC.'/customize/class-wp-customize-upload-control.php'); |
|
610 | 610 | |
611 | 611 | /** WP_Customize_Image_Control class */ |
612 | -require_once( ABSPATH . WPINC . '/customize/class-wp-customize-image-control.php' ); |
|
612 | +require_once(ABSPATH.WPINC.'/customize/class-wp-customize-image-control.php'); |
|
613 | 613 | |
614 | 614 | /** WP_Customize_Background_Image_Control class */ |
615 | -require_once( ABSPATH . WPINC . '/customize/class-wp-customize-background-image-control.php' ); |
|
615 | +require_once(ABSPATH.WPINC.'/customize/class-wp-customize-background-image-control.php'); |
|
616 | 616 | |
617 | 617 | /** WP_Customize_Cropped_Image_Control class */ |
618 | -require_once( ABSPATH . WPINC . '/customize/class-wp-customize-cropped-image-control.php' ); |
|
618 | +require_once(ABSPATH.WPINC.'/customize/class-wp-customize-cropped-image-control.php'); |
|
619 | 619 | |
620 | 620 | /** WP_Customize_Site_Icon_Control class */ |
621 | -require_once( ABSPATH . WPINC . '/customize/class-wp-customize-site-icon-control.php' ); |
|
621 | +require_once(ABSPATH.WPINC.'/customize/class-wp-customize-site-icon-control.php'); |
|
622 | 622 | |
623 | 623 | /** WP_Customize_Header_Image_Control class */ |
624 | -require_once( ABSPATH . WPINC . '/customize/class-wp-customize-header-image-control.php' ); |
|
624 | +require_once(ABSPATH.WPINC.'/customize/class-wp-customize-header-image-control.php'); |
|
625 | 625 | |
626 | 626 | /** WP_Customize_Theme_Control class */ |
627 | -require_once( ABSPATH . WPINC . '/customize/class-wp-customize-theme-control.php' ); |
|
627 | +require_once(ABSPATH.WPINC.'/customize/class-wp-customize-theme-control.php'); |
|
628 | 628 | |
629 | 629 | /** WP_Widget_Area_Customize_Control class */ |
630 | -require_once( ABSPATH . WPINC . '/customize/class-wp-widget-area-customize-control.php' ); |
|
630 | +require_once(ABSPATH.WPINC.'/customize/class-wp-widget-area-customize-control.php'); |
|
631 | 631 | |
632 | 632 | /** WP_Widget_Form_Customize_Control class */ |
633 | -require_once( ABSPATH . WPINC . '/customize/class-wp-widget-form-customize-control.php' ); |
|
633 | +require_once(ABSPATH.WPINC.'/customize/class-wp-widget-form-customize-control.php'); |
|
634 | 634 | |
635 | 635 | /** WP_Customize_Nav_Menu_Control class */ |
636 | -require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-control.php' ); |
|
636 | +require_once(ABSPATH.WPINC.'/customize/class-wp-customize-nav-menu-control.php'); |
|
637 | 637 | |
638 | 638 | /** WP_Customize_Nav_Menu_Item_Control class */ |
639 | -require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-item-control.php' ); |
|
639 | +require_once(ABSPATH.WPINC.'/customize/class-wp-customize-nav-menu-item-control.php'); |
|
640 | 640 | |
641 | 641 | /** WP_Customize_Nav_Menu_Location_Control class */ |
642 | -require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-location-control.php' ); |
|
642 | +require_once(ABSPATH.WPINC.'/customize/class-wp-customize-nav-menu-location-control.php'); |
|
643 | 643 | |
644 | 644 | /** WP_Customize_Nav_Menu_Name_Control class */ |
645 | -require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-name-control.php' ); |
|
645 | +require_once(ABSPATH.WPINC.'/customize/class-wp-customize-nav-menu-name-control.php'); |
|
646 | 646 | |
647 | 647 | /** WP_Customize_Nav_Menu_Auto_Add_Control class */ |
648 | -require_once( ABSPATH . WPINC . '/customize/class-wp-customize-nav-menu-auto-add-control.php' ); |
|
648 | +require_once(ABSPATH.WPINC.'/customize/class-wp-customize-nav-menu-auto-add-control.php'); |
|
649 | 649 | |
650 | 650 | /** WP_Customize_New_Menu_Control class */ |
651 | -require_once( ABSPATH . WPINC . '/customize/class-wp-customize-new-menu-control.php' ); |
|
651 | +require_once(ABSPATH.WPINC.'/customize/class-wp-customize-new-menu-control.php'); |
@@ -361,8 +361,9 @@ discard block |
||
361 | 361 | * @uses WP_Customize_Control::render() |
362 | 362 | */ |
363 | 363 | final public function maybe_render() { |
364 | - if ( ! $this->check_capabilities() ) |
|
365 | - return; |
|
364 | + if ( ! $this->check_capabilities() ) { |
|
365 | + return; |
|
366 | + } |
|
366 | 367 | |
367 | 368 | /** |
368 | 369 | * Fires just before the current Customizer control is rendered. |
@@ -411,8 +412,9 @@ discard block |
||
411 | 412 | * @return string Data link parameter, if $setting_key is a valid setting, empty string otherwise. |
412 | 413 | */ |
413 | 414 | public function get_link( $setting_key = 'default' ) { |
414 | - if ( ! isset( $this->settings[ $setting_key ] ) ) |
|
415 | - return ''; |
|
415 | + if ( ! isset( $this->settings[ $setting_key ] ) ) { |
|
416 | + return ''; |
|
417 | + } |
|
416 | 418 | |
417 | 419 | return 'data-customize-setting-link="' . esc_attr( $this->settings[ $setting_key ]->id ) . '"'; |
418 | 420 | } |
@@ -467,8 +469,9 @@ discard block |
||
467 | 469 | <?php |
468 | 470 | break; |
469 | 471 | case 'radio': |
470 | - if ( empty( $this->choices ) ) |
|
471 | - return; |
|
472 | + if ( empty( $this->choices ) ) { |
|
473 | + return; |
|
474 | + } |
|
472 | 475 | |
473 | 476 | $name = '_customize-radio-' . $this->id; |
474 | 477 | |
@@ -489,8 +492,9 @@ discard block |
||
489 | 492 | endforeach; |
490 | 493 | break; |
491 | 494 | case 'select': |
492 | - if ( empty( $this->choices ) ) |
|
493 | - return; |
|
495 | + if ( empty( $this->choices ) ) { |
|
496 | + return; |
|
497 | + } |
|
494 | 498 | |
495 | 499 | ?> |
496 | 500 | <label> |
@@ -503,8 +507,9 @@ discard block |
||
503 | 507 | |
504 | 508 | <select <?php $this->link(); ?>> |
505 | 509 | <?php |
506 | - foreach ( $this->choices as $value => $label ) |
|
507 | - echo '<option value="' . esc_attr( $value ) . '"' . selected( $this->value(), $value, false ) . '>' . $label . '</option>'; |
|
510 | + foreach ( $this->choices as $value => $label ) { |
|
511 | + echo '<option value="' . esc_attr( $value ) . '"' . selected( $this->value(), $value, false ) . '>' . $label . '</option>'; |
|
512 | + } |
|
508 | 513 | ?> |
509 | 514 | </select> |
510 | 515 | </label> |