@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * @deprecated 3.0.0 |
16 | 16 | */ |
17 | 17 | function wpmu_menu() { |
18 | - _deprecated_function(__FUNCTION__, '3.0' ); |
|
18 | + _deprecated_function(__FUNCTION__, '3.0'); |
|
19 | 19 | // Deprecated. See #11763. |
20 | 20 | } |
21 | 21 | |
@@ -26,10 +26,10 @@ discard block |
||
26 | 26 | * @see is_upload_space_available() |
27 | 27 | */ |
28 | 28 | function wpmu_checkAvailableSpace() { |
29 | - _deprecated_function(__FUNCTION__, '3.0', 'is_upload_space_available()' ); |
|
29 | + _deprecated_function(__FUNCTION__, '3.0', 'is_upload_space_available()'); |
|
30 | 30 | |
31 | - if ( !is_upload_space_available() ) |
|
32 | - wp_die( __('Sorry, you must delete files before you can upload any more.') ); |
|
31 | + if ( ! is_upload_space_available()) |
|
32 | + wp_die(__('Sorry, you must delete files before you can upload any more.')); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | * |
38 | 38 | * @deprecated 3.0.0 |
39 | 39 | */ |
40 | -function mu_options( $options ) { |
|
41 | - _deprecated_function(__FUNCTION__, '3.0' ); |
|
40 | +function mu_options($options) { |
|
41 | + _deprecated_function(__FUNCTION__, '3.0'); |
|
42 | 42 | return $options; |
43 | 43 | } |
44 | 44 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * @see activate_plugin() |
50 | 50 | */ |
51 | 51 | function activate_sitewide_plugin() { |
52 | - _deprecated_function(__FUNCTION__, '3.0', 'activate_plugin()' ); |
|
52 | + _deprecated_function(__FUNCTION__, '3.0', 'activate_plugin()'); |
|
53 | 53 | return false; |
54 | 54 | } |
55 | 55 | |
@@ -59,8 +59,8 @@ discard block |
||
59 | 59 | * @deprecated 3.0.0 Use deactivate_sitewide_plugin() |
60 | 60 | * @see deactivate_sitewide_plugin() |
61 | 61 | */ |
62 | -function deactivate_sitewide_plugin( $plugin = false ) { |
|
63 | - _deprecated_function(__FUNCTION__, '3.0', 'deactivate_plugin()' ); |
|
62 | +function deactivate_sitewide_plugin($plugin = false) { |
|
63 | + _deprecated_function(__FUNCTION__, '3.0', 'deactivate_plugin()'); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | * @deprecated 3.0.0 Use is_network_only_plugin() |
70 | 70 | * @see is_network_only_plugin() |
71 | 71 | */ |
72 | -function is_wpmu_sitewide_plugin( $file ) { |
|
73 | - _deprecated_function(__FUNCTION__, '3.0', 'is_network_only_plugin()' ); |
|
74 | - return is_network_only_plugin( $file ); |
|
72 | +function is_wpmu_sitewide_plugin($file) { |
|
73 | + _deprecated_function(__FUNCTION__, '3.0', 'is_network_only_plugin()'); |
|
74 | + return is_network_only_plugin($file); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | * @see WP_Theme::get_allowed_on_network() |
82 | 82 | */ |
83 | 83 | function get_site_allowed_themes() { |
84 | - _deprecated_function( __FUNCTION__, '3.4', 'WP_Theme::get_allowed_on_network()' ); |
|
85 | - return array_map( 'intval', WP_Theme::get_allowed_on_network() ); |
|
84 | + _deprecated_function(__FUNCTION__, '3.4', 'WP_Theme::get_allowed_on_network()'); |
|
85 | + return array_map('intval', WP_Theme::get_allowed_on_network()); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | * @deprecated 3.4.0 Use WP_Theme::get_allowed_on_site() |
92 | 92 | * @see WP_Theme::get_allowed_on_site() |
93 | 93 | */ |
94 | -function wpmu_get_blog_allowedthemes( $blog_id = 0 ) { |
|
95 | - _deprecated_function( __FUNCTION__, '3.4', 'WP_Theme::get_allowed_on_site()' ); |
|
96 | - return array_map( 'intval', WP_Theme::get_allowed_on_site( $blog_id ) ); |
|
94 | +function wpmu_get_blog_allowedthemes($blog_id = 0) { |
|
95 | + _deprecated_function(__FUNCTION__, '3.4', 'WP_Theme::get_allowed_on_site()'); |
|
96 | + return array_map('intval', WP_Theme::get_allowed_on_site($blog_id)); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -28,9 +28,10 @@ |
||
28 | 28 | function wpmu_checkAvailableSpace() { |
29 | 29 | _deprecated_function(__FUNCTION__, '3.0', 'is_upload_space_available()' ); |
30 | 30 | |
31 | - if ( !is_upload_space_available() ) |
|
32 | - wp_die( __('Sorry, you must delete files before you can upload any more.') ); |
|
33 | -} |
|
31 | + if ( !is_upload_space_available() ) { |
|
32 | + wp_die( __('Sorry, you must delete files before you can upload any more.') ); |
|
33 | + } |
|
34 | + } |
|
34 | 35 | |
35 | 36 | /** |
36 | 37 | * WPMU options. |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Terms List Table class. |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage List_Table |
|
7 | - * @since 3.1.0 |
|
8 | - * @access private |
|
9 | - */ |
|
3 | + * Terms List Table class. |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage List_Table |
|
7 | + * @since 3.1.0 |
|
8 | + * @access private |
|
9 | + */ |
|
10 | 10 | class WP_Terms_List_Table extends WP_List_Table { |
11 | 11 | |
12 | 12 | public $callback_args; |
@@ -28,29 +28,29 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @param array $args An associative array of arguments. |
30 | 30 | */ |
31 | - public function __construct( $args = array() ) { |
|
31 | + public function __construct($args = array()) { |
|
32 | 32 | global $post_type, $taxonomy, $action, $tax; |
33 | 33 | |
34 | - parent::__construct( array( |
|
34 | + parent::__construct(array( |
|
35 | 35 | 'plural' => 'tags', |
36 | 36 | 'singular' => 'tag', |
37 | - 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
|
38 | - ) ); |
|
37 | + 'screen' => isset($args['screen']) ? $args['screen'] : null, |
|
38 | + )); |
|
39 | 39 | |
40 | 40 | $action = $this->screen->action; |
41 | 41 | $post_type = $this->screen->post_type; |
42 | 42 | $taxonomy = $this->screen->taxonomy; |
43 | 43 | |
44 | - if ( empty( $taxonomy ) ) |
|
44 | + if (empty($taxonomy)) |
|
45 | 45 | $taxonomy = 'post_tag'; |
46 | 46 | |
47 | - if ( ! taxonomy_exists( $taxonomy ) ) |
|
48 | - wp_die( __( 'Invalid taxonomy' ) ); |
|
47 | + if ( ! taxonomy_exists($taxonomy)) |
|
48 | + wp_die(__('Invalid taxonomy')); |
|
49 | 49 | |
50 | - $tax = get_taxonomy( $taxonomy ); |
|
50 | + $tax = get_taxonomy($taxonomy); |
|
51 | 51 | |
52 | 52 | // @todo Still needed? Maybe just the show_ui part. |
53 | - if ( empty( $post_type ) || !in_array( $post_type, get_post_types( array( 'show_ui' => true ) ) ) ) |
|
53 | + if (empty($post_type) || ! in_array($post_type, get_post_types(array('show_ui' => true)))) |
|
54 | 54 | $post_type = 'post'; |
55 | 55 | |
56 | 56 | } |
@@ -60,16 +60,16 @@ discard block |
||
60 | 60 | * @return bool |
61 | 61 | */ |
62 | 62 | public function ajax_user_can() { |
63 | - return current_user_can( get_taxonomy( $this->screen->taxonomy )->cap->manage_terms ); |
|
63 | + return current_user_can(get_taxonomy($this->screen->taxonomy)->cap->manage_terms); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
67 | 67 | * @access public |
68 | 68 | */ |
69 | 69 | public function prepare_items() { |
70 | - $tags_per_page = $this->get_items_per_page( 'edit_' . $this->screen->taxonomy . '_per_page' ); |
|
70 | + $tags_per_page = $this->get_items_per_page('edit_'.$this->screen->taxonomy.'_per_page'); |
|
71 | 71 | |
72 | - if ( 'post_tag' == $this->screen->taxonomy ) { |
|
72 | + if ('post_tag' == $this->screen->taxonomy) { |
|
73 | 73 | /** |
74 | 74 | * Filter the number of terms displayed per page for the Tags list table. |
75 | 75 | * |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * |
78 | 78 | * @param int $tags_per_page Number of tags to be displayed. Default 20. |
79 | 79 | */ |
80 | - $tags_per_page = apply_filters( 'edit_tags_per_page', $tags_per_page ); |
|
80 | + $tags_per_page = apply_filters('edit_tags_per_page', $tags_per_page); |
|
81 | 81 | |
82 | 82 | /** |
83 | 83 | * Filter the number of terms displayed per page for the Tags list table. |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @param int $tags_per_page Number of tags to be displayed. Default 20. |
89 | 89 | */ |
90 | - $tags_per_page = apply_filters( 'tagsperpage', $tags_per_page ); |
|
91 | - } elseif ( 'category' == $this->screen->taxonomy ) { |
|
90 | + $tags_per_page = apply_filters('tagsperpage', $tags_per_page); |
|
91 | + } elseif ('category' == $this->screen->taxonomy) { |
|
92 | 92 | /** |
93 | 93 | * Filter the number of terms displayed per page for the Categories list table. |
94 | 94 | * |
@@ -96,10 +96,10 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @param int $tags_per_page Number of categories to be displayed. Default 20. |
98 | 98 | */ |
99 | - $tags_per_page = apply_filters( 'edit_categories_per_page', $tags_per_page ); |
|
99 | + $tags_per_page = apply_filters('edit_categories_per_page', $tags_per_page); |
|
100 | 100 | } |
101 | 101 | |
102 | - $search = !empty( $_REQUEST['s'] ) ? trim( wp_unslash( $_REQUEST['s'] ) ) : ''; |
|
102 | + $search = ! empty($_REQUEST['s']) ? trim(wp_unslash($_REQUEST['s'])) : ''; |
|
103 | 103 | |
104 | 104 | $args = array( |
105 | 105 | 'search' => $search, |
@@ -107,18 +107,18 @@ discard block |
||
107 | 107 | 'number' => $tags_per_page, |
108 | 108 | ); |
109 | 109 | |
110 | - if ( !empty( $_REQUEST['orderby'] ) ) |
|
111 | - $args['orderby'] = trim( wp_unslash( $_REQUEST['orderby'] ) ); |
|
110 | + if ( ! empty($_REQUEST['orderby'])) |
|
111 | + $args['orderby'] = trim(wp_unslash($_REQUEST['orderby'])); |
|
112 | 112 | |
113 | - if ( !empty( $_REQUEST['order'] ) ) |
|
114 | - $args['order'] = trim( wp_unslash( $_REQUEST['order'] ) ); |
|
113 | + if ( ! empty($_REQUEST['order'])) |
|
114 | + $args['order'] = trim(wp_unslash($_REQUEST['order'])); |
|
115 | 115 | |
116 | 116 | $this->callback_args = $args; |
117 | 117 | |
118 | - $this->set_pagination_args( array( |
|
119 | - 'total_items' => wp_count_terms( $this->screen->taxonomy, compact( 'search' ) ), |
|
118 | + $this->set_pagination_args(array( |
|
119 | + 'total_items' => wp_count_terms($this->screen->taxonomy, compact('search')), |
|
120 | 120 | 'per_page' => $tags_per_page, |
121 | - ) ); |
|
121 | + )); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * @access public |
135 | 135 | */ |
136 | 136 | public function no_items() { |
137 | - echo get_taxonomy( $this->screen->taxonomy )->labels->not_found; |
|
137 | + echo get_taxonomy($this->screen->taxonomy)->labels->not_found; |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | */ |
144 | 144 | protected function get_bulk_actions() { |
145 | 145 | $actions = array(); |
146 | - $actions['delete'] = __( 'Delete' ); |
|
146 | + $actions['delete'] = __('Delete'); |
|
147 | 147 | |
148 | 148 | return $actions; |
149 | 149 | } |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @return string |
154 | 154 | */ |
155 | 155 | public function current_action() { |
156 | - if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && ( 'delete' == $_REQUEST['action'] || 'delete' == $_REQUEST['action2'] ) ) |
|
156 | + if (isset($_REQUEST['action']) && isset($_REQUEST['delete_tags']) && ('delete' == $_REQUEST['action'] || 'delete' == $_REQUEST['action2'])) |
|
157 | 157 | return 'bulk-delete'; |
158 | 158 | |
159 | 159 | return parent::current_action(); |
@@ -166,15 +166,15 @@ discard block |
||
166 | 166 | public function get_columns() { |
167 | 167 | $columns = array( |
168 | 168 | 'cb' => '<input type="checkbox" />', |
169 | - 'name' => _x( 'Name', 'term name' ), |
|
170 | - 'description' => __( 'Description' ), |
|
171 | - 'slug' => __( 'Slug' ), |
|
169 | + 'name' => _x('Name', 'term name'), |
|
170 | + 'description' => __('Description'), |
|
171 | + 'slug' => __('Slug'), |
|
172 | 172 | ); |
173 | 173 | |
174 | - if ( 'link_category' == $this->screen->taxonomy ) { |
|
175 | - $columns['links'] = __( 'Links' ); |
|
174 | + if ('link_category' == $this->screen->taxonomy) { |
|
175 | + $columns['links'] = __('Links'); |
|
176 | 176 | } else { |
177 | - $columns['posts'] = _x( 'Count', 'Number/count of items' ); |
|
177 | + $columns['posts'] = _x('Count', 'Number/count of items'); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | return $columns; |
@@ -200,47 +200,47 @@ discard block |
||
200 | 200 | public function display_rows_or_placeholder() { |
201 | 201 | $taxonomy = $this->screen->taxonomy; |
202 | 202 | |
203 | - $args = wp_parse_args( $this->callback_args, array( |
|
203 | + $args = wp_parse_args($this->callback_args, array( |
|
204 | 204 | 'page' => 1, |
205 | 205 | 'number' => 20, |
206 | 206 | 'search' => '', |
207 | 207 | 'hide_empty' => 0 |
208 | - ) ); |
|
208 | + )); |
|
209 | 209 | |
210 | 210 | $page = $args['page']; |
211 | 211 | |
212 | 212 | // Set variable because $args['number'] can be subsequently overridden. |
213 | 213 | $number = $args['number']; |
214 | 214 | |
215 | - $args['offset'] = $offset = ( $page - 1 ) * $number; |
|
215 | + $args['offset'] = $offset = ($page - 1) * $number; |
|
216 | 216 | |
217 | 217 | // Convert it to table rows. |
218 | 218 | $count = 0; |
219 | 219 | |
220 | - if ( is_taxonomy_hierarchical( $taxonomy ) && ! isset( $args['orderby'] ) ) { |
|
220 | + if (is_taxonomy_hierarchical($taxonomy) && ! isset($args['orderby'])) { |
|
221 | 221 | // We'll need the full set of terms then. |
222 | 222 | $args['number'] = $args['offset'] = 0; |
223 | 223 | } |
224 | - $terms = get_terms( $taxonomy, $args ); |
|
224 | + $terms = get_terms($taxonomy, $args); |
|
225 | 225 | |
226 | - if ( empty( $terms ) || ! is_array( $terms ) ) { |
|
227 | - echo '<tr class="no-items"><td class="colspanchange" colspan="' . $this->get_column_count() . '">'; |
|
226 | + if (empty($terms) || ! is_array($terms)) { |
|
227 | + echo '<tr class="no-items"><td class="colspanchange" colspan="'.$this->get_column_count().'">'; |
|
228 | 228 | $this->no_items(); |
229 | 229 | echo '</td></tr>'; |
230 | 230 | return; |
231 | 231 | } |
232 | 232 | |
233 | - if ( is_taxonomy_hierarchical( $taxonomy ) && ! isset( $args['orderby'] ) ) { |
|
234 | - if ( ! empty( $args['search'] ) ) {// Ignore children on searches. |
|
233 | + if (is_taxonomy_hierarchical($taxonomy) && ! isset($args['orderby'])) { |
|
234 | + if ( ! empty($args['search'])) {// Ignore children on searches. |
|
235 | 235 | $children = array(); |
236 | 236 | } else { |
237 | - $children = _get_term_hierarchy( $taxonomy ); |
|
237 | + $children = _get_term_hierarchy($taxonomy); |
|
238 | 238 | } |
239 | 239 | // Some funky recursion to get the job done( Paging & parents mainly ) is contained within, Skip it for non-hierarchical taxonomies for performance sake |
240 | - $this->_rows( $taxonomy, $terms, $children, $offset, $number, $count ); |
|
240 | + $this->_rows($taxonomy, $terms, $children, $offset, $number, $count); |
|
241 | 241 | } else { |
242 | - foreach ( $terms as $term ) { |
|
243 | - $this->single_row( $term ); |
|
242 | + foreach ($terms as $term) { |
|
243 | + $this->single_row($term); |
|
244 | 244 | } |
245 | 245 | } |
246 | 246 | } |
@@ -255,51 +255,51 @@ discard block |
||
255 | 255 | * @param int $parent |
256 | 256 | * @param int $level |
257 | 257 | */ |
258 | - private function _rows( $taxonomy, $terms, &$children, $start, $per_page, &$count, $parent = 0, $level = 0 ) { |
|
258 | + private function _rows($taxonomy, $terms, &$children, $start, $per_page, &$count, $parent = 0, $level = 0) { |
|
259 | 259 | |
260 | 260 | $end = $start + $per_page; |
261 | 261 | |
262 | - foreach ( $terms as $key => $term ) { |
|
262 | + foreach ($terms as $key => $term) { |
|
263 | 263 | |
264 | - if ( $count >= $end ) |
|
264 | + if ($count >= $end) |
|
265 | 265 | break; |
266 | 266 | |
267 | - if ( $term->parent != $parent && empty( $_REQUEST['s'] ) ) |
|
267 | + if ($term->parent != $parent && empty($_REQUEST['s'])) |
|
268 | 268 | continue; |
269 | 269 | |
270 | 270 | // If the page starts in a subtree, print the parents. |
271 | - if ( $count == $start && $term->parent > 0 && empty( $_REQUEST['s'] ) ) { |
|
271 | + if ($count == $start && $term->parent > 0 && empty($_REQUEST['s'])) { |
|
272 | 272 | $my_parents = $parent_ids = array(); |
273 | 273 | $p = $term->parent; |
274 | - while ( $p ) { |
|
275 | - $my_parent = get_term( $p, $taxonomy ); |
|
274 | + while ($p) { |
|
275 | + $my_parent = get_term($p, $taxonomy); |
|
276 | 276 | $my_parents[] = $my_parent; |
277 | 277 | $p = $my_parent->parent; |
278 | - if ( in_array( $p, $parent_ids ) ) // Prevent parent loops. |
|
278 | + if (in_array($p, $parent_ids)) // Prevent parent loops. |
|
279 | 279 | break; |
280 | 280 | $parent_ids[] = $p; |
281 | 281 | } |
282 | - unset( $parent_ids ); |
|
282 | + unset($parent_ids); |
|
283 | 283 | |
284 | - $num_parents = count( $my_parents ); |
|
285 | - while ( $my_parent = array_pop( $my_parents ) ) { |
|
284 | + $num_parents = count($my_parents); |
|
285 | + while ($my_parent = array_pop($my_parents)) { |
|
286 | 286 | echo "\t"; |
287 | - $this->single_row( $my_parent, $level - $num_parents ); |
|
287 | + $this->single_row($my_parent, $level - $num_parents); |
|
288 | 288 | $num_parents--; |
289 | 289 | } |
290 | 290 | } |
291 | 291 | |
292 | - if ( $count >= $start ) { |
|
292 | + if ($count >= $start) { |
|
293 | 293 | echo "\t"; |
294 | - $this->single_row( $term, $level ); |
|
294 | + $this->single_row($term, $level); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | ++$count; |
298 | 298 | |
299 | - unset( $terms[$key] ); |
|
299 | + unset($terms[$key]); |
|
300 | 300 | |
301 | - if ( isset( $children[$term->term_id] ) && empty( $_REQUEST['s'] ) ) |
|
302 | - $this->_rows( $taxonomy, $terms, $children, $start, $per_page, $count, $term->term_id, $level + 1 ); |
|
301 | + if (isset($children[$term->term_id]) && empty($_REQUEST['s'])) |
|
302 | + $this->_rows($taxonomy, $terms, $children, $start, $per_page, $count, $term->term_id, $level + 1); |
|
303 | 303 | } |
304 | 304 | } |
305 | 305 | |
@@ -308,14 +308,14 @@ discard block |
||
308 | 308 | * @param object $tag |
309 | 309 | * @param int $level |
310 | 310 | */ |
311 | - public function single_row( $tag, $level = 0 ) { |
|
311 | + public function single_row($tag, $level = 0) { |
|
312 | 312 | global $taxonomy; |
313 | - $tag = sanitize_term( $tag, $taxonomy ); |
|
313 | + $tag = sanitize_term($tag, $taxonomy); |
|
314 | 314 | |
315 | 315 | $this->level = $level; |
316 | 316 | |
317 | - echo '<tr id="tag-' . $tag->term_id . '">'; |
|
318 | - $this->single_row_columns( $tag ); |
|
317 | + echo '<tr id="tag-'.$tag->term_id.'">'; |
|
318 | + $this->single_row_columns($tag); |
|
319 | 319 | echo '</tr>'; |
320 | 320 | } |
321 | 321 | |
@@ -323,12 +323,12 @@ discard block |
||
323 | 323 | * @param object $tag |
324 | 324 | * @return string |
325 | 325 | */ |
326 | - public function column_cb( $tag ) { |
|
327 | - $default_term = get_option( 'default_' . $this->screen->taxonomy ); |
|
326 | + public function column_cb($tag) { |
|
327 | + $default_term = get_option('default_'.$this->screen->taxonomy); |
|
328 | 328 | |
329 | - if ( current_user_can( get_taxonomy( $this->screen->taxonomy )->cap->delete_terms ) && $tag->term_id != $default_term ) |
|
330 | - return '<label class="screen-reader-text" for="cb-select-' . $tag->term_id . '">' . sprintf( __( 'Select %s' ), $tag->name ) . '</label>' |
|
331 | - . '<input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" id="cb-select-' . $tag->term_id . '" />'; |
|
329 | + if (current_user_can(get_taxonomy($this->screen->taxonomy)->cap->delete_terms) && $tag->term_id != $default_term) |
|
330 | + return '<label class="screen-reader-text" for="cb-select-'.$tag->term_id.'">'.sprintf(__('Select %s'), $tag->name).'</label>' |
|
331 | + . '<input type="checkbox" name="delete_tags[]" value="'.$tag->term_id.'" id="cb-select-'.$tag->term_id.'" />'; |
|
332 | 332 | |
333 | 333 | return ' '; |
334 | 334 | } |
@@ -337,10 +337,10 @@ discard block |
||
337 | 337 | * @param object $tag |
338 | 338 | * @return string |
339 | 339 | */ |
340 | - public function column_name( $tag ) { |
|
340 | + public function column_name($tag) { |
|
341 | 341 | $taxonomy = $this->screen->taxonomy; |
342 | 342 | |
343 | - $pad = str_repeat( '— ', max( 0, $this->level ) ); |
|
343 | + $pad = str_repeat('— ', max(0, $this->level)); |
|
344 | 344 | |
345 | 345 | /** |
346 | 346 | * Filter display of the term name in the terms list table. |
@@ -355,19 +355,19 @@ discard block |
||
355 | 355 | * @param string $pad_tag_name The term name, padded if not top-level. |
356 | 356 | * @param object $tag Term object. |
357 | 357 | */ |
358 | - $name = apply_filters( 'term_name', $pad . ' ' . $tag->name, $tag ); |
|
358 | + $name = apply_filters('term_name', $pad.' '.$tag->name, $tag); |
|
359 | 359 | |
360 | - $qe_data = get_term( $tag->term_id, $taxonomy, OBJECT, 'edit' ); |
|
361 | - $edit_link = esc_url( get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type ) ); |
|
360 | + $qe_data = get_term($tag->term_id, $taxonomy, OBJECT, 'edit'); |
|
361 | + $edit_link = esc_url(get_edit_term_link($tag->term_id, $taxonomy, $this->screen->post_type)); |
|
362 | 362 | |
363 | - $out = '<strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit “%s”' ), $name ) ) . '">' . $name . '</a></strong><br />'; |
|
363 | + $out = '<strong><a class="row-title" href="'.$edit_link.'" title="'.esc_attr(sprintf(__('Edit “%s”'), $name)).'">'.$name.'</a></strong><br />'; |
|
364 | 364 | |
365 | - $out .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">'; |
|
366 | - $out .= '<div class="name">' . $qe_data->name . '</div>'; |
|
365 | + $out .= '<div class="hidden" id="inline_'.$qe_data->term_id.'">'; |
|
366 | + $out .= '<div class="name">'.$qe_data->name.'</div>'; |
|
367 | 367 | |
368 | 368 | /** This filter is documented in wp-admin/edit-tag-form.php */ |
369 | - $out .= '<div class="slug">' . apply_filters( 'editable_slug', $qe_data->slug ) . '</div>'; |
|
370 | - $out .= '<div class="parent">' . $qe_data->parent . '</div></div>'; |
|
369 | + $out .= '<div class="slug">'.apply_filters('editable_slug', $qe_data->slug).'</div>'; |
|
370 | + $out .= '<div class="parent">'.$qe_data->parent.'</div></div>'; |
|
371 | 371 | |
372 | 372 | return $out; |
373 | 373 | } |
@@ -395,26 +395,26 @@ discard block |
||
395 | 395 | * @param string $primary Primary column name. |
396 | 396 | * @return string Row actions output for terms. |
397 | 397 | */ |
398 | - protected function handle_row_actions( $tag, $column_name, $primary ) { |
|
399 | - if ( $primary !== $column_name ) { |
|
398 | + protected function handle_row_actions($tag, $column_name, $primary) { |
|
399 | + if ($primary !== $column_name) { |
|
400 | 400 | return ''; |
401 | 401 | } |
402 | 402 | |
403 | 403 | $taxonomy = $this->screen->taxonomy; |
404 | - $tax = get_taxonomy( $taxonomy ); |
|
405 | - $default_term = get_option( 'default_' . $taxonomy ); |
|
404 | + $tax = get_taxonomy($taxonomy); |
|
405 | + $default_term = get_option('default_'.$taxonomy); |
|
406 | 406 | |
407 | - $edit_link = esc_url( get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type ) ); |
|
407 | + $edit_link = esc_url(get_edit_term_link($tag->term_id, $taxonomy, $this->screen->post_type)); |
|
408 | 408 | |
409 | 409 | $actions = array(); |
410 | - if ( current_user_can( $tax->cap->edit_terms ) ) { |
|
411 | - $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>'; |
|
412 | - $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __( 'Quick Edit' ) . '</a>'; |
|
410 | + if (current_user_can($tax->cap->edit_terms)) { |
|
411 | + $actions['edit'] = '<a href="'.$edit_link.'">'.__('Edit').'</a>'; |
|
412 | + $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">'.__('Quick Edit').'</a>'; |
|
413 | 413 | } |
414 | - if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term ) |
|
415 | - $actions['delete'] = "<a class='delete-tag' href='" . wp_nonce_url( "edit-tags.php?action=delete&taxonomy=$taxonomy&tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id ) . "'>" . __( 'Delete' ) . "</a>"; |
|
416 | - if ( $tax->public ) |
|
417 | - $actions['view'] = '<a href="' . get_term_link( $tag ) . '">' . __( 'View' ) . '</a>'; |
|
414 | + if (current_user_can($tax->cap->delete_terms) && $tag->term_id != $default_term) |
|
415 | + $actions['delete'] = "<a class='delete-tag' href='".wp_nonce_url("edit-tags.php?action=delete&taxonomy=$taxonomy&tag_ID=$tag->term_id", 'delete-tag_'.$tag->term_id)."'>".__('Delete')."</a>"; |
|
416 | + if ($tax->public) |
|
417 | + $actions['view'] = '<a href="'.get_term_link($tag).'">'.__('View').'</a>'; |
|
418 | 418 | |
419 | 419 | /** |
420 | 420 | * Filter the action links displayed for each term in the Tags list table. |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | * 'Edit', 'Quick Edit', 'Delete', and 'View'. |
427 | 427 | * @param object $tag Term object. |
428 | 428 | */ |
429 | - $actions = apply_filters( 'tag_row_actions', $actions, $tag ); |
|
429 | + $actions = apply_filters('tag_row_actions', $actions, $tag); |
|
430 | 430 | |
431 | 431 | /** |
432 | 432 | * Filter the action links displayed for each term in the terms list table. |
@@ -439,16 +439,16 @@ discard block |
||
439 | 439 | * 'Edit', 'Quick Edit', 'Delete', and 'View'. |
440 | 440 | * @param object $tag Term object. |
441 | 441 | */ |
442 | - $actions = apply_filters( "{$taxonomy}_row_actions", $actions, $tag ); |
|
442 | + $actions = apply_filters("{$taxonomy}_row_actions", $actions, $tag); |
|
443 | 443 | |
444 | - return $this->row_actions( $actions ); |
|
444 | + return $this->row_actions($actions); |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | /** |
448 | 448 | * @param object $tag |
449 | 449 | * @return string |
450 | 450 | */ |
451 | - public function column_description( $tag ) { |
|
451 | + public function column_description($tag) { |
|
452 | 452 | return $tag->description; |
453 | 453 | } |
454 | 454 | |
@@ -456,46 +456,46 @@ discard block |
||
456 | 456 | * @param object $tag |
457 | 457 | * @return string |
458 | 458 | */ |
459 | - public function column_slug( $tag ) { |
|
459 | + public function column_slug($tag) { |
|
460 | 460 | /** This filter is documented in wp-admin/edit-tag-form.php */ |
461 | - return apply_filters( 'editable_slug', $tag->slug ); |
|
461 | + return apply_filters('editable_slug', $tag->slug); |
|
462 | 462 | } |
463 | 463 | |
464 | 464 | /** |
465 | 465 | * @param object $tag |
466 | 466 | * @return string |
467 | 467 | */ |
468 | - public function column_posts( $tag ) { |
|
469 | - $count = number_format_i18n( $tag->count ); |
|
468 | + public function column_posts($tag) { |
|
469 | + $count = number_format_i18n($tag->count); |
|
470 | 470 | |
471 | - $tax = get_taxonomy( $this->screen->taxonomy ); |
|
471 | + $tax = get_taxonomy($this->screen->taxonomy); |
|
472 | 472 | |
473 | - $ptype_object = get_post_type_object( $this->screen->post_type ); |
|
474 | - if ( ! $ptype_object->show_ui ) |
|
473 | + $ptype_object = get_post_type_object($this->screen->post_type); |
|
474 | + if ( ! $ptype_object->show_ui) |
|
475 | 475 | return $count; |
476 | 476 | |
477 | - if ( $tax->query_var ) { |
|
478 | - $args = array( $tax->query_var => $tag->slug ); |
|
477 | + if ($tax->query_var) { |
|
478 | + $args = array($tax->query_var => $tag->slug); |
|
479 | 479 | } else { |
480 | - $args = array( 'taxonomy' => $tax->name, 'term' => $tag->slug ); |
|
480 | + $args = array('taxonomy' => $tax->name, 'term' => $tag->slug); |
|
481 | 481 | } |
482 | 482 | |
483 | - if ( 'post' != $this->screen->post_type ) |
|
483 | + if ('post' != $this->screen->post_type) |
|
484 | 484 | $args['post_type'] = $this->screen->post_type; |
485 | 485 | |
486 | - if ( 'attachment' == $this->screen->post_type ) |
|
487 | - return "<a href='" . esc_url ( add_query_arg( $args, 'upload.php' ) ) . "'>$count</a>"; |
|
486 | + if ('attachment' == $this->screen->post_type) |
|
487 | + return "<a href='".esc_url(add_query_arg($args, 'upload.php'))."'>$count</a>"; |
|
488 | 488 | |
489 | - return "<a href='" . esc_url ( add_query_arg( $args, 'edit.php' ) ) . "'>$count</a>"; |
|
489 | + return "<a href='".esc_url(add_query_arg($args, 'edit.php'))."'>$count</a>"; |
|
490 | 490 | } |
491 | 491 | |
492 | 492 | /** |
493 | 493 | * @param object $tag |
494 | 494 | * @return string |
495 | 495 | */ |
496 | - public function column_links( $tag ) { |
|
497 | - $count = number_format_i18n( $tag->count ); |
|
498 | - if ( $count ) |
|
496 | + public function column_links($tag) { |
|
497 | + $count = number_format_i18n($tag->count); |
|
498 | + if ($count) |
|
499 | 499 | $count = "<a href='link-manager.php?cat_id=$tag->term_id'>$count</a>"; |
500 | 500 | return $count; |
501 | 501 | } |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | * @param string $column_name |
506 | 506 | * @return string |
507 | 507 | */ |
508 | - public function column_default( $tag, $column_name ) { |
|
508 | + public function column_default($tag, $column_name) { |
|
509 | 509 | /** |
510 | 510 | * Filter the displayed columns in the terms list table. |
511 | 511 | * |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | * @param string $column_name Name of the column. |
519 | 519 | * @param int $term_id Term ID. |
520 | 520 | */ |
521 | - return apply_filters( "manage_{$this->screen->taxonomy}_custom_column", '', $column_name, $tag->term_id ); |
|
521 | + return apply_filters("manage_{$this->screen->taxonomy}_custom_column", '', $column_name, $tag->term_id); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | /** |
@@ -527,9 +527,9 @@ discard block |
||
527 | 527 | * @since 3.1.0 |
528 | 528 | */ |
529 | 529 | public function inline_edit() { |
530 | - $tax = get_taxonomy( $this->screen->taxonomy ); |
|
530 | + $tax = get_taxonomy($this->screen->taxonomy); |
|
531 | 531 | |
532 | - if ( ! current_user_can( $tax->cap->edit_terms ) ) |
|
532 | + if ( ! current_user_can($tax->cap->edit_terms)) |
|
533 | 533 | return; |
534 | 534 | ?> |
535 | 535 | |
@@ -537,43 +537,43 @@ discard block |
||
537 | 537 | <tr id="inline-edit" class="inline-edit-row" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange"> |
538 | 538 | |
539 | 539 | <fieldset><div class="inline-edit-col"> |
540 | - <h4><?php _e( 'Quick Edit' ); ?></h4> |
|
540 | + <h4><?php _e('Quick Edit'); ?></h4> |
|
541 | 541 | |
542 | 542 | <label> |
543 | - <span class="title"><?php _ex( 'Name', 'term name' ); ?></span> |
|
543 | + <span class="title"><?php _ex('Name', 'term name'); ?></span> |
|
544 | 544 | <span class="input-text-wrap"><input type="text" name="name" class="ptitle" value="" /></span> |
545 | 545 | </label> |
546 | - <?php if ( !global_terms_enabled() ) { ?> |
|
546 | + <?php if ( ! global_terms_enabled()) { ?> |
|
547 | 547 | <label> |
548 | - <span class="title"><?php _e( 'Slug' ); ?></span> |
|
548 | + <span class="title"><?php _e('Slug'); ?></span> |
|
549 | 549 | <span class="input-text-wrap"><input type="text" name="slug" class="ptitle" value="" /></span> |
550 | 550 | </label> |
551 | 551 | <?php } ?> |
552 | 552 | </div></fieldset> |
553 | 553 | <?php |
554 | 554 | |
555 | - $core_columns = array( 'cb' => true, 'description' => true, 'name' => true, 'slug' => true, 'posts' => true ); |
|
555 | + $core_columns = array('cb' => true, 'description' => true, 'name' => true, 'slug' => true, 'posts' => true); |
|
556 | 556 | |
557 | - list( $columns ) = $this->get_column_info(); |
|
557 | + list($columns) = $this->get_column_info(); |
|
558 | 558 | |
559 | - foreach ( $columns as $column_name => $column_display_name ) { |
|
560 | - if ( isset( $core_columns[$column_name] ) ) |
|
559 | + foreach ($columns as $column_name => $column_display_name) { |
|
560 | + if (isset($core_columns[$column_name])) |
|
561 | 561 | continue; |
562 | 562 | |
563 | 563 | /** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */ |
564 | - do_action( 'quick_edit_custom_box', $column_name, 'edit-tags', $this->screen->taxonomy ); |
|
564 | + do_action('quick_edit_custom_box', $column_name, 'edit-tags', $this->screen->taxonomy); |
|
565 | 565 | } |
566 | 566 | |
567 | 567 | ?> |
568 | 568 | |
569 | 569 | <p class="inline-edit-save submit"> |
570 | - <a href="#inline-edit" class="cancel button-secondary alignleft"><?php _e( 'Cancel' ); ?></a> |
|
570 | + <a href="#inline-edit" class="cancel button-secondary alignleft"><?php _e('Cancel'); ?></a> |
|
571 | 571 | <a href="#inline-edit" class="save button-primary alignright"><?php echo $tax->labels->update_item; ?></a> |
572 | 572 | <span class="spinner"></span> |
573 | 573 | <span class="error" style="display:none;"></span> |
574 | - <?php wp_nonce_field( 'taxinlineeditnonce', '_inline_edit', false ); ?> |
|
575 | - <input type="hidden" name="taxonomy" value="<?php echo esc_attr( $this->screen->taxonomy ); ?>" /> |
|
576 | - <input type="hidden" name="post_type" value="<?php echo esc_attr( $this->screen->post_type ); ?>" /> |
|
574 | + <?php wp_nonce_field('taxinlineeditnonce', '_inline_edit', false); ?> |
|
575 | + <input type="hidden" name="taxonomy" value="<?php echo esc_attr($this->screen->taxonomy); ?>" /> |
|
576 | + <input type="hidden" name="post_type" value="<?php echo esc_attr($this->screen->post_type); ?>" /> |
|
577 | 577 | <br class="clear" /> |
578 | 578 | </p> |
579 | 579 | </td></tr> |
@@ -41,17 +41,20 @@ discard block |
||
41 | 41 | $post_type = $this->screen->post_type; |
42 | 42 | $taxonomy = $this->screen->taxonomy; |
43 | 43 | |
44 | - if ( empty( $taxonomy ) ) |
|
45 | - $taxonomy = 'post_tag'; |
|
44 | + if ( empty( $taxonomy ) ) { |
|
45 | + $taxonomy = 'post_tag'; |
|
46 | + } |
|
46 | 47 | |
47 | - if ( ! taxonomy_exists( $taxonomy ) ) |
|
48 | - wp_die( __( 'Invalid taxonomy' ) ); |
|
48 | + if ( ! taxonomy_exists( $taxonomy ) ) { |
|
49 | + wp_die( __( 'Invalid taxonomy' ) ); |
|
50 | + } |
|
49 | 51 | |
50 | 52 | $tax = get_taxonomy( $taxonomy ); |
51 | 53 | |
52 | 54 | // @todo Still needed? Maybe just the show_ui part. |
53 | - if ( empty( $post_type ) || !in_array( $post_type, get_post_types( array( 'show_ui' => true ) ) ) ) |
|
54 | - $post_type = 'post'; |
|
55 | + if ( empty( $post_type ) || !in_array( $post_type, get_post_types( array( 'show_ui' => true ) ) ) ) { |
|
56 | + $post_type = 'post'; |
|
57 | + } |
|
55 | 58 | |
56 | 59 | } |
57 | 60 | |
@@ -107,11 +110,13 @@ discard block |
||
107 | 110 | 'number' => $tags_per_page, |
108 | 111 | ); |
109 | 112 | |
110 | - if ( !empty( $_REQUEST['orderby'] ) ) |
|
111 | - $args['orderby'] = trim( wp_unslash( $_REQUEST['orderby'] ) ); |
|
113 | + if ( !empty( $_REQUEST['orderby'] ) ) { |
|
114 | + $args['orderby'] = trim( wp_unslash( $_REQUEST['orderby'] ) ); |
|
115 | + } |
|
112 | 116 | |
113 | - if ( !empty( $_REQUEST['order'] ) ) |
|
114 | - $args['order'] = trim( wp_unslash( $_REQUEST['order'] ) ); |
|
117 | + if ( !empty( $_REQUEST['order'] ) ) { |
|
118 | + $args['order'] = trim( wp_unslash( $_REQUEST['order'] ) ); |
|
119 | + } |
|
115 | 120 | |
116 | 121 | $this->callback_args = $args; |
117 | 122 | |
@@ -153,8 +158,9 @@ discard block |
||
153 | 158 | * @return string |
154 | 159 | */ |
155 | 160 | public function current_action() { |
156 | - if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && ( 'delete' == $_REQUEST['action'] || 'delete' == $_REQUEST['action2'] ) ) |
|
157 | - return 'bulk-delete'; |
|
161 | + if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && ( 'delete' == $_REQUEST['action'] || 'delete' == $_REQUEST['action2'] ) ) { |
|
162 | + return 'bulk-delete'; |
|
163 | + } |
|
158 | 164 | |
159 | 165 | return parent::current_action(); |
160 | 166 | } |
@@ -261,11 +267,13 @@ discard block |
||
261 | 267 | |
262 | 268 | foreach ( $terms as $key => $term ) { |
263 | 269 | |
264 | - if ( $count >= $end ) |
|
265 | - break; |
|
270 | + if ( $count >= $end ) { |
|
271 | + break; |
|
272 | + } |
|
266 | 273 | |
267 | - if ( $term->parent != $parent && empty( $_REQUEST['s'] ) ) |
|
268 | - continue; |
|
274 | + if ( $term->parent != $parent && empty( $_REQUEST['s'] ) ) { |
|
275 | + continue; |
|
276 | + } |
|
269 | 277 | |
270 | 278 | // If the page starts in a subtree, print the parents. |
271 | 279 | if ( $count == $start && $term->parent > 0 && empty( $_REQUEST['s'] ) ) { |
@@ -275,8 +283,10 @@ discard block |
||
275 | 283 | $my_parent = get_term( $p, $taxonomy ); |
276 | 284 | $my_parents[] = $my_parent; |
277 | 285 | $p = $my_parent->parent; |
278 | - if ( in_array( $p, $parent_ids ) ) // Prevent parent loops. |
|
286 | + if ( in_array( $p, $parent_ids ) ) { |
|
287 | + // Prevent parent loops. |
|
279 | 288 | break; |
289 | + } |
|
280 | 290 | $parent_ids[] = $p; |
281 | 291 | } |
282 | 292 | unset( $parent_ids ); |
@@ -298,8 +308,9 @@ discard block |
||
298 | 308 | |
299 | 309 | unset( $terms[$key] ); |
300 | 310 | |
301 | - if ( isset( $children[$term->term_id] ) && empty( $_REQUEST['s'] ) ) |
|
302 | - $this->_rows( $taxonomy, $terms, $children, $start, $per_page, $count, $term->term_id, $level + 1 ); |
|
311 | + if ( isset( $children[$term->term_id] ) && empty( $_REQUEST['s'] ) ) { |
|
312 | + $this->_rows( $taxonomy, $terms, $children, $start, $per_page, $count, $term->term_id, $level + 1 ); |
|
313 | + } |
|
303 | 314 | } |
304 | 315 | } |
305 | 316 | |
@@ -326,9 +337,10 @@ discard block |
||
326 | 337 | public function column_cb( $tag ) { |
327 | 338 | $default_term = get_option( 'default_' . $this->screen->taxonomy ); |
328 | 339 | |
329 | - if ( current_user_can( get_taxonomy( $this->screen->taxonomy )->cap->delete_terms ) && $tag->term_id != $default_term ) |
|
330 | - return '<label class="screen-reader-text" for="cb-select-' . $tag->term_id . '">' . sprintf( __( 'Select %s' ), $tag->name ) . '</label>' |
|
340 | + if ( current_user_can( get_taxonomy( $this->screen->taxonomy )->cap->delete_terms ) && $tag->term_id != $default_term ) { |
|
341 | + return '<label class="screen-reader-text" for="cb-select-' . $tag->term_id . '">' . sprintf( __( 'Select %s' ), $tag->name ) . '</label>' |
|
331 | 342 | . '<input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" id="cb-select-' . $tag->term_id . '" />'; |
343 | + } |
|
332 | 344 | |
333 | 345 | return ' '; |
334 | 346 | } |
@@ -411,10 +423,12 @@ discard block |
||
411 | 423 | $actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>'; |
412 | 424 | $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __( 'Quick Edit' ) . '</a>'; |
413 | 425 | } |
414 | - if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term ) |
|
415 | - $actions['delete'] = "<a class='delete-tag' href='" . wp_nonce_url( "edit-tags.php?action=delete&taxonomy=$taxonomy&tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id ) . "'>" . __( 'Delete' ) . "</a>"; |
|
416 | - if ( $tax->public ) |
|
417 | - $actions['view'] = '<a href="' . get_term_link( $tag ) . '">' . __( 'View' ) . '</a>'; |
|
426 | + if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term ) { |
|
427 | + $actions['delete'] = "<a class='delete-tag' href='" . wp_nonce_url( "edit-tags.php?action=delete&taxonomy=$taxonomy&tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id ) . "'>" . __( 'Delete' ) . "</a>"; |
|
428 | + } |
|
429 | + if ( $tax->public ) { |
|
430 | + $actions['view'] = '<a href="' . get_term_link( $tag ) . '">' . __( 'View' ) . '</a>'; |
|
431 | + } |
|
418 | 432 | |
419 | 433 | /** |
420 | 434 | * Filter the action links displayed for each term in the Tags list table. |
@@ -471,8 +485,9 @@ discard block |
||
471 | 485 | $tax = get_taxonomy( $this->screen->taxonomy ); |
472 | 486 | |
473 | 487 | $ptype_object = get_post_type_object( $this->screen->post_type ); |
474 | - if ( ! $ptype_object->show_ui ) |
|
475 | - return $count; |
|
488 | + if ( ! $ptype_object->show_ui ) { |
|
489 | + return $count; |
|
490 | + } |
|
476 | 491 | |
477 | 492 | if ( $tax->query_var ) { |
478 | 493 | $args = array( $tax->query_var => $tag->slug ); |
@@ -480,11 +495,13 @@ discard block |
||
480 | 495 | $args = array( 'taxonomy' => $tax->name, 'term' => $tag->slug ); |
481 | 496 | } |
482 | 497 | |
483 | - if ( 'post' != $this->screen->post_type ) |
|
484 | - $args['post_type'] = $this->screen->post_type; |
|
498 | + if ( 'post' != $this->screen->post_type ) { |
|
499 | + $args['post_type'] = $this->screen->post_type; |
|
500 | + } |
|
485 | 501 | |
486 | - if ( 'attachment' == $this->screen->post_type ) |
|
487 | - return "<a href='" . esc_url ( add_query_arg( $args, 'upload.php' ) ) . "'>$count</a>"; |
|
502 | + if ( 'attachment' == $this->screen->post_type ) { |
|
503 | + return "<a href='" . esc_url ( add_query_arg( $args, 'upload.php' ) ) . "'>$count</a>"; |
|
504 | + } |
|
488 | 505 | |
489 | 506 | return "<a href='" . esc_url ( add_query_arg( $args, 'edit.php' ) ) . "'>$count</a>"; |
490 | 507 | } |
@@ -495,8 +512,9 @@ discard block |
||
495 | 512 | */ |
496 | 513 | public function column_links( $tag ) { |
497 | 514 | $count = number_format_i18n( $tag->count ); |
498 | - if ( $count ) |
|
499 | - $count = "<a href='link-manager.php?cat_id=$tag->term_id'>$count</a>"; |
|
515 | + if ( $count ) { |
|
516 | + $count = "<a href='link-manager.php?cat_id=$tag->term_id'>$count</a>"; |
|
517 | + } |
|
500 | 518 | return $count; |
501 | 519 | } |
502 | 520 | |
@@ -529,9 +547,10 @@ discard block |
||
529 | 547 | public function inline_edit() { |
530 | 548 | $tax = get_taxonomy( $this->screen->taxonomy ); |
531 | 549 | |
532 | - if ( ! current_user_can( $tax->cap->edit_terms ) ) |
|
533 | - return; |
|
534 | -?> |
|
550 | + if ( ! current_user_can( $tax->cap->edit_terms ) ) { |
|
551 | + return; |
|
552 | + } |
|
553 | + ?> |
|
535 | 554 | |
536 | 555 | <form method="get"><table style="display: none"><tbody id="inlineedit"> |
537 | 556 | <tr id="inline-edit" class="inline-edit-row" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange"> |
@@ -557,8 +576,9 @@ discard block |
||
557 | 576 | list( $columns ) = $this->get_column_info(); |
558 | 577 | |
559 | 578 | foreach ( $columns as $column_name => $column_display_name ) { |
560 | - if ( isset( $core_columns[$column_name] ) ) |
|
561 | - continue; |
|
579 | + if ( isset( $core_columns[$column_name] ) ) { |
|
580 | + continue; |
|
581 | + } |
|
562 | 582 | |
563 | 583 | /** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */ |
564 | 584 | do_action( 'quick_edit_custom_box', $column_name, 'edit-tags', $this->screen->taxonomy ); |
@@ -38,15 +38,15 @@ discard block |
||
38 | 38 | protected function get_installed_plugin_slugs() { |
39 | 39 | $slugs = array(); |
40 | 40 | |
41 | - $plugin_info = get_site_transient( 'update_plugins' ); |
|
42 | - if ( isset( $plugin_info->no_update ) ) { |
|
43 | - foreach ( $plugin_info->no_update as $plugin ) { |
|
41 | + $plugin_info = get_site_transient('update_plugins'); |
|
42 | + if (isset($plugin_info->no_update)) { |
|
43 | + foreach ($plugin_info->no_update as $plugin) { |
|
44 | 44 | $slugs[] = $plugin->slug; |
45 | 45 | } |
46 | 46 | } |
47 | 47 | |
48 | - if ( isset( $plugin_info->response ) ) { |
|
49 | - foreach ( $plugin_info->response as $plugin ) { |
|
48 | + if (isset($plugin_info->response)) { |
|
49 | + foreach ($plugin_info->response as $plugin) { |
|
50 | 50 | $slugs[] = $plugin->slug; |
51 | 51 | } |
52 | 52 | } |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | * @global string $wp_version |
65 | 65 | */ |
66 | 66 | public function prepare_items() { |
67 | - include( ABSPATH . 'wp-admin/includes/plugin-install.php' ); |
|
67 | + include(ABSPATH.'wp-admin/includes/plugin-install.php'); |
|
68 | 68 | |
69 | 69 | global $tabs, $tab, $paged, $type, $term; |
70 | 70 | |
71 | - wp_reset_vars( array( 'tab' ) ); |
|
71 | + wp_reset_vars(array('tab')); |
|
72 | 72 | |
73 | 73 | $paged = $this->get_pagenum(); |
74 | 74 | |
@@ -77,22 +77,22 @@ discard block |
||
77 | 77 | // These are the tabs which are shown on the page |
78 | 78 | $tabs = array(); |
79 | 79 | |
80 | - if ( 'search' == $tab ) |
|
81 | - $tabs['search'] = __( 'Search Results' ); |
|
82 | - $tabs['featured'] = _x( 'Featured', 'Plugin Installer' ); |
|
83 | - $tabs['popular'] = _x( 'Popular', 'Plugin Installer' ); |
|
84 | - $tabs['recommended'] = _x( 'Recommended', 'Plugin Installer' ); |
|
85 | - $tabs['favorites'] = _x( 'Favorites', 'Plugin Installer' ); |
|
86 | - if ( $tab === 'beta' || false !== strpos( $GLOBALS['wp_version'], '-' ) ) { |
|
87 | - $tabs['beta'] = _x( 'Beta Testing', 'Plugin Installer' ); |
|
80 | + if ('search' == $tab) |
|
81 | + $tabs['search'] = __('Search Results'); |
|
82 | + $tabs['featured'] = _x('Featured', 'Plugin Installer'); |
|
83 | + $tabs['popular'] = _x('Popular', 'Plugin Installer'); |
|
84 | + $tabs['recommended'] = _x('Recommended', 'Plugin Installer'); |
|
85 | + $tabs['favorites'] = _x('Favorites', 'Plugin Installer'); |
|
86 | + if ($tab === 'beta' || false !== strpos($GLOBALS['wp_version'], '-')) { |
|
87 | + $tabs['beta'] = _x('Beta Testing', 'Plugin Installer'); |
|
88 | 88 | } |
89 | - if ( current_user_can( 'upload_plugins' ) ) { |
|
89 | + if (current_user_can('upload_plugins')) { |
|
90 | 90 | // No longer a real tab. Here for filter compatibility. |
91 | 91 | // Gets skipped in get_views(). |
92 | - $tabs['upload'] = __( 'Upload Plugin' ); |
|
92 | + $tabs['upload'] = __('Upload Plugin'); |
|
93 | 93 | } |
94 | 94 | |
95 | - $nonmenu_tabs = array( 'plugin-information' ); // Valid actions to perform which do not have a Menu item. |
|
95 | + $nonmenu_tabs = array('plugin-information'); // Valid actions to perform which do not have a Menu item. |
|
96 | 96 | |
97 | 97 | /** |
98 | 98 | * Filter the tabs shown on the Plugin Install screen. |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @param array $tabs The tabs shown on the Plugin Install screen. Defaults include 'featured', 'popular', |
103 | 103 | * 'recommended', 'favorites', and 'upload'. |
104 | 104 | */ |
105 | - $tabs = apply_filters( 'install_plugins_tabs', $tabs ); |
|
105 | + $tabs = apply_filters('install_plugins_tabs', $tabs); |
|
106 | 106 | |
107 | 107 | /** |
108 | 108 | * Filter tabs not associated with a menu item on the Plugin Install screen. |
@@ -111,11 +111,11 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @param array $nonmenu_tabs The tabs that don't have a Menu item on the Plugin Install screen. |
113 | 113 | */ |
114 | - $nonmenu_tabs = apply_filters( 'install_plugins_nonmenu_tabs', $nonmenu_tabs ); |
|
114 | + $nonmenu_tabs = apply_filters('install_plugins_nonmenu_tabs', $nonmenu_tabs); |
|
115 | 115 | |
116 | 116 | // If a non-valid menu tab has been selected, And it's not a non-menu action. |
117 | - if ( empty( $tab ) || ( !isset( $tabs[ $tab ] ) && !in_array( $tab, (array) $nonmenu_tabs ) ) ) |
|
118 | - $tab = key( $tabs ); |
|
117 | + if (empty($tab) || ( ! isset($tabs[$tab]) && ! in_array($tab, (array) $nonmenu_tabs))) |
|
118 | + $tab = key($tabs); |
|
119 | 119 | |
120 | 120 | $args = array( |
121 | 121 | 'page' => $paged, |
@@ -130,14 +130,14 @@ discard block |
||
130 | 130 | 'installed_plugins' => $this->get_installed_plugin_slugs(), |
131 | 131 | ); |
132 | 132 | |
133 | - switch ( $tab ) { |
|
133 | + switch ($tab) { |
|
134 | 134 | case 'search': |
135 | - $type = isset( $_REQUEST['type'] ) ? wp_unslash( $_REQUEST['type'] ) : 'term'; |
|
136 | - $term = isset( $_REQUEST['s'] ) ? wp_unslash( $_REQUEST['s'] ) : ''; |
|
135 | + $type = isset($_REQUEST['type']) ? wp_unslash($_REQUEST['type']) : 'term'; |
|
136 | + $term = isset($_REQUEST['s']) ? wp_unslash($_REQUEST['s']) : ''; |
|
137 | 137 | |
138 | - switch ( $type ) { |
|
138 | + switch ($type) { |
|
139 | 139 | case 'tag': |
140 | - $args['tag'] = sanitize_title_with_dashes( $term ); |
|
140 | + $args['tag'] = sanitize_title_with_dashes($term); |
|
141 | 141 | break; |
142 | 142 | case 'term': |
143 | 143 | $args['search'] = $term; |
@@ -161,14 +161,14 @@ discard block |
||
161 | 161 | break; |
162 | 162 | |
163 | 163 | case 'favorites': |
164 | - $user = isset( $_GET['user'] ) ? wp_unslash( $_GET['user'] ) : get_user_option( 'wporg_favorites' ); |
|
165 | - update_user_meta( get_current_user_id(), 'wporg_favorites', $user ); |
|
166 | - if ( $user ) |
|
164 | + $user = isset($_GET['user']) ? wp_unslash($_GET['user']) : get_user_option('wporg_favorites'); |
|
165 | + update_user_meta(get_current_user_id(), 'wporg_favorites', $user); |
|
166 | + if ($user) |
|
167 | 167 | $args['user'] = $user; |
168 | 168 | else |
169 | 169 | $args = false; |
170 | 170 | |
171 | - add_action( 'install_plugins_favorites', 'install_plugins_favorites_form', 9, 0 ); |
|
171 | + add_action('install_plugins_favorites', 'install_plugins_favorites_form', 9, 0); |
|
172 | 172 | break; |
173 | 173 | |
174 | 174 | default: |
@@ -186,30 +186,30 @@ discard block |
||
186 | 186 | * |
187 | 187 | * @param array|bool $args Plugin Install API arguments. |
188 | 188 | */ |
189 | - $args = apply_filters( "install_plugins_table_api_args_$tab", $args ); |
|
189 | + $args = apply_filters("install_plugins_table_api_args_$tab", $args); |
|
190 | 190 | |
191 | - if ( !$args ) |
|
191 | + if ( ! $args) |
|
192 | 192 | return; |
193 | 193 | |
194 | - $api = plugins_api( 'query_plugins', $args ); |
|
194 | + $api = plugins_api('query_plugins', $args); |
|
195 | 195 | |
196 | - if ( is_wp_error( $api ) ) { |
|
196 | + if (is_wp_error($api)) { |
|
197 | 197 | $this->error = $api; |
198 | 198 | return; |
199 | 199 | } |
200 | 200 | |
201 | 201 | $this->items = $api->plugins; |
202 | 202 | |
203 | - if ( $this->orderby ) { |
|
204 | - uasort( $this->items, array( $this, 'order_callback' ) ); |
|
203 | + if ($this->orderby) { |
|
204 | + uasort($this->items, array($this, 'order_callback')); |
|
205 | 205 | } |
206 | 206 | |
207 | - $this->set_pagination_args( array( |
|
207 | + $this->set_pagination_args(array( |
|
208 | 208 | 'total_items' => $api->info['results'], |
209 | 209 | 'per_page' => $args['per_page'], |
210 | - ) ); |
|
210 | + )); |
|
211 | 211 | |
212 | - if ( isset( $api->info['groups'] ) ) { |
|
212 | + if (isset($api->info['groups'])) { |
|
213 | 213 | $this->groups = $api->info['groups']; |
214 | 214 | } |
215 | 215 | } |
@@ -218,12 +218,12 @@ discard block |
||
218 | 218 | * @access public |
219 | 219 | */ |
220 | 220 | public function no_items() { |
221 | - if ( isset( $this->error ) ) { |
|
222 | - $message = $this->error->get_error_message() . '<p class="hide-if-no-js"><a href="#" class="button" onclick="document.location.reload(); return false;">' . __( 'Try again' ) . '</a></p>'; |
|
221 | + if (isset($this->error)) { |
|
222 | + $message = $this->error->get_error_message().'<p class="hide-if-no-js"><a href="#" class="button" onclick="document.location.reload(); return false;">'.__('Try again').'</a></p>'; |
|
223 | 223 | } else { |
224 | - $message = __( 'No plugins match your request.' ); |
|
224 | + $message = __('No plugins match your request.'); |
|
225 | 225 | } |
226 | - echo '<div class="no-plugin-results">' . $message . '</div>'; |
|
226 | + echo '<div class="no-plugin-results">'.$message.'</div>'; |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
@@ -237,13 +237,13 @@ discard block |
||
237 | 237 | global $tabs, $tab; |
238 | 238 | |
239 | 239 | $display_tabs = array(); |
240 | - foreach ( (array) $tabs as $action => $text ) { |
|
241 | - $class = ( $action == $tab ) ? ' current' : ''; |
|
242 | - $href = self_admin_url('plugin-install.php?tab=' . $action); |
|
240 | + foreach ((array) $tabs as $action => $text) { |
|
241 | + $class = ($action == $tab) ? ' current' : ''; |
|
242 | + $href = self_admin_url('plugin-install.php?tab='.$action); |
|
243 | 243 | $display_tabs['plugin-install-'.$action] = "<a href='$href' class='$class'>$text</a>"; |
244 | 244 | } |
245 | 245 | // No longer a real tab. |
246 | - unset( $display_tabs['plugin-install-upload'] ); |
|
246 | + unset($display_tabs['plugin-install-upload']); |
|
247 | 247 | |
248 | 248 | return $display_tabs; |
249 | 249 | } |
@@ -255,22 +255,22 @@ discard block |
||
255 | 255 | $views = $this->get_views(); |
256 | 256 | |
257 | 257 | /** This filter is documented in wp-admin/inclues/class-wp-list-table.php */ |
258 | - $views = apply_filters( "views_{$this->screen->id}", $views ); |
|
258 | + $views = apply_filters("views_{$this->screen->id}", $views); |
|
259 | 259 | |
260 | 260 | ?> |
261 | 261 | <div class="wp-filter"> |
262 | 262 | <ul class="filter-links"> |
263 | 263 | <?php |
264 | - if ( ! empty( $views ) ) { |
|
265 | - foreach ( $views as $class => $view ) { |
|
266 | - $views[ $class ] = "\t<li class='$class'>$view"; |
|
264 | + if ( ! empty($views)) { |
|
265 | + foreach ($views as $class => $view) { |
|
266 | + $views[$class] = "\t<li class='$class'>$view"; |
|
267 | 267 | } |
268 | - echo implode( " </li>\n", $views ) . "</li>\n"; |
|
268 | + echo implode(" </li>\n", $views)."</li>\n"; |
|
269 | 269 | } |
270 | 270 | ?> |
271 | 271 | </ul> |
272 | 272 | |
273 | - <?php install_search_form( isset( $views['plugin-install-search'] ) ); ?> |
|
273 | + <?php install_search_form(isset($views['plugin-install-search'])); ?> |
|
274 | 274 | </div> |
275 | 275 | <?php |
276 | 276 | } |
@@ -283,21 +283,21 @@ discard block |
||
283 | 283 | |
284 | 284 | $data_attr = ''; |
285 | 285 | |
286 | - if ( $singular ) { |
|
286 | + if ($singular) { |
|
287 | 287 | $data_attr = " data-wp-lists='list:$singular'"; |
288 | 288 | } |
289 | 289 | |
290 | - $this->display_tablenav( 'top' ); |
|
290 | + $this->display_tablenav('top'); |
|
291 | 291 | |
292 | 292 | ?> |
293 | -<div class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>"> |
|
293 | +<div class="wp-list-table <?php echo implode(' ', $this->get_table_classes()); ?>"> |
|
294 | 294 | |
295 | 295 | <div id="the-list"<?php echo $data_attr; ?>> |
296 | 296 | <?php $this->display_rows_or_placeholder(); ?> |
297 | 297 | </div> |
298 | 298 | </div> |
299 | 299 | <?php |
300 | - $this->display_tablenav( 'bottom' ); |
|
300 | + $this->display_tablenav('bottom'); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | /** |
@@ -305,12 +305,12 @@ discard block |
||
305 | 305 | * |
306 | 306 | * @param string $which |
307 | 307 | */ |
308 | - protected function display_tablenav( $which ) { |
|
309 | - if ( $GLOBALS['tab'] === 'featured' ) { |
|
308 | + protected function display_tablenav($which) { |
|
309 | + if ($GLOBALS['tab'] === 'featured') { |
|
310 | 310 | return; |
311 | 311 | } |
312 | 312 | |
313 | - if ( 'top' == $which ) { |
|
313 | + if ('top' == $which) { |
|
314 | 314 | wp_referer_field(); |
315 | 315 | ?> |
316 | 316 | <div class="tablenav top"> |
@@ -321,14 +321,14 @@ discard block |
||
321 | 321 | * |
322 | 322 | * @since 2.7.0 |
323 | 323 | */ |
324 | - do_action( 'install_plugins_table_header' ); ?> |
|
324 | + do_action('install_plugins_table_header'); ?> |
|
325 | 325 | </div> |
326 | - <?php $this->pagination( $which ); ?> |
|
326 | + <?php $this->pagination($which); ?> |
|
327 | 327 | <br class="clear" /> |
328 | 328 | </div> |
329 | 329 | <?php } else { ?> |
330 | 330 | <div class="tablenav bottom"> |
331 | - <?php $this->pagination( $which ); ?> |
|
331 | + <?php $this->pagination($which); ?> |
|
332 | 332 | <br class="clear" /> |
333 | 333 | </div> |
334 | 334 | <?php |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | * @return array |
340 | 340 | */ |
341 | 341 | protected function get_table_classes() { |
342 | - return array( 'widefat', $this->_args['plural'] ); |
|
342 | + return array('widefat', $this->_args['plural']); |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | /** |
@@ -354,23 +354,23 @@ discard block |
||
354 | 354 | * @param object $plugin_b |
355 | 355 | * @return int |
356 | 356 | */ |
357 | - private function order_callback( $plugin_a, $plugin_b ) { |
|
357 | + private function order_callback($plugin_a, $plugin_b) { |
|
358 | 358 | $orderby = $this->orderby; |
359 | - if ( ! isset( $plugin_a->$orderby, $plugin_b->$orderby ) ) { |
|
359 | + if ( ! isset($plugin_a->$orderby, $plugin_b->$orderby)) { |
|
360 | 360 | return 0; |
361 | 361 | } |
362 | 362 | |
363 | 363 | $a = $plugin_a->$orderby; |
364 | 364 | $b = $plugin_b->$orderby; |
365 | 365 | |
366 | - if ( $a == $b ) { |
|
366 | + if ($a == $b) { |
|
367 | 367 | return 0; |
368 | 368 | } |
369 | 369 | |
370 | - if ( 'DESC' == $this->order ) { |
|
371 | - return ( $a < $b ) ? 1 : -1; |
|
370 | + if ('DESC' == $this->order) { |
|
371 | + return ($a < $b) ? 1 : -1; |
|
372 | 372 | } else { |
373 | - return ( $a < $b ) ? -1 : 1; |
|
373 | + return ($a < $b) ? -1 : 1; |
|
374 | 374 | } |
375 | 375 | } |
376 | 376 | |
@@ -379,98 +379,98 @@ discard block |
||
379 | 379 | */ |
380 | 380 | public function display_rows() { |
381 | 381 | $plugins_allowedtags = array( |
382 | - 'a' => array( 'href' => array(),'title' => array(), 'target' => array() ), |
|
383 | - 'abbr' => array( 'title' => array() ),'acronym' => array( 'title' => array() ), |
|
384 | - 'code' => array(), 'pre' => array(), 'em' => array(),'strong' => array(), |
|
382 | + 'a' => array('href' => array(), 'title' => array(), 'target' => array()), |
|
383 | + 'abbr' => array('title' => array()), 'acronym' => array('title' => array()), |
|
384 | + 'code' => array(), 'pre' => array(), 'em' => array(), 'strong' => array(), |
|
385 | 385 | 'ul' => array(), 'ol' => array(), 'li' => array(), 'p' => array(), 'br' => array() |
386 | 386 | ); |
387 | 387 | |
388 | 388 | $plugins_group_titles = array( |
389 | - 'Performance' => _x( 'Performance', 'Plugin installer group title' ), |
|
390 | - 'Social' => _x( 'Social', 'Plugin installer group title' ), |
|
391 | - 'Tools' => _x( 'Tools', 'Plugin installer group title' ), |
|
389 | + 'Performance' => _x('Performance', 'Plugin installer group title'), |
|
390 | + 'Social' => _x('Social', 'Plugin installer group title'), |
|
391 | + 'Tools' => _x('Tools', 'Plugin installer group title'), |
|
392 | 392 | ); |
393 | 393 | |
394 | 394 | $group = null; |
395 | 395 | |
396 | - foreach ( (array) $this->items as $plugin ) { |
|
397 | - if ( is_object( $plugin ) ) { |
|
396 | + foreach ((array) $this->items as $plugin) { |
|
397 | + if (is_object($plugin)) { |
|
398 | 398 | $plugin = (array) $plugin; |
399 | 399 | } |
400 | 400 | |
401 | 401 | // Display the group heading if there is one |
402 | - if ( isset( $plugin['group'] ) && $plugin['group'] != $group ) { |
|
403 | - if ( isset( $this->groups[ $plugin['group'] ] ) ) { |
|
404 | - $group_name = $this->groups[ $plugin['group'] ]; |
|
405 | - if ( isset( $plugins_group_titles[ $group_name ] ) ) { |
|
406 | - $group_name = $plugins_group_titles[ $group_name ]; |
|
402 | + if (isset($plugin['group']) && $plugin['group'] != $group) { |
|
403 | + if (isset($this->groups[$plugin['group']])) { |
|
404 | + $group_name = $this->groups[$plugin['group']]; |
|
405 | + if (isset($plugins_group_titles[$group_name])) { |
|
406 | + $group_name = $plugins_group_titles[$group_name]; |
|
407 | 407 | } |
408 | 408 | } else { |
409 | 409 | $group_name = $plugin['group']; |
410 | 410 | } |
411 | 411 | |
412 | 412 | // Starting a new group, close off the divs of the last one |
413 | - if ( ! empty( $group ) ) { |
|
413 | + if ( ! empty($group)) { |
|
414 | 414 | echo '</div></div>'; |
415 | 415 | } |
416 | 416 | |
417 | - echo '<div class="plugin-group"><h3>' . esc_html( $group_name ) . '</h3>'; |
|
417 | + echo '<div class="plugin-group"><h3>'.esc_html($group_name).'</h3>'; |
|
418 | 418 | // needs an extra wrapping div for nth-child selectors to work |
419 | 419 | echo '<div class="plugin-items">'; |
420 | 420 | |
421 | 421 | $group = $plugin['group']; |
422 | 422 | } |
423 | - $title = wp_kses( $plugin['name'], $plugins_allowedtags ); |
|
423 | + $title = wp_kses($plugin['name'], $plugins_allowedtags); |
|
424 | 424 | |
425 | 425 | // Remove any HTML from the description. |
426 | - $description = strip_tags( $plugin['short_description'] ); |
|
427 | - $version = wp_kses( $plugin['version'], $plugins_allowedtags ); |
|
426 | + $description = strip_tags($plugin['short_description']); |
|
427 | + $version = wp_kses($plugin['version'], $plugins_allowedtags); |
|
428 | 428 | |
429 | - $name = strip_tags( $title . ' ' . $version ); |
|
429 | + $name = strip_tags($title.' '.$version); |
|
430 | 430 | |
431 | - $author = wp_kses( $plugin['author'], $plugins_allowedtags ); |
|
432 | - if ( ! empty( $author ) ) { |
|
433 | - $author = ' <cite>' . sprintf( __( 'By %s' ), $author ) . '</cite>'; |
|
431 | + $author = wp_kses($plugin['author'], $plugins_allowedtags); |
|
432 | + if ( ! empty($author)) { |
|
433 | + $author = ' <cite>'.sprintf(__('By %s'), $author).'</cite>'; |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | $action_links = array(); |
437 | 437 | |
438 | - if ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) { |
|
439 | - $status = install_plugin_install_status( $plugin ); |
|
438 | + if (current_user_can('install_plugins') || current_user_can('update_plugins')) { |
|
439 | + $status = install_plugin_install_status($plugin); |
|
440 | 440 | |
441 | - switch ( $status['status'] ) { |
|
441 | + switch ($status['status']) { |
|
442 | 442 | case 'install': |
443 | - if ( $status['url'] ) { |
|
443 | + if ($status['url']) { |
|
444 | 444 | /* translators: 1: Plugin name and version. */ |
445 | - $action_links[] = '<a class="install-now button" data-slug="' . esc_attr( $plugin['slug'] ) . '" href="' . esc_url( $status['url'] ) . '" aria-label="' . esc_attr( sprintf( __( 'Install %s now' ), $name ) ) . '" data-name="' . esc_attr( $name ) . '">' . __( 'Install Now' ) . '</a>'; |
|
445 | + $action_links[] = '<a class="install-now button" data-slug="'.esc_attr($plugin['slug']).'" href="'.esc_url($status['url']).'" aria-label="'.esc_attr(sprintf(__('Install %s now'), $name)).'" data-name="'.esc_attr($name).'">'.__('Install Now').'</a>'; |
|
446 | 446 | } |
447 | 447 | |
448 | 448 | break; |
449 | 449 | case 'update_available': |
450 | - if ( $status['url'] ) { |
|
450 | + if ($status['url']) { |
|
451 | 451 | /* translators: 1: Plugin name and version */ |
452 | - $action_links[] = '<a class="update-now button" data-plugin="' . esc_attr( $status['file'] ) . '" data-slug="' . esc_attr( $plugin['slug'] ) . '" href="' . esc_url( $status['url'] ) . '" aria-label="' . esc_attr( sprintf( __( 'Update %s now' ), $name ) ) . '" data-name="' . esc_attr( $name ) . '">' . __( 'Update Now' ) . '</a>'; |
|
452 | + $action_links[] = '<a class="update-now button" data-plugin="'.esc_attr($status['file']).'" data-slug="'.esc_attr($plugin['slug']).'" href="'.esc_url($status['url']).'" aria-label="'.esc_attr(sprintf(__('Update %s now'), $name)).'" data-name="'.esc_attr($name).'">'.__('Update Now').'</a>'; |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | break; |
456 | 456 | case 'latest_installed': |
457 | 457 | case 'newer_installed': |
458 | - $action_links[] = '<span class="button button-disabled" title="' . esc_attr__( 'This plugin is already installed and is up to date' ) . ' ">' . _x( 'Installed', 'plugin' ) . '</span>'; |
|
458 | + $action_links[] = '<span class="button button-disabled" title="'.esc_attr__('This plugin is already installed and is up to date').' ">'._x('Installed', 'plugin').'</span>'; |
|
459 | 459 | break; |
460 | 460 | } |
461 | 461 | } |
462 | 462 | |
463 | - $details_link = self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $plugin['slug'] . |
|
464 | - '&TB_iframe=true&width=600&height=550' ); |
|
463 | + $details_link = self_admin_url('plugin-install.php?tab=plugin-information&plugin='.$plugin['slug']. |
|
464 | + '&TB_iframe=true&width=600&height=550'); |
|
465 | 465 | |
466 | 466 | /* translators: 1: Plugin name and version. */ |
467 | - $action_links[] = '<a href="' . esc_url( $details_link ) . '" class="thickbox" aria-label="' . esc_attr( sprintf( __( 'More information about %s' ), $name ) ) . '" data-title="' . esc_attr( $name ) . '">' . __( 'More Details' ) . '</a>'; |
|
467 | + $action_links[] = '<a href="'.esc_url($details_link).'" class="thickbox" aria-label="'.esc_attr(sprintf(__('More information about %s'), $name)).'" data-title="'.esc_attr($name).'">'.__('More Details').'</a>'; |
|
468 | 468 | |
469 | - if ( !empty( $plugin['icons']['svg'] ) ) { |
|
469 | + if ( ! empty($plugin['icons']['svg'])) { |
|
470 | 470 | $plugin_icon_url = $plugin['icons']['svg']; |
471 | - } elseif ( !empty( $plugin['icons']['2x'] ) ) { |
|
471 | + } elseif ( ! empty($plugin['icons']['2x'])) { |
|
472 | 472 | $plugin_icon_url = $plugin['icons']['2x']; |
473 | - } elseif ( !empty( $plugin['icons']['1x'] ) ) { |
|
473 | + } elseif ( ! empty($plugin['icons']['1x'])) { |
|
474 | 474 | $plugin_icon_url = $plugin['icons']['1x']; |
475 | 475 | } else { |
476 | 476 | $plugin_icon_url = $plugin['icons']['default']; |
@@ -484,21 +484,21 @@ discard block |
||
484 | 484 | * @param array $action_links An array of plugin action hyperlinks. Defaults are links to Details and Install Now. |
485 | 485 | * @param array $plugin The plugin currently being listed. |
486 | 486 | */ |
487 | - $action_links = apply_filters( 'plugin_install_action_links', $action_links, $plugin ); |
|
487 | + $action_links = apply_filters('plugin_install_action_links', $action_links, $plugin); |
|
488 | 488 | |
489 | - $date_format = __( 'M j, Y @ H:i' ); |
|
490 | - $last_updated_timestamp = strtotime( $plugin['last_updated'] ); |
|
489 | + $date_format = __('M j, Y @ H:i'); |
|
490 | + $last_updated_timestamp = strtotime($plugin['last_updated']); |
|
491 | 491 | ?> |
492 | - <div class="plugin-card plugin-card-<?php echo sanitize_html_class( $plugin['slug'] ); ?>"> |
|
492 | + <div class="plugin-card plugin-card-<?php echo sanitize_html_class($plugin['slug']); ?>"> |
|
493 | 493 | <div class="plugin-card-top"> |
494 | - <a href="<?php echo esc_url( $details_link ); ?>" class="thickbox plugin-icon"><img src="<?php echo esc_attr( $plugin_icon_url ) ?>" /></a> |
|
494 | + <a href="<?php echo esc_url($details_link); ?>" class="thickbox plugin-icon"><img src="<?php echo esc_attr($plugin_icon_url) ?>" /></a> |
|
495 | 495 | <div class="name column-name"> |
496 | - <h4><a href="<?php echo esc_url( $details_link ); ?>" class="thickbox"><?php echo $title; ?></a></h4> |
|
496 | + <h4><a href="<?php echo esc_url($details_link); ?>" class="thickbox"><?php echo $title; ?></a></h4> |
|
497 | 497 | </div> |
498 | 498 | <div class="action-links"> |
499 | 499 | <?php |
500 | - if ( $action_links ) { |
|
501 | - echo '<ul class="plugin-action-buttons"><li>' . implode( '</li><li>', $action_links ) . '</li></ul>'; |
|
500 | + if ($action_links) { |
|
501 | + echo '<ul class="plugin-action-buttons"><li>'.implode('</li><li>', $action_links).'</li></ul>'; |
|
502 | 502 | } |
503 | 503 | ?> |
504 | 504 | </div> |
@@ -509,32 +509,32 @@ discard block |
||
509 | 509 | </div> |
510 | 510 | <div class="plugin-card-bottom"> |
511 | 511 | <div class="vers column-rating"> |
512 | - <?php wp_star_rating( array( 'rating' => $plugin['rating'], 'type' => 'percent', 'number' => $plugin['num_ratings'] ) ); ?> |
|
513 | - <span class="num-ratings">(<?php echo number_format_i18n( $plugin['num_ratings'] ); ?>)</span> |
|
512 | + <?php wp_star_rating(array('rating' => $plugin['rating'], 'type' => 'percent', 'number' => $plugin['num_ratings'])); ?> |
|
513 | + <span class="num-ratings">(<?php echo number_format_i18n($plugin['num_ratings']); ?>)</span> |
|
514 | 514 | </div> |
515 | 515 | <div class="column-updated"> |
516 | - <strong><?php _e( 'Last Updated:' ); ?></strong> <span title="<?php echo esc_attr( date_i18n( $date_format, $last_updated_timestamp ) ); ?>"> |
|
517 | - <?php printf( __( '%s ago' ), human_time_diff( $last_updated_timestamp ) ); ?> |
|
516 | + <strong><?php _e('Last Updated:'); ?></strong> <span title="<?php echo esc_attr(date_i18n($date_format, $last_updated_timestamp)); ?>"> |
|
517 | + <?php printf(__('%s ago'), human_time_diff($last_updated_timestamp)); ?> |
|
518 | 518 | </span> |
519 | 519 | </div> |
520 | 520 | <div class="column-downloaded"> |
521 | 521 | <?php |
522 | - if ( $plugin['active_installs'] >= 1000000 ) { |
|
523 | - $active_installs_text = _x( '1+ Million', 'Active plugin installs' ); |
|
522 | + if ($plugin['active_installs'] >= 1000000) { |
|
523 | + $active_installs_text = _x('1+ Million', 'Active plugin installs'); |
|
524 | 524 | } else { |
525 | - $active_installs_text = number_format_i18n( $plugin['active_installs'] ) . '+'; |
|
525 | + $active_installs_text = number_format_i18n($plugin['active_installs']).'+'; |
|
526 | 526 | } |
527 | - printf( __( '%s Active Installs' ), $active_installs_text ); |
|
527 | + printf(__('%s Active Installs'), $active_installs_text); |
|
528 | 528 | ?> |
529 | 529 | </div> |
530 | 530 | <div class="column-compatibility"> |
531 | 531 | <?php |
532 | - if ( ! empty( $plugin['tested'] ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $plugin['tested'] ) ), $plugin['tested'], '>' ) ) { |
|
533 | - echo '<span class="compatibility-untested">' . __( 'Untested with your version of WordPress' ) . '</span>'; |
|
534 | - } elseif ( ! empty( $plugin['requires'] ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $plugin['requires'] ) ), $plugin['requires'], '<' ) ) { |
|
535 | - echo '<span class="compatibility-incompatible">' . __( '<strong>Incompatible</strong> with your version of WordPress' ) . '</span>'; |
|
532 | + if ( ! empty($plugin['tested']) && version_compare(substr($GLOBALS['wp_version'], 0, strlen($plugin['tested'])), $plugin['tested'], '>')) { |
|
533 | + echo '<span class="compatibility-untested">'.__('Untested with your version of WordPress').'</span>'; |
|
534 | + } elseif ( ! empty($plugin['requires']) && version_compare(substr($GLOBALS['wp_version'], 0, strlen($plugin['requires'])), $plugin['requires'], '<')) { |
|
535 | + echo '<span class="compatibility-incompatible">'.__('<strong>Incompatible</strong> with your version of WordPress').'</span>'; |
|
536 | 536 | } else { |
537 | - echo '<span class="compatibility-compatible">' . __( '<strong>Compatible</strong> with your version of WordPress' ) . '</span>'; |
|
537 | + echo '<span class="compatibility-compatible">'.__('<strong>Compatible</strong> with your version of WordPress').'</span>'; |
|
538 | 538 | } |
539 | 539 | ?> |
540 | 540 | </div> |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | } |
545 | 545 | |
546 | 546 | // Close off the group divs of the last one |
547 | - if ( ! empty( $group ) ) { |
|
547 | + if ( ! empty($group)) { |
|
548 | 548 | echo '</div></div>'; |
549 | 549 | } |
550 | 550 | } |
@@ -77,8 +77,9 @@ discard block |
||
77 | 77 | // These are the tabs which are shown on the page |
78 | 78 | $tabs = array(); |
79 | 79 | |
80 | - if ( 'search' == $tab ) |
|
81 | - $tabs['search'] = __( 'Search Results' ); |
|
80 | + if ( 'search' == $tab ) { |
|
81 | + $tabs['search'] = __( 'Search Results' ); |
|
82 | + } |
|
82 | 83 | $tabs['featured'] = _x( 'Featured', 'Plugin Installer' ); |
83 | 84 | $tabs['popular'] = _x( 'Popular', 'Plugin Installer' ); |
84 | 85 | $tabs['recommended'] = _x( 'Recommended', 'Plugin Installer' ); |
@@ -114,8 +115,9 @@ discard block |
||
114 | 115 | $nonmenu_tabs = apply_filters( 'install_plugins_nonmenu_tabs', $nonmenu_tabs ); |
115 | 116 | |
116 | 117 | // If a non-valid menu tab has been selected, And it's not a non-menu action. |
117 | - if ( empty( $tab ) || ( !isset( $tabs[ $tab ] ) && !in_array( $tab, (array) $nonmenu_tabs ) ) ) |
|
118 | - $tab = key( $tabs ); |
|
118 | + if ( empty( $tab ) || ( !isset( $tabs[ $tab ] ) && !in_array( $tab, (array) $nonmenu_tabs ) ) ) { |
|
119 | + $tab = key( $tabs ); |
|
120 | + } |
|
119 | 121 | |
120 | 122 | $args = array( |
121 | 123 | 'page' => $paged, |
@@ -163,10 +165,11 @@ discard block |
||
163 | 165 | case 'favorites': |
164 | 166 | $user = isset( $_GET['user'] ) ? wp_unslash( $_GET['user'] ) : get_user_option( 'wporg_favorites' ); |
165 | 167 | update_user_meta( get_current_user_id(), 'wporg_favorites', $user ); |
166 | - if ( $user ) |
|
167 | - $args['user'] = $user; |
|
168 | - else |
|
169 | - $args = false; |
|
168 | + if ( $user ) { |
|
169 | + $args['user'] = $user; |
|
170 | + } else { |
|
171 | + $args = false; |
|
172 | + } |
|
170 | 173 | |
171 | 174 | add_action( 'install_plugins_favorites', 'install_plugins_favorites_form', 9, 0 ); |
172 | 175 | break; |
@@ -188,8 +191,9 @@ discard block |
||
188 | 191 | */ |
189 | 192 | $args = apply_filters( "install_plugins_table_api_args_$tab", $args ); |
190 | 193 | |
191 | - if ( !$args ) |
|
192 | - return; |
|
194 | + if ( !$args ) { |
|
195 | + return; |
|
196 | + } |
|
193 | 197 | |
194 | 198 | $api = plugins_api( 'query_plugins', $args ); |
195 | 199 |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Includes all of the WordPress Administration API files. |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Administration |
|
7 | - */ |
|
3 | + * Includes all of the WordPress Administration API files. |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Administration |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | if ( ! defined('WP_ADMIN') ) { |
10 | 10 | /* |
@@ -6,76 +6,76 @@ |
||
6 | 6 | * @subpackage Administration |
7 | 7 | */ |
8 | 8 | |
9 | -if ( ! defined('WP_ADMIN') ) { |
|
9 | +if ( ! defined('WP_ADMIN')) { |
|
10 | 10 | /* |
11 | 11 | * This file is being included from a file other than wp-admin/admin.php, so |
12 | 12 | * some setup was skipped. Make sure the admin message catalog is loaded since |
13 | 13 | * load_default_textdomain() will not have done so in this context. |
14 | 14 | */ |
15 | - load_textdomain( 'default', WP_LANG_DIR . '/admin-' . get_locale() . '.mo' ); |
|
15 | + load_textdomain('default', WP_LANG_DIR.'/admin-'.get_locale().'.mo'); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | /** WordPress Administration Hooks */ |
19 | -require_once(ABSPATH . 'wp-admin/includes/admin-filters.php'); |
|
19 | +require_once(ABSPATH.'wp-admin/includes/admin-filters.php'); |
|
20 | 20 | |
21 | 21 | /** WordPress Bookmark Administration API */ |
22 | -require_once(ABSPATH . 'wp-admin/includes/bookmark.php'); |
|
22 | +require_once(ABSPATH.'wp-admin/includes/bookmark.php'); |
|
23 | 23 | |
24 | 24 | /** WordPress Comment Administration API */ |
25 | -require_once(ABSPATH . 'wp-admin/includes/comment.php'); |
|
25 | +require_once(ABSPATH.'wp-admin/includes/comment.php'); |
|
26 | 26 | |
27 | 27 | /** WordPress Administration File API */ |
28 | -require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
28 | +require_once(ABSPATH.'wp-admin/includes/file.php'); |
|
29 | 29 | |
30 | 30 | /** WordPress Image Administration API */ |
31 | -require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
31 | +require_once(ABSPATH.'wp-admin/includes/image.php'); |
|
32 | 32 | |
33 | 33 | /** WordPress Media Administration API */ |
34 | -require_once(ABSPATH . 'wp-admin/includes/media.php'); |
|
34 | +require_once(ABSPATH.'wp-admin/includes/media.php'); |
|
35 | 35 | |
36 | 36 | /** WordPress Import Administration API */ |
37 | -require_once(ABSPATH . 'wp-admin/includes/import.php'); |
|
37 | +require_once(ABSPATH.'wp-admin/includes/import.php'); |
|
38 | 38 | |
39 | 39 | /** WordPress Misc Administration API */ |
40 | -require_once(ABSPATH . 'wp-admin/includes/misc.php'); |
|
40 | +require_once(ABSPATH.'wp-admin/includes/misc.php'); |
|
41 | 41 | |
42 | 42 | /** WordPress Plugin Administration API */ |
43 | -require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
43 | +require_once(ABSPATH.'wp-admin/includes/plugin.php'); |
|
44 | 44 | |
45 | 45 | /** WordPress Post Administration API */ |
46 | -require_once(ABSPATH . 'wp-admin/includes/post.php'); |
|
46 | +require_once(ABSPATH.'wp-admin/includes/post.php'); |
|
47 | 47 | |
48 | 48 | /** WordPress Administration Screen API */ |
49 | -require_once(ABSPATH . 'wp-admin/includes/screen.php'); |
|
49 | +require_once(ABSPATH.'wp-admin/includes/screen.php'); |
|
50 | 50 | |
51 | 51 | /** WordPress Taxonomy Administration API */ |
52 | -require_once(ABSPATH . 'wp-admin/includes/taxonomy.php'); |
|
52 | +require_once(ABSPATH.'wp-admin/includes/taxonomy.php'); |
|
53 | 53 | |
54 | 54 | /** WordPress Template Administration API */ |
55 | -require_once(ABSPATH . 'wp-admin/includes/template.php'); |
|
55 | +require_once(ABSPATH.'wp-admin/includes/template.php'); |
|
56 | 56 | |
57 | 57 | /** WordPress List Table Administration API and base class */ |
58 | -require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php'); |
|
59 | -require_once(ABSPATH . 'wp-admin/includes/list-table.php'); |
|
58 | +require_once(ABSPATH.'wp-admin/includes/class-wp-list-table.php'); |
|
59 | +require_once(ABSPATH.'wp-admin/includes/list-table.php'); |
|
60 | 60 | |
61 | 61 | /** WordPress Theme Administration API */ |
62 | -require_once(ABSPATH . 'wp-admin/includes/theme.php'); |
|
62 | +require_once(ABSPATH.'wp-admin/includes/theme.php'); |
|
63 | 63 | |
64 | 64 | /** WordPress User Administration API */ |
65 | -require_once(ABSPATH . 'wp-admin/includes/user.php'); |
|
65 | +require_once(ABSPATH.'wp-admin/includes/user.php'); |
|
66 | 66 | |
67 | 67 | /** WordPress Site Icon API */ |
68 | -require_once(ABSPATH . 'wp-admin/includes/class-wp-site-icon.php'); |
|
68 | +require_once(ABSPATH.'wp-admin/includes/class-wp-site-icon.php'); |
|
69 | 69 | |
70 | 70 | /** WordPress Update Administration API */ |
71 | -require_once(ABSPATH . 'wp-admin/includes/update.php'); |
|
71 | +require_once(ABSPATH.'wp-admin/includes/update.php'); |
|
72 | 72 | |
73 | 73 | /** WordPress Deprecated Administration API */ |
74 | -require_once(ABSPATH . 'wp-admin/includes/deprecated.php'); |
|
74 | +require_once(ABSPATH.'wp-admin/includes/deprecated.php'); |
|
75 | 75 | |
76 | 76 | /** WordPress Multisite support API */ |
77 | -if ( is_multisite() ) { |
|
78 | - require_once(ABSPATH . 'wp-admin/includes/ms-admin-filters.php'); |
|
79 | - require_once(ABSPATH . 'wp-admin/includes/ms.php'); |
|
80 | - require_once(ABSPATH . 'wp-admin/includes/ms-deprecated.php'); |
|
77 | +if (is_multisite()) { |
|
78 | + require_once(ABSPATH.'wp-admin/includes/ms-admin-filters.php'); |
|
79 | + require_once(ABSPATH.'wp-admin/includes/ms.php'); |
|
80 | + require_once(ABSPATH.'wp-admin/includes/ms-deprecated.php'); |
|
81 | 81 | } |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * WordPress Taxonomy Administration API. |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Administration |
|
7 | - */ |
|
3 | + * WordPress Taxonomy Administration API. |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Administration |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | // |
10 | 10 | // Category |
@@ -21,9 +21,9 @@ discard block |
||
21 | 21 | * @param int $parent Optional. ID of parent term. |
22 | 22 | * @return mixed |
23 | 23 | */ |
24 | -function category_exists( $cat_name, $parent = null ) { |
|
24 | +function category_exists($cat_name, $parent = null) { |
|
25 | 25 | $id = term_exists($cat_name, 'category', $parent); |
26 | - if ( is_array($id) ) |
|
26 | + if (is_array($id)) |
|
27 | 27 | $id = $id['term_id']; |
28 | 28 | return $id; |
29 | 29 | } |
@@ -36,9 +36,9 @@ discard block |
||
36 | 36 | * @param int $id |
37 | 37 | * @return object |
38 | 38 | */ |
39 | -function get_category_to_edit( $id ) { |
|
40 | - $category = get_term( $id, 'category', OBJECT, 'edit' ); |
|
41 | - _make_cat_compat( $category ); |
|
39 | +function get_category_to_edit($id) { |
|
40 | + $category = get_term($id, 'category', OBJECT, 'edit'); |
|
41 | + _make_cat_compat($category); |
|
42 | 42 | return $category; |
43 | 43 | } |
44 | 44 | |
@@ -51,11 +51,11 @@ discard block |
||
51 | 51 | * @param int $parent |
52 | 52 | * @return int|WP_Error |
53 | 53 | */ |
54 | -function wp_create_category( $cat_name, $parent = 0 ) { |
|
55 | - if ( $id = category_exists($cat_name, $parent) ) |
|
54 | +function wp_create_category($cat_name, $parent = 0) { |
|
55 | + if ($id = category_exists($cat_name, $parent)) |
|
56 | 56 | return $id; |
57 | 57 | |
58 | - return wp_insert_category( array('cat_name' => $cat_name, 'category_parent' => $parent) ); |
|
58 | + return wp_insert_category(array('cat_name' => $cat_name, 'category_parent' => $parent)); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -67,17 +67,17 @@ discard block |
||
67 | 67 | * @param int $post_id Optional. The post ID. Default empty. |
68 | 68 | * @return List of categories to create for the given post. |
69 | 69 | */ |
70 | -function wp_create_categories( $categories, $post_id = '' ) { |
|
71 | - $cat_ids = array (); |
|
72 | - foreach ( $categories as $category ) { |
|
73 | - if ( $id = category_exists( $category ) ) { |
|
70 | +function wp_create_categories($categories, $post_id = '') { |
|
71 | + $cat_ids = array(); |
|
72 | + foreach ($categories as $category) { |
|
73 | + if ($id = category_exists($category)) { |
|
74 | 74 | $cat_ids[] = $id; |
75 | - } elseif ( $id = wp_create_category( $category ) ) { |
|
75 | + } elseif ($id = wp_create_category($category)) { |
|
76 | 76 | $cat_ids[] = $id; |
77 | 77 | } |
78 | 78 | } |
79 | 79 | |
80 | - if ( $post_id ) |
|
80 | + if ($post_id) |
|
81 | 81 | wp_set_post_categories($post_id, $cat_ids); |
82 | 82 | |
83 | 83 | return $cat_ids; |
@@ -105,47 +105,47 @@ discard block |
||
105 | 105 | * @return int|object The ID number of the new or updated Category on success. Zero or a WP_Error on failure, |
106 | 106 | * depending on param $wp_error. |
107 | 107 | */ |
108 | -function wp_insert_category( $catarr, $wp_error = false ) { |
|
109 | - $cat_defaults = array( 'cat_ID' => 0, 'taxonomy' => 'category', 'cat_name' => '', 'category_description' => '', 'category_nicename' => '', 'category_parent' => '' ); |
|
110 | - $catarr = wp_parse_args( $catarr, $cat_defaults ); |
|
108 | +function wp_insert_category($catarr, $wp_error = false) { |
|
109 | + $cat_defaults = array('cat_ID' => 0, 'taxonomy' => 'category', 'cat_name' => '', 'category_description' => '', 'category_nicename' => '', 'category_parent' => ''); |
|
110 | + $catarr = wp_parse_args($catarr, $cat_defaults); |
|
111 | 111 | |
112 | - if ( trim( $catarr['cat_name'] ) == '' ) { |
|
113 | - if ( ! $wp_error ) { |
|
112 | + if (trim($catarr['cat_name']) == '') { |
|
113 | + if ( ! $wp_error) { |
|
114 | 114 | return 0; |
115 | 115 | } else { |
116 | - return new WP_Error( 'cat_name', __( 'You did not enter a category name.' ) ); |
|
116 | + return new WP_Error('cat_name', __('You did not enter a category name.')); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | |
120 | 120 | $catarr['cat_ID'] = (int) $catarr['cat_ID']; |
121 | 121 | |
122 | 122 | // Are we updating or creating? |
123 | - $update = ! empty ( $catarr['cat_ID'] ); |
|
123 | + $update = ! empty ($catarr['cat_ID']); |
|
124 | 124 | |
125 | 125 | $name = $catarr['cat_name']; |
126 | 126 | $description = $catarr['category_description']; |
127 | 127 | $slug = $catarr['category_nicename']; |
128 | 128 | $parent = (int) $catarr['category_parent']; |
129 | - if ( $parent < 0 ) { |
|
129 | + if ($parent < 0) { |
|
130 | 130 | $parent = 0; |
131 | 131 | } |
132 | 132 | |
133 | - if ( empty( $parent ) |
|
134 | - || ! term_exists( $parent, $catarr['taxonomy'] ) |
|
135 | - || ( $catarr['cat_ID'] && term_is_ancestor_of( $catarr['cat_ID'], $parent, $catarr['taxonomy'] ) ) ) { |
|
133 | + if (empty($parent) |
|
134 | + || ! term_exists($parent, $catarr['taxonomy']) |
|
135 | + || ($catarr['cat_ID'] && term_is_ancestor_of($catarr['cat_ID'], $parent, $catarr['taxonomy']))) { |
|
136 | 136 | $parent = 0; |
137 | 137 | } |
138 | 138 | |
139 | 139 | $args = compact('name', 'slug', 'parent', 'description'); |
140 | 140 | |
141 | - if ( $update ) { |
|
142 | - $catarr['cat_ID'] = wp_update_term( $catarr['cat_ID'], $catarr['taxonomy'], $args ); |
|
141 | + if ($update) { |
|
142 | + $catarr['cat_ID'] = wp_update_term($catarr['cat_ID'], $catarr['taxonomy'], $args); |
|
143 | 143 | } else { |
144 | - $catarr['cat_ID'] = wp_insert_term( $catarr['cat_name'], $catarr['taxonomy'], $args ); |
|
144 | + $catarr['cat_ID'] = wp_insert_term($catarr['cat_name'], $catarr['taxonomy'], $args); |
|
145 | 145 | } |
146 | 146 | |
147 | - if ( is_wp_error( $catarr['cat_ID'] ) ) { |
|
148 | - if ( $wp_error ) { |
|
147 | + if (is_wp_error($catarr['cat_ID'])) { |
|
148 | + if ($wp_error) { |
|
149 | 149 | return $catarr['cat_ID']; |
150 | 150 | } else { |
151 | 151 | return 0; |
@@ -168,12 +168,12 @@ discard block |
||
168 | 168 | function wp_update_category($catarr) { |
169 | 169 | $cat_ID = (int) $catarr['cat_ID']; |
170 | 170 | |
171 | - if ( isset($catarr['category_parent']) && ($cat_ID == $catarr['category_parent']) ) |
|
171 | + if (isset($catarr['category_parent']) && ($cat_ID == $catarr['category_parent'])) |
|
172 | 172 | return false; |
173 | 173 | |
174 | 174 | // First, get all of the original fields |
175 | - $category = get_term( $cat_ID, 'category', ARRAY_A ); |
|
176 | - _make_cat_compat( $category ); |
|
175 | + $category = get_term($cat_ID, 'category', ARRAY_A); |
|
176 | + _make_cat_compat($category); |
|
177 | 177 | |
178 | 178 | // Escape data pulled from DB. |
179 | 179 | $category = wp_slash($category); |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * @return array|WP_Error |
210 | 210 | */ |
211 | 211 | function wp_create_tag($tag_name) { |
212 | - return wp_create_term( $tag_name, 'post_tag'); |
|
212 | + return wp_create_term($tag_name, 'post_tag'); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
@@ -221,8 +221,8 @@ discard block |
||
221 | 221 | * @param string $taxonomy Optional. The taxonomy for which to retrieve terms. Default 'post_tag'. |
222 | 222 | * @return string|bool|WP_Error |
223 | 223 | */ |
224 | -function get_tags_to_edit( $post_id, $taxonomy = 'post_tag' ) { |
|
225 | - return get_terms_to_edit( $post_id, $taxonomy); |
|
224 | +function get_tags_to_edit($post_id, $taxonomy = 'post_tag') { |
|
225 | + return get_terms_to_edit($post_id, $taxonomy); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | /** |
@@ -234,29 +234,29 @@ discard block |
||
234 | 234 | * @param string $taxonomy Optional. The taxonomy for which to retrieve terms. Default 'post_tag'. |
235 | 235 | * @return string|bool|WP_Error |
236 | 236 | */ |
237 | -function get_terms_to_edit( $post_id, $taxonomy = 'post_tag' ) { |
|
237 | +function get_terms_to_edit($post_id, $taxonomy = 'post_tag') { |
|
238 | 238 | $post_id = (int) $post_id; |
239 | - if ( !$post_id ) |
|
239 | + if ( ! $post_id) |
|
240 | 240 | return false; |
241 | 241 | |
242 | - $terms = get_object_term_cache( $post_id, $taxonomy ); |
|
243 | - if ( false === $terms ) { |
|
244 | - $terms = wp_get_object_terms( $post_id, $taxonomy ); |
|
245 | - wp_cache_add( $post_id, $terms, $taxonomy . '_relationships' ); |
|
242 | + $terms = get_object_term_cache($post_id, $taxonomy); |
|
243 | + if (false === $terms) { |
|
244 | + $terms = wp_get_object_terms($post_id, $taxonomy); |
|
245 | + wp_cache_add($post_id, $terms, $taxonomy.'_relationships'); |
|
246 | 246 | } |
247 | 247 | |
248 | - if ( ! $terms ) { |
|
248 | + if ( ! $terms) { |
|
249 | 249 | return false; |
250 | 250 | } |
251 | - if ( is_wp_error( $terms ) ) { |
|
251 | + if (is_wp_error($terms)) { |
|
252 | 252 | return $terms; |
253 | 253 | } |
254 | 254 | $term_names = array(); |
255 | - foreach ( $terms as $term ) { |
|
255 | + foreach ($terms as $term) { |
|
256 | 256 | $term_names[] = $term->name; |
257 | 257 | } |
258 | 258 | |
259 | - $terms_to_edit = esc_attr( join( ',', $term_names ) ); |
|
259 | + $terms_to_edit = esc_attr(join(',', $term_names)); |
|
260 | 260 | |
261 | 261 | /** |
262 | 262 | * Filter the comma-separated list of terms available to edit. |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | * @param array $terms_to_edit An array of terms. |
269 | 269 | * @param string $taxonomy The taxonomy for which to retrieve terms. Default 'post_tag'. |
270 | 270 | */ |
271 | - $terms_to_edit = apply_filters( 'terms_to_edit', $terms_to_edit, $taxonomy ); |
|
271 | + $terms_to_edit = apply_filters('terms_to_edit', $terms_to_edit, $taxonomy); |
|
272 | 272 | |
273 | 273 | return $terms_to_edit; |
274 | 274 | } |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | * @return array|WP_Error |
284 | 284 | */ |
285 | 285 | function wp_create_term($tag_name, $taxonomy = 'post_tag') { |
286 | - if ( $id = term_exists($tag_name, $taxonomy) ) |
|
286 | + if ($id = term_exists($tag_name, $taxonomy)) |
|
287 | 287 | return $id; |
288 | 288 | |
289 | 289 | return wp_insert_term($tag_name, $taxonomy); |
@@ -23,8 +23,9 @@ discard block |
||
23 | 23 | */ |
24 | 24 | function category_exists( $cat_name, $parent = null ) { |
25 | 25 | $id = term_exists($cat_name, 'category', $parent); |
26 | - if ( is_array($id) ) |
|
27 | - $id = $id['term_id']; |
|
26 | + if ( is_array($id) ) { |
|
27 | + $id = $id['term_id']; |
|
28 | + } |
|
28 | 29 | return $id; |
29 | 30 | } |
30 | 31 | |
@@ -52,8 +53,9 @@ discard block |
||
52 | 53 | * @return int|WP_Error |
53 | 54 | */ |
54 | 55 | function wp_create_category( $cat_name, $parent = 0 ) { |
55 | - if ( $id = category_exists($cat_name, $parent) ) |
|
56 | - return $id; |
|
56 | + if ( $id = category_exists($cat_name, $parent) ) { |
|
57 | + return $id; |
|
58 | + } |
|
57 | 59 | |
58 | 60 | return wp_insert_category( array('cat_name' => $cat_name, 'category_parent' => $parent) ); |
59 | 61 | } |
@@ -77,8 +79,9 @@ discard block |
||
77 | 79 | } |
78 | 80 | } |
79 | 81 | |
80 | - if ( $post_id ) |
|
81 | - wp_set_post_categories($post_id, $cat_ids); |
|
82 | + if ( $post_id ) { |
|
83 | + wp_set_post_categories($post_id, $cat_ids); |
|
84 | + } |
|
82 | 85 | |
83 | 86 | return $cat_ids; |
84 | 87 | } |
@@ -168,8 +171,9 @@ discard block |
||
168 | 171 | function wp_update_category($catarr) { |
169 | 172 | $cat_ID = (int) $catarr['cat_ID']; |
170 | 173 | |
171 | - if ( isset($catarr['category_parent']) && ($cat_ID == $catarr['category_parent']) ) |
|
172 | - return false; |
|
174 | + if ( isset($catarr['category_parent']) && ($cat_ID == $catarr['category_parent']) ) { |
|
175 | + return false; |
|
176 | + } |
|
173 | 177 | |
174 | 178 | // First, get all of the original fields |
175 | 179 | $category = get_term( $cat_ID, 'category', ARRAY_A ); |
@@ -236,8 +240,9 @@ discard block |
||
236 | 240 | */ |
237 | 241 | function get_terms_to_edit( $post_id, $taxonomy = 'post_tag' ) { |
238 | 242 | $post_id = (int) $post_id; |
239 | - if ( !$post_id ) |
|
240 | - return false; |
|
243 | + if ( !$post_id ) { |
|
244 | + return false; |
|
245 | + } |
|
241 | 246 | |
242 | 247 | $terms = get_object_term_cache( $post_id, $taxonomy ); |
243 | 248 | if ( false === $terms ) { |
@@ -283,8 +288,9 @@ discard block |
||
283 | 288 | * @return array|WP_Error |
284 | 289 | */ |
285 | 290 | function wp_create_term($tag_name, $taxonomy = 'post_tag') { |
286 | - if ( $id = term_exists($tag_name, $taxonomy) ) |
|
287 | - return $id; |
|
291 | + if ( $id = term_exists($tag_name, $taxonomy) ) { |
|
292 | + return $id; |
|
293 | + } |
|
288 | 294 | |
289 | 295 | return wp_insert_term($tag_name, $taxonomy); |
290 | 296 | } |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Links Manager List Table class. |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage List_Table |
|
7 | - * @since 3.1.0 |
|
8 | - * @access private |
|
9 | - */ |
|
3 | + * Links Manager List Table class. |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage List_Table |
|
7 | + * @since 3.1.0 |
|
8 | + * @access private |
|
9 | + */ |
|
10 | 10 | class WP_Links_List_Table extends WP_List_Table { |
11 | 11 | |
12 | 12 | /** |
@@ -19,11 +19,11 @@ discard block |
||
19 | 19 | * |
20 | 20 | * @param array $args An associative array of arguments. |
21 | 21 | */ |
22 | - public function __construct( $args = array() ) { |
|
23 | - parent::__construct( array( |
|
22 | + public function __construct($args = array()) { |
|
23 | + parent::__construct(array( |
|
24 | 24 | 'plural' => 'bookmarks', |
25 | - 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
|
26 | - ) ); |
|
25 | + 'screen' => isset($args['screen']) ? $args['screen'] : null, |
|
26 | + )); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @return bool |
32 | 32 | */ |
33 | 33 | public function ajax_user_can() { |
34 | - return current_user_can( 'manage_links' ); |
|
34 | + return current_user_can('manage_links'); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | /** |
@@ -44,27 +44,27 @@ discard block |
||
44 | 44 | public function prepare_items() { |
45 | 45 | global $cat_id, $s, $orderby, $order; |
46 | 46 | |
47 | - wp_reset_vars( array( 'action', 'cat_id', 'link_id', 'orderby', 'order', 's' ) ); |
|
47 | + wp_reset_vars(array('action', 'cat_id', 'link_id', 'orderby', 'order', 's')); |
|
48 | 48 | |
49 | - $args = array( 'hide_invisible' => 0, 'hide_empty' => 0 ); |
|
49 | + $args = array('hide_invisible' => 0, 'hide_empty' => 0); |
|
50 | 50 | |
51 | - if ( 'all' != $cat_id ) |
|
51 | + if ('all' != $cat_id) |
|
52 | 52 | $args['category'] = $cat_id; |
53 | - if ( !empty( $s ) ) |
|
53 | + if ( ! empty($s)) |
|
54 | 54 | $args['search'] = $s; |
55 | - if ( !empty( $orderby ) ) |
|
55 | + if ( ! empty($orderby)) |
|
56 | 56 | $args['orderby'] = $orderby; |
57 | - if ( !empty( $order ) ) |
|
57 | + if ( ! empty($order)) |
|
58 | 58 | $args['order'] = $order; |
59 | 59 | |
60 | - $this->items = get_bookmarks( $args ); |
|
60 | + $this->items = get_bookmarks($args); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
64 | 64 | * @access public |
65 | 65 | */ |
66 | 66 | public function no_items() { |
67 | - _e( 'No links found.' ); |
|
67 | + _e('No links found.'); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | protected function get_bulk_actions() { |
75 | 75 | $actions = array(); |
76 | - $actions['delete'] = __( 'Delete' ); |
|
76 | + $actions['delete'] = __('Delete'); |
|
77 | 77 | |
78 | 78 | return $actions; |
79 | 79 | } |
@@ -83,10 +83,10 @@ discard block |
||
83 | 83 | * @global int $cat_id |
84 | 84 | * @param string $which |
85 | 85 | */ |
86 | - protected function extra_tablenav( $which ) { |
|
86 | + protected function extra_tablenav($which) { |
|
87 | 87 | global $cat_id; |
88 | 88 | |
89 | - if ( 'top' != $which ) |
|
89 | + if ('top' != $which) |
|
90 | 90 | return; |
91 | 91 | ?> |
92 | 92 | <div class="alignleft actions"> |
@@ -95,16 +95,16 @@ discard block |
||
95 | 95 | 'selected' => $cat_id, |
96 | 96 | 'name' => 'cat_id', |
97 | 97 | 'taxonomy' => 'link_category', |
98 | - 'show_option_all' => __( 'All categories' ), |
|
98 | + 'show_option_all' => __('All categories'), |
|
99 | 99 | 'hide_empty' => true, |
100 | 100 | 'hierarchical' => 1, |
101 | 101 | 'show_count' => 0, |
102 | 102 | 'orderby' => 'name', |
103 | 103 | ); |
104 | 104 | |
105 | - echo '<label class="screen-reader-text" for="cat_id">' . __( 'Filter by category' ) . '</label>'; |
|
106 | - wp_dropdown_categories( $dropdown_options ); |
|
107 | - submit_button( __( 'Filter' ), 'button', 'filter_action', false, array( 'id' => 'post-query-submit' ) ); |
|
105 | + echo '<label class="screen-reader-text" for="cat_id">'.__('Filter by category').'</label>'; |
|
106 | + wp_dropdown_categories($dropdown_options); |
|
107 | + submit_button(__('Filter'), 'button', 'filter_action', false, array('id' => 'post-query-submit')); |
|
108 | 108 | ?> |
109 | 109 | </div> |
110 | 110 | <?php |
@@ -117,12 +117,12 @@ discard block |
||
117 | 117 | public function get_columns() { |
118 | 118 | return array( |
119 | 119 | 'cb' => '<input type="checkbox" />', |
120 | - 'name' => _x( 'Name', 'link name' ), |
|
121 | - 'url' => __( 'URL' ), |
|
122 | - 'categories' => __( 'Categories' ), |
|
123 | - 'rel' => __( 'Relationship' ), |
|
124 | - 'visible' => __( 'Visible' ), |
|
125 | - 'rating' => __( 'Rating' ) |
|
120 | + 'name' => _x('Name', 'link name'), |
|
121 | + 'url' => __('URL'), |
|
122 | + 'categories' => __('Categories'), |
|
123 | + 'rel' => __('Relationship'), |
|
124 | + 'visible' => __('Visible'), |
|
125 | + 'rating' => __('Rating') |
|
126 | 126 | ); |
127 | 127 | } |
128 | 128 | |
@@ -159,10 +159,10 @@ discard block |
||
159 | 159 | * |
160 | 160 | * @param object $link The current link object. |
161 | 161 | */ |
162 | - public function column_cb( $link ) { |
|
162 | + public function column_cb($link) { |
|
163 | 163 | ?> |
164 | - <label class="screen-reader-text" for="cb-select-<?php echo $link->link_id; ?>"><?php echo sprintf( __( 'Select %s' ), $link->link_name ); ?></label> |
|
165 | - <input type="checkbox" name="linkcheck[]" id="cb-select-<?php echo $link->link_id; ?>" value="<?php echo esc_attr( $link->link_id ); ?>" /> |
|
164 | + <label class="screen-reader-text" for="cb-select-<?php echo $link->link_id; ?>"><?php echo sprintf(__('Select %s'), $link->link_name); ?></label> |
|
165 | + <input type="checkbox" name="linkcheck[]" id="cb-select-<?php echo $link->link_id; ?>" value="<?php echo esc_attr($link->link_id); ?>" /> |
|
166 | 166 | <?php |
167 | 167 | } |
168 | 168 | |
@@ -174,11 +174,11 @@ discard block |
||
174 | 174 | * |
175 | 175 | * @param object $link The current link object. |
176 | 176 | */ |
177 | - public function column_name( $link ) { |
|
178 | - $edit_link = get_edit_bookmark_link( $link ); |
|
177 | + public function column_name($link) { |
|
178 | + $edit_link = get_edit_bookmark_link($link); |
|
179 | 179 | ?> |
180 | 180 | <strong><a class="row-title" href="<?php echo $edit_link ?>" title="<?php |
181 | - echo esc_attr( sprintf( __( 'Edit “%s”' ), $link->link_name ) ); |
|
181 | + echo esc_attr(sprintf(__('Edit “%s”'), $link->link_name)); |
|
182 | 182 | ?>"><?php echo $link->link_name ?></a></strong><br /> |
183 | 183 | <?php |
184 | 184 | } |
@@ -191,9 +191,9 @@ discard block |
||
191 | 191 | * |
192 | 192 | * @param object $link The current link object. |
193 | 193 | */ |
194 | - public function column_url( $link ) { |
|
195 | - $short_url = url_shorten( $link->link_url ); |
|
196 | - echo "<a href='$link->link_url' title='". esc_attr( sprintf( __( 'Visit %s' ), $link->link_name ) )."'>$short_url</a>"; |
|
194 | + public function column_url($link) { |
|
195 | + $short_url = url_shorten($link->link_url); |
|
196 | + echo "<a href='$link->link_url' title='".esc_attr(sprintf(__('Visit %s'), $link->link_name))."'>$short_url</a>"; |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
@@ -206,22 +206,22 @@ discard block |
||
206 | 206 | * |
207 | 207 | * @param object $link The current link object. |
208 | 208 | */ |
209 | - public function column_categories( $link ) { |
|
209 | + public function column_categories($link) { |
|
210 | 210 | global $cat_id; |
211 | 211 | |
212 | 212 | $cat_names = array(); |
213 | - foreach ( $link->link_category as $category ) { |
|
214 | - $cat = get_term( $category, 'link_category', OBJECT, 'display' ); |
|
215 | - if ( is_wp_error( $cat ) ) { |
|
213 | + foreach ($link->link_category as $category) { |
|
214 | + $cat = get_term($category, 'link_category', OBJECT, 'display'); |
|
215 | + if (is_wp_error($cat)) { |
|
216 | 216 | echo $cat->get_error_message(); |
217 | 217 | } |
218 | 218 | $cat_name = $cat->name; |
219 | - if ( $cat_id != $category ) { |
|
219 | + if ($cat_id != $category) { |
|
220 | 220 | $cat_name = "<a href='link-manager.php?cat_id=$category'>$cat_name</a>"; |
221 | 221 | } |
222 | 222 | $cat_names[] = $cat_name; |
223 | 223 | } |
224 | - echo implode( ', ', $cat_names ); |
|
224 | + echo implode(', ', $cat_names); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | /** |
@@ -232,8 +232,8 @@ discard block |
||
232 | 232 | * |
233 | 233 | * @param object $link The current link object. |
234 | 234 | */ |
235 | - public function column_rel( $link ) { |
|
236 | - echo empty( $link->link_rel ) ? '<br />' : $link->link_rel; |
|
235 | + public function column_rel($link) { |
|
236 | + echo empty($link->link_rel) ? '<br />' : $link->link_rel; |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | /** |
@@ -244,11 +244,11 @@ discard block |
||
244 | 244 | * |
245 | 245 | * @param object $link The current link object. |
246 | 246 | */ |
247 | - public function column_visible( $link ) { |
|
248 | - if ( 'Y' === $link->link_visible ) { |
|
249 | - _e( 'Yes' ); |
|
247 | + public function column_visible($link) { |
|
248 | + if ('Y' === $link->link_visible) { |
|
249 | + _e('Yes'); |
|
250 | 250 | } else { |
251 | - _e( 'No' ); |
|
251 | + _e('No'); |
|
252 | 252 | } |
253 | 253 | } |
254 | 254 | |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | * |
261 | 261 | * @param object $link The current link object. |
262 | 262 | */ |
263 | - public function column_rating( $link ) { |
|
263 | + public function column_rating($link) { |
|
264 | 264 | echo $link->link_rating; |
265 | 265 | } |
266 | 266 | |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | * @param object $link Link object. |
274 | 274 | * @param string $column_name Current column name. |
275 | 275 | */ |
276 | - public function column_default( $link, $column_name ) { |
|
276 | + public function column_default($link, $column_name) { |
|
277 | 277 | /** |
278 | 278 | * Fires for each registered custom link column. |
279 | 279 | * |
@@ -282,17 +282,17 @@ discard block |
||
282 | 282 | * @param string $column_name Name of the custom column. |
283 | 283 | * @param int $link_id Link ID. |
284 | 284 | */ |
285 | - do_action( 'manage_link_custom_column', $column_name, $link->link_id ); |
|
285 | + do_action('manage_link_custom_column', $column_name, $link->link_id); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | public function display_rows() { |
289 | - foreach ( $this->items as $link ) { |
|
290 | - $link = sanitize_bookmark( $link ); |
|
291 | - $link->link_name = esc_attr( $link->link_name ); |
|
292 | - $link->link_category = wp_get_link_cats( $link->link_id ); |
|
289 | + foreach ($this->items as $link) { |
|
290 | + $link = sanitize_bookmark($link); |
|
291 | + $link->link_name = esc_attr($link->link_name); |
|
292 | + $link->link_category = wp_get_link_cats($link->link_id); |
|
293 | 293 | ?> |
294 | 294 | <tr id="link-<?php echo $link->link_id; ?>"> |
295 | - <?php $this->single_row_columns( $link ) ?> |
|
295 | + <?php $this->single_row_columns($link) ?> |
|
296 | 296 | </tr> |
297 | 297 | <?php |
298 | 298 | } |
@@ -309,16 +309,16 @@ discard block |
||
309 | 309 | * @param string $primary Primary column name. |
310 | 310 | * @return string Row action output for links. |
311 | 311 | */ |
312 | - protected function handle_row_actions( $link, $column_name, $primary ) { |
|
313 | - if ( $primary !== $column_name ) { |
|
312 | + protected function handle_row_actions($link, $column_name, $primary) { |
|
313 | + if ($primary !== $column_name) { |
|
314 | 314 | return ''; |
315 | 315 | } |
316 | 316 | |
317 | - $edit_link = get_edit_bookmark_link( $link ); |
|
317 | + $edit_link = get_edit_bookmark_link($link); |
|
318 | 318 | |
319 | 319 | $actions = array(); |
320 | - $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>'; |
|
321 | - $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("link.php?action=delete&link_id=$link->link_id", 'delete-bookmark_' . $link->link_id) . "' onclick=\"if ( confirm( '" . esc_js(sprintf(__("You are about to delete this link '%s'\n 'Cancel' to stop, 'OK' to delete."), $link->link_name)) . "' ) ) { return true;}return false;\">" . __('Delete') . "</a>"; |
|
322 | - return $this->row_actions( $actions ); |
|
320 | + $actions['edit'] = '<a href="'.$edit_link.'">'.__('Edit').'</a>'; |
|
321 | + $actions['delete'] = "<a class='submitdelete' href='".wp_nonce_url("link.php?action=delete&link_id=$link->link_id", 'delete-bookmark_'.$link->link_id)."' onclick=\"if ( confirm( '".esc_js(sprintf(__("You are about to delete this link '%s'\n 'Cancel' to stop, 'OK' to delete."), $link->link_name))."' ) ) { return true;}return false;\">".__('Delete')."</a>"; |
|
322 | + return $this->row_actions($actions); |
|
323 | 323 | } |
324 | 324 | } |
@@ -48,14 +48,18 @@ discard block |
||
48 | 48 | |
49 | 49 | $args = array( 'hide_invisible' => 0, 'hide_empty' => 0 ); |
50 | 50 | |
51 | - if ( 'all' != $cat_id ) |
|
52 | - $args['category'] = $cat_id; |
|
53 | - if ( !empty( $s ) ) |
|
54 | - $args['search'] = $s; |
|
55 | - if ( !empty( $orderby ) ) |
|
56 | - $args['orderby'] = $orderby; |
|
57 | - if ( !empty( $order ) ) |
|
58 | - $args['order'] = $order; |
|
51 | + if ( 'all' != $cat_id ) { |
|
52 | + $args['category'] = $cat_id; |
|
53 | + } |
|
54 | + if ( !empty( $s ) ) { |
|
55 | + $args['search'] = $s; |
|
56 | + } |
|
57 | + if ( !empty( $orderby ) ) { |
|
58 | + $args['orderby'] = $orderby; |
|
59 | + } |
|
60 | + if ( !empty( $order ) ) { |
|
61 | + $args['order'] = $order; |
|
62 | + } |
|
59 | 63 | |
60 | 64 | $this->items = get_bookmarks( $args ); |
61 | 65 | } |
@@ -86,9 +90,10 @@ discard block |
||
86 | 90 | protected function extra_tablenav( $which ) { |
87 | 91 | global $cat_id; |
88 | 92 | |
89 | - if ( 'top' != $which ) |
|
90 | - return; |
|
91 | -?> |
|
93 | + if ( 'top' != $which ) { |
|
94 | + return; |
|
95 | + } |
|
96 | + ?> |
|
92 | 97 | <div class="alignleft actions"> |
93 | 98 | <?php |
94 | 99 | $dropdown_options = array( |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * WordPress Widgets Administration API |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Administration |
|
7 | - */ |
|
3 | + * WordPress Widgets Administration API |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Administration |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Display list of the available widgets. |
@@ -18,34 +18,34 @@ discard block |
||
18 | 18 | global $wp_registered_widgets, $wp_registered_widget_controls; |
19 | 19 | |
20 | 20 | $sort = $wp_registered_widgets; |
21 | - usort( $sort, '_sort_name_callback' ); |
|
21 | + usort($sort, '_sort_name_callback'); |
|
22 | 22 | $done = array(); |
23 | 23 | |
24 | - foreach ( $sort as $widget ) { |
|
25 | - if ( in_array( $widget['callback'], $done, true ) ) // We already showed this multi-widget |
|
24 | + foreach ($sort as $widget) { |
|
25 | + if (in_array($widget['callback'], $done, true)) // We already showed this multi-widget |
|
26 | 26 | continue; |
27 | 27 | |
28 | - $sidebar = is_active_widget( $widget['callback'], $widget['id'], false, false ); |
|
28 | + $sidebar = is_active_widget($widget['callback'], $widget['id'], false, false); |
|
29 | 29 | $done[] = $widget['callback']; |
30 | 30 | |
31 | - if ( ! isset( $widget['params'][0] ) ) |
|
31 | + if ( ! isset($widget['params'][0])) |
|
32 | 32 | $widget['params'][0] = array(); |
33 | 33 | |
34 | - $args = array( 'widget_id' => $widget['id'], 'widget_name' => $widget['name'], '_display' => 'template' ); |
|
34 | + $args = array('widget_id' => $widget['id'], 'widget_name' => $widget['name'], '_display' => 'template'); |
|
35 | 35 | |
36 | - if ( isset($wp_registered_widget_controls[$widget['id']]['id_base']) && isset($widget['params'][0]['number']) ) { |
|
36 | + if (isset($wp_registered_widget_controls[$widget['id']]['id_base']) && isset($widget['params'][0]['number'])) { |
|
37 | 37 | $id_base = $wp_registered_widget_controls[$widget['id']]['id_base']; |
38 | 38 | $args['_temp_id'] = "$id_base-__i__"; |
39 | 39 | $args['_multi_num'] = next_widget_id_number($id_base); |
40 | 40 | $args['_add'] = 'multi'; |
41 | 41 | } else { |
42 | 42 | $args['_add'] = 'single'; |
43 | - if ( $sidebar ) |
|
43 | + if ($sidebar) |
|
44 | 44 | $args['_hide'] = '1'; |
45 | 45 | } |
46 | 46 | |
47 | - $args = wp_list_widget_controls_dynamic_sidebar( array( 0 => $args, 1 => $widget['params'][0] ) ); |
|
48 | - call_user_func_array( 'wp_widget_control', $args ); |
|
47 | + $args = wp_list_widget_controls_dynamic_sidebar(array(0 => $args, 1 => $widget['params'][0])); |
|
48 | + call_user_func_array('wp_widget_control', $args); |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | * |
58 | 58 | * @return int |
59 | 59 | */ |
60 | -function _sort_name_callback( $a, $b ) { |
|
61 | - return strnatcasecmp( $a['name'], $b['name'] ); |
|
60 | +function _sort_name_callback($a, $b) { |
|
61 | + return strnatcasecmp($a['name'], $b['name']); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -70,31 +70,31 @@ discard block |
||
70 | 70 | * @param string $sidebar id slug of the sidebar |
71 | 71 | * @param string optional $sidebar_name Include the HTML for the sidebar name |
72 | 72 | */ |
73 | -function wp_list_widget_controls( $sidebar, $sidebar_name = '' ) { |
|
74 | - add_filter( 'dynamic_sidebar_params', 'wp_list_widget_controls_dynamic_sidebar' ); |
|
73 | +function wp_list_widget_controls($sidebar, $sidebar_name = '') { |
|
74 | + add_filter('dynamic_sidebar_params', 'wp_list_widget_controls_dynamic_sidebar'); |
|
75 | 75 | |
76 | - $description = wp_sidebar_description( $sidebar ); |
|
76 | + $description = wp_sidebar_description($sidebar); |
|
77 | 77 | |
78 | - echo '<div id="' . esc_attr( $sidebar ) . '" class="widgets-sortables">'; |
|
78 | + echo '<div id="'.esc_attr($sidebar).'" class="widgets-sortables">'; |
|
79 | 79 | |
80 | - if ( $sidebar_name ) { |
|
80 | + if ($sidebar_name) { |
|
81 | 81 | ?> |
82 | 82 | <div class="sidebar-name"> |
83 | 83 | <div class="sidebar-name-arrow"><br /></div> |
84 | - <h3><?php echo esc_html( $sidebar_name ); ?> <span class="spinner"></span></h3> |
|
84 | + <h3><?php echo esc_html($sidebar_name); ?> <span class="spinner"></span></h3> |
|
85 | 85 | </div> |
86 | 86 | <?php |
87 | 87 | } |
88 | 88 | |
89 | 89 | echo '<div class="sidebar-description">'; |
90 | 90 | |
91 | - if ( ! empty( $description ) ) { |
|
92 | - echo '<p class="description">' . $description . '</p>'; |
|
91 | + if ( ! empty($description)) { |
|
92 | + echo '<p class="description">'.$description.'</p>'; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | echo '</div>'; |
96 | 96 | |
97 | - dynamic_sidebar( $sidebar ); |
|
97 | + dynamic_sidebar($sidebar); |
|
98 | 98 | |
99 | 99 | echo '</div>'; |
100 | 100 | } |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * @param array $params |
112 | 112 | * @return array |
113 | 113 | */ |
114 | -function wp_list_widget_controls_dynamic_sidebar( $params ) { |
|
114 | +function wp_list_widget_controls_dynamic_sidebar($params) { |
|
115 | 115 | global $wp_registered_widgets; |
116 | 116 | static $i = 0; |
117 | 117 | $i++; |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | $params[0]['after_widget'] = "</div>"; |
125 | 125 | $params[0]['before_title'] = "%BEG_OF_TITLE%"; // deprecated |
126 | 126 | $params[0]['after_title'] = "%END_OF_TITLE%"; // deprecated |
127 | - if ( is_callable( $wp_registered_widgets[$widget_id]['callback'] ) ) { |
|
127 | + if (is_callable($wp_registered_widgets[$widget_id]['callback'])) { |
|
128 | 128 | $wp_registered_widgets[$widget_id]['_callback'] = $wp_registered_widgets[$widget_id]['callback']; |
129 | 129 | $wp_registered_widgets[$widget_id]['callback'] = 'wp_widget_control'; |
130 | 130 | } |
@@ -139,12 +139,12 @@ discard block |
||
139 | 139 | * @param string $id_base |
140 | 140 | * @return int |
141 | 141 | */ |
142 | -function next_widget_id_number( $id_base ) { |
|
142 | +function next_widget_id_number($id_base) { |
|
143 | 143 | global $wp_registered_widgets; |
144 | 144 | $number = 1; |
145 | 145 | |
146 | - foreach ( $wp_registered_widgets as $widget_id => $widget ) { |
|
147 | - if ( preg_match( '/' . $id_base . '-([0-9]+)$/', $widget_id, $matches ) ) |
|
146 | + foreach ($wp_registered_widgets as $widget_id => $widget) { |
|
147 | + if (preg_match('/'.$id_base.'-([0-9]+)$/', $widget_id, $matches)) |
|
148 | 148 | $number = max($number, $matches[1]); |
149 | 149 | } |
150 | 150 | $number++; |
@@ -166,12 +166,12 @@ discard block |
||
166 | 166 | * @param array $sidebar_args |
167 | 167 | * @return array |
168 | 168 | */ |
169 | -function wp_widget_control( $sidebar_args ) { |
|
169 | +function wp_widget_control($sidebar_args) { |
|
170 | 170 | global $wp_registered_widgets, $wp_registered_widget_controls, $sidebars_widgets; |
171 | 171 | |
172 | 172 | $widget_id = $sidebar_args['widget_id']; |
173 | 173 | $sidebar_id = isset($sidebar_args['id']) ? $sidebar_args['id'] : false; |
174 | - $key = $sidebar_id ? array_search( $widget_id, $sidebars_widgets[$sidebar_id] ) : '-1'; // position of widget in sidebar |
|
174 | + $key = $sidebar_id ? array_search($widget_id, $sidebars_widgets[$sidebar_id]) : '-1'; // position of widget in sidebar |
|
175 | 175 | $control = isset($wp_registered_widget_controls[$widget_id]) ? $wp_registered_widget_controls[$widget_id] : array(); |
176 | 176 | $widget = $wp_registered_widgets[$widget_id]; |
177 | 177 | |
@@ -181,10 +181,10 @@ discard block |
||
181 | 181 | $multi_number = isset($sidebar_args['_multi_num']) ? $sidebar_args['_multi_num'] : ''; |
182 | 182 | $add_new = isset($sidebar_args['_add']) ? $sidebar_args['_add'] : ''; |
183 | 183 | |
184 | - $query_arg = array( 'editwidget' => $widget['id'] ); |
|
185 | - if ( $add_new ) { |
|
184 | + $query_arg = array('editwidget' => $widget['id']); |
|
185 | + if ($add_new) { |
|
186 | 186 | $query_arg['addnew'] = 1; |
187 | - if ( $multi_number ) { |
|
187 | + if ($multi_number) { |
|
188 | 188 | $query_arg['num'] = $multi_number; |
189 | 189 | $query_arg['base'] = $id_base; |
190 | 190 | } |
@@ -197,27 +197,27 @@ discard block |
||
197 | 197 | * We aren't showing a widget control, we're outputting a template |
198 | 198 | * for a multi-widget control. |
199 | 199 | */ |
200 | - if ( isset($sidebar_args['_display']) && 'template' == $sidebar_args['_display'] && $widget_number ) { |
|
200 | + if (isset($sidebar_args['_display']) && 'template' == $sidebar_args['_display'] && $widget_number) { |
|
201 | 201 | // number == -1 implies a template where id numbers are replaced by a generic '__i__' |
202 | 202 | $control['params'][0]['number'] = -1; |
203 | 203 | // With id_base widget id's are constructed like {$id_base}-{$id_number}. |
204 | - if ( isset($control['id_base']) ) |
|
205 | - $id_format = $control['id_base'] . '-__i__'; |
|
204 | + if (isset($control['id_base'])) |
|
205 | + $id_format = $control['id_base'].'-__i__'; |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | $wp_registered_widgets[$widget_id]['callback'] = $wp_registered_widgets[$widget_id]['_callback']; |
209 | 209 | unset($wp_registered_widgets[$widget_id]['_callback']); |
210 | 210 | |
211 | - $widget_title = esc_html( strip_tags( $sidebar_args['widget_name'] ) ); |
|
211 | + $widget_title = esc_html(strip_tags($sidebar_args['widget_name'])); |
|
212 | 212 | $has_form = 'noform'; |
213 | 213 | |
214 | 214 | echo $sidebar_args['before_widget']; ?> |
215 | 215 | <div class="widget-top"> |
216 | 216 | <div class="widget-title-action"> |
217 | 217 | <a class="widget-action hide-if-no-js" href="#available-widgets"></a> |
218 | - <a class="widget-control-edit hide-if-js" href="<?php echo esc_url( add_query_arg( $query_arg ) ); ?>"> |
|
219 | - <span class="edit"><?php _ex( 'Edit', 'widget' ); ?></span> |
|
220 | - <span class="add"><?php _ex( 'Add', 'widget' ); ?></span> |
|
218 | + <a class="widget-control-edit hide-if-js" href="<?php echo esc_url(add_query_arg($query_arg)); ?>"> |
|
219 | + <span class="edit"><?php _ex('Edit', 'widget'); ?></span> |
|
220 | + <span class="add"><?php _ex('Add', 'widget'); ?></span> |
|
221 | 221 | <span class="screen-reader-text"><?php echo $widget_title; ?></span> |
222 | 222 | </a> |
223 | 223 | </div> |
@@ -228,15 +228,15 @@ discard block |
||
228 | 228 | <form method="post"> |
229 | 229 | <div class="widget-content"> |
230 | 230 | <?php |
231 | - if ( isset($control['callback']) ) |
|
232 | - $has_form = call_user_func_array( $control['callback'], $control['params'] ); |
|
231 | + if (isset($control['callback'])) |
|
232 | + $has_form = call_user_func_array($control['callback'], $control['params']); |
|
233 | 233 | else |
234 | - echo "\t\t<p>" . __('There are no options for this widget.') . "</p>\n"; ?> |
|
234 | + echo "\t\t<p>".__('There are no options for this widget.')."</p>\n"; ?> |
|
235 | 235 | </div> |
236 | 236 | <input type="hidden" name="widget-id" class="widget-id" value="<?php echo esc_attr($id_format); ?>" /> |
237 | 237 | <input type="hidden" name="id_base" class="id_base" value="<?php echo esc_attr($id_base); ?>" /> |
238 | - <input type="hidden" name="widget-width" class="widget-width" value="<?php if (isset( $control['width'] )) echo esc_attr($control['width']); ?>" /> |
|
239 | - <input type="hidden" name="widget-height" class="widget-height" value="<?php if (isset( $control['height'] )) echo esc_attr($control['height']); ?>" /> |
|
238 | + <input type="hidden" name="widget-width" class="widget-width" value="<?php if (isset($control['width'])) echo esc_attr($control['width']); ?>" /> |
|
239 | + <input type="hidden" name="widget-height" class="widget-height" value="<?php if (isset($control['height'])) echo esc_attr($control['height']); ?>" /> |
|
240 | 240 | <input type="hidden" name="widget_number" class="widget_number" value="<?php echo esc_attr($widget_number); ?>" /> |
241 | 241 | <input type="hidden" name="multi_number" class="multi_number" value="<?php echo esc_attr($multi_number); ?>" /> |
242 | 242 | <input type="hidden" name="add_new" class="add_new" value="<?php echo esc_attr($add_new); ?>" /> |
@@ -246,8 +246,8 @@ discard block |
||
246 | 246 | <a class="widget-control-remove" href="#remove"><?php _e('Delete'); ?></a> | |
247 | 247 | <a class="widget-control-close" href="#close"><?php _e('Close'); ?></a> |
248 | 248 | </div> |
249 | - <div class="alignright<?php if ( 'noform' === $has_form ) echo ' widget-control-noform'; ?>"> |
|
250 | - <?php submit_button( __( 'Save' ), 'button-primary widget-control-save right', 'savewidget', false, array( 'id' => 'widget-' . esc_attr( $id_format ) . '-savewidget' ) ); ?> |
|
249 | + <div class="alignright<?php if ('noform' === $has_form) echo ' widget-control-noform'; ?>"> |
|
250 | + <?php submit_button(__('Save'), 'button-primary widget-control-save right', 'savewidget', false, array('id' => 'widget-'.esc_attr($id_format).'-savewidget')); ?> |
|
251 | 251 | <span class="spinner"></span> |
252 | 252 | </div> |
253 | 253 | <br class="clear" /> |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | </div> |
257 | 257 | |
258 | 258 | <div class="widget-description"> |
259 | -<?php echo ( $widget_description = wp_widget_description($widget_id) ) ? "$widget_description\n" : "$widget_title\n"; ?> |
|
259 | +<?php echo ($widget_description = wp_widget_description($widget_id)) ? "$widget_description\n" : "$widget_title\n"; ?> |
|
260 | 260 | </div> |
261 | 261 | <?php |
262 | 262 | echo $sidebar_args['after_widget']; |
@@ -22,14 +22,17 @@ discard block |
||
22 | 22 | $done = array(); |
23 | 23 | |
24 | 24 | foreach ( $sort as $widget ) { |
25 | - if ( in_array( $widget['callback'], $done, true ) ) // We already showed this multi-widget |
|
25 | + if ( in_array( $widget['callback'], $done, true ) ) { |
|
26 | + // We already showed this multi-widget |
|
26 | 27 | continue; |
28 | + } |
|
27 | 29 | |
28 | 30 | $sidebar = is_active_widget( $widget['callback'], $widget['id'], false, false ); |
29 | 31 | $done[] = $widget['callback']; |
30 | 32 | |
31 | - if ( ! isset( $widget['params'][0] ) ) |
|
32 | - $widget['params'][0] = array(); |
|
33 | + if ( ! isset( $widget['params'][0] ) ) { |
|
34 | + $widget['params'][0] = array(); |
|
35 | + } |
|
33 | 36 | |
34 | 37 | $args = array( 'widget_id' => $widget['id'], 'widget_name' => $widget['name'], '_display' => 'template' ); |
35 | 38 | |
@@ -40,8 +43,9 @@ discard block |
||
40 | 43 | $args['_add'] = 'multi'; |
41 | 44 | } else { |
42 | 45 | $args['_add'] = 'single'; |
43 | - if ( $sidebar ) |
|
44 | - $args['_hide'] = '1'; |
|
46 | + if ( $sidebar ) { |
|
47 | + $args['_hide'] = '1'; |
|
48 | + } |
|
45 | 49 | } |
46 | 50 | |
47 | 51 | $args = wp_list_widget_controls_dynamic_sidebar( array( 0 => $args, 1 => $widget['params'][0] ) ); |
@@ -144,8 +148,9 @@ discard block |
||
144 | 148 | $number = 1; |
145 | 149 | |
146 | 150 | foreach ( $wp_registered_widgets as $widget_id => $widget ) { |
147 | - if ( preg_match( '/' . $id_base . '-([0-9]+)$/', $widget_id, $matches ) ) |
|
148 | - $number = max($number, $matches[1]); |
|
151 | + if ( preg_match( '/' . $id_base . '-([0-9]+)$/', $widget_id, $matches ) ) { |
|
152 | + $number = max($number, $matches[1]); |
|
153 | + } |
|
149 | 154 | } |
150 | 155 | $number++; |
151 | 156 | |
@@ -201,8 +206,9 @@ discard block |
||
201 | 206 | // number == -1 implies a template where id numbers are replaced by a generic '__i__' |
202 | 207 | $control['params'][0]['number'] = -1; |
203 | 208 | // With id_base widget id's are constructed like {$id_base}-{$id_number}. |
204 | - if ( isset($control['id_base']) ) |
|
205 | - $id_format = $control['id_base'] . '-__i__'; |
|
209 | + if ( isset($control['id_base']) ) { |
|
210 | + $id_format = $control['id_base'] . '-__i__'; |
|
211 | + } |
|
206 | 212 | } |
207 | 213 | |
208 | 214 | $wp_registered_widgets[$widget_id]['callback'] = $wp_registered_widgets[$widget_id]['_callback']; |
@@ -228,15 +234,23 @@ discard block |
||
228 | 234 | <form method="post"> |
229 | 235 | <div class="widget-content"> |
230 | 236 | <?php |
231 | - if ( isset($control['callback']) ) |
|
232 | - $has_form = call_user_func_array( $control['callback'], $control['params'] ); |
|
233 | - else |
|
234 | - echo "\t\t<p>" . __('There are no options for this widget.') . "</p>\n"; ?> |
|
237 | + if ( isset($control['callback']) ) { |
|
238 | + $has_form = call_user_func_array( $control['callback'], $control['params'] ); |
|
239 | + } else { |
|
240 | + echo "\t\t<p>" . __('There are no options for this widget.') . "</p>\n"; |
|
241 | + } |
|
242 | + ?> |
|
235 | 243 | </div> |
236 | 244 | <input type="hidden" name="widget-id" class="widget-id" value="<?php echo esc_attr($id_format); ?>" /> |
237 | 245 | <input type="hidden" name="id_base" class="id_base" value="<?php echo esc_attr($id_base); ?>" /> |
238 | - <input type="hidden" name="widget-width" class="widget-width" value="<?php if (isset( $control['width'] )) echo esc_attr($control['width']); ?>" /> |
|
239 | - <input type="hidden" name="widget-height" class="widget-height" value="<?php if (isset( $control['height'] )) echo esc_attr($control['height']); ?>" /> |
|
246 | + <input type="hidden" name="widget-width" class="widget-width" value="<?php if (isset( $control['width'] )) { |
|
247 | + echo esc_attr($control['width']); |
|
248 | +} |
|
249 | +?>" /> |
|
250 | + <input type="hidden" name="widget-height" class="widget-height" value="<?php if (isset( $control['height'] )) { |
|
251 | + echo esc_attr($control['height']); |
|
252 | +} |
|
253 | +?>" /> |
|
240 | 254 | <input type="hidden" name="widget_number" class="widget_number" value="<?php echo esc_attr($widget_number); ?>" /> |
241 | 255 | <input type="hidden" name="multi_number" class="multi_number" value="<?php echo esc_attr($multi_number); ?>" /> |
242 | 256 | <input type="hidden" name="add_new" class="add_new" value="<?php echo esc_attr($add_new); ?>" /> |
@@ -246,7 +260,10 @@ discard block |
||
246 | 260 | <a class="widget-control-remove" href="#remove"><?php _e('Delete'); ?></a> | |
247 | 261 | <a class="widget-control-close" href="#close"><?php _e('Close'); ?></a> |
248 | 262 | </div> |
249 | - <div class="alignright<?php if ( 'noform' === $has_form ) echo ' widget-control-noform'; ?>"> |
|
263 | + <div class="alignright<?php if ( 'noform' === $has_form ) { |
|
264 | + echo ' widget-control-noform'; |
|
265 | +} |
|
266 | +?>"> |
|
250 | 267 | <?php submit_button( __( 'Save' ), 'button-primary widget-control-save right', 'savewidget', false, array( 'id' => 'widget-' . esc_attr( $id_format ) . '-savewidget' ) ); ?> |
251 | 268 | <span class="spinner"></span> |
252 | 269 | </div> |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * WordPress Plugin Install Administration API |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage Administration |
|
7 | - */ |
|
3 | + * WordPress Plugin Install Administration API |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage Administration |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Retrieve plugin installer pages from WordPress Plugins API. |
@@ -28,15 +28,15 @@ discard block |
||
28 | 28 | */ |
29 | 29 | function plugins_api($action, $args = null) { |
30 | 30 | |
31 | - if ( is_array( $args ) ) { |
|
31 | + if (is_array($args)) { |
|
32 | 32 | $args = (object) $args; |
33 | 33 | } |
34 | 34 | |
35 | - if ( ! isset( $args->per_page ) ) { |
|
35 | + if ( ! isset($args->per_page)) { |
|
36 | 36 | $args->per_page = 24; |
37 | 37 | } |
38 | 38 | |
39 | - if ( ! isset( $args->locale ) ) { |
|
39 | + if ( ! isset($args->locale)) { |
|
40 | 40 | $args->locale = get_locale(); |
41 | 41 | } |
42 | 42 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * @param object $args Plugin API arguments. |
51 | 51 | * @param string $action The type of information being requested from the Plugin Install API. |
52 | 52 | */ |
53 | - $args = apply_filters( 'plugins_api_args', $args, $action ); |
|
53 | + $args = apply_filters('plugins_api_args', $args, $action); |
|
54 | 54 | |
55 | 55 | /** |
56 | 56 | * Allows a plugin to override the WordPress.org Plugin Install API entirely. |
@@ -63,35 +63,35 @@ discard block |
||
63 | 63 | * @param string $action The type of information being requested from the Plugin Install API. |
64 | 64 | * @param object $args Plugin API arguments. |
65 | 65 | */ |
66 | - $res = apply_filters( 'plugins_api', false, $action, $args ); |
|
66 | + $res = apply_filters('plugins_api', false, $action, $args); |
|
67 | 67 | |
68 | - if ( false === $res ) { |
|
68 | + if (false === $res) { |
|
69 | 69 | $url = $http_url = 'http://api.wordpress.org/plugins/info/1.0/'; |
70 | - if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) |
|
71 | - $url = set_url_scheme( $url, 'https' ); |
|
70 | + if ($ssl = wp_http_supports(array('ssl'))) |
|
71 | + $url = set_url_scheme($url, 'https'); |
|
72 | 72 | |
73 | 73 | $http_args = array( |
74 | 74 | 'timeout' => 15, |
75 | 75 | 'body' => array( |
76 | 76 | 'action' => $action, |
77 | - 'request' => serialize( $args ) |
|
77 | + 'request' => serialize($args) |
|
78 | 78 | ) |
79 | 79 | ); |
80 | - $request = wp_remote_post( $url, $http_args ); |
|
80 | + $request = wp_remote_post($url, $http_args); |
|
81 | 81 | |
82 | - if ( $ssl && is_wp_error( $request ) ) { |
|
83 | - trigger_error( __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ), headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE ); |
|
84 | - $request = wp_remote_post( $http_url, $http_args ); |
|
82 | + if ($ssl && is_wp_error($request)) { |
|
83 | + trigger_error(__('An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.').' '.__('(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)'), headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE); |
|
84 | + $request = wp_remote_post($http_url, $http_args); |
|
85 | 85 | } |
86 | 86 | |
87 | - if ( is_wp_error($request) ) { |
|
88 | - $res = new WP_Error('plugins_api_failed', __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ), $request->get_error_message() ); |
|
87 | + if (is_wp_error($request)) { |
|
88 | + $res = new WP_Error('plugins_api_failed', __('An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.'), $request->get_error_message()); |
|
89 | 89 | } else { |
90 | - $res = maybe_unserialize( wp_remote_retrieve_body( $request ) ); |
|
91 | - if ( ! is_object( $res ) && ! is_array( $res ) ) |
|
92 | - $res = new WP_Error('plugins_api_failed', __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ), wp_remote_retrieve_body( $request ) ); |
|
90 | + $res = maybe_unserialize(wp_remote_retrieve_body($request)); |
|
91 | + if ( ! is_object($res) && ! is_array($res)) |
|
92 | + $res = new WP_Error('plugins_api_failed', __('An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.'), wp_remote_retrieve_body($request)); |
|
93 | 93 | } |
94 | - } elseif ( !is_wp_error($res) ) { |
|
94 | + } elseif ( ! is_wp_error($res)) { |
|
95 | 95 | $res->external = true; |
96 | 96 | } |
97 | 97 | |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * @param string $action The type of information being requested from the Plugin Install API. |
105 | 105 | * @param object $args Plugin API arguments. |
106 | 106 | */ |
107 | - return apply_filters( 'plugins_api_result', $res, $action, $args ); |
|
107 | + return apply_filters('plugins_api_result', $res, $action, $args); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -115,17 +115,17 @@ discard block |
||
115 | 115 | * @param array $args |
116 | 116 | * @return array |
117 | 117 | */ |
118 | -function install_popular_tags( $args = array() ) { |
|
118 | +function install_popular_tags($args = array()) { |
|
119 | 119 | $key = md5(serialize($args)); |
120 | - if ( false !== ($tags = get_site_transient('poptags_' . $key) ) ) |
|
120 | + if (false !== ($tags = get_site_transient('poptags_'.$key))) |
|
121 | 121 | return $tags; |
122 | 122 | |
123 | 123 | $tags = plugins_api('hot_tags', $args); |
124 | 124 | |
125 | - if ( is_wp_error($tags) ) |
|
125 | + if (is_wp_error($tags)) |
|
126 | 126 | return $tags; |
127 | 127 | |
128 | - set_site_transient( 'poptags_' . $key, $tags, 3 * HOUR_IN_SECONDS ); |
|
128 | + set_site_transient('poptags_'.$key, $tags, 3 * HOUR_IN_SECONDS); |
|
129 | 129 | |
130 | 130 | return $tags; |
131 | 131 | } |
@@ -135,34 +135,34 @@ discard block |
||
135 | 135 | */ |
136 | 136 | function install_dashboard() { |
137 | 137 | ?> |
138 | - <p><?php printf( __( 'Plugins extend and expand the functionality of WordPress. You may automatically install plugins from the <a href="%1$s">WordPress Plugin Directory</a> or upload a plugin in .zip format via <a href="%2$s">this page</a>.' ), 'https://wordpress.org/plugins/', self_admin_url( 'plugin-install.php?tab=upload' ) ); ?></p> |
|
138 | + <p><?php printf(__('Plugins extend and expand the functionality of WordPress. You may automatically install plugins from the <a href="%1$s">WordPress Plugin Directory</a> or upload a plugin in .zip format via <a href="%2$s">this page</a>.'), 'https://wordpress.org/plugins/', self_admin_url('plugin-install.php?tab=upload')); ?></p> |
|
139 | 139 | |
140 | 140 | <?php display_plugins_table(); ?> |
141 | 141 | |
142 | - <h3><?php _e( 'Popular tags' ) ?></h3> |
|
143 | - <p><?php _e( 'You may also browse based on the most popular tags in the Plugin Directory:' ) ?></p> |
|
142 | + <h3><?php _e('Popular tags') ?></h3> |
|
143 | + <p><?php _e('You may also browse based on the most popular tags in the Plugin Directory:') ?></p> |
|
144 | 144 | <?php |
145 | 145 | |
146 | 146 | $api_tags = install_popular_tags(); |
147 | 147 | |
148 | 148 | echo '<p class="popular-tags">'; |
149 | - if ( is_wp_error($api_tags) ) { |
|
149 | + if (is_wp_error($api_tags)) { |
|
150 | 150 | echo $api_tags->get_error_message(); |
151 | 151 | } else { |
152 | 152 | //Set up the tags in a way which can be interpreted by wp_generate_tag_cloud() |
153 | 153 | $tags = array(); |
154 | - foreach ( (array) $api_tags as $tag ) { |
|
155 | - $url = self_admin_url( 'plugin-install.php?tab=search&type=tag&s=' . urlencode( $tag['name'] ) ); |
|
154 | + foreach ((array) $api_tags as $tag) { |
|
155 | + $url = self_admin_url('plugin-install.php?tab=search&type=tag&s='.urlencode($tag['name'])); |
|
156 | 156 | $data = array( |
157 | - 'link' => esc_url( $url ), |
|
157 | + 'link' => esc_url($url), |
|
158 | 158 | 'name' => $tag['name'], |
159 | 159 | 'slug' => $tag['slug'], |
160 | - 'id' => sanitize_title_with_dashes( $tag['name'] ), |
|
160 | + 'id' => sanitize_title_with_dashes($tag['name']), |
|
161 | 161 | 'count' => $tag['count'] |
162 | 162 | ); |
163 | - $tags[ $tag['name'] ] = (object) $data; |
|
163 | + $tags[$tag['name']] = (object) $data; |
|
164 | 164 | } |
165 | - echo wp_generate_tag_cloud($tags, array( 'single_text' => __('%s plugin'), 'multiple_text' => __('%s plugins') ) ); |
|
165 | + echo wp_generate_tag_cloud($tags, array('single_text' => __('%s plugin'), 'multiple_text' => __('%s plugins'))); |
|
166 | 166 | } |
167 | 167 | echo '</p><br class="clear" />'; |
168 | 168 | } |
@@ -174,20 +174,20 @@ discard block |
||
174 | 174 | * |
175 | 175 | * @param bool $type_selector |
176 | 176 | */ |
177 | -function install_search_form( $type_selector = true ) { |
|
178 | - $type = isset($_REQUEST['type']) ? wp_unslash( $_REQUEST['type'] ) : 'term'; |
|
179 | - $term = isset($_REQUEST['s']) ? wp_unslash( $_REQUEST['s'] ) : ''; |
|
177 | +function install_search_form($type_selector = true) { |
|
178 | + $type = isset($_REQUEST['type']) ? wp_unslash($_REQUEST['type']) : 'term'; |
|
179 | + $term = isset($_REQUEST['s']) ? wp_unslash($_REQUEST['s']) : ''; |
|
180 | 180 | $input_attrs = ''; |
181 | 181 | $button_type = 'button screen-reader-text'; |
182 | 182 | |
183 | 183 | // assume no $type_selector means it's a simplified search form |
184 | - if ( ! $type_selector ) { |
|
185 | - $input_attrs = 'class="wp-filter-search" placeholder="' . esc_attr__( 'Search Plugins' ) . '" '; |
|
184 | + if ( ! $type_selector) { |
|
185 | + $input_attrs = 'class="wp-filter-search" placeholder="'.esc_attr__('Search Plugins').'" '; |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | ?><form class="search-form search-plugins" method="get"> |
189 | 189 | <input type="hidden" name="tab" value="search" /> |
190 | - <?php if ( $type_selector ) : ?> |
|
190 | + <?php if ($type_selector) : ?> |
|
191 | 191 | <select name="type" id="typeselector"> |
192 | 192 | <option value="term"<?php selected('term', $type) ?>><?php _e('Keyword'); ?></option> |
193 | 193 | <option value="author"<?php selected('author', $type) ?>><?php _e('Author'); ?></option> |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | <label><span class="screen-reader-text"><?php _e('Search Plugins'); ?></span> |
198 | 198 | <input type="search" name="s" value="<?php echo esc_attr($term) ?>" <?php echo $input_attrs; ?>/> |
199 | 199 | </label> |
200 | - <?php submit_button( __( 'Search Plugins' ), $button_type, false, false, array( 'id' => 'search-submit' ) ); ?> |
|
200 | + <?php submit_button(__('Search Plugins'), $button_type, false, false, array('id' => 'search-submit')); ?> |
|
201 | 201 | </form><?php |
202 | 202 | } |
203 | 203 | |
@@ -210,10 +210,10 @@ discard block |
||
210 | 210 | <div class="upload-plugin"> |
211 | 211 | <p class="install-help"><?php _e('If you have a plugin in a .zip format, you may install it by uploading it here.'); ?></p> |
212 | 212 | <form method="post" enctype="multipart/form-data" class="wp-upload-form" action="<?php echo self_admin_url('update.php?action=upload-plugin'); ?>"> |
213 | - <?php wp_nonce_field( 'plugin-upload'); ?> |
|
213 | + <?php wp_nonce_field('plugin-upload'); ?> |
|
214 | 214 | <label class="screen-reader-text" for="pluginzip"><?php _e('Plugin zip file'); ?></label> |
215 | 215 | <input type="file" id="pluginzip" name="pluginzip" /> |
216 | - <?php submit_button( __( 'Install Now' ), 'button', 'install-plugin-submit', false ); ?> |
|
216 | + <?php submit_button(__('Install Now'), 'button', 'install-plugin-submit', false); ?> |
|
217 | 217 | </form> |
218 | 218 | </div> |
219 | 219 | <?php |
@@ -225,15 +225,15 @@ discard block |
||
225 | 225 | * |
226 | 226 | */ |
227 | 227 | function install_plugins_favorites_form() { |
228 | - $user = ! empty( $_GET['user'] ) ? wp_unslash( $_GET['user'] ) : get_user_option( 'wporg_favorites' ); |
|
228 | + $user = ! empty($_GET['user']) ? wp_unslash($_GET['user']) : get_user_option('wporg_favorites'); |
|
229 | 229 | ?> |
230 | - <p class="install-help"><?php _e( 'If you have marked plugins as favorites on WordPress.org, you can browse them here.' ); ?></p> |
|
230 | + <p class="install-help"><?php _e('If you have marked plugins as favorites on WordPress.org, you can browse them here.'); ?></p> |
|
231 | 231 | <form method="get"> |
232 | 232 | <input type="hidden" name="tab" value="favorites" /> |
233 | 233 | <p> |
234 | - <label for="user"><?php _e( 'Your WordPress.org username:' ); ?></label> |
|
235 | - <input type="search" id="user" name="user" value="<?php echo esc_attr( $user ); ?>" /> |
|
236 | - <input type="submit" class="button" value="<?php esc_attr_e( 'Get Favorites' ); ?>" /> |
|
234 | + <label for="user"><?php _e('Your WordPress.org username:'); ?></label> |
|
235 | + <input type="search" id="user" name="user" value="<?php echo esc_attr($user); ?>" /> |
|
236 | + <input type="submit" class="button" value="<?php esc_attr_e('Get Favorites'); ?>" /> |
|
237 | 237 | </p> |
238 | 238 | </form> |
239 | 239 | <?php |
@@ -249,14 +249,14 @@ discard block |
||
249 | 249 | function display_plugins_table() { |
250 | 250 | global $wp_list_table; |
251 | 251 | |
252 | - switch ( current_filter() ) { |
|
252 | + switch (current_filter()) { |
|
253 | 253 | case 'install_plugins_favorites' : |
254 | - if ( empty( $_GET['user'] ) && ! get_user_option( 'wporg_favorites' ) ) { |
|
254 | + if (empty($_GET['user']) && ! get_user_option('wporg_favorites')) { |
|
255 | 255 | return; |
256 | 256 | } |
257 | 257 | break; |
258 | 258 | case 'install_plugins_recommended' : |
259 | - echo '<p>' . __( 'These suggestions are based on the plugins you and other users have installed.' ) . '</p>'; |
|
259 | + echo '<p>'.__('These suggestions are based on the plugins you and other users have installed.').'</p>'; |
|
260 | 260 | break; |
261 | 261 | } |
262 | 262 | |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | */ |
279 | 279 | function install_plugin_install_status($api, $loop = false) { |
280 | 280 | // This function is called recursively, $loop prevents further loops. |
281 | - if ( is_array($api) ) |
|
281 | + if (is_array($api)) |
|
282 | 282 | $api = (object) $api; |
283 | 283 | |
284 | 284 | // Default to a "new" plugin |
@@ -291,37 +291,37 @@ discard block |
||
291 | 291 | * and has an update awaiting it. |
292 | 292 | */ |
293 | 293 | $update_plugins = get_site_transient('update_plugins'); |
294 | - if ( isset( $update_plugins->response ) ) { |
|
295 | - foreach ( (array)$update_plugins->response as $file => $plugin ) { |
|
296 | - if ( $plugin->slug === $api->slug ) { |
|
294 | + if (isset($update_plugins->response)) { |
|
295 | + foreach ((array) $update_plugins->response as $file => $plugin) { |
|
296 | + if ($plugin->slug === $api->slug) { |
|
297 | 297 | $status = 'update_available'; |
298 | 298 | $update_file = $file; |
299 | 299 | $version = $plugin->new_version; |
300 | - if ( current_user_can('update_plugins') ) |
|
301 | - $url = wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=' . $update_file), 'upgrade-plugin_' . $update_file); |
|
300 | + if (current_user_can('update_plugins')) |
|
301 | + $url = wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin='.$update_file), 'upgrade-plugin_'.$update_file); |
|
302 | 302 | break; |
303 | 303 | } |
304 | 304 | } |
305 | 305 | } |
306 | 306 | |
307 | - if ( 'install' == $status ) { |
|
308 | - if ( is_dir( WP_PLUGIN_DIR . '/' . $api->slug ) ) { |
|
309 | - $installed_plugin = get_plugins('/' . $api->slug); |
|
310 | - if ( empty($installed_plugin) ) { |
|
311 | - if ( current_user_can('install_plugins') ) |
|
312 | - $url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . $api->slug), 'install-plugin_' . $api->slug); |
|
307 | + if ('install' == $status) { |
|
308 | + if (is_dir(WP_PLUGIN_DIR.'/'.$api->slug)) { |
|
309 | + $installed_plugin = get_plugins('/'.$api->slug); |
|
310 | + if (empty($installed_plugin)) { |
|
311 | + if (current_user_can('install_plugins')) |
|
312 | + $url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin='.$api->slug), 'install-plugin_'.$api->slug); |
|
313 | 313 | } else { |
314 | - $key = array_keys( $installed_plugin ); |
|
315 | - $key = reset( $key ); //Use the first plugin regardless of the name, Could have issues for multiple-plugins in one directory if they share different version numbers |
|
316 | - $update_file = $api->slug . '/' . $key; |
|
317 | - if ( version_compare($api->version, $installed_plugin[ $key ]['Version'], '=') ){ |
|
314 | + $key = array_keys($installed_plugin); |
|
315 | + $key = reset($key); //Use the first plugin regardless of the name, Could have issues for multiple-plugins in one directory if they share different version numbers |
|
316 | + $update_file = $api->slug.'/'.$key; |
|
317 | + if (version_compare($api->version, $installed_plugin[$key]['Version'], '=')) { |
|
318 | 318 | $status = 'latest_installed'; |
319 | - } elseif ( version_compare($api->version, $installed_plugin[ $key ]['Version'], '<') ) { |
|
319 | + } elseif (version_compare($api->version, $installed_plugin[$key]['Version'], '<')) { |
|
320 | 320 | $status = 'newer_installed'; |
321 | - $version = $installed_plugin[ $key ]['Version']; |
|
321 | + $version = $installed_plugin[$key]['Version']; |
|
322 | 322 | } else { |
323 | 323 | //If the above update check failed, Then that probably means that the update checker has out-of-date information, force a refresh |
324 | - if ( ! $loop ) { |
|
324 | + if ( ! $loop) { |
|
325 | 325 | delete_site_transient('update_plugins'); |
326 | 326 | wp_update_plugins(); |
327 | 327 | return install_plugin_install_status($api, true); |
@@ -330,15 +330,15 @@ discard block |
||
330 | 330 | } |
331 | 331 | } else { |
332 | 332 | // "install" & no directory with that slug |
333 | - if ( current_user_can('install_plugins') ) |
|
334 | - $url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . $api->slug), 'install-plugin_' . $api->slug); |
|
333 | + if (current_user_can('install_plugins')) |
|
334 | + $url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin='.$api->slug), 'install-plugin_'.$api->slug); |
|
335 | 335 | } |
336 | 336 | } |
337 | - if ( isset($_GET['from']) ) |
|
338 | - $url .= '&from=' . urlencode( wp_unslash( $_GET['from'] ) ); |
|
337 | + if (isset($_GET['from'])) |
|
338 | + $url .= '&from='.urlencode(wp_unslash($_GET['from'])); |
|
339 | 339 | |
340 | 340 | $file = $update_file; |
341 | - return compact( 'status', 'url', 'version', 'file' ); |
|
341 | + return compact('status', 'url', 'version', 'file'); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | /** |
@@ -352,12 +352,12 @@ discard block |
||
352 | 352 | function install_plugin_information() { |
353 | 353 | global $tab; |
354 | 354 | |
355 | - if ( empty( $_REQUEST['plugin'] ) ) { |
|
355 | + if (empty($_REQUEST['plugin'])) { |
|
356 | 356 | return; |
357 | 357 | } |
358 | 358 | |
359 | - $api = plugins_api( 'plugin_information', array( |
|
360 | - 'slug' => wp_unslash( $_REQUEST['plugin'] ), |
|
359 | + $api = plugins_api('plugin_information', array( |
|
360 | + 'slug' => wp_unslash($_REQUEST['plugin']), |
|
361 | 361 | 'is_ssl' => is_ssl(), |
362 | 362 | 'fields' => array( |
363 | 363 | 'banners' => true, |
@@ -365,67 +365,67 @@ discard block |
||
365 | 365 | 'downloaded' => false, |
366 | 366 | 'active_installs' => true |
367 | 367 | ) |
368 | - ) ); |
|
368 | + )); |
|
369 | 369 | |
370 | - if ( is_wp_error( $api ) ) { |
|
371 | - wp_die( $api ); |
|
370 | + if (is_wp_error($api)) { |
|
371 | + wp_die($api); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | $plugins_allowedtags = array( |
375 | - 'a' => array( 'href' => array(), 'title' => array(), 'target' => array() ), |
|
376 | - 'abbr' => array( 'title' => array() ), 'acronym' => array( 'title' => array() ), |
|
375 | + 'a' => array('href' => array(), 'title' => array(), 'target' => array()), |
|
376 | + 'abbr' => array('title' => array()), 'acronym' => array('title' => array()), |
|
377 | 377 | 'code' => array(), 'pre' => array(), 'em' => array(), 'strong' => array(), |
378 | - 'div' => array( 'class' => array() ), 'span' => array( 'class' => array() ), |
|
378 | + 'div' => array('class' => array()), 'span' => array('class' => array()), |
|
379 | 379 | 'p' => array(), 'ul' => array(), 'ol' => array(), 'li' => array(), |
380 | 380 | 'h1' => array(), 'h2' => array(), 'h3' => array(), 'h4' => array(), 'h5' => array(), 'h6' => array(), |
381 | - 'img' => array( 'src' => array(), 'class' => array(), 'alt' => array() ) |
|
381 | + 'img' => array('src' => array(), 'class' => array(), 'alt' => array()) |
|
382 | 382 | ); |
383 | 383 | |
384 | 384 | $plugins_section_titles = array( |
385 | - 'description' => _x( 'Description', 'Plugin installer section title' ), |
|
386 | - 'installation' => _x( 'Installation', 'Plugin installer section title' ), |
|
387 | - 'faq' => _x( 'FAQ', 'Plugin installer section title' ), |
|
388 | - 'screenshots' => _x( 'Screenshots', 'Plugin installer section title' ), |
|
389 | - 'changelog' => _x( 'Changelog', 'Plugin installer section title' ), |
|
390 | - 'reviews' => _x( 'Reviews', 'Plugin installer section title' ), |
|
391 | - 'other_notes' => _x( 'Other Notes', 'Plugin installer section title' ) |
|
385 | + 'description' => _x('Description', 'Plugin installer section title'), |
|
386 | + 'installation' => _x('Installation', 'Plugin installer section title'), |
|
387 | + 'faq' => _x('FAQ', 'Plugin installer section title'), |
|
388 | + 'screenshots' => _x('Screenshots', 'Plugin installer section title'), |
|
389 | + 'changelog' => _x('Changelog', 'Plugin installer section title'), |
|
390 | + 'reviews' => _x('Reviews', 'Plugin installer section title'), |
|
391 | + 'other_notes' => _x('Other Notes', 'Plugin installer section title') |
|
392 | 392 | ); |
393 | 393 | |
394 | 394 | // Sanitize HTML |
395 | - foreach ( (array) $api->sections as $section_name => $content ) { |
|
396 | - $api->sections[$section_name] = wp_kses( $content, $plugins_allowedtags ); |
|
395 | + foreach ((array) $api->sections as $section_name => $content) { |
|
396 | + $api->sections[$section_name] = wp_kses($content, $plugins_allowedtags); |
|
397 | 397 | } |
398 | 398 | |
399 | - foreach ( array( 'version', 'author', 'requires', 'tested', 'homepage', 'downloaded', 'slug' ) as $key ) { |
|
400 | - if ( isset( $api->$key ) ) { |
|
401 | - $api->$key = wp_kses( $api->$key, $plugins_allowedtags ); |
|
399 | + foreach (array('version', 'author', 'requires', 'tested', 'homepage', 'downloaded', 'slug') as $key) { |
|
400 | + if (isset($api->$key)) { |
|
401 | + $api->$key = wp_kses($api->$key, $plugins_allowedtags); |
|
402 | 402 | } |
403 | 403 | } |
404 | 404 | |
405 | - $_tab = esc_attr( $tab ); |
|
405 | + $_tab = esc_attr($tab); |
|
406 | 406 | |
407 | - $section = isset( $_REQUEST['section'] ) ? wp_unslash( $_REQUEST['section'] ) : 'description'; // Default to the Description tab, Do not translate, API returns English. |
|
408 | - if ( empty( $section ) || ! isset( $api->sections[ $section ] ) ) { |
|
409 | - $section_titles = array_keys( (array) $api->sections ); |
|
410 | - $section = reset( $section_titles ); |
|
407 | + $section = isset($_REQUEST['section']) ? wp_unslash($_REQUEST['section']) : 'description'; // Default to the Description tab, Do not translate, API returns English. |
|
408 | + if (empty($section) || ! isset($api->sections[$section])) { |
|
409 | + $section_titles = array_keys((array) $api->sections); |
|
410 | + $section = reset($section_titles); |
|
411 | 411 | } |
412 | 412 | |
413 | - iframe_header( __( 'Plugin Install' ) ); |
|
413 | + iframe_header(__('Plugin Install')); |
|
414 | 414 | |
415 | 415 | $_with_banner = ''; |
416 | 416 | |
417 | - if ( ! empty( $api->banners ) && ( ! empty( $api->banners['low'] ) || ! empty( $api->banners['high'] ) ) ) { |
|
417 | + if ( ! empty($api->banners) && ( ! empty($api->banners['low']) || ! empty($api->banners['high']))) { |
|
418 | 418 | $_with_banner = 'with-banner'; |
419 | - $low = empty( $api->banners['low'] ) ? $api->banners['high'] : $api->banners['low']; |
|
420 | - $high = empty( $api->banners['high'] ) ? $api->banners['low'] : $api->banners['high']; |
|
419 | + $low = empty($api->banners['low']) ? $api->banners['high'] : $api->banners['low']; |
|
420 | + $high = empty($api->banners['high']) ? $api->banners['low'] : $api->banners['high']; |
|
421 | 421 | ?> |
422 | 422 | <style type="text/css"> |
423 | 423 | #plugin-information-title.with-banner { |
424 | - background-image: url( <?php echo esc_url( $low ); ?> ); |
|
424 | + background-image: url( <?php echo esc_url($low); ?> ); |
|
425 | 425 | } |
426 | 426 | @media only screen and ( -webkit-min-device-pixel-ratio: 1.5 ) { |
427 | 427 | #plugin-information-title.with-banner { |
428 | - background-image: url( <?php echo esc_url( $high ); ?> ); |
|
428 | + background-image: url( <?php echo esc_url($high); ?> ); |
|
429 | 429 | } |
430 | 430 | } |
431 | 431 | </style> |
@@ -436,96 +436,96 @@ discard block |
||
436 | 436 | echo "<div id='{$_tab}-title' class='{$_with_banner}'><div class='vignette'></div><h2>{$api->name}</h2></div>"; |
437 | 437 | echo "<div id='{$_tab}-tabs' class='{$_with_banner}'>\n"; |
438 | 438 | |
439 | - foreach ( (array) $api->sections as $section_name => $content ) { |
|
440 | - if ( 'reviews' === $section_name && ( empty( $api->ratings ) || 0 === array_sum( (array) $api->ratings ) ) ) { |
|
439 | + foreach ((array) $api->sections as $section_name => $content) { |
|
440 | + if ('reviews' === $section_name && (empty($api->ratings) || 0 === array_sum((array) $api->ratings))) { |
|
441 | 441 | continue; |
442 | 442 | } |
443 | 443 | |
444 | - if ( isset( $plugins_section_titles[ $section_name ] ) ) { |
|
445 | - $title = $plugins_section_titles[ $section_name ]; |
|
444 | + if (isset($plugins_section_titles[$section_name])) { |
|
445 | + $title = $plugins_section_titles[$section_name]; |
|
446 | 446 | } else { |
447 | - $title = ucwords( str_replace( '_', ' ', $section_name ) ); |
|
447 | + $title = ucwords(str_replace('_', ' ', $section_name)); |
|
448 | 448 | } |
449 | 449 | |
450 | - $class = ( $section_name === $section ) ? ' class="current"' : ''; |
|
451 | - $href = add_query_arg( array('tab' => $tab, 'section' => $section_name) ); |
|
452 | - $href = esc_url( $href ); |
|
453 | - $san_section = esc_attr( $section_name ); |
|
450 | + $class = ($section_name === $section) ? ' class="current"' : ''; |
|
451 | + $href = add_query_arg(array('tab' => $tab, 'section' => $section_name)); |
|
452 | + $href = esc_url($href); |
|
453 | + $san_section = esc_attr($section_name); |
|
454 | 454 | echo "\t<a name='$san_section' href='$href' $class>$title</a>\n"; |
455 | 455 | } |
456 | 456 | |
457 | 457 | echo "</div>\n"; |
458 | 458 | |
459 | - $date_format = __( 'M j, Y @ H:i' ); |
|
460 | - $last_updated_timestamp = strtotime( $api->last_updated ); |
|
459 | + $date_format = __('M j, Y @ H:i'); |
|
460 | + $last_updated_timestamp = strtotime($api->last_updated); |
|
461 | 461 | ?> |
462 | 462 | <div id="<?php echo $_tab; ?>-content" class='<?php echo $_with_banner; ?>'> |
463 | 463 | <div class="fyi"> |
464 | 464 | <ul> |
465 | - <?php if ( ! empty( $api->version ) ) { ?> |
|
466 | - <li><strong><?php _e( 'Version:' ); ?></strong> <?php echo $api->version; ?></li> |
|
467 | - <?php } if ( ! empty( $api->author ) ) { ?> |
|
468 | - <li><strong><?php _e( 'Author:' ); ?></strong> <?php echo links_add_target( $api->author, '_blank' ); ?></li> |
|
469 | - <?php } if ( ! empty( $api->last_updated ) ) { ?> |
|
470 | - <li><strong><?php _e( 'Last Updated:' ); ?></strong> <span title="<?php echo esc_attr( date_i18n( $date_format, $last_updated_timestamp ) ); ?>"> |
|
471 | - <?php printf( __( '%s ago' ), human_time_diff( $last_updated_timestamp ) ); ?> |
|
465 | + <?php if ( ! empty($api->version)) { ?> |
|
466 | + <li><strong><?php _e('Version:'); ?></strong> <?php echo $api->version; ?></li> |
|
467 | + <?php } if ( ! empty($api->author)) { ?> |
|
468 | + <li><strong><?php _e('Author:'); ?></strong> <?php echo links_add_target($api->author, '_blank'); ?></li> |
|
469 | + <?php } if ( ! empty($api->last_updated)) { ?> |
|
470 | + <li><strong><?php _e('Last Updated:'); ?></strong> <span title="<?php echo esc_attr(date_i18n($date_format, $last_updated_timestamp)); ?>"> |
|
471 | + <?php printf(__('%s ago'), human_time_diff($last_updated_timestamp)); ?> |
|
472 | 472 | </span></li> |
473 | - <?php } if ( ! empty( $api->requires ) ) { ?> |
|
474 | - <li><strong><?php _e( 'Requires WordPress Version:' ); ?></strong> <?php printf( __( '%s or higher' ), $api->requires ); ?></li> |
|
475 | - <?php } if ( ! empty( $api->tested ) ) { ?> |
|
476 | - <li><strong><?php _e( 'Compatible up to:' ); ?></strong> <?php echo $api->tested; ?></li> |
|
477 | - <?php } if ( ! empty( $api->active_installs ) ) { ?> |
|
478 | - <li><strong><?php _e( 'Active Installs:' ); ?></strong> <?php |
|
479 | - if ( $api->active_installs >= 1000000 ) { |
|
480 | - _ex( '1+ Million', 'Active plugin installs' ); |
|
473 | + <?php } if ( ! empty($api->requires)) { ?> |
|
474 | + <li><strong><?php _e('Requires WordPress Version:'); ?></strong> <?php printf(__('%s or higher'), $api->requires); ?></li> |
|
475 | + <?php } if ( ! empty($api->tested)) { ?> |
|
476 | + <li><strong><?php _e('Compatible up to:'); ?></strong> <?php echo $api->tested; ?></li> |
|
477 | + <?php } if ( ! empty($api->active_installs)) { ?> |
|
478 | + <li><strong><?php _e('Active Installs:'); ?></strong> <?php |
|
479 | + if ($api->active_installs >= 1000000) { |
|
480 | + _ex('1+ Million', 'Active plugin installs'); |
|
481 | 481 | } else { |
482 | - echo number_format_i18n( $api->active_installs ) . '+'; |
|
482 | + echo number_format_i18n($api->active_installs).'+'; |
|
483 | 483 | } |
484 | 484 | ?></li> |
485 | - <?php } if ( ! empty( $api->slug ) && empty( $api->external ) ) { ?> |
|
486 | - <li><a target="_blank" href="https://wordpress.org/plugins/<?php echo $api->slug; ?>/"><?php _e( 'WordPress.org Plugin Page »' ); ?></a></li> |
|
487 | - <?php } if ( ! empty( $api->homepage ) ) { ?> |
|
488 | - <li><a target="_blank" href="<?php echo esc_url( $api->homepage ); ?>"><?php _e( 'Plugin Homepage »' ); ?></a></li> |
|
489 | - <?php } if ( ! empty( $api->donate_link ) && empty( $api->contributors ) ) { ?> |
|
490 | - <li><a target="_blank" href="<?php echo esc_url( $api->donate_link ); ?>"><?php _e( 'Donate to this plugin »' ); ?></a></li> |
|
485 | + <?php } if ( ! empty($api->slug) && empty($api->external)) { ?> |
|
486 | + <li><a target="_blank" href="https://wordpress.org/plugins/<?php echo $api->slug; ?>/"><?php _e('WordPress.org Plugin Page »'); ?></a></li> |
|
487 | + <?php } if ( ! empty($api->homepage)) { ?> |
|
488 | + <li><a target="_blank" href="<?php echo esc_url($api->homepage); ?>"><?php _e('Plugin Homepage »'); ?></a></li> |
|
489 | + <?php } if ( ! empty($api->donate_link) && empty($api->contributors)) { ?> |
|
490 | + <li><a target="_blank" href="<?php echo esc_url($api->donate_link); ?>"><?php _e('Donate to this plugin »'); ?></a></li> |
|
491 | 491 | <?php } ?> |
492 | 492 | </ul> |
493 | - <?php if ( ! empty( $api->rating ) ) { ?> |
|
494 | - <h3><?php _e( 'Average Rating' ); ?></h3> |
|
495 | - <?php wp_star_rating( array( 'rating' => $api->rating, 'type' => 'percent', 'number' => $api->num_ratings ) ); ?> |
|
496 | - <small><?php printf( _n( '(based on %s rating)', '(based on %s ratings)', $api->num_ratings ), number_format_i18n( $api->num_ratings ) ); ?></small> |
|
493 | + <?php if ( ! empty($api->rating)) { ?> |
|
494 | + <h3><?php _e('Average Rating'); ?></h3> |
|
495 | + <?php wp_star_rating(array('rating' => $api->rating, 'type' => 'percent', 'number' => $api->num_ratings)); ?> |
|
496 | + <small><?php printf(_n('(based on %s rating)', '(based on %s ratings)', $api->num_ratings), number_format_i18n($api->num_ratings)); ?></small> |
|
497 | 497 | <?php } |
498 | 498 | |
499 | - if ( ! empty( $api->ratings ) && array_sum( (array) $api->ratings ) > 0 ) { |
|
500 | - foreach( $api->ratings as $key => $ratecount ) { |
|
499 | + if ( ! empty($api->ratings) && array_sum((array) $api->ratings) > 0) { |
|
500 | + foreach ($api->ratings as $key => $ratecount) { |
|
501 | 501 | // Avoid div-by-zero. |
502 | - $_rating = $api->num_ratings ? ( $ratecount / $api->num_ratings ) : 0; |
|
502 | + $_rating = $api->num_ratings ? ($ratecount / $api->num_ratings) : 0; |
|
503 | 503 | ?> |
504 | 504 | <div class="counter-container"> |
505 | 505 | <span class="counter-label"><a href="https://wordpress.org/support/view/plugin-reviews/<?php echo $api->slug; ?>?filter=<?php echo $key; ?>" |
506 | 506 | target="_blank" |
507 | - title="<?php echo esc_attr( sprintf( _n( 'Click to see reviews that provided a rating of %d star', 'Click to see reviews that provided a rating of %d stars', $key ), $key ) ); ?>"><?php printf( _n( '%d star', '%d stars', $key ), $key ); ?></a></span> |
|
507 | + title="<?php echo esc_attr(sprintf(_n('Click to see reviews that provided a rating of %d star', 'Click to see reviews that provided a rating of %d stars', $key), $key)); ?>"><?php printf(_n('%d star', '%d stars', $key), $key); ?></a></span> |
|
508 | 508 | <span class="counter-back"> |
509 | 509 | <span class="counter-bar" style="width: <?php echo 92 * $_rating; ?>px;"></span> |
510 | 510 | </span> |
511 | - <span class="counter-count"><?php echo number_format_i18n( $ratecount ); ?></span> |
|
511 | + <span class="counter-count"><?php echo number_format_i18n($ratecount); ?></span> |
|
512 | 512 | </div> |
513 | 513 | <?php |
514 | 514 | } |
515 | 515 | } |
516 | - if ( ! empty( $api->contributors ) ) { ?> |
|
517 | - <h3><?php _e( 'Contributors' ); ?></h3> |
|
516 | + if ( ! empty($api->contributors)) { ?> |
|
517 | + <h3><?php _e('Contributors'); ?></h3> |
|
518 | 518 | <ul class="contributors"> |
519 | 519 | <?php |
520 | - foreach ( (array) $api->contributors as $contrib_username => $contrib_profile ) { |
|
521 | - if ( empty( $contrib_username ) && empty( $contrib_profile ) ) { |
|
520 | + foreach ((array) $api->contributors as $contrib_username => $contrib_profile) { |
|
521 | + if (empty($contrib_username) && empty($contrib_profile)) { |
|
522 | 522 | continue; |
523 | 523 | } |
524 | - if ( empty( $contrib_username ) ) { |
|
525 | - $contrib_username = preg_replace( '/^.+\/(.+)\/?$/', '\1', $contrib_profile ); |
|
524 | + if (empty($contrib_username)) { |
|
525 | + $contrib_username = preg_replace('/^.+\/(.+)\/?$/', '\1', $contrib_profile); |
|
526 | 526 | } |
527 | - $contrib_username = sanitize_user( $contrib_username ); |
|
528 | - if ( empty( $contrib_profile ) ) { |
|
527 | + $contrib_username = sanitize_user($contrib_username); |
|
528 | + if (empty($contrib_profile)) { |
|
529 | 529 | echo "<li><img src='https://wordpress.org/grav-redirect.php?user={$contrib_username}&s=36' width='18' height='18' />{$contrib_username}</li>"; |
530 | 530 | } else { |
531 | 531 | echo "<li><a href='{$contrib_profile}' target='_blank'><img src='https://wordpress.org/grav-redirect.php?user={$contrib_username}&s=36' width='18' height='18' />{$contrib_username}</a></li>"; |
@@ -533,26 +533,26 @@ discard block |
||
533 | 533 | } |
534 | 534 | ?> |
535 | 535 | </ul> |
536 | - <?php if ( ! empty( $api->donate_link ) ) { ?> |
|
537 | - <a target="_blank" href="<?php echo esc_url( $api->donate_link ); ?>"><?php _e( 'Donate to this plugin »' ); ?></a> |
|
536 | + <?php if ( ! empty($api->donate_link)) { ?> |
|
537 | + <a target="_blank" href="<?php echo esc_url($api->donate_link); ?>"><?php _e('Donate to this plugin »'); ?></a> |
|
538 | 538 | <?php } ?> |
539 | 539 | <?php } ?> |
540 | 540 | </div> |
541 | 541 | <div id="section-holder" class="wrap"> |
542 | 542 | <?php |
543 | - if ( ! empty( $api->tested ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $api->tested ) ), $api->tested, '>' ) ) { |
|
544 | - echo '<div class="notice notice-warning"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been tested</strong> with your current version of WordPress.') . '</p></div>'; |
|
545 | - } elseif ( ! empty( $api->requires ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $api->requires ) ), $api->requires, '<' ) ) { |
|
546 | - echo '<div class="notice notice-warning"><p>' . __('<strong>Warning:</strong> This plugin has <strong>not been marked as compatible</strong> with your version of WordPress.') . '</p></div>'; |
|
543 | + if ( ! empty($api->tested) && version_compare(substr($GLOBALS['wp_version'], 0, strlen($api->tested)), $api->tested, '>')) { |
|
544 | + echo '<div class="notice notice-warning"><p>'.__('<strong>Warning:</strong> This plugin has <strong>not been tested</strong> with your current version of WordPress.').'</p></div>'; |
|
545 | + } elseif ( ! empty($api->requires) && version_compare(substr($GLOBALS['wp_version'], 0, strlen($api->requires)), $api->requires, '<')) { |
|
546 | + echo '<div class="notice notice-warning"><p>'.__('<strong>Warning:</strong> This plugin has <strong>not been marked as compatible</strong> with your version of WordPress.').'</p></div>'; |
|
547 | 547 | } |
548 | 548 | |
549 | - foreach ( (array) $api->sections as $section_name => $content ) { |
|
550 | - $content = links_add_base_url( $content, 'https://wordpress.org/plugins/' . $api->slug . '/' ); |
|
551 | - $content = links_add_target( $content, '_blank' ); |
|
549 | + foreach ((array) $api->sections as $section_name => $content) { |
|
550 | + $content = links_add_base_url($content, 'https://wordpress.org/plugins/'.$api->slug.'/'); |
|
551 | + $content = links_add_target($content, '_blank'); |
|
552 | 552 | |
553 | - $san_section = esc_attr( $section_name ); |
|
553 | + $san_section = esc_attr($section_name); |
|
554 | 554 | |
555 | - $display = ( $section_name === $section ) ? 'block' : 'none'; |
|
555 | + $display = ($section_name === $section) ? 'block' : 'none'; |
|
556 | 556 | |
557 | 557 | echo "\t<div id='section-{$san_section}' class='section' style='display: {$display};'>\n"; |
558 | 558 | echo $content; |
@@ -562,24 +562,24 @@ discard block |
||
562 | 562 | echo "</div>\n"; |
563 | 563 | echo "</div>\n"; // #plugin-information-scrollable |
564 | 564 | echo "<div id='$tab-footer'>\n"; |
565 | - if ( ! empty( $api->download_link ) && ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) ) { |
|
566 | - $status = install_plugin_install_status( $api ); |
|
567 | - switch ( $status['status'] ) { |
|
565 | + if ( ! empty($api->download_link) && (current_user_can('install_plugins') || current_user_can('update_plugins'))) { |
|
566 | + $status = install_plugin_install_status($api); |
|
567 | + switch ($status['status']) { |
|
568 | 568 | case 'install': |
569 | - if ( $status['url'] ) { |
|
570 | - echo '<a class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __( 'Install Now' ) . '</a>'; |
|
569 | + if ($status['url']) { |
|
570 | + echo '<a class="button button-primary right" href="'.$status['url'].'" target="_parent">'.__('Install Now').'</a>'; |
|
571 | 571 | } |
572 | 572 | break; |
573 | 573 | case 'update_available': |
574 | - if ( $status['url'] ) { |
|
575 | - echo '<a data-slug="' . esc_attr( $api->slug ) . '" id="plugin_update_from_iframe" class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __( 'Install Update Now' ) .'</a>'; |
|
574 | + if ($status['url']) { |
|
575 | + echo '<a data-slug="'.esc_attr($api->slug).'" id="plugin_update_from_iframe" class="button button-primary right" href="'.$status['url'].'" target="_parent">'.__('Install Update Now').'</a>'; |
|
576 | 576 | } |
577 | 577 | break; |
578 | 578 | case 'newer_installed': |
579 | - echo '<a class="button button-primary right disabled">' . sprintf( __( 'Newer Version (%s) Installed'), $status['version'] ) . '</a>'; |
|
579 | + echo '<a class="button button-primary right disabled">'.sprintf(__('Newer Version (%s) Installed'), $status['version']).'</a>'; |
|
580 | 580 | break; |
581 | 581 | case 'latest_installed': |
582 | - echo '<a class="button button-primary right disabled">' . __( 'Latest Version Installed' ) . '</a>'; |
|
582 | + echo '<a class="button button-primary right disabled">'.__('Latest Version Installed').'</a>'; |
|
583 | 583 | break; |
584 | 584 | } |
585 | 585 | } |
@@ -67,8 +67,9 @@ discard block |
||
67 | 67 | |
68 | 68 | if ( false === $res ) { |
69 | 69 | $url = $http_url = 'http://api.wordpress.org/plugins/info/1.0/'; |
70 | - if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) |
|
71 | - $url = set_url_scheme( $url, 'https' ); |
|
70 | + if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) { |
|
71 | + $url = set_url_scheme( $url, 'https' ); |
|
72 | + } |
|
72 | 73 | |
73 | 74 | $http_args = array( |
74 | 75 | 'timeout' => 15, |
@@ -88,8 +89,9 @@ discard block |
||
88 | 89 | $res = new WP_Error('plugins_api_failed', __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ), $request->get_error_message() ); |
89 | 90 | } else { |
90 | 91 | $res = maybe_unserialize( wp_remote_retrieve_body( $request ) ); |
91 | - if ( ! is_object( $res ) && ! is_array( $res ) ) |
|
92 | - $res = new WP_Error('plugins_api_failed', __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ), wp_remote_retrieve_body( $request ) ); |
|
92 | + if ( ! is_object( $res ) && ! is_array( $res ) ) { |
|
93 | + $res = new WP_Error('plugins_api_failed', __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ), wp_remote_retrieve_body( $request ) ); |
|
94 | + } |
|
93 | 95 | } |
94 | 96 | } elseif ( !is_wp_error($res) ) { |
95 | 97 | $res->external = true; |
@@ -117,13 +119,15 @@ discard block |
||
117 | 119 | */ |
118 | 120 | function install_popular_tags( $args = array() ) { |
119 | 121 | $key = md5(serialize($args)); |
120 | - if ( false !== ($tags = get_site_transient('poptags_' . $key) ) ) |
|
121 | - return $tags; |
|
122 | + if ( false !== ($tags = get_site_transient('poptags_' . $key) ) ) { |
|
123 | + return $tags; |
|
124 | + } |
|
122 | 125 | |
123 | 126 | $tags = plugins_api('hot_tags', $args); |
124 | 127 | |
125 | - if ( is_wp_error($tags) ) |
|
126 | - return $tags; |
|
128 | + if ( is_wp_error($tags) ) { |
|
129 | + return $tags; |
|
130 | + } |
|
127 | 131 | |
128 | 132 | set_site_transient( 'poptags_' . $key, $tags, 3 * HOUR_IN_SECONDS ); |
129 | 133 | |
@@ -278,8 +282,9 @@ discard block |
||
278 | 282 | */ |
279 | 283 | function install_plugin_install_status($api, $loop = false) { |
280 | 284 | // This function is called recursively, $loop prevents further loops. |
281 | - if ( is_array($api) ) |
|
282 | - $api = (object) $api; |
|
285 | + if ( is_array($api) ) { |
|
286 | + $api = (object) $api; |
|
287 | + } |
|
283 | 288 | |
284 | 289 | // Default to a "new" plugin |
285 | 290 | $status = 'install'; |
@@ -297,8 +302,9 @@ discard block |
||
297 | 302 | $status = 'update_available'; |
298 | 303 | $update_file = $file; |
299 | 304 | $version = $plugin->new_version; |
300 | - if ( current_user_can('update_plugins') ) |
|
301 | - $url = wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=' . $update_file), 'upgrade-plugin_' . $update_file); |
|
305 | + if ( current_user_can('update_plugins') ) { |
|
306 | + $url = wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=' . $update_file), 'upgrade-plugin_' . $update_file); |
|
307 | + } |
|
302 | 308 | break; |
303 | 309 | } |
304 | 310 | } |
@@ -308,8 +314,9 @@ discard block |
||
308 | 314 | if ( is_dir( WP_PLUGIN_DIR . '/' . $api->slug ) ) { |
309 | 315 | $installed_plugin = get_plugins('/' . $api->slug); |
310 | 316 | if ( empty($installed_plugin) ) { |
311 | - if ( current_user_can('install_plugins') ) |
|
312 | - $url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . $api->slug), 'install-plugin_' . $api->slug); |
|
317 | + if ( current_user_can('install_plugins') ) { |
|
318 | + $url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . $api->slug), 'install-plugin_' . $api->slug); |
|
319 | + } |
|
313 | 320 | } else { |
314 | 321 | $key = array_keys( $installed_plugin ); |
315 | 322 | $key = reset( $key ); //Use the first plugin regardless of the name, Could have issues for multiple-plugins in one directory if they share different version numbers |
@@ -330,12 +337,14 @@ discard block |
||
330 | 337 | } |
331 | 338 | } else { |
332 | 339 | // "install" & no directory with that slug |
333 | - if ( current_user_can('install_plugins') ) |
|
334 | - $url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . $api->slug), 'install-plugin_' . $api->slug); |
|
340 | + if ( current_user_can('install_plugins') ) { |
|
341 | + $url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . $api->slug), 'install-plugin_' . $api->slug); |
|
342 | + } |
|
335 | 343 | } |
336 | 344 | } |
337 | - if ( isset($_GET['from']) ) |
|
338 | - $url .= '&from=' . urlencode( wp_unslash( $_GET['from'] ) ); |
|
345 | + if ( isset($_GET['from']) ) { |
|
346 | + $url .= '&from=' . urlencode( wp_unslash( $_GET['from'] ) ); |
|
347 | + } |
|
339 | 348 | |
340 | 349 | $file = $update_file; |
341 | 350 | return compact( 'status', 'url', 'version', 'file' ); |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * Theme Installer List Table class. |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage List_Table |
|
7 | - * @since 3.1.0 |
|
8 | - * @access private |
|
9 | - */ |
|
3 | + * Theme Installer List Table class. |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage List_Table |
|
7 | + * @since 3.1.0 |
|
8 | + * @access private |
|
9 | + */ |
|
10 | 10 | class WP_Theme_Install_List_Table extends WP_Themes_List_Table { |
11 | 11 | |
12 | 12 | public $features = array(); |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * @return bool |
17 | 17 | */ |
18 | 18 | public function ajax_user_can() { |
19 | - return current_user_can( 'install_themes' ); |
|
19 | + return current_user_can('install_themes'); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | /** |
@@ -28,19 +28,19 @@ discard block |
||
28 | 28 | * @global array $theme_field_defaults |
29 | 29 | */ |
30 | 30 | public function prepare_items() { |
31 | - include( ABSPATH . 'wp-admin/includes/theme-install.php' ); |
|
31 | + include(ABSPATH.'wp-admin/includes/theme-install.php'); |
|
32 | 32 | |
33 | 33 | global $tabs, $tab, $paged, $type, $theme_field_defaults; |
34 | - wp_reset_vars( array( 'tab' ) ); |
|
34 | + wp_reset_vars(array('tab')); |
|
35 | 35 | |
36 | 36 | $search_terms = array(); |
37 | 37 | $search_string = ''; |
38 | - if ( ! empty( $_REQUEST['s'] ) ){ |
|
39 | - $search_string = strtolower( wp_unslash( $_REQUEST['s'] ) ); |
|
40 | - $search_terms = array_unique( array_filter( array_map( 'trim', explode( ',', $search_string ) ) ) ); |
|
38 | + if ( ! empty($_REQUEST['s'])) { |
|
39 | + $search_string = strtolower(wp_unslash($_REQUEST['s'])); |
|
40 | + $search_terms = array_unique(array_filter(array_map('trim', explode(',', $search_string)))); |
|
41 | 41 | } |
42 | 42 | |
43 | - if ( ! empty( $_REQUEST['features'] ) ) |
|
43 | + if ( ! empty($_REQUEST['features'])) |
|
44 | 44 | $this->features = $_REQUEST['features']; |
45 | 45 | |
46 | 46 | $paged = $this->get_pagenum(); |
@@ -49,19 +49,19 @@ discard block |
||
49 | 49 | |
50 | 50 | // These are the tabs which are shown on the page, |
51 | 51 | $tabs = array(); |
52 | - $tabs['dashboard'] = __( 'Search' ); |
|
53 | - if ( 'search' == $tab ) |
|
54 | - $tabs['search'] = __( 'Search Results' ); |
|
55 | - $tabs['upload'] = __( 'Upload' ); |
|
56 | - $tabs['featured'] = _x( 'Featured', 'themes' ); |
|
52 | + $tabs['dashboard'] = __('Search'); |
|
53 | + if ('search' == $tab) |
|
54 | + $tabs['search'] = __('Search Results'); |
|
55 | + $tabs['upload'] = __('Upload'); |
|
56 | + $tabs['featured'] = _x('Featured', 'themes'); |
|
57 | 57 | //$tabs['popular'] = _x( 'Popular', 'themes' ); |
58 | - $tabs['new'] = _x( 'Latest', 'themes' ); |
|
59 | - $tabs['updated'] = _x( 'Recently Updated', 'themes' ); |
|
58 | + $tabs['new'] = _x('Latest', 'themes'); |
|
59 | + $tabs['updated'] = _x('Recently Updated', 'themes'); |
|
60 | 60 | |
61 | - $nonmenu_tabs = array( 'theme-information' ); // Valid actions to perform which do not have a Menu item. |
|
61 | + $nonmenu_tabs = array('theme-information'); // Valid actions to perform which do not have a Menu item. |
|
62 | 62 | |
63 | 63 | /** This filter is documented in wp-admin/theme-install.php */ |
64 | - $tabs = apply_filters( 'install_themes_tabs', $tabs ); |
|
64 | + $tabs = apply_filters('install_themes_tabs', $tabs); |
|
65 | 65 | |
66 | 66 | /** |
67 | 67 | * Filter tabs not associated with a menu item on the Install Themes screen. |
@@ -71,20 +71,20 @@ discard block |
||
71 | 71 | * @param array $nonmenu_tabs The tabs that don't have a menu item on |
72 | 72 | * the Install Themes screen. |
73 | 73 | */ |
74 | - $nonmenu_tabs = apply_filters( 'install_themes_nonmenu_tabs', $nonmenu_tabs ); |
|
74 | + $nonmenu_tabs = apply_filters('install_themes_nonmenu_tabs', $nonmenu_tabs); |
|
75 | 75 | |
76 | 76 | // If a non-valid menu tab has been selected, And it's not a non-menu action. |
77 | - if ( empty( $tab ) || ( ! isset( $tabs[ $tab ] ) && ! in_array( $tab, (array) $nonmenu_tabs ) ) ) |
|
78 | - $tab = key( $tabs ); |
|
77 | + if (empty($tab) || ( ! isset($tabs[$tab]) && ! in_array($tab, (array) $nonmenu_tabs))) |
|
78 | + $tab = key($tabs); |
|
79 | 79 | |
80 | - $args = array( 'page' => $paged, 'per_page' => $per_page, 'fields' => $theme_field_defaults ); |
|
80 | + $args = array('page' => $paged, 'per_page' => $per_page, 'fields' => $theme_field_defaults); |
|
81 | 81 | |
82 | - switch ( $tab ) { |
|
82 | + switch ($tab) { |
|
83 | 83 | case 'search': |
84 | - $type = isset( $_REQUEST['type'] ) ? wp_unslash( $_REQUEST['type'] ) : 'term'; |
|
85 | - switch ( $type ) { |
|
84 | + $type = isset($_REQUEST['type']) ? wp_unslash($_REQUEST['type']) : 'term'; |
|
85 | + switch ($type) { |
|
86 | 86 | case 'tag': |
87 | - $args['tag'] = array_map( 'sanitize_key', $search_terms ); |
|
87 | + $args['tag'] = array_map('sanitize_key', $search_terms); |
|
88 | 88 | break; |
89 | 89 | case 'term': |
90 | 90 | $args['search'] = $search_string; |
@@ -94,13 +94,13 @@ discard block |
||
94 | 94 | break; |
95 | 95 | } |
96 | 96 | |
97 | - if ( ! empty( $this->features ) ) { |
|
97 | + if ( ! empty($this->features)) { |
|
98 | 98 | $args['tag'] = $this->features; |
99 | - $_REQUEST['s'] = implode( ',', $this->features ); |
|
99 | + $_REQUEST['s'] = implode(',', $this->features); |
|
100 | 100 | $_REQUEST['type'] = 'tag'; |
101 | 101 | } |
102 | 102 | |
103 | - add_action( 'install_themes_table_header', 'install_theme_search_form', 10, 0 ); |
|
103 | + add_action('install_themes_table_header', 'install_theme_search_form', 10, 0); |
|
104 | 104 | break; |
105 | 105 | |
106 | 106 | case 'featured': |
@@ -126,30 +126,30 @@ discard block |
||
126 | 126 | * |
127 | 127 | * @param array $args An array of themes API arguments. |
128 | 128 | */ |
129 | - $args = apply_filters( 'install_themes_table_api_args_' . $tab, $args ); |
|
129 | + $args = apply_filters('install_themes_table_api_args_'.$tab, $args); |
|
130 | 130 | |
131 | - if ( ! $args ) |
|
131 | + if ( ! $args) |
|
132 | 132 | return; |
133 | 133 | |
134 | - $api = themes_api( 'query_themes', $args ); |
|
134 | + $api = themes_api('query_themes', $args); |
|
135 | 135 | |
136 | - if ( is_wp_error( $api ) ) |
|
137 | - wp_die( $api->get_error_message() . '</p> <p><a href="#" onclick="document.location.reload(); return false;">' . __( 'Try again' ) . '</a>' ); |
|
136 | + if (is_wp_error($api)) |
|
137 | + wp_die($api->get_error_message().'</p> <p><a href="#" onclick="document.location.reload(); return false;">'.__('Try again').'</a>'); |
|
138 | 138 | |
139 | 139 | $this->items = $api->themes; |
140 | 140 | |
141 | - $this->set_pagination_args( array( |
|
141 | + $this->set_pagination_args(array( |
|
142 | 142 | 'total_items' => $api->info['results'], |
143 | 143 | 'per_page' => $args['per_page'], |
144 | 144 | 'infinite_scroll' => true, |
145 | - ) ); |
|
145 | + )); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | /** |
149 | 149 | * @access public |
150 | 150 | */ |
151 | 151 | public function no_items() { |
152 | - _e( 'No themes match your request.' ); |
|
152 | + _e('No themes match your request.'); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -162,9 +162,9 @@ discard block |
||
162 | 162 | global $tabs, $tab; |
163 | 163 | |
164 | 164 | $display_tabs = array(); |
165 | - foreach ( (array) $tabs as $action => $text ) { |
|
166 | - $class = ( $action == $tab ) ? ' class="current"' : ''; |
|
167 | - $href = self_admin_url('theme-install.php?tab=' . $action); |
|
165 | + foreach ((array) $tabs as $action => $text) { |
|
166 | + $class = ($action == $tab) ? ' class="current"' : ''; |
|
167 | + $href = self_admin_url('theme-install.php?tab='.$action); |
|
168 | 168 | $display_tabs['theme-install-'.$action] = "<a href='$href'$class>$text</a>"; |
169 | 169 | } |
170 | 170 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | * @access public |
176 | 176 | */ |
177 | 177 | public function display() { |
178 | - wp_nonce_field( "fetch-list-" . get_class( $this ), '_ajax_fetch_list_nonce' ); |
|
178 | + wp_nonce_field("fetch-list-".get_class($this), '_ajax_fetch_list_nonce'); |
|
179 | 179 | ?> |
180 | 180 | <div class="tablenav top themes"> |
181 | 181 | <div class="alignleft actions"> |
@@ -185,10 +185,10 @@ discard block |
||
185 | 185 | * |
186 | 186 | * @since 2.8.0 |
187 | 187 | */ |
188 | - do_action( 'install_themes_table_header' ); |
|
188 | + do_action('install_themes_table_header'); |
|
189 | 189 | ?> |
190 | 190 | </div> |
191 | - <?php $this->pagination( 'top' ); ?> |
|
191 | + <?php $this->pagination('top'); ?> |
|
192 | 192 | <br class="clear" /> |
193 | 193 | </div> |
194 | 194 | |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | </div> |
198 | 198 | |
199 | 199 | <?php |
200 | - $this->tablenav( 'bottom' ); |
|
200 | + $this->tablenav('bottom'); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
@@ -205,10 +205,10 @@ discard block |
||
205 | 205 | */ |
206 | 206 | public function display_rows() { |
207 | 207 | $themes = $this->items; |
208 | - foreach ( $themes as $theme ) { |
|
208 | + foreach ($themes as $theme) { |
|
209 | 209 | ?> |
210 | 210 | <div class="available-theme installable-theme"><?php |
211 | - $this->single_row( $theme ); |
|
211 | + $this->single_row($theme); |
|
212 | 212 | ?></div> |
213 | 213 | <?php } // end foreach $theme_names |
214 | 214 | |
@@ -236,50 +236,50 @@ discard block |
||
236 | 236 | * public 'description' => string 'A basic magazine style layout with a fully customizable layout through a backend interface. Designed by <a href="http://bavotasan.com">c.bavota</a> of <a href="http://tinkerpriestmedia.com">Tinker Priest Media</a>.' |
237 | 237 | * public 'download_link' => string 'http://wordpress.org/themes/download/magazine-basic.1.1.zip' |
238 | 238 | */ |
239 | - public function single_row( $theme ) { |
|
239 | + public function single_row($theme) { |
|
240 | 240 | global $themes_allowedtags; |
241 | 241 | |
242 | - if ( empty( $theme ) ) |
|
242 | + if (empty($theme)) |
|
243 | 243 | return; |
244 | 244 | |
245 | - $name = wp_kses( $theme->name, $themes_allowedtags ); |
|
246 | - $author = wp_kses( $theme->author, $themes_allowedtags ); |
|
245 | + $name = wp_kses($theme->name, $themes_allowedtags); |
|
246 | + $author = wp_kses($theme->author, $themes_allowedtags); |
|
247 | 247 | |
248 | - $preview_title = sprintf( __('Preview “%s”'), $name ); |
|
249 | - $preview_url = add_query_arg( array( |
|
248 | + $preview_title = sprintf(__('Preview “%s”'), $name); |
|
249 | + $preview_url = add_query_arg(array( |
|
250 | 250 | 'tab' => 'theme-information', |
251 | 251 | 'theme' => $theme->slug, |
252 | - ), self_admin_url( 'theme-install.php' ) ); |
|
252 | + ), self_admin_url('theme-install.php')); |
|
253 | 253 | |
254 | 254 | $actions = array(); |
255 | 255 | |
256 | - $install_url = add_query_arg( array( |
|
256 | + $install_url = add_query_arg(array( |
|
257 | 257 | 'action' => 'install-theme', |
258 | 258 | 'theme' => $theme->slug, |
259 | - ), self_admin_url( 'update.php' ) ); |
|
259 | + ), self_admin_url('update.php')); |
|
260 | 260 | |
261 | - $update_url = add_query_arg( array( |
|
261 | + $update_url = add_query_arg(array( |
|
262 | 262 | 'action' => 'upgrade-theme', |
263 | 263 | 'theme' => $theme->slug, |
264 | - ), self_admin_url( 'update.php' ) ); |
|
264 | + ), self_admin_url('update.php')); |
|
265 | 265 | |
266 | - $status = $this->_get_theme_status( $theme ); |
|
266 | + $status = $this->_get_theme_status($theme); |
|
267 | 267 | |
268 | - switch ( $status ) { |
|
268 | + switch ($status) { |
|
269 | 269 | case 'update_available': |
270 | - $actions[] = '<a class="install-now" href="' . esc_url( wp_nonce_url( $update_url, 'upgrade-theme_' . $theme->slug ) ) . '" title="' . esc_attr( sprintf( __( 'Update to version %s' ), $theme->version ) ) . '">' . __( 'Update' ) . '</a>'; |
|
270 | + $actions[] = '<a class="install-now" href="'.esc_url(wp_nonce_url($update_url, 'upgrade-theme_'.$theme->slug)).'" title="'.esc_attr(sprintf(__('Update to version %s'), $theme->version)).'">'.__('Update').'</a>'; |
|
271 | 271 | break; |
272 | 272 | case 'newer_installed': |
273 | 273 | case 'latest_installed': |
274 | - $actions[] = '<span class="install-now" title="' . esc_attr__( 'This theme is already installed and is up to date' ) . '">' . _x( 'Installed', 'theme' ) . '</span>'; |
|
274 | + $actions[] = '<span class="install-now" title="'.esc_attr__('This theme is already installed and is up to date').'">'._x('Installed', 'theme').'</span>'; |
|
275 | 275 | break; |
276 | 276 | case 'install': |
277 | 277 | default: |
278 | - $actions[] = '<a class="install-now" href="' . esc_url( wp_nonce_url( $install_url, 'install-theme_' . $theme->slug ) ) . '" title="' . esc_attr( sprintf( __( 'Install %s' ), $name ) ) . '">' . __( 'Install Now' ) . '</a>'; |
|
278 | + $actions[] = '<a class="install-now" href="'.esc_url(wp_nonce_url($install_url, 'install-theme_'.$theme->slug)).'" title="'.esc_attr(sprintf(__('Install %s'), $name)).'">'.__('Install Now').'</a>'; |
|
279 | 279 | break; |
280 | 280 | } |
281 | 281 | |
282 | - $actions[] = '<a class="install-theme-preview" href="' . esc_url( $preview_url ) . '" title="' . esc_attr( sprintf( __( 'Preview %s' ), $name ) ) . '">' . __( 'Preview' ) . '</a>'; |
|
282 | + $actions[] = '<a class="install-theme-preview" href="'.esc_url($preview_url).'" title="'.esc_attr(sprintf(__('Preview %s'), $name)).'">'.__('Preview').'</a>'; |
|
283 | 283 | |
284 | 284 | /** |
285 | 285 | * Filter the install action links for a theme in the Install Themes list table. |
@@ -290,19 +290,19 @@ discard block |
||
290 | 290 | * links to Install Now, Preview, and Details. |
291 | 291 | * @param WP_Theme $theme Theme object. |
292 | 292 | */ |
293 | - $actions = apply_filters( 'theme_install_actions', $actions, $theme ); |
|
293 | + $actions = apply_filters('theme_install_actions', $actions, $theme); |
|
294 | 294 | |
295 | 295 | ?> |
296 | - <a class="screenshot install-theme-preview" href="<?php echo esc_url( $preview_url ); ?>" title="<?php echo esc_attr( $preview_title ); ?>"> |
|
297 | - <img src="<?php echo esc_url( $theme->screenshot_url ); ?>" width="150" /> |
|
296 | + <a class="screenshot install-theme-preview" href="<?php echo esc_url($preview_url); ?>" title="<?php echo esc_attr($preview_title); ?>"> |
|
297 | + <img src="<?php echo esc_url($theme->screenshot_url); ?>" width="150" /> |
|
298 | 298 | </a> |
299 | 299 | |
300 | 300 | <h3><?php echo $name; ?></h3> |
301 | - <div class="theme-author"><?php printf( __( 'By %s' ), $author ); ?></div> |
|
301 | + <div class="theme-author"><?php printf(__('By %s'), $author); ?></div> |
|
302 | 302 | |
303 | 303 | <div class="action-links"> |
304 | 304 | <ul> |
305 | - <?php foreach ( $actions as $action ): ?> |
|
305 | + <?php foreach ($actions as $action): ?> |
|
306 | 306 | <li><?php echo $action; ?></li> |
307 | 307 | <?php endforeach; ?> |
308 | 308 | <li class="hide-if-no-js"><a href="#" class="theme-detail"><?php _e('Details') ?></a></li> |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | </div> |
311 | 311 | |
312 | 312 | <?php |
313 | - $this->install_theme_info( $theme ); |
|
313 | + $this->install_theme_info($theme); |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | /** |
@@ -321,16 +321,16 @@ discard block |
||
321 | 321 | <div id="theme-installer" class="wp-full-overlay expanded"> |
322 | 322 | <div class="wp-full-overlay-sidebar"> |
323 | 323 | <div class="wp-full-overlay-header"> |
324 | - <a href="#" class="close-full-overlay button-secondary"><?php _e( 'Close' ); ?></a> |
|
324 | + <a href="#" class="close-full-overlay button-secondary"><?php _e('Close'); ?></a> |
|
325 | 325 | <span class="theme-install"></span> |
326 | 326 | </div> |
327 | 327 | <div class="wp-full-overlay-sidebar-content"> |
328 | 328 | <div class="install-theme-info"></div> |
329 | 329 | </div> |
330 | 330 | <div class="wp-full-overlay-footer"> |
331 | - <button type="button" class="collapse-sidebar button-secondary" aria-expanded="true" aria-label="<?php esc_attr_e( 'Collapse Sidebar' ); ?>"> |
|
331 | + <button type="button" class="collapse-sidebar button-secondary" aria-expanded="true" aria-label="<?php esc_attr_e('Collapse Sidebar'); ?>"> |
|
332 | 332 | <span class="collapse-sidebar-arrow"></span> |
333 | - <span class="collapse-sidebar-label"><?php _e( 'Collapse' ); ?></span> |
|
333 | + <span class="collapse-sidebar-label"><?php _e('Collapse'); ?></span> |
|
334 | 334 | </button> |
335 | 335 | </div> |
336 | 336 | </div> |
@@ -345,14 +345,14 @@ discard block |
||
345 | 345 | * |
346 | 346 | * @param object $theme - A WordPress.org Theme API object. |
347 | 347 | */ |
348 | - public function theme_installer_single( $theme ) { |
|
348 | + public function theme_installer_single($theme) { |
|
349 | 349 | ?> |
350 | 350 | <div id="theme-installer" class="wp-full-overlay single-theme"> |
351 | 351 | <div class="wp-full-overlay-sidebar"> |
352 | - <?php $this->install_theme_info( $theme ); ?> |
|
352 | + <?php $this->install_theme_info($theme); ?> |
|
353 | 353 | </div> |
354 | 354 | <div class="wp-full-overlay-main"> |
355 | - <iframe src="<?php echo esc_url( $theme->preview_url ); ?>"></iframe> |
|
355 | + <iframe src="<?php echo esc_url($theme->preview_url); ?>"></iframe> |
|
356 | 356 | </div> |
357 | 357 | </div> |
358 | 358 | <?php |
@@ -365,58 +365,58 @@ discard block |
||
365 | 365 | * |
366 | 366 | * @param object $theme - A WordPress.org Theme API object. |
367 | 367 | */ |
368 | - public function install_theme_info( $theme ) { |
|
368 | + public function install_theme_info($theme) { |
|
369 | 369 | global $themes_allowedtags; |
370 | 370 | |
371 | - if ( empty( $theme ) ) |
|
371 | + if (empty($theme)) |
|
372 | 372 | return; |
373 | 373 | |
374 | - $name = wp_kses( $theme->name, $themes_allowedtags ); |
|
375 | - $author = wp_kses( $theme->author, $themes_allowedtags ); |
|
374 | + $name = wp_kses($theme->name, $themes_allowedtags); |
|
375 | + $author = wp_kses($theme->author, $themes_allowedtags); |
|
376 | 376 | |
377 | - $install_url = add_query_arg( array( |
|
377 | + $install_url = add_query_arg(array( |
|
378 | 378 | 'action' => 'install-theme', |
379 | 379 | 'theme' => $theme->slug, |
380 | - ), self_admin_url( 'update.php' ) ); |
|
380 | + ), self_admin_url('update.php')); |
|
381 | 381 | |
382 | - $update_url = add_query_arg( array( |
|
382 | + $update_url = add_query_arg(array( |
|
383 | 383 | 'action' => 'upgrade-theme', |
384 | 384 | 'theme' => $theme->slug, |
385 | - ), self_admin_url( 'update.php' ) ); |
|
385 | + ), self_admin_url('update.php')); |
|
386 | 386 | |
387 | - $status = $this->_get_theme_status( $theme ); |
|
387 | + $status = $this->_get_theme_status($theme); |
|
388 | 388 | |
389 | 389 | ?> |
390 | 390 | <div class="install-theme-info"><?php |
391 | - switch ( $status ) { |
|
391 | + switch ($status) { |
|
392 | 392 | case 'update_available': |
393 | - echo '<a class="theme-install button-primary" href="' . esc_url( wp_nonce_url( $update_url, 'upgrade-theme_' . $theme->slug ) ) . '" title="' . esc_attr( sprintf( __( 'Update to version %s' ), $theme->version ) ) . '">' . __( 'Update' ) . '</a>'; |
|
393 | + echo '<a class="theme-install button-primary" href="'.esc_url(wp_nonce_url($update_url, 'upgrade-theme_'.$theme->slug)).'" title="'.esc_attr(sprintf(__('Update to version %s'), $theme->version)).'">'.__('Update').'</a>'; |
|
394 | 394 | break; |
395 | 395 | case 'newer_installed': |
396 | 396 | case 'latest_installed': |
397 | - echo '<span class="theme-install" title="' . esc_attr__( 'This theme is already installed and is up to date' ) . '">' . _x( 'Installed', 'theme' ) . '</span>'; |
|
397 | + echo '<span class="theme-install" title="'.esc_attr__('This theme is already installed and is up to date').'">'._x('Installed', 'theme').'</span>'; |
|
398 | 398 | break; |
399 | 399 | case 'install': |
400 | 400 | default: |
401 | - echo '<a class="theme-install button-primary" href="' . esc_url( wp_nonce_url( $install_url, 'install-theme_' . $theme->slug ) ) . '">' . __( 'Install' ) . '</a>'; |
|
401 | + echo '<a class="theme-install button-primary" href="'.esc_url(wp_nonce_url($install_url, 'install-theme_'.$theme->slug)).'">'.__('Install').'</a>'; |
|
402 | 402 | break; |
403 | 403 | } ?> |
404 | 404 | <h3 class="theme-name"><?php echo $name; ?></h3> |
405 | - <span class="theme-by"><?php printf( __( 'By %s' ), $author ); ?></span> |
|
406 | - <?php if ( isset( $theme->screenshot_url ) ): ?> |
|
407 | - <img class="theme-screenshot" src="<?php echo esc_url( $theme->screenshot_url ); ?>" /> |
|
405 | + <span class="theme-by"><?php printf(__('By %s'), $author); ?></span> |
|
406 | + <?php if (isset($theme->screenshot_url)): ?> |
|
407 | + <img class="theme-screenshot" src="<?php echo esc_url($theme->screenshot_url); ?>" /> |
|
408 | 408 | <?php endif; ?> |
409 | 409 | <div class="theme-details"> |
410 | - <?php wp_star_rating( array( 'rating' => $theme->rating, 'type' => 'percent', 'number' => $theme->num_ratings ) ); ?> |
|
410 | + <?php wp_star_rating(array('rating' => $theme->rating, 'type' => 'percent', 'number' => $theme->num_ratings)); ?> |
|
411 | 411 | <div class="theme-version"> |
412 | 412 | <strong><?php _e('Version:') ?> </strong> |
413 | - <?php echo wp_kses( $theme->version, $themes_allowedtags ); ?> |
|
413 | + <?php echo wp_kses($theme->version, $themes_allowedtags); ?> |
|
414 | 414 | </div> |
415 | 415 | <div class="theme-description"> |
416 | - <?php echo wp_kses( $theme->description, $themes_allowedtags ); ?> |
|
416 | + <?php echo wp_kses($theme->description, $themes_allowedtags); ?> |
|
417 | 417 | </div> |
418 | 418 | </div> |
419 | - <input class="theme-preview-url" type="hidden" value="<?php echo esc_url( $theme->preview_url ); ?>" /> |
|
419 | + <input class="theme-preview-url" type="hidden" value="<?php echo esc_url($theme->preview_url); ?>" /> |
|
420 | 420 | </div> |
421 | 421 | <?php |
422 | 422 | } |
@@ -432,9 +432,9 @@ discard block |
||
432 | 432 | * |
433 | 433 | * @param array $extra_args Unused. |
434 | 434 | */ |
435 | - public function _js_vars( $extra_args = array() ) { |
|
435 | + public function _js_vars($extra_args = array()) { |
|
436 | 436 | global $tab, $type; |
437 | - parent::_js_vars( compact( 'tab', 'type' ) ); |
|
437 | + parent::_js_vars(compact('tab', 'type')); |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | /** |
@@ -446,14 +446,14 @@ discard block |
||
446 | 446 | * @param object $theme - A WordPress.org Theme API object. |
447 | 447 | * @return string Theme status. |
448 | 448 | */ |
449 | - private function _get_theme_status( $theme ) { |
|
449 | + private function _get_theme_status($theme) { |
|
450 | 450 | $status = 'install'; |
451 | 451 | |
452 | - $installed_theme = wp_get_theme( $theme->slug ); |
|
453 | - if ( $installed_theme->exists() ) { |
|
454 | - if ( version_compare( $installed_theme->get('Version'), $theme->version, '=' ) ) |
|
452 | + $installed_theme = wp_get_theme($theme->slug); |
|
453 | + if ($installed_theme->exists()) { |
|
454 | + if (version_compare($installed_theme->get('Version'), $theme->version, '=')) |
|
455 | 455 | $status = 'latest_installed'; |
456 | - elseif ( version_compare( $installed_theme->get('Version'), $theme->version, '>' ) ) |
|
456 | + elseif (version_compare($installed_theme->get('Version'), $theme->version, '>')) |
|
457 | 457 | $status = 'newer_installed'; |
458 | 458 | else |
459 | 459 | $status = 'update_available'; |
@@ -40,8 +40,9 @@ discard block |
||
40 | 40 | $search_terms = array_unique( array_filter( array_map( 'trim', explode( ',', $search_string ) ) ) ); |
41 | 41 | } |
42 | 42 | |
43 | - if ( ! empty( $_REQUEST['features'] ) ) |
|
44 | - $this->features = $_REQUEST['features']; |
|
43 | + if ( ! empty( $_REQUEST['features'] ) ) { |
|
44 | + $this->features = $_REQUEST['features']; |
|
45 | + } |
|
45 | 46 | |
46 | 47 | $paged = $this->get_pagenum(); |
47 | 48 | |
@@ -50,8 +51,9 @@ discard block |
||
50 | 51 | // These are the tabs which are shown on the page, |
51 | 52 | $tabs = array(); |
52 | 53 | $tabs['dashboard'] = __( 'Search' ); |
53 | - if ( 'search' == $tab ) |
|
54 | - $tabs['search'] = __( 'Search Results' ); |
|
54 | + if ( 'search' == $tab ) { |
|
55 | + $tabs['search'] = __( 'Search Results' ); |
|
56 | + } |
|
55 | 57 | $tabs['upload'] = __( 'Upload' ); |
56 | 58 | $tabs['featured'] = _x( 'Featured', 'themes' ); |
57 | 59 | //$tabs['popular'] = _x( 'Popular', 'themes' ); |
@@ -74,8 +76,9 @@ discard block |
||
74 | 76 | $nonmenu_tabs = apply_filters( 'install_themes_nonmenu_tabs', $nonmenu_tabs ); |
75 | 77 | |
76 | 78 | // If a non-valid menu tab has been selected, And it's not a non-menu action. |
77 | - if ( empty( $tab ) || ( ! isset( $tabs[ $tab ] ) && ! in_array( $tab, (array) $nonmenu_tabs ) ) ) |
|
78 | - $tab = key( $tabs ); |
|
79 | + if ( empty( $tab ) || ( ! isset( $tabs[ $tab ] ) && ! in_array( $tab, (array) $nonmenu_tabs ) ) ) { |
|
80 | + $tab = key( $tabs ); |
|
81 | + } |
|
79 | 82 | |
80 | 83 | $args = array( 'page' => $paged, 'per_page' => $per_page, 'fields' => $theme_field_defaults ); |
81 | 84 | |
@@ -128,13 +131,15 @@ discard block |
||
128 | 131 | */ |
129 | 132 | $args = apply_filters( 'install_themes_table_api_args_' . $tab, $args ); |
130 | 133 | |
131 | - if ( ! $args ) |
|
132 | - return; |
|
134 | + if ( ! $args ) { |
|
135 | + return; |
|
136 | + } |
|
133 | 137 | |
134 | 138 | $api = themes_api( 'query_themes', $args ); |
135 | 139 | |
136 | - if ( is_wp_error( $api ) ) |
|
137 | - wp_die( $api->get_error_message() . '</p> <p><a href="#" onclick="document.location.reload(); return false;">' . __( 'Try again' ) . '</a>' ); |
|
140 | + if ( is_wp_error( $api ) ) { |
|
141 | + wp_die( $api->get_error_message() . '</p> <p><a href="#" onclick="document.location.reload(); return false;">' . __( 'Try again' ) . '</a>' ); |
|
142 | + } |
|
138 | 143 | |
139 | 144 | $this->items = $api->themes; |
140 | 145 | |
@@ -239,8 +244,9 @@ discard block |
||
239 | 244 | public function single_row( $theme ) { |
240 | 245 | global $themes_allowedtags; |
241 | 246 | |
242 | - if ( empty( $theme ) ) |
|
243 | - return; |
|
247 | + if ( empty( $theme ) ) { |
|
248 | + return; |
|
249 | + } |
|
244 | 250 | |
245 | 251 | $name = wp_kses( $theme->name, $themes_allowedtags ); |
246 | 252 | $author = wp_kses( $theme->author, $themes_allowedtags ); |
@@ -368,8 +374,9 @@ discard block |
||
368 | 374 | public function install_theme_info( $theme ) { |
369 | 375 | global $themes_allowedtags; |
370 | 376 | |
371 | - if ( empty( $theme ) ) |
|
372 | - return; |
|
377 | + if ( empty( $theme ) ) { |
|
378 | + return; |
|
379 | + } |
|
373 | 380 | |
374 | 381 | $name = wp_kses( $theme->name, $themes_allowedtags ); |
375 | 382 | $author = wp_kses( $theme->author, $themes_allowedtags ); |
@@ -451,12 +458,13 @@ discard block |
||
451 | 458 | |
452 | 459 | $installed_theme = wp_get_theme( $theme->slug ); |
453 | 460 | if ( $installed_theme->exists() ) { |
454 | - if ( version_compare( $installed_theme->get('Version'), $theme->version, '=' ) ) |
|
455 | - $status = 'latest_installed'; |
|
456 | - elseif ( version_compare( $installed_theme->get('Version'), $theme->version, '>' ) ) |
|
457 | - $status = 'newer_installed'; |
|
458 | - else |
|
459 | - $status = 'update_available'; |
|
461 | + if ( version_compare( $installed_theme->get('Version'), $theme->version, '=' ) ) { |
|
462 | + $status = 'latest_installed'; |
|
463 | + } elseif ( version_compare( $installed_theme->get('Version'), $theme->version, '>' ) ) { |
|
464 | + $status = 'newer_installed'; |
|
465 | + } else { |
|
466 | + $status = 'update_available'; |
|
467 | + } |
|
460 | 468 | } |
461 | 469 | |
462 | 470 | return $status; |