@@ -36,29 +36,29 @@ discard block |
||
36 | 36 | * |
37 | 37 | * @param array $args An associative array of arguments. |
38 | 38 | */ |
39 | - public function __construct( $args = array() ) { |
|
39 | + public function __construct($args = array()) { |
|
40 | 40 | global $post_type, $taxonomy, $action, $tax; |
41 | 41 | |
42 | - parent::__construct( array( |
|
42 | + parent::__construct(array( |
|
43 | 43 | 'plural' => 'tags', |
44 | 44 | 'singular' => 'tag', |
45 | - 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
|
46 | - ) ); |
|
45 | + 'screen' => isset($args['screen']) ? $args['screen'] : null, |
|
46 | + )); |
|
47 | 47 | |
48 | 48 | $action = $this->screen->action; |
49 | 49 | $post_type = $this->screen->post_type; |
50 | 50 | $taxonomy = $this->screen->taxonomy; |
51 | 51 | |
52 | - if ( empty( $taxonomy ) ) |
|
52 | + if (empty($taxonomy)) |
|
53 | 53 | $taxonomy = 'post_tag'; |
54 | 54 | |
55 | - if ( ! taxonomy_exists( $taxonomy ) ) |
|
56 | - wp_die( __( 'Invalid taxonomy.' ) ); |
|
55 | + if ( ! taxonomy_exists($taxonomy)) |
|
56 | + wp_die(__('Invalid taxonomy.')); |
|
57 | 57 | |
58 | - $tax = get_taxonomy( $taxonomy ); |
|
58 | + $tax = get_taxonomy($taxonomy); |
|
59 | 59 | |
60 | 60 | // @todo Still needed? Maybe just the show_ui part. |
61 | - if ( empty( $post_type ) || !in_array( $post_type, get_post_types( array( 'show_ui' => true ) ) ) ) |
|
61 | + if (empty($post_type) || ! in_array($post_type, get_post_types(array('show_ui' => true)))) |
|
62 | 62 | $post_type = 'post'; |
63 | 63 | |
64 | 64 | } |
@@ -68,16 +68,16 @@ discard block |
||
68 | 68 | * @return bool |
69 | 69 | */ |
70 | 70 | public function ajax_user_can() { |
71 | - return current_user_can( get_taxonomy( $this->screen->taxonomy )->cap->manage_terms ); |
|
71 | + return current_user_can(get_taxonomy($this->screen->taxonomy)->cap->manage_terms); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
75 | 75 | * @access public |
76 | 76 | */ |
77 | 77 | public function prepare_items() { |
78 | - $tags_per_page = $this->get_items_per_page( 'edit_' . $this->screen->taxonomy . '_per_page' ); |
|
78 | + $tags_per_page = $this->get_items_per_page('edit_'.$this->screen->taxonomy.'_per_page'); |
|
79 | 79 | |
80 | - if ( 'post_tag' === $this->screen->taxonomy ) { |
|
80 | + if ('post_tag' === $this->screen->taxonomy) { |
|
81 | 81 | /** |
82 | 82 | * Filters the number of terms displayed per page for the Tags list table. |
83 | 83 | * |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @param int $tags_per_page Number of tags to be displayed. Default 20. |
87 | 87 | */ |
88 | - $tags_per_page = apply_filters( 'edit_tags_per_page', $tags_per_page ); |
|
88 | + $tags_per_page = apply_filters('edit_tags_per_page', $tags_per_page); |
|
89 | 89 | |
90 | 90 | /** |
91 | 91 | * Filters the number of terms displayed per page for the Tags list table. |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | * |
96 | 96 | * @param int $tags_per_page Number of tags to be displayed. Default 20. |
97 | 97 | */ |
98 | - $tags_per_page = apply_filters( 'tagsperpage', $tags_per_page ); |
|
99 | - } elseif ( 'category' === $this->screen->taxonomy ) { |
|
98 | + $tags_per_page = apply_filters('tagsperpage', $tags_per_page); |
|
99 | + } elseif ('category' === $this->screen->taxonomy) { |
|
100 | 100 | /** |
101 | 101 | * Filters the number of terms displayed per page for the Categories list table. |
102 | 102 | * |
@@ -104,10 +104,10 @@ discard block |
||
104 | 104 | * |
105 | 105 | * @param int $tags_per_page Number of categories to be displayed. Default 20. |
106 | 106 | */ |
107 | - $tags_per_page = apply_filters( 'edit_categories_per_page', $tags_per_page ); |
|
107 | + $tags_per_page = apply_filters('edit_categories_per_page', $tags_per_page); |
|
108 | 108 | } |
109 | 109 | |
110 | - $search = !empty( $_REQUEST['s'] ) ? trim( wp_unslash( $_REQUEST['s'] ) ) : ''; |
|
110 | + $search = ! empty($_REQUEST['s']) ? trim(wp_unslash($_REQUEST['s'])) : ''; |
|
111 | 111 | |
112 | 112 | $args = array( |
113 | 113 | 'search' => $search, |
@@ -115,18 +115,18 @@ discard block |
||
115 | 115 | 'number' => $tags_per_page, |
116 | 116 | ); |
117 | 117 | |
118 | - if ( !empty( $_REQUEST['orderby'] ) ) |
|
119 | - $args['orderby'] = trim( wp_unslash( $_REQUEST['orderby'] ) ); |
|
118 | + if ( ! empty($_REQUEST['orderby'])) |
|
119 | + $args['orderby'] = trim(wp_unslash($_REQUEST['orderby'])); |
|
120 | 120 | |
121 | - if ( !empty( $_REQUEST['order'] ) ) |
|
122 | - $args['order'] = trim( wp_unslash( $_REQUEST['order'] ) ); |
|
121 | + if ( ! empty($_REQUEST['order'])) |
|
122 | + $args['order'] = trim(wp_unslash($_REQUEST['order'])); |
|
123 | 123 | |
124 | 124 | $this->callback_args = $args; |
125 | 125 | |
126 | - $this->set_pagination_args( array( |
|
127 | - 'total_items' => wp_count_terms( $this->screen->taxonomy, compact( 'search' ) ), |
|
126 | + $this->set_pagination_args(array( |
|
127 | + 'total_items' => wp_count_terms($this->screen->taxonomy, compact('search')), |
|
128 | 128 | 'per_page' => $tags_per_page, |
129 | - ) ); |
|
129 | + )); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * @access public |
143 | 143 | */ |
144 | 144 | public function no_items() { |
145 | - echo get_taxonomy( $this->screen->taxonomy )->labels->not_found; |
|
145 | + echo get_taxonomy($this->screen->taxonomy)->labels->not_found; |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | */ |
152 | 152 | protected function get_bulk_actions() { |
153 | 153 | $actions = array(); |
154 | - $actions['delete'] = __( 'Delete' ); |
|
154 | + $actions['delete'] = __('Delete'); |
|
155 | 155 | |
156 | 156 | return $actions; |
157 | 157 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | * @return string |
162 | 162 | */ |
163 | 163 | public function current_action() { |
164 | - if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && ( 'delete' === $_REQUEST['action'] || 'delete' === $_REQUEST['action2'] ) ) |
|
164 | + if (isset($_REQUEST['action']) && isset($_REQUEST['delete_tags']) && ('delete' === $_REQUEST['action'] || 'delete' === $_REQUEST['action2'])) |
|
165 | 165 | return 'bulk-delete'; |
166 | 166 | |
167 | 167 | return parent::current_action(); |
@@ -174,15 +174,15 @@ discard block |
||
174 | 174 | public function get_columns() { |
175 | 175 | $columns = array( |
176 | 176 | 'cb' => '<input type="checkbox" />', |
177 | - 'name' => _x( 'Name', 'term name' ), |
|
178 | - 'description' => __( 'Description' ), |
|
179 | - 'slug' => __( 'Slug' ), |
|
177 | + 'name' => _x('Name', 'term name'), |
|
178 | + 'description' => __('Description'), |
|
179 | + 'slug' => __('Slug'), |
|
180 | 180 | ); |
181 | 181 | |
182 | - if ( 'link_category' === $this->screen->taxonomy ) { |
|
183 | - $columns['links'] = __( 'Links' ); |
|
182 | + if ('link_category' === $this->screen->taxonomy) { |
|
183 | + $columns['links'] = __('Links'); |
|
184 | 184 | } else { |
185 | - $columns['posts'] = _x( 'Count', 'Number/count of items' ); |
|
185 | + $columns['posts'] = _x('Count', 'Number/count of items'); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | return $columns; |
@@ -208,47 +208,47 @@ discard block |
||
208 | 208 | public function display_rows_or_placeholder() { |
209 | 209 | $taxonomy = $this->screen->taxonomy; |
210 | 210 | |
211 | - $args = wp_parse_args( $this->callback_args, array( |
|
211 | + $args = wp_parse_args($this->callback_args, array( |
|
212 | 212 | 'page' => 1, |
213 | 213 | 'number' => 20, |
214 | 214 | 'search' => '', |
215 | 215 | 'hide_empty' => 0 |
216 | - ) ); |
|
216 | + )); |
|
217 | 217 | |
218 | 218 | $page = $args['page']; |
219 | 219 | |
220 | 220 | // Set variable because $args['number'] can be subsequently overridden. |
221 | 221 | $number = $args['number']; |
222 | 222 | |
223 | - $args['offset'] = $offset = ( $page - 1 ) * $number; |
|
223 | + $args['offset'] = $offset = ($page - 1) * $number; |
|
224 | 224 | |
225 | 225 | // Convert it to table rows. |
226 | 226 | $count = 0; |
227 | 227 | |
228 | - if ( is_taxonomy_hierarchical( $taxonomy ) && ! isset( $args['orderby'] ) ) { |
|
228 | + if (is_taxonomy_hierarchical($taxonomy) && ! isset($args['orderby'])) { |
|
229 | 229 | // We'll need the full set of terms then. |
230 | 230 | $args['number'] = $args['offset'] = 0; |
231 | 231 | } |
232 | - $terms = get_terms( $taxonomy, $args ); |
|
232 | + $terms = get_terms($taxonomy, $args); |
|
233 | 233 | |
234 | - if ( empty( $terms ) || ! is_array( $terms ) ) { |
|
235 | - echo '<tr class="no-items"><td class="colspanchange" colspan="' . $this->get_column_count() . '">'; |
|
234 | + if (empty($terms) || ! is_array($terms)) { |
|
235 | + echo '<tr class="no-items"><td class="colspanchange" colspan="'.$this->get_column_count().'">'; |
|
236 | 236 | $this->no_items(); |
237 | 237 | echo '</td></tr>'; |
238 | 238 | return; |
239 | 239 | } |
240 | 240 | |
241 | - if ( is_taxonomy_hierarchical( $taxonomy ) && ! isset( $args['orderby'] ) ) { |
|
242 | - if ( ! empty( $args['search'] ) ) {// Ignore children on searches. |
|
241 | + if (is_taxonomy_hierarchical($taxonomy) && ! isset($args['orderby'])) { |
|
242 | + if ( ! empty($args['search'])) {// Ignore children on searches. |
|
243 | 243 | $children = array(); |
244 | 244 | } else { |
245 | - $children = _get_term_hierarchy( $taxonomy ); |
|
245 | + $children = _get_term_hierarchy($taxonomy); |
|
246 | 246 | } |
247 | 247 | // Some funky recursion to get the job done( Paging & parents mainly ) is contained within, Skip it for non-hierarchical taxonomies for performance sake |
248 | - $this->_rows( $taxonomy, $terms, $children, $offset, $number, $count ); |
|
248 | + $this->_rows($taxonomy, $terms, $children, $offset, $number, $count); |
|
249 | 249 | } else { |
250 | - foreach ( $terms as $term ) { |
|
251 | - $this->single_row( $term ); |
|
250 | + foreach ($terms as $term) { |
|
251 | + $this->single_row($term); |
|
252 | 252 | } |
253 | 253 | } |
254 | 254 | } |
@@ -263,51 +263,51 @@ discard block |
||
263 | 263 | * @param int $parent |
264 | 264 | * @param int $level |
265 | 265 | */ |
266 | - private function _rows( $taxonomy, $terms, &$children, $start, $per_page, &$count, $parent = 0, $level = 0 ) { |
|
266 | + private function _rows($taxonomy, $terms, &$children, $start, $per_page, &$count, $parent = 0, $level = 0) { |
|
267 | 267 | |
268 | 268 | $end = $start + $per_page; |
269 | 269 | |
270 | - foreach ( $terms as $key => $term ) { |
|
270 | + foreach ($terms as $key => $term) { |
|
271 | 271 | |
272 | - if ( $count >= $end ) |
|
272 | + if ($count >= $end) |
|
273 | 273 | break; |
274 | 274 | |
275 | - if ( $term->parent != $parent && empty( $_REQUEST['s'] ) ) |
|
275 | + if ($term->parent != $parent && empty($_REQUEST['s'])) |
|
276 | 276 | continue; |
277 | 277 | |
278 | 278 | // If the page starts in a subtree, print the parents. |
279 | - if ( $count == $start && $term->parent > 0 && empty( $_REQUEST['s'] ) ) { |
|
279 | + if ($count == $start && $term->parent > 0 && empty($_REQUEST['s'])) { |
|
280 | 280 | $my_parents = $parent_ids = array(); |
281 | 281 | $p = $term->parent; |
282 | - while ( $p ) { |
|
283 | - $my_parent = get_term( $p, $taxonomy ); |
|
282 | + while ($p) { |
|
283 | + $my_parent = get_term($p, $taxonomy); |
|
284 | 284 | $my_parents[] = $my_parent; |
285 | 285 | $p = $my_parent->parent; |
286 | - if ( in_array( $p, $parent_ids ) ) // Prevent parent loops. |
|
286 | + if (in_array($p, $parent_ids)) // Prevent parent loops. |
|
287 | 287 | break; |
288 | 288 | $parent_ids[] = $p; |
289 | 289 | } |
290 | - unset( $parent_ids ); |
|
290 | + unset($parent_ids); |
|
291 | 291 | |
292 | - $num_parents = count( $my_parents ); |
|
293 | - while ( $my_parent = array_pop( $my_parents ) ) { |
|
292 | + $num_parents = count($my_parents); |
|
293 | + while ($my_parent = array_pop($my_parents)) { |
|
294 | 294 | echo "\t"; |
295 | - $this->single_row( $my_parent, $level - $num_parents ); |
|
295 | + $this->single_row($my_parent, $level - $num_parents); |
|
296 | 296 | $num_parents--; |
297 | 297 | } |
298 | 298 | } |
299 | 299 | |
300 | - if ( $count >= $start ) { |
|
300 | + if ($count >= $start) { |
|
301 | 301 | echo "\t"; |
302 | - $this->single_row( $term, $level ); |
|
302 | + $this->single_row($term, $level); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | ++$count; |
306 | 306 | |
307 | - unset( $terms[$key] ); |
|
307 | + unset($terms[$key]); |
|
308 | 308 | |
309 | - if ( isset( $children[$term->term_id] ) && empty( $_REQUEST['s'] ) ) |
|
310 | - $this->_rows( $taxonomy, $terms, $children, $start, $per_page, $count, $term->term_id, $level + 1 ); |
|
309 | + if (isset($children[$term->term_id]) && empty($_REQUEST['s'])) |
|
310 | + $this->_rows($taxonomy, $terms, $children, $start, $per_page, $count, $term->term_id, $level + 1); |
|
311 | 311 | } |
312 | 312 | } |
313 | 313 | |
@@ -316,14 +316,14 @@ discard block |
||
316 | 316 | * @param object $tag |
317 | 317 | * @param int $level |
318 | 318 | */ |
319 | - public function single_row( $tag, $level = 0 ) { |
|
319 | + public function single_row($tag, $level = 0) { |
|
320 | 320 | global $taxonomy; |
321 | - $tag = sanitize_term( $tag, $taxonomy ); |
|
321 | + $tag = sanitize_term($tag, $taxonomy); |
|
322 | 322 | |
323 | 323 | $this->level = $level; |
324 | 324 | |
325 | - echo '<tr id="tag-' . $tag->term_id . '">'; |
|
326 | - $this->single_row_columns( $tag ); |
|
325 | + echo '<tr id="tag-'.$tag->term_id.'">'; |
|
326 | + $this->single_row_columns($tag); |
|
327 | 327 | echo '</tr>'; |
328 | 328 | } |
329 | 329 | |
@@ -331,12 +331,12 @@ discard block |
||
331 | 331 | * @param object $tag |
332 | 332 | * @return string |
333 | 333 | */ |
334 | - public function column_cb( $tag ) { |
|
335 | - $default_term = get_option( 'default_' . $this->screen->taxonomy ); |
|
334 | + public function column_cb($tag) { |
|
335 | + $default_term = get_option('default_'.$this->screen->taxonomy); |
|
336 | 336 | |
337 | - if ( current_user_can( get_taxonomy( $this->screen->taxonomy )->cap->delete_terms ) && $tag->term_id != $default_term ) |
|
338 | - return '<label class="screen-reader-text" for="cb-select-' . $tag->term_id . '">' . sprintf( __( 'Select %s' ), $tag->name ) . '</label>' |
|
339 | - . '<input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" id="cb-select-' . $tag->term_id . '" />'; |
|
337 | + if (current_user_can(get_taxonomy($this->screen->taxonomy)->cap->delete_terms) && $tag->term_id != $default_term) |
|
338 | + return '<label class="screen-reader-text" for="cb-select-'.$tag->term_id.'">'.sprintf(__('Select %s'), $tag->name).'</label>' |
|
339 | + . '<input type="checkbox" name="delete_tags[]" value="'.$tag->term_id.'" id="cb-select-'.$tag->term_id.'" />'; |
|
340 | 340 | |
341 | 341 | return ' '; |
342 | 342 | } |
@@ -345,10 +345,10 @@ discard block |
||
345 | 345 | * @param object $tag |
346 | 346 | * @return string |
347 | 347 | */ |
348 | - public function column_name( $tag ) { |
|
348 | + public function column_name($tag) { |
|
349 | 349 | $taxonomy = $this->screen->taxonomy; |
350 | 350 | |
351 | - $pad = str_repeat( '— ', max( 0, $this->level ) ); |
|
351 | + $pad = str_repeat('— ', max(0, $this->level)); |
|
352 | 352 | |
353 | 353 | /** |
354 | 354 | * Filters display of the term name in the terms list table. |
@@ -363,32 +363,32 @@ discard block |
||
363 | 363 | * @param string $pad_tag_name The term name, padded if not top-level. |
364 | 364 | * @param object $tag Term object. |
365 | 365 | */ |
366 | - $name = apply_filters( 'term_name', $pad . ' ' . $tag->name, $tag ); |
|
366 | + $name = apply_filters('term_name', $pad.' '.$tag->name, $tag); |
|
367 | 367 | |
368 | - $qe_data = get_term( $tag->term_id, $taxonomy, OBJECT, 'edit' ); |
|
368 | + $qe_data = get_term($tag->term_id, $taxonomy, OBJECT, 'edit'); |
|
369 | 369 | |
370 | - $uri = ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ? wp_get_referer() : $_SERVER['REQUEST_URI']; |
|
370 | + $uri = (defined('DOING_AJAX') && DOING_AJAX) ? wp_get_referer() : $_SERVER['REQUEST_URI']; |
|
371 | 371 | |
372 | 372 | $edit_link = add_query_arg( |
373 | 373 | 'wp_http_referer', |
374 | - urlencode( wp_unslash( $uri ) ), |
|
375 | - get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type ) |
|
374 | + urlencode(wp_unslash($uri)), |
|
375 | + get_edit_term_link($tag->term_id, $taxonomy, $this->screen->post_type) |
|
376 | 376 | ); |
377 | 377 | |
378 | 378 | $out = sprintf( |
379 | 379 | '<strong><a class="row-title" href="%s" aria-label="%s">%s</a></strong><br />', |
380 | - esc_url( $edit_link ), |
|
380 | + esc_url($edit_link), |
|
381 | 381 | /* translators: %s: taxonomy term name */ |
382 | - esc_attr( sprintf( __( '“%s” (Edit)' ), $tag->name ) ), |
|
382 | + esc_attr(sprintf(__('“%s” (Edit)'), $tag->name)), |
|
383 | 383 | $name |
384 | 384 | ); |
385 | 385 | |
386 | - $out .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">'; |
|
387 | - $out .= '<div class="name">' . $qe_data->name . '</div>'; |
|
386 | + $out .= '<div class="hidden" id="inline_'.$qe_data->term_id.'">'; |
|
387 | + $out .= '<div class="name">'.$qe_data->name.'</div>'; |
|
388 | 388 | |
389 | 389 | /** This filter is documented in wp-admin/edit-tag-form.php */ |
390 | - $out .= '<div class="slug">' . apply_filters( 'editable_slug', $qe_data->slug, $qe_data ) . '</div>'; |
|
391 | - $out .= '<div class="parent">' . $qe_data->parent . '</div></div>'; |
|
390 | + $out .= '<div class="slug">'.apply_filters('editable_slug', $qe_data->slug, $qe_data).'</div>'; |
|
391 | + $out .= '<div class="parent">'.$qe_data->parent.'</div></div>'; |
|
392 | 392 | |
393 | 393 | return $out; |
394 | 394 | } |
@@ -416,55 +416,55 @@ discard block |
||
416 | 416 | * @param string $primary Primary column name. |
417 | 417 | * @return string Row actions output for terms. |
418 | 418 | */ |
419 | - protected function handle_row_actions( $tag, $column_name, $primary ) { |
|
420 | - if ( $primary !== $column_name ) { |
|
419 | + protected function handle_row_actions($tag, $column_name, $primary) { |
|
420 | + if ($primary !== $column_name) { |
|
421 | 421 | return ''; |
422 | 422 | } |
423 | 423 | |
424 | 424 | $taxonomy = $this->screen->taxonomy; |
425 | - $tax = get_taxonomy( $taxonomy ); |
|
426 | - $default_term = get_option( 'default_' . $taxonomy ); |
|
425 | + $tax = get_taxonomy($taxonomy); |
|
426 | + $default_term = get_option('default_'.$taxonomy); |
|
427 | 427 | |
428 | - $uri = ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ? wp_get_referer() : $_SERVER['REQUEST_URI']; |
|
428 | + $uri = (defined('DOING_AJAX') && DOING_AJAX) ? wp_get_referer() : $_SERVER['REQUEST_URI']; |
|
429 | 429 | |
430 | 430 | $edit_link = add_query_arg( |
431 | 431 | 'wp_http_referer', |
432 | - urlencode( wp_unslash( $uri ) ), |
|
433 | - get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type ) |
|
432 | + urlencode(wp_unslash($uri)), |
|
433 | + get_edit_term_link($tag->term_id, $taxonomy, $this->screen->post_type) |
|
434 | 434 | ); |
435 | 435 | |
436 | 436 | $actions = array(); |
437 | - if ( current_user_can( $tax->cap->edit_terms ) ) { |
|
437 | + if (current_user_can($tax->cap->edit_terms)) { |
|
438 | 438 | $actions['edit'] = sprintf( |
439 | 439 | '<a href="%s" aria-label="%s">%s</a>', |
440 | - esc_url( $edit_link ), |
|
440 | + esc_url($edit_link), |
|
441 | 441 | /* translators: %s: taxonomy term name */ |
442 | - esc_attr( sprintf( __( 'Edit “%s”' ), $tag->name ) ), |
|
443 | - __( 'Edit' ) |
|
442 | + esc_attr(sprintf(__('Edit “%s”'), $tag->name)), |
|
443 | + __('Edit') |
|
444 | 444 | ); |
445 | 445 | $actions['inline hide-if-no-js'] = sprintf( |
446 | 446 | '<a href="#" class="editinline aria-button-if-js" aria-label="%s">%s</a>', |
447 | 447 | /* translators: %s: taxonomy term name */ |
448 | - esc_attr( sprintf( __( 'Quick edit “%s” inline' ), $tag->name ) ), |
|
449 | - __( 'Quick Edit' ) |
|
448 | + esc_attr(sprintf(__('Quick edit “%s” inline'), $tag->name)), |
|
449 | + __('Quick Edit') |
|
450 | 450 | ); |
451 | 451 | } |
452 | - if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term ) { |
|
452 | + if (current_user_can($tax->cap->delete_terms) && $tag->term_id != $default_term) { |
|
453 | 453 | $actions['delete'] = sprintf( |
454 | 454 | '<a href="%s" class="delete-tag aria-button-if-js" aria-label="%s">%s</a>', |
455 | - wp_nonce_url( "edit-tags.php?action=delete&taxonomy=$taxonomy&tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id ), |
|
455 | + wp_nonce_url("edit-tags.php?action=delete&taxonomy=$taxonomy&tag_ID=$tag->term_id", 'delete-tag_'.$tag->term_id), |
|
456 | 456 | /* translators: %s: taxonomy term name */ |
457 | - esc_attr( sprintf( __( 'Delete “%s”' ), $tag->name ) ), |
|
458 | - __( 'Delete' ) |
|
457 | + esc_attr(sprintf(__('Delete “%s”'), $tag->name)), |
|
458 | + __('Delete') |
|
459 | 459 | ); |
460 | 460 | } |
461 | - if ( $tax->public ) { |
|
461 | + if ($tax->public) { |
|
462 | 462 | $actions['view'] = sprintf( |
463 | 463 | '<a href="%s" aria-label="%s">%s</a>', |
464 | - get_term_link( $tag ), |
|
464 | + get_term_link($tag), |
|
465 | 465 | /* translators: %s: taxonomy term name */ |
466 | - esc_attr( sprintf( __( 'View “%s” archive' ), $tag->name ) ), |
|
467 | - __( 'View' ) |
|
466 | + esc_attr(sprintf(__('View “%s” archive'), $tag->name)), |
|
467 | + __('View') |
|
468 | 468 | ); |
469 | 469 | } |
470 | 470 | |
@@ -478,7 +478,7 @@ discard block |
||
478 | 478 | * 'Edit', 'Quick Edit', 'Delete', and 'View'. |
479 | 479 | * @param object $tag Term object. |
480 | 480 | */ |
481 | - $actions = apply_filters( 'tag_row_actions', $actions, $tag ); |
|
481 | + $actions = apply_filters('tag_row_actions', $actions, $tag); |
|
482 | 482 | |
483 | 483 | /** |
484 | 484 | * Filters the action links displayed for each term in the terms list table. |
@@ -491,16 +491,16 @@ discard block |
||
491 | 491 | * 'Edit', 'Quick Edit', 'Delete', and 'View'. |
492 | 492 | * @param object $tag Term object. |
493 | 493 | */ |
494 | - $actions = apply_filters( "{$taxonomy}_row_actions", $actions, $tag ); |
|
494 | + $actions = apply_filters("{$taxonomy}_row_actions", $actions, $tag); |
|
495 | 495 | |
496 | - return $this->row_actions( $actions ); |
|
496 | + return $this->row_actions($actions); |
|
497 | 497 | } |
498 | 498 | |
499 | 499 | /** |
500 | 500 | * @param object $tag |
501 | 501 | * @return string |
502 | 502 | */ |
503 | - public function column_description( $tag ) { |
|
503 | + public function column_description($tag) { |
|
504 | 504 | return $tag->description; |
505 | 505 | } |
506 | 506 | |
@@ -508,46 +508,46 @@ discard block |
||
508 | 508 | * @param object $tag |
509 | 509 | * @return string |
510 | 510 | */ |
511 | - public function column_slug( $tag ) { |
|
511 | + public function column_slug($tag) { |
|
512 | 512 | /** This filter is documented in wp-admin/edit-tag-form.php */ |
513 | - return apply_filters( 'editable_slug', $tag->slug, $tag ); |
|
513 | + return apply_filters('editable_slug', $tag->slug, $tag); |
|
514 | 514 | } |
515 | 515 | |
516 | 516 | /** |
517 | 517 | * @param object $tag |
518 | 518 | * @return string |
519 | 519 | */ |
520 | - public function column_posts( $tag ) { |
|
521 | - $count = number_format_i18n( $tag->count ); |
|
520 | + public function column_posts($tag) { |
|
521 | + $count = number_format_i18n($tag->count); |
|
522 | 522 | |
523 | - $tax = get_taxonomy( $this->screen->taxonomy ); |
|
523 | + $tax = get_taxonomy($this->screen->taxonomy); |
|
524 | 524 | |
525 | - $ptype_object = get_post_type_object( $this->screen->post_type ); |
|
526 | - if ( ! $ptype_object->show_ui ) |
|
525 | + $ptype_object = get_post_type_object($this->screen->post_type); |
|
526 | + if ( ! $ptype_object->show_ui) |
|
527 | 527 | return $count; |
528 | 528 | |
529 | - if ( $tax->query_var ) { |
|
530 | - $args = array( $tax->query_var => $tag->slug ); |
|
529 | + if ($tax->query_var) { |
|
530 | + $args = array($tax->query_var => $tag->slug); |
|
531 | 531 | } else { |
532 | - $args = array( 'taxonomy' => $tax->name, 'term' => $tag->slug ); |
|
532 | + $args = array('taxonomy' => $tax->name, 'term' => $tag->slug); |
|
533 | 533 | } |
534 | 534 | |
535 | - if ( 'post' != $this->screen->post_type ) |
|
535 | + if ('post' != $this->screen->post_type) |
|
536 | 536 | $args['post_type'] = $this->screen->post_type; |
537 | 537 | |
538 | - if ( 'attachment' === $this->screen->post_type ) |
|
539 | - return "<a href='" . esc_url ( add_query_arg( $args, 'upload.php' ) ) . "'>$count</a>"; |
|
538 | + if ('attachment' === $this->screen->post_type) |
|
539 | + return "<a href='".esc_url(add_query_arg($args, 'upload.php'))."'>$count</a>"; |
|
540 | 540 | |
541 | - return "<a href='" . esc_url ( add_query_arg( $args, 'edit.php' ) ) . "'>$count</a>"; |
|
541 | + return "<a href='".esc_url(add_query_arg($args, 'edit.php'))."'>$count</a>"; |
|
542 | 542 | } |
543 | 543 | |
544 | 544 | /** |
545 | 545 | * @param object $tag |
546 | 546 | * @return string |
547 | 547 | */ |
548 | - public function column_links( $tag ) { |
|
549 | - $count = number_format_i18n( $tag->count ); |
|
550 | - if ( $count ) |
|
548 | + public function column_links($tag) { |
|
549 | + $count = number_format_i18n($tag->count); |
|
550 | + if ($count) |
|
551 | 551 | $count = "<a href='link-manager.php?cat_id=$tag->term_id'>$count</a>"; |
552 | 552 | return $count; |
553 | 553 | } |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | * @param string $column_name |
558 | 558 | * @return string |
559 | 559 | */ |
560 | - public function column_default( $tag, $column_name ) { |
|
560 | + public function column_default($tag, $column_name) { |
|
561 | 561 | /** |
562 | 562 | * Filters the displayed columns in the terms list table. |
563 | 563 | * |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | * @param string $column_name Name of the column. |
571 | 571 | * @param int $term_id Term ID. |
572 | 572 | */ |
573 | - return apply_filters( "manage_{$this->screen->taxonomy}_custom_column", '', $column_name, $tag->term_id ); |
|
573 | + return apply_filters("manage_{$this->screen->taxonomy}_custom_column", '', $column_name, $tag->term_id); |
|
574 | 574 | } |
575 | 575 | |
576 | 576 | /** |
@@ -579,9 +579,9 @@ discard block |
||
579 | 579 | * @since 3.1.0 |
580 | 580 | */ |
581 | 581 | public function inline_edit() { |
582 | - $tax = get_taxonomy( $this->screen->taxonomy ); |
|
582 | + $tax = get_taxonomy($this->screen->taxonomy); |
|
583 | 583 | |
584 | - if ( ! current_user_can( $tax->cap->edit_terms ) ) |
|
584 | + if ( ! current_user_can($tax->cap->edit_terms)) |
|
585 | 585 | return; |
586 | 586 | ?> |
587 | 587 | |
@@ -589,43 +589,43 @@ discard block |
||
589 | 589 | <tr id="inline-edit" class="inline-edit-row" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange"> |
590 | 590 | |
591 | 591 | <fieldset> |
592 | - <legend class="inline-edit-legend"><?php _e( 'Quick Edit' ); ?></legend> |
|
592 | + <legend class="inline-edit-legend"><?php _e('Quick Edit'); ?></legend> |
|
593 | 593 | <div class="inline-edit-col"> |
594 | 594 | <label> |
595 | - <span class="title"><?php _ex( 'Name', 'term name' ); ?></span> |
|
595 | + <span class="title"><?php _ex('Name', 'term name'); ?></span> |
|
596 | 596 | <span class="input-text-wrap"><input type="text" name="name" class="ptitle" value="" /></span> |
597 | 597 | </label> |
598 | - <?php if ( !global_terms_enabled() ) { ?> |
|
598 | + <?php if ( ! global_terms_enabled()) { ?> |
|
599 | 599 | <label> |
600 | - <span class="title"><?php _e( 'Slug' ); ?></span> |
|
600 | + <span class="title"><?php _e('Slug'); ?></span> |
|
601 | 601 | <span class="input-text-wrap"><input type="text" name="slug" class="ptitle" value="" /></span> |
602 | 602 | </label> |
603 | 603 | <?php } ?> |
604 | 604 | </div></fieldset> |
605 | 605 | <?php |
606 | 606 | |
607 | - $core_columns = array( 'cb' => true, 'description' => true, 'name' => true, 'slug' => true, 'posts' => true ); |
|
607 | + $core_columns = array('cb' => true, 'description' => true, 'name' => true, 'slug' => true, 'posts' => true); |
|
608 | 608 | |
609 | - list( $columns ) = $this->get_column_info(); |
|
609 | + list($columns) = $this->get_column_info(); |
|
610 | 610 | |
611 | - foreach ( $columns as $column_name => $column_display_name ) { |
|
612 | - if ( isset( $core_columns[$column_name] ) ) |
|
611 | + foreach ($columns as $column_name => $column_display_name) { |
|
612 | + if (isset($core_columns[$column_name])) |
|
613 | 613 | continue; |
614 | 614 | |
615 | 615 | /** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */ |
616 | - do_action( 'quick_edit_custom_box', $column_name, 'edit-tags', $this->screen->taxonomy ); |
|
616 | + do_action('quick_edit_custom_box', $column_name, 'edit-tags', $this->screen->taxonomy); |
|
617 | 617 | } |
618 | 618 | |
619 | 619 | ?> |
620 | 620 | |
621 | 621 | <p class="inline-edit-save submit"> |
622 | - <button type="button" class="cancel button-secondary alignleft"><?php _e( 'Cancel' ); ?></button> |
|
622 | + <button type="button" class="cancel button-secondary alignleft"><?php _e('Cancel'); ?></button> |
|
623 | 623 | <button type="button" class="save button-primary alignright"><?php echo $tax->labels->update_item; ?></button> |
624 | 624 | <span class="spinner"></span> |
625 | 625 | <span class="error" style="display:none;"></span> |
626 | - <?php wp_nonce_field( 'taxinlineeditnonce', '_inline_edit', false ); ?> |
|
627 | - <input type="hidden" name="taxonomy" value="<?php echo esc_attr( $this->screen->taxonomy ); ?>" /> |
|
628 | - <input type="hidden" name="post_type" value="<?php echo esc_attr( $this->screen->post_type ); ?>" /> |
|
626 | + <?php wp_nonce_field('taxinlineeditnonce', '_inline_edit', false); ?> |
|
627 | + <input type="hidden" name="taxonomy" value="<?php echo esc_attr($this->screen->taxonomy); ?>" /> |
|
628 | + <input type="hidden" name="post_type" value="<?php echo esc_attr($this->screen->post_type); ?>" /> |
|
629 | 629 | <br class="clear" /> |
630 | 630 | </p> |
631 | 631 | </td></tr> |
@@ -49,17 +49,20 @@ discard block |
||
49 | 49 | $post_type = $this->screen->post_type; |
50 | 50 | $taxonomy = $this->screen->taxonomy; |
51 | 51 | |
52 | - if ( empty( $taxonomy ) ) |
|
53 | - $taxonomy = 'post_tag'; |
|
52 | + if ( empty( $taxonomy ) ) { |
|
53 | + $taxonomy = 'post_tag'; |
|
54 | + } |
|
54 | 55 | |
55 | - if ( ! taxonomy_exists( $taxonomy ) ) |
|
56 | - wp_die( __( 'Invalid taxonomy.' ) ); |
|
56 | + if ( ! taxonomy_exists( $taxonomy ) ) { |
|
57 | + wp_die( __( 'Invalid taxonomy.' ) ); |
|
58 | + } |
|
57 | 59 | |
58 | 60 | $tax = get_taxonomy( $taxonomy ); |
59 | 61 | |
60 | 62 | // @todo Still needed? Maybe just the show_ui part. |
61 | - if ( empty( $post_type ) || !in_array( $post_type, get_post_types( array( 'show_ui' => true ) ) ) ) |
|
62 | - $post_type = 'post'; |
|
63 | + if ( empty( $post_type ) || !in_array( $post_type, get_post_types( array( 'show_ui' => true ) ) ) ) { |
|
64 | + $post_type = 'post'; |
|
65 | + } |
|
63 | 66 | |
64 | 67 | } |
65 | 68 | |
@@ -115,11 +118,13 @@ discard block |
||
115 | 118 | 'number' => $tags_per_page, |
116 | 119 | ); |
117 | 120 | |
118 | - if ( !empty( $_REQUEST['orderby'] ) ) |
|
119 | - $args['orderby'] = trim( wp_unslash( $_REQUEST['orderby'] ) ); |
|
121 | + if ( !empty( $_REQUEST['orderby'] ) ) { |
|
122 | + $args['orderby'] = trim( wp_unslash( $_REQUEST['orderby'] ) ); |
|
123 | + } |
|
120 | 124 | |
121 | - if ( !empty( $_REQUEST['order'] ) ) |
|
122 | - $args['order'] = trim( wp_unslash( $_REQUEST['order'] ) ); |
|
125 | + if ( !empty( $_REQUEST['order'] ) ) { |
|
126 | + $args['order'] = trim( wp_unslash( $_REQUEST['order'] ) ); |
|
127 | + } |
|
123 | 128 | |
124 | 129 | $this->callback_args = $args; |
125 | 130 | |
@@ -161,8 +166,9 @@ discard block |
||
161 | 166 | * @return string |
162 | 167 | */ |
163 | 168 | public function current_action() { |
164 | - if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && ( 'delete' === $_REQUEST['action'] || 'delete' === $_REQUEST['action2'] ) ) |
|
165 | - return 'bulk-delete'; |
|
169 | + if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && ( 'delete' === $_REQUEST['action'] || 'delete' === $_REQUEST['action2'] ) ) { |
|
170 | + return 'bulk-delete'; |
|
171 | + } |
|
166 | 172 | |
167 | 173 | return parent::current_action(); |
168 | 174 | } |
@@ -269,11 +275,13 @@ discard block |
||
269 | 275 | |
270 | 276 | foreach ( $terms as $key => $term ) { |
271 | 277 | |
272 | - if ( $count >= $end ) |
|
273 | - break; |
|
278 | + if ( $count >= $end ) { |
|
279 | + break; |
|
280 | + } |
|
274 | 281 | |
275 | - if ( $term->parent != $parent && empty( $_REQUEST['s'] ) ) |
|
276 | - continue; |
|
282 | + if ( $term->parent != $parent && empty( $_REQUEST['s'] ) ) { |
|
283 | + continue; |
|
284 | + } |
|
277 | 285 | |
278 | 286 | // If the page starts in a subtree, print the parents. |
279 | 287 | if ( $count == $start && $term->parent > 0 && empty( $_REQUEST['s'] ) ) { |
@@ -283,8 +291,10 @@ discard block |
||
283 | 291 | $my_parent = get_term( $p, $taxonomy ); |
284 | 292 | $my_parents[] = $my_parent; |
285 | 293 | $p = $my_parent->parent; |
286 | - if ( in_array( $p, $parent_ids ) ) // Prevent parent loops. |
|
294 | + if ( in_array( $p, $parent_ids ) ) { |
|
295 | + // Prevent parent loops. |
|
287 | 296 | break; |
297 | + } |
|
288 | 298 | $parent_ids[] = $p; |
289 | 299 | } |
290 | 300 | unset( $parent_ids ); |
@@ -306,8 +316,9 @@ discard block |
||
306 | 316 | |
307 | 317 | unset( $terms[$key] ); |
308 | 318 | |
309 | - if ( isset( $children[$term->term_id] ) && empty( $_REQUEST['s'] ) ) |
|
310 | - $this->_rows( $taxonomy, $terms, $children, $start, $per_page, $count, $term->term_id, $level + 1 ); |
|
319 | + if ( isset( $children[$term->term_id] ) && empty( $_REQUEST['s'] ) ) { |
|
320 | + $this->_rows( $taxonomy, $terms, $children, $start, $per_page, $count, $term->term_id, $level + 1 ); |
|
321 | + } |
|
311 | 322 | } |
312 | 323 | } |
313 | 324 | |
@@ -334,9 +345,10 @@ discard block |
||
334 | 345 | public function column_cb( $tag ) { |
335 | 346 | $default_term = get_option( 'default_' . $this->screen->taxonomy ); |
336 | 347 | |
337 | - if ( current_user_can( get_taxonomy( $this->screen->taxonomy )->cap->delete_terms ) && $tag->term_id != $default_term ) |
|
338 | - return '<label class="screen-reader-text" for="cb-select-' . $tag->term_id . '">' . sprintf( __( 'Select %s' ), $tag->name ) . '</label>' |
|
348 | + if ( current_user_can( get_taxonomy( $this->screen->taxonomy )->cap->delete_terms ) && $tag->term_id != $default_term ) { |
|
349 | + return '<label class="screen-reader-text" for="cb-select-' . $tag->term_id . '">' . sprintf( __( 'Select %s' ), $tag->name ) . '</label>' |
|
339 | 350 | . '<input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" id="cb-select-' . $tag->term_id . '" />'; |
351 | + } |
|
340 | 352 | |
341 | 353 | return ' '; |
342 | 354 | } |
@@ -523,8 +535,9 @@ discard block |
||
523 | 535 | $tax = get_taxonomy( $this->screen->taxonomy ); |
524 | 536 | |
525 | 537 | $ptype_object = get_post_type_object( $this->screen->post_type ); |
526 | - if ( ! $ptype_object->show_ui ) |
|
527 | - return $count; |
|
538 | + if ( ! $ptype_object->show_ui ) { |
|
539 | + return $count; |
|
540 | + } |
|
528 | 541 | |
529 | 542 | if ( $tax->query_var ) { |
530 | 543 | $args = array( $tax->query_var => $tag->slug ); |
@@ -532,11 +545,13 @@ discard block |
||
532 | 545 | $args = array( 'taxonomy' => $tax->name, 'term' => $tag->slug ); |
533 | 546 | } |
534 | 547 | |
535 | - if ( 'post' != $this->screen->post_type ) |
|
536 | - $args['post_type'] = $this->screen->post_type; |
|
548 | + if ( 'post' != $this->screen->post_type ) { |
|
549 | + $args['post_type'] = $this->screen->post_type; |
|
550 | + } |
|
537 | 551 | |
538 | - if ( 'attachment' === $this->screen->post_type ) |
|
539 | - return "<a href='" . esc_url ( add_query_arg( $args, 'upload.php' ) ) . "'>$count</a>"; |
|
552 | + if ( 'attachment' === $this->screen->post_type ) { |
|
553 | + return "<a href='" . esc_url ( add_query_arg( $args, 'upload.php' ) ) . "'>$count</a>"; |
|
554 | + } |
|
540 | 555 | |
541 | 556 | return "<a href='" . esc_url ( add_query_arg( $args, 'edit.php' ) ) . "'>$count</a>"; |
542 | 557 | } |
@@ -547,8 +562,9 @@ discard block |
||
547 | 562 | */ |
548 | 563 | public function column_links( $tag ) { |
549 | 564 | $count = number_format_i18n( $tag->count ); |
550 | - if ( $count ) |
|
551 | - $count = "<a href='link-manager.php?cat_id=$tag->term_id'>$count</a>"; |
|
565 | + if ( $count ) { |
|
566 | + $count = "<a href='link-manager.php?cat_id=$tag->term_id'>$count</a>"; |
|
567 | + } |
|
552 | 568 | return $count; |
553 | 569 | } |
554 | 570 | |
@@ -581,9 +597,10 @@ discard block |
||
581 | 597 | public function inline_edit() { |
582 | 598 | $tax = get_taxonomy( $this->screen->taxonomy ); |
583 | 599 | |
584 | - if ( ! current_user_can( $tax->cap->edit_terms ) ) |
|
585 | - return; |
|
586 | -?> |
|
600 | + if ( ! current_user_can( $tax->cap->edit_terms ) ) { |
|
601 | + return; |
|
602 | + } |
|
603 | + ?> |
|
587 | 604 | |
588 | 605 | <form method="get"><table style="display: none"><tbody id="inlineedit"> |
589 | 606 | <tr id="inline-edit" class="inline-edit-row" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange"> |
@@ -609,8 +626,9 @@ discard block |
||
609 | 626 | list( $columns ) = $this->get_column_info(); |
610 | 627 | |
611 | 628 | foreach ( $columns as $column_name => $column_display_name ) { |
612 | - if ( isset( $core_columns[$column_name] ) ) |
|
613 | - continue; |
|
629 | + if ( isset( $core_columns[$column_name] ) ) { |
|
630 | + continue; |
|
631 | + } |
|
614 | 632 | |
615 | 633 | /** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */ |
616 | 634 | do_action( 'quick_edit_custom_box', $column_name, 'edit-tags', $this->screen->taxonomy ); |
@@ -8,10 +8,10 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | /** Walker_Nav_Menu_Edit class */ |
11 | -require_once( ABSPATH . 'wp-admin/includes/class-walker-nav-menu-edit.php' ); |
|
11 | +require_once(ABSPATH.'wp-admin/includes/class-walker-nav-menu-edit.php'); |
|
12 | 12 | |
13 | 13 | /** Walker_Nav_Menu_Checklist class */ |
14 | -require_once( ABSPATH . 'wp-admin/includes/class-walker-nav-menu-checklist.php' ); |
|
14 | +require_once(ABSPATH.'wp-admin/includes/class-walker-nav-menu-checklist.php'); |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * Prints the appropriate response to a menu quick search. |
@@ -20,41 +20,41 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @param array $request The unsanitized request values. |
22 | 22 | */ |
23 | -function _wp_ajax_menu_quick_search( $request = array() ) { |
|
23 | +function _wp_ajax_menu_quick_search($request = array()) { |
|
24 | 24 | $args = array(); |
25 | - $type = isset( $request['type'] ) ? $request['type'] : ''; |
|
26 | - $object_type = isset( $request['object_type'] ) ? $request['object_type'] : ''; |
|
27 | - $query = isset( $request['q'] ) ? $request['q'] : ''; |
|
28 | - $response_format = isset( $request['response-format'] ) && in_array( $request['response-format'], array( 'json', 'markup' ) ) ? $request['response-format'] : 'json'; |
|
25 | + $type = isset($request['type']) ? $request['type'] : ''; |
|
26 | + $object_type = isset($request['object_type']) ? $request['object_type'] : ''; |
|
27 | + $query = isset($request['q']) ? $request['q'] : ''; |
|
28 | + $response_format = isset($request['response-format']) && in_array($request['response-format'], array('json', 'markup')) ? $request['response-format'] : 'json'; |
|
29 | 29 | |
30 | - if ( 'markup' == $response_format ) { |
|
30 | + if ('markup' == $response_format) { |
|
31 | 31 | $args['walker'] = new Walker_Nav_Menu_Checklist; |
32 | 32 | } |
33 | 33 | |
34 | - if ( 'get-post-item' == $type ) { |
|
35 | - if ( post_type_exists( $object_type ) ) { |
|
36 | - if ( isset( $request['ID'] ) ) { |
|
34 | + if ('get-post-item' == $type) { |
|
35 | + if (post_type_exists($object_type)) { |
|
36 | + if (isset($request['ID'])) { |
|
37 | 37 | $object_id = (int) $request['ID']; |
38 | - if ( 'markup' == $response_format ) { |
|
39 | - echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( get_post( $object_id ) ) ), 0, (object) $args ); |
|
40 | - } elseif ( 'json' == $response_format ) { |
|
38 | + if ('markup' == $response_format) { |
|
39 | + echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', array(get_post($object_id))), 0, (object) $args); |
|
40 | + } elseif ('json' == $response_format) { |
|
41 | 41 | echo wp_json_encode( |
42 | 42 | array( |
43 | 43 | 'ID' => $object_id, |
44 | - 'post_title' => get_the_title( $object_id ), |
|
45 | - 'post_type' => get_post_type( $object_id ), |
|
44 | + 'post_title' => get_the_title($object_id), |
|
45 | + 'post_type' => get_post_type($object_id), |
|
46 | 46 | ) |
47 | 47 | ); |
48 | 48 | echo "\n"; |
49 | 49 | } |
50 | 50 | } |
51 | - } elseif ( taxonomy_exists( $object_type ) ) { |
|
52 | - if ( isset( $request['ID'] ) ) { |
|
51 | + } elseif (taxonomy_exists($object_type)) { |
|
52 | + if (isset($request['ID'])) { |
|
53 | 53 | $object_id = (int) $request['ID']; |
54 | - if ( 'markup' == $response_format ) { |
|
55 | - echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( get_term( $object_id, $object_type ) ) ), 0, (object) $args ); |
|
56 | - } elseif ( 'json' == $response_format ) { |
|
57 | - $post_obj = get_term( $object_id, $object_type ); |
|
54 | + if ('markup' == $response_format) { |
|
55 | + echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', array(get_term($object_id, $object_type))), 0, (object) $args); |
|
56 | + } elseif ('json' == $response_format) { |
|
57 | + $post_obj = get_term($object_id, $object_type); |
|
58 | 58 | echo wp_json_encode( |
59 | 59 | array( |
60 | 60 | 'ID' => $object_id, |
@@ -68,46 +68,46 @@ discard block |
||
68 | 68 | |
69 | 69 | } |
70 | 70 | |
71 | - } elseif ( preg_match('/quick-search-(posttype|taxonomy)-([a-zA-Z_-]*\b)/', $type, $matches) ) { |
|
72 | - if ( 'posttype' == $matches[1] && get_post_type_object( $matches[2] ) ) { |
|
73 | - $search_results_query = new WP_Query( array( |
|
71 | + } elseif (preg_match('/quick-search-(posttype|taxonomy)-([a-zA-Z_-]*\b)/', $type, $matches)) { |
|
72 | + if ('posttype' == $matches[1] && get_post_type_object($matches[2])) { |
|
73 | + $search_results_query = new WP_Query(array( |
|
74 | 74 | 'no_found_rows' => true, |
75 | 75 | 'update_post_meta_cache' => false, |
76 | 76 | 'update_post_term_cache' => false, |
77 | 77 | 'posts_per_page' => 10, |
78 | 78 | 'post_type' => $matches[2], |
79 | 79 | 's' => $query, |
80 | - ) ); |
|
81 | - if ( ! $search_results_query->have_posts() ) { |
|
80 | + )); |
|
81 | + if ( ! $search_results_query->have_posts()) { |
|
82 | 82 | return; |
83 | 83 | } |
84 | - while ( $search_results_query->have_posts() ) { |
|
84 | + while ($search_results_query->have_posts()) { |
|
85 | 85 | $post = $search_results_query->next_post(); |
86 | - if ( 'markup' == $response_format ) { |
|
86 | + if ('markup' == $response_format) { |
|
87 | 87 | $var_by_ref = $post->ID; |
88 | - echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( get_post( $var_by_ref ) ) ), 0, (object) $args ); |
|
89 | - } elseif ( 'json' == $response_format ) { |
|
88 | + echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', array(get_post($var_by_ref))), 0, (object) $args); |
|
89 | + } elseif ('json' == $response_format) { |
|
90 | 90 | echo wp_json_encode( |
91 | 91 | array( |
92 | 92 | 'ID' => $post->ID, |
93 | - 'post_title' => get_the_title( $post->ID ), |
|
93 | + 'post_title' => get_the_title($post->ID), |
|
94 | 94 | 'post_type' => $matches[2], |
95 | 95 | ) |
96 | 96 | ); |
97 | 97 | echo "\n"; |
98 | 98 | } |
99 | 99 | } |
100 | - } elseif ( 'taxonomy' == $matches[1] ) { |
|
101 | - $terms = get_terms( $matches[2], array( |
|
100 | + } elseif ('taxonomy' == $matches[1]) { |
|
101 | + $terms = get_terms($matches[2], array( |
|
102 | 102 | 'name__like' => $query, |
103 | 103 | 'number' => 10, |
104 | 104 | )); |
105 | - if ( empty( $terms ) || is_wp_error( $terms ) ) |
|
105 | + if (empty($terms) || is_wp_error($terms)) |
|
106 | 106 | return; |
107 | - foreach ( (array) $terms as $term ) { |
|
108 | - if ( 'markup' == $response_format ) { |
|
109 | - echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( $term ) ), 0, (object) $args ); |
|
110 | - } elseif ( 'json' == $response_format ) { |
|
107 | + foreach ((array) $terms as $term) { |
|
108 | + if ('markup' == $response_format) { |
|
109 | + echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', array($term)), 0, (object) $args); |
|
110 | + } elseif ('json' == $response_format) { |
|
111 | 111 | echo wp_json_encode( |
112 | 112 | array( |
113 | 113 | 'ID' => $term->term_id, |
@@ -130,17 +130,17 @@ discard block |
||
130 | 130 | function wp_nav_menu_setup() { |
131 | 131 | // Register meta boxes |
132 | 132 | wp_nav_menu_post_type_meta_boxes(); |
133 | - add_meta_box( 'add-custom-links', __( 'Custom Links' ), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default' ); |
|
133 | + add_meta_box('add-custom-links', __('Custom Links'), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default'); |
|
134 | 134 | wp_nav_menu_taxonomy_meta_boxes(); |
135 | 135 | |
136 | 136 | // Register advanced menu items (columns) |
137 | - add_filter( 'manage_nav-menus_columns', 'wp_nav_menu_manage_columns' ); |
|
137 | + add_filter('manage_nav-menus_columns', 'wp_nav_menu_manage_columns'); |
|
138 | 138 | |
139 | 139 | // If first time editing, disable advanced items by default. |
140 | - if ( false === get_user_option( 'managenav-menuscolumnshidden' ) ) { |
|
140 | + if (false === get_user_option('managenav-menuscolumnshidden')) { |
|
141 | 141 | $user = wp_get_current_user(); |
142 | 142 | update_user_option($user->ID, 'managenav-menuscolumnshidden', |
143 | - array( 0 => 'link-target', 1 => 'css-classes', 2 => 'xfn', 3 => 'description', 4 => 'title-attribute', ), |
|
143 | + array(0 => 'link-target', 1 => 'css-classes', 2 => 'xfn', 3 => 'description', 4 => 'title-attribute',), |
|
144 | 144 | true); |
145 | 145 | } |
146 | 146 | } |
@@ -155,17 +155,17 @@ discard block |
||
155 | 155 | function wp_initial_nav_menu_meta_boxes() { |
156 | 156 | global $wp_meta_boxes; |
157 | 157 | |
158 | - if ( get_user_option( 'metaboxhidden_nav-menus' ) !== false || ! is_array($wp_meta_boxes) ) |
|
158 | + if (get_user_option('metaboxhidden_nav-menus') !== false || ! is_array($wp_meta_boxes)) |
|
159 | 159 | return; |
160 | 160 | |
161 | - $initial_meta_boxes = array( 'add-post-type-page', 'add-post-type-post', 'add-custom-links', 'add-category' ); |
|
161 | + $initial_meta_boxes = array('add-post-type-page', 'add-post-type-post', 'add-custom-links', 'add-category'); |
|
162 | 162 | $hidden_meta_boxes = array(); |
163 | 163 | |
164 | - foreach ( array_keys($wp_meta_boxes['nav-menus']) as $context ) { |
|
165 | - foreach ( array_keys($wp_meta_boxes['nav-menus'][$context]) as $priority ) { |
|
166 | - foreach ( $wp_meta_boxes['nav-menus'][$context][$priority] as $box ) { |
|
167 | - if ( in_array( $box['id'], $initial_meta_boxes ) ) { |
|
168 | - unset( $box['id'] ); |
|
164 | + foreach (array_keys($wp_meta_boxes['nav-menus']) as $context) { |
|
165 | + foreach (array_keys($wp_meta_boxes['nav-menus'][$context]) as $priority) { |
|
166 | + foreach ($wp_meta_boxes['nav-menus'][$context][$priority] as $box) { |
|
167 | + if (in_array($box['id'], $initial_meta_boxes)) { |
|
168 | + unset($box['id']); |
|
169 | 169 | } else { |
170 | 170 | $hidden_meta_boxes[] = $box['id']; |
171 | 171 | } |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | } |
175 | 175 | |
176 | 176 | $user = wp_get_current_user(); |
177 | - update_user_option( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true ); |
|
177 | + update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | /** |
@@ -183,12 +183,12 @@ discard block |
||
183 | 183 | * @since 3.0.0 |
184 | 184 | */ |
185 | 185 | function wp_nav_menu_post_type_meta_boxes() { |
186 | - $post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'object' ); |
|
186 | + $post_types = get_post_types(array('show_in_nav_menus' => true), 'object'); |
|
187 | 187 | |
188 | - if ( ! $post_types ) |
|
188 | + if ( ! $post_types) |
|
189 | 189 | return; |
190 | 190 | |
191 | - foreach ( $post_types as $post_type ) { |
|
191 | + foreach ($post_types as $post_type) { |
|
192 | 192 | /** |
193 | 193 | * Filters whether a menu items meta box will be added for the current |
194 | 194 | * object type. |
@@ -201,12 +201,12 @@ discard block |
||
201 | 201 | * @param object $meta_box_object The current object to add a menu items |
202 | 202 | * meta box for. |
203 | 203 | */ |
204 | - $post_type = apply_filters( 'nav_menu_meta_box_object', $post_type ); |
|
205 | - if ( $post_type ) { |
|
204 | + $post_type = apply_filters('nav_menu_meta_box_object', $post_type); |
|
205 | + if ($post_type) { |
|
206 | 206 | $id = $post_type->name; |
207 | 207 | // Give pages a higher priority. |
208 | - $priority = ( 'page' == $post_type->name ? 'core' : 'default' ); |
|
209 | - add_meta_box( "add-post-type-{$id}", $post_type->labels->name, 'wp_nav_menu_item_post_type_meta_box', 'nav-menus', 'side', $priority, $post_type ); |
|
208 | + $priority = ('page' == $post_type->name ? 'core' : 'default'); |
|
209 | + add_meta_box("add-post-type-{$id}", $post_type->labels->name, 'wp_nav_menu_item_post_type_meta_box', 'nav-menus', 'side', $priority, $post_type); |
|
210 | 210 | } |
211 | 211 | } |
212 | 212 | } |
@@ -217,17 +217,17 @@ discard block |
||
217 | 217 | * @since 3.0.0 |
218 | 218 | */ |
219 | 219 | function wp_nav_menu_taxonomy_meta_boxes() { |
220 | - $taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'object' ); |
|
220 | + $taxonomies = get_taxonomies(array('show_in_nav_menus' => true), 'object'); |
|
221 | 221 | |
222 | - if ( !$taxonomies ) |
|
222 | + if ( ! $taxonomies) |
|
223 | 223 | return; |
224 | 224 | |
225 | - foreach ( $taxonomies as $tax ) { |
|
225 | + foreach ($taxonomies as $tax) { |
|
226 | 226 | /** This filter is documented in wp-admin/includes/nav-menu.php */ |
227 | - $tax = apply_filters( 'nav_menu_meta_box_object', $tax ); |
|
228 | - if ( $tax ) { |
|
227 | + $tax = apply_filters('nav_menu_meta_box_object', $tax); |
|
228 | + if ($tax) { |
|
229 | 229 | $id = $tax->name; |
230 | - add_meta_box( "add-{$id}", $tax->labels->name, 'wp_nav_menu_item_taxonomy_meta_box', 'nav-menus', 'side', 'default', $tax ); |
|
230 | + add_meta_box("add-{$id}", $tax->labels->name, 'wp_nav_menu_item_taxonomy_meta_box', 'nav-menus', 'side', 'default', $tax); |
|
231 | 231 | } |
232 | 232 | } |
233 | 233 | } |
@@ -242,13 +242,13 @@ discard block |
||
242 | 242 | * @param int|string $nav_menu_selected_id (id, name or slug) of the currently-selected menu |
243 | 243 | * @return string Disabled attribute if at least one menu exists, false if not |
244 | 244 | */ |
245 | -function wp_nav_menu_disabled_check( $nav_menu_selected_id ) { |
|
245 | +function wp_nav_menu_disabled_check($nav_menu_selected_id) { |
|
246 | 246 | global $one_theme_location_no_menus; |
247 | 247 | |
248 | - if ( $one_theme_location_no_menus ) |
|
248 | + if ($one_theme_location_no_menus) |
|
249 | 249 | return false; |
250 | 250 | |
251 | - return disabled( $nav_menu_selected_id, 0 ); |
|
251 | + return disabled($nav_menu_selected_id, 0); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
@@ -268,18 +268,18 @@ discard block |
||
268 | 268 | <div class="customlinkdiv" id="customlinkdiv"> |
269 | 269 | <input type="hidden" value="custom" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-type]" /> |
270 | 270 | <p id="menu-item-url-wrap" class="wp-clearfix"> |
271 | - <label class="howto" for="custom-menu-item-url"><?php _e( 'URL' ); ?></label> |
|
271 | + <label class="howto" for="custom-menu-item-url"><?php _e('URL'); ?></label> |
|
272 | 272 | <input id="custom-menu-item-url" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-url]" type="text" class="code menu-item-textbox" value="http://" /> |
273 | 273 | </p> |
274 | 274 | |
275 | 275 | <p id="menu-item-name-wrap" class="wp-clearfix"> |
276 | - <label class="howto" for="custom-menu-item-name"><?php _e( 'Link Text' ); ?></label> |
|
276 | + <label class="howto" for="custom-menu-item-name"><?php _e('Link Text'); ?></label> |
|
277 | 277 | <input id="custom-menu-item-name" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-title]" type="text" class="regular-text menu-item-textbox" /> |
278 | 278 | </p> |
279 | 279 | |
280 | 280 | <p class="button-controls wp-clearfix"> |
281 | 281 | <span class="add-to-menu"> |
282 | - <input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-custom-menu-item" id="submit-customlinkdiv" /> |
|
282 | + <input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-custom-menu-item" id="submit-customlinkdiv" /> |
|
283 | 283 | <span class="spinner"></span> |
284 | 284 | </span> |
285 | 285 | </p> |
@@ -306,15 +306,15 @@ discard block |
||
306 | 306 | * @type WP_Post_Type $args Extra meta box arguments (the post type object for this meta box). |
307 | 307 | * } |
308 | 308 | */ |
309 | -function wp_nav_menu_item_post_type_meta_box( $object, $box ) { |
|
309 | +function wp_nav_menu_item_post_type_meta_box($object, $box) { |
|
310 | 310 | global $_nav_menu_placeholder, $nav_menu_selected_id; |
311 | 311 | |
312 | 312 | $post_type_name = $box['args']->name; |
313 | 313 | |
314 | 314 | // Paginate browsing for large numbers of post objects. |
315 | 315 | $per_page = 50; |
316 | - $pagenum = isset( $_REQUEST[$post_type_name . '-tab'] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1; |
|
317 | - $offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0; |
|
316 | + $pagenum = isset($_REQUEST[$post_type_name.'-tab']) && isset($_REQUEST['paged']) ? absint($_REQUEST['paged']) : 1; |
|
317 | + $offset = 0 < $pagenum ? $per_page * ($pagenum - 1) : 0; |
|
318 | 318 | |
319 | 319 | $args = array( |
320 | 320 | 'offset' => $offset, |
@@ -327,23 +327,23 @@ discard block |
||
327 | 327 | 'update_post_meta_cache' => false |
328 | 328 | ); |
329 | 329 | |
330 | - if ( isset( $box['args']->_default_query ) ) |
|
331 | - $args = array_merge($args, (array) $box['args']->_default_query ); |
|
330 | + if (isset($box['args']->_default_query)) |
|
331 | + $args = array_merge($args, (array) $box['args']->_default_query); |
|
332 | 332 | |
333 | 333 | // @todo transient caching of these results with proper invalidation on updating of a post of this type |
334 | 334 | $get_posts = new WP_Query; |
335 | - $posts = $get_posts->query( $args ); |
|
336 | - if ( ! $get_posts->post_count ) { |
|
337 | - echo '<p>' . __( 'No items.' ) . '</p>'; |
|
335 | + $posts = $get_posts->query($args); |
|
336 | + if ( ! $get_posts->post_count) { |
|
337 | + echo '<p>'.__('No items.').'</p>'; |
|
338 | 338 | return; |
339 | 339 | } |
340 | 340 | |
341 | 341 | $num_pages = $get_posts->max_num_pages; |
342 | 342 | |
343 | - $page_links = paginate_links( array( |
|
343 | + $page_links = paginate_links(array( |
|
344 | 344 | 'base' => add_query_arg( |
345 | 345 | array( |
346 | - $post_type_name . '-tab' => 'all', |
|
346 | + $post_type_name.'-tab' => 'all', |
|
347 | 347 | 'paged' => '%#%', |
348 | 348 | 'item-type' => 'post_type', |
349 | 349 | 'item-object' => $post_type_name, |
@@ -357,18 +357,18 @@ discard block |
||
357 | 357 | )); |
358 | 358 | |
359 | 359 | $db_fields = false; |
360 | - if ( is_post_type_hierarchical( $post_type_name ) ) { |
|
361 | - $db_fields = array( 'parent' => 'post_parent', 'id' => 'ID' ); |
|
360 | + if (is_post_type_hierarchical($post_type_name)) { |
|
361 | + $db_fields = array('parent' => 'post_parent', 'id' => 'ID'); |
|
362 | 362 | } |
363 | 363 | |
364 | - $walker = new Walker_Nav_Menu_Checklist( $db_fields ); |
|
364 | + $walker = new Walker_Nav_Menu_Checklist($db_fields); |
|
365 | 365 | |
366 | 366 | $current_tab = 'most-recent'; |
367 | - if ( isset( $_REQUEST[$post_type_name . '-tab'] ) && in_array( $_REQUEST[$post_type_name . '-tab'], array('all', 'search') ) ) { |
|
368 | - $current_tab = $_REQUEST[$post_type_name . '-tab']; |
|
367 | + if (isset($_REQUEST[$post_type_name.'-tab']) && in_array($_REQUEST[$post_type_name.'-tab'], array('all', 'search'))) { |
|
368 | + $current_tab = $_REQUEST[$post_type_name.'-tab']; |
|
369 | 369 | } |
370 | 370 | |
371 | - if ( ! empty( $_REQUEST['quick-search-posttype-' . $post_type_name] ) ) { |
|
371 | + if ( ! empty($_REQUEST['quick-search-posttype-'.$post_type_name])) { |
|
372 | 372 | $current_tab = 'search'; |
373 | 373 | } |
374 | 374 | |
@@ -384,30 +384,30 @@ discard block |
||
384 | 384 | ?> |
385 | 385 | <div id="posttype-<?php echo $post_type_name; ?>" class="posttypediv"> |
386 | 386 | <ul id="posttype-<?php echo $post_type_name; ?>-tabs" class="posttype-tabs add-menu-item-tabs"> |
387 | - <li <?php echo ( 'most-recent' == $current_tab ? ' class="tabs"' : '' ); ?>> |
|
388 | - <a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-most-recent" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($post_type_name . '-tab', 'most-recent', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent"> |
|
389 | - <?php _e( 'Most Recent' ); ?> |
|
387 | + <li <?php echo ('most-recent' == $current_tab ? ' class="tabs"' : ''); ?>> |
|
388 | + <a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr($post_type_name); ?>-most-recent" href="<?php if ($nav_menu_selected_id) echo esc_url(add_query_arg($post_type_name.'-tab', 'most-recent', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent"> |
|
389 | + <?php _e('Most Recent'); ?> |
|
390 | 390 | </a> |
391 | 391 | </li> |
392 | - <li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>> |
|
393 | - <a class="nav-tab-link" data-type="<?php echo esc_attr( $post_type_name ); ?>-all" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($post_type_name . '-tab', 'all', remove_query_arg($removed_args))); ?>#<?php echo $post_type_name; ?>-all"> |
|
394 | - <?php _e( 'View All' ); ?> |
|
392 | + <li <?php echo ('all' == $current_tab ? ' class="tabs"' : ''); ?>> |
|
393 | + <a class="nav-tab-link" data-type="<?php echo esc_attr($post_type_name); ?>-all" href="<?php if ($nav_menu_selected_id) echo esc_url(add_query_arg($post_type_name.'-tab', 'all', remove_query_arg($removed_args))); ?>#<?php echo $post_type_name; ?>-all"> |
|
394 | + <?php _e('View All'); ?> |
|
395 | 395 | </a> |
396 | 396 | </li> |
397 | - <li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>> |
|
398 | - <a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-search" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($post_type_name . '-tab', 'search', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-search"> |
|
399 | - <?php _e( 'Search'); ?> |
|
397 | + <li <?php echo ('search' == $current_tab ? ' class="tabs"' : ''); ?>> |
|
398 | + <a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr($post_type_name); ?>-search" href="<?php if ($nav_menu_selected_id) echo esc_url(add_query_arg($post_type_name.'-tab', 'search', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-search"> |
|
399 | + <?php _e('Search'); ?> |
|
400 | 400 | </a> |
401 | 401 | </li> |
402 | 402 | </ul><!-- .posttype-tabs --> |
403 | 403 | |
404 | 404 | <div id="tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent" class="tabs-panel <?php |
405 | - echo ( 'most-recent' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); |
|
405 | + echo ('most-recent' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); |
|
406 | 406 | ?>"> |
407 | 407 | <ul id="<?php echo $post_type_name; ?>checklist-most-recent" class="categorychecklist form-no-clear"> |
408 | 408 | <?php |
409 | - $recent_args = array_merge( $args, array( 'orderby' => 'post_date', 'order' => 'DESC', 'posts_per_page' => 15 ) ); |
|
410 | - $most_recent = $get_posts->query( $recent_args ); |
|
409 | + $recent_args = array_merge($args, array('orderby' => 'post_date', 'order' => 'DESC', 'posts_per_page' => 15)); |
|
410 | + $most_recent = $get_posts->query($recent_args); |
|
411 | 411 | $args['walker'] = $walker; |
412 | 412 | |
413 | 413 | /** |
@@ -422,50 +422,50 @@ discard block |
||
422 | 422 | * @param array $args An array of WP_Query arguments. |
423 | 423 | * @param array $box Arguments passed to wp_nav_menu_item_post_type_meta_box(). |
424 | 424 | */ |
425 | - $most_recent = apply_filters( "nav_menu_items_{$post_type_name}_recent", $most_recent, $args, $box ); |
|
425 | + $most_recent = apply_filters("nav_menu_items_{$post_type_name}_recent", $most_recent, $args, $box); |
|
426 | 426 | |
427 | - echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $most_recent), 0, (object) $args ); |
|
427 | + echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $most_recent), 0, (object) $args); |
|
428 | 428 | ?> |
429 | 429 | </ul> |
430 | 430 | </div><!-- /.tabs-panel --> |
431 | 431 | |
432 | 432 | <div class="tabs-panel <?php |
433 | - echo ( 'search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); |
|
433 | + echo ('search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); |
|
434 | 434 | ?>" id="tabs-panel-posttype-<?php echo $post_type_name; ?>-search"> |
435 | 435 | <?php |
436 | - if ( isset( $_REQUEST['quick-search-posttype-' . $post_type_name] ) ) { |
|
437 | - $searched = esc_attr( $_REQUEST['quick-search-posttype-' . $post_type_name] ); |
|
438 | - $search_results = get_posts( array( 's' => $searched, 'post_type' => $post_type_name, 'fields' => 'all', 'order' => 'DESC', ) ); |
|
436 | + if (isset($_REQUEST['quick-search-posttype-'.$post_type_name])) { |
|
437 | + $searched = esc_attr($_REQUEST['quick-search-posttype-'.$post_type_name]); |
|
438 | + $search_results = get_posts(array('s' => $searched, 'post_type' => $post_type_name, 'fields' => 'all', 'order' => 'DESC',)); |
|
439 | 439 | } else { |
440 | 440 | $searched = ''; |
441 | 441 | $search_results = array(); |
442 | 442 | } |
443 | 443 | ?> |
444 | 444 | <p class="quick-search-wrap"> |
445 | - <label for="quick-search-posttype-<?php echo $post_type_name; ?>" class="screen-reader-text"><?php _e( 'Search' ); ?></label> |
|
445 | + <label for="quick-search-posttype-<?php echo $post_type_name; ?>" class="screen-reader-text"><?php _e('Search'); ?></label> |
|
446 | 446 | <input type="search" class="quick-search" value="<?php echo $searched; ?>" name="quick-search-posttype-<?php echo $post_type_name; ?>" id="quick-search-posttype-<?php echo $post_type_name; ?>" /> |
447 | 447 | <span class="spinner"></span> |
448 | - <?php submit_button( __( 'Search' ), 'button-small quick-search-submit button-secondary hide-if-js', 'submit', false, array( 'id' => 'submit-quick-search-posttype-' . $post_type_name ) ); ?> |
|
448 | + <?php submit_button(__('Search'), 'button-small quick-search-submit button-secondary hide-if-js', 'submit', false, array('id' => 'submit-quick-search-posttype-'.$post_type_name)); ?> |
|
449 | 449 | </p> |
450 | 450 | |
451 | 451 | <ul id="<?php echo $post_type_name; ?>-search-checklist" data-wp-lists="list:<?php echo $post_type_name?>" class="categorychecklist form-no-clear"> |
452 | - <?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?> |
|
452 | + <?php if ( ! empty($search_results) && ! is_wp_error($search_results)) : ?> |
|
453 | 453 | <?php |
454 | 454 | $args['walker'] = $walker; |
455 | - echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args ); |
|
455 | + echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args); |
|
456 | 456 | ?> |
457 | - <?php elseif ( is_wp_error( $search_results ) ) : ?> |
|
457 | + <?php elseif (is_wp_error($search_results)) : ?> |
|
458 | 458 | <li><?php echo $search_results->get_error_message(); ?></li> |
459 | - <?php elseif ( ! empty( $searched ) ) : ?> |
|
459 | + <?php elseif ( ! empty($searched)) : ?> |
|
460 | 460 | <li><?php _e('No results found.'); ?></li> |
461 | 461 | <?php endif; ?> |
462 | 462 | </ul> |
463 | 463 | </div><!-- /.tabs-panel --> |
464 | 464 | |
465 | 465 | <div id="<?php echo $post_type_name; ?>-all" class="tabs-panel tabs-panel-view-all <?php |
466 | - echo ( 'all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); |
|
466 | + echo ('all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); |
|
467 | 467 | ?>"> |
468 | - <?php if ( ! empty( $page_links ) ) : ?> |
|
468 | + <?php if ( ! empty($page_links)) : ?> |
|
469 | 469 | <div class="add-menu-item-pagelinks"> |
470 | 470 | <?php echo $page_links; ?> |
471 | 471 | </div> |
@@ -478,15 +478,15 @@ discard block |
||
478 | 478 | * If we're dealing with pages, let's put a checkbox for the front |
479 | 479 | * page at the top of the list. |
480 | 480 | */ |
481 | - if ( 'page' == $post_type_name ) { |
|
482 | - $front_page = 'page' == get_option('show_on_front') ? (int) get_option( 'page_on_front' ) : 0; |
|
483 | - if ( ! empty( $front_page ) ) { |
|
484 | - $front_page_obj = get_post( $front_page ); |
|
481 | + if ('page' == $post_type_name) { |
|
482 | + $front_page = 'page' == get_option('show_on_front') ? (int) get_option('page_on_front') : 0; |
|
483 | + if ( ! empty($front_page)) { |
|
484 | + $front_page_obj = get_post($front_page); |
|
485 | 485 | $front_page_obj->front_or_home = true; |
486 | - array_unshift( $posts, $front_page_obj ); |
|
486 | + array_unshift($posts, $front_page_obj); |
|
487 | 487 | } else { |
488 | - $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1; |
|
489 | - array_unshift( $posts, (object) array( |
|
488 | + $_nav_menu_placeholder = (0 > $_nav_menu_placeholder) ? intval($_nav_menu_placeholder) - 1 : -1; |
|
489 | + array_unshift($posts, (object) array( |
|
490 | 490 | 'front_or_home' => true, |
491 | 491 | 'ID' => 0, |
492 | 492 | 'object_id' => $_nav_menu_placeholder, |
@@ -497,15 +497,15 @@ discard block |
||
497 | 497 | 'post_type' => 'nav_menu_item', |
498 | 498 | 'type' => 'custom', |
499 | 499 | 'url' => home_url('/'), |
500 | - ) ); |
|
500 | + )); |
|
501 | 501 | } |
502 | 502 | } |
503 | 503 | |
504 | - $post_type = get_post_type_object( $post_type_name ); |
|
505 | - $archive_link = get_post_type_archive_link( $post_type_name ); |
|
506 | - if ( $post_type->has_archive ) { |
|
507 | - $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1; |
|
508 | - array_unshift( $posts, (object) array( |
|
504 | + $post_type = get_post_type_object($post_type_name); |
|
505 | + $archive_link = get_post_type_archive_link($post_type_name); |
|
506 | + if ($post_type->has_archive) { |
|
507 | + $_nav_menu_placeholder = (0 > $_nav_menu_placeholder) ? intval($_nav_menu_placeholder) - 1 : -1; |
|
508 | + array_unshift($posts, (object) array( |
|
509 | 509 | 'ID' => 0, |
510 | 510 | 'object_id' => $_nav_menu_placeholder, |
511 | 511 | 'object' => $post_type_name, |
@@ -514,8 +514,8 @@ discard block |
||
514 | 514 | 'post_title' => $post_type->labels->archives, |
515 | 515 | 'post_type' => 'nav_menu_item', |
516 | 516 | 'type' => 'post_type_archive', |
517 | - 'url' => get_post_type_archive_link( $post_type_name ), |
|
518 | - ) ); |
|
517 | + 'url' => get_post_type_archive_link($post_type_name), |
|
518 | + )); |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | /** |
@@ -534,11 +534,11 @@ discard block |
||
534 | 534 | * @param array $args An array of WP_Query arguments. |
535 | 535 | * @param WP_Post_Type $post_type The current post type object for this menu item meta box. |
536 | 536 | */ |
537 | - $posts = apply_filters( "nav_menu_items_{$post_type_name}", $posts, $args, $post_type ); |
|
537 | + $posts = apply_filters("nav_menu_items_{$post_type_name}", $posts, $args, $post_type); |
|
538 | 538 | |
539 | - $checkbox_items = walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $posts), 0, (object) $args ); |
|
539 | + $checkbox_items = walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $posts), 0, (object) $args); |
|
540 | 540 | |
541 | - if ( 'all' == $current_tab && ! empty( $_REQUEST['selectall'] ) ) { |
|
541 | + if ('all' == $current_tab && ! empty($_REQUEST['selectall'])) { |
|
542 | 542 | $checkbox_items = preg_replace('/(type=(.)checkbox(\2))/', '$1 checked=$2checked$2', $checkbox_items); |
543 | 543 | |
544 | 544 | } |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | echo $checkbox_items; |
547 | 547 | ?> |
548 | 548 | </ul> |
549 | - <?php if ( ! empty( $page_links ) ) : ?> |
|
549 | + <?php if ( ! empty($page_links)) : ?> |
|
550 | 550 | <div class="add-menu-item-pagelinks"> |
551 | 551 | <?php echo $page_links; ?> |
552 | 552 | </div> |
@@ -556,18 +556,18 @@ discard block |
||
556 | 556 | <p class="button-controls wp-clearfix"> |
557 | 557 | <span class="list-controls"> |
558 | 558 | <a href="<?php |
559 | - echo esc_url( add_query_arg( |
|
559 | + echo esc_url(add_query_arg( |
|
560 | 560 | array( |
561 | - $post_type_name . '-tab' => 'all', |
|
561 | + $post_type_name.'-tab' => 'all', |
|
562 | 562 | 'selectall' => 1, |
563 | 563 | ), |
564 | - remove_query_arg( $removed_args ) |
|
564 | + remove_query_arg($removed_args) |
|
565 | 565 | )); |
566 | 566 | ?>#posttype-<?php echo $post_type_name; ?>" class="select-all"><?php _e('Select All'); ?></a> |
567 | 567 | </span> |
568 | 568 | |
569 | 569 | <span class="add-to-menu"> |
570 | - <input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>" name="add-post-type-menu-item" id="<?php echo esc_attr( 'submit-posttype-' . $post_type_name ); ?>" /> |
|
570 | + <input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-post-type-menu-item" id="<?php echo esc_attr('submit-posttype-'.$post_type_name); ?>" /> |
|
571 | 571 | <span class="spinner"></span> |
572 | 572 | </span> |
573 | 573 | </p> |
@@ -593,14 +593,14 @@ discard block |
||
593 | 593 | * @type object $args Extra meta box arguments (the taxonomy object for this meta box). |
594 | 594 | * } |
595 | 595 | */ |
596 | -function wp_nav_menu_item_taxonomy_meta_box( $object, $box ) { |
|
596 | +function wp_nav_menu_item_taxonomy_meta_box($object, $box) { |
|
597 | 597 | global $nav_menu_selected_id; |
598 | 598 | $taxonomy_name = $box['args']->name; |
599 | 599 | |
600 | 600 | // Paginate browsing for large numbers of objects. |
601 | 601 | $per_page = 50; |
602 | - $pagenum = isset( $_REQUEST[$taxonomy_name . '-tab'] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1; |
|
603 | - $offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0; |
|
602 | + $pagenum = isset($_REQUEST[$taxonomy_name.'-tab']) && isset($_REQUEST['paged']) ? absint($_REQUEST['paged']) : 1; |
|
603 | + $offset = 0 < $pagenum ? $per_page * ($pagenum - 1) : 0; |
|
604 | 604 | |
605 | 605 | $args = array( |
606 | 606 | 'child_of' => 0, |
@@ -615,19 +615,19 @@ discard block |
||
615 | 615 | 'pad_counts' => false, |
616 | 616 | ); |
617 | 617 | |
618 | - $terms = get_terms( $taxonomy_name, $args ); |
|
618 | + $terms = get_terms($taxonomy_name, $args); |
|
619 | 619 | |
620 | - if ( ! $terms || is_wp_error($terms) ) { |
|
621 | - echo '<p>' . __( 'No items.' ) . '</p>'; |
|
620 | + if ( ! $terms || is_wp_error($terms)) { |
|
621 | + echo '<p>'.__('No items.').'</p>'; |
|
622 | 622 | return; |
623 | 623 | } |
624 | 624 | |
625 | - $num_pages = ceil( wp_count_terms( $taxonomy_name , array_merge( $args, array('number' => '', 'offset' => '') ) ) / $per_page ); |
|
625 | + $num_pages = ceil(wp_count_terms($taxonomy_name, array_merge($args, array('number' => '', 'offset' => ''))) / $per_page); |
|
626 | 626 | |
627 | - $page_links = paginate_links( array( |
|
627 | + $page_links = paginate_links(array( |
|
628 | 628 | 'base' => add_query_arg( |
629 | 629 | array( |
630 | - $taxonomy_name . '-tab' => 'all', |
|
630 | + $taxonomy_name.'-tab' => 'all', |
|
631 | 631 | 'paged' => '%#%', |
632 | 632 | 'item-type' => 'taxonomy', |
633 | 633 | 'item-object' => $taxonomy_name, |
@@ -641,18 +641,18 @@ discard block |
||
641 | 641 | )); |
642 | 642 | |
643 | 643 | $db_fields = false; |
644 | - if ( is_taxonomy_hierarchical( $taxonomy_name ) ) { |
|
645 | - $db_fields = array( 'parent' => 'parent', 'id' => 'term_id' ); |
|
644 | + if (is_taxonomy_hierarchical($taxonomy_name)) { |
|
645 | + $db_fields = array('parent' => 'parent', 'id' => 'term_id'); |
|
646 | 646 | } |
647 | 647 | |
648 | - $walker = new Walker_Nav_Menu_Checklist( $db_fields ); |
|
648 | + $walker = new Walker_Nav_Menu_Checklist($db_fields); |
|
649 | 649 | |
650 | 650 | $current_tab = 'most-used'; |
651 | - if ( isset( $_REQUEST[$taxonomy_name . '-tab'] ) && in_array( $_REQUEST[$taxonomy_name . '-tab'], array('all', 'most-used', 'search') ) ) { |
|
652 | - $current_tab = $_REQUEST[$taxonomy_name . '-tab']; |
|
651 | + if (isset($_REQUEST[$taxonomy_name.'-tab']) && in_array($_REQUEST[$taxonomy_name.'-tab'], array('all', 'most-used', 'search'))) { |
|
652 | + $current_tab = $_REQUEST[$taxonomy_name.'-tab']; |
|
653 | 653 | } |
654 | 654 | |
655 | - if ( ! empty( $_REQUEST['quick-search-taxonomy-' . $taxonomy_name] ) ) { |
|
655 | + if ( ! empty($_REQUEST['quick-search-taxonomy-'.$taxonomy_name])) { |
|
656 | 656 | $current_tab = 'search'; |
657 | 657 | } |
658 | 658 | |
@@ -668,39 +668,39 @@ discard block |
||
668 | 668 | ?> |
669 | 669 | <div id="taxonomy-<?php echo $taxonomy_name; ?>" class="taxonomydiv"> |
670 | 670 | <ul id="taxonomy-<?php echo $taxonomy_name; ?>-tabs" class="taxonomy-tabs add-menu-item-tabs"> |
671 | - <li <?php echo ( 'most-used' == $current_tab ? ' class="tabs"' : '' ); ?>> |
|
672 | - <a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-pop" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($taxonomy_name . '-tab', 'most-used', remove_query_arg($removed_args))); ?>#tabs-panel-<?php echo $taxonomy_name; ?>-pop"> |
|
673 | - <?php _e( 'Most Used' ); ?> |
|
671 | + <li <?php echo ('most-used' == $current_tab ? ' class="tabs"' : ''); ?>> |
|
672 | + <a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr($taxonomy_name); ?>-pop" href="<?php if ($nav_menu_selected_id) echo esc_url(add_query_arg($taxonomy_name.'-tab', 'most-used', remove_query_arg($removed_args))); ?>#tabs-panel-<?php echo $taxonomy_name; ?>-pop"> |
|
673 | + <?php _e('Most Used'); ?> |
|
674 | 674 | </a> |
675 | 675 | </li> |
676 | - <li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>> |
|
677 | - <a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-all" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($taxonomy_name . '-tab', 'all', remove_query_arg($removed_args))); ?>#tabs-panel-<?php echo $taxonomy_name; ?>-all"> |
|
678 | - <?php _e( 'View All' ); ?> |
|
676 | + <li <?php echo ('all' == $current_tab ? ' class="tabs"' : ''); ?>> |
|
677 | + <a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr($taxonomy_name); ?>-all" href="<?php if ($nav_menu_selected_id) echo esc_url(add_query_arg($taxonomy_name.'-tab', 'all', remove_query_arg($removed_args))); ?>#tabs-panel-<?php echo $taxonomy_name; ?>-all"> |
|
678 | + <?php _e('View All'); ?> |
|
679 | 679 | </a> |
680 | 680 | </li> |
681 | - <li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>> |
|
682 | - <a class="nav-tab-link" data-type="tabs-panel-search-taxonomy-<?php echo esc_attr( $taxonomy_name ); ?>" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($taxonomy_name . '-tab', 'search', remove_query_arg($removed_args))); ?>#tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>"> |
|
683 | - <?php _e( 'Search' ); ?> |
|
681 | + <li <?php echo ('search' == $current_tab ? ' class="tabs"' : ''); ?>> |
|
682 | + <a class="nav-tab-link" data-type="tabs-panel-search-taxonomy-<?php echo esc_attr($taxonomy_name); ?>" href="<?php if ($nav_menu_selected_id) echo esc_url(add_query_arg($taxonomy_name.'-tab', 'search', remove_query_arg($removed_args))); ?>#tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>"> |
|
683 | + <?php _e('Search'); ?> |
|
684 | 684 | </a> |
685 | 685 | </li> |
686 | 686 | </ul><!-- .taxonomy-tabs --> |
687 | 687 | |
688 | 688 | <div id="tabs-panel-<?php echo $taxonomy_name; ?>-pop" class="tabs-panel <?php |
689 | - echo ( 'most-used' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); |
|
689 | + echo ('most-used' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); |
|
690 | 690 | ?>"> |
691 | 691 | <ul id="<?php echo $taxonomy_name; ?>checklist-pop" class="categorychecklist form-no-clear" > |
692 | 692 | <?php |
693 | - $popular_terms = get_terms( $taxonomy_name, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) ); |
|
693 | + $popular_terms = get_terms($taxonomy_name, array('orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false)); |
|
694 | 694 | $args['walker'] = $walker; |
695 | - echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $popular_terms), 0, (object) $args ); |
|
695 | + echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $popular_terms), 0, (object) $args); |
|
696 | 696 | ?> |
697 | 697 | </ul> |
698 | 698 | </div><!-- /.tabs-panel --> |
699 | 699 | |
700 | 700 | <div id="tabs-panel-<?php echo $taxonomy_name; ?>-all" class="tabs-panel tabs-panel-view-all <?php |
701 | - echo ( 'all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); |
|
701 | + echo ('all' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); |
|
702 | 702 | ?>"> |
703 | - <?php if ( ! empty( $page_links ) ) : ?> |
|
703 | + <?php if ( ! empty($page_links)) : ?> |
|
704 | 704 | <div class="add-menu-item-pagelinks"> |
705 | 705 | <?php echo $page_links; ?> |
706 | 706 | </div> |
@@ -708,10 +708,10 @@ discard block |
||
708 | 708 | <ul id="<?php echo $taxonomy_name; ?>checklist" data-wp-lists="list:<?php echo $taxonomy_name?>" class="categorychecklist form-no-clear"> |
709 | 709 | <?php |
710 | 710 | $args['walker'] = $walker; |
711 | - echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $terms), 0, (object) $args ); |
|
711 | + echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $terms), 0, (object) $args); |
|
712 | 712 | ?> |
713 | 713 | </ul> |
714 | - <?php if ( ! empty( $page_links ) ) : ?> |
|
714 | + <?php if ( ! empty($page_links)) : ?> |
|
715 | 715 | <div class="add-menu-item-pagelinks"> |
716 | 716 | <?php echo $page_links; ?> |
717 | 717 | </div> |
@@ -719,33 +719,33 @@ discard block |
||
719 | 719 | </div><!-- /.tabs-panel --> |
720 | 720 | |
721 | 721 | <div class="tabs-panel <?php |
722 | - echo ( 'search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); |
|
722 | + echo ('search' == $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); |
|
723 | 723 | ?>" id="tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>"> |
724 | 724 | <?php |
725 | - if ( isset( $_REQUEST['quick-search-taxonomy-' . $taxonomy_name] ) ) { |
|
726 | - $searched = esc_attr( $_REQUEST['quick-search-taxonomy-' . $taxonomy_name] ); |
|
727 | - $search_results = get_terms( $taxonomy_name, array( 'name__like' => $searched, 'fields' => 'all', 'orderby' => 'count', 'order' => 'DESC', 'hierarchical' => false ) ); |
|
725 | + if (isset($_REQUEST['quick-search-taxonomy-'.$taxonomy_name])) { |
|
726 | + $searched = esc_attr($_REQUEST['quick-search-taxonomy-'.$taxonomy_name]); |
|
727 | + $search_results = get_terms($taxonomy_name, array('name__like' => $searched, 'fields' => 'all', 'orderby' => 'count', 'order' => 'DESC', 'hierarchical' => false)); |
|
728 | 728 | } else { |
729 | 729 | $searched = ''; |
730 | 730 | $search_results = array(); |
731 | 731 | } |
732 | 732 | ?> |
733 | 733 | <p class="quick-search-wrap"> |
734 | - <label for="quick-search-taxonomy-<?php echo $taxonomy_name; ?>" class="screen-reader-text"><?php _e( 'Search' ); ?></label> |
|
734 | + <label for="quick-search-taxonomy-<?php echo $taxonomy_name; ?>" class="screen-reader-text"><?php _e('Search'); ?></label> |
|
735 | 735 | <input type="search" class="quick-search" value="<?php echo $searched; ?>" name="quick-search-taxonomy-<?php echo $taxonomy_name; ?>" id="quick-search-taxonomy-<?php echo $taxonomy_name; ?>" /> |
736 | 736 | <span class="spinner"></span> |
737 | - <?php submit_button( __( 'Search' ), 'button-small quick-search-submit button-secondary hide-if-js', 'submit', false, array( 'id' => 'submit-quick-search-taxonomy-' . $taxonomy_name ) ); ?> |
|
737 | + <?php submit_button(__('Search'), 'button-small quick-search-submit button-secondary hide-if-js', 'submit', false, array('id' => 'submit-quick-search-taxonomy-'.$taxonomy_name)); ?> |
|
738 | 738 | </p> |
739 | 739 | |
740 | 740 | <ul id="<?php echo $taxonomy_name; ?>-search-checklist" data-wp-lists="list:<?php echo $taxonomy_name?>" class="categorychecklist form-no-clear"> |
741 | - <?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?> |
|
741 | + <?php if ( ! empty($search_results) && ! is_wp_error($search_results)) : ?> |
|
742 | 742 | <?php |
743 | 743 | $args['walker'] = $walker; |
744 | - echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args ); |
|
744 | + echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args); |
|
745 | 745 | ?> |
746 | - <?php elseif ( is_wp_error( $search_results ) ) : ?> |
|
746 | + <?php elseif (is_wp_error($search_results)) : ?> |
|
747 | 747 | <li><?php echo $search_results->get_error_message(); ?></li> |
748 | - <?php elseif ( ! empty( $searched ) ) : ?> |
|
748 | + <?php elseif ( ! empty($searched)) : ?> |
|
749 | 749 | <li><?php _e('No results found.'); ?></li> |
750 | 750 | <?php endif; ?> |
751 | 751 | </ul> |
@@ -756,7 +756,7 @@ discard block |
||
756 | 756 | <a href="<?php |
757 | 757 | echo esc_url(add_query_arg( |
758 | 758 | array( |
759 | - $taxonomy_name . '-tab' => 'all', |
|
759 | + $taxonomy_name.'-tab' => 'all', |
|
760 | 760 | 'selectall' => 1, |
761 | 761 | ), |
762 | 762 | remove_query_arg($removed_args) |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | </span> |
766 | 766 | |
767 | 767 | <span class="add-to-menu"> |
768 | - <input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>" name="add-taxonomy-menu-item" id="<?php echo esc_attr( 'submit-taxonomy-' . $taxonomy_name ); ?>" /> |
|
768 | + <input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-taxonomy-menu-item" id="<?php echo esc_attr('submit-taxonomy-'.$taxonomy_name); ?>" /> |
|
769 | 769 | <span class="spinner"></span> |
770 | 770 | </span> |
771 | 771 | </p> |
@@ -783,25 +783,25 @@ discard block |
||
783 | 783 | * @param array $menu_data The unsanitized posted menu item data. |
784 | 784 | * @return array The database IDs of the items saved |
785 | 785 | */ |
786 | -function wp_save_nav_menu_items( $menu_id = 0, $menu_data = array() ) { |
|
786 | +function wp_save_nav_menu_items($menu_id = 0, $menu_data = array()) { |
|
787 | 787 | $menu_id = (int) $menu_id; |
788 | 788 | $items_saved = array(); |
789 | 789 | |
790 | - if ( 0 == $menu_id || is_nav_menu( $menu_id ) ) { |
|
790 | + if (0 == $menu_id || is_nav_menu($menu_id)) { |
|
791 | 791 | |
792 | 792 | // Loop through all the menu items' POST values. |
793 | - foreach ( (array) $menu_data as $_possible_db_id => $_item_object_data ) { |
|
793 | + foreach ((array) $menu_data as $_possible_db_id => $_item_object_data) { |
|
794 | 794 | if ( |
795 | 795 | // Checkbox is not checked. |
796 | - empty( $_item_object_data['menu-item-object-id'] ) && |
|
796 | + empty($_item_object_data['menu-item-object-id']) && |
|
797 | 797 | ( |
798 | 798 | // And item type either isn't set. |
799 | - ! isset( $_item_object_data['menu-item-type'] ) || |
|
799 | + ! isset($_item_object_data['menu-item-type']) || |
|
800 | 800 | // Or URL is the default. |
801 | - in_array( $_item_object_data['menu-item-url'], array( 'http://', '' ) ) || |
|
802 | - ! ( 'custom' == $_item_object_data['menu-item-type'] && ! isset( $_item_object_data['menu-item-db-id'] ) ) || // or it's not a custom menu item (but not the custom home page) |
|
801 | + in_array($_item_object_data['menu-item-url'], array('http://', '')) || |
|
802 | + ! ('custom' == $_item_object_data['menu-item-type'] && ! isset($_item_object_data['menu-item-db-id'])) || // or it's not a custom menu item (but not the custom home page) |
|
803 | 803 | // Or it *is* a custom menu item that already exists. |
804 | - ! empty( $_item_object_data['menu-item-db-id'] ) |
|
804 | + ! empty($_item_object_data['menu-item-db-id']) |
|
805 | 805 | ) |
806 | 806 | ) { |
807 | 807 | // Then this potential menu item is not getting added to this menu. |
@@ -810,8 +810,8 @@ discard block |
||
810 | 810 | |
811 | 811 | // If this possible menu item doesn't actually have a menu database ID yet. |
812 | 812 | if ( |
813 | - empty( $_item_object_data['menu-item-db-id'] ) || |
|
814 | - ( 0 > $_possible_db_id ) || |
|
813 | + empty($_item_object_data['menu-item-db-id']) || |
|
814 | + (0 > $_possible_db_id) || |
|
815 | 815 | $_possible_db_id != $_item_object_data['menu-item-db-id'] |
816 | 816 | ) { |
817 | 817 | $_actual_db_id = 0; |
@@ -820,22 +820,22 @@ discard block |
||
820 | 820 | } |
821 | 821 | |
822 | 822 | $args = array( |
823 | - 'menu-item-db-id' => ( isset( $_item_object_data['menu-item-db-id'] ) ? $_item_object_data['menu-item-db-id'] : '' ), |
|
824 | - 'menu-item-object-id' => ( isset( $_item_object_data['menu-item-object-id'] ) ? $_item_object_data['menu-item-object-id'] : '' ), |
|
825 | - 'menu-item-object' => ( isset( $_item_object_data['menu-item-object'] ) ? $_item_object_data['menu-item-object'] : '' ), |
|
826 | - 'menu-item-parent-id' => ( isset( $_item_object_data['menu-item-parent-id'] ) ? $_item_object_data['menu-item-parent-id'] : '' ), |
|
827 | - 'menu-item-position' => ( isset( $_item_object_data['menu-item-position'] ) ? $_item_object_data['menu-item-position'] : '' ), |
|
828 | - 'menu-item-type' => ( isset( $_item_object_data['menu-item-type'] ) ? $_item_object_data['menu-item-type'] : '' ), |
|
829 | - 'menu-item-title' => ( isset( $_item_object_data['menu-item-title'] ) ? $_item_object_data['menu-item-title'] : '' ), |
|
830 | - 'menu-item-url' => ( isset( $_item_object_data['menu-item-url'] ) ? $_item_object_data['menu-item-url'] : '' ), |
|
831 | - 'menu-item-description' => ( isset( $_item_object_data['menu-item-description'] ) ? $_item_object_data['menu-item-description'] : '' ), |
|
832 | - 'menu-item-attr-title' => ( isset( $_item_object_data['menu-item-attr-title'] ) ? $_item_object_data['menu-item-attr-title'] : '' ), |
|
833 | - 'menu-item-target' => ( isset( $_item_object_data['menu-item-target'] ) ? $_item_object_data['menu-item-target'] : '' ), |
|
834 | - 'menu-item-classes' => ( isset( $_item_object_data['menu-item-classes'] ) ? $_item_object_data['menu-item-classes'] : '' ), |
|
835 | - 'menu-item-xfn' => ( isset( $_item_object_data['menu-item-xfn'] ) ? $_item_object_data['menu-item-xfn'] : '' ), |
|
823 | + 'menu-item-db-id' => (isset($_item_object_data['menu-item-db-id']) ? $_item_object_data['menu-item-db-id'] : ''), |
|
824 | + 'menu-item-object-id' => (isset($_item_object_data['menu-item-object-id']) ? $_item_object_data['menu-item-object-id'] : ''), |
|
825 | + 'menu-item-object' => (isset($_item_object_data['menu-item-object']) ? $_item_object_data['menu-item-object'] : ''), |
|
826 | + 'menu-item-parent-id' => (isset($_item_object_data['menu-item-parent-id']) ? $_item_object_data['menu-item-parent-id'] : ''), |
|
827 | + 'menu-item-position' => (isset($_item_object_data['menu-item-position']) ? $_item_object_data['menu-item-position'] : ''), |
|
828 | + 'menu-item-type' => (isset($_item_object_data['menu-item-type']) ? $_item_object_data['menu-item-type'] : ''), |
|
829 | + 'menu-item-title' => (isset($_item_object_data['menu-item-title']) ? $_item_object_data['menu-item-title'] : ''), |
|
830 | + 'menu-item-url' => (isset($_item_object_data['menu-item-url']) ? $_item_object_data['menu-item-url'] : ''), |
|
831 | + 'menu-item-description' => (isset($_item_object_data['menu-item-description']) ? $_item_object_data['menu-item-description'] : ''), |
|
832 | + 'menu-item-attr-title' => (isset($_item_object_data['menu-item-attr-title']) ? $_item_object_data['menu-item-attr-title'] : ''), |
|
833 | + 'menu-item-target' => (isset($_item_object_data['menu-item-target']) ? $_item_object_data['menu-item-target'] : ''), |
|
834 | + 'menu-item-classes' => (isset($_item_object_data['menu-item-classes']) ? $_item_object_data['menu-item-classes'] : ''), |
|
835 | + 'menu-item-xfn' => (isset($_item_object_data['menu-item-xfn']) ? $_item_object_data['menu-item-xfn'] : ''), |
|
836 | 836 | ); |
837 | 837 | |
838 | - $items_saved[] = wp_update_nav_menu_item( $menu_id, $_actual_db_id, $args ); |
|
838 | + $items_saved[] = wp_update_nav_menu_item($menu_id, $_actual_db_id, $args); |
|
839 | 839 | |
840 | 840 | } |
841 | 841 | } |
@@ -852,23 +852,23 @@ discard block |
||
852 | 852 | * @param object $object The post type or taxonomy meta-object. |
853 | 853 | * @return object The post type of taxonomy object. |
854 | 854 | */ |
855 | -function _wp_nav_menu_meta_box_object( $object = null ) { |
|
856 | - if ( isset( $object->name ) ) { |
|
855 | +function _wp_nav_menu_meta_box_object($object = null) { |
|
856 | + if (isset($object->name)) { |
|
857 | 857 | |
858 | - if ( 'page' == $object->name ) { |
|
858 | + if ('page' == $object->name) { |
|
859 | 859 | $object->_default_query = array( |
860 | 860 | 'orderby' => 'menu_order title', |
861 | 861 | 'post_status' => 'publish', |
862 | 862 | ); |
863 | 863 | |
864 | 864 | // Posts should show only published items. |
865 | - } elseif ( 'post' == $object->name ) { |
|
865 | + } elseif ('post' == $object->name) { |
|
866 | 866 | $object->_default_query = array( |
867 | 867 | 'post_status' => 'publish', |
868 | 868 | ); |
869 | 869 | |
870 | 870 | // Categories should be in reverse chronological order. |
871 | - } elseif ( 'category' == $object->name ) { |
|
871 | + } elseif ('category' == $object->name) { |
|
872 | 872 | $object->_default_query = array( |
873 | 873 | 'orderby' => 'id', |
874 | 874 | 'order' => 'DESC', |
@@ -893,19 +893,19 @@ discard block |
||
893 | 893 | * @param int $menu_id Optional. The ID of the menu to format. Default 0. |
894 | 894 | * @return string|WP_Error $output The menu formatted to edit or error object on failure. |
895 | 895 | */ |
896 | -function wp_get_nav_menu_to_edit( $menu_id = 0 ) { |
|
897 | - $menu = wp_get_nav_menu_object( $menu_id ); |
|
896 | +function wp_get_nav_menu_to_edit($menu_id = 0) { |
|
897 | + $menu = wp_get_nav_menu_object($menu_id); |
|
898 | 898 | |
899 | 899 | // If the menu exists, get its items. |
900 | - if ( is_nav_menu( $menu ) ) { |
|
901 | - $menu_items = wp_get_nav_menu_items( $menu->term_id, array('post_status' => 'any') ); |
|
900 | + if (is_nav_menu($menu)) { |
|
901 | + $menu_items = wp_get_nav_menu_items($menu->term_id, array('post_status' => 'any')); |
|
902 | 902 | $result = '<div id="menu-instructions" class="post-body-plain'; |
903 | - $result .= ( ! empty($menu_items) ) ? ' menu-instructions-inactive">' : '">'; |
|
904 | - $result .= '<p>' . __( 'Add menu items from the column on the left.' ) . '</p>'; |
|
903 | + $result .= ( ! empty($menu_items)) ? ' menu-instructions-inactive">' : '">'; |
|
904 | + $result .= '<p>'.__('Add menu items from the column on the left.').'</p>'; |
|
905 | 905 | $result .= '</div>'; |
906 | 906 | |
907 | - if ( empty($menu_items) ) |
|
908 | - return $result . ' <ul class="menu" id="menu-to-edit"> </ul>'; |
|
907 | + if (empty($menu_items)) |
|
908 | + return $result.' <ul class="menu" id="menu-to-edit"> </ul>'; |
|
909 | 909 | |
910 | 910 | /** |
911 | 911 | * Filters the Walker class used when adding nav menu items. |
@@ -915,40 +915,40 @@ discard block |
||
915 | 915 | * @param string $class The walker class to use. Default 'Walker_Nav_Menu_Edit'. |
916 | 916 | * @param int $menu_id ID of the menu being rendered. |
917 | 917 | */ |
918 | - $walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $menu_id ); |
|
918 | + $walker_class_name = apply_filters('wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $menu_id); |
|
919 | 919 | |
920 | - if ( class_exists( $walker_class_name ) ) { |
|
920 | + if (class_exists($walker_class_name)) { |
|
921 | 921 | $walker = new $walker_class_name; |
922 | 922 | } else { |
923 | - return new WP_Error( 'menu_walker_not_exist', |
|
923 | + return new WP_Error('menu_walker_not_exist', |
|
924 | 924 | /* translators: %s: walker class name */ |
925 | - sprintf( __( 'The Walker class named %s does not exist.' ), |
|
926 | - '<strong>' . $walker_class_name . '</strong>' |
|
925 | + sprintf(__('The Walker class named %s does not exist.'), |
|
926 | + '<strong>'.$walker_class_name.'</strong>' |
|
927 | 927 | ) |
928 | 928 | ); |
929 | 929 | } |
930 | 930 | |
931 | 931 | $some_pending_menu_items = $some_invalid_menu_items = false; |
932 | - foreach ( (array) $menu_items as $menu_item ) { |
|
933 | - if ( isset( $menu_item->post_status ) && 'draft' == $menu_item->post_status ) |
|
932 | + foreach ((array) $menu_items as $menu_item) { |
|
933 | + if (isset($menu_item->post_status) && 'draft' == $menu_item->post_status) |
|
934 | 934 | $some_pending_menu_items = true; |
935 | - if ( ! empty( $menu_item->_invalid ) ) |
|
935 | + if ( ! empty($menu_item->_invalid)) |
|
936 | 936 | $some_invalid_menu_items = true; |
937 | 937 | } |
938 | 938 | |
939 | - if ( $some_pending_menu_items ) { |
|
940 | - $result .= '<div class="notice notice-info notice-alt inline"><p>' . __( 'Click Save Menu to make pending menu items public.' ) . '</p></div>'; |
|
939 | + if ($some_pending_menu_items) { |
|
940 | + $result .= '<div class="notice notice-info notice-alt inline"><p>'.__('Click Save Menu to make pending menu items public.').'</p></div>'; |
|
941 | 941 | } |
942 | 942 | |
943 | - if ( $some_invalid_menu_items ) { |
|
944 | - $result .= '<div class="notice notice-error notice-alt inline"><p>' . __( 'There are some invalid menu items. Please check or delete them.' ) . '</p></div>'; |
|
943 | + if ($some_invalid_menu_items) { |
|
944 | + $result .= '<div class="notice notice-error notice-alt inline"><p>'.__('There are some invalid menu items. Please check or delete them.').'</p></div>'; |
|
945 | 945 | } |
946 | 946 | |
947 | 947 | $result .= '<ul class="menu" id="menu-to-edit"> '; |
948 | - $result .= walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', $menu_items), 0, (object) array('walker' => $walker ) ); |
|
948 | + $result .= walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $menu_items), 0, (object) array('walker' => $walker)); |
|
949 | 949 | $result .= ' </ul> '; |
950 | 950 | return $result; |
951 | - } elseif ( is_wp_error( $menu ) ) { |
|
951 | + } elseif (is_wp_error($menu)) { |
|
952 | 952 | return $menu; |
953 | 953 | } |
954 | 954 | |
@@ -963,13 +963,13 @@ discard block |
||
963 | 963 | */ |
964 | 964 | function wp_nav_menu_manage_columns() { |
965 | 965 | return array( |
966 | - '_title' => __( 'Show advanced menu properties' ), |
|
966 | + '_title' => __('Show advanced menu properties'), |
|
967 | 967 | 'cb' => '<input type="checkbox" />', |
968 | - 'link-target' => __( 'Link Target' ), |
|
969 | - 'title-attribute' => __( 'Title Attribute' ), |
|
970 | - 'css-classes' => __( 'CSS Classes' ), |
|
971 | - 'xfn' => __( 'Link Relationship (XFN)' ), |
|
972 | - 'description' => __( 'Description' ), |
|
968 | + 'link-target' => __('Link Target'), |
|
969 | + 'title-attribute' => __('Title Attribute'), |
|
970 | + 'css-classes' => __('CSS Classes'), |
|
971 | + 'xfn' => __('Link Relationship (XFN)'), |
|
972 | + 'description' => __('Description'), |
|
973 | 973 | ); |
974 | 974 | } |
975 | 975 | |
@@ -983,13 +983,13 @@ discard block |
||
983 | 983 | */ |
984 | 984 | function _wp_delete_orphaned_draft_menu_items() { |
985 | 985 | global $wpdb; |
986 | - $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS ); |
|
986 | + $delete_timestamp = time() - (DAY_IN_SECONDS * EMPTY_TRASH_DAYS); |
|
987 | 987 | |
988 | 988 | // Delete orphaned draft menu items. |
989 | - $menu_items_to_delete = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts AS p LEFT JOIN $wpdb->postmeta AS m ON p.ID = m.post_id WHERE post_type = 'nav_menu_item' AND post_status = 'draft' AND meta_key = '_menu_item_orphaned' AND meta_value < '%d'", $delete_timestamp ) ); |
|
989 | + $menu_items_to_delete = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts AS p LEFT JOIN $wpdb->postmeta AS m ON p.ID = m.post_id WHERE post_type = 'nav_menu_item' AND post_status = 'draft' AND meta_key = '_menu_item_orphaned' AND meta_value < '%d'", $delete_timestamp)); |
|
990 | 990 | |
991 | - foreach ( (array) $menu_items_to_delete as $menu_item_id ) |
|
992 | - wp_delete_post( $menu_item_id, true ); |
|
991 | + foreach ((array) $menu_items_to_delete as $menu_item_id) |
|
992 | + wp_delete_post($menu_item_id, true); |
|
993 | 993 | } |
994 | 994 | |
995 | 995 | /** |
@@ -1001,12 +1001,12 @@ discard block |
||
1001 | 1001 | * @param string $nav_menu_selected_title Title of the currently-selected menu |
1002 | 1002 | * @return array $messages The menu updated message |
1003 | 1003 | */ |
1004 | -function wp_nav_menu_update_menu_items ( $nav_menu_selected_id, $nav_menu_selected_title ) { |
|
1005 | - $unsorted_menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array( 'orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID', 'post_status' => 'draft,publish' ) ); |
|
1004 | +function wp_nav_menu_update_menu_items($nav_menu_selected_id, $nav_menu_selected_title) { |
|
1005 | + $unsorted_menu_items = wp_get_nav_menu_items($nav_menu_selected_id, array('orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID', 'post_status' => 'draft,publish')); |
|
1006 | 1006 | $messages = array(); |
1007 | 1007 | $menu_items = array(); |
1008 | 1008 | // Index menu items by db ID |
1009 | - foreach ( $unsorted_menu_items as $_item ) |
|
1009 | + foreach ($unsorted_menu_items as $_item) |
|
1010 | 1010 | $menu_items[$_item->db_id] = $_item; |
1011 | 1011 | |
1012 | 1012 | $post_fields = array( |
@@ -1016,66 +1016,66 @@ discard block |
||
1016 | 1016 | 'menu-item-attr-title', 'menu-item-target', 'menu-item-classes', 'menu-item-xfn' |
1017 | 1017 | ); |
1018 | 1018 | |
1019 | - wp_defer_term_counting( true ); |
|
1019 | + wp_defer_term_counting(true); |
|
1020 | 1020 | // Loop through all the menu items' POST variables |
1021 | - if ( ! empty( $_POST['menu-item-db-id'] ) ) { |
|
1022 | - foreach ( (array) $_POST['menu-item-db-id'] as $_key => $k ) { |
|
1021 | + if ( ! empty($_POST['menu-item-db-id'])) { |
|
1022 | + foreach ((array) $_POST['menu-item-db-id'] as $_key => $k) { |
|
1023 | 1023 | |
1024 | 1024 | // Menu item title can't be blank |
1025 | - if ( ! isset( $_POST['menu-item-title'][ $_key ] ) || '' == $_POST['menu-item-title'][ $_key ] ) |
|
1025 | + if ( ! isset($_POST['menu-item-title'][$_key]) || '' == $_POST['menu-item-title'][$_key]) |
|
1026 | 1026 | continue; |
1027 | 1027 | |
1028 | 1028 | $args = array(); |
1029 | - foreach ( $post_fields as $field ) |
|
1030 | - $args[$field] = isset( $_POST[$field][$_key] ) ? $_POST[$field][$_key] : ''; |
|
1029 | + foreach ($post_fields as $field) |
|
1030 | + $args[$field] = isset($_POST[$field][$_key]) ? $_POST[$field][$_key] : ''; |
|
1031 | 1031 | |
1032 | - $menu_item_db_id = wp_update_nav_menu_item( $nav_menu_selected_id, ( $_POST['menu-item-db-id'][$_key] != $_key ? 0 : $_key ), $args ); |
|
1032 | + $menu_item_db_id = wp_update_nav_menu_item($nav_menu_selected_id, ($_POST['menu-item-db-id'][$_key] != $_key ? 0 : $_key), $args); |
|
1033 | 1033 | |
1034 | - if ( is_wp_error( $menu_item_db_id ) ) { |
|
1035 | - $messages[] = '<div id="message" class="error"><p>' . $menu_item_db_id->get_error_message() . '</p></div>'; |
|
1034 | + if (is_wp_error($menu_item_db_id)) { |
|
1035 | + $messages[] = '<div id="message" class="error"><p>'.$menu_item_db_id->get_error_message().'</p></div>'; |
|
1036 | 1036 | } else { |
1037 | - unset( $menu_items[ $menu_item_db_id ] ); |
|
1037 | + unset($menu_items[$menu_item_db_id]); |
|
1038 | 1038 | } |
1039 | 1039 | } |
1040 | 1040 | } |
1041 | 1041 | |
1042 | 1042 | // Remove menu items from the menu that weren't in $_POST |
1043 | - if ( ! empty( $menu_items ) ) { |
|
1044 | - foreach ( array_keys( $menu_items ) as $menu_item_id ) { |
|
1045 | - if ( is_nav_menu_item( $menu_item_id ) ) { |
|
1046 | - wp_delete_post( $menu_item_id ); |
|
1043 | + if ( ! empty($menu_items)) { |
|
1044 | + foreach (array_keys($menu_items) as $menu_item_id) { |
|
1045 | + if (is_nav_menu_item($menu_item_id)) { |
|
1046 | + wp_delete_post($menu_item_id); |
|
1047 | 1047 | } |
1048 | 1048 | } |
1049 | 1049 | } |
1050 | 1050 | |
1051 | 1051 | // Store 'auto-add' pages. |
1052 | - $auto_add = ! empty( $_POST['auto-add-pages'] ); |
|
1053 | - $nav_menu_option = (array) get_option( 'nav_menu_options' ); |
|
1054 | - if ( ! isset( $nav_menu_option['auto_add'] ) ) |
|
1052 | + $auto_add = ! empty($_POST['auto-add-pages']); |
|
1053 | + $nav_menu_option = (array) get_option('nav_menu_options'); |
|
1054 | + if ( ! isset($nav_menu_option['auto_add'])) |
|
1055 | 1055 | $nav_menu_option['auto_add'] = array(); |
1056 | - if ( $auto_add ) { |
|
1057 | - if ( ! in_array( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) |
|
1056 | + if ($auto_add) { |
|
1057 | + if ( ! in_array($nav_menu_selected_id, $nav_menu_option['auto_add'])) |
|
1058 | 1058 | $nav_menu_option['auto_add'][] = $nav_menu_selected_id; |
1059 | 1059 | } else { |
1060 | - if ( false !== ( $key = array_search( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) ) |
|
1061 | - unset( $nav_menu_option['auto_add'][$key] ); |
|
1060 | + if (false !== ($key = array_search($nav_menu_selected_id, $nav_menu_option['auto_add']))) |
|
1061 | + unset($nav_menu_option['auto_add'][$key]); |
|
1062 | 1062 | } |
1063 | 1063 | // Remove nonexistent/deleted menus |
1064 | - $nav_menu_option['auto_add'] = array_intersect( $nav_menu_option['auto_add'], wp_get_nav_menus( array( 'fields' => 'ids' ) ) ); |
|
1065 | - update_option( 'nav_menu_options', $nav_menu_option ); |
|
1064 | + $nav_menu_option['auto_add'] = array_intersect($nav_menu_option['auto_add'], wp_get_nav_menus(array('fields' => 'ids'))); |
|
1065 | + update_option('nav_menu_options', $nav_menu_option); |
|
1066 | 1066 | |
1067 | - wp_defer_term_counting( false ); |
|
1067 | + wp_defer_term_counting(false); |
|
1068 | 1068 | |
1069 | 1069 | /** This action is documented in wp-includes/nav-menu.php */ |
1070 | - do_action( 'wp_update_nav_menu', $nav_menu_selected_id ); |
|
1070 | + do_action('wp_update_nav_menu', $nav_menu_selected_id); |
|
1071 | 1071 | |
1072 | - $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . |
|
1072 | + $messages[] = '<div id="message" class="updated notice is-dismissible"><p>'. |
|
1073 | 1073 | /* translators: %s: nav menu title */ |
1074 | - sprintf( __( '%s has been updated.' ), |
|
1075 | - '<strong>' . $nav_menu_selected_title . '</strong>' |
|
1076 | - ) . '</p></div>'; |
|
1074 | + sprintf(__('%s has been updated.'), |
|
1075 | + '<strong>'.$nav_menu_selected_title.'</strong>' |
|
1076 | + ).'</p></div>'; |
|
1077 | 1077 | |
1078 | - unset( $menu_items, $unsorted_menu_items ); |
|
1078 | + unset($menu_items, $unsorted_menu_items); |
|
1079 | 1079 | |
1080 | 1080 | return $messages; |
1081 | 1081 | } |
@@ -1089,36 +1089,36 @@ discard block |
||
1089 | 1089 | * @access private |
1090 | 1090 | */ |
1091 | 1091 | function _wp_expand_nav_menu_post_data() { |
1092 | - if ( ! isset( $_POST['nav-menu-data'] ) ) { |
|
1092 | + if ( ! isset($_POST['nav-menu-data'])) { |
|
1093 | 1093 | return; |
1094 | 1094 | } |
1095 | 1095 | |
1096 | - $data = json_decode( stripslashes( $_POST['nav-menu-data'] ) ); |
|
1096 | + $data = json_decode(stripslashes($_POST['nav-menu-data'])); |
|
1097 | 1097 | |
1098 | - if ( ! is_null( $data ) && $data ) { |
|
1099 | - foreach ( $data as $post_input_data ) { |
|
1098 | + if ( ! is_null($data) && $data) { |
|
1099 | + foreach ($data as $post_input_data) { |
|
1100 | 1100 | // For input names that are arrays (e.g. `menu-item-db-id[3][4][5]`), |
1101 | 1101 | // derive the array path keys via regex and set the value in $_POST. |
1102 | - preg_match( '#([^\[]*)(\[(.+)\])?#', $post_input_data->name, $matches ); |
|
1102 | + preg_match('#([^\[]*)(\[(.+)\])?#', $post_input_data->name, $matches); |
|
1103 | 1103 | |
1104 | - $array_bits = array( $matches[1] ); |
|
1104 | + $array_bits = array($matches[1]); |
|
1105 | 1105 | |
1106 | - if ( isset( $matches[3] ) ) { |
|
1107 | - $array_bits = array_merge( $array_bits, explode( '][', $matches[3] ) ); |
|
1106 | + if (isset($matches[3])) { |
|
1107 | + $array_bits = array_merge($array_bits, explode('][', $matches[3])); |
|
1108 | 1108 | } |
1109 | 1109 | |
1110 | 1110 | $new_post_data = array(); |
1111 | 1111 | |
1112 | 1112 | // Build the new array value from leaf to trunk. |
1113 | - for ( $i = count( $array_bits ) - 1; $i >= 0; $i -- ) { |
|
1114 | - if ( $i == count( $array_bits ) - 1 ) { |
|
1115 | - $new_post_data[ $array_bits[ $i ] ] = wp_slash( $post_input_data->value ); |
|
1113 | + for ($i = count($array_bits) - 1; $i >= 0; $i--) { |
|
1114 | + if ($i == count($array_bits) - 1) { |
|
1115 | + $new_post_data[$array_bits[$i]] = wp_slash($post_input_data->value); |
|
1116 | 1116 | } else { |
1117 | - $new_post_data = array( $array_bits[ $i ] => $new_post_data ); |
|
1117 | + $new_post_data = array($array_bits[$i] => $new_post_data); |
|
1118 | 1118 | } |
1119 | 1119 | } |
1120 | 1120 | |
1121 | - $_POST = array_replace_recursive( $_POST, $new_post_data ); |
|
1121 | + $_POST = array_replace_recursive($_POST, $new_post_data); |
|
1122 | 1122 | } |
1123 | 1123 | } |
1124 | 1124 | } |
@@ -102,8 +102,9 @@ discard block |
||
102 | 102 | 'name__like' => $query, |
103 | 103 | 'number' => 10, |
104 | 104 | )); |
105 | - if ( empty( $terms ) || is_wp_error( $terms ) ) |
|
106 | - return; |
|
105 | + if ( empty( $terms ) || is_wp_error( $terms ) ) { |
|
106 | + return; |
|
107 | + } |
|
107 | 108 | foreach ( (array) $terms as $term ) { |
108 | 109 | if ( 'markup' == $response_format ) { |
109 | 110 | echo walk_nav_menu_tree( array_map('wp_setup_nav_menu_item', array( $term ) ), 0, (object) $args ); |
@@ -155,8 +156,9 @@ discard block |
||
155 | 156 | function wp_initial_nav_menu_meta_boxes() { |
156 | 157 | global $wp_meta_boxes; |
157 | 158 | |
158 | - if ( get_user_option( 'metaboxhidden_nav-menus' ) !== false || ! is_array($wp_meta_boxes) ) |
|
159 | - return; |
|
159 | + if ( get_user_option( 'metaboxhidden_nav-menus' ) !== false || ! is_array($wp_meta_boxes) ) { |
|
160 | + return; |
|
161 | + } |
|
160 | 162 | |
161 | 163 | $initial_meta_boxes = array( 'add-post-type-page', 'add-post-type-post', 'add-custom-links', 'add-category' ); |
162 | 164 | $hidden_meta_boxes = array(); |
@@ -185,8 +187,9 @@ discard block |
||
185 | 187 | function wp_nav_menu_post_type_meta_boxes() { |
186 | 188 | $post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'object' ); |
187 | 189 | |
188 | - if ( ! $post_types ) |
|
189 | - return; |
|
190 | + if ( ! $post_types ) { |
|
191 | + return; |
|
192 | + } |
|
190 | 193 | |
191 | 194 | foreach ( $post_types as $post_type ) { |
192 | 195 | /** |
@@ -219,8 +222,9 @@ discard block |
||
219 | 222 | function wp_nav_menu_taxonomy_meta_boxes() { |
220 | 223 | $taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'object' ); |
221 | 224 | |
222 | - if ( !$taxonomies ) |
|
223 | - return; |
|
225 | + if ( !$taxonomies ) { |
|
226 | + return; |
|
227 | + } |
|
224 | 228 | |
225 | 229 | foreach ( $taxonomies as $tax ) { |
226 | 230 | /** This filter is documented in wp-admin/includes/nav-menu.php */ |
@@ -245,8 +249,9 @@ discard block |
||
245 | 249 | function wp_nav_menu_disabled_check( $nav_menu_selected_id ) { |
246 | 250 | global $one_theme_location_no_menus; |
247 | 251 | |
248 | - if ( $one_theme_location_no_menus ) |
|
249 | - return false; |
|
252 | + if ( $one_theme_location_no_menus ) { |
|
253 | + return false; |
|
254 | + } |
|
250 | 255 | |
251 | 256 | return disabled( $nav_menu_selected_id, 0 ); |
252 | 257 | } |
@@ -327,8 +332,9 @@ discard block |
||
327 | 332 | 'update_post_meta_cache' => false |
328 | 333 | ); |
329 | 334 | |
330 | - if ( isset( $box['args']->_default_query ) ) |
|
331 | - $args = array_merge($args, (array) $box['args']->_default_query ); |
|
335 | + if ( isset( $box['args']->_default_query ) ) { |
|
336 | + $args = array_merge($args, (array) $box['args']->_default_query ); |
|
337 | + } |
|
332 | 338 | |
333 | 339 | // @todo transient caching of these results with proper invalidation on updating of a post of this type |
334 | 340 | $get_posts = new WP_Query; |
@@ -385,17 +391,26 @@ discard block |
||
385 | 391 | <div id="posttype-<?php echo $post_type_name; ?>" class="posttypediv"> |
386 | 392 | <ul id="posttype-<?php echo $post_type_name; ?>-tabs" class="posttype-tabs add-menu-item-tabs"> |
387 | 393 | <li <?php echo ( 'most-recent' == $current_tab ? ' class="tabs"' : '' ); ?>> |
388 | - <a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-most-recent" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($post_type_name . '-tab', 'most-recent', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent"> |
|
394 | + <a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-most-recent" href="<?php if ( $nav_menu_selected_id ) { |
|
395 | + echo esc_url(add_query_arg($post_type_name . '-tab', 'most-recent', remove_query_arg($removed_args))); |
|
396 | +} |
|
397 | +?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent"> |
|
389 | 398 | <?php _e( 'Most Recent' ); ?> |
390 | 399 | </a> |
391 | 400 | </li> |
392 | 401 | <li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>> |
393 | - <a class="nav-tab-link" data-type="<?php echo esc_attr( $post_type_name ); ?>-all" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($post_type_name . '-tab', 'all', remove_query_arg($removed_args))); ?>#<?php echo $post_type_name; ?>-all"> |
|
402 | + <a class="nav-tab-link" data-type="<?php echo esc_attr( $post_type_name ); ?>-all" href="<?php if ( $nav_menu_selected_id ) { |
|
403 | + echo esc_url(add_query_arg($post_type_name . '-tab', 'all', remove_query_arg($removed_args))); |
|
404 | +} |
|
405 | +?>#<?php echo $post_type_name; ?>-all"> |
|
394 | 406 | <?php _e( 'View All' ); ?> |
395 | 407 | </a> |
396 | 408 | </li> |
397 | 409 | <li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>> |
398 | - <a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-search" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($post_type_name . '-tab', 'search', remove_query_arg($removed_args))); ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-search"> |
|
410 | + <a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-search" href="<?php if ( $nav_menu_selected_id ) { |
|
411 | + echo esc_url(add_query_arg($post_type_name . '-tab', 'search', remove_query_arg($removed_args))); |
|
412 | +} |
|
413 | +?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-search"> |
|
399 | 414 | <?php _e( 'Search'); ?> |
400 | 415 | </a> |
401 | 416 | </li> |
@@ -669,17 +684,26 @@ discard block |
||
669 | 684 | <div id="taxonomy-<?php echo $taxonomy_name; ?>" class="taxonomydiv"> |
670 | 685 | <ul id="taxonomy-<?php echo $taxonomy_name; ?>-tabs" class="taxonomy-tabs add-menu-item-tabs"> |
671 | 686 | <li <?php echo ( 'most-used' == $current_tab ? ' class="tabs"' : '' ); ?>> |
672 | - <a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-pop" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($taxonomy_name . '-tab', 'most-used', remove_query_arg($removed_args))); ?>#tabs-panel-<?php echo $taxonomy_name; ?>-pop"> |
|
687 | + <a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-pop" href="<?php if ( $nav_menu_selected_id ) { |
|
688 | + echo esc_url(add_query_arg($taxonomy_name . '-tab', 'most-used', remove_query_arg($removed_args))); |
|
689 | +} |
|
690 | +?>#tabs-panel-<?php echo $taxonomy_name; ?>-pop"> |
|
673 | 691 | <?php _e( 'Most Used' ); ?> |
674 | 692 | </a> |
675 | 693 | </li> |
676 | 694 | <li <?php echo ( 'all' == $current_tab ? ' class="tabs"' : '' ); ?>> |
677 | - <a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-all" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($taxonomy_name . '-tab', 'all', remove_query_arg($removed_args))); ?>#tabs-panel-<?php echo $taxonomy_name; ?>-all"> |
|
695 | + <a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-all" href="<?php if ( $nav_menu_selected_id ) { |
|
696 | + echo esc_url(add_query_arg($taxonomy_name . '-tab', 'all', remove_query_arg($removed_args))); |
|
697 | +} |
|
698 | +?>#tabs-panel-<?php echo $taxonomy_name; ?>-all"> |
|
678 | 699 | <?php _e( 'View All' ); ?> |
679 | 700 | </a> |
680 | 701 | </li> |
681 | 702 | <li <?php echo ( 'search' == $current_tab ? ' class="tabs"' : '' ); ?>> |
682 | - <a class="nav-tab-link" data-type="tabs-panel-search-taxonomy-<?php echo esc_attr( $taxonomy_name ); ?>" href="<?php if ( $nav_menu_selected_id ) echo esc_url(add_query_arg($taxonomy_name . '-tab', 'search', remove_query_arg($removed_args))); ?>#tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>"> |
|
703 | + <a class="nav-tab-link" data-type="tabs-panel-search-taxonomy-<?php echo esc_attr( $taxonomy_name ); ?>" href="<?php if ( $nav_menu_selected_id ) { |
|
704 | + echo esc_url(add_query_arg($taxonomy_name . '-tab', 'search', remove_query_arg($removed_args))); |
|
705 | +} |
|
706 | +?>#tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>"> |
|
683 | 707 | <?php _e( 'Search' ); ?> |
684 | 708 | </a> |
685 | 709 | </li> |
@@ -904,8 +928,9 @@ discard block |
||
904 | 928 | $result .= '<p>' . __( 'Add menu items from the column on the left.' ) . '</p>'; |
905 | 929 | $result .= '</div>'; |
906 | 930 | |
907 | - if ( empty($menu_items) ) |
|
908 | - return $result . ' <ul class="menu" id="menu-to-edit"> </ul>'; |
|
931 | + if ( empty($menu_items) ) { |
|
932 | + return $result . ' <ul class="menu" id="menu-to-edit"> </ul>'; |
|
933 | + } |
|
909 | 934 | |
910 | 935 | /** |
911 | 936 | * Filters the Walker class used when adding nav menu items. |
@@ -930,10 +955,12 @@ discard block |
||
930 | 955 | |
931 | 956 | $some_pending_menu_items = $some_invalid_menu_items = false; |
932 | 957 | foreach ( (array) $menu_items as $menu_item ) { |
933 | - if ( isset( $menu_item->post_status ) && 'draft' == $menu_item->post_status ) |
|
934 | - $some_pending_menu_items = true; |
|
935 | - if ( ! empty( $menu_item->_invalid ) ) |
|
936 | - $some_invalid_menu_items = true; |
|
958 | + if ( isset( $menu_item->post_status ) && 'draft' == $menu_item->post_status ) { |
|
959 | + $some_pending_menu_items = true; |
|
960 | + } |
|
961 | + if ( ! empty( $menu_item->_invalid ) ) { |
|
962 | + $some_invalid_menu_items = true; |
|
963 | + } |
|
937 | 964 | } |
938 | 965 | |
939 | 966 | if ( $some_pending_menu_items ) { |
@@ -988,9 +1015,10 @@ discard block |
||
988 | 1015 | // Delete orphaned draft menu items. |
989 | 1016 | $menu_items_to_delete = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts AS p LEFT JOIN $wpdb->postmeta AS m ON p.ID = m.post_id WHERE post_type = 'nav_menu_item' AND post_status = 'draft' AND meta_key = '_menu_item_orphaned' AND meta_value < '%d'", $delete_timestamp ) ); |
990 | 1017 | |
991 | - foreach ( (array) $menu_items_to_delete as $menu_item_id ) |
|
992 | - wp_delete_post( $menu_item_id, true ); |
|
993 | -} |
|
1018 | + foreach ( (array) $menu_items_to_delete as $menu_item_id ) { |
|
1019 | + wp_delete_post( $menu_item_id, true ); |
|
1020 | + } |
|
1021 | + } |
|
994 | 1022 | |
995 | 1023 | /** |
996 | 1024 | * Saves nav menu items |
@@ -1006,8 +1034,9 @@ discard block |
||
1006 | 1034 | $messages = array(); |
1007 | 1035 | $menu_items = array(); |
1008 | 1036 | // Index menu items by db ID |
1009 | - foreach ( $unsorted_menu_items as $_item ) |
|
1010 | - $menu_items[$_item->db_id] = $_item; |
|
1037 | + foreach ( $unsorted_menu_items as $_item ) { |
|
1038 | + $menu_items[$_item->db_id] = $_item; |
|
1039 | + } |
|
1011 | 1040 | |
1012 | 1041 | $post_fields = array( |
1013 | 1042 | 'menu-item-db-id', 'menu-item-object-id', 'menu-item-object', |
@@ -1022,12 +1051,14 @@ discard block |
||
1022 | 1051 | foreach ( (array) $_POST['menu-item-db-id'] as $_key => $k ) { |
1023 | 1052 | |
1024 | 1053 | // Menu item title can't be blank |
1025 | - if ( ! isset( $_POST['menu-item-title'][ $_key ] ) || '' == $_POST['menu-item-title'][ $_key ] ) |
|
1026 | - continue; |
|
1054 | + if ( ! isset( $_POST['menu-item-title'][ $_key ] ) || '' == $_POST['menu-item-title'][ $_key ] ) { |
|
1055 | + continue; |
|
1056 | + } |
|
1027 | 1057 | |
1028 | 1058 | $args = array(); |
1029 | - foreach ( $post_fields as $field ) |
|
1030 | - $args[$field] = isset( $_POST[$field][$_key] ) ? $_POST[$field][$_key] : ''; |
|
1059 | + foreach ( $post_fields as $field ) { |
|
1060 | + $args[$field] = isset( $_POST[$field][$_key] ) ? $_POST[$field][$_key] : ''; |
|
1061 | + } |
|
1031 | 1062 | |
1032 | 1063 | $menu_item_db_id = wp_update_nav_menu_item( $nav_menu_selected_id, ( $_POST['menu-item-db-id'][$_key] != $_key ? 0 : $_key ), $args ); |
1033 | 1064 | |
@@ -1051,14 +1082,17 @@ discard block |
||
1051 | 1082 | // Store 'auto-add' pages. |
1052 | 1083 | $auto_add = ! empty( $_POST['auto-add-pages'] ); |
1053 | 1084 | $nav_menu_option = (array) get_option( 'nav_menu_options' ); |
1054 | - if ( ! isset( $nav_menu_option['auto_add'] ) ) |
|
1055 | - $nav_menu_option['auto_add'] = array(); |
|
1085 | + if ( ! isset( $nav_menu_option['auto_add'] ) ) { |
|
1086 | + $nav_menu_option['auto_add'] = array(); |
|
1087 | + } |
|
1056 | 1088 | if ( $auto_add ) { |
1057 | - if ( ! in_array( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) |
|
1058 | - $nav_menu_option['auto_add'][] = $nav_menu_selected_id; |
|
1089 | + if ( ! in_array( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) { |
|
1090 | + $nav_menu_option['auto_add'][] = $nav_menu_selected_id; |
|
1091 | + } |
|
1059 | 1092 | } else { |
1060 | - if ( false !== ( $key = array_search( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) ) |
|
1061 | - unset( $nav_menu_option['auto_add'][$key] ); |
|
1093 | + if ( false !== ( $key = array_search( $nav_menu_selected_id, $nav_menu_option['auto_add'] ) ) ) { |
|
1094 | + unset( $nav_menu_option['auto_add'][$key] ); |
|
1095 | + } |
|
1062 | 1096 | } |
1063 | 1097 | // Remove nonexistent/deleted menus |
1064 | 1098 | $nav_menu_option['auto_add'] = array_intersect( $nav_menu_option['auto_add'], wp_get_nav_menus( array( 'fields' => 'ids' ) ) ); |
@@ -26,43 +26,43 @@ discard block |
||
26 | 26 | |
27 | 27 | $response = wp_check_browser_version(); |
28 | 28 | |
29 | - if ( $response && $response['upgrade'] ) { |
|
30 | - add_filter( 'postbox_classes_dashboard_dashboard_browser_nag', 'dashboard_browser_nag_class' ); |
|
31 | - if ( $response['insecure'] ) |
|
32 | - wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'You are using an insecure browser!' ), 'wp_dashboard_browser_nag' ); |
|
29 | + if ($response && $response['upgrade']) { |
|
30 | + add_filter('postbox_classes_dashboard_dashboard_browser_nag', 'dashboard_browser_nag_class'); |
|
31 | + if ($response['insecure']) |
|
32 | + wp_add_dashboard_widget('dashboard_browser_nag', __('You are using an insecure browser!'), 'wp_dashboard_browser_nag'); |
|
33 | 33 | else |
34 | - wp_add_dashboard_widget( 'dashboard_browser_nag', __( 'Your browser is out of date!' ), 'wp_dashboard_browser_nag' ); |
|
34 | + wp_add_dashboard_widget('dashboard_browser_nag', __('Your browser is out of date!'), 'wp_dashboard_browser_nag'); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | // Right Now |
38 | - if ( is_blog_admin() && current_user_can('edit_posts') ) |
|
39 | - wp_add_dashboard_widget( 'dashboard_right_now', __( 'At a Glance' ), 'wp_dashboard_right_now' ); |
|
38 | + if (is_blog_admin() && current_user_can('edit_posts')) |
|
39 | + wp_add_dashboard_widget('dashboard_right_now', __('At a Glance'), 'wp_dashboard_right_now'); |
|
40 | 40 | |
41 | - if ( is_network_admin() ) |
|
42 | - wp_add_dashboard_widget( 'network_dashboard_right_now', __( 'Right Now' ), 'wp_network_dashboard_right_now' ); |
|
41 | + if (is_network_admin()) |
|
42 | + wp_add_dashboard_widget('network_dashboard_right_now', __('Right Now'), 'wp_network_dashboard_right_now'); |
|
43 | 43 | |
44 | 44 | // Activity Widget |
45 | - if ( is_blog_admin() ) { |
|
46 | - wp_add_dashboard_widget( 'dashboard_activity', __( 'Activity' ), 'wp_dashboard_site_activity' ); |
|
45 | + if (is_blog_admin()) { |
|
46 | + wp_add_dashboard_widget('dashboard_activity', __('Activity'), 'wp_dashboard_site_activity'); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | // QuickPress Widget |
50 | - if ( is_blog_admin() && current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) { |
|
51 | - $quick_draft_title = sprintf( '<span class="hide-if-no-js">%1$s</span> <span class="hide-if-js">%2$s</span>', __( 'Quick Draft' ), __( 'Drafts' ) ); |
|
52 | - wp_add_dashboard_widget( 'dashboard_quick_press', $quick_draft_title, 'wp_dashboard_quick_press' ); |
|
50 | + if (is_blog_admin() && current_user_can(get_post_type_object('post')->cap->create_posts)) { |
|
51 | + $quick_draft_title = sprintf('<span class="hide-if-no-js">%1$s</span> <span class="hide-if-js">%2$s</span>', __('Quick Draft'), __('Drafts')); |
|
52 | + wp_add_dashboard_widget('dashboard_quick_press', $quick_draft_title, 'wp_dashboard_quick_press'); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | // WordPress News |
56 | - wp_add_dashboard_widget( 'dashboard_primary', __( 'WordPress News' ), 'wp_dashboard_primary' ); |
|
56 | + wp_add_dashboard_widget('dashboard_primary', __('WordPress News'), 'wp_dashboard_primary'); |
|
57 | 57 | |
58 | - if ( is_network_admin() ) { |
|
58 | + if (is_network_admin()) { |
|
59 | 59 | |
60 | 60 | /** |
61 | 61 | * Fires after core widgets for the Network Admin dashboard have been registered. |
62 | 62 | * |
63 | 63 | * @since 3.1.0 |
64 | 64 | */ |
65 | - do_action( 'wp_network_dashboard_setup' ); |
|
65 | + do_action('wp_network_dashboard_setup'); |
|
66 | 66 | |
67 | 67 | /** |
68 | 68 | * Filters the list of widgets to load for the Network Admin dashboard. |
@@ -71,15 +71,15 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @param array $dashboard_widgets An array of dashboard widgets. |
73 | 73 | */ |
74 | - $dashboard_widgets = apply_filters( 'wp_network_dashboard_widgets', array() ); |
|
75 | - } elseif ( is_user_admin() ) { |
|
74 | + $dashboard_widgets = apply_filters('wp_network_dashboard_widgets', array()); |
|
75 | + } elseif (is_user_admin()) { |
|
76 | 76 | |
77 | 77 | /** |
78 | 78 | * Fires after core widgets for the User Admin dashboard have been registered. |
79 | 79 | * |
80 | 80 | * @since 3.1.0 |
81 | 81 | */ |
82 | - do_action( 'wp_user_dashboard_setup' ); |
|
82 | + do_action('wp_user_dashboard_setup'); |
|
83 | 83 | |
84 | 84 | /** |
85 | 85 | * Filters the list of widgets to load for the User Admin dashboard. |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @param array $dashboard_widgets An array of dashboard widgets. |
90 | 90 | */ |
91 | - $dashboard_widgets = apply_filters( 'wp_user_dashboard_widgets', array() ); |
|
91 | + $dashboard_widgets = apply_filters('wp_user_dashboard_widgets', array()); |
|
92 | 92 | } else { |
93 | 93 | |
94 | 94 | /** |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @since 2.5.0 |
98 | 98 | */ |
99 | - do_action( 'wp_dashboard_setup' ); |
|
99 | + do_action('wp_dashboard_setup'); |
|
100 | 100 | |
101 | 101 | /** |
102 | 102 | * Filters the list of widgets to load for the admin dashboard. |
@@ -105,28 +105,28 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @param array $dashboard_widgets An array of dashboard widgets. |
107 | 107 | */ |
108 | - $dashboard_widgets = apply_filters( 'wp_dashboard_widgets', array() ); |
|
108 | + $dashboard_widgets = apply_filters('wp_dashboard_widgets', array()); |
|
109 | 109 | } |
110 | 110 | |
111 | - foreach ( $dashboard_widgets as $widget_id ) { |
|
112 | - $name = empty( $wp_registered_widgets[$widget_id]['all_link'] ) ? $wp_registered_widgets[$widget_id]['name'] : $wp_registered_widgets[$widget_id]['name'] . " <a href='{$wp_registered_widgets[$widget_id]['all_link']}' class='edit-box open-box'>" . __('View all') . '</a>'; |
|
113 | - wp_add_dashboard_widget( $widget_id, $name, $wp_registered_widgets[$widget_id]['callback'], $wp_registered_widget_controls[$widget_id]['callback'] ); |
|
111 | + foreach ($dashboard_widgets as $widget_id) { |
|
112 | + $name = empty($wp_registered_widgets[$widget_id]['all_link']) ? $wp_registered_widgets[$widget_id]['name'] : $wp_registered_widgets[$widget_id]['name']." <a href='{$wp_registered_widgets[$widget_id]['all_link']}' class='edit-box open-box'>".__('View all').'</a>'; |
|
113 | + wp_add_dashboard_widget($widget_id, $name, $wp_registered_widgets[$widget_id]['callback'], $wp_registered_widget_controls[$widget_id]['callback']); |
|
114 | 114 | } |
115 | 115 | |
116 | - if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget_id']) ) { |
|
117 | - check_admin_referer( 'edit-dashboard-widget_' . $_POST['widget_id'], 'dashboard-widget-nonce' ); |
|
116 | + if ('POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget_id'])) { |
|
117 | + check_admin_referer('edit-dashboard-widget_'.$_POST['widget_id'], 'dashboard-widget-nonce'); |
|
118 | 118 | ob_start(); // hack - but the same hack wp-admin/widgets.php uses |
119 | - wp_dashboard_trigger_widget_control( $_POST['widget_id'] ); |
|
119 | + wp_dashboard_trigger_widget_control($_POST['widget_id']); |
|
120 | 120 | ob_end_clean(); |
121 | - wp_redirect( remove_query_arg( 'edit' ) ); |
|
121 | + wp_redirect(remove_query_arg('edit')); |
|
122 | 122 | exit; |
123 | 123 | } |
124 | 124 | |
125 | 125 | /** This action is documented in wp-admin/edit-form-advanced.php */ |
126 | - do_action( 'do_meta_boxes', $screen->id, 'normal', '' ); |
|
126 | + do_action('do_meta_boxes', $screen->id, 'normal', ''); |
|
127 | 127 | |
128 | 128 | /** This action is documented in wp-admin/edit-form-advanced.php */ |
129 | - do_action( 'do_meta_boxes', $screen->id, 'side', '' ); |
|
129 | + do_action('do_meta_boxes', $screen->id, 'side', ''); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -144,41 +144,41 @@ discard block |
||
144 | 144 | * @param array $callback_args Optional. Data that should be set as the $args property of the widget array |
145 | 145 | * (which is the second parameter passed to your callback). Default null. |
146 | 146 | */ |
147 | -function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null, $callback_args = null ) { |
|
147 | +function wp_add_dashboard_widget($widget_id, $widget_name, $callback, $control_callback = null, $callback_args = null) { |
|
148 | 148 | $screen = get_current_screen(); |
149 | 149 | global $wp_dashboard_control_callbacks; |
150 | 150 | |
151 | - $private_callback_args = array( '__widget_basename' => $widget_name ); |
|
151 | + $private_callback_args = array('__widget_basename' => $widget_name); |
|
152 | 152 | |
153 | - if ( is_null( $callback_args ) ) { |
|
153 | + if (is_null($callback_args)) { |
|
154 | 154 | $callback_args = $private_callback_args; |
155 | - } else if ( is_array( $callback_args ) ) { |
|
156 | - $callback_args = array_merge( $callback_args, $private_callback_args ); |
|
155 | + } else if (is_array($callback_args)) { |
|
156 | + $callback_args = array_merge($callback_args, $private_callback_args); |
|
157 | 157 | } |
158 | 158 | |
159 | - if ( $control_callback && current_user_can( 'edit_dashboard' ) && is_callable( $control_callback ) ) { |
|
159 | + if ($control_callback && current_user_can('edit_dashboard') && is_callable($control_callback)) { |
|
160 | 160 | $wp_dashboard_control_callbacks[$widget_id] = $control_callback; |
161 | - if ( isset( $_GET['edit'] ) && $widget_id == $_GET['edit'] ) { |
|
162 | - list($url) = explode( '#', add_query_arg( 'edit', false ), 2 ); |
|
163 | - $widget_name .= ' <span class="postbox-title-action"><a href="' . esc_url( $url ) . '">' . __( 'Cancel' ) . '</a></span>'; |
|
161 | + if (isset($_GET['edit']) && $widget_id == $_GET['edit']) { |
|
162 | + list($url) = explode('#', add_query_arg('edit', false), 2); |
|
163 | + $widget_name .= ' <span class="postbox-title-action"><a href="'.esc_url($url).'">'.__('Cancel').'</a></span>'; |
|
164 | 164 | $callback = '_wp_dashboard_control_callback'; |
165 | 165 | } else { |
166 | - list($url) = explode( '#', add_query_arg( 'edit', $widget_id ), 2 ); |
|
167 | - $widget_name .= ' <span class="postbox-title-action"><a href="' . esc_url( "$url#$widget_id" ) . '" class="edit-box open-box">' . __( 'Configure' ) . '</a></span>'; |
|
166 | + list($url) = explode('#', add_query_arg('edit', $widget_id), 2); |
|
167 | + $widget_name .= ' <span class="postbox-title-action"><a href="'.esc_url("$url#$widget_id").'" class="edit-box open-box">'.__('Configure').'</a></span>'; |
|
168 | 168 | } |
169 | 169 | } |
170 | 170 | |
171 | - $side_widgets = array( 'dashboard_quick_press', 'dashboard_primary' ); |
|
171 | + $side_widgets = array('dashboard_quick_press', 'dashboard_primary'); |
|
172 | 172 | |
173 | 173 | $location = 'normal'; |
174 | - if ( in_array($widget_id, $side_widgets) ) |
|
174 | + if (in_array($widget_id, $side_widgets)) |
|
175 | 175 | $location = 'side'; |
176 | 176 | |
177 | 177 | $priority = 'core'; |
178 | - if ( 'dashboard_browser_nag' === $widget_id ) |
|
178 | + if ('dashboard_browser_nag' === $widget_id) |
|
179 | 179 | $priority = 'high'; |
180 | 180 | |
181 | - add_meta_box( $widget_id, $widget_name, $callback, $screen, $location, $priority, $callback_args ); |
|
181 | + add_meta_box($widget_id, $widget_name, $callback, $screen, $location, $priority, $callback_args); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -190,12 +190,12 @@ discard block |
||
190 | 190 | * @param mixed $dashboard |
191 | 191 | * @param array $meta_box |
192 | 192 | */ |
193 | -function _wp_dashboard_control_callback( $dashboard, $meta_box ) { |
|
193 | +function _wp_dashboard_control_callback($dashboard, $meta_box) { |
|
194 | 194 | echo '<form method="post" class="dashboard-widget-control-form">'; |
195 | - wp_dashboard_trigger_widget_control( $meta_box['id'] ); |
|
196 | - wp_nonce_field( 'edit-dashboard-widget_' . $meta_box['id'], 'dashboard-widget-nonce' ); |
|
197 | - echo '<input type="hidden" name="widget_id" value="' . esc_attr($meta_box['id']) . '" />'; |
|
198 | - submit_button( __('Submit') ); |
|
195 | + wp_dashboard_trigger_widget_control($meta_box['id']); |
|
196 | + wp_nonce_field('edit-dashboard-widget_'.$meta_box['id'], 'dashboard-widget-nonce'); |
|
197 | + echo '<input type="hidden" name="widget_id" value="'.esc_attr($meta_box['id']).'" />'; |
|
198 | + submit_button(__('Submit')); |
|
199 | 199 | echo '</form>'; |
200 | 200 | } |
201 | 201 | |
@@ -206,31 +206,31 @@ discard block |
||
206 | 206 | */ |
207 | 207 | function wp_dashboard() { |
208 | 208 | $screen = get_current_screen(); |
209 | - $columns = absint( $screen->get_columns() ); |
|
209 | + $columns = absint($screen->get_columns()); |
|
210 | 210 | $columns_css = ''; |
211 | - if ( $columns ) { |
|
211 | + if ($columns) { |
|
212 | 212 | $columns_css = " columns-$columns"; |
213 | 213 | } |
214 | 214 | |
215 | 215 | ?> |
216 | 216 | <div id="dashboard-widgets" class="metabox-holder<?php echo $columns_css; ?>"> |
217 | 217 | <div id="postbox-container-1" class="postbox-container"> |
218 | - <?php do_meta_boxes( $screen->id, 'normal', '' ); ?> |
|
218 | + <?php do_meta_boxes($screen->id, 'normal', ''); ?> |
|
219 | 219 | </div> |
220 | 220 | <div id="postbox-container-2" class="postbox-container"> |
221 | - <?php do_meta_boxes( $screen->id, 'side', '' ); ?> |
|
221 | + <?php do_meta_boxes($screen->id, 'side', ''); ?> |
|
222 | 222 | </div> |
223 | 223 | <div id="postbox-container-3" class="postbox-container"> |
224 | - <?php do_meta_boxes( $screen->id, 'column3', '' ); ?> |
|
224 | + <?php do_meta_boxes($screen->id, 'column3', ''); ?> |
|
225 | 225 | </div> |
226 | 226 | <div id="postbox-container-4" class="postbox-container"> |
227 | - <?php do_meta_boxes( $screen->id, 'column4', '' ); ?> |
|
227 | + <?php do_meta_boxes($screen->id, 'column4', ''); ?> |
|
228 | 228 | </div> |
229 | 229 | </div> |
230 | 230 | |
231 | 231 | <?php |
232 | - wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); |
|
233 | - wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); |
|
232 | + wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); |
|
233 | + wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); |
|
234 | 234 | |
235 | 235 | } |
236 | 236 | |
@@ -251,42 +251,42 @@ discard block |
||
251 | 251 | <ul> |
252 | 252 | <?php |
253 | 253 | // Posts and Pages |
254 | - foreach ( array( 'post', 'page' ) as $post_type ) { |
|
255 | - $num_posts = wp_count_posts( $post_type ); |
|
256 | - if ( $num_posts && $num_posts->publish ) { |
|
257 | - if ( 'post' == $post_type ) { |
|
258 | - $text = _n( '%s Post', '%s Posts', $num_posts->publish ); |
|
254 | + foreach (array('post', 'page') as $post_type) { |
|
255 | + $num_posts = wp_count_posts($post_type); |
|
256 | + if ($num_posts && $num_posts->publish) { |
|
257 | + if ('post' == $post_type) { |
|
258 | + $text = _n('%s Post', '%s Posts', $num_posts->publish); |
|
259 | 259 | } else { |
260 | - $text = _n( '%s Page', '%s Pages', $num_posts->publish ); |
|
260 | + $text = _n('%s Page', '%s Pages', $num_posts->publish); |
|
261 | 261 | } |
262 | - $text = sprintf( $text, number_format_i18n( $num_posts->publish ) ); |
|
263 | - $post_type_object = get_post_type_object( $post_type ); |
|
264 | - if ( $post_type_object && current_user_can( $post_type_object->cap->edit_posts ) ) { |
|
265 | - printf( '<li class="%1$s-count"><a href="edit.php?post_type=%1$s">%2$s</a></li>', $post_type, $text ); |
|
262 | + $text = sprintf($text, number_format_i18n($num_posts->publish)); |
|
263 | + $post_type_object = get_post_type_object($post_type); |
|
264 | + if ($post_type_object && current_user_can($post_type_object->cap->edit_posts)) { |
|
265 | + printf('<li class="%1$s-count"><a href="edit.php?post_type=%1$s">%2$s</a></li>', $post_type, $text); |
|
266 | 266 | } else { |
267 | - printf( '<li class="%1$s-count"><span>%2$s</span></li>', $post_type, $text ); |
|
267 | + printf('<li class="%1$s-count"><span>%2$s</span></li>', $post_type, $text); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | } |
271 | 271 | } |
272 | 272 | // Comments |
273 | 273 | $num_comm = wp_count_comments(); |
274 | - if ( $num_comm && ( $num_comm->approved || $num_comm->moderated ) ) { |
|
275 | - $text = sprintf( _n( '%s Comment', '%s Comments', $num_comm->approved ), number_format_i18n( $num_comm->approved ) ); |
|
274 | + if ($num_comm && ($num_comm->approved || $num_comm->moderated)) { |
|
275 | + $text = sprintf(_n('%s Comment', '%s Comments', $num_comm->approved), number_format_i18n($num_comm->approved)); |
|
276 | 276 | ?> |
277 | 277 | <li class="comment-count"><a href="edit-comments.php"><?php echo $text; ?></a></li> |
278 | 278 | <?php |
279 | - $moderated_comments_count_i18n = number_format_i18n( $num_comm->moderated ); |
|
279 | + $moderated_comments_count_i18n = number_format_i18n($num_comm->moderated); |
|
280 | 280 | /* translators: Number of comments in moderation */ |
281 | - $text = sprintf( _nx( '%s in moderation', '%s in moderation', $num_comm->moderated, 'comments' ), $moderated_comments_count_i18n ); |
|
281 | + $text = sprintf(_nx('%s in moderation', '%s in moderation', $num_comm->moderated, 'comments'), $moderated_comments_count_i18n); |
|
282 | 282 | /* translators: Number of comments in moderation */ |
283 | - $aria_label = sprintf( _nx( '%s comment in moderation', '%s comments in moderation', $num_comm->moderated, 'comments' ), $moderated_comments_count_i18n ); |
|
283 | + $aria_label = sprintf(_nx('%s comment in moderation', '%s comments in moderation', $num_comm->moderated, 'comments'), $moderated_comments_count_i18n); |
|
284 | 284 | ?> |
285 | 285 | <li class="comment-mod-count<?php |
286 | - if ( ! $num_comm->moderated ) { |
|
286 | + if ( ! $num_comm->moderated) { |
|
287 | 287 | echo ' hidden'; |
288 | 288 | } |
289 | - ?>"><a href="edit-comments.php?comment_status=moderated" aria-label="<?php esc_attr_e( $aria_label ); ?>"><?php echo $text; ?></a></li> |
|
289 | + ?>"><a href="edit-comments.php?comment_status=moderated" aria-label="<?php esc_attr_e($aria_label); ?>"><?php echo $text; ?></a></li> |
|
290 | 290 | <?php |
291 | 291 | } |
292 | 292 | |
@@ -301,10 +301,10 @@ discard block |
||
301 | 301 | * |
302 | 302 | * @param array $items Array of extra 'At a Glance' widget items. |
303 | 303 | */ |
304 | - $elements = apply_filters( 'dashboard_glance_items', array() ); |
|
304 | + $elements = apply_filters('dashboard_glance_items', array()); |
|
305 | 305 | |
306 | - if ( $elements ) { |
|
307 | - echo '<li>' . implode( "</li>\n<li>", $elements ) . "</li>\n"; |
|
306 | + if ($elements) { |
|
307 | + echo '<li>'.implode("</li>\n<li>", $elements)."</li>\n"; |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | ?> |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | update_right_now_message(); |
314 | 314 | |
315 | 315 | // Check if search engines are asked not to index this site. |
316 | - if ( ! is_network_admin() && ! is_user_admin() && current_user_can( 'manage_options' ) && '0' == get_option( 'blog_public' ) ) { |
|
316 | + if ( ! is_network_admin() && ! is_user_admin() && current_user_can('manage_options') && '0' == get_option('blog_public')) { |
|
317 | 317 | |
318 | 318 | /** |
319 | 319 | * Filters the link title attribute for the 'Search Engines Discouraged' |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | * |
327 | 327 | * @param string $title Default attribute text. |
328 | 328 | */ |
329 | - $title = apply_filters( 'privacy_on_link_title', '' ); |
|
329 | + $title = apply_filters('privacy_on_link_title', ''); |
|
330 | 330 | |
331 | 331 | /** |
332 | 332 | * Filters the link label for the 'Search Engines Discouraged' message |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | * |
339 | 339 | * @param string $content Default text. |
340 | 340 | */ |
341 | - $content = apply_filters( 'privacy_on_link_text' , __( 'Search Engines Discouraged' ) ); |
|
341 | + $content = apply_filters('privacy_on_link_text', __('Search Engines Discouraged')); |
|
342 | 342 | $title_attr = '' === $title ? '' : " title='$title'"; |
343 | 343 | |
344 | 344 | echo "<p><a href='options-reading.php'$title_attr>$content</a></p>"; |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | * |
360 | 360 | * @since 2.5.0 |
361 | 361 | */ |
362 | - do_action( 'rightnow_end' ); |
|
362 | + do_action('rightnow_end'); |
|
363 | 363 | |
364 | 364 | /** |
365 | 365 | * Fires at the end of the 'At a Glance' dashboard widget. |
@@ -368,11 +368,11 @@ discard block |
||
368 | 368 | * |
369 | 369 | * @since 2.0.0 |
370 | 370 | */ |
371 | - do_action( 'activity_box_end' ); |
|
371 | + do_action('activity_box_end'); |
|
372 | 372 | |
373 | 373 | $actions = ob_get_clean(); |
374 | 374 | |
375 | - if ( !empty( $actions ) ) : ?> |
|
375 | + if ( ! empty($actions)) : ?> |
|
376 | 376 | <div class="sub"> |
377 | 377 | <?php echo $actions; ?> |
378 | 378 | </div> |
@@ -384,25 +384,25 @@ discard block |
||
384 | 384 | */ |
385 | 385 | function wp_network_dashboard_right_now() { |
386 | 386 | $actions = array(); |
387 | - if ( current_user_can('create_sites') ) |
|
388 | - $actions['create-site'] = '<a href="' . network_admin_url('site-new.php') . '">' . __( 'Create a New Site' ) . '</a>'; |
|
389 | - if ( current_user_can('create_users') ) |
|
390 | - $actions['create-user'] = '<a href="' . network_admin_url('user-new.php') . '">' . __( 'Create a New User' ) . '</a>'; |
|
387 | + if (current_user_can('create_sites')) |
|
388 | + $actions['create-site'] = '<a href="'.network_admin_url('site-new.php').'">'.__('Create a New Site').'</a>'; |
|
389 | + if (current_user_can('create_users')) |
|
390 | + $actions['create-user'] = '<a href="'.network_admin_url('user-new.php').'">'.__('Create a New User').'</a>'; |
|
391 | 391 | |
392 | 392 | $c_users = get_user_count(); |
393 | 393 | $c_blogs = get_blog_count(); |
394 | 394 | |
395 | - $user_text = sprintf( _n( '%s user', '%s users', $c_users ), number_format_i18n( $c_users ) ); |
|
396 | - $blog_text = sprintf( _n( '%s site', '%s sites', $c_blogs ), number_format_i18n( $c_blogs ) ); |
|
395 | + $user_text = sprintf(_n('%s user', '%s users', $c_users), number_format_i18n($c_users)); |
|
396 | + $blog_text = sprintf(_n('%s site', '%s sites', $c_blogs), number_format_i18n($c_blogs)); |
|
397 | 397 | |
398 | - $sentence = sprintf( __( 'You have %1$s and %2$s.' ), $blog_text, $user_text ); |
|
398 | + $sentence = sprintf(__('You have %1$s and %2$s.'), $blog_text, $user_text); |
|
399 | 399 | |
400 | - if ( $actions ) { |
|
400 | + if ($actions) { |
|
401 | 401 | echo '<ul class="subsubsub">'; |
402 | - foreach ( $actions as $class => $action ) { |
|
403 | - $actions[ $class ] = "\t<li class='$class'>$action"; |
|
402 | + foreach ($actions as $class => $action) { |
|
403 | + $actions[$class] = "\t<li class='$class'>$action"; |
|
404 | 404 | } |
405 | - echo implode( " |</li>\n", $actions ) . "</li>\n"; |
|
405 | + echo implode(" |</li>\n", $actions)."</li>\n"; |
|
406 | 406 | echo '</ul>'; |
407 | 407 | } |
408 | 408 | ?> |
@@ -420,22 +420,22 @@ discard block |
||
420 | 420 | * |
421 | 421 | * @param null $unused |
422 | 422 | */ |
423 | - do_action( 'wpmuadminresult', '' ); |
|
423 | + do_action('wpmuadminresult', ''); |
|
424 | 424 | ?> |
425 | 425 | |
426 | 426 | <form action="<?php echo network_admin_url('users.php'); ?>" method="get"> |
427 | 427 | <p> |
428 | - <label class="screen-reader-text" for="search-users"><?php _e( 'Search Users' ); ?></label> |
|
428 | + <label class="screen-reader-text" for="search-users"><?php _e('Search Users'); ?></label> |
|
429 | 429 | <input type="search" name="s" value="" size="30" autocomplete="off" id="search-users"/> |
430 | - <?php submit_button( __( 'Search Users' ), 'button', false, false, array( 'id' => 'submit_users' ) ); ?> |
|
430 | + <?php submit_button(__('Search Users'), 'button', false, false, array('id' => 'submit_users')); ?> |
|
431 | 431 | </p> |
432 | 432 | </form> |
433 | 433 | |
434 | 434 | <form action="<?php echo network_admin_url('sites.php'); ?>" method="get"> |
435 | 435 | <p> |
436 | - <label class="screen-reader-text" for="search-sites"><?php _e( 'Search Sites' ); ?></label> |
|
436 | + <label class="screen-reader-text" for="search-sites"><?php _e('Search Sites'); ?></label> |
|
437 | 437 | <input type="search" name="s" value="" size="30" autocomplete="off" id="search-sites"/> |
438 | - <?php submit_button( __( 'Search Sites' ), 'button', false, false, array( 'id' => 'submit_sites' ) ); ?> |
|
438 | + <?php submit_button(__('Search Sites'), 'button', false, false, array('id' => 'submit_sites')); ?> |
|
439 | 439 | </p> |
440 | 440 | </form> |
441 | 441 | <?php |
@@ -444,14 +444,14 @@ discard block |
||
444 | 444 | * |
445 | 445 | * @since MU |
446 | 446 | */ |
447 | - do_action( 'mu_rightnow_end' ); |
|
447 | + do_action('mu_rightnow_end'); |
|
448 | 448 | |
449 | 449 | /** |
450 | 450 | * Fires at the end of the 'Right Now' widget in the Network Admin dashboard. |
451 | 451 | * |
452 | 452 | * @since MU |
453 | 453 | */ |
454 | - do_action( 'mu_activity_box_end' ); |
|
454 | + do_action('mu_activity_box_end'); |
|
455 | 455 | } |
456 | 456 | |
457 | 457 | /** |
@@ -463,37 +463,37 @@ discard block |
||
463 | 463 | * |
464 | 464 | * @param string $error_msg Optional. Error message. Default false. |
465 | 465 | */ |
466 | -function wp_dashboard_quick_press( $error_msg = false ) { |
|
466 | +function wp_dashboard_quick_press($error_msg = false) { |
|
467 | 467 | global $post_ID; |
468 | 468 | |
469 | - if ( ! current_user_can( 'edit_posts' ) ) { |
|
469 | + if ( ! current_user_can('edit_posts')) { |
|
470 | 470 | return; |
471 | 471 | } |
472 | 472 | |
473 | 473 | /* Check if a new auto-draft (= no new post_ID) is needed or if the old can be used */ |
474 | - $last_post_id = (int) get_user_option( 'dashboard_quick_press_last_post_id' ); // Get the last post_ID |
|
475 | - if ( $last_post_id ) { |
|
476 | - $post = get_post( $last_post_id ); |
|
477 | - if ( empty( $post ) || $post->post_status != 'auto-draft' ) { // auto-draft doesn't exists anymore |
|
478 | - $post = get_default_post_to_edit( 'post', true ); |
|
479 | - update_user_option( get_current_user_id(), 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID |
|
474 | + $last_post_id = (int) get_user_option('dashboard_quick_press_last_post_id'); // Get the last post_ID |
|
475 | + if ($last_post_id) { |
|
476 | + $post = get_post($last_post_id); |
|
477 | + if (empty($post) || $post->post_status != 'auto-draft') { // auto-draft doesn't exists anymore |
|
478 | + $post = get_default_post_to_edit('post', true); |
|
479 | + update_user_option(get_current_user_id(), 'dashboard_quick_press_last_post_id', (int) $post->ID); // Save post_ID |
|
480 | 480 | } else { |
481 | 481 | $post->post_title = ''; // Remove the auto draft title |
482 | 482 | } |
483 | 483 | } else { |
484 | - $post = get_default_post_to_edit( 'post' , true); |
|
484 | + $post = get_default_post_to_edit('post', true); |
|
485 | 485 | $user_id = get_current_user_id(); |
486 | 486 | // Don't create an option if this is a super admin who does not belong to this site. |
487 | - if ( ! ( is_super_admin( $user_id ) && ! in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user_id ) ) ) ) ) |
|
488 | - update_user_option( $user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID |
|
487 | + if ( ! (is_super_admin($user_id) && ! in_array(get_current_blog_id(), array_keys(get_blogs_of_user($user_id))))) |
|
488 | + update_user_option($user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID); // Save post_ID |
|
489 | 489 | } |
490 | 490 | |
491 | 491 | $post_ID = (int) $post->ID; |
492 | 492 | ?> |
493 | 493 | |
494 | - <form name="post" action="<?php echo esc_url( admin_url( 'post.php' ) ); ?>" method="post" id="quick-press" class="initial-form hide-if-no-js"> |
|
494 | + <form name="post" action="<?php echo esc_url(admin_url('post.php')); ?>" method="post" id="quick-press" class="initial-form hide-if-no-js"> |
|
495 | 495 | |
496 | - <?php if ( $error_msg ) : ?> |
|
496 | + <?php if ($error_msg) : ?> |
|
497 | 497 | <div class="error"><?php echo $error_msg; ?></div> |
498 | 498 | <?php endif; ?> |
499 | 499 | |
@@ -502,14 +502,14 @@ discard block |
||
502 | 502 | |
503 | 503 | <?php |
504 | 504 | /** This filter is documented in wp-admin/edit-form-advanced.php */ |
505 | - echo apply_filters( 'enter_title_here', __( 'Title' ), $post ); |
|
505 | + echo apply_filters('enter_title_here', __('Title'), $post); |
|
506 | 506 | ?> |
507 | 507 | </label> |
508 | 508 | <input type="text" name="post_title" id="title" autocomplete="off" /> |
509 | 509 | </div> |
510 | 510 | |
511 | 511 | <div class="textarea-wrap" id="description-wrap"> |
512 | - <label class="screen-reader-text prompt" for="content" id="content-prompt-text"><?php _e( 'What’s on your mind?' ); ?></label> |
|
512 | + <label class="screen-reader-text prompt" for="content" id="content-prompt-text"><?php _e('What’s on your mind?'); ?></label> |
|
513 | 513 | <textarea name="content" id="content" class="mceEditor" rows="3" cols="15" autocomplete="off"></textarea> |
514 | 514 | </div> |
515 | 515 | |
@@ -517,8 +517,8 @@ discard block |
||
517 | 517 | <input type="hidden" name="action" id="quickpost-action" value="post-quickdraft-save" /> |
518 | 518 | <input type="hidden" name="post_ID" value="<?php echo $post_ID; ?>" /> |
519 | 519 | <input type="hidden" name="post_type" value="post" /> |
520 | - <?php wp_nonce_field( 'add-post' ); ?> |
|
521 | - <?php submit_button( __( 'Save Draft' ), 'primary', 'save', false, array( 'id' => 'save-post' ) ); ?> |
|
520 | + <?php wp_nonce_field('add-post'); ?> |
|
521 | + <?php submit_button(__('Save Draft'), 'primary', 'save', false, array('id' => 'save-post')); ?> |
|
522 | 522 | <br class="clear" /> |
523 | 523 | </p> |
524 | 524 | |
@@ -534,8 +534,8 @@ discard block |
||
534 | 534 | * |
535 | 535 | * @param array $drafts |
536 | 536 | */ |
537 | -function wp_dashboard_recent_drafts( $drafts = false ) { |
|
538 | - if ( ! $drafts ) { |
|
537 | +function wp_dashboard_recent_drafts($drafts = false) { |
|
538 | + if ( ! $drafts) { |
|
539 | 539 | $query_args = array( |
540 | 540 | 'post_type' => 'post', |
541 | 541 | 'post_status' => 'draft', |
@@ -552,30 +552,30 @@ discard block |
||
552 | 552 | * |
553 | 553 | * @param array $query_args The query arguments for the 'Recent Drafts' dashboard widget. |
554 | 554 | */ |
555 | - $query_args = apply_filters( 'dashboard_recent_drafts_query_args', $query_args ); |
|
555 | + $query_args = apply_filters('dashboard_recent_drafts_query_args', $query_args); |
|
556 | 556 | |
557 | - $drafts = get_posts( $query_args ); |
|
558 | - if ( ! $drafts ) { |
|
557 | + $drafts = get_posts($query_args); |
|
558 | + if ( ! $drafts) { |
|
559 | 559 | return; |
560 | 560 | } |
561 | 561 | } |
562 | 562 | |
563 | 563 | echo '<div class="drafts">'; |
564 | - if ( count( $drafts ) > 3 ) { |
|
565 | - echo '<p class="view-all"><a href="' . esc_url( admin_url( 'edit.php?post_status=draft' ) ) . '" aria-label="' . __( 'View all drafts' ) . '">' . _x( 'View all', 'drafts' ) . "</a></p>\n"; |
|
564 | + if (count($drafts) > 3) { |
|
565 | + echo '<p class="view-all"><a href="'.esc_url(admin_url('edit.php?post_status=draft')).'" aria-label="'.__('View all drafts').'">'._x('View all', 'drafts')."</a></p>\n"; |
|
566 | 566 | } |
567 | - echo '<h2 class="hide-if-no-js">' . __( 'Drafts' ) . "</h2>\n<ul>"; |
|
567 | + echo '<h2 class="hide-if-no-js">'.__('Drafts')."</h2>\n<ul>"; |
|
568 | 568 | |
569 | - $drafts = array_slice( $drafts, 0, 3 ); |
|
570 | - foreach ( $drafts as $draft ) { |
|
571 | - $url = get_edit_post_link( $draft->ID ); |
|
572 | - $title = _draft_or_post_title( $draft->ID ); |
|
569 | + $drafts = array_slice($drafts, 0, 3); |
|
570 | + foreach ($drafts as $draft) { |
|
571 | + $url = get_edit_post_link($draft->ID); |
|
572 | + $title = _draft_or_post_title($draft->ID); |
|
573 | 573 | echo "<li>\n"; |
574 | 574 | /* translators: %s: post title */ |
575 | - echo '<div class="draft-title"><a href="' . esc_url( $url ) . '" aria-label="' . esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ) . '">' . esc_html( $title ) . '</a>'; |
|
576 | - echo '<time datetime="' . get_the_time( 'c', $draft ) . '">' . get_the_time( __( 'F j, Y' ), $draft ) . '</time></div>'; |
|
577 | - if ( $the_content = wp_trim_words( $draft->post_content, 10 ) ) { |
|
578 | - echo '<p>' . $the_content . '</p>'; |
|
575 | + echo '<div class="draft-title"><a href="'.esc_url($url).'" aria-label="'.esc_attr(sprintf(__('Edit “%s”'), $title)).'">'.esc_html($title).'</a>'; |
|
576 | + echo '<time datetime="'.get_the_time('c', $draft).'">'.get_the_time(__('F j, Y'), $draft).'</time></div>'; |
|
577 | + if ($the_content = wp_trim_words($draft->post_content, 10)) { |
|
578 | + echo '<p>'.$the_content.'</p>'; |
|
579 | 579 | } |
580 | 580 | echo "</li>\n"; |
581 | 581 | } |
@@ -593,20 +593,20 @@ discard block |
||
593 | 593 | * @param WP_Comment $comment The current comment. |
594 | 594 | * @param bool $show_date Optional. Whether to display the date. |
595 | 595 | */ |
596 | -function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) { |
|
596 | +function _wp_dashboard_recent_comments_row(&$comment, $show_date = true) { |
|
597 | 597 | $GLOBALS['comment'] = clone $comment; |
598 | 598 | |
599 | - if ( $comment->comment_post_ID > 0 ) { |
|
599 | + if ($comment->comment_post_ID > 0) { |
|
600 | 600 | |
601 | - $comment_post_title = _draft_or_post_title( $comment->comment_post_ID ); |
|
602 | - $comment_post_url = get_the_permalink( $comment->comment_post_ID ); |
|
601 | + $comment_post_title = _draft_or_post_title($comment->comment_post_ID); |
|
602 | + $comment_post_url = get_the_permalink($comment->comment_post_ID); |
|
603 | 603 | $comment_post_link = "<a href='$comment_post_url'>$comment_post_title</a>"; |
604 | 604 | } else { |
605 | 605 | $comment_post_link = ''; |
606 | 606 | } |
607 | 607 | |
608 | 608 | $actions_string = ''; |
609 | - if ( current_user_can( 'edit_comment', $comment->comment_ID ) ) { |
|
609 | + if (current_user_can('edit_comment', $comment->comment_ID)) { |
|
610 | 610 | // Pre-order it: Approve | Reply | Edit | Spam | Trash. |
611 | 611 | $actions = array( |
612 | 612 | 'approve' => '', 'unapprove' => '', |
@@ -617,28 +617,28 @@ discard block |
||
617 | 617 | 'view' => '', |
618 | 618 | ); |
619 | 619 | |
620 | - $del_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "delete-comment_$comment->comment_ID" ) ); |
|
621 | - $approve_nonce = esc_html( '_wpnonce=' . wp_create_nonce( "approve-comment_$comment->comment_ID" ) ); |
|
620 | + $del_nonce = esc_html('_wpnonce='.wp_create_nonce("delete-comment_$comment->comment_ID")); |
|
621 | + $approve_nonce = esc_html('_wpnonce='.wp_create_nonce("approve-comment_$comment->comment_ID")); |
|
622 | 622 | |
623 | - $approve_url = esc_url( "comment.php?action=approvecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" ); |
|
624 | - $unapprove_url = esc_url( "comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce" ); |
|
625 | - $spam_url = esc_url( "comment.php?action=spamcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" ); |
|
626 | - $trash_url = esc_url( "comment.php?action=trashcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" ); |
|
627 | - $delete_url = esc_url( "comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce" ); |
|
623 | + $approve_url = esc_url("comment.php?action=approvecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce"); |
|
624 | + $unapprove_url = esc_url("comment.php?action=unapprovecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$approve_nonce"); |
|
625 | + $spam_url = esc_url("comment.php?action=spamcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce"); |
|
626 | + $trash_url = esc_url("comment.php?action=trashcomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce"); |
|
627 | + $delete_url = esc_url("comment.php?action=deletecomment&p=$comment->comment_post_ID&c=$comment->comment_ID&$del_nonce"); |
|
628 | 628 | |
629 | - $actions['approve'] = "<a href='$approve_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved' class='vim-a' aria-label='" . esc_attr__( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a>'; |
|
630 | - $actions['unapprove'] = "<a href='$unapprove_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved' class='vim-u' aria-label='" . esc_attr__( 'Unapprove this comment' ) . "'>" . __( 'Unapprove' ) . '</a>'; |
|
631 | - $actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' aria-label='" . esc_attr__( 'Edit this comment' ) . "'>". __( 'Edit' ) . '</a>'; |
|
632 | - $actions['reply'] = '<a onclick="window.commentReply && commentReply.open(\'' . $comment->comment_ID . '\',\''.$comment->comment_post_ID.'\');return false;" class="vim-r hide-if-no-js" aria-label="' . esc_attr__( 'Reply to this comment' ) . '" href="#">' . __( 'Reply' ) . '</a>'; |
|
633 | - $actions['spam'] = "<a href='$spam_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::spam=1' class='vim-s vim-destructive' aria-label='" . esc_attr__( 'Mark this comment as spam' ) . "'>" . /* translators: mark as spam link */ _x( 'Spam', 'verb' ) . '</a>'; |
|
629 | + $actions['approve'] = "<a href='$approve_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=approved' class='vim-a' aria-label='".esc_attr__('Approve this comment')."'>".__('Approve').'</a>'; |
|
630 | + $actions['unapprove'] = "<a href='$unapprove_url' data-wp-lists='dim:the-comment-list:comment-$comment->comment_ID:unapproved:e7e7d3:e7e7d3:new=unapproved' class='vim-u' aria-label='".esc_attr__('Unapprove this comment')."'>".__('Unapprove').'</a>'; |
|
631 | + $actions['edit'] = "<a href='comment.php?action=editcomment&c={$comment->comment_ID}' aria-label='".esc_attr__('Edit this comment')."'>".__('Edit').'</a>'; |
|
632 | + $actions['reply'] = '<a onclick="window.commentReply && commentReply.open(\''.$comment->comment_ID.'\',\''.$comment->comment_post_ID.'\');return false;" class="vim-r hide-if-no-js" aria-label="'.esc_attr__('Reply to this comment').'" href="#">'.__('Reply').'</a>'; |
|
633 | + $actions['spam'] = "<a href='$spam_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::spam=1' class='vim-s vim-destructive' aria-label='".esc_attr__('Mark this comment as spam')."'>"./* translators: mark as spam link */ _x('Spam', 'verb').'</a>'; |
|
634 | 634 | |
635 | - if ( ! EMPTY_TRASH_DAYS ) { |
|
636 | - $actions['delete'] = "<a href='$delete_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive' aria-label='" . esc_attr__( 'Delete this comment permanently' ) . "'>" . __( 'Delete Permanently' ) . '</a>'; |
|
635 | + if ( ! EMPTY_TRASH_DAYS) { |
|
636 | + $actions['delete'] = "<a href='$delete_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive' aria-label='".esc_attr__('Delete this comment permanently')."'>".__('Delete Permanently').'</a>'; |
|
637 | 637 | } else { |
638 | - $actions['trash'] = "<a href='$trash_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive' aria-label='" . esc_attr__( 'Move this comment to the Trash' ) . "'>" . _x( 'Trash', 'verb' ) . '</a>'; |
|
638 | + $actions['trash'] = "<a href='$trash_url' data-wp-lists='delete:the-comment-list:comment-$comment->comment_ID::trash=1' class='delete vim-d vim-destructive' aria-label='".esc_attr__('Move this comment to the Trash')."'>"._x('Trash', 'verb').'</a>'; |
|
639 | 639 | } |
640 | 640 | |
641 | - $actions['view'] = '<a class="comment-link" href="' . esc_url( get_comment_link( $comment ) ) . '" aria-label="' . esc_attr__( 'View this comment' ) . '">' . __( 'View' ) . '</a>'; |
|
641 | + $actions['view'] = '<a class="comment-link" href="'.esc_url(get_comment_link($comment)).'" aria-label="'.esc_attr__('View this comment').'">'.__('View').'</a>'; |
|
642 | 642 | |
643 | 643 | /** |
644 | 644 | * Filters the action links displayed for each comment in the 'Recent Comments' |
@@ -651,19 +651,19 @@ discard block |
||
651 | 651 | * 'Delete', and 'Trash'. |
652 | 652 | * @param WP_Comment $comment The comment object. |
653 | 653 | */ |
654 | - $actions = apply_filters( 'comment_row_actions', array_filter($actions), $comment ); |
|
654 | + $actions = apply_filters('comment_row_actions', array_filter($actions), $comment); |
|
655 | 655 | |
656 | 656 | $i = 0; |
657 | - foreach ( $actions as $action => $link ) { |
|
657 | + foreach ($actions as $action => $link) { |
|
658 | 658 | ++$i; |
659 | - ( ( ('approve' == $action || 'unapprove' == $action) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | '; |
|
659 | + ((('approve' == $action || 'unapprove' == $action) && 2 === $i) || 1 === $i) ? $sep = '' : $sep = ' | '; |
|
660 | 660 | |
661 | 661 | // Reply and quickedit need a hide-if-no-js span |
662 | - if ( 'reply' == $action || 'quickedit' == $action ) { |
|
662 | + if ('reply' == $action || 'quickedit' == $action) { |
|
663 | 663 | $action .= ' hide-if-no-js'; |
664 | 664 | } |
665 | 665 | |
666 | - if ( 'view' === $action && '1' !== $comment->comment_approved ) { |
|
666 | + if ('view' === $action && '1' !== $comment->comment_approved) { |
|
667 | 667 | $action .= ' hidden'; |
668 | 668 | } |
669 | 669 | $actions_string .= "<span class='$action'>$sep$link</span>"; |
@@ -671,30 +671,30 @@ discard block |
||
671 | 671 | } |
672 | 672 | ?> |
673 | 673 | |
674 | - <li id="comment-<?php echo $comment->comment_ID; ?>" <?php comment_class( array( 'comment-item', wp_get_comment_status( $comment ) ), $comment ); ?>> |
|
674 | + <li id="comment-<?php echo $comment->comment_ID; ?>" <?php comment_class(array('comment-item', wp_get_comment_status($comment)), $comment); ?>> |
|
675 | 675 | |
676 | - <?php echo get_avatar( $comment, 50, 'mystery' ); ?> |
|
676 | + <?php echo get_avatar($comment, 50, 'mystery'); ?> |
|
677 | 677 | |
678 | - <?php if ( !$comment->comment_type || 'comment' == $comment->comment_type ) : ?> |
|
678 | + <?php if ( ! $comment->comment_type || 'comment' == $comment->comment_type) : ?> |
|
679 | 679 | |
680 | 680 | <div class="dashboard-comment-wrap has-row-actions"> |
681 | 681 | <p class="comment-meta"> |
682 | 682 | <?php |
683 | 683 | // Comments might not have a post they relate to, e.g. programmatically created ones. |
684 | - if ( $comment_post_link ) { |
|
684 | + if ($comment_post_link) { |
|
685 | 685 | printf( |
686 | 686 | /* translators: 1: comment author, 2: post link, 3: notification if the comment is pending */ |
687 | - __( 'From %1$s on %2$s %3$s' ), |
|
688 | - '<cite class="comment-author">' . get_comment_author_link( $comment ) . '</cite>', |
|
687 | + __('From %1$s on %2$s %3$s'), |
|
688 | + '<cite class="comment-author">'.get_comment_author_link($comment).'</cite>', |
|
689 | 689 | $comment_post_link, |
690 | - '<span class="approve">' . __( '[Pending]' ) . '</span>' |
|
690 | + '<span class="approve">'.__('[Pending]').'</span>' |
|
691 | 691 | ); |
692 | 692 | } else { |
693 | 693 | printf( |
694 | 694 | /* translators: 1: comment author, 2: notification if the comment is pending */ |
695 | - __( 'From %1$s %2$s' ), |
|
696 | - '<cite class="comment-author">' . get_comment_author_link( $comment ) . '</cite>', |
|
697 | - '<span class="approve">' . __( '[Pending]' ) . '</span>' |
|
695 | + __('From %1$s %2$s'), |
|
696 | + '<cite class="comment-author">'.get_comment_author_link($comment).'</cite>', |
|
697 | + '<span class="approve">'.__('[Pending]').'</span>' |
|
698 | 698 | ); |
699 | 699 | } |
700 | 700 | ?> |
@@ -702,45 +702,45 @@ discard block |
||
702 | 702 | |
703 | 703 | <?php |
704 | 704 | else : |
705 | - switch ( $comment->comment_type ) { |
|
705 | + switch ($comment->comment_type) { |
|
706 | 706 | case 'pingback' : |
707 | - $type = __( 'Pingback' ); |
|
707 | + $type = __('Pingback'); |
|
708 | 708 | break; |
709 | 709 | case 'trackback' : |
710 | - $type = __( 'Trackback' ); |
|
710 | + $type = __('Trackback'); |
|
711 | 711 | break; |
712 | 712 | default : |
713 | - $type = ucwords( $comment->comment_type ); |
|
713 | + $type = ucwords($comment->comment_type); |
|
714 | 714 | } |
715 | - $type = esc_html( $type ); |
|
715 | + $type = esc_html($type); |
|
716 | 716 | ?> |
717 | 717 | <div class="dashboard-comment-wrap has-row-actions"> |
718 | 718 | <p class="comment-meta"> |
719 | 719 | <?php |
720 | 720 | // Pingbacks, Trackbacks or custom comment types might not have a post they relate to, e.g. programmatically created ones. |
721 | - if ( $comment_post_link ) { |
|
721 | + if ($comment_post_link) { |
|
722 | 722 | printf( |
723 | 723 | /* translators: 1: type of comment, 2: post link, 3: notification if the comment is pending */ |
724 | - _x( '%1$s on %2$s %3$s', 'dashboard' ), |
|
724 | + _x('%1$s on %2$s %3$s', 'dashboard'), |
|
725 | 725 | "<strong>$type</strong>", |
726 | 726 | $comment_post_link, |
727 | - '<span class="approve">' . __( '[Pending]' ) . '</span>' |
|
727 | + '<span class="approve">'.__('[Pending]').'</span>' |
|
728 | 728 | ); |
729 | 729 | } else { |
730 | 730 | printf( |
731 | 731 | /* translators: 1: type of comment, 2: notification if the comment is pending */ |
732 | - _x( '%1$s %2$s', 'dashboard' ), |
|
732 | + _x('%1$s %2$s', 'dashboard'), |
|
733 | 733 | "<strong>$type</strong>", |
734 | - '<span class="approve">' . __( '[Pending]' ) . '</span>' |
|
734 | + '<span class="approve">'.__('[Pending]').'</span>' |
|
735 | 735 | ); |
736 | 736 | } |
737 | 737 | ?> |
738 | 738 | </p> |
739 | - <p class="comment-author"><?php comment_author_link( $comment ); ?></p> |
|
739 | + <p class="comment-author"><?php comment_author_link($comment); ?></p> |
|
740 | 740 | |
741 | 741 | <?php endif; // comment_type ?> |
742 | - <blockquote><p><?php comment_excerpt( $comment ); ?></p></blockquote> |
|
743 | - <?php if ( $actions_string ) : ?> |
|
742 | + <blockquote><p><?php comment_excerpt($comment); ?></p></blockquote> |
|
743 | + <?php if ($actions_string) : ?> |
|
744 | 744 | <p class="row-actions"><?php echo $actions_string; ?></p> |
745 | 745 | <?php endif; ?> |
746 | 746 | </div> |
@@ -758,27 +758,27 @@ discard block |
||
758 | 758 | |
759 | 759 | echo '<div id="activity-widget">'; |
760 | 760 | |
761 | - $future_posts = wp_dashboard_recent_posts( array( |
|
761 | + $future_posts = wp_dashboard_recent_posts(array( |
|
762 | 762 | 'max' => 5, |
763 | 763 | 'status' => 'future', |
764 | 764 | 'order' => 'ASC', |
765 | - 'title' => __( 'Publishing Soon' ), |
|
765 | + 'title' => __('Publishing Soon'), |
|
766 | 766 | 'id' => 'future-posts', |
767 | - ) ); |
|
768 | - $recent_posts = wp_dashboard_recent_posts( array( |
|
767 | + )); |
|
768 | + $recent_posts = wp_dashboard_recent_posts(array( |
|
769 | 769 | 'max' => 5, |
770 | 770 | 'status' => 'publish', |
771 | 771 | 'order' => 'DESC', |
772 | - 'title' => __( 'Recently Published' ), |
|
772 | + 'title' => __('Recently Published'), |
|
773 | 773 | 'id' => 'published-posts', |
774 | - ) ); |
|
774 | + )); |
|
775 | 775 | |
776 | 776 | $recent_comments = wp_dashboard_recent_comments(); |
777 | 777 | |
778 | - if ( !$future_posts && !$recent_posts && !$recent_comments ) { |
|
778 | + if ( ! $future_posts && ! $recent_posts && ! $recent_comments) { |
|
779 | 779 | echo '<div class="no-activity">'; |
780 | 780 | echo '<p class="smiley"></p>'; |
781 | - echo '<p>' . __( 'No activity yet!' ) . '</p>'; |
|
781 | + echo '<p>'.__('No activity yet!').'</p>'; |
|
782 | 782 | echo '</div>'; |
783 | 783 | } |
784 | 784 | |
@@ -801,16 +801,16 @@ discard block |
||
801 | 801 | * } |
802 | 802 | * @return bool False if no posts were found. True otherwise. |
803 | 803 | */ |
804 | -function wp_dashboard_recent_posts( $args ) { |
|
804 | +function wp_dashboard_recent_posts($args) { |
|
805 | 805 | $query_args = array( |
806 | 806 | 'post_type' => 'post', |
807 | 807 | 'post_status' => $args['status'], |
808 | 808 | 'orderby' => 'date', |
809 | 809 | 'order' => $args['order'], |
810 | - 'posts_per_page' => intval( $args['max'] ), |
|
810 | + 'posts_per_page' => intval($args['max']), |
|
811 | 811 | 'no_found_rows' => true, |
812 | 812 | 'cache_results' => false, |
813 | - 'perm' => ( 'future' === $args['status'] ) ? 'editable' : 'readable', |
|
813 | + 'perm' => ('future' === $args['status']) ? 'editable' : 'readable', |
|
814 | 814 | ); |
815 | 815 | |
816 | 816 | /** |
@@ -820,47 +820,47 @@ discard block |
||
820 | 820 | * |
821 | 821 | * @param array $query_args The arguments passed to WP_Query to produce the list of posts. |
822 | 822 | */ |
823 | - $query_args = apply_filters( 'dashboard_recent_posts_query_args', $query_args ); |
|
824 | - $posts = new WP_Query( $query_args ); |
|
823 | + $query_args = apply_filters('dashboard_recent_posts_query_args', $query_args); |
|
824 | + $posts = new WP_Query($query_args); |
|
825 | 825 | |
826 | - if ( $posts->have_posts() ) { |
|
826 | + if ($posts->have_posts()) { |
|
827 | 827 | |
828 | - echo '<div id="' . $args['id'] . '" class="activity-block">'; |
|
828 | + echo '<div id="'.$args['id'].'" class="activity-block">'; |
|
829 | 829 | |
830 | - echo '<h3>' . $args['title'] . '</h3>'; |
|
830 | + echo '<h3>'.$args['title'].'</h3>'; |
|
831 | 831 | |
832 | 832 | echo '<ul>'; |
833 | 833 | |
834 | - $today = date( 'Y-m-d', current_time( 'timestamp' ) ); |
|
835 | - $tomorrow = date( 'Y-m-d', strtotime( '+1 day', current_time( 'timestamp' ) ) ); |
|
834 | + $today = date('Y-m-d', current_time('timestamp')); |
|
835 | + $tomorrow = date('Y-m-d', strtotime('+1 day', current_time('timestamp'))); |
|
836 | 836 | |
837 | - while ( $posts->have_posts() ) { |
|
837 | + while ($posts->have_posts()) { |
|
838 | 838 | $posts->the_post(); |
839 | 839 | |
840 | - $time = get_the_time( 'U' ); |
|
841 | - if ( date( 'Y-m-d', $time ) == $today ) { |
|
842 | - $relative = __( 'Today' ); |
|
843 | - } elseif ( date( 'Y-m-d', $time ) == $tomorrow ) { |
|
844 | - $relative = __( 'Tomorrow' ); |
|
845 | - } elseif ( date( 'Y', $time ) !== date( 'Y', current_time( 'timestamp' ) ) ) { |
|
840 | + $time = get_the_time('U'); |
|
841 | + if (date('Y-m-d', $time) == $today) { |
|
842 | + $relative = __('Today'); |
|
843 | + } elseif (date('Y-m-d', $time) == $tomorrow) { |
|
844 | + $relative = __('Tomorrow'); |
|
845 | + } elseif (date('Y', $time) !== date('Y', current_time('timestamp'))) { |
|
846 | 846 | /* translators: date and time format for recent posts on the dashboard, from a different calendar year, see https://secure.php.net/date */ |
847 | - $relative = date_i18n( __( 'M jS Y' ), $time ); |
|
847 | + $relative = date_i18n(__('M jS Y'), $time); |
|
848 | 848 | } else { |
849 | 849 | /* translators: date and time format for recent posts on the dashboard, see https://secure.php.net/date */ |
850 | - $relative = date_i18n( __( 'M jS' ), $time ); |
|
850 | + $relative = date_i18n(__('M jS'), $time); |
|
851 | 851 | } |
852 | 852 | |
853 | 853 | // Use the post edit link for those who can edit, the permalink otherwise. |
854 | - $recent_post_link = current_user_can( 'edit_post', get_the_ID() ) ? get_edit_post_link() : get_permalink(); |
|
854 | + $recent_post_link = current_user_can('edit_post', get_the_ID()) ? get_edit_post_link() : get_permalink(); |
|
855 | 855 | |
856 | 856 | $draft_or_post_title = _draft_or_post_title(); |
857 | 857 | printf( |
858 | 858 | '<li><span>%1$s</span> <a href="%2$s" aria-label="%3$s">%4$s</a></li>', |
859 | 859 | /* translators: 1: relative date, 2: time */ |
860 | - sprintf( _x( '%1$s, %2$s', 'dashboard' ), $relative, get_the_time() ), |
|
860 | + sprintf(_x('%1$s, %2$s', 'dashboard'), $relative, get_the_time()), |
|
861 | 861 | $recent_post_link, |
862 | 862 | /* translators: %s: post title */ |
863 | - esc_attr( sprintf( __( 'Edit “%s”' ), $draft_or_post_title ) ), |
|
863 | + esc_attr(sprintf(__('Edit “%s”'), $draft_or_post_title)), |
|
864 | 864 | $draft_or_post_title |
865 | 865 | ); |
866 | 866 | } |
@@ -885,7 +885,7 @@ discard block |
||
885 | 885 | * @param int $total_items Optional. Number of comments to query. Default 5. |
886 | 886 | * @return bool False if no comments were found. True otherwise. |
887 | 887 | */ |
888 | -function wp_dashboard_recent_comments( $total_items = 5 ) { |
|
888 | +function wp_dashboard_recent_comments($total_items = 5) { |
|
889 | 889 | // Select all comment types and filter out spam later for better query performance. |
890 | 890 | $comments = array(); |
891 | 891 | |
@@ -893,36 +893,36 @@ discard block |
||
893 | 893 | 'number' => $total_items * 5, |
894 | 894 | 'offset' => 0 |
895 | 895 | ); |
896 | - if ( ! current_user_can( 'edit_posts' ) ) |
|
896 | + if ( ! current_user_can('edit_posts')) |
|
897 | 897 | $comments_query['status'] = 'approve'; |
898 | 898 | |
899 | - while ( count( $comments ) < $total_items && $possible = get_comments( $comments_query ) ) { |
|
900 | - if ( ! is_array( $possible ) ) { |
|
899 | + while (count($comments) < $total_items && $possible = get_comments($comments_query)) { |
|
900 | + if ( ! is_array($possible)) { |
|
901 | 901 | break; |
902 | 902 | } |
903 | - foreach ( $possible as $comment ) { |
|
904 | - if ( ! current_user_can( 'read_post', $comment->comment_post_ID ) ) |
|
903 | + foreach ($possible as $comment) { |
|
904 | + if ( ! current_user_can('read_post', $comment->comment_post_ID)) |
|
905 | 905 | continue; |
906 | 906 | $comments[] = $comment; |
907 | - if ( count( $comments ) == $total_items ) |
|
907 | + if (count($comments) == $total_items) |
|
908 | 908 | break 2; |
909 | 909 | } |
910 | 910 | $comments_query['offset'] += $comments_query['number']; |
911 | 911 | $comments_query['number'] = $total_items * 10; |
912 | 912 | } |
913 | 913 | |
914 | - if ( $comments ) { |
|
914 | + if ($comments) { |
|
915 | 915 | echo '<div id="latest-comments" class="activity-block">'; |
916 | - echo '<h3>' . __( 'Recent Comments' ) . '</h3>'; |
|
916 | + echo '<h3>'.__('Recent Comments').'</h3>'; |
|
917 | 917 | |
918 | 918 | echo '<ul id="the-comment-list" data-wp-lists="list:comment">'; |
919 | - foreach ( $comments as $comment ) |
|
920 | - _wp_dashboard_recent_comments_row( $comment ); |
|
919 | + foreach ($comments as $comment) |
|
920 | + _wp_dashboard_recent_comments_row($comment); |
|
921 | 921 | echo '</ul>'; |
922 | 922 | |
923 | - if ( current_user_can( 'edit_posts' ) ) { |
|
924 | - echo '<h3 class="screen-reader-text">' . __( 'View more comments' ) . '</h3>'; |
|
925 | - _get_list_table( 'WP_Comments_List_Table' )->views(); |
|
923 | + if (current_user_can('edit_posts')) { |
|
924 | + echo '<h3 class="screen-reader-text">'.__('View more comments').'</h3>'; |
|
925 | + _get_list_table('WP_Comments_List_Table')->views(); |
|
926 | 926 | } |
927 | 927 | |
928 | 928 | wp_comment_reply( -1, false, 'dashboard', false ); |
@@ -942,10 +942,10 @@ discard block |
||
942 | 942 | * |
943 | 943 | * @param string $widget_id |
944 | 944 | */ |
945 | -function wp_dashboard_rss_output( $widget_id ) { |
|
946 | - $widgets = get_option( 'dashboard_widget_options' ); |
|
945 | +function wp_dashboard_rss_output($widget_id) { |
|
946 | + $widgets = get_option('dashboard_widget_options'); |
|
947 | 947 | echo '<div class="rss-widget">'; |
948 | - wp_widget_rss_output( $widgets[ $widget_id ] ); |
|
948 | + wp_widget_rss_output($widgets[$widget_id]); |
|
949 | 949 | echo "</div>"; |
950 | 950 | } |
951 | 951 | |
@@ -964,37 +964,37 @@ discard block |
||
964 | 964 | * @param array $check_urls RSS feeds |
965 | 965 | * @return bool False on failure. True on success. |
966 | 966 | */ |
967 | -function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = array() ) { |
|
968 | - $loading = '<p class="widget-loading hide-if-no-js">' . __( 'Loading…' ) . '</p><p class="hide-if-js">' . __( 'This widget requires JavaScript.' ) . '</p>'; |
|
969 | - $doing_ajax = ( defined('DOING_AJAX') && DOING_AJAX ); |
|
967 | +function wp_dashboard_cached_rss_widget($widget_id, $callback, $check_urls = array()) { |
|
968 | + $loading = '<p class="widget-loading hide-if-no-js">'.__('Loading…').'</p><p class="hide-if-js">'.__('This widget requires JavaScript.').'</p>'; |
|
969 | + $doing_ajax = (defined('DOING_AJAX') && DOING_AJAX); |
|
970 | 970 | |
971 | - if ( empty($check_urls) ) { |
|
972 | - $widgets = get_option( 'dashboard_widget_options' ); |
|
973 | - if ( empty($widgets[$widget_id]['url']) && ! $doing_ajax ) { |
|
971 | + if (empty($check_urls)) { |
|
972 | + $widgets = get_option('dashboard_widget_options'); |
|
973 | + if (empty($widgets[$widget_id]['url']) && ! $doing_ajax) { |
|
974 | 974 | echo $loading; |
975 | 975 | return false; |
976 | 976 | } |
977 | - $check_urls = array( $widgets[$widget_id]['url'] ); |
|
977 | + $check_urls = array($widgets[$widget_id]['url']); |
|
978 | 978 | } |
979 | 979 | |
980 | 980 | $locale = get_locale(); |
981 | - $cache_key = 'dash_' . md5( $widget_id . '_' . $locale ); |
|
982 | - if ( false !== ( $output = get_transient( $cache_key ) ) ) { |
|
981 | + $cache_key = 'dash_'.md5($widget_id.'_'.$locale); |
|
982 | + if (false !== ($output = get_transient($cache_key))) { |
|
983 | 983 | echo $output; |
984 | 984 | return true; |
985 | 985 | } |
986 | 986 | |
987 | - if ( ! $doing_ajax ) { |
|
987 | + if ( ! $doing_ajax) { |
|
988 | 988 | echo $loading; |
989 | 989 | return false; |
990 | 990 | } |
991 | 991 | |
992 | - if ( $callback && is_callable( $callback ) ) { |
|
993 | - $args = array_slice( func_get_args(), 3 ); |
|
994 | - array_unshift( $args, $widget_id, $check_urls ); |
|
992 | + if ($callback && is_callable($callback)) { |
|
993 | + $args = array_slice(func_get_args(), 3); |
|
994 | + array_unshift($args, $widget_id, $check_urls); |
|
995 | 995 | ob_start(); |
996 | - call_user_func_array( $callback, $args ); |
|
997 | - set_transient( $cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS ); // Default lifetime in cache of 12 hours (same as the feeds) |
|
996 | + call_user_func_array($callback, $args); |
|
997 | + set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS); // Default lifetime in cache of 12 hours (same as the feeds) |
|
998 | 998 | } |
999 | 999 | |
1000 | 1000 | return true; |
@@ -1013,11 +1013,11 @@ discard block |
||
1013 | 1013 | * |
1014 | 1014 | * @param int $widget_control_id Registered Widget ID. |
1015 | 1015 | */ |
1016 | -function wp_dashboard_trigger_widget_control( $widget_control_id = false ) { |
|
1016 | +function wp_dashboard_trigger_widget_control($widget_control_id = false) { |
|
1017 | 1017 | global $wp_dashboard_control_callbacks; |
1018 | 1018 | |
1019 | - if ( is_scalar($widget_control_id) && $widget_control_id && isset($wp_dashboard_control_callbacks[$widget_control_id]) && is_callable($wp_dashboard_control_callbacks[$widget_control_id]) ) { |
|
1020 | - call_user_func( $wp_dashboard_control_callbacks[$widget_control_id], '', array( 'id' => $widget_control_id, 'callback' => $wp_dashboard_control_callbacks[$widget_control_id] ) ); |
|
1019 | + if (is_scalar($widget_control_id) && $widget_control_id && isset($wp_dashboard_control_callbacks[$widget_control_id]) && is_callable($wp_dashboard_control_callbacks[$widget_control_id])) { |
|
1020 | + call_user_func($wp_dashboard_control_callbacks[$widget_control_id], '', array('id' => $widget_control_id, 'callback' => $wp_dashboard_control_callbacks[$widget_control_id])); |
|
1021 | 1021 | } |
1022 | 1022 | } |
1023 | 1023 | |
@@ -1032,25 +1032,25 @@ discard block |
||
1032 | 1032 | * @param string $widget_id |
1033 | 1033 | * @param array $form_inputs |
1034 | 1034 | */ |
1035 | -function wp_dashboard_rss_control( $widget_id, $form_inputs = array() ) { |
|
1036 | - if ( !$widget_options = get_option( 'dashboard_widget_options' ) ) |
|
1035 | +function wp_dashboard_rss_control($widget_id, $form_inputs = array()) { |
|
1036 | + if ( ! $widget_options = get_option('dashboard_widget_options')) |
|
1037 | 1037 | $widget_options = array(); |
1038 | 1038 | |
1039 | - if ( !isset($widget_options[$widget_id]) ) |
|
1039 | + if ( ! isset($widget_options[$widget_id])) |
|
1040 | 1040 | $widget_options[$widget_id] = array(); |
1041 | 1041 | |
1042 | 1042 | $number = 1; // Hack to use wp_widget_rss_form() |
1043 | 1043 | $widget_options[$widget_id]['number'] = $number; |
1044 | 1044 | |
1045 | - if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget-rss'][$number]) ) { |
|
1046 | - $_POST['widget-rss'][$number] = wp_unslash( $_POST['widget-rss'][$number] ); |
|
1047 | - $widget_options[$widget_id] = wp_widget_rss_process( $_POST['widget-rss'][$number] ); |
|
1045 | + if ('POST' == $_SERVER['REQUEST_METHOD'] && isset($_POST['widget-rss'][$number])) { |
|
1046 | + $_POST['widget-rss'][$number] = wp_unslash($_POST['widget-rss'][$number]); |
|
1047 | + $widget_options[$widget_id] = wp_widget_rss_process($_POST['widget-rss'][$number]); |
|
1048 | 1048 | $widget_options[$widget_id]['number'] = $number; |
1049 | 1049 | |
1050 | 1050 | // Title is optional. If black, fill it if possible. |
1051 | - if ( !$widget_options[$widget_id]['title'] && isset($_POST['widget-rss'][$number]['title']) ) { |
|
1051 | + if ( ! $widget_options[$widget_id]['title'] && isset($_POST['widget-rss'][$number]['title'])) { |
|
1052 | 1052 | $rss = fetch_feed($widget_options[$widget_id]['url']); |
1053 | - if ( is_wp_error($rss) ) { |
|
1053 | + if (is_wp_error($rss)) { |
|
1054 | 1054 | $widget_options[$widget_id]['title'] = htmlentities(__('Unknown Feed')); |
1055 | 1055 | } else { |
1056 | 1056 | $widget_options[$widget_id]['title'] = htmlentities(strip_tags($rss->get_title())); |
@@ -1058,12 +1058,12 @@ discard block |
||
1058 | 1058 | unset($rss); |
1059 | 1059 | } |
1060 | 1060 | } |
1061 | - update_option( 'dashboard_widget_options', $widget_options ); |
|
1062 | - $cache_key = 'dash_' . md5( $widget_id ); |
|
1063 | - delete_transient( $cache_key ); |
|
1061 | + update_option('dashboard_widget_options', $widget_options); |
|
1062 | + $cache_key = 'dash_'.md5($widget_id); |
|
1063 | + delete_transient($cache_key); |
|
1064 | 1064 | } |
1065 | 1065 | |
1066 | - wp_widget_rss_form( $widget_options[$widget_id], $form_inputs ); |
|
1066 | + wp_widget_rss_form($widget_options[$widget_id], $form_inputs); |
|
1067 | 1067 | } |
1068 | 1068 | |
1069 | 1069 | /** |
@@ -1082,7 +1082,7 @@ discard block |
||
1082 | 1082 | * |
1083 | 1083 | * @param string $link The widget's primary link URL. |
1084 | 1084 | */ |
1085 | - 'link' => apply_filters( 'dashboard_primary_link', __( 'https://wordpress.org/news/' ) ), |
|
1085 | + 'link' => apply_filters('dashboard_primary_link', __('https://wordpress.org/news/')), |
|
1086 | 1086 | |
1087 | 1087 | /** |
1088 | 1088 | * Filters the primary feed URL for the 'WordPress News' dashboard widget. |
@@ -1091,7 +1091,7 @@ discard block |
||
1091 | 1091 | * |
1092 | 1092 | * @param string $url The widget's primary feed URL. |
1093 | 1093 | */ |
1094 | - 'url' => apply_filters( 'dashboard_primary_feed', __( 'http://wordpress.org/news/feed/' ) ), |
|
1094 | + 'url' => apply_filters('dashboard_primary_feed', __('http://wordpress.org/news/feed/')), |
|
1095 | 1095 | |
1096 | 1096 | /** |
1097 | 1097 | * Filters the primary link title for the 'WordPress News' dashboard widget. |
@@ -1100,7 +1100,7 @@ discard block |
||
1100 | 1100 | * |
1101 | 1101 | * @param string $title Title attribute for the widget's primary link. |
1102 | 1102 | */ |
1103 | - 'title' => apply_filters( 'dashboard_primary_title', __( 'WordPress Blog' ) ), |
|
1103 | + 'title' => apply_filters('dashboard_primary_title', __('WordPress Blog')), |
|
1104 | 1104 | 'items' => 1, |
1105 | 1105 | 'show_summary' => 1, |
1106 | 1106 | 'show_author' => 0, |
@@ -1115,7 +1115,7 @@ discard block |
||
1115 | 1115 | * |
1116 | 1116 | * @param string $link The widget's secondary link URL. |
1117 | 1117 | */ |
1118 | - 'link' => apply_filters( 'dashboard_secondary_link', __( 'https://planet.wordpress.org/' ) ), |
|
1118 | + 'link' => apply_filters('dashboard_secondary_link', __('https://planet.wordpress.org/')), |
|
1119 | 1119 | |
1120 | 1120 | /** |
1121 | 1121 | * Filters the secondary feed URL for the 'WordPress News' dashboard widget. |
@@ -1124,7 +1124,7 @@ discard block |
||
1124 | 1124 | * |
1125 | 1125 | * @param string $url The widget's secondary feed URL. |
1126 | 1126 | */ |
1127 | - 'url' => apply_filters( 'dashboard_secondary_feed', __( 'https://planet.wordpress.org/feed/' ) ), |
|
1127 | + 'url' => apply_filters('dashboard_secondary_feed', __('https://planet.wordpress.org/feed/')), |
|
1128 | 1128 | |
1129 | 1129 | /** |
1130 | 1130 | * Filters the secondary link title for the 'WordPress News' dashboard widget. |
@@ -1133,7 +1133,7 @@ discard block |
||
1133 | 1133 | * |
1134 | 1134 | * @param string $title Title attribute for the widget's secondary link. |
1135 | 1135 | */ |
1136 | - 'title' => apply_filters( 'dashboard_secondary_title', __( 'Other WordPress News' ) ), |
|
1136 | + 'title' => apply_filters('dashboard_secondary_title', __('Other WordPress News')), |
|
1137 | 1137 | |
1138 | 1138 | /** |
1139 | 1139 | * Filters the number of secondary link items for the 'WordPress News' dashboard widget. |
@@ -1142,14 +1142,14 @@ discard block |
||
1142 | 1142 | * |
1143 | 1143 | * @param string $items How many items to show in the secondary feed. |
1144 | 1144 | */ |
1145 | - 'items' => apply_filters( 'dashboard_secondary_items', 3 ), |
|
1145 | + 'items' => apply_filters('dashboard_secondary_items', 3), |
|
1146 | 1146 | 'show_summary' => 0, |
1147 | 1147 | 'show_author' => 0, |
1148 | 1148 | 'show_date' => 0, |
1149 | 1149 | ) |
1150 | 1150 | ); |
1151 | 1151 | |
1152 | - if ( ( ! is_multisite() && is_blog_admin() && current_user_can( 'install_plugins' ) ) || ( is_network_admin() && current_user_can( 'manage_network_plugins' ) && current_user_can( 'install_plugins' ) ) ) { |
|
1152 | + if (( ! is_multisite() && is_blog_admin() && current_user_can('install_plugins')) || (is_network_admin() && current_user_can('manage_network_plugins') && current_user_can('install_plugins'))) { |
|
1153 | 1153 | $feeds['plugins'] = array( |
1154 | 1154 | 'link' => '', |
1155 | 1155 | 'url' => array( |
@@ -1163,7 +1163,7 @@ discard block |
||
1163 | 1163 | ); |
1164 | 1164 | } |
1165 | 1165 | |
1166 | - wp_dashboard_cached_rss_widget( 'dashboard_primary', 'wp_dashboard_primary_output', $feeds ); |
|
1166 | + wp_dashboard_cached_rss_widget('dashboard_primary', 'wp_dashboard_primary_output', $feeds); |
|
1167 | 1167 | } |
1168 | 1168 | |
1169 | 1169 | /** |
@@ -1174,14 +1174,14 @@ discard block |
||
1174 | 1174 | * @param string $widget_id Widget ID. |
1175 | 1175 | * @param array $feeds Array of RSS feeds. |
1176 | 1176 | */ |
1177 | -function wp_dashboard_primary_output( $widget_id, $feeds ) { |
|
1178 | - foreach ( $feeds as $type => $args ) { |
|
1177 | +function wp_dashboard_primary_output($widget_id, $feeds) { |
|
1178 | + foreach ($feeds as $type => $args) { |
|
1179 | 1179 | $args['type'] = $type; |
1180 | 1180 | echo '<div class="rss-widget">'; |
1181 | - if ( $type === 'plugins' ) { |
|
1182 | - wp_dashboard_plugins_output( $args['url'], $args ); |
|
1181 | + if ($type === 'plugins') { |
|
1182 | + wp_dashboard_plugins_output($args['url'], $args); |
|
1183 | 1183 | } else { |
1184 | - wp_widget_rss_output( $args['url'], $args ); |
|
1184 | + wp_widget_rss_output($args['url'], $args); |
|
1185 | 1185 | } |
1186 | 1186 | echo "</div>"; |
1187 | 1187 | } |
@@ -1195,47 +1195,47 @@ discard block |
||
1195 | 1195 | * @param string $rss The RSS feed URL. |
1196 | 1196 | * @param array $args Array of arguments for this RSS feed. |
1197 | 1197 | */ |
1198 | -function wp_dashboard_plugins_output( $rss, $args = array() ) { |
|
1198 | +function wp_dashboard_plugins_output($rss, $args = array()) { |
|
1199 | 1199 | // Plugin feeds plus link to install them |
1200 | - $popular = fetch_feed( $args['url']['popular'] ); |
|
1200 | + $popular = fetch_feed($args['url']['popular']); |
|
1201 | 1201 | |
1202 | - if ( false === $plugin_slugs = get_transient( 'plugin_slugs' ) ) { |
|
1203 | - $plugin_slugs = array_keys( get_plugins() ); |
|
1204 | - set_transient( 'plugin_slugs', $plugin_slugs, DAY_IN_SECONDS ); |
|
1202 | + if (false === $plugin_slugs = get_transient('plugin_slugs')) { |
|
1203 | + $plugin_slugs = array_keys(get_plugins()); |
|
1204 | + set_transient('plugin_slugs', $plugin_slugs, DAY_IN_SECONDS); |
|
1205 | 1205 | } |
1206 | 1206 | |
1207 | 1207 | echo '<ul>'; |
1208 | 1208 | |
1209 | - foreach ( array( $popular ) as $feed ) { |
|
1210 | - if ( is_wp_error( $feed ) || ! $feed->get_item_quantity() ) |
|
1209 | + foreach (array($popular) as $feed) { |
|
1210 | + if (is_wp_error($feed) || ! $feed->get_item_quantity()) |
|
1211 | 1211 | continue; |
1212 | 1212 | |
1213 | 1213 | $items = $feed->get_items(0, 5); |
1214 | 1214 | |
1215 | 1215 | // Pick a random, non-installed plugin |
1216 | - while ( true ) { |
|
1216 | + while (true) { |
|
1217 | 1217 | // Abort this foreach loop iteration if there's no plugins left of this type |
1218 | - if ( 0 == count($items) ) |
|
1218 | + if (0 == count($items)) |
|
1219 | 1219 | continue 2; |
1220 | 1220 | |
1221 | 1221 | $item_key = array_rand($items); |
1222 | 1222 | $item = $items[$item_key]; |
1223 | 1223 | |
1224 | - list($link, $frag) = explode( '#', $item->get_link() ); |
|
1224 | + list($link, $frag) = explode('#', $item->get_link()); |
|
1225 | 1225 | |
1226 | 1226 | $link = esc_url($link); |
1227 | - if ( preg_match( '|/([^/]+?)/?$|', $link, $matches ) ) |
|
1227 | + if (preg_match('|/([^/]+?)/?$|', $link, $matches)) |
|
1228 | 1228 | $slug = $matches[1]; |
1229 | 1229 | else { |
1230 | - unset( $items[$item_key] ); |
|
1230 | + unset($items[$item_key]); |
|
1231 | 1231 | continue; |
1232 | 1232 | } |
1233 | 1233 | |
1234 | 1234 | // Is this random plugin's slug already installed? If so, try again. |
1235 | - reset( $plugin_slugs ); |
|
1236 | - foreach ( $plugin_slugs as $plugin_slug ) { |
|
1237 | - if ( $slug == substr( $plugin_slug, 0, strlen( $slug ) ) ) { |
|
1238 | - unset( $items[$item_key] ); |
|
1235 | + reset($plugin_slugs); |
|
1236 | + foreach ($plugin_slugs as $plugin_slug) { |
|
1237 | + if ($slug == substr($plugin_slug, 0, strlen($slug))) { |
|
1238 | + unset($items[$item_key]); |
|
1239 | 1239 | continue 2; |
1240 | 1240 | } |
1241 | 1241 | } |
@@ -1245,22 +1245,22 @@ discard block |
||
1245 | 1245 | } |
1246 | 1246 | |
1247 | 1247 | // Eliminate some common badly formed plugin descriptions |
1248 | - while ( ( null !== $item_key = array_rand($items) ) && false !== strpos( $items[$item_key]->get_description(), 'Plugin Name:' ) ) |
|
1248 | + while ((null !== $item_key = array_rand($items)) && false !== strpos($items[$item_key]->get_description(), 'Plugin Name:')) |
|
1249 | 1249 | unset($items[$item_key]); |
1250 | 1250 | |
1251 | - if ( !isset($items[$item_key]) ) |
|
1251 | + if ( ! isset($items[$item_key])) |
|
1252 | 1252 | continue; |
1253 | 1253 | |
1254 | 1254 | $raw_title = $item->get_title(); |
1255 | 1255 | |
1256 | - $ilink = wp_nonce_url('plugin-install.php?tab=plugin-information&plugin=' . $slug, 'install-plugin_' . $slug) . '&TB_iframe=true&width=600&height=800'; |
|
1257 | - echo '<li class="dashboard-news-plugin"><span>' . __( 'Popular Plugin' ) . ':</span> ' . esc_html( $raw_title ) . |
|
1258 | - ' <a href="' . $ilink . '" class="thickbox open-plugin-details-modal" aria-label="' . |
|
1256 | + $ilink = wp_nonce_url('plugin-install.php?tab=plugin-information&plugin='.$slug, 'install-plugin_'.$slug).'&TB_iframe=true&width=600&height=800'; |
|
1257 | + echo '<li class="dashboard-news-plugin"><span>'.__('Popular Plugin').':</span> '.esc_html($raw_title). |
|
1258 | + ' <a href="'.$ilink.'" class="thickbox open-plugin-details-modal" aria-label="'. |
|
1259 | 1259 | /* translators: %s: plugin name */ |
1260 | - esc_attr( sprintf( __( 'Install %s' ), $raw_title ) ) . '">(' . __( 'Install' ) . ')</a></li>'; |
|
1260 | + esc_attr(sprintf(__('Install %s'), $raw_title)).'">('.__('Install').')</a></li>'; |
|
1261 | 1261 | |
1262 | 1262 | $feed->__destruct(); |
1263 | - unset( $feed ); |
|
1263 | + unset($feed); |
|
1264 | 1264 | } |
1265 | 1265 | |
1266 | 1266 | echo '</ul>'; |
@@ -1276,48 +1276,48 @@ discard block |
||
1276 | 1276 | * @return bool|null True if not multisite, user can't upload files, or the space check option is disabled. |
1277 | 1277 | */ |
1278 | 1278 | function wp_dashboard_quota() { |
1279 | - if ( !is_multisite() || !current_user_can( 'upload_files' ) || get_site_option( 'upload_space_check_disabled' ) ) |
|
1279 | + if ( ! is_multisite() || ! current_user_can('upload_files') || get_site_option('upload_space_check_disabled')) |
|
1280 | 1280 | return true; |
1281 | 1281 | |
1282 | 1282 | $quota = get_space_allowed(); |
1283 | 1283 | $used = get_space_used(); |
1284 | 1284 | |
1285 | - if ( $used > $quota ) |
|
1285 | + if ($used > $quota) |
|
1286 | 1286 | $percentused = '100'; |
1287 | 1287 | else |
1288 | - $percentused = ( $used / $quota ) * 100; |
|
1289 | - $used_class = ( $percentused >= 70 ) ? ' warning' : ''; |
|
1290 | - $used = round( $used, 2 ); |
|
1291 | - $percentused = number_format( $percentused ); |
|
1288 | + $percentused = ($used / $quota) * 100; |
|
1289 | + $used_class = ($percentused >= 70) ? ' warning' : ''; |
|
1290 | + $used = round($used, 2); |
|
1291 | + $percentused = number_format($percentused); |
|
1292 | 1292 | |
1293 | 1293 | ?> |
1294 | - <h3 class="mu-storage"><?php _e( 'Storage Space' ); ?></h3> |
|
1294 | + <h3 class="mu-storage"><?php _e('Storage Space'); ?></h3> |
|
1295 | 1295 | <div class="mu-storage"> |
1296 | 1296 | <ul> |
1297 | 1297 | <li class="storage-count"> |
1298 | 1298 | <?php $text = sprintf( |
1299 | 1299 | /* translators: number of megabytes */ |
1300 | - __( '%s MB Space Allowed' ), |
|
1301 | - number_format_i18n( $quota ) |
|
1300 | + __('%s MB Space Allowed'), |
|
1301 | + number_format_i18n($quota) |
|
1302 | 1302 | ); |
1303 | 1303 | printf( |
1304 | 1304 | '<a href="%1$s">%2$s <span class="screen-reader-text">(%3$s)</span></a>', |
1305 | - esc_url( admin_url( 'upload.php' ) ), |
|
1305 | + esc_url(admin_url('upload.php')), |
|
1306 | 1306 | $text, |
1307 | - __( 'Manage Uploads' ) |
|
1307 | + __('Manage Uploads') |
|
1308 | 1308 | ); ?> |
1309 | 1309 | </li><li class="storage-count <?php echo $used_class; ?>"> |
1310 | 1310 | <?php $text = sprintf( |
1311 | 1311 | /* translators: 1: number of megabytes, 2: percentage */ |
1312 | - __( '%1$s MB (%2$s%%) Space Used' ), |
|
1313 | - number_format_i18n( $used, 2 ), |
|
1312 | + __('%1$s MB (%2$s%%) Space Used'), |
|
1313 | + number_format_i18n($used, 2), |
|
1314 | 1314 | $percentused |
1315 | 1315 | ); |
1316 | 1316 | printf( |
1317 | 1317 | '<a href="%1$s" class="musublink">%2$s <span class="screen-reader-text">(%3$s)</span></a>', |
1318 | - esc_url( admin_url( 'upload.php' ) ), |
|
1318 | + esc_url(admin_url('upload.php')), |
|
1319 | 1319 | $text, |
1320 | - __( 'Manage Uploads' ) |
|
1320 | + __('Manage Uploads') |
|
1321 | 1321 | ); ?> |
1322 | 1322 | </li> |
1323 | 1323 | </ul> |
@@ -1330,35 +1330,35 @@ discard block |
||
1330 | 1330 | $notice = ''; |
1331 | 1331 | $response = wp_check_browser_version(); |
1332 | 1332 | |
1333 | - if ( $response ) { |
|
1334 | - if ( $response['insecure'] ) { |
|
1333 | + if ($response) { |
|
1334 | + if ($response['insecure']) { |
|
1335 | 1335 | /* translators: %s: browser name and link */ |
1336 | - $msg = sprintf( __( "It looks like you're using an insecure version of %s. Using an outdated browser makes your computer unsafe. For the best WordPress experience, please update your browser." ), |
|
1337 | - sprintf( '<a href="%s">%s</a>', esc_url( $response['update_url'] ), esc_html( $response['name'] ) ) |
|
1336 | + $msg = sprintf(__("It looks like you're using an insecure version of %s. Using an outdated browser makes your computer unsafe. For the best WordPress experience, please update your browser."), |
|
1337 | + sprintf('<a href="%s">%s</a>', esc_url($response['update_url']), esc_html($response['name'])) |
|
1338 | 1338 | ); |
1339 | 1339 | } else { |
1340 | 1340 | /* translators: %s: browser name and link */ |
1341 | - $msg = sprintf( __( "It looks like you're using an old version of %s. For the best WordPress experience, please update your browser." ), |
|
1342 | - sprintf( '<a href="%s">%s</a>', esc_url( $response['update_url'] ), esc_html( $response['name'] ) ) |
|
1341 | + $msg = sprintf(__("It looks like you're using an old version of %s. For the best WordPress experience, please update your browser."), |
|
1342 | + sprintf('<a href="%s">%s</a>', esc_url($response['update_url']), esc_html($response['name'])) |
|
1343 | 1343 | ); |
1344 | 1344 | } |
1345 | 1345 | |
1346 | 1346 | $browser_nag_class = ''; |
1347 | - if ( !empty( $response['img_src'] ) ) { |
|
1348 | - $img_src = ( is_ssl() && ! empty( $response['img_src_ssl'] ) )? $response['img_src_ssl'] : $response['img_src']; |
|
1347 | + if ( ! empty($response['img_src'])) { |
|
1348 | + $img_src = (is_ssl() && ! empty($response['img_src_ssl'])) ? $response['img_src_ssl'] : $response['img_src']; |
|
1349 | 1349 | |
1350 | - $notice .= '<div class="alignright browser-icon"><a href="' . esc_attr($response['update_url']) . '"><img src="' . esc_attr( $img_src ) . '" alt="" /></a></div>'; |
|
1350 | + $notice .= '<div class="alignright browser-icon"><a href="'.esc_attr($response['update_url']).'"><img src="'.esc_attr($img_src).'" alt="" /></a></div>'; |
|
1351 | 1351 | $browser_nag_class = ' has-browser-icon'; |
1352 | 1352 | } |
1353 | 1353 | $notice .= "<p class='browser-update-nag{$browser_nag_class}'>{$msg}</p>"; |
1354 | 1354 | |
1355 | 1355 | $browsehappy = 'http://browsehappy.com/'; |
1356 | 1356 | $locale = get_locale(); |
1357 | - if ( 'en_US' !== $locale ) |
|
1358 | - $browsehappy = add_query_arg( 'locale', $locale, $browsehappy ); |
|
1357 | + if ('en_US' !== $locale) |
|
1358 | + $browsehappy = add_query_arg('locale', $locale, $browsehappy); |
|
1359 | 1359 | |
1360 | - $notice .= '<p>' . sprintf( __( '<a href="%1$s" class="update-browser-link">Update %2$s</a> or learn how to <a href="%3$s" class="browse-happy-link">browse happy</a>' ), esc_attr( $response['update_url'] ), esc_html( $response['name'] ), esc_url( $browsehappy ) ) . '</p>'; |
|
1361 | - $notice .= '<p class="hide-if-no-js"><a href="" class="dismiss" aria-label="' . esc_attr__( 'Dismiss the browser warning panel' ) . '">' . __( 'Dismiss' ) . '</a></p>'; |
|
1360 | + $notice .= '<p>'.sprintf(__('<a href="%1$s" class="update-browser-link">Update %2$s</a> or learn how to <a href="%3$s" class="browse-happy-link">browse happy</a>'), esc_attr($response['update_url']), esc_html($response['name']), esc_url($browsehappy)).'</p>'; |
|
1361 | + $notice .= '<p class="hide-if-no-js"><a href="" class="dismiss" aria-label="'.esc_attr__('Dismiss the browser warning panel').'">'.__('Dismiss').'</a></p>'; |
|
1362 | 1362 | $notice .= '<div class="clear"></div>'; |
1363 | 1363 | } |
1364 | 1364 | |
@@ -1370,7 +1370,7 @@ discard block |
||
1370 | 1370 | * @param string $notice The notice content. |
1371 | 1371 | * @param array $response An array containing web browser information. |
1372 | 1372 | */ |
1373 | - echo apply_filters( 'browse-happy-notice', $notice, $response ); |
|
1373 | + echo apply_filters('browse-happy-notice', $notice, $response); |
|
1374 | 1374 | } |
1375 | 1375 | |
1376 | 1376 | /** |
@@ -1379,10 +1379,10 @@ discard block |
||
1379 | 1379 | * @param array $classes |
1380 | 1380 | * @return array |
1381 | 1381 | */ |
1382 | -function dashboard_browser_nag_class( $classes ) { |
|
1382 | +function dashboard_browser_nag_class($classes) { |
|
1383 | 1383 | $response = wp_check_browser_version(); |
1384 | 1384 | |
1385 | - if ( $response && $response['insecure'] ) |
|
1385 | + if ($response && $response['insecure']) |
|
1386 | 1386 | $classes[] = 'browser-insecure'; |
1387 | 1387 | |
1388 | 1388 | return $classes; |
@@ -1398,22 +1398,22 @@ discard block |
||
1398 | 1398 | * @return array|bool False on failure, array of browser data on success. |
1399 | 1399 | */ |
1400 | 1400 | function wp_check_browser_version() { |
1401 | - if ( empty( $_SERVER['HTTP_USER_AGENT'] ) ) |
|
1401 | + if (empty($_SERVER['HTTP_USER_AGENT'])) |
|
1402 | 1402 | return false; |
1403 | 1403 | |
1404 | - $key = md5( $_SERVER['HTTP_USER_AGENT'] ); |
|
1404 | + $key = md5($_SERVER['HTTP_USER_AGENT']); |
|
1405 | 1405 | |
1406 | - if ( false === ($response = get_site_transient('browser_' . $key) ) ) { |
|
1406 | + if (false === ($response = get_site_transient('browser_'.$key))) { |
|
1407 | 1407 | global $wp_version; |
1408 | 1408 | |
1409 | 1409 | $options = array( |
1410 | - 'body' => array( 'useragent' => $_SERVER['HTTP_USER_AGENT'] ), |
|
1411 | - 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url() |
|
1410 | + 'body' => array('useragent' => $_SERVER['HTTP_USER_AGENT']), |
|
1411 | + 'user-agent' => 'WordPress/'.$wp_version.'; '.home_url() |
|
1412 | 1412 | ); |
1413 | 1413 | |
1414 | - $response = wp_remote_post( 'http://api.wordpress.org/core/browse-happy/1.1/', $options ); |
|
1414 | + $response = wp_remote_post('http://api.wordpress.org/core/browse-happy/1.1/', $options); |
|
1415 | 1415 | |
1416 | - if ( is_wp_error( $response ) || 200 != wp_remote_retrieve_response_code( $response ) ) |
|
1416 | + if (is_wp_error($response) || 200 != wp_remote_retrieve_response_code($response)) |
|
1417 | 1417 | return false; |
1418 | 1418 | |
1419 | 1419 | /** |
@@ -1427,12 +1427,12 @@ discard block |
||
1427 | 1427 | * 'img_src' - string - An image representing the browser |
1428 | 1428 | * 'img_src_ssl' - string - An image (over SSL) representing the browser |
1429 | 1429 | */ |
1430 | - $response = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
1430 | + $response = json_decode(wp_remote_retrieve_body($response), true); |
|
1431 | 1431 | |
1432 | - if ( ! is_array( $response ) ) |
|
1432 | + if ( ! is_array($response)) |
|
1433 | 1433 | return false; |
1434 | 1434 | |
1435 | - set_site_transient( 'browser_' . $key, $response, WEEK_IN_SECONDS ); |
|
1435 | + set_site_transient('browser_'.$key, $response, WEEK_IN_SECONDS); |
|
1436 | 1436 | } |
1437 | 1437 | |
1438 | 1438 | return $response; |
@@ -1451,55 +1451,55 @@ discard block |
||
1451 | 1451 | function wp_welcome_panel() { |
1452 | 1452 | ?> |
1453 | 1453 | <div class="welcome-panel-content"> |
1454 | - <h2><?php _e( 'Welcome to WordPress!' ); ?></h2> |
|
1455 | - <p class="about-description"><?php _e( 'We’ve assembled some links to get you started:' ); ?></p> |
|
1454 | + <h2><?php _e('Welcome to WordPress!'); ?></h2> |
|
1455 | + <p class="about-description"><?php _e('We’ve assembled some links to get you started:'); ?></p> |
|
1456 | 1456 | <div class="welcome-panel-column-container"> |
1457 | 1457 | <div class="welcome-panel-column"> |
1458 | - <?php if ( current_user_can( 'customize' ) ): ?> |
|
1459 | - <h3><?php _e( 'Get Started' ); ?></h3> |
|
1460 | - <a class="button button-primary button-hero load-customize hide-if-no-customize" href="<?php echo wp_customize_url(); ?>"><?php _e( 'Customize Your Site' ); ?></a> |
|
1458 | + <?php if (current_user_can('customize')): ?> |
|
1459 | + <h3><?php _e('Get Started'); ?></h3> |
|
1460 | + <a class="button button-primary button-hero load-customize hide-if-no-customize" href="<?php echo wp_customize_url(); ?>"><?php _e('Customize Your Site'); ?></a> |
|
1461 | 1461 | <?php endif; ?> |
1462 | - <a class="button button-primary button-hero hide-if-customize" href="<?php echo admin_url( 'themes.php' ); ?>"><?php _e( 'Customize Your Site' ); ?></a> |
|
1463 | - <?php if ( current_user_can( 'install_themes' ) || ( current_user_can( 'switch_themes' ) && count( wp_get_themes( array( 'allowed' => true ) ) ) > 1 ) ) : ?> |
|
1464 | - <p class="hide-if-no-customize"><?php printf( __( 'or, <a href="%s">change your theme completely</a>' ), admin_url( 'themes.php' ) ); ?></p> |
|
1462 | + <a class="button button-primary button-hero hide-if-customize" href="<?php echo admin_url('themes.php'); ?>"><?php _e('Customize Your Site'); ?></a> |
|
1463 | + <?php if (current_user_can('install_themes') || (current_user_can('switch_themes') && count(wp_get_themes(array('allowed' => true))) > 1)) : ?> |
|
1464 | + <p class="hide-if-no-customize"><?php printf(__('or, <a href="%s">change your theme completely</a>'), admin_url('themes.php')); ?></p> |
|
1465 | 1465 | <?php endif; ?> |
1466 | 1466 | </div> |
1467 | 1467 | <div class="welcome-panel-column"> |
1468 | - <h3><?php _e( 'Next Steps' ); ?></h3> |
|
1468 | + <h3><?php _e('Next Steps'); ?></h3> |
|
1469 | 1469 | <ul> |
1470 | - <?php if ( 'page' == get_option( 'show_on_front' ) && ! get_option( 'page_for_posts' ) ) : ?> |
|
1471 | - <li><?php printf( '<a href="%s" class="welcome-icon welcome-edit-page">' . __( 'Edit your front page' ) . '</a>', get_edit_post_link( get_option( 'page_on_front' ) ) ); ?></li> |
|
1472 | - <li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add additional pages' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li> |
|
1473 | - <?php elseif ( 'page' == get_option( 'show_on_front' ) ) : ?> |
|
1474 | - <li><?php printf( '<a href="%s" class="welcome-icon welcome-edit-page">' . __( 'Edit your front page' ) . '</a>', get_edit_post_link( get_option( 'page_on_front' ) ) ); ?></li> |
|
1475 | - <li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add additional pages' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li> |
|
1476 | - <li><?php printf( '<a href="%s" class="welcome-icon welcome-write-blog">' . __( 'Add a blog post' ) . '</a>', admin_url( 'post-new.php' ) ); ?></li> |
|
1470 | + <?php if ('page' == get_option('show_on_front') && ! get_option('page_for_posts')) : ?> |
|
1471 | + <li><?php printf('<a href="%s" class="welcome-icon welcome-edit-page">'.__('Edit your front page').'</a>', get_edit_post_link(get_option('page_on_front'))); ?></li> |
|
1472 | + <li><?php printf('<a href="%s" class="welcome-icon welcome-add-page">'.__('Add additional pages').'</a>', admin_url('post-new.php?post_type=page')); ?></li> |
|
1473 | + <?php elseif ('page' == get_option('show_on_front')) : ?> |
|
1474 | + <li><?php printf('<a href="%s" class="welcome-icon welcome-edit-page">'.__('Edit your front page').'</a>', get_edit_post_link(get_option('page_on_front'))); ?></li> |
|
1475 | + <li><?php printf('<a href="%s" class="welcome-icon welcome-add-page">'.__('Add additional pages').'</a>', admin_url('post-new.php?post_type=page')); ?></li> |
|
1476 | + <li><?php printf('<a href="%s" class="welcome-icon welcome-write-blog">'.__('Add a blog post').'</a>', admin_url('post-new.php')); ?></li> |
|
1477 | 1477 | <?php else : ?> |
1478 | - <li><?php printf( '<a href="%s" class="welcome-icon welcome-write-blog">' . __( 'Write your first blog post' ) . '</a>', admin_url( 'post-new.php' ) ); ?></li> |
|
1479 | - <li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add an About page' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li> |
|
1478 | + <li><?php printf('<a href="%s" class="welcome-icon welcome-write-blog">'.__('Write your first blog post').'</a>', admin_url('post-new.php')); ?></li> |
|
1479 | + <li><?php printf('<a href="%s" class="welcome-icon welcome-add-page">'.__('Add an About page').'</a>', admin_url('post-new.php?post_type=page')); ?></li> |
|
1480 | 1480 | <?php endif; ?> |
1481 | - <li><?php printf( '<a href="%s" class="welcome-icon welcome-view-site">' . __( 'View your site' ) . '</a>', home_url( '/' ) ); ?></li> |
|
1481 | + <li><?php printf('<a href="%s" class="welcome-icon welcome-view-site">'.__('View your site').'</a>', home_url('/')); ?></li> |
|
1482 | 1482 | </ul> |
1483 | 1483 | </div> |
1484 | 1484 | <div class="welcome-panel-column welcome-panel-last"> |
1485 | - <h3><?php _e( 'More Actions' ); ?></h3> |
|
1485 | + <h3><?php _e('More Actions'); ?></h3> |
|
1486 | 1486 | <ul> |
1487 | - <?php if ( current_theme_supports( 'widgets' ) || current_theme_supports( 'menus' ) ) : ?> |
|
1487 | + <?php if (current_theme_supports('widgets') || current_theme_supports('menus')) : ?> |
|
1488 | 1488 | <li><div class="welcome-icon welcome-widgets-menus"><?php |
1489 | - if ( current_theme_supports( 'widgets' ) && current_theme_supports( 'menus' ) ) { |
|
1490 | - printf( __( 'Manage <a href="%1$s">widgets</a> or <a href="%2$s">menus</a>' ), |
|
1491 | - admin_url( 'widgets.php' ), admin_url( 'nav-menus.php' ) ); |
|
1492 | - } elseif ( current_theme_supports( 'widgets' ) ) { |
|
1493 | - echo '<a href="' . admin_url( 'widgets.php' ) . '">' . __( 'Manage widgets' ) . '</a>'; |
|
1489 | + if (current_theme_supports('widgets') && current_theme_supports('menus')) { |
|
1490 | + printf(__('Manage <a href="%1$s">widgets</a> or <a href="%2$s">menus</a>'), |
|
1491 | + admin_url('widgets.php'), admin_url('nav-menus.php')); |
|
1492 | + } elseif (current_theme_supports('widgets')) { |
|
1493 | + echo '<a href="'.admin_url('widgets.php').'">'.__('Manage widgets').'</a>'; |
|
1494 | 1494 | } else { |
1495 | - echo '<a href="' . admin_url( 'nav-menus.php' ) . '">' . __( 'Manage menus' ) . '</a>'; |
|
1495 | + echo '<a href="'.admin_url('nav-menus.php').'">'.__('Manage menus').'</a>'; |
|
1496 | 1496 | } |
1497 | 1497 | ?></div></li> |
1498 | 1498 | <?php endif; ?> |
1499 | - <?php if ( current_user_can( 'manage_options' ) ) : ?> |
|
1500 | - <li><?php printf( '<a href="%s" class="welcome-icon welcome-comments">' . __( 'Turn comments on or off' ) . '</a>', admin_url( 'options-discussion.php' ) ); ?></li> |
|
1499 | + <?php if (current_user_can('manage_options')) : ?> |
|
1500 | + <li><?php printf('<a href="%s" class="welcome-icon welcome-comments">'.__('Turn comments on or off').'</a>', admin_url('options-discussion.php')); ?></li> |
|
1501 | 1501 | <?php endif; ?> |
1502 | - <li><?php printf( '<a href="%s" class="welcome-icon welcome-learn-more">' . __( 'Learn more about getting started' ) . '</a>', __( 'https://codex.wordpress.org/First_Steps_With_WordPress' ) ); ?></li> |
|
1502 | + <li><?php printf('<a href="%s" class="welcome-icon welcome-learn-more">'.__('Learn more about getting started').'</a>', __('https://codex.wordpress.org/First_Steps_With_WordPress')); ?></li> |
|
1503 | 1503 | </ul> |
1504 | 1504 | </div> |
1505 | 1505 | </div> |
@@ -8,34 +8,34 @@ |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | /** WP_Upgrader_Skin class */ |
11 | -require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader-skin.php'; |
|
11 | +require_once ABSPATH.'wp-admin/includes/class-wp-upgrader-skin.php'; |
|
12 | 12 | |
13 | 13 | /** Plugin_Upgrader_Skin class */ |
14 | -require_once ABSPATH . 'wp-admin/includes/class-plugin-upgrader-skin.php'; |
|
14 | +require_once ABSPATH.'wp-admin/includes/class-plugin-upgrader-skin.php'; |
|
15 | 15 | |
16 | 16 | /** Theme_Upgrader_Skin class */ |
17 | -require_once ABSPATH . 'wp-admin/includes/class-theme-upgrader-skin.php'; |
|
17 | +require_once ABSPATH.'wp-admin/includes/class-theme-upgrader-skin.php'; |
|
18 | 18 | |
19 | 19 | /** Bulk_Upgrader_Skin class */ |
20 | -require_once ABSPATH . 'wp-admin/includes/class-bulk-upgrader-skin.php'; |
|
20 | +require_once ABSPATH.'wp-admin/includes/class-bulk-upgrader-skin.php'; |
|
21 | 21 | |
22 | 22 | /** Bulk_Plugin_Upgrader_Skin class */ |
23 | -require_once ABSPATH . 'wp-admin/includes/class-bulk-plugin-upgrader-skin.php'; |
|
23 | +require_once ABSPATH.'wp-admin/includes/class-bulk-plugin-upgrader-skin.php'; |
|
24 | 24 | |
25 | 25 | /** Bulk_Theme_Upgrader_Skin class */ |
26 | -require_once ABSPATH . 'wp-admin/includes/class-bulk-theme-upgrader-skin.php'; |
|
26 | +require_once ABSPATH.'wp-admin/includes/class-bulk-theme-upgrader-skin.php'; |
|
27 | 27 | |
28 | 28 | /** Plugin_Installer_Skin class */ |
29 | -require_once ABSPATH . 'wp-admin/includes/class-plugin-installer-skin.php'; |
|
29 | +require_once ABSPATH.'wp-admin/includes/class-plugin-installer-skin.php'; |
|
30 | 30 | |
31 | 31 | /** Theme_Installer_Skin class */ |
32 | -require_once ABSPATH . 'wp-admin/includes/class-theme-installer-skin.php'; |
|
32 | +require_once ABSPATH.'wp-admin/includes/class-theme-installer-skin.php'; |
|
33 | 33 | |
34 | 34 | /** Language_Pack_Upgrader_Skin class */ |
35 | -require_once ABSPATH . 'wp-admin/includes/class-language-pack-upgrader-skin.php'; |
|
35 | +require_once ABSPATH.'wp-admin/includes/class-language-pack-upgrader-skin.php'; |
|
36 | 36 | |
37 | 37 | /** Automatic_Upgrader_Skin class */ |
38 | -require_once ABSPATH . 'wp-admin/includes/class-automatic-upgrader-skin.php'; |
|
38 | +require_once ABSPATH.'wp-admin/includes/class-automatic-upgrader-skin.php'; |
|
39 | 39 | |
40 | 40 | /** WP_Ajax_Upgrader_Skin class */ |
41 | -require_once ABSPATH . 'wp-admin/includes/class-wp-ajax-upgrader-skin.php'; |
|
41 | +require_once ABSPATH.'wp-admin/includes/class-wp-ajax-upgrader-skin.php'; |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @subpackage Administration |
7 | 7 | */ |
8 | 8 | |
9 | -if ( is_network_admin() ) { |
|
9 | +if (is_network_admin()) { |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Fires before the administration menu loads in the Network Admin. |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | * @private |
17 | 17 | * @since 3.1.0 |
18 | 18 | */ |
19 | - do_action( '_network_admin_menu' ); |
|
20 | -} elseif ( is_user_admin() ) { |
|
19 | + do_action('_network_admin_menu'); |
|
20 | +} elseif (is_user_admin()) { |
|
21 | 21 | |
22 | 22 | /** |
23 | 23 | * Fires before the administration menu loads in the User Admin. |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * @private |
28 | 28 | * @since 3.1.0 |
29 | 29 | */ |
30 | - do_action( '_user_admin_menu' ); |
|
30 | + do_action('_user_admin_menu'); |
|
31 | 31 | } else { |
32 | 32 | |
33 | 33 | /** |
@@ -38,18 +38,18 @@ discard block |
||
38 | 38 | * @private |
39 | 39 | * @since 2.2.0 |
40 | 40 | */ |
41 | - do_action( '_admin_menu' ); |
|
41 | + do_action('_admin_menu'); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | // Create list of page plugin hook names. |
45 | 45 | foreach ($menu as $menu_page) { |
46 | - if ( false !== $pos = strpos($menu_page[2], '?') ) { |
|
46 | + if (false !== $pos = strpos($menu_page[2], '?')) { |
|
47 | 47 | // Handle post_type=post|page|foo pages. |
48 | 48 | $hook_name = substr($menu_page[2], 0, $pos); |
49 | 49 | $hook_args = substr($menu_page[2], $pos + 1); |
50 | 50 | wp_parse_str($hook_args, $hook_args); |
51 | 51 | // Set the hook name to be the post type. |
52 | - if ( isset($hook_args['post_type']) ) |
|
52 | + if (isset($hook_args['post_type'])) |
|
53 | 53 | $hook_name = $hook_args['post_type']; |
54 | 54 | else |
55 | 55 | $hook_name = basename($hook_name, '.php'); |
@@ -59,9 +59,9 @@ discard block |
||
59 | 59 | } |
60 | 60 | $hook_name = sanitize_title($hook_name); |
61 | 61 | |
62 | - if ( isset($compat[$hook_name]) ) |
|
62 | + if (isset($compat[$hook_name])) |
|
63 | 63 | $hook_name = $compat[$hook_name]; |
64 | - elseif ( !$hook_name ) |
|
64 | + elseif ( ! $hook_name) |
|
65 | 65 | continue; |
66 | 66 | |
67 | 67 | $admin_page_hooks[$menu_page[2]] = $hook_name; |
@@ -73,14 +73,14 @@ discard block |
||
73 | 73 | // Loop over submenus and remove pages for which the user does not have privs. |
74 | 74 | foreach ($submenu as $parent => $sub) { |
75 | 75 | foreach ($sub as $index => $data) { |
76 | - if ( ! current_user_can($data[1]) ) { |
|
76 | + if ( ! current_user_can($data[1])) { |
|
77 | 77 | unset($submenu[$parent][$index]); |
78 | 78 | $_wp_submenu_nopriv[$parent][$data[2]] = true; |
79 | 79 | } |
80 | 80 | } |
81 | 81 | unset($index, $data); |
82 | 82 | |
83 | - if ( empty($submenu[$parent]) ) |
|
83 | + if (empty($submenu[$parent])) |
|
84 | 84 | unset($submenu[$parent]); |
85 | 85 | } |
86 | 86 | unset($sub, $parent); |
@@ -90,18 +90,18 @@ discard block |
||
90 | 90 | * Menus for which the original parent is not accessible due to lack of privileges |
91 | 91 | * will have the next submenu in line be assigned as the new menu parent. |
92 | 92 | */ |
93 | -foreach ( $menu as $id => $data ) { |
|
94 | - if ( empty($submenu[$data[2]]) ) |
|
93 | +foreach ($menu as $id => $data) { |
|
94 | + if (empty($submenu[$data[2]])) |
|
95 | 95 | continue; |
96 | 96 | $subs = $submenu[$data[2]]; |
97 | - $first_sub = reset( $subs ); |
|
97 | + $first_sub = reset($subs); |
|
98 | 98 | $old_parent = $data[2]; |
99 | 99 | $new_parent = $first_sub[2]; |
100 | 100 | /* |
101 | 101 | * If the first submenu is not the same as the assigned parent, |
102 | 102 | * make the first submenu the new parent. |
103 | 103 | */ |
104 | - if ( $new_parent != $old_parent ) { |
|
104 | + if ($new_parent != $old_parent) { |
|
105 | 105 | $_wp_real_parent_file[$old_parent] = $new_parent; |
106 | 106 | $menu[$id][2] = $new_parent; |
107 | 107 | |
@@ -111,13 +111,13 @@ discard block |
||
111 | 111 | } |
112 | 112 | unset($submenu[$old_parent], $index); |
113 | 113 | |
114 | - if ( isset($_wp_submenu_nopriv[$old_parent]) ) |
|
114 | + if (isset($_wp_submenu_nopriv[$old_parent])) |
|
115 | 115 | $_wp_submenu_nopriv[$new_parent] = $_wp_submenu_nopriv[$old_parent]; |
116 | 116 | } |
117 | 117 | } |
118 | 118 | unset($id, $data, $subs, $first_sub, $old_parent, $new_parent); |
119 | 119 | |
120 | -if ( is_network_admin() ) { |
|
120 | +if (is_network_admin()) { |
|
121 | 121 | |
122 | 122 | /** |
123 | 123 | * Fires before the administration menu loads in the Network Admin. |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | * |
127 | 127 | * @param string $context Empty context. |
128 | 128 | */ |
129 | - do_action( 'network_admin_menu', '' ); |
|
130 | -} elseif ( is_user_admin() ) { |
|
129 | + do_action('network_admin_menu', ''); |
|
130 | +} elseif (is_user_admin()) { |
|
131 | 131 | |
132 | 132 | /** |
133 | 133 | * Fires before the administration menu loads in the User Admin. |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * |
137 | 137 | * @param string $context Empty context. |
138 | 138 | */ |
139 | - do_action( 'user_admin_menu', '' ); |
|
139 | + do_action('user_admin_menu', ''); |
|
140 | 140 | } else { |
141 | 141 | |
142 | 142 | /** |
@@ -146,32 +146,32 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @param string $context Empty context. |
148 | 148 | */ |
149 | - do_action( 'admin_menu', '' ); |
|
149 | + do_action('admin_menu', ''); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /* |
153 | 153 | * Remove menus that have no accessible submenus and require privileges |
154 | 154 | * that the user does not have. Run re-parent loop again. |
155 | 155 | */ |
156 | -foreach ( $menu as $id => $data ) { |
|
157 | - if ( ! current_user_can($data[1]) ) |
|
156 | +foreach ($menu as $id => $data) { |
|
157 | + if ( ! current_user_can($data[1])) |
|
158 | 158 | $_wp_menu_nopriv[$data[2]] = true; |
159 | 159 | |
160 | 160 | /* |
161 | 161 | * If there is only one submenu and it is has same destination as the parent, |
162 | 162 | * remove the submenu. |
163 | 163 | */ |
164 | - if ( ! empty( $submenu[$data[2]] ) && 1 == count ( $submenu[$data[2]] ) ) { |
|
164 | + if ( ! empty($submenu[$data[2]]) && 1 == count($submenu[$data[2]])) { |
|
165 | 165 | $subs = $submenu[$data[2]]; |
166 | - $first_sub = reset( $subs ); |
|
167 | - if ( $data[2] == $first_sub[2] ) |
|
168 | - unset( $submenu[$data[2]] ); |
|
166 | + $first_sub = reset($subs); |
|
167 | + if ($data[2] == $first_sub[2]) |
|
168 | + unset($submenu[$data[2]]); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | // If submenu is empty... |
172 | - if ( empty($submenu[$data[2]]) ) { |
|
172 | + if (empty($submenu[$data[2]])) { |
|
173 | 173 | // And user doesn't have privs, remove menu. |
174 | - if ( isset( $_wp_menu_nopriv[$data[2]] ) ) { |
|
174 | + if (isset($_wp_menu_nopriv[$data[2]])) { |
|
175 | 175 | unset($menu[$id]); |
176 | 176 | } |
177 | 177 | } |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | * @return string |
186 | 186 | */ |
187 | 187 | function add_cssclass($add, $class) { |
188 | - $class = empty($class) ? $add : $class .= ' ' . $add; |
|
188 | + $class = empty($class) ? $add : $class .= ' '.$add; |
|
189 | 189 | return $class; |
190 | 190 | } |
191 | 191 | |
@@ -198,29 +198,29 @@ discard block |
||
198 | 198 | $first = $lastorder = false; |
199 | 199 | $i = 0; |
200 | 200 | $mc = count($menu); |
201 | - foreach ( $menu as $order => $top ) { |
|
201 | + foreach ($menu as $order => $top) { |
|
202 | 202 | $i++; |
203 | 203 | |
204 | - if ( 0 == $order ) { // dashboard is always shown/single |
|
204 | + if (0 == $order) { // dashboard is always shown/single |
|
205 | 205 | $menu[0][4] = add_cssclass('menu-top-first', $top[4]); |
206 | 206 | $lastorder = 0; |
207 | 207 | continue; |
208 | 208 | } |
209 | 209 | |
210 | - if ( 0 === strpos($top[2], 'separator') && false !== $lastorder ) { // if separator |
|
210 | + if (0 === strpos($top[2], 'separator') && false !== $lastorder) { // if separator |
|
211 | 211 | $first = true; |
212 | 212 | $c = $menu[$lastorder][4]; |
213 | 213 | $menu[$lastorder][4] = add_cssclass('menu-top-last', $c); |
214 | 214 | continue; |
215 | 215 | } |
216 | 216 | |
217 | - if ( $first ) { |
|
217 | + if ($first) { |
|
218 | 218 | $c = $menu[$order][4]; |
219 | 219 | $menu[$order][4] = add_cssclass('menu-top-first', $c); |
220 | 220 | $first = false; |
221 | 221 | } |
222 | 222 | |
223 | - if ( $mc == $i ) { // last item |
|
223 | + if ($mc == $i) { // last item |
|
224 | 224 | $c = $menu[$order][4]; |
225 | 225 | $menu[$order][4] = add_cssclass('menu-top-last', $c); |
226 | 226 | } |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | * |
236 | 236 | * @param array $menu Associative array of administration menu items. |
237 | 237 | */ |
238 | - return apply_filters( 'add_menu_classes', $menu ); |
|
238 | + return apply_filters('add_menu_classes', $menu); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | uksort($menu, "strnatcasecmp"); // make it all pretty |
@@ -249,9 +249,9 @@ discard block |
||
249 | 249 | * |
250 | 250 | * @param bool $custom Whether custom ordering is enabled. Default false. |
251 | 251 | */ |
252 | -if ( apply_filters( 'custom_menu_order', false ) ) { |
|
252 | +if (apply_filters('custom_menu_order', false)) { |
|
253 | 253 | $menu_order = array(); |
254 | - foreach ( $menu as $menu_item ) { |
|
254 | + foreach ($menu as $menu_item) { |
|
255 | 255 | $menu_order[] = $menu_item[2]; |
256 | 256 | } |
257 | 257 | unset($menu_item); |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | * |
270 | 270 | * @param array $menu_order An ordered array of menu items. |
271 | 271 | */ |
272 | - $menu_order = apply_filters( 'menu_order', $menu_order ); |
|
272 | + $menu_order = apply_filters('menu_order', $menu_order); |
|
273 | 273 | $menu_order = array_flip($menu_order); |
274 | 274 | $default_menu_order = array_flip($default_menu_order); |
275 | 275 | |
@@ -286,12 +286,12 @@ discard block |
||
286 | 286 | global $menu_order, $default_menu_order; |
287 | 287 | $a = $a[2]; |
288 | 288 | $b = $b[2]; |
289 | - if ( isset($menu_order[$a]) && !isset($menu_order[$b]) ) { |
|
289 | + if (isset($menu_order[$a]) && ! isset($menu_order[$b])) { |
|
290 | 290 | return -1; |
291 | - } elseif ( !isset($menu_order[$a]) && isset($menu_order[$b]) ) { |
|
291 | + } elseif ( ! isset($menu_order[$a]) && isset($menu_order[$b])) { |
|
292 | 292 | return 1; |
293 | - } elseif ( isset($menu_order[$a]) && isset($menu_order[$b]) ) { |
|
294 | - if ( $menu_order[$a] == $menu_order[$b] ) |
|
293 | + } elseif (isset($menu_order[$a]) && isset($menu_order[$b])) { |
|
294 | + if ($menu_order[$a] == $menu_order[$b]) |
|
295 | 295 | return 0; |
296 | 296 | return ($menu_order[$a] < $menu_order[$b]) ? -1 : 1; |
297 | 297 | } else { |
@@ -305,41 +305,41 @@ discard block |
||
305 | 305 | |
306 | 306 | // Prevent adjacent separators |
307 | 307 | $prev_menu_was_separator = false; |
308 | -foreach ( $menu as $id => $data ) { |
|
309 | - if ( false === stristr( $data[4], 'wp-menu-separator' ) ) { |
|
308 | +foreach ($menu as $id => $data) { |
|
309 | + if (false === stristr($data[4], 'wp-menu-separator')) { |
|
310 | 310 | |
311 | 311 | // This item is not a separator, so falsey the toggler and do nothing |
312 | 312 | $prev_menu_was_separator = false; |
313 | 313 | } else { |
314 | 314 | |
315 | 315 | // The previous item was a separator, so unset this one |
316 | - if ( true === $prev_menu_was_separator ) { |
|
317 | - unset( $menu[ $id ] ); |
|
316 | + if (true === $prev_menu_was_separator) { |
|
317 | + unset($menu[$id]); |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | // This item is a separator, so truthy the toggler and move on |
321 | 321 | $prev_menu_was_separator = true; |
322 | 322 | } |
323 | 323 | } |
324 | -unset( $id, $data, $prev_menu_was_separator ); |
|
324 | +unset($id, $data, $prev_menu_was_separator); |
|
325 | 325 | |
326 | 326 | // Remove the last menu item if it is a separator. |
327 | -$last_menu_key = array_keys( $menu ); |
|
328 | -$last_menu_key = array_pop( $last_menu_key ); |
|
329 | -if ( !empty( $menu ) && 'wp-menu-separator' == $menu[ $last_menu_key ][ 4 ] ) |
|
330 | - unset( $menu[ $last_menu_key ] ); |
|
331 | -unset( $last_menu_key ); |
|
327 | +$last_menu_key = array_keys($menu); |
|
328 | +$last_menu_key = array_pop($last_menu_key); |
|
329 | +if ( ! empty($menu) && 'wp-menu-separator' == $menu[$last_menu_key][4]) |
|
330 | + unset($menu[$last_menu_key]); |
|
331 | +unset($last_menu_key); |
|
332 | 332 | |
333 | -if ( !user_can_access_admin_page() ) { |
|
333 | +if ( ! user_can_access_admin_page()) { |
|
334 | 334 | |
335 | 335 | /** |
336 | 336 | * Fires when access to an admin page is denied. |
337 | 337 | * |
338 | 338 | * @since 2.5.0 |
339 | 339 | */ |
340 | - do_action( 'admin_page_access_denied' ); |
|
340 | + do_action('admin_page_access_denied'); |
|
341 | 341 | |
342 | - wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 ); |
|
342 | + wp_die(__('Sorry, you are not allowed to access this page.'), 403); |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | $menu = add_menu_classes($menu); |
@@ -39,18 +39,18 @@ discard block |
||
39 | 39 | * |
40 | 40 | * @param array $args An associative array of arguments. |
41 | 41 | */ |
42 | - public function __construct( $args = array() ) { |
|
43 | - $this->detached = ( isset( $_REQUEST['attachment-filter'] ) && 'detached' === $_REQUEST['attachment-filter'] ); |
|
42 | + public function __construct($args = array()) { |
|
43 | + $this->detached = (isset($_REQUEST['attachment-filter']) && 'detached' === $_REQUEST['attachment-filter']); |
|
44 | 44 | |
45 | 45 | $this->modes = array( |
46 | - 'list' => __( 'List View' ), |
|
47 | - 'grid' => __( 'Grid View' ) |
|
46 | + 'list' => __('List View'), |
|
47 | + 'grid' => __('Grid View') |
|
48 | 48 | ); |
49 | 49 | |
50 | - parent::__construct( array( |
|
50 | + parent::__construct(array( |
|
51 | 51 | 'plural' => 'media', |
52 | - 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
|
53 | - ) ); |
|
52 | + 'screen' => isset($args['screen']) ? $args['screen'] : null, |
|
53 | + )); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -71,17 +71,17 @@ discard block |
||
71 | 71 | public function prepare_items() { |
72 | 72 | global $wp_query, $post_mime_types, $avail_post_mime_types, $mode; |
73 | 73 | |
74 | - list( $post_mime_types, $avail_post_mime_types ) = wp_edit_attachments_query( $_REQUEST ); |
|
74 | + list($post_mime_types, $avail_post_mime_types) = wp_edit_attachments_query($_REQUEST); |
|
75 | 75 | |
76 | - $this->is_trash = isset( $_REQUEST['attachment-filter'] ) && 'trash' === $_REQUEST['attachment-filter']; |
|
76 | + $this->is_trash = isset($_REQUEST['attachment-filter']) && 'trash' === $_REQUEST['attachment-filter']; |
|
77 | 77 | |
78 | - $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode']; |
|
78 | + $mode = empty($_REQUEST['mode']) ? 'list' : $_REQUEST['mode']; |
|
79 | 79 | |
80 | - $this->set_pagination_args( array( |
|
80 | + $this->set_pagination_args(array( |
|
81 | 81 | 'total_items' => $wp_query->found_posts, |
82 | 82 | 'total_pages' => $wp_query->max_num_pages, |
83 | 83 | 'per_page' => $wp_query->query_vars['posts_per_page'], |
84 | - ) ); |
|
84 | + )); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -94,40 +94,40 @@ discard block |
||
94 | 94 | |
95 | 95 | $type_links = array(); |
96 | 96 | |
97 | - $filter = empty( $_GET['attachment-filter'] ) ? '' : $_GET['attachment-filter']; |
|
97 | + $filter = empty($_GET['attachment-filter']) ? '' : $_GET['attachment-filter']; |
|
98 | 98 | |
99 | 99 | $type_links['all'] = sprintf( |
100 | 100 | '<option value=""%s>%s</option>', |
101 | - selected( $filter, true, false ), |
|
102 | - __( 'All media items' ) |
|
101 | + selected($filter, true, false), |
|
102 | + __('All media items') |
|
103 | 103 | ); |
104 | 104 | |
105 | - foreach ( $post_mime_types as $mime_type => $label ) { |
|
106 | - if ( ! wp_match_mime_types( $mime_type, $avail_post_mime_types ) ) { |
|
105 | + foreach ($post_mime_types as $mime_type => $label) { |
|
106 | + if ( ! wp_match_mime_types($mime_type, $avail_post_mime_types)) { |
|
107 | 107 | continue; |
108 | 108 | } |
109 | 109 | |
110 | 110 | $selected = selected( |
111 | - $filter && 0 === strpos( $filter, 'post_mime_type:' ) && |
|
112 | - wp_match_mime_types( $mime_type, str_replace( 'post_mime_type:', '', $filter ) ), |
|
111 | + $filter && 0 === strpos($filter, 'post_mime_type:') && |
|
112 | + wp_match_mime_types($mime_type, str_replace('post_mime_type:', '', $filter)), |
|
113 | 113 | true, |
114 | 114 | false |
115 | 115 | ); |
116 | 116 | |
117 | 117 | $type_links[$mime_type] = sprintf( |
118 | 118 | '<option value="post_mime_type:%s"%s>%s</option>', |
119 | - esc_attr( $mime_type ), |
|
119 | + esc_attr($mime_type), |
|
120 | 120 | $selected, |
121 | 121 | $label[0] |
122 | 122 | ); |
123 | 123 | } |
124 | - $type_links['detached'] = '<option value="detached"' . ( $this->detached ? ' selected="selected"' : '' ) . '>' . __( 'Unattached' ) . '</option>'; |
|
124 | + $type_links['detached'] = '<option value="detached"'.($this->detached ? ' selected="selected"' : '').'>'.__('Unattached').'</option>'; |
|
125 | 125 | |
126 | - if ( $this->is_trash || ( defined( 'MEDIA_TRASH') && MEDIA_TRASH ) ) { |
|
126 | + if ($this->is_trash || (defined('MEDIA_TRASH') && MEDIA_TRASH)) { |
|
127 | 127 | $type_links['trash'] = sprintf( |
128 | 128 | '<option value="trash"%s>%s</option>', |
129 | - selected( 'trash' === $filter, true, false ), |
|
130 | - _x( 'Trash', 'attachment filter' ) |
|
129 | + selected('trash' === $filter, true, false), |
|
130 | + _x('Trash', 'attachment filter') |
|
131 | 131 | ); |
132 | 132 | } |
133 | 133 | return $type_links; |
@@ -139,19 +139,19 @@ discard block |
||
139 | 139 | */ |
140 | 140 | protected function get_bulk_actions() { |
141 | 141 | $actions = array(); |
142 | - if ( MEDIA_TRASH ) { |
|
143 | - if ( $this->is_trash ) { |
|
144 | - $actions['untrash'] = __( 'Restore' ); |
|
145 | - $actions['delete'] = __( 'Delete Permanently' ); |
|
142 | + if (MEDIA_TRASH) { |
|
143 | + if ($this->is_trash) { |
|
144 | + $actions['untrash'] = __('Restore'); |
|
145 | + $actions['delete'] = __('Delete Permanently'); |
|
146 | 146 | } else { |
147 | - $actions['trash'] = _x( 'Trash', 'verb' ); |
|
147 | + $actions['trash'] = _x('Trash', 'verb'); |
|
148 | 148 | } |
149 | 149 | } else { |
150 | - $actions['delete'] = __( 'Delete Permanently' ); |
|
150 | + $actions['delete'] = __('Delete Permanently'); |
|
151 | 151 | } |
152 | 152 | |
153 | - if ( $this->detached ) |
|
154 | - $actions['attach'] = __( 'Attach' ); |
|
153 | + if ($this->detached) |
|
154 | + $actions['attach'] = __('Attach'); |
|
155 | 155 | |
156 | 156 | return $actions; |
157 | 157 | } |
@@ -159,26 +159,26 @@ discard block |
||
159 | 159 | /** |
160 | 160 | * @param string $which |
161 | 161 | */ |
162 | - protected function extra_tablenav( $which ) { |
|
163 | - if ( 'bar' !== $which ) { |
|
162 | + protected function extra_tablenav($which) { |
|
163 | + if ('bar' !== $which) { |
|
164 | 164 | return; |
165 | 165 | } |
166 | 166 | ?> |
167 | 167 | <div class="actions"> |
168 | 168 | <?php |
169 | - if ( ! is_singular() ) { |
|
170 | - if ( ! $this->is_trash ) { |
|
171 | - $this->months_dropdown( 'attachment' ); |
|
169 | + if ( ! is_singular()) { |
|
170 | + if ( ! $this->is_trash) { |
|
171 | + $this->months_dropdown('attachment'); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | /** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */ |
175 | - do_action( 'restrict_manage_posts', $this->screen->post_type ); |
|
175 | + do_action('restrict_manage_posts', $this->screen->post_type); |
|
176 | 176 | |
177 | - submit_button( __( 'Filter' ), 'button', 'filter_action', false, array( 'id' => 'post-query-submit' ) ); |
|
177 | + submit_button(__('Filter'), 'button', 'filter_action', false, array('id' => 'post-query-submit')); |
|
178 | 178 | } |
179 | 179 | |
180 | - if ( $this->is_trash && current_user_can( 'edit_others_posts' ) ) { |
|
181 | - submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); |
|
180 | + if ($this->is_trash && current_user_can('edit_others_posts')) { |
|
181 | + submit_button(__('Empty Trash'), 'apply', 'delete_all', false); |
|
182 | 182 | } ?> |
183 | 183 | </div> |
184 | 184 | <?php |
@@ -189,13 +189,13 @@ discard block |
||
189 | 189 | * @return string |
190 | 190 | */ |
191 | 191 | public function current_action() { |
192 | - if ( isset( $_REQUEST['found_post_id'] ) && isset( $_REQUEST['media'] ) ) |
|
192 | + if (isset($_REQUEST['found_post_id']) && isset($_REQUEST['media'])) |
|
193 | 193 | return 'attach'; |
194 | 194 | |
195 | - if ( isset( $_REQUEST['parent_post_id'] ) && isset( $_REQUEST['media'] ) ) |
|
195 | + if (isset($_REQUEST['parent_post_id']) && isset($_REQUEST['media'])) |
|
196 | 196 | return 'detach'; |
197 | 197 | |
198 | - if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) |
|
198 | + if (isset($_REQUEST['delete_all']) || isset($_REQUEST['delete_all2'])) |
|
199 | 199 | return 'delete_all'; |
200 | 200 | |
201 | 201 | return parent::current_action(); |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | * @access public |
214 | 214 | */ |
215 | 215 | public function no_items() { |
216 | - _e( 'No media files found.' ); |
|
216 | + _e('No media files found.'); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
@@ -226,17 +226,17 @@ discard block |
||
226 | 226 | |
227 | 227 | $views = $this->get_views(); |
228 | 228 | |
229 | - $this->screen->render_screen_reader_content( 'heading_views' ); |
|
229 | + $this->screen->render_screen_reader_content('heading_views'); |
|
230 | 230 | ?> |
231 | 231 | <div class="wp-filter"> |
232 | 232 | <div class="filter-items"> |
233 | - <?php $this->view_switcher( $mode ); ?> |
|
233 | + <?php $this->view_switcher($mode); ?> |
|
234 | 234 | |
235 | - <label for="attachment-filter" class="screen-reader-text"><?php _e( 'Filter by type' ); ?></label> |
|
235 | + <label for="attachment-filter" class="screen-reader-text"><?php _e('Filter by type'); ?></label> |
|
236 | 236 | <select class="attachment-filters" name="attachment-filter" id="attachment-filter"> |
237 | 237 | <?php |
238 | - if ( ! empty( $views ) ) { |
|
239 | - foreach ( $views as $class => $view ) { |
|
238 | + if ( ! empty($views)) { |
|
239 | + foreach ($views as $class => $view) { |
|
240 | 240 | echo "\t$view\n"; |
241 | 241 | } |
242 | 242 | } |
@@ -244,15 +244,15 @@ discard block |
||
244 | 244 | </select> |
245 | 245 | |
246 | 246 | <?php |
247 | - $this->extra_tablenav( 'bar' ); |
|
247 | + $this->extra_tablenav('bar'); |
|
248 | 248 | |
249 | 249 | /** This filter is documented in wp-admin/inclues/class-wp-list-table.php */ |
250 | - $views = apply_filters( "views_{$this->screen->id}", array() ); |
|
250 | + $views = apply_filters("views_{$this->screen->id}", array()); |
|
251 | 251 | |
252 | 252 | // Back compat for pre-4.0 view links. |
253 | - if ( ! empty( $views ) ) { |
|
253 | + if ( ! empty($views)) { |
|
254 | 254 | echo '<ul class="filter-links">'; |
255 | - foreach ( $views as $class => $view ) { |
|
255 | + foreach ($views as $class => $view) { |
|
256 | 256 | echo "<li class='$class'>$view</li>"; |
257 | 257 | } |
258 | 258 | echo '</ul>'; |
@@ -261,8 +261,8 @@ discard block |
||
261 | 261 | </div> |
262 | 262 | |
263 | 263 | <div class="search-form"> |
264 | - <label for="media-search-input" class="screen-reader-text"><?php esc_html_e( 'Search Media' ); ?></label> |
|
265 | - <input type="search" placeholder="<?php esc_attr_e( 'Search' ) ?>" id="media-search-input" class="search" name="s" value="<?php _admin_search_query(); ?>"></div> |
|
264 | + <label for="media-search-input" class="screen-reader-text"><?php esc_html_e('Search Media'); ?></label> |
|
265 | + <input type="search" placeholder="<?php esc_attr_e('Search') ?>" id="media-search-input" class="search" name="s" value="<?php _admin_search_query(); ?>"></div> |
|
266 | 266 | </div> |
267 | 267 | <?php |
268 | 268 | } |
@@ -275,11 +275,11 @@ discard block |
||
275 | 275 | $posts_columns = array(); |
276 | 276 | $posts_columns['cb'] = '<input type="checkbox" />'; |
277 | 277 | /* translators: column name */ |
278 | - $posts_columns['title'] = _x( 'File', 'column name' ); |
|
279 | - $posts_columns['author'] = __( 'Author' ); |
|
278 | + $posts_columns['title'] = _x('File', 'column name'); |
|
279 | + $posts_columns['author'] = __('Author'); |
|
280 | 280 | |
281 | - $taxonomies = get_taxonomies_for_attachments( 'objects' ); |
|
282 | - $taxonomies = wp_filter_object_list( $taxonomies, array( 'show_admin_column' => true ), 'and', 'name' ); |
|
281 | + $taxonomies = get_taxonomies_for_attachments('objects'); |
|
282 | + $taxonomies = wp_filter_object_list($taxonomies, array('show_admin_column' => true), 'and', 'name'); |
|
283 | 283 | |
284 | 284 | /** |
285 | 285 | * Filters the taxonomy columns for attachments in the Media list table. |
@@ -289,28 +289,28 @@ discard block |
||
289 | 289 | * @param array $taxonomies An array of registered taxonomies to show for attachments. |
290 | 290 | * @param string $post_type The post type. Default 'attachment'. |
291 | 291 | */ |
292 | - $taxonomies = apply_filters( 'manage_taxonomies_for_attachment_columns', $taxonomies, 'attachment' ); |
|
293 | - $taxonomies = array_filter( $taxonomies, 'taxonomy_exists' ); |
|
292 | + $taxonomies = apply_filters('manage_taxonomies_for_attachment_columns', $taxonomies, 'attachment'); |
|
293 | + $taxonomies = array_filter($taxonomies, 'taxonomy_exists'); |
|
294 | 294 | |
295 | - foreach ( $taxonomies as $taxonomy ) { |
|
296 | - if ( 'category' === $taxonomy ) { |
|
295 | + foreach ($taxonomies as $taxonomy) { |
|
296 | + if ('category' === $taxonomy) { |
|
297 | 297 | $column_key = 'categories'; |
298 | - } elseif ( 'post_tag' === $taxonomy ) { |
|
298 | + } elseif ('post_tag' === $taxonomy) { |
|
299 | 299 | $column_key = 'tags'; |
300 | 300 | } else { |
301 | - $column_key = 'taxonomy-' . $taxonomy; |
|
301 | + $column_key = 'taxonomy-'.$taxonomy; |
|
302 | 302 | } |
303 | - $posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name; |
|
303 | + $posts_columns[$column_key] = get_taxonomy($taxonomy)->labels->name; |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | /* translators: column name */ |
307 | - if ( !$this->detached ) { |
|
308 | - $posts_columns['parent'] = _x( 'Uploaded to', 'column name' ); |
|
309 | - if ( post_type_supports( 'attachment', 'comments' ) ) |
|
310 | - $posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="' . esc_attr__( 'Comments' ) . '"><span class="screen-reader-text">' . __( 'Comments' ) . '</span></span>'; |
|
307 | + if ( ! $this->detached) { |
|
308 | + $posts_columns['parent'] = _x('Uploaded to', 'column name'); |
|
309 | + if (post_type_supports('attachment', 'comments')) |
|
310 | + $posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="'.esc_attr__('Comments').'"><span class="screen-reader-text">'.__('Comments').'</span></span>'; |
|
311 | 311 | } |
312 | 312 | /* translators: column name */ |
313 | - $posts_columns['date'] = _x( 'Date', 'column name' ); |
|
313 | + $posts_columns['date'] = _x('Date', 'column name'); |
|
314 | 314 | /** |
315 | 315 | * Filters the Media list table columns. |
316 | 316 | * |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | * @param bool $detached Whether the list table contains media not attached |
321 | 321 | * to any posts. Default true. |
322 | 322 | */ |
323 | - return apply_filters( 'manage_media_columns', $posts_columns, $this->detached ); |
|
323 | + return apply_filters('manage_media_columns', $posts_columns, $this->detached); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | /** |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | 'author' => 'author', |
334 | 334 | 'parent' => 'parent', |
335 | 335 | 'comments' => 'comment_count', |
336 | - 'date' => array( 'date', true ), |
|
336 | + 'date' => array('date', true), |
|
337 | 337 | ); |
338 | 338 | } |
339 | 339 | |
@@ -345,10 +345,10 @@ discard block |
||
345 | 345 | * |
346 | 346 | * @param WP_Post $post The current WP_Post object. |
347 | 347 | */ |
348 | - public function column_cb( $post ) { |
|
349 | - if ( current_user_can( 'edit_post', $post->ID ) ) { ?> |
|
348 | + public function column_cb($post) { |
|
349 | + if (current_user_can('edit_post', $post->ID)) { ?> |
|
350 | 350 | <label class="screen-reader-text" for="cb-select-<?php echo $post->ID; ?>"><?php |
351 | - echo sprintf( __( 'Select %s' ), _draft_or_post_title() ); |
|
351 | + echo sprintf(__('Select %s'), _draft_or_post_title()); |
|
352 | 352 | ?></label> |
353 | 353 | <input type="checkbox" name="media[]" id="cb-select-<?php echo $post->ID; ?>" value="<?php echo $post->ID; ?>" /> |
354 | 354 | <?php } |
@@ -362,19 +362,19 @@ discard block |
||
362 | 362 | * |
363 | 363 | * @param WP_Post $post The current WP_Post object. |
364 | 364 | */ |
365 | - public function column_title( $post ) { |
|
366 | - list( $mime ) = explode( '/', $post->post_mime_type ); |
|
365 | + public function column_title($post) { |
|
366 | + list($mime) = explode('/', $post->post_mime_type); |
|
367 | 367 | |
368 | 368 | $title = _draft_or_post_title(); |
369 | - $thumb = wp_get_attachment_image( $post->ID, array( 60, 60 ), true, array( 'alt' => '' ) ); |
|
369 | + $thumb = wp_get_attachment_image($post->ID, array(60, 60), true, array('alt' => '')); |
|
370 | 370 | $link_start = $link_end = ''; |
371 | 371 | |
372 | - if ( current_user_can( 'edit_post', $post->ID ) && ! $this->is_trash ) { |
|
372 | + if (current_user_can('edit_post', $post->ID) && ! $this->is_trash) { |
|
373 | 373 | $link_start = sprintf( |
374 | 374 | '<a href="%s" aria-label="%s">', |
375 | - get_edit_post_link( $post->ID ), |
|
375 | + get_edit_post_link($post->ID), |
|
376 | 376 | /* translators: %s: attachment title */ |
377 | - esc_attr( sprintf( __( '“%s” (Edit)' ), $title ) ) |
|
377 | + esc_attr(sprintf(__('“%s” (Edit)'), $title)) |
|
378 | 378 | ); |
379 | 379 | $link_end = '</a>'; |
380 | 380 | } |
@@ -384,18 +384,18 @@ discard block |
||
384 | 384 | <strong<?php echo $class; ?>> |
385 | 385 | <?php |
386 | 386 | echo $link_start; |
387 | - if ( $thumb ) : ?> |
|
388 | - <span class="media-icon <?php echo sanitize_html_class( $mime . '-icon' ); ?>"><?php echo $thumb; ?></span> |
|
387 | + if ($thumb) : ?> |
|
388 | + <span class="media-icon <?php echo sanitize_html_class($mime.'-icon'); ?>"><?php echo $thumb; ?></span> |
|
389 | 389 | <?php endif; |
390 | - echo $title . $link_end; |
|
391 | - _media_states( $post ); |
|
390 | + echo $title.$link_end; |
|
391 | + _media_states($post); |
|
392 | 392 | ?> |
393 | 393 | </strong> |
394 | 394 | <p class="filename"> |
395 | - <span class="screen-reader-text"><?php _e( 'File name:' ); ?> </span> |
|
395 | + <span class="screen-reader-text"><?php _e('File name:'); ?> </span> |
|
396 | 396 | <?php |
397 | - $file = get_attached_file( $post->ID ); |
|
398 | - echo esc_html( wp_basename( $file ) ); |
|
397 | + $file = get_attached_file($post->ID); |
|
398 | + echo esc_html(wp_basename($file)); |
|
399 | 399 | ?> |
400 | 400 | </p> |
401 | 401 | <?php |
@@ -409,9 +409,9 @@ discard block |
||
409 | 409 | * |
410 | 410 | * @param WP_Post $post The current WP_Post object. |
411 | 411 | */ |
412 | - public function column_author( $post ) { |
|
413 | - printf( '<a href="%s">%s</a>', |
|
414 | - esc_url( add_query_arg( array( 'author' => get_the_author_meta('ID') ), 'upload.php' ) ), |
|
412 | + public function column_author($post) { |
|
413 | + printf('<a href="%s">%s</a>', |
|
414 | + esc_url(add_query_arg(array('author' => get_the_author_meta('ID')), 'upload.php')), |
|
415 | 415 | get_the_author() |
416 | 416 | ); |
417 | 417 | } |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | * |
425 | 425 | * @param WP_Post $post The current WP_Post object. |
426 | 426 | */ |
427 | - public function column_desc( $post ) { |
|
427 | + public function column_desc($post) { |
|
428 | 428 | echo has_excerpt() ? $post->post_excerpt : ''; |
429 | 429 | } |
430 | 430 | |
@@ -436,20 +436,20 @@ discard block |
||
436 | 436 | * |
437 | 437 | * @param WP_Post $post The current WP_Post object. |
438 | 438 | */ |
439 | - public function column_date( $post ) { |
|
440 | - if ( '0000-00-00 00:00:00' === $post->post_date ) { |
|
441 | - $h_time = __( 'Unpublished' ); |
|
439 | + public function column_date($post) { |
|
440 | + if ('0000-00-00 00:00:00' === $post->post_date) { |
|
441 | + $h_time = __('Unpublished'); |
|
442 | 442 | } else { |
443 | 443 | $m_time = $post->post_date; |
444 | - $time = get_post_time( 'G', true, $post, false ); |
|
445 | - if ( ( abs( $t_diff = time() - $time ) ) < DAY_IN_SECONDS ) { |
|
446 | - if ( $t_diff < 0 ) { |
|
447 | - $h_time = sprintf( __( '%s from now' ), human_time_diff( $time ) ); |
|
444 | + $time = get_post_time('G', true, $post, false); |
|
445 | + if ((abs($t_diff = time() - $time)) < DAY_IN_SECONDS) { |
|
446 | + if ($t_diff < 0) { |
|
447 | + $h_time = sprintf(__('%s from now'), human_time_diff($time)); |
|
448 | 448 | } else { |
449 | - $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) ); |
|
449 | + $h_time = sprintf(__('%s ago'), human_time_diff($time)); |
|
450 | 450 | } |
451 | 451 | } else { |
452 | - $h_time = mysql2date( __( 'Y/m/d' ), $m_time ); |
|
452 | + $h_time = mysql2date(__('Y/m/d'), $m_time); |
|
453 | 453 | } |
454 | 454 | } |
455 | 455 | |
@@ -464,54 +464,54 @@ discard block |
||
464 | 464 | * |
465 | 465 | * @param WP_Post $post The current WP_Post object. |
466 | 466 | */ |
467 | - public function column_parent( $post ) { |
|
468 | - $user_can_edit = current_user_can( 'edit_post', $post->ID ); |
|
467 | + public function column_parent($post) { |
|
468 | + $user_can_edit = current_user_can('edit_post', $post->ID); |
|
469 | 469 | |
470 | - if ( $post->post_parent > 0 ) { |
|
471 | - $parent = get_post( $post->post_parent ); |
|
470 | + if ($post->post_parent > 0) { |
|
471 | + $parent = get_post($post->post_parent); |
|
472 | 472 | } else { |
473 | 473 | $parent = false; |
474 | 474 | } |
475 | 475 | |
476 | - if ( $parent ) { |
|
477 | - $title = _draft_or_post_title( $post->post_parent ); |
|
478 | - $parent_type = get_post_type_object( $parent->post_type ); |
|
476 | + if ($parent) { |
|
477 | + $title = _draft_or_post_title($post->post_parent); |
|
478 | + $parent_type = get_post_type_object($parent->post_type); |
|
479 | 479 | |
480 | - if ( $parent_type && $parent_type->show_ui && current_user_can( 'edit_post', $post->post_parent ) ) { |
|
480 | + if ($parent_type && $parent_type->show_ui && current_user_can('edit_post', $post->post_parent)) { |
|
481 | 481 | ?> |
482 | - <strong><a href="<?php echo get_edit_post_link( $post->post_parent ); ?>"> |
|
482 | + <strong><a href="<?php echo get_edit_post_link($post->post_parent); ?>"> |
|
483 | 483 | <?php echo $title ?></a></strong><?php |
484 | - } elseif ( $parent_type && current_user_can( 'read_post', $post->post_parent ) ) { |
|
484 | + } elseif ($parent_type && current_user_can('read_post', $post->post_parent)) { |
|
485 | 485 | ?> |
486 | 486 | <strong><?php echo $title ?></strong><?php |
487 | 487 | } else { |
488 | - _e( '(Private post)' ); |
|
488 | + _e('(Private post)'); |
|
489 | 489 | } |
490 | 490 | |
491 | - if ( $user_can_edit ): |
|
492 | - $detach_url = add_query_arg( array( |
|
491 | + if ($user_can_edit): |
|
492 | + $detach_url = add_query_arg(array( |
|
493 | 493 | 'parent_post_id' => $post->post_parent, |
494 | 494 | 'media[]' => $post->ID, |
495 | - '_wpnonce' => wp_create_nonce( 'bulk-' . $this->_args['plural'] ) |
|
496 | - ), 'upload.php' ); |
|
495 | + '_wpnonce' => wp_create_nonce('bulk-'.$this->_args['plural']) |
|
496 | + ), 'upload.php'); |
|
497 | 497 | printf( |
498 | 498 | '<br /><a href="%s" class="hide-if-no-js detach-from-parent" aria-label="%s">%s</a>', |
499 | 499 | $detach_url, |
500 | 500 | /* translators: %s: title of the post the attachment is attached to */ |
501 | - esc_attr( sprintf( __( 'Detach from “%s”' ), $title ) ), |
|
502 | - __( 'Detach' ) |
|
501 | + esc_attr(sprintf(__('Detach from “%s”'), $title)), |
|
502 | + __('Detach') |
|
503 | 503 | ); |
504 | 504 | endif; |
505 | 505 | } else { |
506 | - _e( '(Unattached)' ); ?> |
|
507 | - <?php if ( $user_can_edit ) { |
|
508 | - $title = _draft_or_post_title( $post->post_parent ); |
|
506 | + _e('(Unattached)'); ?> |
|
507 | + <?php if ($user_can_edit) { |
|
508 | + $title = _draft_or_post_title($post->post_parent); |
|
509 | 509 | printf( |
510 | 510 | '<br /><a href="#the-list" onclick="findPosts.open( \'media[]\', \'%s\' ); return false;" class="hide-if-no-js aria-button-if-js" aria-label="%s">%s</a>', |
511 | 511 | $post->ID, |
512 | 512 | /* translators: %s: attachment title */ |
513 | - esc_attr( sprintf( __( 'Attach “%s” to existing content' ), $title ) ), |
|
514 | - __( 'Attach' ) |
|
513 | + esc_attr(sprintf(__('Attach “%s” to existing content'), $title)), |
|
514 | + __('Attach') |
|
515 | 515 | ); |
516 | 516 | } |
517 | 517 | } |
@@ -525,16 +525,16 @@ discard block |
||
525 | 525 | * |
526 | 526 | * @param WP_Post $post The current WP_Post object. |
527 | 527 | */ |
528 | - public function column_comments( $post ) { |
|
528 | + public function column_comments($post) { |
|
529 | 529 | echo '<div class="post-com-count-wrapper">'; |
530 | 530 | |
531 | - if ( isset( $this->comment_pending_count[ $post->ID ] ) ) { |
|
532 | - $pending_comments = $this->comment_pending_count[ $post->ID ]; |
|
531 | + if (isset($this->comment_pending_count[$post->ID])) { |
|
532 | + $pending_comments = $this->comment_pending_count[$post->ID]; |
|
533 | 533 | } else { |
534 | - $pending_comments = get_pending_comments_num( $post->ID ); |
|
534 | + $pending_comments = get_pending_comments_num($post->ID); |
|
535 | 535 | } |
536 | 536 | |
537 | - $this->comments_bubble( $post->ID, $pending_comments ); |
|
537 | + $this->comments_bubble($post->ID, $pending_comments); |
|
538 | 538 | |
539 | 539 | echo '</div>'; |
540 | 540 | } |
@@ -548,35 +548,35 @@ discard block |
||
548 | 548 | * @param WP_Post $post The current WP_Post object. |
549 | 549 | * @param string $column_name Current column name. |
550 | 550 | */ |
551 | - public function column_default( $post, $column_name ) { |
|
552 | - if ( 'categories' === $column_name ) { |
|
551 | + public function column_default($post, $column_name) { |
|
552 | + if ('categories' === $column_name) { |
|
553 | 553 | $taxonomy = 'category'; |
554 | - } elseif ( 'tags' === $column_name ) { |
|
554 | + } elseif ('tags' === $column_name) { |
|
555 | 555 | $taxonomy = 'post_tag'; |
556 | - } elseif ( 0 === strpos( $column_name, 'taxonomy-' ) ) { |
|
557 | - $taxonomy = substr( $column_name, 9 ); |
|
556 | + } elseif (0 === strpos($column_name, 'taxonomy-')) { |
|
557 | + $taxonomy = substr($column_name, 9); |
|
558 | 558 | } else { |
559 | 559 | $taxonomy = false; |
560 | 560 | } |
561 | 561 | |
562 | - if ( $taxonomy ) { |
|
563 | - $terms = get_the_terms( $post->ID, $taxonomy ); |
|
564 | - if ( is_array( $terms ) ) { |
|
562 | + if ($taxonomy) { |
|
563 | + $terms = get_the_terms($post->ID, $taxonomy); |
|
564 | + if (is_array($terms)) { |
|
565 | 565 | $out = array(); |
566 | - foreach ( $terms as $t ) { |
|
566 | + foreach ($terms as $t) { |
|
567 | 567 | $posts_in_term_qv = array(); |
568 | 568 | $posts_in_term_qv['taxonomy'] = $taxonomy; |
569 | 569 | $posts_in_term_qv['term'] = $t->slug; |
570 | 570 | |
571 | - $out[] = sprintf( '<a href="%s">%s</a>', |
|
572 | - esc_url( add_query_arg( $posts_in_term_qv, 'upload.php' ) ), |
|
573 | - esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) ) |
|
571 | + $out[] = sprintf('<a href="%s">%s</a>', |
|
572 | + esc_url(add_query_arg($posts_in_term_qv, 'upload.php')), |
|
573 | + esc_html(sanitize_term_field('name', $t->name, $t->term_id, $taxonomy, 'display')) |
|
574 | 574 | ); |
575 | 575 | } |
576 | 576 | /* translators: used between list items, there is a space after the comma */ |
577 | - echo join( __( ', ' ), $out ); |
|
577 | + echo join(__(', '), $out); |
|
578 | 578 | } else { |
579 | - echo '<span aria-hidden="true">—</span><span class="screen-reader-text">' . get_taxonomy( $taxonomy )->labels->no_terms . '</span>'; |
|
579 | + echo '<span aria-hidden="true">—</span><span class="screen-reader-text">'.get_taxonomy($taxonomy)->labels->no_terms.'</span>'; |
|
580 | 580 | } |
581 | 581 | |
582 | 582 | return; |
@@ -592,7 +592,7 @@ discard block |
||
592 | 592 | * @param string $column_name Name of the custom column. |
593 | 593 | * @param int $post_id Attachment ID. |
594 | 594 | */ |
595 | - do_action( 'manage_media_custom_column', $column_name, $post->ID ); |
|
595 | + do_action('manage_media_custom_column', $column_name, $post->ID); |
|
596 | 596 | } |
597 | 597 | |
598 | 598 | /** |
@@ -602,24 +602,24 @@ discard block |
||
602 | 602 | public function display_rows() { |
603 | 603 | global $post, $wp_query; |
604 | 604 | |
605 | - $post_ids = wp_list_pluck( $wp_query->posts, 'ID' ); |
|
606 | - reset( $wp_query->posts ); |
|
605 | + $post_ids = wp_list_pluck($wp_query->posts, 'ID'); |
|
606 | + reset($wp_query->posts); |
|
607 | 607 | |
608 | - $this->comment_pending_count = get_pending_comments_num( $post_ids ); |
|
608 | + $this->comment_pending_count = get_pending_comments_num($post_ids); |
|
609 | 609 | |
610 | - add_filter( 'the_title','esc_html' ); |
|
610 | + add_filter('the_title', 'esc_html'); |
|
611 | 611 | |
612 | - while ( have_posts() ) : the_post(); |
|
612 | + while (have_posts()) : the_post(); |
|
613 | 613 | if ( |
614 | - ( $this->is_trash && $post->post_status != 'trash' ) |
|
615 | - || ( ! $this->is_trash && $post->post_status === 'trash' ) |
|
614 | + ($this->is_trash && $post->post_status != 'trash') |
|
615 | + || ( ! $this->is_trash && $post->post_status === 'trash') |
|
616 | 616 | ) { |
617 | 617 | continue; |
618 | 618 | } |
619 | - $post_owner = ( get_current_user_id() == $post->post_author ) ? 'self' : 'other'; |
|
619 | + $post_owner = (get_current_user_id() == $post->post_author) ? 'self' : 'other'; |
|
620 | 620 | ?> |
621 | - <tr id="post-<?php echo $post->ID; ?>" class="<?php echo trim( ' author-' . $post_owner . ' status-' . $post->post_status ); ?>"> |
|
622 | - <?php $this->single_row_columns( $post ); ?> |
|
621 | + <tr id="post-<?php echo $post->ID; ?>" class="<?php echo trim(' author-'.$post_owner.' status-'.$post->post_status); ?>"> |
|
622 | + <?php $this->single_row_columns($post); ?> |
|
623 | 623 | </tr> |
624 | 624 | <?php |
625 | 625 | endwhile; |
@@ -643,105 +643,105 @@ discard block |
||
643 | 643 | * |
644 | 644 | * @return array |
645 | 645 | */ |
646 | - private function _get_row_actions( $post, $att_title ) { |
|
646 | + private function _get_row_actions($post, $att_title) { |
|
647 | 647 | $actions = array(); |
648 | 648 | |
649 | - if ( $this->detached ) { |
|
650 | - if ( current_user_can( 'edit_post', $post->ID ) ) { |
|
649 | + if ($this->detached) { |
|
650 | + if (current_user_can('edit_post', $post->ID)) { |
|
651 | 651 | $actions['edit'] = sprintf( |
652 | 652 | '<a href="%s" aria-label="%s">%s</a>', |
653 | - get_edit_post_link( $post->ID ), |
|
653 | + get_edit_post_link($post->ID), |
|
654 | 654 | /* translators: %s: attachment title */ |
655 | - esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ), |
|
656 | - __( 'Edit' ) |
|
655 | + esc_attr(sprintf(__('Edit “%s”'), $att_title)), |
|
656 | + __('Edit') |
|
657 | 657 | ); |
658 | 658 | } |
659 | - if ( current_user_can( 'delete_post', $post->ID ) ) { |
|
660 | - if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) { |
|
659 | + if (current_user_can('delete_post', $post->ID)) { |
|
660 | + if (EMPTY_TRASH_DAYS && MEDIA_TRASH) { |
|
661 | 661 | $actions['trash'] = sprintf( |
662 | 662 | '<a href="%s" class="submitdelete aria-button-if-js" aria-label="%s">%s</a>', |
663 | - wp_nonce_url( "post.php?action=trash&post=$post->ID", 'trash-post_' . $post->ID ), |
|
663 | + wp_nonce_url("post.php?action=trash&post=$post->ID", 'trash-post_'.$post->ID), |
|
664 | 664 | /* translators: %s: attachment title */ |
665 | - esc_attr( sprintf( __( 'Move “%s” to the Trash' ), $att_title ) ), |
|
666 | - _x( 'Trash', 'verb' ) |
|
665 | + esc_attr(sprintf(__('Move “%s” to the Trash'), $att_title)), |
|
666 | + _x('Trash', 'verb') |
|
667 | 667 | ); |
668 | 668 | } else { |
669 | 669 | $delete_ays = ! MEDIA_TRASH ? " onclick='return showNotice.warn();'" : ''; |
670 | 670 | $actions['delete'] = sprintf( |
671 | 671 | '<a href="%s" class="submitdelete aria-button-if-js"%s aria-label="%s">%s</a>', |
672 | - wp_nonce_url( "post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID ), |
|
672 | + wp_nonce_url("post.php?action=delete&post=$post->ID", 'delete-post_'.$post->ID), |
|
673 | 673 | $delete_ays, |
674 | 674 | /* translators: %s: attachment title */ |
675 | - esc_attr( sprintf( __( 'Delete “%s” permanently' ), $att_title ) ), |
|
676 | - __( 'Delete Permanently' ) |
|
675 | + esc_attr(sprintf(__('Delete “%s” permanently'), $att_title)), |
|
676 | + __('Delete Permanently') |
|
677 | 677 | ); |
678 | 678 | } |
679 | 679 | } |
680 | 680 | $actions['view'] = sprintf( |
681 | 681 | '<a href="%s" aria-label="%s" rel="permalink">%s</a>', |
682 | - get_permalink( $post->ID ), |
|
682 | + get_permalink($post->ID), |
|
683 | 683 | /* translators: %s: attachment title */ |
684 | - esc_attr( sprintf( __( 'View “%s”' ), $att_title ) ), |
|
685 | - __( 'View' ) |
|
684 | + esc_attr(sprintf(__('View “%s”'), $att_title)), |
|
685 | + __('View') |
|
686 | 686 | ); |
687 | 687 | |
688 | - if ( current_user_can( 'edit_post', $post->ID ) ) { |
|
688 | + if (current_user_can('edit_post', $post->ID)) { |
|
689 | 689 | $actions['attach'] = sprintf( |
690 | 690 | '<a href="#the-list" onclick="findPosts.open( \'media[]\', \'%s\' ); return false;" class="hide-if-no-js aria-button-if-js" aria-label="%s">%s</a>', |
691 | 691 | $post->ID, |
692 | 692 | /* translators: %s: attachment title */ |
693 | - esc_attr( sprintf( __( 'Attach “%s” to existing content' ), $att_title ) ), |
|
694 | - __( 'Attach' ) |
|
693 | + esc_attr(sprintf(__('Attach “%s” to existing content'), $att_title)), |
|
694 | + __('Attach') |
|
695 | 695 | ); |
696 | 696 | } |
697 | 697 | } |
698 | 698 | else { |
699 | - if ( current_user_can( 'edit_post', $post->ID ) && !$this->is_trash ) { |
|
699 | + if (current_user_can('edit_post', $post->ID) && ! $this->is_trash) { |
|
700 | 700 | $actions['edit'] = sprintf( |
701 | 701 | '<a href="%s" aria-label="%s">%s</a>', |
702 | - get_edit_post_link( $post->ID ), |
|
702 | + get_edit_post_link($post->ID), |
|
703 | 703 | /* translators: %s: attachment title */ |
704 | - esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ), |
|
705 | - __( 'Edit' ) |
|
704 | + esc_attr(sprintf(__('Edit “%s”'), $att_title)), |
|
705 | + __('Edit') |
|
706 | 706 | ); |
707 | 707 | } |
708 | - if ( current_user_can( 'delete_post', $post->ID ) ) { |
|
709 | - if ( $this->is_trash ) { |
|
708 | + if (current_user_can('delete_post', $post->ID)) { |
|
709 | + if ($this->is_trash) { |
|
710 | 710 | $actions['untrash'] = sprintf( |
711 | 711 | '<a href="%s" class="submitdelete aria-button-if-js" aria-label="%s">%s</a>', |
712 | - wp_nonce_url( "post.php?action=untrash&post=$post->ID", 'untrash-post_' . $post->ID ), |
|
712 | + wp_nonce_url("post.php?action=untrash&post=$post->ID", 'untrash-post_'.$post->ID), |
|
713 | 713 | /* translators: %s: attachment title */ |
714 | - esc_attr( sprintf( __( 'Restore “%s” from the Trash' ), $att_title ) ), |
|
715 | - __( 'Restore' ) |
|
714 | + esc_attr(sprintf(__('Restore “%s” from the Trash'), $att_title)), |
|
715 | + __('Restore') |
|
716 | 716 | ); |
717 | - } elseif ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) { |
|
717 | + } elseif (EMPTY_TRASH_DAYS && MEDIA_TRASH) { |
|
718 | 718 | $actions['trash'] = sprintf( |
719 | 719 | '<a href="%s" class="submitdelete aria-button-if-js" aria-label="%s">%s</a>', |
720 | - wp_nonce_url( "post.php?action=trash&post=$post->ID", 'trash-post_' . $post->ID ), |
|
720 | + wp_nonce_url("post.php?action=trash&post=$post->ID", 'trash-post_'.$post->ID), |
|
721 | 721 | /* translators: %s: attachment title */ |
722 | - esc_attr( sprintf( __( 'Move “%s” to the Trash' ), $att_title ) ), |
|
723 | - _x( 'Trash', 'verb' ) |
|
722 | + esc_attr(sprintf(__('Move “%s” to the Trash'), $att_title)), |
|
723 | + _x('Trash', 'verb') |
|
724 | 724 | ); |
725 | 725 | } |
726 | - if ( $this->is_trash || ! EMPTY_TRASH_DAYS || ! MEDIA_TRASH ) { |
|
727 | - $delete_ays = ( !$this->is_trash && !MEDIA_TRASH ) ? " onclick='return showNotice.warn();'" : ''; |
|
726 | + if ($this->is_trash || ! EMPTY_TRASH_DAYS || ! MEDIA_TRASH) { |
|
727 | + $delete_ays = ( ! $this->is_trash && ! MEDIA_TRASH) ? " onclick='return showNotice.warn();'" : ''; |
|
728 | 728 | $actions['delete'] = sprintf( |
729 | 729 | '<a href="%s" class="submitdelete aria-button-if-js"%s aria-label="%s">%s</a>', |
730 | - wp_nonce_url( "post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID ), |
|
730 | + wp_nonce_url("post.php?action=delete&post=$post->ID", 'delete-post_'.$post->ID), |
|
731 | 731 | $delete_ays, |
732 | 732 | /* translators: %s: attachment title */ |
733 | - esc_attr( sprintf( __( 'Delete “%s” permanently' ), $att_title ) ), |
|
734 | - __( 'Delete Permanently' ) |
|
733 | + esc_attr(sprintf(__('Delete “%s” permanently'), $att_title)), |
|
734 | + __('Delete Permanently') |
|
735 | 735 | ); |
736 | 736 | } |
737 | 737 | } |
738 | - if ( ! $this->is_trash ) { |
|
738 | + if ( ! $this->is_trash) { |
|
739 | 739 | $actions['view'] = sprintf( |
740 | 740 | '<a href="%s" aria-label="%s" rel="permalink">%s</a>', |
741 | - get_permalink( $post->ID ), |
|
741 | + get_permalink($post->ID), |
|
742 | 742 | /* translators: %s: attachment title */ |
743 | - esc_attr( sprintf( __( 'View “%s”' ), $att_title ) ), |
|
744 | - __( 'View' ) |
|
743 | + esc_attr(sprintf(__('View “%s”'), $att_title)), |
|
744 | + __('View') |
|
745 | 745 | ); |
746 | 746 | } |
747 | 747 | } |
@@ -757,7 +757,7 @@ discard block |
||
757 | 757 | * @param bool $detached Whether the list table contains media not attached |
758 | 758 | * to any posts. Default true. |
759 | 759 | */ |
760 | - return apply_filters( 'media_row_actions', $actions, $post, $this->detached ); |
|
760 | + return apply_filters('media_row_actions', $actions, $post, $this->detached); |
|
761 | 761 | } |
762 | 762 | |
763 | 763 | /** |
@@ -771,12 +771,12 @@ discard block |
||
771 | 771 | * @param string $primary Primary column name. |
772 | 772 | * @return string Row actions output for media attachments. |
773 | 773 | */ |
774 | - protected function handle_row_actions( $post, $column_name, $primary ) { |
|
775 | - if ( $primary !== $column_name ) { |
|
774 | + protected function handle_row_actions($post, $column_name, $primary) { |
|
775 | + if ($primary !== $column_name) { |
|
776 | 776 | return ''; |
777 | 777 | } |
778 | 778 | |
779 | 779 | $att_title = _draft_or_post_title(); |
780 | - return $this->row_actions( $this->_get_row_actions( $post, $att_title ) ); |
|
780 | + return $this->row_actions($this->_get_row_actions($post, $att_title)); |
|
781 | 781 | } |
782 | 782 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * @deprecated 3.0.0 |
17 | 17 | */ |
18 | 18 | function wpmu_menu() { |
19 | - _deprecated_function(__FUNCTION__, '3.0.0' ); |
|
19 | + _deprecated_function(__FUNCTION__, '3.0.0'); |
|
20 | 20 | // Deprecated. See #11763. |
21 | 21 | } |
22 | 22 | |
@@ -27,10 +27,10 @@ discard block |
||
27 | 27 | * @see is_upload_space_available() |
28 | 28 | */ |
29 | 29 | function wpmu_checkAvailableSpace() { |
30 | - _deprecated_function(__FUNCTION__, '3.0.0', 'is_upload_space_available()' ); |
|
30 | + _deprecated_function(__FUNCTION__, '3.0.0', 'is_upload_space_available()'); |
|
31 | 31 | |
32 | - if ( !is_upload_space_available() ) |
|
33 | - wp_die( __('Sorry, you must delete files before you can upload any more.') ); |
|
32 | + if ( ! is_upload_space_available()) |
|
33 | + wp_die(__('Sorry, you must delete files before you can upload any more.')); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @deprecated 3.0.0 |
40 | 40 | */ |
41 | -function mu_options( $options ) { |
|
42 | - _deprecated_function(__FUNCTION__, '3.0.0' ); |
|
41 | +function mu_options($options) { |
|
42 | + _deprecated_function(__FUNCTION__, '3.0.0'); |
|
43 | 43 | return $options; |
44 | 44 | } |
45 | 45 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * @see activate_plugin() |
51 | 51 | */ |
52 | 52 | function activate_sitewide_plugin() { |
53 | - _deprecated_function(__FUNCTION__, '3.0.0', 'activate_plugin()' ); |
|
53 | + _deprecated_function(__FUNCTION__, '3.0.0', 'activate_plugin()'); |
|
54 | 54 | return false; |
55 | 55 | } |
56 | 56 | |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | * @deprecated 3.0.0 Use deactivate_sitewide_plugin() |
61 | 61 | * @see deactivate_sitewide_plugin() |
62 | 62 | */ |
63 | -function deactivate_sitewide_plugin( $plugin = false ) { |
|
64 | - _deprecated_function(__FUNCTION__, '3.0.0', 'deactivate_plugin()' ); |
|
63 | +function deactivate_sitewide_plugin($plugin = false) { |
|
64 | + _deprecated_function(__FUNCTION__, '3.0.0', 'deactivate_plugin()'); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | * @deprecated 3.0.0 Use is_network_only_plugin() |
71 | 71 | * @see is_network_only_plugin() |
72 | 72 | */ |
73 | -function is_wpmu_sitewide_plugin( $file ) { |
|
74 | - _deprecated_function(__FUNCTION__, '3.0.0', 'is_network_only_plugin()' ); |
|
75 | - return is_network_only_plugin( $file ); |
|
73 | +function is_wpmu_sitewide_plugin($file) { |
|
74 | + _deprecated_function(__FUNCTION__, '3.0.0', 'is_network_only_plugin()'); |
|
75 | + return is_network_only_plugin($file); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | * @see WP_Theme::get_allowed_on_network() |
83 | 83 | */ |
84 | 84 | function get_site_allowed_themes() { |
85 | - _deprecated_function( __FUNCTION__, '3.4.0', 'WP_Theme::get_allowed_on_network()' ); |
|
86 | - return array_map( 'intval', WP_Theme::get_allowed_on_network() ); |
|
85 | + _deprecated_function(__FUNCTION__, '3.4.0', 'WP_Theme::get_allowed_on_network()'); |
|
86 | + return array_map('intval', WP_Theme::get_allowed_on_network()); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -92,9 +92,9 @@ discard block |
||
92 | 92 | * @deprecated 3.4.0 Use WP_Theme::get_allowed_on_site() |
93 | 93 | * @see WP_Theme::get_allowed_on_site() |
94 | 94 | */ |
95 | -function wpmu_get_blog_allowedthemes( $blog_id = 0 ) { |
|
96 | - _deprecated_function( __FUNCTION__, '3.4.0', 'WP_Theme::get_allowed_on_site()' ); |
|
97 | - return array_map( 'intval', WP_Theme::get_allowed_on_site( $blog_id ) ); |
|
95 | +function wpmu_get_blog_allowedthemes($blog_id = 0) { |
|
96 | + _deprecated_function(__FUNCTION__, '3.4.0', 'WP_Theme::get_allowed_on_site()'); |
|
97 | + return array_map('intval', WP_Theme::get_allowed_on_site($blog_id)); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -30,20 +30,20 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @param array $args An associative array of arguments. |
32 | 32 | */ |
33 | - public function __construct( $args = array() ) { |
|
33 | + public function __construct($args = array()) { |
|
34 | 34 | global $status, $page; |
35 | 35 | |
36 | - parent::__construct( array( |
|
36 | + parent::__construct(array( |
|
37 | 37 | 'plural' => 'plugins', |
38 | - 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
|
39 | - ) ); |
|
38 | + 'screen' => isset($args['screen']) ? $args['screen'] : null, |
|
39 | + )); |
|
40 | 40 | |
41 | 41 | $status = 'all'; |
42 | - if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], array( 'active', 'inactive', 'recently_activated', 'upgrade', 'mustuse', 'dropins', 'search' ) ) ) |
|
42 | + if (isset($_REQUEST['plugin_status']) && in_array($_REQUEST['plugin_status'], array('active', 'inactive', 'recently_activated', 'upgrade', 'mustuse', 'dropins', 'search'))) |
|
43 | 43 | $status = $_REQUEST['plugin_status']; |
44 | 44 | |
45 | - if ( isset($_REQUEST['s']) ) |
|
46 | - $_SERVER['REQUEST_URI'] = add_query_arg('s', wp_unslash($_REQUEST['s']) ); |
|
45 | + if (isset($_REQUEST['s'])) |
|
46 | + $_SERVER['REQUEST_URI'] = add_query_arg('s', wp_unslash($_REQUEST['s'])); |
|
47 | 47 | |
48 | 48 | $page = $this->get_pagenum(); |
49 | 49 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @return array |
53 | 53 | */ |
54 | 54 | protected function get_table_classes() { |
55 | - return array( 'widefat', $this->_args['plural'] ); |
|
55 | + return array('widefat', $this->_args['plural']); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | public function prepare_items() { |
76 | 76 | global $status, $plugins, $totals, $page, $orderby, $order, $s; |
77 | 77 | |
78 | - wp_reset_vars( array( 'orderby', 'order' ) ); |
|
78 | + wp_reset_vars(array('orderby', 'order')); |
|
79 | 79 | |
80 | 80 | /** |
81 | 81 | * Filters the full array of plugins to list in the Plugins list table. |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @param array $all_plugins An array of plugins to display in the list table. |
88 | 88 | */ |
89 | - $all_plugins = apply_filters( 'all_plugins', get_plugins() ); |
|
89 | + $all_plugins = apply_filters('all_plugins', get_plugins()); |
|
90 | 90 | |
91 | 91 | $plugins = array( |
92 | 92 | 'all' => $all_plugins, |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | |
102 | 102 | $screen = $this->screen; |
103 | 103 | |
104 | - if ( ! is_multisite() || ( $screen->in_admin( 'network' ) && current_user_can( 'manage_network_plugins' ) ) ) { |
|
104 | + if ( ! is_multisite() || ($screen->in_admin('network') && current_user_can('manage_network_plugins'))) { |
|
105 | 105 | |
106 | 106 | /** |
107 | 107 | * Filters whether to display the advanced plugins list table. |
@@ -118,27 +118,27 @@ discard block |
||
118 | 118 | * plugin type. Default true. |
119 | 119 | * @param string $type The plugin type. Accepts 'mustuse', 'dropins'. |
120 | 120 | */ |
121 | - if ( apply_filters( 'show_advanced_plugins', true, 'mustuse' ) ) { |
|
121 | + if (apply_filters('show_advanced_plugins', true, 'mustuse')) { |
|
122 | 122 | $plugins['mustuse'] = get_mu_plugins(); |
123 | 123 | } |
124 | 124 | |
125 | 125 | /** This action is documented in wp-admin/includes/class-wp-plugins-list-table.php */ |
126 | - if ( apply_filters( 'show_advanced_plugins', true, 'dropins' ) ) |
|
126 | + if (apply_filters('show_advanced_plugins', true, 'dropins')) |
|
127 | 127 | $plugins['dropins'] = get_dropins(); |
128 | 128 | |
129 | - if ( current_user_can( 'update_plugins' ) ) { |
|
130 | - $current = get_site_transient( 'update_plugins' ); |
|
131 | - foreach ( (array) $plugins['all'] as $plugin_file => $plugin_data ) { |
|
132 | - if ( isset( $current->response[ $plugin_file ] ) ) { |
|
133 | - $plugins['all'][ $plugin_file ]['update'] = true; |
|
134 | - $plugins['upgrade'][ $plugin_file ] = $plugins['all'][ $plugin_file ]; |
|
129 | + if (current_user_can('update_plugins')) { |
|
130 | + $current = get_site_transient('update_plugins'); |
|
131 | + foreach ((array) $plugins['all'] as $plugin_file => $plugin_data) { |
|
132 | + if (isset($current->response[$plugin_file])) { |
|
133 | + $plugins['all'][$plugin_file]['update'] = true; |
|
134 | + $plugins['upgrade'][$plugin_file] = $plugins['all'][$plugin_file]; |
|
135 | 135 | } |
136 | 136 | } |
137 | 137 | } |
138 | 138 | } |
139 | 139 | |
140 | - if ( ! $screen->in_admin( 'network' ) ) { |
|
141 | - $show = current_user_can( 'manage_network_plugins' ); |
|
140 | + if ( ! $screen->in_admin('network')) { |
|
141 | + $show = current_user_can('manage_network_plugins'); |
|
142 | 142 | /** |
143 | 143 | * Filters whether to display network-active plugins alongside plugins active for the current site. |
144 | 144 | * |
@@ -152,130 +152,130 @@ discard block |
||
152 | 152 | * @param bool $show Whether to show network-active plugins. Default is whether the current |
153 | 153 | * user can manage network plugins (ie. a Super Admin). |
154 | 154 | */ |
155 | - $show_network_active = apply_filters( 'show_network_active_plugins', $show ); |
|
155 | + $show_network_active = apply_filters('show_network_active_plugins', $show); |
|
156 | 156 | } |
157 | 157 | |
158 | - set_transient( 'plugin_slugs', array_keys( $plugins['all'] ), DAY_IN_SECONDS ); |
|
158 | + set_transient('plugin_slugs', array_keys($plugins['all']), DAY_IN_SECONDS); |
|
159 | 159 | |
160 | - if ( $screen->in_admin( 'network' ) ) { |
|
161 | - $recently_activated = get_site_option( 'recently_activated', array() ); |
|
160 | + if ($screen->in_admin('network')) { |
|
161 | + $recently_activated = get_site_option('recently_activated', array()); |
|
162 | 162 | } else { |
163 | - $recently_activated = get_option( 'recently_activated', array() ); |
|
163 | + $recently_activated = get_option('recently_activated', array()); |
|
164 | 164 | } |
165 | 165 | |
166 | - foreach ( $recently_activated as $key => $time ) { |
|
167 | - if ( $time + WEEK_IN_SECONDS < time() ) { |
|
168 | - unset( $recently_activated[$key] ); |
|
166 | + foreach ($recently_activated as $key => $time) { |
|
167 | + if ($time + WEEK_IN_SECONDS < time()) { |
|
168 | + unset($recently_activated[$key]); |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 | |
172 | - if ( $screen->in_admin( 'network' ) ) { |
|
173 | - update_site_option( 'recently_activated', $recently_activated ); |
|
172 | + if ($screen->in_admin('network')) { |
|
173 | + update_site_option('recently_activated', $recently_activated); |
|
174 | 174 | } else { |
175 | - update_option( 'recently_activated', $recently_activated ); |
|
175 | + update_option('recently_activated', $recently_activated); |
|
176 | 176 | } |
177 | 177 | |
178 | - $plugin_info = get_site_transient( 'update_plugins' ); |
|
178 | + $plugin_info = get_site_transient('update_plugins'); |
|
179 | 179 | |
180 | - foreach ( (array) $plugins['all'] as $plugin_file => $plugin_data ) { |
|
180 | + foreach ((array) $plugins['all'] as $plugin_file => $plugin_data) { |
|
181 | 181 | // Extra info if known. array_merge() ensures $plugin_data has precedence if keys collide. |
182 | - if ( isset( $plugin_info->response[ $plugin_file ] ) ) { |
|
183 | - $plugins['all'][ $plugin_file ] = $plugin_data = array_merge( (array) $plugin_info->response[ $plugin_file ], $plugin_data ); |
|
182 | + if (isset($plugin_info->response[$plugin_file])) { |
|
183 | + $plugins['all'][$plugin_file] = $plugin_data = array_merge((array) $plugin_info->response[$plugin_file], $plugin_data); |
|
184 | 184 | // Make sure that $plugins['upgrade'] also receives the extra info since it is used on ?plugin_status=upgrade |
185 | - if ( isset( $plugins['upgrade'][ $plugin_file ] ) ) { |
|
186 | - $plugins['upgrade'][ $plugin_file ] = $plugin_data = array_merge( (array) $plugin_info->response[ $plugin_file ], $plugin_data ); |
|
185 | + if (isset($plugins['upgrade'][$plugin_file])) { |
|
186 | + $plugins['upgrade'][$plugin_file] = $plugin_data = array_merge((array) $plugin_info->response[$plugin_file], $plugin_data); |
|
187 | 187 | } |
188 | 188 | |
189 | - } elseif ( isset( $plugin_info->no_update[ $plugin_file ] ) ) { |
|
190 | - $plugins['all'][ $plugin_file ] = $plugin_data = array_merge( (array) $plugin_info->no_update[ $plugin_file ], $plugin_data ); |
|
189 | + } elseif (isset($plugin_info->no_update[$plugin_file])) { |
|
190 | + $plugins['all'][$plugin_file] = $plugin_data = array_merge((array) $plugin_info->no_update[$plugin_file], $plugin_data); |
|
191 | 191 | // Make sure that $plugins['upgrade'] also receives the extra info since it is used on ?plugin_status=upgrade |
192 | - if ( isset( $plugins['upgrade'][ $plugin_file ] ) ) { |
|
193 | - $plugins['upgrade'][ $plugin_file ] = $plugin_data = array_merge( (array) $plugin_info->no_update[ $plugin_file ], $plugin_data ); |
|
192 | + if (isset($plugins['upgrade'][$plugin_file])) { |
|
193 | + $plugins['upgrade'][$plugin_file] = $plugin_data = array_merge((array) $plugin_info->no_update[$plugin_file], $plugin_data); |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
197 | 197 | // Filter into individual sections |
198 | - if ( is_multisite() && ! $screen->in_admin( 'network' ) && is_network_only_plugin( $plugin_file ) && ! is_plugin_active( $plugin_file ) ) { |
|
199 | - if ( $show_network_active ) { |
|
198 | + if (is_multisite() && ! $screen->in_admin('network') && is_network_only_plugin($plugin_file) && ! is_plugin_active($plugin_file)) { |
|
199 | + if ($show_network_active) { |
|
200 | 200 | // On the non-network screen, show inactive network-only plugins if allowed |
201 | - $plugins['inactive'][ $plugin_file ] = $plugin_data; |
|
201 | + $plugins['inactive'][$plugin_file] = $plugin_data; |
|
202 | 202 | } else { |
203 | 203 | // On the non-network screen, filter out network-only plugins as long as they're not individually active |
204 | - unset( $plugins['all'][ $plugin_file ] ); |
|
204 | + unset($plugins['all'][$plugin_file]); |
|
205 | 205 | } |
206 | - } elseif ( ! $screen->in_admin( 'network' ) && is_plugin_active_for_network( $plugin_file ) ) { |
|
207 | - if ( $show_network_active ) { |
|
206 | + } elseif ( ! $screen->in_admin('network') && is_plugin_active_for_network($plugin_file)) { |
|
207 | + if ($show_network_active) { |
|
208 | 208 | // On the non-network screen, show network-active plugins if allowed |
209 | - $plugins['active'][ $plugin_file ] = $plugin_data; |
|
209 | + $plugins['active'][$plugin_file] = $plugin_data; |
|
210 | 210 | } else { |
211 | 211 | // On the non-network screen, filter out network-active plugins |
212 | - unset( $plugins['all'][ $plugin_file ] ); |
|
212 | + unset($plugins['all'][$plugin_file]); |
|
213 | 213 | } |
214 | - } elseif ( ( ! $screen->in_admin( 'network' ) && is_plugin_active( $plugin_file ) ) |
|
215 | - || ( $screen->in_admin( 'network' ) && is_plugin_active_for_network( $plugin_file ) ) ) { |
|
214 | + } elseif (( ! $screen->in_admin('network') && is_plugin_active($plugin_file)) |
|
215 | + || ($screen->in_admin('network') && is_plugin_active_for_network($plugin_file))) { |
|
216 | 216 | // On the non-network screen, populate the active list with plugins that are individually activated |
217 | 217 | // On the network-admin screen, populate the active list with plugins that are network activated |
218 | - $plugins['active'][ $plugin_file ] = $plugin_data; |
|
218 | + $plugins['active'][$plugin_file] = $plugin_data; |
|
219 | 219 | } else { |
220 | - if ( isset( $recently_activated[ $plugin_file ] ) ) { |
|
220 | + if (isset($recently_activated[$plugin_file])) { |
|
221 | 221 | // Populate the recently activated list with plugins that have been recently activated |
222 | - $plugins['recently_activated'][ $plugin_file ] = $plugin_data; |
|
222 | + $plugins['recently_activated'][$plugin_file] = $plugin_data; |
|
223 | 223 | } |
224 | 224 | // Populate the inactive list with plugins that aren't activated |
225 | - $plugins['inactive'][ $plugin_file ] = $plugin_data; |
|
225 | + $plugins['inactive'][$plugin_file] = $plugin_data; |
|
226 | 226 | } |
227 | 227 | } |
228 | 228 | |
229 | - if ( strlen( $s ) ) { |
|
229 | + if (strlen($s)) { |
|
230 | 230 | $status = 'search'; |
231 | - $plugins['search'] = array_filter( $plugins['all'], array( $this, '_search_callback' ) ); |
|
231 | + $plugins['search'] = array_filter($plugins['all'], array($this, '_search_callback')); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | $totals = array(); |
235 | - foreach ( $plugins as $type => $list ) |
|
236 | - $totals[ $type ] = count( $list ); |
|
235 | + foreach ($plugins as $type => $list) |
|
236 | + $totals[$type] = count($list); |
|
237 | 237 | |
238 | - if ( empty( $plugins[ $status ] ) && !in_array( $status, array( 'all', 'search' ) ) ) |
|
238 | + if (empty($plugins[$status]) && ! in_array($status, array('all', 'search'))) |
|
239 | 239 | $status = 'all'; |
240 | 240 | |
241 | 241 | $this->items = array(); |
242 | - foreach ( $plugins[ $status ] as $plugin_file => $plugin_data ) { |
|
242 | + foreach ($plugins[$status] as $plugin_file => $plugin_data) { |
|
243 | 243 | // Translate, Don't Apply Markup, Sanitize HTML |
244 | - $this->items[$plugin_file] = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, false, true ); |
|
244 | + $this->items[$plugin_file] = _get_plugin_data_markup_translate($plugin_file, $plugin_data, false, true); |
|
245 | 245 | } |
246 | 246 | |
247 | - $total_this_page = $totals[ $status ]; |
|
247 | + $total_this_page = $totals[$status]; |
|
248 | 248 | |
249 | 249 | $js_plugins = array(); |
250 | - foreach ( $plugins as $key => $list ) { |
|
251 | - $js_plugins[ $key ] = array_keys( (array) $list ); |
|
250 | + foreach ($plugins as $key => $list) { |
|
251 | + $js_plugins[$key] = array_keys((array) $list); |
|
252 | 252 | } |
253 | 253 | |
254 | - wp_localize_script( 'updates', '_wpUpdatesItemCounts', array( |
|
254 | + wp_localize_script('updates', '_wpUpdatesItemCounts', array( |
|
255 | 255 | 'plugins' => $js_plugins, |
256 | - ) ); |
|
256 | + )); |
|
257 | 257 | |
258 | - if ( ! $orderby ) { |
|
258 | + if ( ! $orderby) { |
|
259 | 259 | $orderby = 'Name'; |
260 | 260 | } else { |
261 | - $orderby = ucfirst( $orderby ); |
|
261 | + $orderby = ucfirst($orderby); |
|
262 | 262 | } |
263 | 263 | |
264 | - $order = strtoupper( $order ); |
|
264 | + $order = strtoupper($order); |
|
265 | 265 | |
266 | - uasort( $this->items, array( $this, '_order_callback' ) ); |
|
266 | + uasort($this->items, array($this, '_order_callback')); |
|
267 | 267 | |
268 | - $plugins_per_page = $this->get_items_per_page( str_replace( '-', '_', $screen->id . '_per_page' ), 999 ); |
|
268 | + $plugins_per_page = $this->get_items_per_page(str_replace('-', '_', $screen->id.'_per_page'), 999); |
|
269 | 269 | |
270 | - $start = ( $page - 1 ) * $plugins_per_page; |
|
270 | + $start = ($page - 1) * $plugins_per_page; |
|
271 | 271 | |
272 | - if ( $total_this_page > $plugins_per_page ) |
|
273 | - $this->items = array_slice( $this->items, $start, $plugins_per_page ); |
|
272 | + if ($total_this_page > $plugins_per_page) |
|
273 | + $this->items = array_slice($this->items, $start, $plugins_per_page); |
|
274 | 274 | |
275 | - $this->set_pagination_args( array( |
|
275 | + $this->set_pagination_args(array( |
|
276 | 276 | 'total_items' => $total_this_page, |
277 | 277 | 'per_page' => $plugins_per_page, |
278 | - ) ); |
|
278 | + )); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** |
@@ -284,11 +284,11 @@ discard block |
||
284 | 284 | * @param array $plugin |
285 | 285 | * @return bool |
286 | 286 | */ |
287 | - public function _search_callback( $plugin ) { |
|
287 | + public function _search_callback($plugin) { |
|
288 | 288 | global $s; |
289 | 289 | |
290 | - foreach ( $plugin as $value ) { |
|
291 | - if ( is_string( $value ) && false !== stripos( strip_tags( $value ), urldecode( $s ) ) ) { |
|
290 | + foreach ($plugin as $value) { |
|
291 | + if (is_string($value) && false !== stripos(strip_tags($value), urldecode($s))) { |
|
292 | 292 | return true; |
293 | 293 | } |
294 | 294 | } |
@@ -303,19 +303,19 @@ discard block |
||
303 | 303 | * @param array $plugin_b |
304 | 304 | * @return int |
305 | 305 | */ |
306 | - public function _order_callback( $plugin_a, $plugin_b ) { |
|
306 | + public function _order_callback($plugin_a, $plugin_b) { |
|
307 | 307 | global $orderby, $order; |
308 | 308 | |
309 | 309 | $a = $plugin_a[$orderby]; |
310 | 310 | $b = $plugin_b[$orderby]; |
311 | 311 | |
312 | - if ( $a == $b ) |
|
312 | + if ($a == $b) |
|
313 | 313 | return 0; |
314 | 314 | |
315 | - if ( 'DESC' === $order ) { |
|
316 | - return strcasecmp( $b, $a ); |
|
315 | + if ('DESC' === $order) { |
|
316 | + return strcasecmp($b, $a); |
|
317 | 317 | } else { |
318 | - return strcasecmp( $a, $b ); |
|
318 | + return strcasecmp($a, $b); |
|
319 | 319 | } |
320 | 320 | } |
321 | 321 | |
@@ -326,19 +326,19 @@ discard block |
||
326 | 326 | public function no_items() { |
327 | 327 | global $plugins; |
328 | 328 | |
329 | - if ( ! empty( $_REQUEST['s'] ) ) { |
|
330 | - $s = esc_html( wp_unslash( $_REQUEST['s'] ) ); |
|
329 | + if ( ! empty($_REQUEST['s'])) { |
|
330 | + $s = esc_html(wp_unslash($_REQUEST['s'])); |
|
331 | 331 | |
332 | - printf( __( 'No plugins found for “%s”.' ), $s ); |
|
332 | + printf(__('No plugins found for “%s”.'), $s); |
|
333 | 333 | |
334 | 334 | // We assume that somebody who can install plugins in multisite is experienced enough to not need this helper link. |
335 | - if ( ! is_multisite() && current_user_can( 'install_plugins' ) ) { |
|
336 | - echo ' <a href="' . esc_url( admin_url( 'plugin-install.php?tab=search&s=' . urlencode( $s ) ) ) . '">' . __( 'Search for plugins in the WordPress Plugin Directory.' ) . '</a>'; |
|
335 | + if ( ! is_multisite() && current_user_can('install_plugins')) { |
|
336 | + echo ' <a href="'.esc_url(admin_url('plugin-install.php?tab=search&s='.urlencode($s))).'">'.__('Search for plugins in the WordPress Plugin Directory.').'</a>'; |
|
337 | 337 | } |
338 | - } elseif ( ! empty( $plugins['all'] ) ) |
|
339 | - _e( 'No plugins found.' ); |
|
338 | + } elseif ( ! empty($plugins['all'])) |
|
339 | + _e('No plugins found.'); |
|
340 | 340 | else |
341 | - _e( 'You do not appear to have any plugins available at this time.' ); |
|
341 | + _e('You do not appear to have any plugins available at this time.'); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | /** |
@@ -350,24 +350,24 @@ discard block |
||
350 | 350 | * @param string $text The 'submit' button label. |
351 | 351 | * @param string $input_id ID attribute value for the search input field. |
352 | 352 | */ |
353 | - public function search_box( $text, $input_id ) { |
|
354 | - if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) { |
|
353 | + public function search_box($text, $input_id) { |
|
354 | + if (empty($_REQUEST['s']) && ! $this->has_items()) { |
|
355 | 355 | return; |
356 | 356 | } |
357 | 357 | |
358 | - $input_id = $input_id . '-search-input'; |
|
358 | + $input_id = $input_id.'-search-input'; |
|
359 | 359 | |
360 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
361 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
360 | + if ( ! empty($_REQUEST['orderby'])) { |
|
361 | + echo '<input type="hidden" name="orderby" value="'.esc_attr($_REQUEST['orderby']).'" />'; |
|
362 | 362 | } |
363 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
364 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
363 | + if ( ! empty($_REQUEST['order'])) { |
|
364 | + echo '<input type="hidden" name="order" value="'.esc_attr($_REQUEST['order']).'" />'; |
|
365 | 365 | } |
366 | 366 | ?> |
367 | 367 | <p class="search-box"> |
368 | - <label class="screen-reader-text" for="<?php echo esc_attr( $input_id ); ?>"><?php echo $text; ?>:</label> |
|
369 | - <input type="search" id="<?php echo esc_attr( $input_id ); ?>" class="wp-filter-search" name="s" value="<?php _admin_search_query(); ?>" placeholder="<?php esc_attr_e( 'Search installed plugins...' ); ?>"/> |
|
370 | - <?php submit_button( $text, 'button hide-if-js', '', false, array( 'id' => 'search-submit' ) ); ?> |
|
368 | + <label class="screen-reader-text" for="<?php echo esc_attr($input_id); ?>"><?php echo $text; ?>:</label> |
|
369 | + <input type="search" id="<?php echo esc_attr($input_id); ?>" class="wp-filter-search" name="s" value="<?php _admin_search_query(); ?>" placeholder="<?php esc_attr_e('Search installed plugins...'); ?>"/> |
|
370 | + <?php submit_button($text, 'button hide-if-js', '', false, array('id' => 'search-submit')); ?> |
|
371 | 371 | </p> |
372 | 372 | <?php |
373 | 373 | } |
@@ -381,9 +381,9 @@ discard block |
||
381 | 381 | global $status; |
382 | 382 | |
383 | 383 | return array( |
384 | - 'cb' => !in_array( $status, array( 'mustuse', 'dropins' ) ) ? '<input type="checkbox" />' : '', |
|
385 | - 'name' => __( 'Plugin' ), |
|
386 | - 'description' => __( 'Description' ), |
|
384 | + 'cb' => ! in_array($status, array('mustuse', 'dropins')) ? '<input type="checkbox" />' : '', |
|
385 | + 'name' => __('Plugin'), |
|
386 | + 'description' => __('Description'), |
|
387 | 387 | ); |
388 | 388 | } |
389 | 389 | |
@@ -404,39 +404,39 @@ discard block |
||
404 | 404 | global $totals, $status; |
405 | 405 | |
406 | 406 | $status_links = array(); |
407 | - foreach ( $totals as $type => $count ) { |
|
408 | - if ( !$count ) |
|
407 | + foreach ($totals as $type => $count) { |
|
408 | + if ( ! $count) |
|
409 | 409 | continue; |
410 | 410 | |
411 | - switch ( $type ) { |
|
411 | + switch ($type) { |
|
412 | 412 | case 'all': |
413 | - $text = _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $count, 'plugins' ); |
|
413 | + $text = _nx('All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $count, 'plugins'); |
|
414 | 414 | break; |
415 | 415 | case 'active': |
416 | - $text = _n( 'Active <span class="count">(%s)</span>', 'Active <span class="count">(%s)</span>', $count ); |
|
416 | + $text = _n('Active <span class="count">(%s)</span>', 'Active <span class="count">(%s)</span>', $count); |
|
417 | 417 | break; |
418 | 418 | case 'recently_activated': |
419 | - $text = _n( 'Recently Active <span class="count">(%s)</span>', 'Recently Active <span class="count">(%s)</span>', $count ); |
|
419 | + $text = _n('Recently Active <span class="count">(%s)</span>', 'Recently Active <span class="count">(%s)</span>', $count); |
|
420 | 420 | break; |
421 | 421 | case 'inactive': |
422 | - $text = _n( 'Inactive <span class="count">(%s)</span>', 'Inactive <span class="count">(%s)</span>', $count ); |
|
422 | + $text = _n('Inactive <span class="count">(%s)</span>', 'Inactive <span class="count">(%s)</span>', $count); |
|
423 | 423 | break; |
424 | 424 | case 'mustuse': |
425 | - $text = _n( 'Must-Use <span class="count">(%s)</span>', 'Must-Use <span class="count">(%s)</span>', $count ); |
|
425 | + $text = _n('Must-Use <span class="count">(%s)</span>', 'Must-Use <span class="count">(%s)</span>', $count); |
|
426 | 426 | break; |
427 | 427 | case 'dropins': |
428 | - $text = _n( 'Drop-ins <span class="count">(%s)</span>', 'Drop-ins <span class="count">(%s)</span>', $count ); |
|
428 | + $text = _n('Drop-ins <span class="count">(%s)</span>', 'Drop-ins <span class="count">(%s)</span>', $count); |
|
429 | 429 | break; |
430 | 430 | case 'upgrade': |
431 | - $text = _n( 'Update Available <span class="count">(%s)</span>', 'Update Available <span class="count">(%s)</span>', $count ); |
|
431 | + $text = _n('Update Available <span class="count">(%s)</span>', 'Update Available <span class="count">(%s)</span>', $count); |
|
432 | 432 | break; |
433 | 433 | } |
434 | 434 | |
435 | - if ( 'search' !== $type ) { |
|
436 | - $status_links[$type] = sprintf( "<a href='%s' %s>%s</a>", |
|
435 | + if ('search' !== $type) { |
|
436 | + $status_links[$type] = sprintf("<a href='%s' %s>%s</a>", |
|
437 | 437 | add_query_arg('plugin_status', $type, 'plugins.php'), |
438 | - ( $type === $status ) ? ' class="current"' : '', |
|
439 | - sprintf( $text, number_format_i18n( $count ) ) |
|
438 | + ($type === $status) ? ' class="current"' : '', |
|
439 | + sprintf($text, number_format_i18n($count)) |
|
440 | 440 | ); |
441 | 441 | } |
442 | 442 | } |
@@ -454,17 +454,17 @@ discard block |
||
454 | 454 | |
455 | 455 | $actions = array(); |
456 | 456 | |
457 | - if ( 'active' != $status ) |
|
458 | - $actions['activate-selected'] = $this->screen->in_admin( 'network' ) ? __( 'Network Activate' ) : __( 'Activate' ); |
|
457 | + if ('active' != $status) |
|
458 | + $actions['activate-selected'] = $this->screen->in_admin('network') ? __('Network Activate') : __('Activate'); |
|
459 | 459 | |
460 | - if ( 'inactive' != $status && 'recent' != $status ) |
|
461 | - $actions['deactivate-selected'] = $this->screen->in_admin( 'network' ) ? __( 'Network Deactivate' ) : __( 'Deactivate' ); |
|
460 | + if ('inactive' != $status && 'recent' != $status) |
|
461 | + $actions['deactivate-selected'] = $this->screen->in_admin('network') ? __('Network Deactivate') : __('Deactivate'); |
|
462 | 462 | |
463 | - if ( !is_multisite() || $this->screen->in_admin( 'network' ) ) { |
|
464 | - if ( current_user_can( 'update_plugins' ) ) |
|
465 | - $actions['update-selected'] = __( 'Update' ); |
|
466 | - if ( current_user_can( 'delete_plugins' ) && ( 'active' != $status ) ) |
|
467 | - $actions['delete-selected'] = __( 'Delete' ); |
|
463 | + if ( ! is_multisite() || $this->screen->in_admin('network')) { |
|
464 | + if (current_user_can('update_plugins')) |
|
465 | + $actions['update-selected'] = __('Update'); |
|
466 | + if (current_user_can('delete_plugins') && ('active' != $status)) |
|
467 | + $actions['delete-selected'] = __('Delete'); |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | return $actions; |
@@ -474,39 +474,39 @@ discard block |
||
474 | 474 | * @global string $status |
475 | 475 | * @param string $which |
476 | 476 | */ |
477 | - public function bulk_actions( $which = '' ) { |
|
477 | + public function bulk_actions($which = '') { |
|
478 | 478 | global $status; |
479 | 479 | |
480 | - if ( in_array( $status, array( 'mustuse', 'dropins' ) ) ) |
|
480 | + if (in_array($status, array('mustuse', 'dropins'))) |
|
481 | 481 | return; |
482 | 482 | |
483 | - parent::bulk_actions( $which ); |
|
483 | + parent::bulk_actions($which); |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | /** |
487 | 487 | * @global string $status |
488 | 488 | * @param string $which |
489 | 489 | */ |
490 | - protected function extra_tablenav( $which ) { |
|
490 | + protected function extra_tablenav($which) { |
|
491 | 491 | global $status; |
492 | 492 | |
493 | - if ( ! in_array($status, array('recently_activated', 'mustuse', 'dropins') ) ) |
|
493 | + if ( ! in_array($status, array('recently_activated', 'mustuse', 'dropins'))) |
|
494 | 494 | return; |
495 | 495 | |
496 | 496 | echo '<div class="alignleft actions">'; |
497 | 497 | |
498 | - if ( 'recently_activated' == $status ) { |
|
499 | - submit_button( __( 'Clear List' ), 'button', 'clear-recent-list', false ); |
|
500 | - } elseif ( 'top' === $which && 'mustuse' === $status ) { |
|
498 | + if ('recently_activated' == $status) { |
|
499 | + submit_button(__('Clear List'), 'button', 'clear-recent-list', false); |
|
500 | + } elseif ('top' === $which && 'mustuse' === $status) { |
|
501 | 501 | /* translators: %s: mu-plugins directory name */ |
502 | - echo '<p>' . sprintf( __( 'Files in the %s directory are executed automatically.' ), |
|
503 | - '<code>' . str_replace( ABSPATH, '/', WPMU_PLUGIN_DIR ) . '</code>' |
|
504 | - ) . '</p>'; |
|
505 | - } elseif ( 'top' === $which && 'dropins' === $status ) { |
|
502 | + echo '<p>'.sprintf(__('Files in the %s directory are executed automatically.'), |
|
503 | + '<code>'.str_replace(ABSPATH, '/', WPMU_PLUGIN_DIR).'</code>' |
|
504 | + ).'</p>'; |
|
505 | + } elseif ('top' === $which && 'dropins' === $status) { |
|
506 | 506 | /* translators: %s: wp-content directory name */ |
507 | - echo '<p>' . sprintf( __( 'Drop-ins are advanced plugins in the %s directory that replace WordPress functionality when present.' ), |
|
508 | - '<code>' . str_replace( ABSPATH, '', WP_CONTENT_DIR ) . '</code>' |
|
509 | - ) . '</p>'; |
|
507 | + echo '<p>'.sprintf(__('Drop-ins are advanced plugins in the %s directory that replace WordPress functionality when present.'), |
|
508 | + '<code>'.str_replace(ABSPATH, '', WP_CONTENT_DIR).'</code>' |
|
509 | + ).'</p>'; |
|
510 | 510 | } |
511 | 511 | echo '</div>'; |
512 | 512 | } |
@@ -515,7 +515,7 @@ discard block |
||
515 | 515 | * @return string |
516 | 516 | */ |
517 | 517 | public function current_action() { |
518 | - if ( isset($_POST['clear-recent-list']) ) |
|
518 | + if (isset($_POST['clear-recent-list'])) |
|
519 | 519 | return 'clear-recent-list'; |
520 | 520 | |
521 | 521 | return parent::current_action(); |
@@ -528,11 +528,11 @@ discard block |
||
528 | 528 | public function display_rows() { |
529 | 529 | global $status; |
530 | 530 | |
531 | - if ( is_multisite() && ! $this->screen->in_admin( 'network' ) && in_array( $status, array( 'mustuse', 'dropins' ) ) ) |
|
531 | + if (is_multisite() && ! $this->screen->in_admin('network') && in_array($status, array('mustuse', 'dropins'))) |
|
532 | 532 | return; |
533 | 533 | |
534 | - foreach ( $this->items as $plugin_file => $plugin_data ) |
|
535 | - $this->single_row( array( $plugin_file, $plugin_data ) ); |
|
534 | + foreach ($this->items as $plugin_file => $plugin_data) |
|
535 | + $this->single_row(array($plugin_file, $plugin_data)); |
|
536 | 536 | } |
537 | 537 | |
538 | 538 | /** |
@@ -543,10 +543,10 @@ discard block |
||
543 | 543 | * |
544 | 544 | * @param array $item |
545 | 545 | */ |
546 | - public function single_row( $item ) { |
|
546 | + public function single_row($item) { |
|
547 | 547 | global $status, $page, $s, $totals; |
548 | 548 | |
549 | - list( $plugin_file, $plugin_data ) = $item; |
|
549 | + list($plugin_file, $plugin_data) = $item; |
|
550 | 550 | $context = $status; |
551 | 551 | $screen = $this->screen; |
552 | 552 | |
@@ -563,88 +563,88 @@ discard block |
||
563 | 563 | $restrict_network_active = false; |
564 | 564 | $restrict_network_only = false; |
565 | 565 | |
566 | - if ( 'mustuse' === $context ) { |
|
566 | + if ('mustuse' === $context) { |
|
567 | 567 | $is_active = true; |
568 | - } elseif ( 'dropins' === $context ) { |
|
568 | + } elseif ('dropins' === $context) { |
|
569 | 569 | $dropins = _get_dropins(); |
570 | 570 | $plugin_name = $plugin_file; |
571 | - if ( $plugin_file != $plugin_data['Name'] ) |
|
572 | - $plugin_name .= '<br/>' . $plugin_data['Name']; |
|
573 | - if ( true === ( $dropins[ $plugin_file ][1] ) ) { // Doesn't require a constant |
|
571 | + if ($plugin_file != $plugin_data['Name']) |
|
572 | + $plugin_name .= '<br/>'.$plugin_data['Name']; |
|
573 | + if (true === ($dropins[$plugin_file][1])) { // Doesn't require a constant |
|
574 | 574 | $is_active = true; |
575 | - $description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>'; |
|
576 | - } elseif ( defined( $dropins[ $plugin_file ][1] ) && constant( $dropins[ $plugin_file ][1] ) ) { // Constant is true |
|
575 | + $description = '<p><strong>'.$dropins[$plugin_file][0].'</strong></p>'; |
|
576 | + } elseif (defined($dropins[$plugin_file][1]) && constant($dropins[$plugin_file][1])) { // Constant is true |
|
577 | 577 | $is_active = true; |
578 | - $description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>'; |
|
578 | + $description = '<p><strong>'.$dropins[$plugin_file][0].'</strong></p>'; |
|
579 | 579 | } else { |
580 | 580 | $is_active = false; |
581 | - $description = '<p><strong>' . $dropins[ $plugin_file ][0] . ' <span class="error-message">' . __( 'Inactive:' ) . '</span></strong> ' . |
|
581 | + $description = '<p><strong>'.$dropins[$plugin_file][0].' <span class="error-message">'.__('Inactive:').'</span></strong> '. |
|
582 | 582 | /* translators: 1: drop-in constant name, 2: wp-config.php */ |
583 | - sprintf( __( 'Requires %1$s in %2$s file.' ), |
|
584 | - "<code>define('" . $dropins[ $plugin_file ][1] . "', true);</code>", |
|
583 | + sprintf(__('Requires %1$s in %2$s file.'), |
|
584 | + "<code>define('".$dropins[$plugin_file][1]."', true);</code>", |
|
585 | 585 | '<code>wp-config.php</code>' |
586 | - ) . '</p>'; |
|
586 | + ).'</p>'; |
|
587 | 587 | } |
588 | - if ( $plugin_data['Description'] ) |
|
589 | - $description .= '<p>' . $plugin_data['Description'] . '</p>'; |
|
588 | + if ($plugin_data['Description']) |
|
589 | + $description .= '<p>'.$plugin_data['Description'].'</p>'; |
|
590 | 590 | } else { |
591 | - if ( $screen->in_admin( 'network' ) ) { |
|
592 | - $is_active = is_plugin_active_for_network( $plugin_file ); |
|
591 | + if ($screen->in_admin('network')) { |
|
592 | + $is_active = is_plugin_active_for_network($plugin_file); |
|
593 | 593 | } else { |
594 | - $is_active = is_plugin_active( $plugin_file ); |
|
595 | - $restrict_network_active = ( is_multisite() && is_plugin_active_for_network( $plugin_file ) ); |
|
596 | - $restrict_network_only = ( is_multisite() && is_network_only_plugin( $plugin_file ) && ! $is_active ); |
|
594 | + $is_active = is_plugin_active($plugin_file); |
|
595 | + $restrict_network_active = (is_multisite() && is_plugin_active_for_network($plugin_file)); |
|
596 | + $restrict_network_only = (is_multisite() && is_network_only_plugin($plugin_file) && ! $is_active); |
|
597 | 597 | } |
598 | 598 | |
599 | - if ( $screen->in_admin( 'network' ) ) { |
|
600 | - if ( $is_active ) { |
|
601 | - if ( current_user_can( 'manage_network_plugins' ) ) { |
|
599 | + if ($screen->in_admin('network')) { |
|
600 | + if ($is_active) { |
|
601 | + if (current_user_can('manage_network_plugins')) { |
|
602 | 602 | /* translators: %s: plugin name */ |
603 | - $actions['deactivate'] = '<a href="' . wp_nonce_url( 'plugins.php?action=deactivate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'deactivate-plugin_' . $plugin_file ) . '" aria-label="' . esc_attr( sprintf( _x( 'Network Deactivate %s', 'plugin' ), $plugin_data['Name'] ) ) . '">' . __( 'Network Deactivate' ) . '</a>'; |
|
603 | + $actions['deactivate'] = '<a href="'.wp_nonce_url('plugins.php?action=deactivate&plugin='.$plugin_file.'&plugin_status='.$context.'&paged='.$page.'&s='.$s, 'deactivate-plugin_'.$plugin_file).'" aria-label="'.esc_attr(sprintf(_x('Network Deactivate %s', 'plugin'), $plugin_data['Name'])).'">'.__('Network Deactivate').'</a>'; |
|
604 | 604 | } |
605 | 605 | } else { |
606 | - if ( current_user_can( 'manage_network_plugins' ) ) { |
|
606 | + if (current_user_can('manage_network_plugins')) { |
|
607 | 607 | /* translators: %s: plugin name */ |
608 | - $actions['activate'] = '<a href="' . wp_nonce_url( 'plugins.php?action=activate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'activate-plugin_' . $plugin_file ) . '" class="edit" aria-label="' . esc_attr( sprintf( _x( 'Network Activate %s', 'plugin' ), $plugin_data['Name'] ) ) . '">' . __( 'Network Activate' ) . '</a>'; |
|
608 | + $actions['activate'] = '<a href="'.wp_nonce_url('plugins.php?action=activate&plugin='.$plugin_file.'&plugin_status='.$context.'&paged='.$page.'&s='.$s, 'activate-plugin_'.$plugin_file).'" class="edit" aria-label="'.esc_attr(sprintf(_x('Network Activate %s', 'plugin'), $plugin_data['Name'])).'">'.__('Network Activate').'</a>'; |
|
609 | 609 | } |
610 | - if ( current_user_can( 'delete_plugins' ) && ! is_plugin_active( $plugin_file ) ) { |
|
610 | + if (current_user_can('delete_plugins') && ! is_plugin_active($plugin_file)) { |
|
611 | 611 | /* translators: %s: plugin name */ |
612 | - $actions['delete'] = '<a href="' . wp_nonce_url( 'plugins.php?action=delete-selected&checked[]=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'bulk-plugins' ) . '" class="delete" aria-label="' . esc_attr( sprintf( _x( 'Delete %s', 'plugin' ), $plugin_data['Name'] ) ) . '">' . __( 'Delete' ) . '</a>'; |
|
612 | + $actions['delete'] = '<a href="'.wp_nonce_url('plugins.php?action=delete-selected&checked[]='.$plugin_file.'&plugin_status='.$context.'&paged='.$page.'&s='.$s, 'bulk-plugins').'" class="delete" aria-label="'.esc_attr(sprintf(_x('Delete %s', 'plugin'), $plugin_data['Name'])).'">'.__('Delete').'</a>'; |
|
613 | 613 | } |
614 | 614 | } |
615 | 615 | } else { |
616 | - if ( $restrict_network_active ) { |
|
616 | + if ($restrict_network_active) { |
|
617 | 617 | $actions = array( |
618 | - 'network_active' => __( 'Network Active' ), |
|
618 | + 'network_active' => __('Network Active'), |
|
619 | 619 | ); |
620 | - } elseif ( $restrict_network_only ) { |
|
620 | + } elseif ($restrict_network_only) { |
|
621 | 621 | $actions = array( |
622 | - 'network_only' => __( 'Network Only' ), |
|
622 | + 'network_only' => __('Network Only'), |
|
623 | 623 | ); |
624 | - } elseif ( $is_active ) { |
|
624 | + } elseif ($is_active) { |
|
625 | 625 | /* translators: %s: plugin name */ |
626 | - $actions['deactivate'] = '<a href="' . wp_nonce_url( 'plugins.php?action=deactivate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'deactivate-plugin_' . $plugin_file ) . '" aria-label="' . esc_attr( sprintf( _x( 'Deactivate %s', 'plugin' ), $plugin_data['Name'] ) ) . '">' . __( 'Deactivate' ) . '</a>'; |
|
626 | + $actions['deactivate'] = '<a href="'.wp_nonce_url('plugins.php?action=deactivate&plugin='.$plugin_file.'&plugin_status='.$context.'&paged='.$page.'&s='.$s, 'deactivate-plugin_'.$plugin_file).'" aria-label="'.esc_attr(sprintf(_x('Deactivate %s', 'plugin'), $plugin_data['Name'])).'">'.__('Deactivate').'</a>'; |
|
627 | 627 | } else { |
628 | 628 | /* translators: %s: plugin name */ |
629 | - $actions['activate'] = '<a href="' . wp_nonce_url( 'plugins.php?action=activate&plugin=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'activate-plugin_' . $plugin_file ) . '" class="edit" aria-label="' . esc_attr( sprintf( _x( 'Activate %s', 'plugin' ), $plugin_data['Name'] ) ) . '">' . __( 'Activate' ) . '</a>'; |
|
629 | + $actions['activate'] = '<a href="'.wp_nonce_url('plugins.php?action=activate&plugin='.$plugin_file.'&plugin_status='.$context.'&paged='.$page.'&s='.$s, 'activate-plugin_'.$plugin_file).'" class="edit" aria-label="'.esc_attr(sprintf(_x('Activate %s', 'plugin'), $plugin_data['Name'])).'">'.__('Activate').'</a>'; |
|
630 | 630 | |
631 | - if ( ! is_multisite() && current_user_can( 'delete_plugins' ) ) { |
|
631 | + if ( ! is_multisite() && current_user_can('delete_plugins')) { |
|
632 | 632 | /* translators: %s: plugin name */ |
633 | - $actions['delete'] = '<a href="' . wp_nonce_url( 'plugins.php?action=delete-selected&checked[]=' . $plugin_file . '&plugin_status=' . $context . '&paged=' . $page . '&s=' . $s, 'bulk-plugins' ) . '" class="delete" aria-label="' . esc_attr( sprintf( _x( 'Delete %s', 'plugin' ), $plugin_data['Name'] ) ) . '">' . __( 'Delete' ) . '</a>'; |
|
633 | + $actions['delete'] = '<a href="'.wp_nonce_url('plugins.php?action=delete-selected&checked[]='.$plugin_file.'&plugin_status='.$context.'&paged='.$page.'&s='.$s, 'bulk-plugins').'" class="delete" aria-label="'.esc_attr(sprintf(_x('Delete %s', 'plugin'), $plugin_data['Name'])).'">'.__('Delete').'</a>'; |
|
634 | 634 | } |
635 | 635 | } // end if $is_active |
636 | 636 | |
637 | 637 | } // end if $screen->in_admin( 'network' ) |
638 | 638 | |
639 | - if ( ( ! is_multisite() || $screen->in_admin( 'network' ) ) && current_user_can( 'edit_plugins' ) && is_writable( WP_PLUGIN_DIR . '/' . $plugin_file ) ) { |
|
639 | + if (( ! is_multisite() || $screen->in_admin('network')) && current_user_can('edit_plugins') && is_writable(WP_PLUGIN_DIR.'/'.$plugin_file)) { |
|
640 | 640 | /* translators: %s: plugin name */ |
641 | - $actions['edit'] = '<a href="plugin-editor.php?file=' . $plugin_file . '" class="edit" aria-label="' . esc_attr( sprintf( __( 'Edit %s' ), $plugin_data['Name'] ) ) . '">' . __( 'Edit' ) . '</a>'; |
|
641 | + $actions['edit'] = '<a href="plugin-editor.php?file='.$plugin_file.'" class="edit" aria-label="'.esc_attr(sprintf(__('Edit %s'), $plugin_data['Name'])).'">'.__('Edit').'</a>'; |
|
642 | 642 | } |
643 | 643 | } // end if $context |
644 | 644 | |
645 | - $actions = array_filter( $actions ); |
|
645 | + $actions = array_filter($actions); |
|
646 | 646 | |
647 | - if ( $screen->in_admin( 'network' ) ) { |
|
647 | + if ($screen->in_admin('network')) { |
|
648 | 648 | |
649 | 649 | /** |
650 | 650 | * Filters the action links displayed for each plugin in the Network Admin Plugins list table. |
@@ -662,7 +662,7 @@ discard block |
||
662 | 662 | * 'Inactive', 'Recently Activated', 'Upgrade', |
663 | 663 | * 'Must-Use', 'Drop-ins', 'Search'. |
664 | 664 | */ |
665 | - $actions = apply_filters( 'network_admin_plugin_action_links', $actions, $plugin_file, $plugin_data, $context ); |
|
665 | + $actions = apply_filters('network_admin_plugin_action_links', $actions, $plugin_file, $plugin_data, $context); |
|
666 | 666 | |
667 | 667 | /** |
668 | 668 | * Filters the list of action links displayed for a specific plugin in the Network Admin Plugins list table. |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | * 'Inactive', 'Recently Activated', 'Upgrade', |
681 | 681 | * 'Must-Use', 'Drop-ins', 'Search'. |
682 | 682 | */ |
683 | - $actions = apply_filters( "network_admin_plugin_action_links_{$plugin_file}", $actions, $plugin_file, $plugin_data, $context ); |
|
683 | + $actions = apply_filters("network_admin_plugin_action_links_{$plugin_file}", $actions, $plugin_file, $plugin_data, $context); |
|
684 | 684 | |
685 | 685 | } else { |
686 | 686 | |
@@ -701,7 +701,7 @@ discard block |
||
701 | 701 | * 'Inactive', 'Recently Activated', 'Upgrade', |
702 | 702 | * 'Must-Use', 'Drop-ins', 'Search'. |
703 | 703 | */ |
704 | - $actions = apply_filters( 'plugin_action_links', $actions, $plugin_file, $plugin_data, $context ); |
|
704 | + $actions = apply_filters('plugin_action_links', $actions, $plugin_file, $plugin_data, $context); |
|
705 | 705 | |
706 | 706 | /** |
707 | 707 | * Filters the list of action links displayed for a specific plugin in the Plugins list table. |
@@ -719,48 +719,48 @@ discard block |
||
719 | 719 | * 'Inactive', 'Recently Activated', 'Upgrade', |
720 | 720 | * 'Must-Use', 'Drop-ins', 'Search'. |
721 | 721 | */ |
722 | - $actions = apply_filters( "plugin_action_links_{$plugin_file}", $actions, $plugin_file, $plugin_data, $context ); |
|
722 | + $actions = apply_filters("plugin_action_links_{$plugin_file}", $actions, $plugin_file, $plugin_data, $context); |
|
723 | 723 | |
724 | 724 | } |
725 | 725 | |
726 | 726 | $class = $is_active ? 'active' : 'inactive'; |
727 | - $checkbox_id = "checkbox_" . md5($plugin_data['Name']); |
|
728 | - if ( $restrict_network_active || $restrict_network_only || in_array( $status, array( 'mustuse', 'dropins' ) ) ) { |
|
727 | + $checkbox_id = "checkbox_".md5($plugin_data['Name']); |
|
728 | + if ($restrict_network_active || $restrict_network_only || in_array($status, array('mustuse', 'dropins'))) { |
|
729 | 729 | $checkbox = ''; |
730 | 730 | } else { |
731 | - $checkbox = "<label class='screen-reader-text' for='" . $checkbox_id . "' >" . sprintf( __( 'Select %s' ), $plugin_data['Name'] ) . "</label>" |
|
732 | - . "<input type='checkbox' name='checked[]' value='" . esc_attr( $plugin_file ) . "' id='" . $checkbox_id . "' />"; |
|
731 | + $checkbox = "<label class='screen-reader-text' for='".$checkbox_id."' >".sprintf(__('Select %s'), $plugin_data['Name'])."</label>" |
|
732 | + . "<input type='checkbox' name='checked[]' value='".esc_attr($plugin_file)."' id='".$checkbox_id."' />"; |
|
733 | 733 | } |
734 | - if ( 'dropins' != $context ) { |
|
735 | - $description = '<p>' . ( $plugin_data['Description'] ? $plugin_data['Description'] : ' ' ) . '</p>'; |
|
734 | + if ('dropins' != $context) { |
|
735 | + $description = '<p>'.($plugin_data['Description'] ? $plugin_data['Description'] : ' ').'</p>'; |
|
736 | 736 | $plugin_name = $plugin_data['Name']; |
737 | 737 | } |
738 | 738 | |
739 | - if ( ! empty( $totals['upgrade'] ) && ! empty( $plugin_data['update'] ) ) |
|
739 | + if ( ! empty($totals['upgrade']) && ! empty($plugin_data['update'])) |
|
740 | 740 | $class .= ' update'; |
741 | 741 | |
742 | - $plugin_slug = isset( $plugin_data['slug'] ) ? $plugin_data['slug'] : sanitize_title( $plugin_name ); |
|
743 | - printf( '<tr class="%s" data-slug="%s" data-plugin="%s">', |
|
744 | - esc_attr( $class ), |
|
745 | - esc_attr( $plugin_slug ), |
|
746 | - esc_attr( $plugin_file ) |
|
742 | + $plugin_slug = isset($plugin_data['slug']) ? $plugin_data['slug'] : sanitize_title($plugin_name); |
|
743 | + printf('<tr class="%s" data-slug="%s" data-plugin="%s">', |
|
744 | + esc_attr($class), |
|
745 | + esc_attr($plugin_slug), |
|
746 | + esc_attr($plugin_file) |
|
747 | 747 | ); |
748 | 748 | |
749 | - list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); |
|
749 | + list($columns, $hidden, $sortable, $primary) = $this->get_column_info(); |
|
750 | 750 | |
751 | - foreach ( $columns as $column_name => $column_display_name ) { |
|
751 | + foreach ($columns as $column_name => $column_display_name) { |
|
752 | 752 | $extra_classes = ''; |
753 | - if ( in_array( $column_name, $hidden ) ) { |
|
753 | + if (in_array($column_name, $hidden)) { |
|
754 | 754 | $extra_classes = ' hidden'; |
755 | 755 | } |
756 | 756 | |
757 | - switch ( $column_name ) { |
|
757 | + switch ($column_name) { |
|
758 | 758 | case 'cb': |
759 | 759 | echo "<th scope='row' class='check-column'>$checkbox</th>"; |
760 | 760 | break; |
761 | 761 | case 'name': |
762 | 762 | echo "<td class='plugin-title column-primary'><strong>$plugin_name</strong>"; |
763 | - echo $this->row_actions( $actions, true ); |
|
763 | + echo $this->row_actions($actions, true); |
|
764 | 764 | echo "</td>"; |
765 | 765 | break; |
766 | 766 | case 'description': |
@@ -771,28 +771,28 @@ discard block |
||
771 | 771 | <div class='$class second plugin-version-author-uri'>"; |
772 | 772 | |
773 | 773 | $plugin_meta = array(); |
774 | - if ( !empty( $plugin_data['Version'] ) ) |
|
775 | - $plugin_meta[] = sprintf( __( 'Version %s' ), $plugin_data['Version'] ); |
|
776 | - if ( !empty( $plugin_data['Author'] ) ) { |
|
774 | + if ( ! empty($plugin_data['Version'])) |
|
775 | + $plugin_meta[] = sprintf(__('Version %s'), $plugin_data['Version']); |
|
776 | + if ( ! empty($plugin_data['Author'])) { |
|
777 | 777 | $author = $plugin_data['Author']; |
778 | - if ( !empty( $plugin_data['AuthorURI'] ) ) |
|
779 | - $author = '<a href="' . $plugin_data['AuthorURI'] . '">' . $plugin_data['Author'] . '</a>'; |
|
780 | - $plugin_meta[] = sprintf( __( 'By %s' ), $author ); |
|
778 | + if ( ! empty($plugin_data['AuthorURI'])) |
|
779 | + $author = '<a href="'.$plugin_data['AuthorURI'].'">'.$plugin_data['Author'].'</a>'; |
|
780 | + $plugin_meta[] = sprintf(__('By %s'), $author); |
|
781 | 781 | } |
782 | 782 | |
783 | 783 | // Details link using API info, if available |
784 | - if ( isset( $plugin_data['slug'] ) && current_user_can( 'install_plugins' ) ) { |
|
785 | - $plugin_meta[] = sprintf( '<a href="%s" class="thickbox open-plugin-details-modal" aria-label="%s" data-title="%s">%s</a>', |
|
786 | - esc_url( network_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin_data['slug'] . |
|
787 | - '&TB_iframe=true&width=600&height=550' ) ), |
|
788 | - esc_attr( sprintf( __( 'More information about %s' ), $plugin_name ) ), |
|
789 | - esc_attr( $plugin_name ), |
|
790 | - __( 'View details' ) |
|
784 | + if (isset($plugin_data['slug']) && current_user_can('install_plugins')) { |
|
785 | + $plugin_meta[] = sprintf('<a href="%s" class="thickbox open-plugin-details-modal" aria-label="%s" data-title="%s">%s</a>', |
|
786 | + esc_url(network_admin_url('plugin-install.php?tab=plugin-information&plugin='.$plugin_data['slug']. |
|
787 | + '&TB_iframe=true&width=600&height=550')), |
|
788 | + esc_attr(sprintf(__('More information about %s'), $plugin_name)), |
|
789 | + esc_attr($plugin_name), |
|
790 | + __('View details') |
|
791 | 791 | ); |
792 | - } elseif ( ! empty( $plugin_data['PluginURI'] ) ) { |
|
793 | - $plugin_meta[] = sprintf( '<a href="%s">%s</a>', |
|
794 | - esc_url( $plugin_data['PluginURI'] ), |
|
795 | - __( 'Visit plugin site' ) |
|
792 | + } elseif ( ! empty($plugin_data['PluginURI'])) { |
|
793 | + $plugin_meta[] = sprintf('<a href="%s">%s</a>', |
|
794 | + esc_url($plugin_data['PluginURI']), |
|
795 | + __('Visit plugin site') |
|
796 | 796 | ); |
797 | 797 | } |
798 | 798 | |
@@ -810,8 +810,8 @@ discard block |
||
810 | 810 | * 'Inactive', 'Recently Activated', 'Upgrade', 'Must-Use', |
811 | 811 | * 'Drop-ins', 'Search'. |
812 | 812 | */ |
813 | - $plugin_meta = apply_filters( 'plugin_row_meta', $plugin_meta, $plugin_file, $plugin_data, $status ); |
|
814 | - echo implode( ' | ', $plugin_meta ); |
|
813 | + $plugin_meta = apply_filters('plugin_row_meta', $plugin_meta, $plugin_file, $plugin_data, $status); |
|
814 | + echo implode(' | ', $plugin_meta); |
|
815 | 815 | |
816 | 816 | echo "</div></td>"; |
817 | 817 | break; |
@@ -829,7 +829,7 @@ discard block |
||
829 | 829 | * @param string $plugin_file Path to the plugin file. |
830 | 830 | * @param array $plugin_data An array of plugin data. |
831 | 831 | */ |
832 | - do_action( 'manage_plugins_custom_column', $column_name, $plugin_file, $plugin_data ); |
|
832 | + do_action('manage_plugins_custom_column', $column_name, $plugin_file, $plugin_data); |
|
833 | 833 | |
834 | 834 | echo "</td>"; |
835 | 835 | } |
@@ -848,7 +848,7 @@ discard block |
||
848 | 848 | * 'Inactive', 'Recently Activated', 'Upgrade', 'Must-Use', |
849 | 849 | * 'Drop-ins', 'Search'. |
850 | 850 | */ |
851 | - do_action( 'after_plugin_row', $plugin_file, $plugin_data, $status ); |
|
851 | + do_action('after_plugin_row', $plugin_file, $plugin_data, $status); |
|
852 | 852 | |
853 | 853 | /** |
854 | 854 | * Fires after each specific row in the Plugins list table. |
@@ -864,7 +864,7 @@ discard block |
||
864 | 864 | * 'Inactive', 'Recently Activated', 'Upgrade', 'Must-Use', |
865 | 865 | * 'Drop-ins', 'Search'. |
866 | 866 | */ |
867 | - do_action( "after_plugin_row_$plugin_file", $plugin_file, $plugin_data, $status ); |
|
867 | + do_action("after_plugin_row_$plugin_file", $plugin_file, $plugin_data, $status); |
|
868 | 868 | } |
869 | 869 | |
870 | 870 | /** |
@@ -25,28 +25,28 @@ discard block |
||
25 | 25 | * @param int $link_id Optional. ID of the link to edit. Default 0. |
26 | 26 | * @return int|WP_Error Value 0 or WP_Error on failure. The link ID on success. |
27 | 27 | */ |
28 | -function edit_link( $link_id = 0 ) { |
|
29 | - if ( ! current_user_can( 'manage_links' ) ) { |
|
28 | +function edit_link($link_id = 0) { |
|
29 | + if ( ! current_user_can('manage_links')) { |
|
30 | 30 | wp_die( |
31 | - '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' . |
|
32 | - '<p>' . __( 'Sorry, you are not allowed to edit the links for this site.' ) . '</p>', |
|
31 | + '<h1>'.__('Cheatin’ uh?').'</h1>'. |
|
32 | + '<p>'.__('Sorry, you are not allowed to edit the links for this site.').'</p>', |
|
33 | 33 | 403 |
34 | 34 | ); |
35 | 35 | } |
36 | 36 | |
37 | - $_POST['link_url'] = esc_html( $_POST['link_url'] ); |
|
37 | + $_POST['link_url'] = esc_html($_POST['link_url']); |
|
38 | 38 | $_POST['link_url'] = esc_url($_POST['link_url']); |
39 | - $_POST['link_name'] = esc_html( $_POST['link_name'] ); |
|
40 | - $_POST['link_image'] = esc_html( $_POST['link_image'] ); |
|
39 | + $_POST['link_name'] = esc_html($_POST['link_name']); |
|
40 | + $_POST['link_image'] = esc_html($_POST['link_image']); |
|
41 | 41 | $_POST['link_rss'] = esc_url($_POST['link_rss']); |
42 | - if ( !isset($_POST['link_visible']) || 'N' != $_POST['link_visible'] ) |
|
42 | + if ( ! isset($_POST['link_visible']) || 'N' != $_POST['link_visible']) |
|
43 | 43 | $_POST['link_visible'] = 'Y'; |
44 | 44 | |
45 | - if ( !empty( $link_id ) ) { |
|
45 | + if ( ! empty($link_id)) { |
|
46 | 46 | $_POST['link_id'] = $link_id; |
47 | - return wp_update_link( $_POST ); |
|
47 | + return wp_update_link($_POST); |
|
48 | 48 | } else { |
49 | - return wp_insert_link( $_POST ); |
|
49 | + return wp_insert_link($_POST); |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
@@ -59,13 +59,13 @@ discard block |
||
59 | 59 | */ |
60 | 60 | function get_default_link_to_edit() { |
61 | 61 | $link = new stdClass; |
62 | - if ( isset( $_GET['linkurl'] ) ) |
|
63 | - $link->link_url = esc_url( wp_unslash( $_GET['linkurl'] ) ); |
|
62 | + if (isset($_GET['linkurl'])) |
|
63 | + $link->link_url = esc_url(wp_unslash($_GET['linkurl'])); |
|
64 | 64 | else |
65 | 65 | $link->link_url = ''; |
66 | 66 | |
67 | - if ( isset( $_GET['name'] ) ) |
|
68 | - $link->link_name = esc_attr( wp_unslash( $_GET['name'] ) ); |
|
67 | + if (isset($_GET['name'])) |
|
68 | + $link->link_name = esc_attr(wp_unslash($_GET['name'])); |
|
69 | 69 | else |
70 | 70 | $link->link_name = ''; |
71 | 71 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @param int $link_id ID of the link to delete |
85 | 85 | * @return true Always true. |
86 | 86 | */ |
87 | -function wp_delete_link( $link_id ) { |
|
87 | +function wp_delete_link($link_id) { |
|
88 | 88 | global $wpdb; |
89 | 89 | /** |
90 | 90 | * Fires before a link is deleted. |
@@ -93,11 +93,11 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @param int $link_id ID of the link to delete. |
95 | 95 | */ |
96 | - do_action( 'delete_link', $link_id ); |
|
96 | + do_action('delete_link', $link_id); |
|
97 | 97 | |
98 | - wp_delete_object_term_relationships( $link_id, 'link_category' ); |
|
98 | + wp_delete_object_term_relationships($link_id, 'link_category'); |
|
99 | 99 | |
100 | - $wpdb->delete( $wpdb->links, array( 'link_id' => $link_id ) ); |
|
100 | + $wpdb->delete($wpdb->links, array('link_id' => $link_id)); |
|
101 | 101 | |
102 | 102 | /** |
103 | 103 | * Fires after a link has been deleted. |
@@ -106,9 +106,9 @@ discard block |
||
106 | 106 | * |
107 | 107 | * @param int $link_id ID of the deleted link. |
108 | 108 | */ |
109 | - do_action( 'deleted_link', $link_id ); |
|
109 | + do_action('deleted_link', $link_id); |
|
110 | 110 | |
111 | - clean_bookmark_cache( $link_id ); |
|
111 | + clean_bookmark_cache($link_id); |
|
112 | 112 | |
113 | 113 | return true; |
114 | 114 | } |
@@ -121,9 +121,9 @@ discard block |
||
121 | 121 | * @param int $link_id Link ID to look up |
122 | 122 | * @return array The requested link's categories |
123 | 123 | */ |
124 | -function wp_get_link_cats( $link_id = 0 ) { |
|
125 | - $cats = wp_get_object_terms( $link_id, 'link_category', array('fields' => 'ids') ); |
|
126 | - return array_unique( $cats ); |
|
124 | +function wp_get_link_cats($link_id = 0) { |
|
125 | + $cats = wp_get_object_terms($link_id, 'link_category', array('fields' => 'ids')); |
|
126 | + return array_unique($cats); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | * @param int|stdClass $link Link ID or object to retrieve. |
135 | 135 | * @return object Link object for editing. |
136 | 136 | */ |
137 | -function get_link_to_edit( $link ) { |
|
138 | - return get_bookmark( $link, OBJECT, 'edit' ); |
|
137 | +function get_link_to_edit($link) { |
|
138 | + return get_bookmark($link, OBJECT, 'edit'); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -149,63 +149,63 @@ discard block |
||
149 | 149 | * @param bool $wp_error Optional. Whether to return a WP_Error object on failure. Default false. |
150 | 150 | * @return int|WP_Error Value 0 or WP_Error on failure. The link ID on success. |
151 | 151 | */ |
152 | -function wp_insert_link( $linkdata, $wp_error = false ) { |
|
152 | +function wp_insert_link($linkdata, $wp_error = false) { |
|
153 | 153 | global $wpdb; |
154 | 154 | |
155 | - $defaults = array( 'link_id' => 0, 'link_name' => '', 'link_url' => '', 'link_rating' => 0 ); |
|
155 | + $defaults = array('link_id' => 0, 'link_name' => '', 'link_url' => '', 'link_rating' => 0); |
|
156 | 156 | |
157 | - $args = wp_parse_args( $linkdata, $defaults ); |
|
158 | - $r = wp_unslash( sanitize_bookmark( $args, 'db' ) ); |
|
157 | + $args = wp_parse_args($linkdata, $defaults); |
|
158 | + $r = wp_unslash(sanitize_bookmark($args, 'db')); |
|
159 | 159 | |
160 | 160 | $link_id = $r['link_id']; |
161 | 161 | $link_name = $r['link_name']; |
162 | 162 | $link_url = $r['link_url']; |
163 | 163 | |
164 | 164 | $update = false; |
165 | - if ( ! empty( $link_id ) ) { |
|
165 | + if ( ! empty($link_id)) { |
|
166 | 166 | $update = true; |
167 | 167 | } |
168 | 168 | |
169 | - if ( trim( $link_name ) == '' ) { |
|
170 | - if ( trim( $link_url ) != '' ) { |
|
169 | + if (trim($link_name) == '') { |
|
170 | + if (trim($link_url) != '') { |
|
171 | 171 | $link_name = $link_url; |
172 | 172 | } else { |
173 | 173 | return 0; |
174 | 174 | } |
175 | 175 | } |
176 | 176 | |
177 | - if ( trim( $link_url ) == '' ) { |
|
177 | + if (trim($link_url) == '') { |
|
178 | 178 | return 0; |
179 | 179 | } |
180 | 180 | |
181 | - $link_rating = ( ! empty( $r['link_rating'] ) ) ? $r['link_rating'] : 0; |
|
182 | - $link_image = ( ! empty( $r['link_image'] ) ) ? $r['link_image'] : ''; |
|
183 | - $link_target = ( ! empty( $r['link_target'] ) ) ? $r['link_target'] : ''; |
|
184 | - $link_visible = ( ! empty( $r['link_visible'] ) ) ? $r['link_visible'] : 'Y'; |
|
185 | - $link_owner = ( ! empty( $r['link_owner'] ) ) ? $r['link_owner'] : get_current_user_id(); |
|
186 | - $link_notes = ( ! empty( $r['link_notes'] ) ) ? $r['link_notes'] : ''; |
|
187 | - $link_description = ( ! empty( $r['link_description'] ) ) ? $r['link_description'] : ''; |
|
188 | - $link_rss = ( ! empty( $r['link_rss'] ) ) ? $r['link_rss'] : ''; |
|
189 | - $link_rel = ( ! empty( $r['link_rel'] ) ) ? $r['link_rel'] : ''; |
|
190 | - $link_category = ( ! empty( $r['link_category'] ) ) ? $r['link_category'] : array(); |
|
181 | + $link_rating = ( ! empty($r['link_rating'])) ? $r['link_rating'] : 0; |
|
182 | + $link_image = ( ! empty($r['link_image'])) ? $r['link_image'] : ''; |
|
183 | + $link_target = ( ! empty($r['link_target'])) ? $r['link_target'] : ''; |
|
184 | + $link_visible = ( ! empty($r['link_visible'])) ? $r['link_visible'] : 'Y'; |
|
185 | + $link_owner = ( ! empty($r['link_owner'])) ? $r['link_owner'] : get_current_user_id(); |
|
186 | + $link_notes = ( ! empty($r['link_notes'])) ? $r['link_notes'] : ''; |
|
187 | + $link_description = ( ! empty($r['link_description'])) ? $r['link_description'] : ''; |
|
188 | + $link_rss = ( ! empty($r['link_rss'])) ? $r['link_rss'] : ''; |
|
189 | + $link_rel = ( ! empty($r['link_rel'])) ? $r['link_rel'] : ''; |
|
190 | + $link_category = ( ! empty($r['link_category'])) ? $r['link_category'] : array(); |
|
191 | 191 | |
192 | 192 | // Make sure we set a valid category. |
193 | - if ( ! is_array( $link_category ) || 0 == count( $link_category ) ) { |
|
194 | - $link_category = array( get_option( 'default_link_category' ) ); |
|
193 | + if ( ! is_array($link_category) || 0 == count($link_category)) { |
|
194 | + $link_category = array(get_option('default_link_category')); |
|
195 | 195 | } |
196 | 196 | |
197 | - if ( $update ) { |
|
198 | - if ( false === $wpdb->update( $wpdb->links, compact( 'link_url', 'link_name', 'link_image', 'link_target', 'link_description', 'link_visible', 'link_rating', 'link_rel', 'link_notes', 'link_rss' ), compact( 'link_id' ) ) ) { |
|
199 | - if ( $wp_error ) { |
|
200 | - return new WP_Error( 'db_update_error', __( 'Could not update link in the database' ), $wpdb->last_error ); |
|
197 | + if ($update) { |
|
198 | + if (false === $wpdb->update($wpdb->links, compact('link_url', 'link_name', 'link_image', 'link_target', 'link_description', 'link_visible', 'link_rating', 'link_rel', 'link_notes', 'link_rss'), compact('link_id'))) { |
|
199 | + if ($wp_error) { |
|
200 | + return new WP_Error('db_update_error', __('Could not update link in the database'), $wpdb->last_error); |
|
201 | 201 | } else { |
202 | 202 | return 0; |
203 | 203 | } |
204 | 204 | } |
205 | 205 | } else { |
206 | - if ( false === $wpdb->insert( $wpdb->links, compact( 'link_url', 'link_name', 'link_image', 'link_target', 'link_description', 'link_visible', 'link_owner', 'link_rating', 'link_rel', 'link_notes', 'link_rss' ) ) ) { |
|
207 | - if ( $wp_error ) { |
|
208 | - return new WP_Error( 'db_insert_error', __( 'Could not insert link into the database' ), $wpdb->last_error ); |
|
206 | + if (false === $wpdb->insert($wpdb->links, compact('link_url', 'link_name', 'link_image', 'link_target', 'link_description', 'link_visible', 'link_owner', 'link_rating', 'link_rel', 'link_notes', 'link_rss'))) { |
|
207 | + if ($wp_error) { |
|
208 | + return new WP_Error('db_insert_error', __('Could not insert link into the database'), $wpdb->last_error); |
|
209 | 209 | } else { |
210 | 210 | return 0; |
211 | 211 | } |
@@ -213,9 +213,9 @@ discard block |
||
213 | 213 | $link_id = (int) $wpdb->insert_id; |
214 | 214 | } |
215 | 215 | |
216 | - wp_set_link_cats( $link_id, $link_category ); |
|
216 | + wp_set_link_cats($link_id, $link_category); |
|
217 | 217 | |
218 | - if ( $update ) { |
|
218 | + if ($update) { |
|
219 | 219 | /** |
220 | 220 | * Fires after a link was updated in the database. |
221 | 221 | * |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | * |
224 | 224 | * @param int $link_id ID of the link that was updated. |
225 | 225 | */ |
226 | - do_action( 'edit_link', $link_id ); |
|
226 | + do_action('edit_link', $link_id); |
|
227 | 227 | } else { |
228 | 228 | /** |
229 | 229 | * Fires after a link was added to the database. |
@@ -232,9 +232,9 @@ discard block |
||
232 | 232 | * |
233 | 233 | * @param int $link_id ID of the link that was added. |
234 | 234 | */ |
235 | - do_action( 'add_link', $link_id ); |
|
235 | + do_action('add_link', $link_id); |
|
236 | 236 | } |
237 | - clean_bookmark_cache( $link_id ); |
|
237 | + clean_bookmark_cache($link_id); |
|
238 | 238 | |
239 | 239 | return $link_id; |
240 | 240 | } |
@@ -247,17 +247,17 @@ discard block |
||
247 | 247 | * @param int $link_id ID of the link to update. |
248 | 248 | * @param array $link_categories Array of link categories to add the link to. |
249 | 249 | */ |
250 | -function wp_set_link_cats( $link_id = 0, $link_categories = array() ) { |
|
250 | +function wp_set_link_cats($link_id = 0, $link_categories = array()) { |
|
251 | 251 | // If $link_categories isn't already an array, make it one: |
252 | - if ( !is_array( $link_categories ) || 0 == count( $link_categories ) ) |
|
253 | - $link_categories = array( get_option( 'default_link_category' ) ); |
|
252 | + if ( ! is_array($link_categories) || 0 == count($link_categories)) |
|
253 | + $link_categories = array(get_option('default_link_category')); |
|
254 | 254 | |
255 | - $link_categories = array_map( 'intval', $link_categories ); |
|
256 | - $link_categories = array_unique( $link_categories ); |
|
255 | + $link_categories = array_map('intval', $link_categories); |
|
256 | + $link_categories = array_unique($link_categories); |
|
257 | 257 | |
258 | - wp_set_object_terms( $link_id, $link_categories, 'link_category' ); |
|
258 | + wp_set_object_terms($link_id, $link_categories, 'link_category'); |
|
259 | 259 | |
260 | - clean_bookmark_cache( $link_id ); |
|
260 | + clean_bookmark_cache($link_id); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | /** |
@@ -268,26 +268,26 @@ discard block |
||
268 | 268 | * @param array $linkdata Link data to update. |
269 | 269 | * @return int|WP_Error Value 0 or WP_Error on failure. The updated link ID on success. |
270 | 270 | */ |
271 | -function wp_update_link( $linkdata ) { |
|
271 | +function wp_update_link($linkdata) { |
|
272 | 272 | $link_id = (int) $linkdata['link_id']; |
273 | 273 | |
274 | - $link = get_bookmark( $link_id, ARRAY_A ); |
|
274 | + $link = get_bookmark($link_id, ARRAY_A); |
|
275 | 275 | |
276 | 276 | // Escape data pulled from DB. |
277 | - $link = wp_slash( $link ); |
|
277 | + $link = wp_slash($link); |
|
278 | 278 | |
279 | 279 | // Passed link category list overwrites existing category list if not empty. |
280 | - if ( isset( $linkdata['link_category'] ) && is_array( $linkdata['link_category'] ) |
|
281 | - && 0 != count( $linkdata['link_category'] ) ) |
|
280 | + if (isset($linkdata['link_category']) && is_array($linkdata['link_category']) |
|
281 | + && 0 != count($linkdata['link_category'])) |
|
282 | 282 | $link_cats = $linkdata['link_category']; |
283 | 283 | else |
284 | 284 | $link_cats = $link['link_category']; |
285 | 285 | |
286 | 286 | // Merge old and new fields with new fields overwriting old ones. |
287 | - $linkdata = array_merge( $link, $linkdata ); |
|
287 | + $linkdata = array_merge($link, $linkdata); |
|
288 | 288 | $linkdata['link_category'] = $link_cats; |
289 | 289 | |
290 | - return wp_insert_link( $linkdata ); |
|
290 | + return wp_insert_link($linkdata); |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | /** |
@@ -300,17 +300,17 @@ discard block |
||
300 | 300 | */ |
301 | 301 | function wp_link_manager_disabled_message() { |
302 | 302 | global $pagenow; |
303 | - if ( 'link-manager.php' != $pagenow && 'link-add.php' != $pagenow && 'link.php' != $pagenow ) |
|
303 | + if ('link-manager.php' != $pagenow && 'link-add.php' != $pagenow && 'link.php' != $pagenow) |
|
304 | 304 | return; |
305 | 305 | |
306 | - add_filter( 'pre_option_link_manager_enabled', '__return_true', 100 ); |
|
307 | - $really_can_manage_links = current_user_can( 'manage_links' ); |
|
308 | - remove_filter( 'pre_option_link_manager_enabled', '__return_true', 100 ); |
|
306 | + add_filter('pre_option_link_manager_enabled', '__return_true', 100); |
|
307 | + $really_can_manage_links = current_user_can('manage_links'); |
|
308 | + remove_filter('pre_option_link_manager_enabled', '__return_true', 100); |
|
309 | 309 | |
310 | - if ( $really_can_manage_links && current_user_can( 'install_plugins' ) ) { |
|
311 | - $link = network_admin_url( 'plugin-install.php?tab=search&s=Link+Manager' ); |
|
312 | - wp_die( sprintf( __( 'If you are looking to use the link manager, please install the <a href="%s">Link Manager</a> plugin.' ), $link ) ); |
|
310 | + if ($really_can_manage_links && current_user_can('install_plugins')) { |
|
311 | + $link = network_admin_url('plugin-install.php?tab=search&s=Link+Manager'); |
|
312 | + wp_die(sprintf(__('If you are looking to use the link manager, please install the <a href="%s">Link Manager</a> plugin.'), $link)); |
|
313 | 313 | } |
314 | 314 | |
315 | - wp_die( __( 'Sorry, you are not allowed to edit the links for this site.' ) ); |
|
315 | + wp_die(__('Sorry, you are not allowed to edit the links for this site.')); |
|
316 | 316 | } |