@@ -18,20 +18,23 @@ discard block |
||
18 | 18 | global $action; |
19 | 19 | wp_reset_vars( array('action') ); |
20 | 20 | |
21 | -if ( isset( $_POST['deletecomment'] ) ) |
|
21 | +if ( isset( $_POST['deletecomment'] ) ) { |
|
22 | 22 | $action = 'deletecomment'; |
23 | +} |
|
23 | 24 | |
24 | -if ( 'cdc' == $action ) |
|
25 | +if ( 'cdc' == $action ) { |
|
25 | 26 | $action = 'delete'; |
26 | -elseif ( 'mac' == $action ) |
|
27 | +} elseif ( 'mac' == $action ) { |
|
27 | 28 | $action = 'approve'; |
29 | +} |
|
28 | 30 | |
29 | 31 | if ( isset( $_GET['dt'] ) ) { |
30 | - if ( 'spam' == $_GET['dt'] ) |
|
31 | - $action = 'spam'; |
|
32 | - elseif ( 'trash' == $_GET['dt'] ) |
|
33 | - $action = 'trash'; |
|
34 | -} |
|
32 | + if ( 'spam' == $_GET['dt'] ) { |
|
33 | + $action = 'spam'; |
|
34 | + } elseif ( 'trash' == $_GET['dt'] ) { |
|
35 | + $action = 'trash'; |
|
36 | + } |
|
37 | + } |
|
35 | 38 | |
36 | 39 | switch( $action ) { |
37 | 40 | |
@@ -57,14 +60,17 @@ discard block |
||
57 | 60 | |
58 | 61 | $comment_id = absint( $_GET['c'] ); |
59 | 62 | |
60 | - if ( !$comment = get_comment( $comment_id ) ) |
|
61 | - comment_footer_die( __( 'Invalid comment ID.' ) . sprintf(' <a href="%s">' . __('Go back') . '</a>.', 'javascript:history.go(-1)') ); |
|
63 | + if ( !$comment = get_comment( $comment_id ) ) { |
|
64 | + comment_footer_die( __( 'Invalid comment ID.' ) . sprintf(' <a href="%s">' . __('Go back') . '</a>.', 'javascript:history.go(-1)') ); |
|
65 | + } |
|
62 | 66 | |
63 | - if ( !current_user_can( 'edit_comment', $comment_id ) ) |
|
64 | - comment_footer_die( __('Sorry, you are not allowed to edit this comment.') ); |
|
67 | + if ( !current_user_can( 'edit_comment', $comment_id ) ) { |
|
68 | + comment_footer_die( __('Sorry, you are not allowed to edit this comment.') ); |
|
69 | + } |
|
65 | 70 | |
66 | - if ( 'trash' == $comment->comment_approved ) |
|
67 | - comment_footer_die( __('This comment is in the Trash. Please move it out of the Trash if you want to edit it.') ); |
|
71 | + if ( 'trash' == $comment->comment_approved ) { |
|
72 | + comment_footer_die( __('This comment is in the Trash. Please move it out of the Trash if you want to edit it.') ); |
|
73 | + } |
|
68 | 74 | |
69 | 75 | $comment = get_comment_to_edit( $comment_id ); |
70 | 76 | |
@@ -244,26 +250,30 @@ discard block |
||
244 | 250 | case 'unapprovecomment' : |
245 | 251 | $comment_id = absint( $_REQUEST['c'] ); |
246 | 252 | |
247 | - if ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ) ) ) |
|
248 | - check_admin_referer( 'approve-comment_' . $comment_id ); |
|
249 | - else |
|
250 | - check_admin_referer( 'delete-comment_' . $comment_id ); |
|
253 | + if ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ) ) ) { |
|
254 | + check_admin_referer( 'approve-comment_' . $comment_id ); |
|
255 | + } else { |
|
256 | + check_admin_referer( 'delete-comment_' . $comment_id ); |
|
257 | + } |
|
251 | 258 | |
252 | 259 | $noredir = isset($_REQUEST['noredir']); |
253 | 260 | |
254 | - if ( !$comment = get_comment($comment_id) ) |
|
255 | - comment_footer_die( __( 'Invalid comment ID.' ) . sprintf(' <a href="%s">' . __('Go back') . '</a>.', 'edit-comments.php') ); |
|
256 | - if ( !current_user_can( 'edit_comment', $comment->comment_ID ) ) |
|
257 | - comment_footer_die( __('Sorry, you are not allowed to edit comments on this post.') ); |
|
258 | - |
|
259 | - if ( '' != wp_get_referer() && ! $noredir && false === strpos(wp_get_referer(), 'comment.php') ) |
|
260 | - $redir = wp_get_referer(); |
|
261 | - elseif ( '' != wp_get_original_referer() && ! $noredir ) |
|
262 | - $redir = wp_get_original_referer(); |
|
263 | - elseif ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ) ) ) |
|
264 | - $redir = admin_url('edit-comments.php?p=' . absint( $comment->comment_post_ID ) ); |
|
265 | - else |
|
266 | - $redir = admin_url('edit-comments.php'); |
|
261 | + if ( !$comment = get_comment($comment_id) ) { |
|
262 | + comment_footer_die( __( 'Invalid comment ID.' ) . sprintf(' <a href="%s">' . __('Go back') . '</a>.', 'edit-comments.php') ); |
|
263 | + } |
|
264 | + if ( !current_user_can( 'edit_comment', $comment->comment_ID ) ) { |
|
265 | + comment_footer_die( __('Sorry, you are not allowed to edit comments on this post.') ); |
|
266 | + } |
|
267 | + |
|
268 | + if ( '' != wp_get_referer() && ! $noredir && false === strpos(wp_get_referer(), 'comment.php') ) { |
|
269 | + $redir = wp_get_referer(); |
|
270 | + } elseif ( '' != wp_get_original_referer() && ! $noredir ) { |
|
271 | + $redir = wp_get_original_referer(); |
|
272 | + } elseif ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ) ) ) { |
|
273 | + $redir = admin_url('edit-comments.php?p=' . absint( $comment->comment_post_ID ) ); |
|
274 | + } else { |
|
275 | + $redir = admin_url('edit-comments.php'); |
|
276 | + } |
|
267 | 277 | |
268 | 278 | $redir = remove_query_arg( array('spammed', 'unspammed', 'trashed', 'untrashed', 'deleted', 'ids', 'approved', 'unapproved'), $redir ); |
269 | 279 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | /** Load WordPress Bootstrap */ |
10 | -require_once( dirname( __FILE__ ) . '/admin.php' ); |
|
10 | +require_once(dirname(__FILE__).'/admin.php'); |
|
11 | 11 | |
12 | 12 | $parent_file = 'edit-comments.php'; |
13 | 13 | $submenu_file = 'edit-comments.php'; |
@@ -16,59 +16,59 @@ discard block |
||
16 | 16 | * @global string $action |
17 | 17 | */ |
18 | 18 | global $action; |
19 | -wp_reset_vars( array('action') ); |
|
19 | +wp_reset_vars(array('action')); |
|
20 | 20 | |
21 | -if ( isset( $_POST['deletecomment'] ) ) |
|
21 | +if (isset($_POST['deletecomment'])) |
|
22 | 22 | $action = 'deletecomment'; |
23 | 23 | |
24 | -if ( 'cdc' == $action ) |
|
24 | +if ('cdc' == $action) |
|
25 | 25 | $action = 'delete'; |
26 | -elseif ( 'mac' == $action ) |
|
26 | +elseif ('mac' == $action) |
|
27 | 27 | $action = 'approve'; |
28 | 28 | |
29 | -if ( isset( $_GET['dt'] ) ) { |
|
30 | - if ( 'spam' == $_GET['dt'] ) |
|
29 | +if (isset($_GET['dt'])) { |
|
30 | + if ('spam' == $_GET['dt']) |
|
31 | 31 | $action = 'spam'; |
32 | - elseif ( 'trash' == $_GET['dt'] ) |
|
32 | + elseif ('trash' == $_GET['dt']) |
|
33 | 33 | $action = 'trash'; |
34 | 34 | } |
35 | 35 | |
36 | -switch( $action ) { |
|
36 | +switch ($action) { |
|
37 | 37 | |
38 | 38 | case 'editcomment' : |
39 | 39 | $title = __('Edit Comment'); |
40 | 40 | |
41 | - get_current_screen()->add_help_tab( array( |
|
41 | + get_current_screen()->add_help_tab(array( |
|
42 | 42 | 'id' => 'overview', |
43 | 43 | 'title' => __('Overview'), |
44 | 44 | 'content' => |
45 | - '<p>' . __( 'You can edit the information left in a comment if needed. This is often useful when you notice that a commenter has made a typographical error.' ) . '</p>' . |
|
46 | - '<p>' . __( 'You can also moderate the comment from this screen using the Status box, where you can also change the timestamp of the comment.' ) . '</p>' |
|
47 | - ) ); |
|
45 | + '<p>'.__('You can edit the information left in a comment if needed. This is often useful when you notice that a commenter has made a typographical error.').'</p>'. |
|
46 | + '<p>'.__('You can also moderate the comment from this screen using the Status box, where you can also change the timestamp of the comment.').'</p>' |
|
47 | + )); |
|
48 | 48 | |
49 | 49 | get_current_screen()->set_help_sidebar( |
50 | - '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
|
51 | - '<p>' . __( '<a href="https://codex.wordpress.org/Administration_Screens#Comments">Documentation on Comments</a>' ) . '</p>' . |
|
52 | - '<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>' |
|
50 | + '<p><strong>'.__('For more information:').'</strong></p>'. |
|
51 | + '<p>'.__('<a href="https://codex.wordpress.org/Administration_Screens#Comments">Documentation on Comments</a>').'</p>'. |
|
52 | + '<p>'.__('<a href="https://wordpress.org/support/">Support Forums</a>').'</p>' |
|
53 | 53 | ); |
54 | 54 | |
55 | 55 | wp_enqueue_script('comment'); |
56 | - require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
|
56 | + require_once(ABSPATH.'wp-admin/admin-header.php'); |
|
57 | 57 | |
58 | - $comment_id = absint( $_GET['c'] ); |
|
58 | + $comment_id = absint($_GET['c']); |
|
59 | 59 | |
60 | - if ( !$comment = get_comment( $comment_id ) ) |
|
61 | - comment_footer_die( __( 'Invalid comment ID.' ) . sprintf(' <a href="%s">' . __('Go back') . '</a>.', 'javascript:history.go(-1)') ); |
|
60 | + if ( ! $comment = get_comment($comment_id)) |
|
61 | + comment_footer_die(__('Invalid comment ID.').sprintf(' <a href="%s">'.__('Go back').'</a>.', 'javascript:history.go(-1)')); |
|
62 | 62 | |
63 | - if ( !current_user_can( 'edit_comment', $comment_id ) ) |
|
64 | - comment_footer_die( __('Sorry, you are not allowed to edit this comment.') ); |
|
63 | + if ( ! current_user_can('edit_comment', $comment_id)) |
|
64 | + comment_footer_die(__('Sorry, you are not allowed to edit this comment.')); |
|
65 | 65 | |
66 | - if ( 'trash' == $comment->comment_approved ) |
|
67 | - comment_footer_die( __('This comment is in the Trash. Please move it out of the Trash if you want to edit it.') ); |
|
66 | + if ('trash' == $comment->comment_approved) |
|
67 | + comment_footer_die(__('This comment is in the Trash. Please move it out of the Trash if you want to edit it.')); |
|
68 | 68 | |
69 | - $comment = get_comment_to_edit( $comment_id ); |
|
69 | + $comment = get_comment_to_edit($comment_id); |
|
70 | 70 | |
71 | - include( ABSPATH . 'wp-admin/edit-form-comment.php' ); |
|
71 | + include(ABSPATH.'wp-admin/edit-form-comment.php'); |
|
72 | 72 | |
73 | 73 | break; |
74 | 74 | |
@@ -79,40 +79,40 @@ discard block |
||
79 | 79 | |
80 | 80 | $title = __('Moderate Comment'); |
81 | 81 | |
82 | - $comment_id = absint( $_GET['c'] ); |
|
82 | + $comment_id = absint($_GET['c']); |
|
83 | 83 | |
84 | - if ( ! $comment = get_comment( $comment_id ) ) { |
|
85 | - wp_redirect( admin_url('edit-comments.php?error=1') ); |
|
84 | + if ( ! $comment = get_comment($comment_id)) { |
|
85 | + wp_redirect(admin_url('edit-comments.php?error=1')); |
|
86 | 86 | die(); |
87 | 87 | } |
88 | 88 | |
89 | - if ( !current_user_can( 'edit_comment', $comment->comment_ID ) ) { |
|
90 | - wp_redirect( admin_url('edit-comments.php?error=2') ); |
|
89 | + if ( ! current_user_can('edit_comment', $comment->comment_ID)) { |
|
90 | + wp_redirect(admin_url('edit-comments.php?error=2')); |
|
91 | 91 | die(); |
92 | 92 | } |
93 | 93 | |
94 | 94 | // No need to re-approve/re-trash/re-spam a comment. |
95 | - if ( $action == str_replace( '1', 'approve', $comment->comment_approved ) ) { |
|
96 | - wp_redirect( admin_url( 'edit-comments.php?same=' . $comment_id ) ); |
|
95 | + if ($action == str_replace('1', 'approve', $comment->comment_approved)) { |
|
96 | + wp_redirect(admin_url('edit-comments.php?same='.$comment_id)); |
|
97 | 97 | die(); |
98 | 98 | } |
99 | 99 | |
100 | - require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
|
100 | + require_once(ABSPATH.'wp-admin/admin-header.php'); |
|
101 | 101 | |
102 | - $formaction = $action . 'comment'; |
|
102 | + $formaction = $action.'comment'; |
|
103 | 103 | $nonce_action = 'approve' == $action ? 'approve-comment_' : 'delete-comment_'; |
104 | 104 | $nonce_action .= $comment_id; |
105 | 105 | |
106 | 106 | ?> |
107 | 107 | <div class="wrap"> |
108 | 108 | |
109 | -<h1><?php echo esc_html( $title ); ?></h1> |
|
109 | +<h1><?php echo esc_html($title); ?></h1> |
|
110 | 110 | |
111 | 111 | <?php |
112 | -switch ( $action ) { |
|
112 | +switch ($action) { |
|
113 | 113 | case 'spam' : |
114 | 114 | $caution_msg = __('You are about to mark the following comment as spam:'); |
115 | - $button = _x( 'Mark as Spam', 'comment' ); |
|
115 | + $button = _x('Mark as Spam', 'comment'); |
|
116 | 116 | break; |
117 | 117 | case 'trash' : |
118 | 118 | $caution_msg = __('You are about to move the following comment to the Trash:'); |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | break; |
129 | 129 | } |
130 | 130 | |
131 | -if ( $comment->comment_approved != '0' ) { // if not unapproved |
|
131 | +if ($comment->comment_approved != '0') { // if not unapproved |
|
132 | 132 | $message = ''; |
133 | - switch ( $comment->comment_approved ) { |
|
133 | + switch ($comment->comment_approved) { |
|
134 | 134 | case '1' : |
135 | 135 | $message = __('This comment is currently approved.'); |
136 | 136 | break; |
@@ -141,68 +141,68 @@ discard block |
||
141 | 141 | $message = __('This comment is currently in the Trash.'); |
142 | 142 | break; |
143 | 143 | } |
144 | - if ( $message ) { |
|
145 | - echo '<div id="message" class="notice notice-info"><p>' . $message . '</p></div>'; |
|
144 | + if ($message) { |
|
145 | + echo '<div id="message" class="notice notice-info"><p>'.$message.'</p></div>'; |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | ?> |
149 | -<div id="message" class="notice notice-warning"><p><strong><?php _e( 'Caution:' ); ?></strong> <?php echo $caution_msg; ?></p></div> |
|
149 | +<div id="message" class="notice notice-warning"><p><strong><?php _e('Caution:'); ?></strong> <?php echo $caution_msg; ?></p></div> |
|
150 | 150 | |
151 | 151 | <table class="form-table comment-ays"> |
152 | 152 | <tr> |
153 | 153 | <th scope="row"><?php _e('Author'); ?></th> |
154 | -<td><?php comment_author( $comment ); ?></td> |
|
154 | +<td><?php comment_author($comment); ?></td> |
|
155 | 155 | </tr> |
156 | -<?php if ( get_comment_author_email( $comment ) ) { ?> |
|
156 | +<?php if (get_comment_author_email($comment)) { ?> |
|
157 | 157 | <tr> |
158 | 158 | <th scope="row"><?php _e('Email'); ?></th> |
159 | -<td><?php comment_author_email( $comment ); ?></td> |
|
159 | +<td><?php comment_author_email($comment); ?></td> |
|
160 | 160 | </tr> |
161 | 161 | <?php } ?> |
162 | -<?php if ( get_comment_author_url( $comment ) ) { ?> |
|
162 | +<?php if (get_comment_author_url($comment)) { ?> |
|
163 | 163 | <tr> |
164 | 164 | <th scope="row"><?php _e('URL'); ?></th> |
165 | -<td><a href="<?php comment_author_url( $comment ); ?>"><?php comment_author_url( $comment ); ?></a></td> |
|
165 | +<td><a href="<?php comment_author_url($comment); ?>"><?php comment_author_url($comment); ?></a></td> |
|
166 | 166 | </tr> |
167 | 167 | <?php } ?> |
168 | 168 | <tr> |
169 | - <th scope="row"><?php /* translators: column name or table row header */ _e( 'In Response To' ); ?></th> |
|
169 | + <th scope="row"><?php /* translators: column name or table row header */ _e('In Response To'); ?></th> |
|
170 | 170 | <td> |
171 | 171 | <?php |
172 | 172 | $post_id = $comment->comment_post_ID; |
173 | - if ( current_user_can( 'edit_post', $post_id ) ) { |
|
174 | - $post_link = "<a href='" . esc_url( get_edit_post_link( $post_id ) ) . "'>"; |
|
175 | - $post_link .= esc_html( get_the_title( $post_id ) ) . '</a>'; |
|
173 | + if (current_user_can('edit_post', $post_id)) { |
|
174 | + $post_link = "<a href='".esc_url(get_edit_post_link($post_id))."'>"; |
|
175 | + $post_link .= esc_html(get_the_title($post_id)).'</a>'; |
|
176 | 176 | } else { |
177 | - $post_link = esc_html( get_the_title( $post_id ) ); |
|
177 | + $post_link = esc_html(get_the_title($post_id)); |
|
178 | 178 | } |
179 | 179 | echo $post_link; |
180 | 180 | |
181 | - if ( $comment->comment_parent ) { |
|
182 | - $parent = get_comment( $comment->comment_parent ); |
|
183 | - $parent_link = esc_url( get_comment_link( $parent ) ); |
|
184 | - $name = get_comment_author( $parent ); |
|
181 | + if ($comment->comment_parent) { |
|
182 | + $parent = get_comment($comment->comment_parent); |
|
183 | + $parent_link = esc_url(get_comment_link($parent)); |
|
184 | + $name = get_comment_author($parent); |
|
185 | 185 | printf( |
186 | 186 | /* translators: %s: comment link */ |
187 | - ' | ' . __( 'In reply to %s.' ), |
|
188 | - '<a href="' . $parent_link . '">' . $name . '</a>' |
|
187 | + ' | '.__('In reply to %s.'), |
|
188 | + '<a href="'.$parent_link.'">'.$name.'</a>' |
|
189 | 189 | ); |
190 | 190 | } |
191 | 191 | ?> |
192 | 192 | </td> |
193 | 193 | </tr> |
194 | 194 | <tr> |
195 | - <th scope="row"><?php _e( 'Submitted on' ); ?></th> |
|
195 | + <th scope="row"><?php _e('Submitted on'); ?></th> |
|
196 | 196 | <td> |
197 | 197 | <?php |
198 | 198 | /* translators: 1: comment date, 2: comment time */ |
199 | - $submitted = sprintf( __( '%1$s at %2$s' ), |
|
199 | + $submitted = sprintf(__('%1$s at %2$s'), |
|
200 | 200 | /* translators: comment date format. See https://secure.php.net/date */ |
201 | - get_comment_date( __( 'Y/m/d' ), $comment ), |
|
202 | - get_comment_date( __( 'g:i a' ), $comment ) |
|
201 | + get_comment_date(__('Y/m/d'), $comment), |
|
202 | + get_comment_date(__('g:i a'), $comment) |
|
203 | 203 | ); |
204 | - if ( 'approved' === wp_get_comment_status( $comment ) && ! empty ( $comment->comment_post_ID ) ) { |
|
205 | - echo '<a href="' . esc_url( get_comment_link( $comment ) ) . '">' . $submitted . '</a>'; |
|
204 | + if ('approved' === wp_get_comment_status($comment) && ! empty ($comment->comment_post_ID)) { |
|
205 | + echo '<a href="'.esc_url(get_comment_link($comment)).'">'.$submitted.'</a>'; |
|
206 | 206 | } else { |
207 | 207 | echo $submitted; |
208 | 208 | } |
@@ -212,8 +212,8 @@ discard block |
||
212 | 212 | <tr> |
213 | 213 | <th scope="row"><?php /* translators: field name in comment form */ _ex('Comment', 'noun'); ?></th> |
214 | 214 | <td class="comment-content"> |
215 | - <?php comment_text( $comment ); ?> |
|
216 | - <p class="edit-comment"><a href="<?php echo admin_url( "comment.php?action=editcomment&c={$comment->comment_ID}" ); ?>"><?php esc_html_e( 'Edit' ); ?></a></p> |
|
215 | + <?php comment_text($comment); ?> |
|
216 | + <p class="edit-comment"><a href="<?php echo admin_url("comment.php?action=editcomment&c={$comment->comment_ID}"); ?>"><?php esc_html_e('Edit'); ?></a></p> |
|
217 | 217 | </td> |
218 | 218 | </tr> |
219 | 219 | </table> |
@@ -221,11 +221,11 @@ discard block |
||
221 | 221 | <form action="comment.php" method="get" class="comment-ays-submit"> |
222 | 222 | |
223 | 223 | <p> |
224 | - <?php submit_button( $button, 'primary', 'submit', false ); ?> |
|
225 | - <a href="<?php echo admin_url('edit-comments.php'); ?>" class="button-cancel"><?php esc_html_e( 'Cancel' ); ?></a> |
|
224 | + <?php submit_button($button, 'primary', 'submit', false); ?> |
|
225 | + <a href="<?php echo admin_url('edit-comments.php'); ?>" class="button-cancel"><?php esc_html_e('Cancel'); ?></a> |
|
226 | 226 | </p> |
227 | 227 | |
228 | -<?php wp_nonce_field( $nonce_action ); ?> |
|
228 | +<?php wp_nonce_field($nonce_action); ?> |
|
229 | 229 | <input type="hidden" name="action" value="<?php echo esc_attr($formaction); ?>" /> |
230 | 230 | <input type="hidden" name="c" value="<?php echo esc_attr($comment->comment_ID); ?>" /> |
231 | 231 | <input type="hidden" name="noredir" value="1" /> |
@@ -242,75 +242,75 @@ discard block |
||
242 | 242 | case 'unspamcomment' : |
243 | 243 | case 'approvecomment' : |
244 | 244 | case 'unapprovecomment' : |
245 | - $comment_id = absint( $_REQUEST['c'] ); |
|
245 | + $comment_id = absint($_REQUEST['c']); |
|
246 | 246 | |
247 | - if ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ) ) ) |
|
248 | - check_admin_referer( 'approve-comment_' . $comment_id ); |
|
247 | + if (in_array($action, array('approvecomment', 'unapprovecomment'))) |
|
248 | + check_admin_referer('approve-comment_'.$comment_id); |
|
249 | 249 | else |
250 | - check_admin_referer( 'delete-comment_' . $comment_id ); |
|
250 | + check_admin_referer('delete-comment_'.$comment_id); |
|
251 | 251 | |
252 | 252 | $noredir = isset($_REQUEST['noredir']); |
253 | 253 | |
254 | - if ( !$comment = get_comment($comment_id) ) |
|
255 | - comment_footer_die( __( 'Invalid comment ID.' ) . sprintf(' <a href="%s">' . __('Go back') . '</a>.', 'edit-comments.php') ); |
|
256 | - if ( !current_user_can( 'edit_comment', $comment->comment_ID ) ) |
|
257 | - comment_footer_die( __('Sorry, you are not allowed to edit comments on this post.') ); |
|
254 | + if ( ! $comment = get_comment($comment_id)) |
|
255 | + comment_footer_die(__('Invalid comment ID.').sprintf(' <a href="%s">'.__('Go back').'</a>.', 'edit-comments.php')); |
|
256 | + if ( ! current_user_can('edit_comment', $comment->comment_ID)) |
|
257 | + comment_footer_die(__('Sorry, you are not allowed to edit comments on this post.')); |
|
258 | 258 | |
259 | - if ( '' != wp_get_referer() && ! $noredir && false === strpos(wp_get_referer(), 'comment.php') ) |
|
259 | + if ('' != wp_get_referer() && ! $noredir && false === strpos(wp_get_referer(), 'comment.php')) |
|
260 | 260 | $redir = wp_get_referer(); |
261 | - elseif ( '' != wp_get_original_referer() && ! $noredir ) |
|
261 | + elseif ('' != wp_get_original_referer() && ! $noredir) |
|
262 | 262 | $redir = wp_get_original_referer(); |
263 | - elseif ( in_array( $action, array( 'approvecomment', 'unapprovecomment' ) ) ) |
|
264 | - $redir = admin_url('edit-comments.php?p=' . absint( $comment->comment_post_ID ) ); |
|
263 | + elseif (in_array($action, array('approvecomment', 'unapprovecomment'))) |
|
264 | + $redir = admin_url('edit-comments.php?p='.absint($comment->comment_post_ID)); |
|
265 | 265 | else |
266 | 266 | $redir = admin_url('edit-comments.php'); |
267 | 267 | |
268 | - $redir = remove_query_arg( array('spammed', 'unspammed', 'trashed', 'untrashed', 'deleted', 'ids', 'approved', 'unapproved'), $redir ); |
|
268 | + $redir = remove_query_arg(array('spammed', 'unspammed', 'trashed', 'untrashed', 'deleted', 'ids', 'approved', 'unapproved'), $redir); |
|
269 | 269 | |
270 | - switch ( $action ) { |
|
270 | + switch ($action) { |
|
271 | 271 | case 'deletecomment' : |
272 | - wp_delete_comment( $comment ); |
|
273 | - $redir = add_query_arg( array('deleted' => '1'), $redir ); |
|
272 | + wp_delete_comment($comment); |
|
273 | + $redir = add_query_arg(array('deleted' => '1'), $redir); |
|
274 | 274 | break; |
275 | 275 | case 'trashcomment' : |
276 | - wp_trash_comment( $comment ); |
|
277 | - $redir = add_query_arg( array('trashed' => '1', 'ids' => $comment_id), $redir ); |
|
276 | + wp_trash_comment($comment); |
|
277 | + $redir = add_query_arg(array('trashed' => '1', 'ids' => $comment_id), $redir); |
|
278 | 278 | break; |
279 | 279 | case 'untrashcomment' : |
280 | - wp_untrash_comment( $comment ); |
|
281 | - $redir = add_query_arg( array('untrashed' => '1'), $redir ); |
|
280 | + wp_untrash_comment($comment); |
|
281 | + $redir = add_query_arg(array('untrashed' => '1'), $redir); |
|
282 | 282 | break; |
283 | 283 | case 'spamcomment' : |
284 | - wp_spam_comment( $comment ); |
|
285 | - $redir = add_query_arg( array('spammed' => '1', 'ids' => $comment_id), $redir ); |
|
284 | + wp_spam_comment($comment); |
|
285 | + $redir = add_query_arg(array('spammed' => '1', 'ids' => $comment_id), $redir); |
|
286 | 286 | break; |
287 | 287 | case 'unspamcomment' : |
288 | - wp_unspam_comment( $comment ); |
|
289 | - $redir = add_query_arg( array('unspammed' => '1'), $redir ); |
|
288 | + wp_unspam_comment($comment); |
|
289 | + $redir = add_query_arg(array('unspammed' => '1'), $redir); |
|
290 | 290 | break; |
291 | 291 | case 'approvecomment' : |
292 | - wp_set_comment_status( $comment, 'approve' ); |
|
293 | - $redir = add_query_arg( array( 'approved' => 1 ), $redir ); |
|
292 | + wp_set_comment_status($comment, 'approve'); |
|
293 | + $redir = add_query_arg(array('approved' => 1), $redir); |
|
294 | 294 | break; |
295 | 295 | case 'unapprovecomment' : |
296 | - wp_set_comment_status( $comment, 'hold' ); |
|
297 | - $redir = add_query_arg( array( 'unapproved' => 1 ), $redir ); |
|
296 | + wp_set_comment_status($comment, 'hold'); |
|
297 | + $redir = add_query_arg(array('unapproved' => 1), $redir); |
|
298 | 298 | break; |
299 | 299 | } |
300 | 300 | |
301 | - wp_redirect( $redir ); |
|
301 | + wp_redirect($redir); |
|
302 | 302 | die; |
303 | 303 | |
304 | 304 | case 'editedcomment' : |
305 | 305 | |
306 | - $comment_id = absint( $_POST['comment_ID'] ); |
|
307 | - $comment_post_id = absint( $_POST['comment_post_ID'] ); |
|
306 | + $comment_id = absint($_POST['comment_ID']); |
|
307 | + $comment_post_id = absint($_POST['comment_post_ID']); |
|
308 | 308 | |
309 | - check_admin_referer( 'update-comment_' . $comment_id ); |
|
309 | + check_admin_referer('update-comment_'.$comment_id); |
|
310 | 310 | |
311 | 311 | edit_comment(); |
312 | 312 | |
313 | - $location = ( empty( $_POST['referredby'] ) ? "edit-comments.php?p=$comment_post_id" : $_POST['referredby'] ) . '#comment-' . $comment_id; |
|
313 | + $location = (empty($_POST['referredby']) ? "edit-comments.php?p=$comment_post_id" : $_POST['referredby']).'#comment-'.$comment_id; |
|
314 | 314 | |
315 | 315 | /** |
316 | 316 | * Filters the URI the user is redirected to after editing a comment in the admin. |
@@ -320,14 +320,14 @@ discard block |
||
320 | 320 | * @param string $location The URI the user will be redirected to. |
321 | 321 | * @param int $comment_id The ID of the comment being edited. |
322 | 322 | */ |
323 | - $location = apply_filters( 'comment_edit_redirect', $location, $comment_id ); |
|
324 | - wp_redirect( $location ); |
|
323 | + $location = apply_filters('comment_edit_redirect', $location, $comment_id); |
|
324 | + wp_redirect($location); |
|
325 | 325 | |
326 | 326 | exit(); |
327 | 327 | |
328 | 328 | default: |
329 | - wp_die( __('Unknown action.') ); |
|
329 | + wp_die(__('Unknown action.')); |
|
330 | 330 | |
331 | 331 | } // end switch |
332 | 332 | |
333 | -include( ABSPATH . 'wp-admin/admin-footer.php' ); |
|
333 | +include(ABSPATH.'wp-admin/admin-footer.php'); |
@@ -9,8 +9,9 @@ discard block |
||
9 | 9 | /** WordPress Administration Bootstrap */ |
10 | 10 | require_once( dirname( __FILE__ ) . '/admin.php' ); |
11 | 11 | |
12 | -if ( ! current_user_can( 'manage_options' ) ) |
|
12 | +if ( ! current_user_can( 'manage_options' ) ) { |
|
13 | 13 | wp_die( __( 'Sorry, you are not allowed to manage options for this site.' ) ); |
14 | +} |
|
14 | 15 | |
15 | 16 | $title = __('Permalink Settings'); |
16 | 17 | $parent_file = 'options-general.php'; |
@@ -53,8 +54,9 @@ discard block |
||
53 | 54 | $permalink_structure = get_option( 'permalink_structure' ); |
54 | 55 | |
55 | 56 | $prefix = $blog_prefix = ''; |
56 | -if ( ! got_url_rewrite() ) |
|
57 | +if ( ! got_url_rewrite() ) { |
|
57 | 58 | $prefix = '/index.php'; |
59 | +} |
|
58 | 60 | |
59 | 61 | /** |
60 | 62 | * In a subdirectory configuration of multisite, the `/blog` prefix is used by |
@@ -71,11 +73,12 @@ discard block |
||
71 | 73 | $update_required = false; |
72 | 74 | |
73 | 75 | if ( $iis7_permalinks ) { |
74 | - if ( ( ! file_exists($home_path . 'web.config') && win_is_writable($home_path) ) || win_is_writable($home_path . 'web.config') ) |
|
75 | - $writable = true; |
|
76 | - else |
|
77 | - $writable = false; |
|
78 | -} elseif ( $is_nginx ) { |
|
76 | + if ( ( ! file_exists($home_path . 'web.config') && win_is_writable($home_path) ) || win_is_writable($home_path . 'web.config') ) { |
|
77 | + $writable = true; |
|
78 | + } else { |
|
79 | + $writable = false; |
|
80 | + } |
|
81 | + } elseif ( $is_nginx ) { |
|
79 | 82 | $writable = false; |
80 | 83 | } else { |
81 | 84 | if ( ( ! file_exists( $home_path . '.htaccess' ) && is_writable( $home_path ) ) || is_writable( $home_path . '.htaccess' ) ) { |
@@ -94,17 +97,19 @@ discard block |
||
94 | 97 | check_admin_referer('update-permalink'); |
95 | 98 | |
96 | 99 | if ( isset( $_POST['permalink_structure'] ) ) { |
97 | - if ( isset( $_POST['selection'] ) && 'custom' != $_POST['selection'] ) |
|
98 | - $permalink_structure = $_POST['selection']; |
|
99 | - else |
|
100 | - $permalink_structure = $_POST['permalink_structure']; |
|
100 | + if ( isset( $_POST['selection'] ) && 'custom' != $_POST['selection'] ) { |
|
101 | + $permalink_structure = $_POST['selection']; |
|
102 | + } else { |
|
103 | + $permalink_structure = $_POST['permalink_structure']; |
|
104 | + } |
|
101 | 105 | |
102 | 106 | if ( ! empty( $permalink_structure ) ) { |
103 | 107 | $permalink_structure = preg_replace( '#/+#', '/', '/' . str_replace( '#', '', $permalink_structure ) ); |
104 | - if ( $prefix && $blog_prefix ) |
|
105 | - $permalink_structure = $prefix . preg_replace( '#^/?index\.php#', '', $permalink_structure ); |
|
106 | - else |
|
107 | - $permalink_structure = $blog_prefix . $permalink_structure; |
|
108 | + if ( $prefix && $blog_prefix ) { |
|
109 | + $permalink_structure = $prefix . preg_replace( '#^/?index\.php#', '', $permalink_structure ); |
|
110 | + } else { |
|
111 | + $permalink_structure = $blog_prefix . $permalink_structure; |
|
112 | + } |
|
108 | 113 | } |
109 | 114 | |
110 | 115 | $permalink_structure = sanitize_option( 'permalink_structure', $permalink_structure ); |
@@ -114,15 +119,17 @@ discard block |
||
114 | 119 | |
115 | 120 | if ( isset( $_POST['category_base'] ) ) { |
116 | 121 | $category_base = $_POST['category_base']; |
117 | - if ( ! empty( $category_base ) ) |
|
118 | - $category_base = $blog_prefix . preg_replace('#/+#', '/', '/' . str_replace( '#', '', $category_base ) ); |
|
122 | + if ( ! empty( $category_base ) ) { |
|
123 | + $category_base = $blog_prefix . preg_replace('#/+#', '/', '/' . str_replace( '#', '', $category_base ) ); |
|
124 | + } |
|
119 | 125 | $wp_rewrite->set_category_base( $category_base ); |
120 | 126 | } |
121 | 127 | |
122 | 128 | if ( isset( $_POST['tag_base'] ) ) { |
123 | 129 | $tag_base = $_POST['tag_base']; |
124 | - if ( ! empty( $tag_base ) ) |
|
125 | - $tag_base = $blog_prefix . preg_replace('#/+#', '/', '/' . str_replace( '#', '', $tag_base ) ); |
|
130 | + if ( ! empty( $tag_base ) ) { |
|
131 | + $tag_base = $blog_prefix . preg_replace('#/+#', '/', '/' . str_replace( '#', '', $tag_base ) ); |
|
132 | + } |
|
126 | 133 | $wp_rewrite->set_tag_base( $tag_base ); |
127 | 134 | } |
128 | 135 | |
@@ -241,23 +248,29 @@ discard block |
||
241 | 248 | <p><textarea rows="9" class="large-text readonly" name="rules" id="rules" readonly="readonly"><?php echo esc_textarea( $wp_rewrite->iis7_url_rewrite_rules() ); ?></textarea></p> |
242 | 249 | </form> |
243 | 250 | <p><?php _e('If you temporarily make your <code>web.config</code> file writable for us to generate rewrite rules automatically, do not forget to revert the permissions after rule has been saved.') ?></p> |
244 | - <?php else : ?> |
|
251 | + <?php else { |
|
252 | + : ?> |
|
245 | 253 | <p><?php _e('If the root directory of your site were <a href="https://codex.wordpress.org/Changing_File_Permissions">writable</a>, we could do this automatically, but it isn’t so this is the url rewrite rule you should have in your <code>web.config</code> file. Create a new file, called <code>web.config</code> in the root directory of your site. Click in the field and press <kbd>CTRL + a</kbd> to select all. Then insert this code into the <code>web.config</code> file.') ?></p> |
246 | 254 | <form action="options-permalink.php" method="post"> |
247 | 255 | <?php wp_nonce_field('update-permalink') ?> |
248 | - <p><textarea rows="18" class="large-text readonly" name="rules" id="rules" readonly="readonly"><?php echo esc_textarea( $wp_rewrite->iis7_url_rewrite_rules(true) ); ?></textarea></p> |
|
256 | + <p><textarea rows="18" class="large-text readonly" name="rules" id="rules" readonly="readonly"><?php echo esc_textarea( $wp_rewrite->iis7_url_rewrite_rules(true) ); |
|
257 | +} |
|
258 | +?></textarea></p> |
|
249 | 259 | </form> |
250 | 260 | <p><?php _e('If you temporarily make your site’s root directory writable for us to generate the <code>web.config</code> file automatically, do not forget to revert the permissions after the file has been created.') ?></p> |
251 | 261 | <?php endif; ?> |
252 | 262 | <?php endif; ?> |
253 | 263 | <?php elseif ( $is_nginx ) : ?> |
254 | 264 | <p><?php _e( '<a href="https://codex.wordpress.org/Nginx">Documentation on Nginx configuration</a>.' ); ?></p> |
255 | -<?php else: |
|
265 | +<?php else { |
|
266 | + : |
|
256 | 267 | if ( $permalink_structure && ! $using_index_permalinks && ! $writable && $update_required ) : ?> |
257 | 268 | <p><?php _e('If your <code>.htaccess</code> file were <a href="https://codex.wordpress.org/Changing_File_Permissions">writable</a>, we could do this automatically, but it isn’t so these are the mod_rewrite rules you should have in your <code>.htaccess</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all.') ?></p> |
258 | 269 | <form action="options-permalink.php" method="post"> |
259 | 270 | <?php wp_nonce_field('update-permalink') ?> |
260 | - <p><textarea rows="6" class="large-text readonly" name="rules" id="rules" readonly="readonly"><?php echo esc_textarea( $wp_rewrite->mod_rewrite_rules() ); ?></textarea></p> |
|
271 | + <p><textarea rows="6" class="large-text readonly" name="rules" id="rules" readonly="readonly"><?php echo esc_textarea( $wp_rewrite->mod_rewrite_rules() ); |
|
272 | +} |
|
273 | +?></textarea></p> |
|
261 | 274 | </form> |
262 | 275 | <?php endif; ?> |
263 | 276 | <?php endif; ?> |
@@ -7,53 +7,53 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | /** WordPress Administration Bootstrap */ |
10 | -require_once( dirname( __FILE__ ) . '/admin.php' ); |
|
10 | +require_once(dirname(__FILE__).'/admin.php'); |
|
11 | 11 | |
12 | -if ( ! current_user_can( 'manage_options' ) ) |
|
13 | - wp_die( __( 'Sorry, you are not allowed to manage options for this site.' ) ); |
|
12 | +if ( ! current_user_can('manage_options')) |
|
13 | + wp_die(__('Sorry, you are not allowed to manage options for this site.')); |
|
14 | 14 | |
15 | 15 | $title = __('Permalink Settings'); |
16 | 16 | $parent_file = 'options-general.php'; |
17 | 17 | |
18 | -get_current_screen()->add_help_tab( array( |
|
18 | +get_current_screen()->add_help_tab(array( |
|
19 | 19 | 'id' => 'overview', |
20 | 20 | 'title' => __('Overview'), |
21 | - 'content' => '<p>' . __('Permalinks are the permanent URLs to your individual pages and blog posts, as well as your category and tag archives. A permalink is the web address used to link to your content. The URL to each post should be permanent, and never change — hence the name permalink.') . '</p>' . |
|
22 | - '<p>' . __( 'This screen allows you to choose your permalink structure. You can choose from common settings or create custom URL structures.' ) . '</p>' . |
|
23 | - '<p>' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '</p>', |
|
24 | -) ); |
|
21 | + 'content' => '<p>'.__('Permalinks are the permanent URLs to your individual pages and blog posts, as well as your category and tag archives. A permalink is the web address used to link to your content. The URL to each post should be permanent, and never change — hence the name permalink.').'</p>'. |
|
22 | + '<p>'.__('This screen allows you to choose your permalink structure. You can choose from common settings or create custom URL structures.').'</p>'. |
|
23 | + '<p>'.__('You must click the Save Changes button at the bottom of the screen for new settings to take effect.').'</p>', |
|
24 | +)); |
|
25 | 25 | |
26 | -get_current_screen()->add_help_tab( array( |
|
26 | +get_current_screen()->add_help_tab(array( |
|
27 | 27 | 'id' => 'permalink-settings', |
28 | 28 | 'title' => __('Permalink Settings'), |
29 | - 'content' => '<p>' . __( 'Permalinks can contain useful information, such as the post date, title, or other elements. You can choose from any of the suggested permalink formats, or you can craft your own if you select Custom Structure.' ) . '</p>' . |
|
30 | - '<p>' . __( 'If you pick an option other than Plain, your general URL path with structure tags (terms surrounded by <code>%</code>) will also appear in the custom structure field and your path can be further modified there.' ) . '</p>' . |
|
31 | - '<p>' . __('When you assign multiple categories or tags to a post, only one can show up in the permalink: the lowest numbered category. This applies if your custom structure includes <code>%category%</code> or <code>%tag%</code>.') . '</p>' . |
|
32 | - '<p>' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '</p>', |
|
33 | -) ); |
|
29 | + 'content' => '<p>'.__('Permalinks can contain useful information, such as the post date, title, or other elements. You can choose from any of the suggested permalink formats, or you can craft your own if you select Custom Structure.').'</p>'. |
|
30 | + '<p>'.__('If you pick an option other than Plain, your general URL path with structure tags (terms surrounded by <code>%</code>) will also appear in the custom structure field and your path can be further modified there.').'</p>'. |
|
31 | + '<p>'.__('When you assign multiple categories or tags to a post, only one can show up in the permalink: the lowest numbered category. This applies if your custom structure includes <code>%category%</code> or <code>%tag%</code>.').'</p>'. |
|
32 | + '<p>'.__('You must click the Save Changes button at the bottom of the screen for new settings to take effect.').'</p>', |
|
33 | +)); |
|
34 | 34 | |
35 | -get_current_screen()->add_help_tab( array( |
|
35 | +get_current_screen()->add_help_tab(array( |
|
36 | 36 | 'id' => 'custom-structures', |
37 | 37 | 'title' => __('Custom Structures'), |
38 | - 'content' => '<p>' . __('The Optional fields let you customize the “category” and “tag” base names that will appear in archive URLs. For example, the page listing all posts in the “Uncategorized” category could be <code>/topics/uncategorized</code> instead of <code>/category/uncategorized</code>.') . '</p>' . |
|
39 | - '<p>' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '</p>', |
|
40 | -) ); |
|
38 | + 'content' => '<p>'.__('The Optional fields let you customize the “category” and “tag” base names that will appear in archive URLs. For example, the page listing all posts in the “Uncategorized” category could be <code>/topics/uncategorized</code> instead of <code>/category/uncategorized</code>.').'</p>'. |
|
39 | + '<p>'.__('You must click the Save Changes button at the bottom of the screen for new settings to take effect.').'</p>', |
|
40 | +)); |
|
41 | 41 | |
42 | 42 | get_current_screen()->set_help_sidebar( |
43 | - '<p><strong>' . __('For more information:') . '</strong></p>' . |
|
44 | - '<p>' . __('<a href="https://codex.wordpress.org/Settings_Permalinks_Screen">Documentation on Permalinks Settings</a>') . '</p>' . |
|
45 | - '<p>' . __('<a href="https://codex.wordpress.org/Using_Permalinks">Documentation on Using Permalinks</a>') . '</p>' . |
|
46 | - '<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>' |
|
43 | + '<p><strong>'.__('For more information:').'</strong></p>'. |
|
44 | + '<p>'.__('<a href="https://codex.wordpress.org/Settings_Permalinks_Screen">Documentation on Permalinks Settings</a>').'</p>'. |
|
45 | + '<p>'.__('<a href="https://codex.wordpress.org/Using_Permalinks">Documentation on Using Permalinks</a>').'</p>'. |
|
46 | + '<p>'.__('<a href="https://wordpress.org/support/">Support Forums</a>').'</p>' |
|
47 | 47 | ); |
48 | 48 | |
49 | 49 | add_filter('admin_head', 'options_permalink_add_js'); |
50 | 50 | |
51 | 51 | $home_path = get_home_path(); |
52 | 52 | $iis7_permalinks = iis7_supports_permalinks(); |
53 | -$permalink_structure = get_option( 'permalink_structure' ); |
|
53 | +$permalink_structure = get_option('permalink_structure'); |
|
54 | 54 | |
55 | 55 | $prefix = $blog_prefix = ''; |
56 | -if ( ! got_url_rewrite() ) |
|
56 | +if ( ! got_url_rewrite()) |
|
57 | 57 | $prefix = '/index.php'; |
58 | 58 | |
59 | 59 | /** |
@@ -62,149 +62,149 @@ discard block |
||
62 | 62 | * network. If the `permalink_structure` option has been changed to remove this |
63 | 63 | * base prefix, WordPress core can no longer account for the possible collision. |
64 | 64 | */ |
65 | -if ( is_multisite() && ! is_subdomain_install() && is_main_site() && 0 === strpos( $permalink_structure, '/blog/' ) ) { |
|
65 | +if (is_multisite() && ! is_subdomain_install() && is_main_site() && 0 === strpos($permalink_structure, '/blog/')) { |
|
66 | 66 | $blog_prefix = '/blog'; |
67 | 67 | } |
68 | 68 | |
69 | -$category_base = get_option( 'category_base' ); |
|
70 | -$tag_base = get_option( 'tag_base' ); |
|
69 | +$category_base = get_option('category_base'); |
|
70 | +$tag_base = get_option('tag_base'); |
|
71 | 71 | $update_required = false; |
72 | 72 | |
73 | -if ( $iis7_permalinks ) { |
|
74 | - if ( ( ! file_exists($home_path . 'web.config') && win_is_writable($home_path) ) || win_is_writable($home_path . 'web.config') ) |
|
73 | +if ($iis7_permalinks) { |
|
74 | + if (( ! file_exists($home_path.'web.config') && win_is_writable($home_path)) || win_is_writable($home_path.'web.config')) |
|
75 | 75 | $writable = true; |
76 | 76 | else |
77 | 77 | $writable = false; |
78 | -} elseif ( $is_nginx ) { |
|
78 | +} elseif ($is_nginx) { |
|
79 | 79 | $writable = false; |
80 | 80 | } else { |
81 | - if ( ( ! file_exists( $home_path . '.htaccess' ) && is_writable( $home_path ) ) || is_writable( $home_path . '.htaccess' ) ) { |
|
81 | + if (( ! file_exists($home_path.'.htaccess') && is_writable($home_path)) || is_writable($home_path.'.htaccess')) { |
|
82 | 82 | $writable = true; |
83 | 83 | } else { |
84 | 84 | $writable = false; |
85 | - $existing_rules = array_filter( extract_from_markers( $home_path . '.htaccess', 'WordPress' ) ); |
|
86 | - $new_rules = array_filter( explode( "\n", $wp_rewrite->mod_rewrite_rules() ) ); |
|
87 | - $update_required = ( $new_rules !== $existing_rules ); |
|
85 | + $existing_rules = array_filter(extract_from_markers($home_path.'.htaccess', 'WordPress')); |
|
86 | + $new_rules = array_filter(explode("\n", $wp_rewrite->mod_rewrite_rules())); |
|
87 | + $update_required = ($new_rules !== $existing_rules); |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
91 | 91 | $using_index_permalinks = $wp_rewrite->using_index_permalinks(); |
92 | 92 | |
93 | -if ( isset($_POST['permalink_structure']) || isset($_POST['category_base']) ) { |
|
93 | +if (isset($_POST['permalink_structure']) || isset($_POST['category_base'])) { |
|
94 | 94 | check_admin_referer('update-permalink'); |
95 | 95 | |
96 | - if ( isset( $_POST['permalink_structure'] ) ) { |
|
97 | - if ( isset( $_POST['selection'] ) && 'custom' != $_POST['selection'] ) |
|
96 | + if (isset($_POST['permalink_structure'])) { |
|
97 | + if (isset($_POST['selection']) && 'custom' != $_POST['selection']) |
|
98 | 98 | $permalink_structure = $_POST['selection']; |
99 | 99 | else |
100 | 100 | $permalink_structure = $_POST['permalink_structure']; |
101 | 101 | |
102 | - if ( ! empty( $permalink_structure ) ) { |
|
103 | - $permalink_structure = preg_replace( '#/+#', '/', '/' . str_replace( '#', '', $permalink_structure ) ); |
|
104 | - if ( $prefix && $blog_prefix ) |
|
105 | - $permalink_structure = $prefix . preg_replace( '#^/?index\.php#', '', $permalink_structure ); |
|
102 | + if ( ! empty($permalink_structure)) { |
|
103 | + $permalink_structure = preg_replace('#/+#', '/', '/'.str_replace('#', '', $permalink_structure)); |
|
104 | + if ($prefix && $blog_prefix) |
|
105 | + $permalink_structure = $prefix.preg_replace('#^/?index\.php#', '', $permalink_structure); |
|
106 | 106 | else |
107 | - $permalink_structure = $blog_prefix . $permalink_structure; |
|
107 | + $permalink_structure = $blog_prefix.$permalink_structure; |
|
108 | 108 | } |
109 | 109 | |
110 | - $permalink_structure = sanitize_option( 'permalink_structure', $permalink_structure ); |
|
110 | + $permalink_structure = sanitize_option('permalink_structure', $permalink_structure); |
|
111 | 111 | |
112 | - $wp_rewrite->set_permalink_structure( $permalink_structure ); |
|
112 | + $wp_rewrite->set_permalink_structure($permalink_structure); |
|
113 | 113 | } |
114 | 114 | |
115 | - if ( isset( $_POST['category_base'] ) ) { |
|
115 | + if (isset($_POST['category_base'])) { |
|
116 | 116 | $category_base = $_POST['category_base']; |
117 | - if ( ! empty( $category_base ) ) |
|
118 | - $category_base = $blog_prefix . preg_replace('#/+#', '/', '/' . str_replace( '#', '', $category_base ) ); |
|
119 | - $wp_rewrite->set_category_base( $category_base ); |
|
117 | + if ( ! empty($category_base)) |
|
118 | + $category_base = $blog_prefix.preg_replace('#/+#', '/', '/'.str_replace('#', '', $category_base)); |
|
119 | + $wp_rewrite->set_category_base($category_base); |
|
120 | 120 | } |
121 | 121 | |
122 | - if ( isset( $_POST['tag_base'] ) ) { |
|
122 | + if (isset($_POST['tag_base'])) { |
|
123 | 123 | $tag_base = $_POST['tag_base']; |
124 | - if ( ! empty( $tag_base ) ) |
|
125 | - $tag_base = $blog_prefix . preg_replace('#/+#', '/', '/' . str_replace( '#', '', $tag_base ) ); |
|
126 | - $wp_rewrite->set_tag_base( $tag_base ); |
|
124 | + if ( ! empty($tag_base)) |
|
125 | + $tag_base = $blog_prefix.preg_replace('#/+#', '/', '/'.str_replace('#', '', $tag_base)); |
|
126 | + $wp_rewrite->set_tag_base($tag_base); |
|
127 | 127 | } |
128 | 128 | |
129 | - $message = __( 'Permalink structure updated.' ); |
|
129 | + $message = __('Permalink structure updated.'); |
|
130 | 130 | |
131 | - if ( $iis7_permalinks ) { |
|
132 | - if ( $permalink_structure && ! $using_index_permalinks && ! $writable ) { |
|
133 | - $message = __( 'You should update your web.config now.' ); |
|
134 | - } elseif ( $permalink_structure && ! $using_index_permalinks && $writable ) { |
|
135 | - $message = __( 'Permalink structure updated. Remove write access on web.config file now!' ); |
|
131 | + if ($iis7_permalinks) { |
|
132 | + if ($permalink_structure && ! $using_index_permalinks && ! $writable) { |
|
133 | + $message = __('You should update your web.config now.'); |
|
134 | + } elseif ($permalink_structure && ! $using_index_permalinks && $writable) { |
|
135 | + $message = __('Permalink structure updated. Remove write access on web.config file now!'); |
|
136 | 136 | } |
137 | - } elseif ( ! $is_nginx && $permalink_structure && ! $using_index_permalinks && ! $writable && $update_required ) { |
|
138 | - $message = __( 'You should update your .htaccess now.' ); |
|
137 | + } elseif ( ! $is_nginx && $permalink_structure && ! $using_index_permalinks && ! $writable && $update_required) { |
|
138 | + $message = __('You should update your .htaccess now.'); |
|
139 | 139 | } |
140 | 140 | |
141 | - if ( ! get_settings_errors() ) { |
|
142 | - add_settings_error( 'general', 'settings_updated', $message, 'updated' ); |
|
141 | + if ( ! get_settings_errors()) { |
|
142 | + add_settings_error('general', 'settings_updated', $message, 'updated'); |
|
143 | 143 | } |
144 | 144 | |
145 | - set_transient( 'settings_errors', get_settings_errors(), 30 ); |
|
145 | + set_transient('settings_errors', get_settings_errors(), 30); |
|
146 | 146 | |
147 | - wp_redirect( admin_url( 'options-permalink.php?settings-updated=true' ) ); |
|
147 | + wp_redirect(admin_url('options-permalink.php?settings-updated=true')); |
|
148 | 148 | exit; |
149 | 149 | } |
150 | 150 | |
151 | 151 | flush_rewrite_rules(); |
152 | 152 | |
153 | -require( ABSPATH . 'wp-admin/admin-header.php' ); |
|
153 | +require(ABSPATH.'wp-admin/admin-header.php'); |
|
154 | 154 | ?> |
155 | 155 | <div class="wrap"> |
156 | -<h1><?php echo esc_html( $title ); ?></h1> |
|
156 | +<h1><?php echo esc_html($title); ?></h1> |
|
157 | 157 | |
158 | 158 | <form name="form" action="options-permalink.php" method="post"> |
159 | 159 | <?php wp_nonce_field('update-permalink') ?> |
160 | 160 | |
161 | - <p><?php _e( 'WordPress offers you the ability to create a custom URL structure for your permalinks and archives. Custom URL structures can improve the aesthetics, usability, and forward-compatibility of your links. A <a href="https://codex.wordpress.org/Using_Permalinks">number of tags are available</a>, and here are some examples to get you started.' ); ?></p> |
|
161 | + <p><?php _e('WordPress offers you the ability to create a custom URL structure for your permalinks and archives. Custom URL structures can improve the aesthetics, usability, and forward-compatibility of your links. A <a href="https://codex.wordpress.org/Using_Permalinks">number of tags are available</a>, and here are some examples to get you started.'); ?></p> |
|
162 | 162 | |
163 | 163 | <?php |
164 | -if ( is_multisite() && ! is_subdomain_install() && is_main_site() && 0 === strpos( $permalink_structure, '/blog/' ) ) { |
|
165 | - $permalink_structure = preg_replace( '|^/?blog|', '', $permalink_structure ); |
|
166 | - $category_base = preg_replace( '|^/?blog|', '', $category_base ); |
|
167 | - $tag_base = preg_replace( '|^/?blog|', '', $tag_base ); |
|
164 | +if (is_multisite() && ! is_subdomain_install() && is_main_site() && 0 === strpos($permalink_structure, '/blog/')) { |
|
165 | + $permalink_structure = preg_replace('|^/?blog|', '', $permalink_structure); |
|
166 | + $category_base = preg_replace('|^/?blog|', '', $category_base); |
|
167 | + $tag_base = preg_replace('|^/?blog|', '', $tag_base); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | $structures = array( |
171 | 171 | 0 => '', |
172 | - 1 => $prefix . '/%year%/%monthnum%/%day%/%postname%/', |
|
173 | - 2 => $prefix . '/%year%/%monthnum%/%postname%/', |
|
174 | - 3 => $prefix . '/' . _x( 'archives', 'sample permalink base' ) . '/%post_id%', |
|
175 | - 4 => $prefix . '/%postname%/', |
|
172 | + 1 => $prefix.'/%year%/%monthnum%/%day%/%postname%/', |
|
173 | + 2 => $prefix.'/%year%/%monthnum%/%postname%/', |
|
174 | + 3 => $prefix.'/'._x('archives', 'sample permalink base').'/%post_id%', |
|
175 | + 4 => $prefix.'/%postname%/', |
|
176 | 176 | ); |
177 | 177 | ?> |
178 | 178 | <h2 class="title"><?php _e('Common Settings'); ?></h2> |
179 | 179 | <table class="form-table permalink-structure"> |
180 | 180 | <tr> |
181 | - <th><label><input name="selection" type="radio" value="" <?php checked('', $permalink_structure); ?> /> <?php _e( 'Plain' ); ?></label></th> |
|
181 | + <th><label><input name="selection" type="radio" value="" <?php checked('', $permalink_structure); ?> /> <?php _e('Plain'); ?></label></th> |
|
182 | 182 | <td><code><?php echo get_option('home'); ?>/?p=123</code></td> |
183 | 183 | </tr> |
184 | 184 | <tr> |
185 | 185 | <th><label><input name="selection" type="radio" value="<?php echo esc_attr($structures[1]); ?>" <?php checked($structures[1], $permalink_structure); ?> /> <?php _e('Day and name'); ?></label></th> |
186 | - <td><code><?php echo get_option('home') . $blog_prefix . $prefix . '/' . date('Y') . '/' . date('m') . '/' . date('d') . '/' . _x( 'sample-post', 'sample permalink structure' ) . '/'; ?></code></td> |
|
186 | + <td><code><?php echo get_option('home').$blog_prefix.$prefix.'/'.date('Y').'/'.date('m').'/'.date('d').'/'._x('sample-post', 'sample permalink structure').'/'; ?></code></td> |
|
187 | 187 | </tr> |
188 | 188 | <tr> |
189 | 189 | <th><label><input name="selection" type="radio" value="<?php echo esc_attr($structures[2]); ?>" <?php checked($structures[2], $permalink_structure); ?> /> <?php _e('Month and name'); ?></label></th> |
190 | - <td><code><?php echo get_option('home') . $blog_prefix . $prefix . '/' . date('Y') . '/' . date('m') . '/' . _x( 'sample-post', 'sample permalink structure' ) . '/'; ?></code></td> |
|
190 | + <td><code><?php echo get_option('home').$blog_prefix.$prefix.'/'.date('Y').'/'.date('m').'/'._x('sample-post', 'sample permalink structure').'/'; ?></code></td> |
|
191 | 191 | </tr> |
192 | 192 | <tr> |
193 | 193 | <th><label><input name="selection" type="radio" value="<?php echo esc_attr($structures[3]); ?>" <?php checked($structures[3], $permalink_structure); ?> /> <?php _e('Numeric'); ?></label></th> |
194 | - <td><code><?php echo get_option('home') . $blog_prefix . $prefix . '/' . _x( 'archives', 'sample permalink base' ) . '/123'; ?></code></td> |
|
194 | + <td><code><?php echo get_option('home').$blog_prefix.$prefix.'/'._x('archives', 'sample permalink base').'/123'; ?></code></td> |
|
195 | 195 | </tr> |
196 | 196 | <tr> |
197 | 197 | <th><label><input name="selection" type="radio" value="<?php echo esc_attr($structures[4]); ?>" <?php checked($structures[4], $permalink_structure); ?> /> <?php _e('Post name'); ?></label></th> |
198 | - <td><code><?php echo get_option('home') . $blog_prefix . $prefix . '/' . _x( 'sample-post', 'sample permalink structure' ) . '/'; ?></code></td> |
|
198 | + <td><code><?php echo get_option('home').$blog_prefix.$prefix.'/'._x('sample-post', 'sample permalink structure').'/'; ?></code></td> |
|
199 | 199 | </tr> |
200 | 200 | <tr> |
201 | 201 | <th> |
202 | - <label><input name="selection" id="custom_selection" type="radio" value="custom" <?php checked( !in_array($permalink_structure, $structures) ); ?> /> |
|
202 | + <label><input name="selection" id="custom_selection" type="radio" value="custom" <?php checked( ! in_array($permalink_structure, $structures)); ?> /> |
|
203 | 203 | <?php _e('Custom Structure'); ?> |
204 | 204 | </label> |
205 | 205 | </th> |
206 | 206 | <td> |
207 | - <code><?php echo get_option('home') . $blog_prefix; ?></code> |
|
207 | + <code><?php echo get_option('home').$blog_prefix; ?></code> |
|
208 | 208 | <input name="permalink_structure" id="permalink_structure" type="text" value="<?php echo esc_attr($permalink_structure); ?>" class="regular-text code" /> |
209 | 209 | </td> |
210 | 210 | </tr> |
@@ -213,12 +213,12 @@ discard block |
||
213 | 213 | <h2 class="title"><?php _e('Optional'); ?></h2> |
214 | 214 | <p><?php |
215 | 215 | /* translators: %s is a placeholder that must come at the start of the URL. */ |
216 | -printf( __( 'If you like, you may enter custom structures for your category and tag URLs here. For example, using <code>topics</code> as your category base would make your category links like <code>%s/topics/uncategorized/</code>. If you leave these blank the defaults will be used.' ), get_option( 'home' ) . $blog_prefix . $prefix ); ?></p> |
|
216 | +printf(__('If you like, you may enter custom structures for your category and tag URLs here. For example, using <code>topics</code> as your category base would make your category links like <code>%s/topics/uncategorized/</code>. If you leave these blank the defaults will be used.'), get_option('home').$blog_prefix.$prefix); ?></p> |
|
217 | 217 | |
218 | 218 | <table class="form-table"> |
219 | 219 | <tr> |
220 | 220 | <th><label for="category_base"><?php /* translators: prefix for category permalinks */ _e('Category base'); ?></label></th> |
221 | - <td><?php echo $blog_prefix; ?> <input name="category_base" id="category_base" type="text" value="<?php echo esc_attr( $category_base ); ?>" class="regular-text code" /></td> |
|
221 | + <td><?php echo $blog_prefix; ?> <input name="category_base" id="category_base" type="text" value="<?php echo esc_attr($category_base); ?>" class="regular-text code" /></td> |
|
222 | 222 | </tr> |
223 | 223 | <tr> |
224 | 224 | <th><label for="tag_base"><?php _e('Tag base'); ?></label></th> |
@@ -231,33 +231,33 @@ discard block |
||
231 | 231 | |
232 | 232 | <?php submit_button(); ?> |
233 | 233 | </form> |
234 | -<?php if ( !is_multisite() ) { ?> |
|
235 | -<?php if ( $iis7_permalinks ) : |
|
236 | - if ( isset($_POST['submit']) && $permalink_structure && ! $using_index_permalinks && ! $writable ) : |
|
237 | - if ( file_exists($home_path . 'web.config') ) : ?> |
|
234 | +<?php if ( ! is_multisite()) { ?> |
|
235 | +<?php if ($iis7_permalinks) : |
|
236 | + if (isset($_POST['submit']) && $permalink_structure && ! $using_index_permalinks && ! $writable) : |
|
237 | + if (file_exists($home_path.'web.config')) : ?> |
|
238 | 238 | <p><?php _e('If your <code>web.config</code> file were <a href="https://codex.wordpress.org/Changing_File_Permissions">writable</a>, we could do this automatically, but it isn’t so this is the url rewrite rule you should have in your <code>web.config</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all. Then insert this rule inside of the <code>/<configuration>/<system.webServer>/<rewrite>/<rules></code> element in <code>web.config</code> file.') ?></p> |
239 | 239 | <form action="options-permalink.php" method="post"> |
240 | 240 | <?php wp_nonce_field('update-permalink') ?> |
241 | - <p><textarea rows="9" class="large-text readonly" name="rules" id="rules" readonly="readonly"><?php echo esc_textarea( $wp_rewrite->iis7_url_rewrite_rules() ); ?></textarea></p> |
|
241 | + <p><textarea rows="9" class="large-text readonly" name="rules" id="rules" readonly="readonly"><?php echo esc_textarea($wp_rewrite->iis7_url_rewrite_rules()); ?></textarea></p> |
|
242 | 242 | </form> |
243 | 243 | <p><?php _e('If you temporarily make your <code>web.config</code> file writable for us to generate rewrite rules automatically, do not forget to revert the permissions after rule has been saved.') ?></p> |
244 | 244 | <?php else : ?> |
245 | 245 | <p><?php _e('If the root directory of your site were <a href="https://codex.wordpress.org/Changing_File_Permissions">writable</a>, we could do this automatically, but it isn’t so this is the url rewrite rule you should have in your <code>web.config</code> file. Create a new file, called <code>web.config</code> in the root directory of your site. Click in the field and press <kbd>CTRL + a</kbd> to select all. Then insert this code into the <code>web.config</code> file.') ?></p> |
246 | 246 | <form action="options-permalink.php" method="post"> |
247 | 247 | <?php wp_nonce_field('update-permalink') ?> |
248 | - <p><textarea rows="18" class="large-text readonly" name="rules" id="rules" readonly="readonly"><?php echo esc_textarea( $wp_rewrite->iis7_url_rewrite_rules(true) ); ?></textarea></p> |
|
248 | + <p><textarea rows="18" class="large-text readonly" name="rules" id="rules" readonly="readonly"><?php echo esc_textarea($wp_rewrite->iis7_url_rewrite_rules(true)); ?></textarea></p> |
|
249 | 249 | </form> |
250 | 250 | <p><?php _e('If you temporarily make your site’s root directory writable for us to generate the <code>web.config</code> file automatically, do not forget to revert the permissions after the file has been created.') ?></p> |
251 | 251 | <?php endif; ?> |
252 | 252 | <?php endif; ?> |
253 | -<?php elseif ( $is_nginx ) : ?> |
|
254 | - <p><?php _e( '<a href="https://codex.wordpress.org/Nginx">Documentation on Nginx configuration</a>.' ); ?></p> |
|
253 | +<?php elseif ($is_nginx) : ?> |
|
254 | + <p><?php _e('<a href="https://codex.wordpress.org/Nginx">Documentation on Nginx configuration</a>.'); ?></p> |
|
255 | 255 | <?php else: |
256 | - if ( $permalink_structure && ! $using_index_permalinks && ! $writable && $update_required ) : ?> |
|
256 | + if ($permalink_structure && ! $using_index_permalinks && ! $writable && $update_required) : ?> |
|
257 | 257 | <p><?php _e('If your <code>.htaccess</code> file were <a href="https://codex.wordpress.org/Changing_File_Permissions">writable</a>, we could do this automatically, but it isn’t so these are the mod_rewrite rules you should have in your <code>.htaccess</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all.') ?></p> |
258 | 258 | <form action="options-permalink.php" method="post"> |
259 | 259 | <?php wp_nonce_field('update-permalink') ?> |
260 | - <p><textarea rows="6" class="large-text readonly" name="rules" id="rules" readonly="readonly"><?php echo esc_textarea( $wp_rewrite->mod_rewrite_rules() ); ?></textarea></p> |
|
260 | + <p><textarea rows="6" class="large-text readonly" name="rules" id="rules" readonly="readonly"><?php echo esc_textarea($wp_rewrite->mod_rewrite_rules()); ?></textarea></p> |
|
261 | 261 | </form> |
262 | 262 | <?php endif; ?> |
263 | 263 | <?php endif; ?> |
@@ -265,4 +265,4 @@ discard block |
||
265 | 265 | |
266 | 266 | </div> |
267 | 267 | |
268 | -<?php require( ABSPATH . 'wp-admin/admin-footer.php' ); ?> |
|
268 | +<?php require(ABSPATH.'wp-admin/admin-footer.php'); ?> |
@@ -23,19 +23,19 @@ discard block |
||
23 | 23 | global $current_site, $current_blog; |
24 | 24 | |
25 | 25 | /** WP_Network class */ |
26 | -require_once( ABSPATH . WPINC . '/class-wp-network.php' ); |
|
26 | +require_once(ABSPATH.WPINC.'/class-wp-network.php'); |
|
27 | 27 | |
28 | 28 | /** WP_Site class */ |
29 | -require_once( ABSPATH . WPINC . '/class-wp-site.php' ); |
|
29 | +require_once(ABSPATH.WPINC.'/class-wp-site.php'); |
|
30 | 30 | |
31 | 31 | /** Multisite loader */ |
32 | -require_once( ABSPATH . WPINC . '/ms-load.php' ); |
|
32 | +require_once(ABSPATH.WPINC.'/ms-load.php'); |
|
33 | 33 | |
34 | 34 | /** Default Multisite constants */ |
35 | -require_once( ABSPATH . WPINC . '/ms-default-constants.php' ); |
|
35 | +require_once(ABSPATH.WPINC.'/ms-default-constants.php'); |
|
36 | 36 | |
37 | -if ( defined( 'SUNRISE' ) ) { |
|
38 | - include_once( WP_CONTENT_DIR . '/sunrise.php' ); |
|
37 | +if (defined('SUNRISE')) { |
|
38 | + include_once(WP_CONTENT_DIR.'/sunrise.php'); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | /** Check for and define SUBDOMAIN_INSTALL and the deprecated VHOST constant. */ |
@@ -43,50 +43,50 @@ discard block |
||
43 | 43 | |
44 | 44 | // This block will process a request if the current network or current site objects |
45 | 45 | // have not been populated in the global scope through something like `sunrise.php`. |
46 | -if ( !isset( $current_site ) || !isset( $current_blog ) ) { |
|
47 | - |
|
48 | - $domain = strtolower( stripslashes( $_SERVER['HTTP_HOST'] ) ); |
|
49 | - if ( substr( $domain, -3 ) == ':80' ) { |
|
50 | - $domain = substr( $domain, 0, -3 ); |
|
51 | - $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -3 ); |
|
52 | - } elseif ( substr( $domain, -4 ) == ':443' ) { |
|
53 | - $domain = substr( $domain, 0, -4 ); |
|
54 | - $_SERVER['HTTP_HOST'] = substr( $_SERVER['HTTP_HOST'], 0, -4 ); |
|
46 | +if ( ! isset($current_site) || ! isset($current_blog)) { |
|
47 | + |
|
48 | + $domain = strtolower(stripslashes($_SERVER['HTTP_HOST'])); |
|
49 | + if (substr($domain, -3) == ':80') { |
|
50 | + $domain = substr($domain, 0, -3); |
|
51 | + $_SERVER['HTTP_HOST'] = substr($_SERVER['HTTP_HOST'], 0, -3); |
|
52 | + } elseif (substr($domain, -4) == ':443') { |
|
53 | + $domain = substr($domain, 0, -4); |
|
54 | + $_SERVER['HTTP_HOST'] = substr($_SERVER['HTTP_HOST'], 0, -4); |
|
55 | 55 | } |
56 | 56 | |
57 | - $path = stripslashes( $_SERVER['REQUEST_URI'] ); |
|
58 | - if ( is_admin() ) { |
|
59 | - $path = preg_replace( '#(.*)/wp-admin/.*#', '$1/', $path ); |
|
57 | + $path = stripslashes($_SERVER['REQUEST_URI']); |
|
58 | + if (is_admin()) { |
|
59 | + $path = preg_replace('#(.*)/wp-admin/.*#', '$1/', $path); |
|
60 | 60 | } |
61 | - list( $path ) = explode( '?', $path ); |
|
61 | + list($path) = explode('?', $path); |
|
62 | 62 | |
63 | - $bootstrap_result = ms_load_current_site_and_network( $domain, $path, is_subdomain_install() ); |
|
63 | + $bootstrap_result = ms_load_current_site_and_network($domain, $path, is_subdomain_install()); |
|
64 | 64 | |
65 | - if ( true === $bootstrap_result ) { |
|
65 | + if (true === $bootstrap_result) { |
|
66 | 66 | // `$current_blog` and `$current_site are now populated. |
67 | - } elseif ( false === $bootstrap_result ) { |
|
68 | - ms_not_installed( $domain, $path ); |
|
67 | + } elseif (false === $bootstrap_result) { |
|
68 | + ms_not_installed($domain, $path); |
|
69 | 69 | } else { |
70 | - header( 'Location: ' . $bootstrap_result ); |
|
70 | + header('Location: '.$bootstrap_result); |
|
71 | 71 | exit; |
72 | 72 | } |
73 | - unset( $bootstrap_result ); |
|
73 | + unset($bootstrap_result); |
|
74 | 74 | |
75 | 75 | $blog_id = $current_blog->blog_id; |
76 | 76 | $public = $current_blog->public; |
77 | 77 | |
78 | - if ( empty( $current_blog->site_id ) ) { |
|
78 | + if (empty($current_blog->site_id)) { |
|
79 | 79 | // This dates to [MU134] and shouldn't be relevant anymore, |
80 | 80 | // but it could be possible for arguments passed to insert_blog() etc. |
81 | 81 | $current_blog->site_id = 1; |
82 | 82 | } |
83 | 83 | |
84 | 84 | $site_id = $current_blog->site_id; |
85 | - wp_load_core_site_options( $site_id ); |
|
85 | + wp_load_core_site_options($site_id); |
|
86 | 86 | } |
87 | 87 | |
88 | -$wpdb->set_prefix( $table_prefix, false ); // $table_prefix can be set in sunrise.php |
|
89 | -$wpdb->set_blog_id( $current_blog->blog_id, $current_blog->site_id ); |
|
88 | +$wpdb->set_prefix($table_prefix, false); // $table_prefix can be set in sunrise.php |
|
89 | +$wpdb->set_blog_id($current_blog->blog_id, $current_blog->site_id); |
|
90 | 90 | $table_prefix = $wpdb->get_blog_prefix(); |
91 | 91 | $_wp_switched_stack = array(); |
92 | 92 | $switched = false; |
@@ -94,12 +94,12 @@ discard block |
||
94 | 94 | // need to init cache again after blog_id is set |
95 | 95 | wp_start_object_cache(); |
96 | 96 | |
97 | -if ( ! $current_site instanceof WP_Network ) { |
|
98 | - $current_site = new WP_Network( $current_site ); |
|
97 | +if ( ! $current_site instanceof WP_Network) { |
|
98 | + $current_site = new WP_Network($current_site); |
|
99 | 99 | } |
100 | 100 | |
101 | -if ( ! $current_blog instanceof WP_Site ) { |
|
102 | - $current_blog = new WP_Site( $current_blog ); |
|
101 | +if ( ! $current_blog instanceof WP_Site) { |
|
102 | + $current_blog = new WP_Site($current_blog); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | // Define upload directory constants |
@@ -111,4 +111,4 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @since 4.6.0 |
113 | 113 | */ |
114 | -do_action( 'ms_loaded' ); |
|
114 | +do_action('ms_loaded'); |
@@ -21,13 +21,13 @@ discard block |
||
21 | 21 | * @param string $name |
22 | 22 | * @return string|array|void |
23 | 23 | */ |
24 | - public function __get( $name ) { |
|
25 | - switch ( $name ) { |
|
24 | + public function __get($name) { |
|
25 | + switch ($name) { |
|
26 | 26 | case 'proto' : |
27 | 27 | return is_ssl() ? 'https://' : 'http://'; |
28 | 28 | |
29 | 29 | case 'menu' : |
30 | - _deprecated_argument( 'WP_Admin_Bar', '3.3.0', 'Modify admin bar nodes with WP_Admin_Bar::get_node(), WP_Admin_Bar::add_node(), and WP_Admin_Bar::remove_node(), not the <code>menu</code> property.' ); |
|
30 | + _deprecated_argument('WP_Admin_Bar', '3.3.0', 'Modify admin bar nodes with WP_Admin_Bar::get_node(), WP_Admin_Bar::add_node(), and WP_Admin_Bar::remove_node(), not the <code>menu</code> property.'); |
|
31 | 31 | return array(); // Sorry, folks. |
32 | 32 | } |
33 | 33 | } |
@@ -38,61 +38,61 @@ discard block |
||
38 | 38 | public function initialize() { |
39 | 39 | $this->user = new stdClass; |
40 | 40 | |
41 | - if ( is_user_logged_in() ) { |
|
41 | + if (is_user_logged_in()) { |
|
42 | 42 | /* Populate settings we need for the menu based on the current user. */ |
43 | - $this->user->blogs = get_blogs_of_user( get_current_user_id() ); |
|
44 | - if ( is_multisite() ) { |
|
45 | - $this->user->active_blog = get_active_blog_for_user( get_current_user_id() ); |
|
46 | - $this->user->domain = empty( $this->user->active_blog ) ? user_admin_url() : trailingslashit( get_home_url( $this->user->active_blog->blog_id ) ); |
|
43 | + $this->user->blogs = get_blogs_of_user(get_current_user_id()); |
|
44 | + if (is_multisite()) { |
|
45 | + $this->user->active_blog = get_active_blog_for_user(get_current_user_id()); |
|
46 | + $this->user->domain = empty($this->user->active_blog) ? user_admin_url() : trailingslashit(get_home_url($this->user->active_blog->blog_id)); |
|
47 | 47 | $this->user->account_domain = $this->user->domain; |
48 | 48 | } else { |
49 | 49 | $this->user->active_blog = $this->user->blogs[get_current_blog_id()]; |
50 | - $this->user->domain = trailingslashit( home_url() ); |
|
50 | + $this->user->domain = trailingslashit(home_url()); |
|
51 | 51 | $this->user->account_domain = $this->user->domain; |
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | - add_action( 'wp_head', 'wp_admin_bar_header' ); |
|
55 | + add_action('wp_head', 'wp_admin_bar_header'); |
|
56 | 56 | |
57 | - add_action( 'admin_head', 'wp_admin_bar_header' ); |
|
57 | + add_action('admin_head', 'wp_admin_bar_header'); |
|
58 | 58 | |
59 | - if ( current_theme_supports( 'admin-bar' ) ) { |
|
59 | + if (current_theme_supports('admin-bar')) { |
|
60 | 60 | /** |
61 | 61 | * To remove the default padding styles from WordPress for the Toolbar, use the following code: |
62 | 62 | * add_theme_support( 'admin-bar', array( 'callback' => '__return_false' ) ); |
63 | 63 | */ |
64 | - $admin_bar_args = get_theme_support( 'admin-bar' ); |
|
64 | + $admin_bar_args = get_theme_support('admin-bar'); |
|
65 | 65 | $header_callback = $admin_bar_args[0]['callback']; |
66 | 66 | } |
67 | 67 | |
68 | - if ( empty($header_callback) ) |
|
68 | + if (empty($header_callback)) |
|
69 | 69 | $header_callback = '_admin_bar_bump_cb'; |
70 | 70 | |
71 | 71 | add_action('wp_head', $header_callback); |
72 | 72 | |
73 | - wp_enqueue_script( 'admin-bar' ); |
|
74 | - wp_enqueue_style( 'admin-bar' ); |
|
73 | + wp_enqueue_script('admin-bar'); |
|
74 | + wp_enqueue_style('admin-bar'); |
|
75 | 75 | |
76 | 76 | /** |
77 | 77 | * Fires after WP_Admin_Bar is initialized. |
78 | 78 | * |
79 | 79 | * @since 3.1.0 |
80 | 80 | */ |
81 | - do_action( 'admin_bar_init' ); |
|
81 | + do_action('admin_bar_init'); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
85 | 85 | * @param array $node |
86 | 86 | */ |
87 | - public function add_menu( $node ) { |
|
88 | - $this->add_node( $node ); |
|
87 | + public function add_menu($node) { |
|
88 | + $this->add_node($node); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
92 | 92 | * @param string $id |
93 | 93 | */ |
94 | - public function remove_menu( $id ) { |
|
95 | - $this->remove_node( $id ); |
|
94 | + public function remove_menu($id) { |
|
95 | + $this->remove_node($id); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -114,22 +114,22 @@ discard block |
||
114 | 114 | * 'onclick', 'target', 'title', 'tabindex'. Default empty. |
115 | 115 | * } |
116 | 116 | */ |
117 | - public function add_node( $args ) { |
|
117 | + public function add_node($args) { |
|
118 | 118 | // Shim for old method signature: add_node( $parent_id, $menu_obj, $args ) |
119 | - if ( func_num_args() >= 3 && is_string( func_get_arg(0) ) ) |
|
120 | - $args = array_merge( array( 'parent' => func_get_arg(0) ), func_get_arg(2) ); |
|
119 | + if (func_num_args() >= 3 && is_string(func_get_arg(0))) |
|
120 | + $args = array_merge(array('parent' => func_get_arg(0)), func_get_arg(2)); |
|
121 | 121 | |
122 | - if ( is_object( $args ) ) |
|
123 | - $args = get_object_vars( $args ); |
|
122 | + if (is_object($args)) |
|
123 | + $args = get_object_vars($args); |
|
124 | 124 | |
125 | 125 | // Ensure we have a valid title. |
126 | - if ( empty( $args['id'] ) ) { |
|
127 | - if ( empty( $args['title'] ) ) |
|
126 | + if (empty($args['id'])) { |
|
127 | + if (empty($args['title'])) |
|
128 | 128 | return; |
129 | 129 | |
130 | - _doing_it_wrong( __METHOD__, __( 'The menu ID should not be empty.' ), '3.3.0' ); |
|
130 | + _doing_it_wrong(__METHOD__, __('The menu ID should not be empty.'), '3.3.0'); |
|
131 | 131 | // Deprecated: Generate an ID from the title. |
132 | - $args['id'] = esc_attr( sanitize_title( trim( $args['title'] ) ) ); |
|
132 | + $args['id'] = esc_attr(sanitize_title(trim($args['title']))); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | $defaults = array( |
@@ -142,34 +142,34 @@ discard block |
||
142 | 142 | ); |
143 | 143 | |
144 | 144 | // If the node already exists, keep any data that isn't provided. |
145 | - if ( $maybe_defaults = $this->get_node( $args['id'] ) ) |
|
146 | - $defaults = get_object_vars( $maybe_defaults ); |
|
145 | + if ($maybe_defaults = $this->get_node($args['id'])) |
|
146 | + $defaults = get_object_vars($maybe_defaults); |
|
147 | 147 | |
148 | 148 | // Do the same for 'meta' items. |
149 | - if ( ! empty( $defaults['meta'] ) && ! empty( $args['meta'] ) ) |
|
150 | - $args['meta'] = wp_parse_args( $args['meta'], $defaults['meta'] ); |
|
149 | + if ( ! empty($defaults['meta']) && ! empty($args['meta'])) |
|
150 | + $args['meta'] = wp_parse_args($args['meta'], $defaults['meta']); |
|
151 | 151 | |
152 | - $args = wp_parse_args( $args, $defaults ); |
|
152 | + $args = wp_parse_args($args, $defaults); |
|
153 | 153 | |
154 | 154 | $back_compat_parents = array( |
155 | - 'my-account-with-avatar' => array( 'my-account', '3.3' ), |
|
156 | - 'my-blogs' => array( 'my-sites', '3.3' ), |
|
155 | + 'my-account-with-avatar' => array('my-account', '3.3'), |
|
156 | + 'my-blogs' => array('my-sites', '3.3'), |
|
157 | 157 | ); |
158 | 158 | |
159 | - if ( isset( $back_compat_parents[ $args['parent'] ] ) ) { |
|
160 | - list( $new_parent, $version ) = $back_compat_parents[ $args['parent'] ]; |
|
161 | - _deprecated_argument( __METHOD__, $version, sprintf( 'Use <code>%s</code> as the parent for the <code>%s</code> admin bar node instead of <code>%s</code>.', $new_parent, $args['id'], $args['parent'] ) ); |
|
159 | + if (isset($back_compat_parents[$args['parent']])) { |
|
160 | + list($new_parent, $version) = $back_compat_parents[$args['parent']]; |
|
161 | + _deprecated_argument(__METHOD__, $version, sprintf('Use <code>%s</code> as the parent for the <code>%s</code> admin bar node instead of <code>%s</code>.', $new_parent, $args['id'], $args['parent'])); |
|
162 | 162 | $args['parent'] = $new_parent; |
163 | 163 | } |
164 | 164 | |
165 | - $this->_set_node( $args ); |
|
165 | + $this->_set_node($args); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
169 | 169 | * @param array $args |
170 | 170 | */ |
171 | - final protected function _set_node( $args ) { |
|
172 | - $this->nodes[ $args['id'] ] = (object) $args; |
|
171 | + final protected function _set_node($args) { |
|
172 | + $this->nodes[$args['id']] = (object) $args; |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
@@ -178,8 +178,8 @@ discard block |
||
178 | 178 | * @param string $id |
179 | 179 | * @return object Node. |
180 | 180 | */ |
181 | - final public function get_node( $id ) { |
|
182 | - if ( $node = $this->_get_node( $id ) ) |
|
181 | + final public function get_node($id) { |
|
182 | + if ($node = $this->_get_node($id)) |
|
183 | 183 | return clone $node; |
184 | 184 | } |
185 | 185 | |
@@ -187,25 +187,25 @@ discard block |
||
187 | 187 | * @param string $id |
188 | 188 | * @return object|void |
189 | 189 | */ |
190 | - final protected function _get_node( $id ) { |
|
191 | - if ( $this->bound ) |
|
190 | + final protected function _get_node($id) { |
|
191 | + if ($this->bound) |
|
192 | 192 | return; |
193 | 193 | |
194 | - if ( empty( $id ) ) |
|
194 | + if (empty($id)) |
|
195 | 195 | $id = 'root'; |
196 | 196 | |
197 | - if ( isset( $this->nodes[ $id ] ) ) |
|
198 | - return $this->nodes[ $id ]; |
|
197 | + if (isset($this->nodes[$id])) |
|
198 | + return $this->nodes[$id]; |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | /** |
202 | 202 | * @return array|void |
203 | 203 | */ |
204 | 204 | final public function get_nodes() { |
205 | - if ( ! $nodes = $this->_get_nodes() ) |
|
205 | + if ( ! $nodes = $this->_get_nodes()) |
|
206 | 206 | return; |
207 | 207 | |
208 | - foreach ( $nodes as &$node ) { |
|
208 | + foreach ($nodes as &$node) { |
|
209 | 209 | $node = clone $node; |
210 | 210 | } |
211 | 211 | return $nodes; |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * @return array|void |
216 | 216 | */ |
217 | 217 | final protected function _get_nodes() { |
218 | - if ( $this->bound ) |
|
218 | + if ($this->bound) |
|
219 | 219 | return; |
220 | 220 | |
221 | 221 | return $this->nodes; |
@@ -235,10 +235,10 @@ discard block |
||
235 | 235 | * 'class', 'onclick', 'target', and 'title'. |
236 | 236 | * } |
237 | 237 | */ |
238 | - final public function add_group( $args ) { |
|
238 | + final public function add_group($args) { |
|
239 | 239 | $args['group'] = true; |
240 | 240 | |
241 | - $this->add_node( $args ); |
|
241 | + $this->add_node($args); |
|
242 | 242 | } |
243 | 243 | |
244 | 244 | /** |
@@ -246,15 +246,15 @@ discard block |
||
246 | 246 | * |
247 | 247 | * @param string $id The ID of the item. |
248 | 248 | */ |
249 | - public function remove_node( $id ) { |
|
250 | - $this->_unset_node( $id ); |
|
249 | + public function remove_node($id) { |
|
250 | + $this->_unset_node($id); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | /** |
254 | 254 | * @param string $id |
255 | 255 | */ |
256 | - final protected function _unset_node( $id ) { |
|
257 | - unset( $this->nodes[ $id ] ); |
|
256 | + final protected function _unset_node($id) { |
|
257 | + unset($this->nodes[$id]); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | /** |
@@ -262,66 +262,66 @@ discard block |
||
262 | 262 | */ |
263 | 263 | public function render() { |
264 | 264 | $root = $this->_bind(); |
265 | - if ( $root ) |
|
266 | - $this->_render( $root ); |
|
265 | + if ($root) |
|
266 | + $this->_render($root); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | /** |
270 | 270 | * @return object|void |
271 | 271 | */ |
272 | 272 | final protected function _bind() { |
273 | - if ( $this->bound ) |
|
273 | + if ($this->bound) |
|
274 | 274 | return; |
275 | 275 | |
276 | 276 | // Add the root node. |
277 | 277 | // Clear it first, just in case. Don't mess with The Root. |
278 | - $this->remove_node( 'root' ); |
|
279 | - $this->add_node( array( |
|
278 | + $this->remove_node('root'); |
|
279 | + $this->add_node(array( |
|
280 | 280 | 'id' => 'root', |
281 | 281 | 'group' => false, |
282 | - ) ); |
|
282 | + )); |
|
283 | 283 | |
284 | 284 | // Normalize nodes: define internal 'children' and 'type' properties. |
285 | - foreach ( $this->_get_nodes() as $node ) { |
|
285 | + foreach ($this->_get_nodes() as $node) { |
|
286 | 286 | $node->children = array(); |
287 | - $node->type = ( $node->group ) ? 'group' : 'item'; |
|
288 | - unset( $node->group ); |
|
287 | + $node->type = ($node->group) ? 'group' : 'item'; |
|
288 | + unset($node->group); |
|
289 | 289 | |
290 | 290 | // The Root wants your orphans. No lonely items allowed. |
291 | - if ( ! $node->parent ) |
|
291 | + if ( ! $node->parent) |
|
292 | 292 | $node->parent = 'root'; |
293 | 293 | } |
294 | 294 | |
295 | - foreach ( $this->_get_nodes() as $node ) { |
|
296 | - if ( 'root' == $node->id ) |
|
295 | + foreach ($this->_get_nodes() as $node) { |
|
296 | + if ('root' == $node->id) |
|
297 | 297 | continue; |
298 | 298 | |
299 | 299 | // Fetch the parent node. If it isn't registered, ignore the node. |
300 | - if ( ! $parent = $this->_get_node( $node->parent ) ) { |
|
300 | + if ( ! $parent = $this->_get_node($node->parent)) { |
|
301 | 301 | continue; |
302 | 302 | } |
303 | 303 | |
304 | 304 | // Generate the group class (we distinguish between top level and other level groups). |
305 | - $group_class = ( $node->parent == 'root' ) ? 'ab-top-menu' : 'ab-submenu'; |
|
305 | + $group_class = ($node->parent == 'root') ? 'ab-top-menu' : 'ab-submenu'; |
|
306 | 306 | |
307 | - if ( $node->type == 'group' ) { |
|
308 | - if ( empty( $node->meta['class'] ) ) |
|
307 | + if ($node->type == 'group') { |
|
308 | + if (empty($node->meta['class'])) |
|
309 | 309 | $node->meta['class'] = $group_class; |
310 | 310 | else |
311 | - $node->meta['class'] .= ' ' . $group_class; |
|
311 | + $node->meta['class'] .= ' '.$group_class; |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | // Items in items aren't allowed. Wrap nested items in 'default' groups. |
315 | - if ( $parent->type == 'item' && $node->type == 'item' ) { |
|
316 | - $default_id = $parent->id . '-default'; |
|
317 | - $default = $this->_get_node( $default_id ); |
|
315 | + if ($parent->type == 'item' && $node->type == 'item') { |
|
316 | + $default_id = $parent->id.'-default'; |
|
317 | + $default = $this->_get_node($default_id); |
|
318 | 318 | |
319 | 319 | // The default group is added here to allow groups that are |
320 | 320 | // added before standard menu items to render first. |
321 | - if ( ! $default ) { |
|
321 | + if ( ! $default) { |
|
322 | 322 | // Use _set_node because add_node can be overloaded. |
323 | 323 | // Make sure to specify default settings for all properties. |
324 | - $this->_set_node( array( |
|
324 | + $this->_set_node(array( |
|
325 | 325 | 'id' => $default_id, |
326 | 326 | 'parent' => $parent->id, |
327 | 327 | 'type' => 'group', |
@@ -331,45 +331,45 @@ discard block |
||
331 | 331 | ), |
332 | 332 | 'title' => false, |
333 | 333 | 'href' => false, |
334 | - ) ); |
|
335 | - $default = $this->_get_node( $default_id ); |
|
334 | + )); |
|
335 | + $default = $this->_get_node($default_id); |
|
336 | 336 | $parent->children[] = $default; |
337 | 337 | } |
338 | 338 | $parent = $default; |
339 | 339 | |
340 | 340 | // Groups in groups aren't allowed. Add a special 'container' node. |
341 | 341 | // The container will invisibly wrap both groups. |
342 | - } elseif ( $parent->type == 'group' && $node->type == 'group' ) { |
|
343 | - $container_id = $parent->id . '-container'; |
|
344 | - $container = $this->_get_node( $container_id ); |
|
342 | + } elseif ($parent->type == 'group' && $node->type == 'group') { |
|
343 | + $container_id = $parent->id.'-container'; |
|
344 | + $container = $this->_get_node($container_id); |
|
345 | 345 | |
346 | 346 | // We need to create a container for this group, life is sad. |
347 | - if ( ! $container ) { |
|
347 | + if ( ! $container) { |
|
348 | 348 | // Use _set_node because add_node can be overloaded. |
349 | 349 | // Make sure to specify default settings for all properties. |
350 | - $this->_set_node( array( |
|
350 | + $this->_set_node(array( |
|
351 | 351 | 'id' => $container_id, |
352 | 352 | 'type' => 'container', |
353 | - 'children' => array( $parent ), |
|
353 | + 'children' => array($parent), |
|
354 | 354 | 'parent' => false, |
355 | 355 | 'title' => false, |
356 | 356 | 'href' => false, |
357 | 357 | 'meta' => array(), |
358 | - ) ); |
|
358 | + )); |
|
359 | 359 | |
360 | - $container = $this->_get_node( $container_id ); |
|
360 | + $container = $this->_get_node($container_id); |
|
361 | 361 | |
362 | 362 | // Link the container node if a grandparent node exists. |
363 | - $grandparent = $this->_get_node( $parent->parent ); |
|
363 | + $grandparent = $this->_get_node($parent->parent); |
|
364 | 364 | |
365 | - if ( $grandparent ) { |
|
365 | + if ($grandparent) { |
|
366 | 366 | $container->parent = $grandparent->id; |
367 | 367 | |
368 | - $index = array_search( $parent, $grandparent->children, true ); |
|
369 | - if ( $index === false ) |
|
368 | + $index = array_search($parent, $grandparent->children, true); |
|
369 | + if ($index === false) |
|
370 | 370 | $grandparent->children[] = $container; |
371 | 371 | else |
372 | - array_splice( $grandparent->children, $index, 1, array( $container ) ); |
|
372 | + array_splice($grandparent->children, $index, 1, array($container)); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | $parent->parent = $container->id; |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | $parent->children[] = $node; |
386 | 386 | } |
387 | 387 | |
388 | - $root = $this->_get_node( 'root' ); |
|
388 | + $root = $this->_get_node('root'); |
|
389 | 389 | $this->bound = true; |
390 | 390 | return $root; |
391 | 391 | } |
@@ -395,35 +395,35 @@ discard block |
||
395 | 395 | * @global bool $is_IE |
396 | 396 | * @param object $root |
397 | 397 | */ |
398 | - final protected function _render( $root ) { |
|
398 | + final protected function _render($root) { |
|
399 | 399 | global $is_IE; |
400 | 400 | |
401 | 401 | // Add browser classes. |
402 | 402 | // We have to do this here since admin bar shows on the front end. |
403 | 403 | $class = 'nojq nojs'; |
404 | - if ( $is_IE ) { |
|
405 | - if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE 7' ) ) |
|
404 | + if ($is_IE) { |
|
405 | + if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 7')) |
|
406 | 406 | $class .= ' ie7'; |
407 | - elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE 8' ) ) |
|
407 | + elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 8')) |
|
408 | 408 | $class .= ' ie8'; |
409 | - elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE 9' ) ) |
|
409 | + elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE 9')) |
|
410 | 410 | $class .= ' ie9'; |
411 | - } elseif ( wp_is_mobile() ) { |
|
411 | + } elseif (wp_is_mobile()) { |
|
412 | 412 | $class .= ' mobile'; |
413 | 413 | } |
414 | 414 | |
415 | 415 | ?> |
416 | 416 | <div id="wpadminbar" class="<?php echo $class; ?>"> |
417 | - <?php if ( ! is_admin() ) { ?> |
|
418 | - <a class="screen-reader-shortcut" href="#wp-toolbar" tabindex="1"><?php _e( 'Skip to toolbar' ); ?></a> |
|
417 | + <?php if ( ! is_admin()) { ?> |
|
418 | + <a class="screen-reader-shortcut" href="#wp-toolbar" tabindex="1"><?php _e('Skip to toolbar'); ?></a> |
|
419 | 419 | <?php } ?> |
420 | - <div class="quicklinks" id="wp-toolbar" role="navigation" aria-label="<?php esc_attr_e( 'Toolbar' ); ?>" tabindex="0"> |
|
421 | - <?php foreach ( $root->children as $group ) { |
|
422 | - $this->_render_group( $group ); |
|
420 | + <div class="quicklinks" id="wp-toolbar" role="navigation" aria-label="<?php esc_attr_e('Toolbar'); ?>" tabindex="0"> |
|
421 | + <?php foreach ($root->children as $group) { |
|
422 | + $this->_render_group($group); |
|
423 | 423 | } ?> |
424 | 424 | </div> |
425 | - <?php if ( is_user_logged_in() ) : ?> |
|
426 | - <a class="screen-reader-shortcut" href="<?php echo esc_url( wp_logout_url() ); ?>"><?php _e('Log Out'); ?></a> |
|
425 | + <?php if (is_user_logged_in()) : ?> |
|
426 | + <a class="screen-reader-shortcut" href="<?php echo esc_url(wp_logout_url()); ?>"><?php _e('Log Out'); ?></a> |
|
427 | 427 | <?php endif; ?> |
428 | 428 | </div> |
429 | 429 | |
@@ -433,13 +433,13 @@ discard block |
||
433 | 433 | /** |
434 | 434 | * @param object $node |
435 | 435 | */ |
436 | - final protected function _render_container( $node ) { |
|
437 | - if ( $node->type != 'container' || empty( $node->children ) ) |
|
436 | + final protected function _render_container($node) { |
|
437 | + if ($node->type != 'container' || empty($node->children)) |
|
438 | 438 | return; |
439 | 439 | |
440 | - ?><div id="<?php echo esc_attr( 'wp-admin-bar-' . $node->id ); ?>" class="ab-group-container"><?php |
|
441 | - foreach ( $node->children as $group ) { |
|
442 | - $this->_render_group( $group ); |
|
440 | + ?><div id="<?php echo esc_attr('wp-admin-bar-'.$node->id); ?>" class="ab-group-container"><?php |
|
441 | + foreach ($node->children as $group) { |
|
442 | + $this->_render_group($group); |
|
443 | 443 | } |
444 | 444 | ?></div><?php |
445 | 445 | } |
@@ -447,22 +447,22 @@ discard block |
||
447 | 447 | /** |
448 | 448 | * @param object $node |
449 | 449 | */ |
450 | - final protected function _render_group( $node ) { |
|
451 | - if ( $node->type == 'container' ) { |
|
452 | - $this->_render_container( $node ); |
|
450 | + final protected function _render_group($node) { |
|
451 | + if ($node->type == 'container') { |
|
452 | + $this->_render_container($node); |
|
453 | 453 | return; |
454 | 454 | } |
455 | - if ( $node->type != 'group' || empty( $node->children ) ) |
|
455 | + if ($node->type != 'group' || empty($node->children)) |
|
456 | 456 | return; |
457 | 457 | |
458 | - if ( ! empty( $node->meta['class'] ) ) |
|
459 | - $class = ' class="' . esc_attr( trim( $node->meta['class'] ) ) . '"'; |
|
458 | + if ( ! empty($node->meta['class'])) |
|
459 | + $class = ' class="'.esc_attr(trim($node->meta['class'])).'"'; |
|
460 | 460 | else |
461 | 461 | $class = ''; |
462 | 462 | |
463 | - ?><ul id="<?php echo esc_attr( 'wp-admin-bar-' . $node->id ); ?>"<?php echo $class; ?>><?php |
|
464 | - foreach ( $node->children as $item ) { |
|
465 | - $this->_render_item( $item ); |
|
463 | + ?><ul id="<?php echo esc_attr('wp-admin-bar-'.$node->id); ?>"<?php echo $class; ?>><?php |
|
464 | + foreach ($node->children as $item) { |
|
465 | + $this->_render_item($item); |
|
466 | 466 | } |
467 | 467 | ?></ul><?php |
468 | 468 | } |
@@ -470,85 +470,85 @@ discard block |
||
470 | 470 | /** |
471 | 471 | * @param object $node |
472 | 472 | */ |
473 | - final protected function _render_item( $node ) { |
|
474 | - if ( $node->type != 'item' ) |
|
473 | + final protected function _render_item($node) { |
|
474 | + if ($node->type != 'item') |
|
475 | 475 | return; |
476 | 476 | |
477 | - $is_parent = ! empty( $node->children ); |
|
478 | - $has_link = ! empty( $node->href ); |
|
477 | + $is_parent = ! empty($node->children); |
|
478 | + $has_link = ! empty($node->href); |
|
479 | 479 | |
480 | 480 | // Allow only numeric values, then casted to integers, and allow a tabindex value of `0` for a11y. |
481 | - $tabindex = ( isset( $node->meta['tabindex'] ) && is_numeric( $node->meta['tabindex'] ) ) ? (int) $node->meta['tabindex'] : ''; |
|
482 | - $aria_attributes = ( '' !== $tabindex ) ? ' tabindex="' . $tabindex . '"' : ''; |
|
481 | + $tabindex = (isset($node->meta['tabindex']) && is_numeric($node->meta['tabindex'])) ? (int) $node->meta['tabindex'] : ''; |
|
482 | + $aria_attributes = ('' !== $tabindex) ? ' tabindex="'.$tabindex.'"' : ''; |
|
483 | 483 | |
484 | 484 | $menuclass = ''; |
485 | 485 | |
486 | - if ( $is_parent ) { |
|
486 | + if ($is_parent) { |
|
487 | 487 | $menuclass = 'menupop '; |
488 | 488 | $aria_attributes .= ' aria-haspopup="true"'; |
489 | 489 | } |
490 | 490 | |
491 | - if ( ! empty( $node->meta['class'] ) ) |
|
491 | + if ( ! empty($node->meta['class'])) |
|
492 | 492 | $menuclass .= $node->meta['class']; |
493 | 493 | |
494 | - if ( $menuclass ) |
|
495 | - $menuclass = ' class="' . esc_attr( trim( $menuclass ) ) . '"'; |
|
494 | + if ($menuclass) |
|
495 | + $menuclass = ' class="'.esc_attr(trim($menuclass)).'"'; |
|
496 | 496 | |
497 | 497 | ?> |
498 | 498 | |
499 | - <li id="<?php echo esc_attr( 'wp-admin-bar-' . $node->id ); ?>"<?php echo $menuclass; ?>><?php |
|
500 | - if ( $has_link ): |
|
501 | - ?><a class="ab-item"<?php echo $aria_attributes; ?> href="<?php echo esc_url( $node->href ) ?>"<?php |
|
502 | - if ( ! empty( $node->meta['onclick'] ) ) : |
|
503 | - ?> onclick="<?php echo esc_js( $node->meta['onclick'] ); ?>"<?php |
|
499 | + <li id="<?php echo esc_attr('wp-admin-bar-'.$node->id); ?>"<?php echo $menuclass; ?>><?php |
|
500 | + if ($has_link): |
|
501 | + ?><a class="ab-item"<?php echo $aria_attributes; ?> href="<?php echo esc_url($node->href) ?>"<?php |
|
502 | + if ( ! empty($node->meta['onclick'])) : |
|
503 | + ?> onclick="<?php echo esc_js($node->meta['onclick']); ?>"<?php |
|
504 | 504 | endif; |
505 | - if ( ! empty( $node->meta['target'] ) ) : |
|
506 | - ?> target="<?php echo esc_attr( $node->meta['target'] ); ?>"<?php |
|
505 | + if ( ! empty($node->meta['target'])) : |
|
506 | + ?> target="<?php echo esc_attr($node->meta['target']); ?>"<?php |
|
507 | 507 | endif; |
508 | - if ( ! empty( $node->meta['title'] ) ) : |
|
509 | - ?> title="<?php echo esc_attr( $node->meta['title'] ); ?>"<?php |
|
508 | + if ( ! empty($node->meta['title'])) : |
|
509 | + ?> title="<?php echo esc_attr($node->meta['title']); ?>"<?php |
|
510 | 510 | endif; |
511 | - if ( ! empty( $node->meta['rel'] ) ) : |
|
512 | - ?> rel="<?php echo esc_attr( $node->meta['rel'] ); ?>"<?php |
|
511 | + if ( ! empty($node->meta['rel'])) : |
|
512 | + ?> rel="<?php echo esc_attr($node->meta['rel']); ?>"<?php |
|
513 | 513 | endif; |
514 | - if ( ! empty( $node->meta['lang'] ) ) : |
|
515 | - ?> lang="<?php echo esc_attr( $node->meta['lang'] ); ?>"<?php |
|
514 | + if ( ! empty($node->meta['lang'])) : |
|
515 | + ?> lang="<?php echo esc_attr($node->meta['lang']); ?>"<?php |
|
516 | 516 | endif; |
517 | - if ( ! empty( $node->meta['dir'] ) ) : |
|
518 | - ?> dir="<?php echo esc_attr( $node->meta['dir'] ); ?>"<?php |
|
517 | + if ( ! empty($node->meta['dir'])) : |
|
518 | + ?> dir="<?php echo esc_attr($node->meta['dir']); ?>"<?php |
|
519 | 519 | endif; |
520 | 520 | ?>><?php |
521 | 521 | else: |
522 | 522 | ?><div class="ab-item ab-empty-item"<?php echo $aria_attributes; |
523 | - if ( ! empty( $node->meta['title'] ) ) : |
|
524 | - ?> title="<?php echo esc_attr( $node->meta['title'] ); ?>"<?php |
|
523 | + if ( ! empty($node->meta['title'])) : |
|
524 | + ?> title="<?php echo esc_attr($node->meta['title']); ?>"<?php |
|
525 | 525 | endif; |
526 | - if ( ! empty( $node->meta['lang'] ) ) : |
|
527 | - ?> lang="<?php echo esc_attr( $node->meta['lang'] ); ?>"<?php |
|
526 | + if ( ! empty($node->meta['lang'])) : |
|
527 | + ?> lang="<?php echo esc_attr($node->meta['lang']); ?>"<?php |
|
528 | 528 | endif; |
529 | - if ( ! empty( $node->meta['dir'] ) ) : |
|
530 | - ?> dir="<?php echo esc_attr( $node->meta['dir'] ); ?>"<?php |
|
529 | + if ( ! empty($node->meta['dir'])) : |
|
530 | + ?> dir="<?php echo esc_attr($node->meta['dir']); ?>"<?php |
|
531 | 531 | endif; |
532 | 532 | ?>><?php |
533 | 533 | endif; |
534 | 534 | |
535 | 535 | echo $node->title; |
536 | 536 | |
537 | - if ( $has_link ) : |
|
537 | + if ($has_link) : |
|
538 | 538 | ?></a><?php |
539 | 539 | else: |
540 | 540 | ?></div><?php |
541 | 541 | endif; |
542 | 542 | |
543 | - if ( $is_parent ) : |
|
543 | + if ($is_parent) : |
|
544 | 544 | ?><div class="ab-sub-wrapper"><?php |
545 | - foreach ( $node->children as $group ) { |
|
546 | - $this->_render_group( $group ); |
|
545 | + foreach ($node->children as $group) { |
|
546 | + $this->_render_group($group); |
|
547 | 547 | } |
548 | 548 | ?></div><?php |
549 | 549 | endif; |
550 | 550 | |
551 | - if ( ! empty( $node->meta['html'] ) ) |
|
551 | + if ( ! empty($node->meta['html'])) |
|
552 | 552 | echo $node->meta['html']; |
553 | 553 | |
554 | 554 | ?> |
@@ -559,9 +559,9 @@ discard block |
||
559 | 559 | * @param string $id Unused. |
560 | 560 | * @param object $node |
561 | 561 | */ |
562 | - public function recursive_render( $id, $node ) { |
|
563 | - _deprecated_function( __METHOD__, '3.3.0', 'WP_Admin_bar::render(), WP_Admin_Bar::_render_item()' ); |
|
564 | - $this->_render_item( $node ); |
|
562 | + public function recursive_render($id, $node) { |
|
563 | + _deprecated_function(__METHOD__, '3.3.0', 'WP_Admin_bar::render(), WP_Admin_Bar::_render_item()'); |
|
564 | + $this->_render_item($node); |
|
565 | 565 | } |
566 | 566 | |
567 | 567 | /** |
@@ -569,32 +569,32 @@ discard block |
||
569 | 569 | */ |
570 | 570 | public function add_menus() { |
571 | 571 | // User related, aligned right. |
572 | - add_action( 'admin_bar_menu', 'wp_admin_bar_my_account_menu', 0 ); |
|
573 | - add_action( 'admin_bar_menu', 'wp_admin_bar_search_menu', 4 ); |
|
574 | - add_action( 'admin_bar_menu', 'wp_admin_bar_my_account_item', 7 ); |
|
572 | + add_action('admin_bar_menu', 'wp_admin_bar_my_account_menu', 0); |
|
573 | + add_action('admin_bar_menu', 'wp_admin_bar_search_menu', 4); |
|
574 | + add_action('admin_bar_menu', 'wp_admin_bar_my_account_item', 7); |
|
575 | 575 | |
576 | 576 | // Site related. |
577 | - add_action( 'admin_bar_menu', 'wp_admin_bar_sidebar_toggle', 0 ); |
|
578 | - add_action( 'admin_bar_menu', 'wp_admin_bar_wp_menu', 10 ); |
|
579 | - add_action( 'admin_bar_menu', 'wp_admin_bar_my_sites_menu', 20 ); |
|
580 | - add_action( 'admin_bar_menu', 'wp_admin_bar_site_menu', 30 ); |
|
581 | - add_action( 'admin_bar_menu', 'wp_admin_bar_customize_menu', 40 ); |
|
582 | - add_action( 'admin_bar_menu', 'wp_admin_bar_updates_menu', 50 ); |
|
577 | + add_action('admin_bar_menu', 'wp_admin_bar_sidebar_toggle', 0); |
|
578 | + add_action('admin_bar_menu', 'wp_admin_bar_wp_menu', 10); |
|
579 | + add_action('admin_bar_menu', 'wp_admin_bar_my_sites_menu', 20); |
|
580 | + add_action('admin_bar_menu', 'wp_admin_bar_site_menu', 30); |
|
581 | + add_action('admin_bar_menu', 'wp_admin_bar_customize_menu', 40); |
|
582 | + add_action('admin_bar_menu', 'wp_admin_bar_updates_menu', 50); |
|
583 | 583 | |
584 | 584 | // Content related. |
585 | - if ( ! is_network_admin() && ! is_user_admin() ) { |
|
586 | - add_action( 'admin_bar_menu', 'wp_admin_bar_comments_menu', 60 ); |
|
587 | - add_action( 'admin_bar_menu', 'wp_admin_bar_new_content_menu', 70 ); |
|
585 | + if ( ! is_network_admin() && ! is_user_admin()) { |
|
586 | + add_action('admin_bar_menu', 'wp_admin_bar_comments_menu', 60); |
|
587 | + add_action('admin_bar_menu', 'wp_admin_bar_new_content_menu', 70); |
|
588 | 588 | } |
589 | - add_action( 'admin_bar_menu', 'wp_admin_bar_edit_menu', 80 ); |
|
589 | + add_action('admin_bar_menu', 'wp_admin_bar_edit_menu', 80); |
|
590 | 590 | |
591 | - add_action( 'admin_bar_menu', 'wp_admin_bar_add_secondary_groups', 200 ); |
|
591 | + add_action('admin_bar_menu', 'wp_admin_bar_add_secondary_groups', 200); |
|
592 | 592 | |
593 | 593 | /** |
594 | 594 | * Fires after menus are added to the menu bar. |
595 | 595 | * |
596 | 596 | * @since 3.1.0 |
597 | 597 | */ |
598 | - do_action( 'add_admin_bar_menus' ); |
|
598 | + do_action('add_admin_bar_menus'); |
|
599 | 599 | } |
600 | 600 | } |
@@ -65,8 +65,9 @@ discard block |
||
65 | 65 | $header_callback = $admin_bar_args[0]['callback']; |
66 | 66 | } |
67 | 67 | |
68 | - if ( empty($header_callback) ) |
|
69 | - $header_callback = '_admin_bar_bump_cb'; |
|
68 | + if ( empty($header_callback) ) { |
|
69 | + $header_callback = '_admin_bar_bump_cb'; |
|
70 | + } |
|
70 | 71 | |
71 | 72 | add_action('wp_head', $header_callback); |
72 | 73 | |
@@ -116,16 +117,19 @@ discard block |
||
116 | 117 | */ |
117 | 118 | public function add_node( $args ) { |
118 | 119 | // Shim for old method signature: add_node( $parent_id, $menu_obj, $args ) |
119 | - if ( func_num_args() >= 3 && is_string( func_get_arg(0) ) ) |
|
120 | - $args = array_merge( array( 'parent' => func_get_arg(0) ), func_get_arg(2) ); |
|
120 | + if ( func_num_args() >= 3 && is_string( func_get_arg(0) ) ) { |
|
121 | + $args = array_merge( array( 'parent' => func_get_arg(0) ), func_get_arg(2) ); |
|
122 | + } |
|
121 | 123 | |
122 | - if ( is_object( $args ) ) |
|
123 | - $args = get_object_vars( $args ); |
|
124 | + if ( is_object( $args ) ) { |
|
125 | + $args = get_object_vars( $args ); |
|
126 | + } |
|
124 | 127 | |
125 | 128 | // Ensure we have a valid title. |
126 | 129 | if ( empty( $args['id'] ) ) { |
127 | - if ( empty( $args['title'] ) ) |
|
128 | - return; |
|
130 | + if ( empty( $args['title'] ) ) { |
|
131 | + return; |
|
132 | + } |
|
129 | 133 | |
130 | 134 | _doing_it_wrong( __METHOD__, __( 'The menu ID should not be empty.' ), '3.3.0' ); |
131 | 135 | // Deprecated: Generate an ID from the title. |
@@ -142,12 +146,14 @@ discard block |
||
142 | 146 | ); |
143 | 147 | |
144 | 148 | // If the node already exists, keep any data that isn't provided. |
145 | - if ( $maybe_defaults = $this->get_node( $args['id'] ) ) |
|
146 | - $defaults = get_object_vars( $maybe_defaults ); |
|
149 | + if ( $maybe_defaults = $this->get_node( $args['id'] ) ) { |
|
150 | + $defaults = get_object_vars( $maybe_defaults ); |
|
151 | + } |
|
147 | 152 | |
148 | 153 | // Do the same for 'meta' items. |
149 | - if ( ! empty( $defaults['meta'] ) && ! empty( $args['meta'] ) ) |
|
150 | - $args['meta'] = wp_parse_args( $args['meta'], $defaults['meta'] ); |
|
154 | + if ( ! empty( $defaults['meta'] ) && ! empty( $args['meta'] ) ) { |
|
155 | + $args['meta'] = wp_parse_args( $args['meta'], $defaults['meta'] ); |
|
156 | + } |
|
151 | 157 | |
152 | 158 | $args = wp_parse_args( $args, $defaults ); |
153 | 159 | |
@@ -179,8 +185,9 @@ discard block |
||
179 | 185 | * @return object Node. |
180 | 186 | */ |
181 | 187 | final public function get_node( $id ) { |
182 | - if ( $node = $this->_get_node( $id ) ) |
|
183 | - return clone $node; |
|
188 | + if ( $node = $this->_get_node( $id ) ) { |
|
189 | + return clone $node; |
|
190 | + } |
|
184 | 191 | } |
185 | 192 | |
186 | 193 | /** |
@@ -188,22 +195,26 @@ discard block |
||
188 | 195 | * @return object|void |
189 | 196 | */ |
190 | 197 | final protected function _get_node( $id ) { |
191 | - if ( $this->bound ) |
|
192 | - return; |
|
198 | + if ( $this->bound ) { |
|
199 | + return; |
|
200 | + } |
|
193 | 201 | |
194 | - if ( empty( $id ) ) |
|
195 | - $id = 'root'; |
|
202 | + if ( empty( $id ) ) { |
|
203 | + $id = 'root'; |
|
204 | + } |
|
196 | 205 | |
197 | - if ( isset( $this->nodes[ $id ] ) ) |
|
198 | - return $this->nodes[ $id ]; |
|
206 | + if ( isset( $this->nodes[ $id ] ) ) { |
|
207 | + return $this->nodes[ $id ]; |
|
208 | + } |
|
199 | 209 | } |
200 | 210 | |
201 | 211 | /** |
202 | 212 | * @return array|void |
203 | 213 | */ |
204 | 214 | final public function get_nodes() { |
205 | - if ( ! $nodes = $this->_get_nodes() ) |
|
206 | - return; |
|
215 | + if ( ! $nodes = $this->_get_nodes() ) { |
|
216 | + return; |
|
217 | + } |
|
207 | 218 | |
208 | 219 | foreach ( $nodes as &$node ) { |
209 | 220 | $node = clone $node; |
@@ -215,8 +226,9 @@ discard block |
||
215 | 226 | * @return array|void |
216 | 227 | */ |
217 | 228 | final protected function _get_nodes() { |
218 | - if ( $this->bound ) |
|
219 | - return; |
|
229 | + if ( $this->bound ) { |
|
230 | + return; |
|
231 | + } |
|
220 | 232 | |
221 | 233 | return $this->nodes; |
222 | 234 | } |
@@ -262,16 +274,18 @@ discard block |
||
262 | 274 | */ |
263 | 275 | public function render() { |
264 | 276 | $root = $this->_bind(); |
265 | - if ( $root ) |
|
266 | - $this->_render( $root ); |
|
277 | + if ( $root ) { |
|
278 | + $this->_render( $root ); |
|
279 | + } |
|
267 | 280 | } |
268 | 281 | |
269 | 282 | /** |
270 | 283 | * @return object|void |
271 | 284 | */ |
272 | 285 | final protected function _bind() { |
273 | - if ( $this->bound ) |
|
274 | - return; |
|
286 | + if ( $this->bound ) { |
|
287 | + return; |
|
288 | + } |
|
275 | 289 | |
276 | 290 | // Add the root node. |
277 | 291 | // Clear it first, just in case. Don't mess with The Root. |
@@ -288,13 +302,15 @@ discard block |
||
288 | 302 | unset( $node->group ); |
289 | 303 | |
290 | 304 | // The Root wants your orphans. No lonely items allowed. |
291 | - if ( ! $node->parent ) |
|
292 | - $node->parent = 'root'; |
|
305 | + if ( ! $node->parent ) { |
|
306 | + $node->parent = 'root'; |
|
307 | + } |
|
293 | 308 | } |
294 | 309 | |
295 | 310 | foreach ( $this->_get_nodes() as $node ) { |
296 | - if ( 'root' == $node->id ) |
|
297 | - continue; |
|
311 | + if ( 'root' == $node->id ) { |
|
312 | + continue; |
|
313 | + } |
|
298 | 314 | |
299 | 315 | // Fetch the parent node. If it isn't registered, ignore the node. |
300 | 316 | if ( ! $parent = $this->_get_node( $node->parent ) ) { |
@@ -305,10 +321,11 @@ discard block |
||
305 | 321 | $group_class = ( $node->parent == 'root' ) ? 'ab-top-menu' : 'ab-submenu'; |
306 | 322 | |
307 | 323 | if ( $node->type == 'group' ) { |
308 | - if ( empty( $node->meta['class'] ) ) |
|
309 | - $node->meta['class'] = $group_class; |
|
310 | - else |
|
311 | - $node->meta['class'] .= ' ' . $group_class; |
|
324 | + if ( empty( $node->meta['class'] ) ) { |
|
325 | + $node->meta['class'] = $group_class; |
|
326 | + } else { |
|
327 | + $node->meta['class'] .= ' ' . $group_class; |
|
328 | + } |
|
312 | 329 | } |
313 | 330 | |
314 | 331 | // Items in items aren't allowed. Wrap nested items in 'default' groups. |
@@ -366,10 +383,11 @@ discard block |
||
366 | 383 | $container->parent = $grandparent->id; |
367 | 384 | |
368 | 385 | $index = array_search( $parent, $grandparent->children, true ); |
369 | - if ( $index === false ) |
|
370 | - $grandparent->children[] = $container; |
|
371 | - else |
|
372 | - array_splice( $grandparent->children, $index, 1, array( $container ) ); |
|
386 | + if ( $index === false ) { |
|
387 | + $grandparent->children[] = $container; |
|
388 | + } else { |
|
389 | + array_splice( $grandparent->children, $index, 1, array( $container ) ); |
|
390 | + } |
|
373 | 391 | } |
374 | 392 | |
375 | 393 | $parent->parent = $container->id; |
@@ -402,12 +420,13 @@ discard block |
||
402 | 420 | // We have to do this here since admin bar shows on the front end. |
403 | 421 | $class = 'nojq nojs'; |
404 | 422 | if ( $is_IE ) { |
405 | - if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE 7' ) ) |
|
406 | - $class .= ' ie7'; |
|
407 | - elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE 8' ) ) |
|
408 | - $class .= ' ie8'; |
|
409 | - elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE 9' ) ) |
|
410 | - $class .= ' ie9'; |
|
423 | + if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE 7' ) ) { |
|
424 | + $class .= ' ie7'; |
|
425 | + } elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE 8' ) ) { |
|
426 | + $class .= ' ie8'; |
|
427 | + } elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE 9' ) ) { |
|
428 | + $class .= ' ie9'; |
|
429 | + } |
|
411 | 430 | } elseif ( wp_is_mobile() ) { |
412 | 431 | $class .= ' mobile'; |
413 | 432 | } |
@@ -434,8 +453,9 @@ discard block |
||
434 | 453 | * @param object $node |
435 | 454 | */ |
436 | 455 | final protected function _render_container( $node ) { |
437 | - if ( $node->type != 'container' || empty( $node->children ) ) |
|
438 | - return; |
|
456 | + if ( $node->type != 'container' || empty( $node->children ) ) { |
|
457 | + return; |
|
458 | + } |
|
439 | 459 | |
440 | 460 | ?><div id="<?php echo esc_attr( 'wp-admin-bar-' . $node->id ); ?>" class="ab-group-container"><?php |
441 | 461 | foreach ( $node->children as $group ) { |
@@ -452,13 +472,15 @@ discard block |
||
452 | 472 | $this->_render_container( $node ); |
453 | 473 | return; |
454 | 474 | } |
455 | - if ( $node->type != 'group' || empty( $node->children ) ) |
|
456 | - return; |
|
475 | + if ( $node->type != 'group' || empty( $node->children ) ) { |
|
476 | + return; |
|
477 | + } |
|
457 | 478 | |
458 | - if ( ! empty( $node->meta['class'] ) ) |
|
459 | - $class = ' class="' . esc_attr( trim( $node->meta['class'] ) ) . '"'; |
|
460 | - else |
|
461 | - $class = ''; |
|
479 | + if ( ! empty( $node->meta['class'] ) ) { |
|
480 | + $class = ' class="' . esc_attr( trim( $node->meta['class'] ) ) . '"'; |
|
481 | + } else { |
|
482 | + $class = ''; |
|
483 | + } |
|
462 | 484 | |
463 | 485 | ?><ul id="<?php echo esc_attr( 'wp-admin-bar-' . $node->id ); ?>"<?php echo $class; ?>><?php |
464 | 486 | foreach ( $node->children as $item ) { |
@@ -471,8 +493,9 @@ discard block |
||
471 | 493 | * @param object $node |
472 | 494 | */ |
473 | 495 | final protected function _render_item( $node ) { |
474 | - if ( $node->type != 'item' ) |
|
475 | - return; |
|
496 | + if ( $node->type != 'item' ) { |
|
497 | + return; |
|
498 | + } |
|
476 | 499 | |
477 | 500 | $is_parent = ! empty( $node->children ); |
478 | 501 | $has_link = ! empty( $node->href ); |
@@ -488,11 +511,13 @@ discard block |
||
488 | 511 | $aria_attributes .= ' aria-haspopup="true"'; |
489 | 512 | } |
490 | 513 | |
491 | - if ( ! empty( $node->meta['class'] ) ) |
|
492 | - $menuclass .= $node->meta['class']; |
|
514 | + if ( ! empty( $node->meta['class'] ) ) { |
|
515 | + $menuclass .= $node->meta['class']; |
|
516 | + } |
|
493 | 517 | |
494 | - if ( $menuclass ) |
|
495 | - $menuclass = ' class="' . esc_attr( trim( $menuclass ) ) . '"'; |
|
518 | + if ( $menuclass ) { |
|
519 | + $menuclass = ' class="' . esc_attr( trim( $menuclass ) ) . '"'; |
|
520 | + } |
|
496 | 521 | |
497 | 522 | ?> |
498 | 523 | |
@@ -518,8 +543,10 @@ discard block |
||
518 | 543 | ?> dir="<?php echo esc_attr( $node->meta['dir'] ); ?>"<?php |
519 | 544 | endif; |
520 | 545 | ?>><?php |
521 | - else: |
|
546 | + else { |
|
547 | + : |
|
522 | 548 | ?><div class="ab-item ab-empty-item"<?php echo $aria_attributes; |
549 | + } |
|
523 | 550 | if ( ! empty( $node->meta['title'] ) ) : |
524 | 551 | ?> title="<?php echo esc_attr( $node->meta['title'] ); ?>"<?php |
525 | 552 | endif; |
@@ -536,9 +563,11 @@ discard block |
||
536 | 563 | |
537 | 564 | if ( $has_link ) : |
538 | 565 | ?></a><?php |
539 | - else: |
|
566 | + else { |
|
567 | + : |
|
540 | 568 | ?></div><?php |
541 | 569 | endif; |
570 | + } |
|
542 | 571 | |
543 | 572 | if ( $is_parent ) : |
544 | 573 | ?><div class="ab-sub-wrapper"><?php |
@@ -548,8 +577,9 @@ discard block |
||
548 | 577 | ?></div><?php |
549 | 578 | endif; |
550 | 579 | |
551 | - if ( ! empty( $node->meta['html'] ) ) |
|
552 | - echo $node->meta['html']; |
|
580 | + if ( ! empty( $node->meta['html'] ) ) { |
|
581 | + echo $node->meta['html']; |
|
582 | + } |
|
553 | 583 | |
554 | 584 | ?> |
555 | 585 | </li><?php |
@@ -8,6 +8,6 @@ |
||
8 | 8 | * @deprecated 4.5.0 Moved to wp-includes/theme-compat/embed.php |
9 | 9 | */ |
10 | 10 | |
11 | -_deprecated_file( basename( __FILE__ ), '4.5.0', 'wp-includes/theme-compat/embed.php' ); |
|
11 | +_deprecated_file(basename(__FILE__), '4.5.0', 'wp-includes/theme-compat/embed.php'); |
|
12 | 12 | |
13 | -include( ABSPATH . WPINC . '/theme-compat/embed.php' ); |
|
13 | +include(ABSPATH.WPINC.'/theme-compat/embed.php'); |
@@ -5,5 +5,5 @@ |
||
5 | 5 | * @package WordPress |
6 | 6 | */ |
7 | 7 | |
8 | -_deprecated_file( basename(__FILE__), '2.1.0', WPINC . '/rss.php' ); |
|
9 | -require_once( ABSPATH . WPINC . '/rss.php' ); |
|
8 | +_deprecated_file(basename(__FILE__), '2.1.0', WPINC.'/rss.php'); |
|
9 | +require_once(ABSPATH.WPINC.'/rss.php'); |
@@ -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.0', 'wp_set_current_user()' ); |
|
33 | + _deprecated_function(__FUNCTION__, '3.0.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.0', 'wp_get_current_user()' ); |
|
49 | + _deprecated_function(__FUNCTION__, '4.5.0', '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.0', "get_user_by('login')" ); |
|
67 | + _deprecated_function(__FUNCTION__, '3.3.0', "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.0', "get_user_by('email')" ); |
|
84 | + _deprecated_function(__FUNCTION__, '3.3.0', "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.0', 'wp_set_auth_cookie()' ); |
|
105 | + _deprecated_function(__FUNCTION__, '2.5.0', '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.0', 'wp_set_auth_cookie()' ); |
|
110 | + _deprecated_function('wp_setcookie', '2.5.0', '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.0', 'wp_clear_auth_cookie()' ); |
|
122 | + _deprecated_function(__FUNCTION__, '2.5.0', 'wp_clear_auth_cookie()'); |
|
123 | 123 | wp_clear_auth_cookie(); |
124 | 124 | } |
125 | 125 | else : |
126 | - _deprecated_function( 'wp_clearcookie', '2.5.0', 'wp_clear_auth_cookie()' ); |
|
126 | + _deprecated_function('wp_clearcookie', '2.5.0', '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.0' ); |
|
142 | + _deprecated_function(__FUNCTION__, '2.5.0'); |
|
143 | 143 | return false; |
144 | 144 | } |
145 | 145 | else : |
146 | - _deprecated_function( 'wp_get_cookie_login', '2.5.0' ); |
|
146 | + _deprecated_function('wp_get_cookie_login', '2.5.0'); |
|
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.0', 'wp_signon()' ); |
|
172 | + _deprecated_function(__FUNCTION__, '2.5.0', '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.0', 'wp_signon()' ); |
|
184 | + _deprecated_function('wp_login', '2.5.0', '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.0', 'the Atom Publishing Protocol plugin' ); |
|
200 | + public function __call($name, $arguments) { |
|
201 | + _deprecated_function(__CLASS__.'::'.$name, '3.5.0', 'the Atom Publishing Protocol plugin'); |
|
202 | 202 | } |
203 | 203 | |
204 | - public static function __callStatic( $name, $arguments ) { |
|
205 | - _deprecated_function( __CLASS__ . '::' . $name, '3.5.0', 'the Atom Publishing Protocol plugin' ); |
|
204 | + public static function __callStatic($name, $arguments) { |
|
205 | + _deprecated_function(__CLASS__.'::'.$name, '3.5.0', 'the Atom Publishing Protocol plugin'); |
|
206 | 206 | } |
207 | 207 | } |
208 | 208 | } |
@@ -105,9 +105,10 @@ discard block |
||
105 | 105 | _deprecated_function( __FUNCTION__, '2.5.0', 'wp_set_auth_cookie()' ); |
106 | 106 | $user = get_user_by('login', $username); |
107 | 107 | wp_set_auth_cookie($user->ID, $remember); |
108 | -} |
|
109 | -else : |
|
108 | +} else { |
|
109 | + : |
|
110 | 110 | _deprecated_function( 'wp_setcookie', '2.5.0', 'wp_set_auth_cookie()' ); |
111 | +} |
|
111 | 112 | endif; |
112 | 113 | |
113 | 114 | if ( !function_exists('wp_clearcookie') ) : |
@@ -121,9 +122,10 @@ discard block |
||
121 | 122 | function wp_clearcookie() { |
122 | 123 | _deprecated_function( __FUNCTION__, '2.5.0', 'wp_clear_auth_cookie()' ); |
123 | 124 | wp_clear_auth_cookie(); |
124 | -} |
|
125 | -else : |
|
125 | +} else { |
|
126 | + : |
|
126 | 127 | _deprecated_function( 'wp_clearcookie', '2.5.0', 'wp_clear_auth_cookie()' ); |
128 | +} |
|
127 | 129 | endif; |
128 | 130 | |
129 | 131 | if ( !function_exists('wp_get_cookie_login') ): |
@@ -141,9 +143,10 @@ discard block |
||
141 | 143 | function wp_get_cookie_login() { |
142 | 144 | _deprecated_function( __FUNCTION__, '2.5.0' ); |
143 | 145 | return false; |
144 | -} |
|
145 | -else : |
|
146 | +} else { |
|
147 | + : |
|
146 | 148 | _deprecated_function( 'wp_get_cookie_login', '2.5.0' ); |
149 | +} |
|
147 | 150 | endif; |
148 | 151 | |
149 | 152 | if ( !function_exists('wp_login') ) : |
@@ -174,14 +177,16 @@ discard block |
||
174 | 177 | |
175 | 178 | $user = wp_authenticate($username, $password); |
176 | 179 | |
177 | - if ( ! is_wp_error($user) ) |
|
178 | - return true; |
|
180 | + if ( ! is_wp_error($user) ) { |
|
181 | + return true; |
|
182 | + } |
|
179 | 183 | |
180 | 184 | $error = $user->get_error_message(); |
181 | 185 | return false; |
182 | -} |
|
183 | -else : |
|
186 | +} else { |
|
187 | + : |
|
184 | 188 | _deprecated_function( 'wp_login', '2.5.0', 'wp_signon()' ); |
189 | +} |
|
185 | 190 | endif; |
186 | 191 | |
187 | 192 | /** |
@@ -56,28 +56,28 @@ |
||
56 | 56 | * @access public |
57 | 57 | */ |
58 | 58 | public function render_content() { |
59 | - if ( empty( $this->choices ) ) { |
|
59 | + if (empty($this->choices)) { |
|
60 | 60 | return; |
61 | 61 | } |
62 | 62 | ?> |
63 | 63 | <label> |
64 | - <?php if ( ! empty( $this->label ) ) : ?> |
|
65 | - <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span> |
|
64 | + <?php if ( ! empty($this->label)) : ?> |
|
65 | + <span class="customize-control-title"><?php echo esc_html($this->label); ?></span> |
|
66 | 66 | <?php endif; ?> |
67 | 67 | |
68 | - <?php if ( ! empty( $this->description ) ) : ?> |
|
68 | + <?php if ( ! empty($this->description)) : ?> |
|
69 | 69 | <span class="description customize-control-description"><?php echo $this->description; ?></span> |
70 | 70 | <?php endif; ?> |
71 | 71 | |
72 | 72 | <select <?php $this->link(); ?>> |
73 | 73 | <?php |
74 | - foreach ( $this->choices as $value => $label ) : |
|
75 | - echo '<option value="' . esc_attr( $value ) . '"' . selected( $this->value(), $value, false ) . '>' . $label . '</option>'; |
|
74 | + foreach ($this->choices as $value => $label) : |
|
75 | + echo '<option value="'.esc_attr($value).'"'.selected($this->value(), $value, false).'>'.$label.'</option>'; |
|
76 | 76 | endforeach; |
77 | 77 | ?> |
78 | 78 | </select> |
79 | 79 | </label> |
80 | - <button type="button" class="button-link edit-menu<?php if ( ! $this->value() ) { echo ' hidden'; } ?>" aria-label="<?php esc_attr_e( 'Edit selected menu' ); ?>"><?php _e( 'Edit Menu' ); ?></button> |
|
80 | + <button type="button" class="button-link edit-menu<?php if ( ! $this->value()) { echo ' hidden'; } ?>" aria-label="<?php esc_attr_e('Edit selected menu'); ?>"><?php _e('Edit Menu'); ?></button> |
|
81 | 81 | <?php |
82 | 82 | } |
83 | 83 | } |
@@ -36,7 +36,7 @@ |
||
36 | 36 | */ |
37 | 37 | public function json() { |
38 | 38 | $exported = parent::json(); |
39 | - $exported['menu_id'] = intval( preg_replace( '/^nav_menu\[(-?\d+)\]/', '$1', $this->id ) ); |
|
39 | + $exported['menu_id'] = intval(preg_replace('/^nav_menu\[(-?\d+)\]/', '$1', $this->id)); |
|
40 | 40 | |
41 | 41 | return $exported; |
42 | 42 | } |