@@ -20,45 +20,45 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @param array $request The unsanitized request values. |
22 | 22 | */ |
23 | -function _wp_ajax_menu_quick_search( $request = array() ) { |
|
23 | +function _wp_ajax_menu_quick_search($request = array()) { |
|
24 | 24 | $args = array(); |
25 | - $type = isset( $request['type'] ) ? $request['type'] : ''; |
|
26 | - $object_type = isset( $request['object_type'] ) ? $request['object_type'] : ''; |
|
27 | - $query = isset( $request['q'] ) ? $request['q'] : ''; |
|
28 | - $response_format = isset( $request['response-format'] ) ? $request['response-format'] : ''; |
|
25 | + $type = isset($request['type']) ? $request['type'] : ''; |
|
26 | + $object_type = isset($request['object_type']) ? $request['object_type'] : ''; |
|
27 | + $query = isset($request['q']) ? $request['q'] : ''; |
|
28 | + $response_format = isset($request['response-format']) ? $request['response-format'] : ''; |
|
29 | 29 | |
30 | - if ( ! $response_format || ! in_array( $response_format, array( 'json', 'markup' ), true ) ) { |
|
30 | + if (!$response_format || !in_array($response_format, array('json', 'markup'), true)) { |
|
31 | 31 | $response_format = 'json'; |
32 | 32 | } |
33 | 33 | |
34 | - if ( 'markup' === $response_format ) { |
|
34 | + if ('markup' === $response_format) { |
|
35 | 35 | $args['walker'] = new Walker_Nav_Menu_Checklist; |
36 | 36 | } |
37 | 37 | |
38 | - if ( 'get-post-item' === $type ) { |
|
39 | - if ( post_type_exists( $object_type ) ) { |
|
40 | - if ( isset( $request['ID'] ) ) { |
|
38 | + if ('get-post-item' === $type) { |
|
39 | + if (post_type_exists($object_type)) { |
|
40 | + if (isset($request['ID'])) { |
|
41 | 41 | $object_id = (int) $request['ID']; |
42 | - if ( 'markup' === $response_format ) { |
|
43 | - echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', array( get_post( $object_id ) ) ), 0, (object) $args ); |
|
44 | - } elseif ( 'json' === $response_format ) { |
|
42 | + if ('markup' === $response_format) { |
|
43 | + echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', array(get_post($object_id))), 0, (object) $args); |
|
44 | + } elseif ('json' === $response_format) { |
|
45 | 45 | echo wp_json_encode( |
46 | 46 | array( |
47 | 47 | 'ID' => $object_id, |
48 | - 'post_title' => get_the_title( $object_id ), |
|
49 | - 'post_type' => get_post_type( $object_id ), |
|
48 | + 'post_title' => get_the_title($object_id), |
|
49 | + 'post_type' => get_post_type($object_id), |
|
50 | 50 | ) |
51 | 51 | ); |
52 | 52 | echo "\n"; |
53 | 53 | } |
54 | 54 | } |
55 | - } elseif ( taxonomy_exists( $object_type ) ) { |
|
56 | - if ( isset( $request['ID'] ) ) { |
|
55 | + } elseif (taxonomy_exists($object_type)) { |
|
56 | + if (isset($request['ID'])) { |
|
57 | 57 | $object_id = (int) $request['ID']; |
58 | - if ( 'markup' === $response_format ) { |
|
59 | - echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', array( get_term( $object_id, $object_type ) ) ), 0, (object) $args ); |
|
60 | - } elseif ( 'json' === $response_format ) { |
|
61 | - $post_obj = get_term( $object_id, $object_type ); |
|
58 | + if ('markup' === $response_format) { |
|
59 | + echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', array(get_term($object_id, $object_type))), 0, (object) $args); |
|
60 | + } elseif ('json' === $response_format) { |
|
61 | + $post_obj = get_term($object_id, $object_type); |
|
62 | 62 | echo wp_json_encode( |
63 | 63 | array( |
64 | 64 | 'ID' => $object_id, |
@@ -70,9 +70,9 @@ discard block |
||
70 | 70 | } |
71 | 71 | } |
72 | 72 | } |
73 | - } elseif ( preg_match( '/quick-search-(posttype|taxonomy)-([a-zA-Z_-]*\b)/', $type, $matches ) ) { |
|
74 | - if ( 'posttype' === $matches[1] && get_post_type_object( $matches[2] ) ) { |
|
75 | - $post_type_obj = _wp_nav_menu_meta_box_object( get_post_type_object( $matches[2] ) ); |
|
73 | + } elseif (preg_match('/quick-search-(posttype|taxonomy)-([a-zA-Z_-]*\b)/', $type, $matches)) { |
|
74 | + if ('posttype' === $matches[1] && get_post_type_object($matches[2])) { |
|
75 | + $post_type_obj = _wp_nav_menu_meta_box_object(get_post_type_object($matches[2])); |
|
76 | 76 | $args = array_merge( |
77 | 77 | $args, |
78 | 78 | array( |
@@ -84,30 +84,30 @@ discard block |
||
84 | 84 | 's' => $query, |
85 | 85 | ) |
86 | 86 | ); |
87 | - if ( isset( $post_type_obj->_default_query ) ) { |
|
88 | - $args = array_merge( $args, (array) $post_type_obj->_default_query ); |
|
87 | + if (isset($post_type_obj->_default_query)) { |
|
88 | + $args = array_merge($args, (array) $post_type_obj->_default_query); |
|
89 | 89 | } |
90 | - $search_results_query = new WP_Query( $args ); |
|
91 | - if ( ! $search_results_query->have_posts() ) { |
|
90 | + $search_results_query = new WP_Query($args); |
|
91 | + if (!$search_results_query->have_posts()) { |
|
92 | 92 | return; |
93 | 93 | } |
94 | - while ( $search_results_query->have_posts() ) { |
|
94 | + while ($search_results_query->have_posts()) { |
|
95 | 95 | $post = $search_results_query->next_post(); |
96 | - if ( 'markup' === $response_format ) { |
|
96 | + if ('markup' === $response_format) { |
|
97 | 97 | $var_by_ref = $post->ID; |
98 | - echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', array( get_post( $var_by_ref ) ) ), 0, (object) $args ); |
|
99 | - } elseif ( 'json' === $response_format ) { |
|
98 | + echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', array(get_post($var_by_ref))), 0, (object) $args); |
|
99 | + } elseif ('json' === $response_format) { |
|
100 | 100 | echo wp_json_encode( |
101 | 101 | array( |
102 | 102 | 'ID' => $post->ID, |
103 | - 'post_title' => get_the_title( $post->ID ), |
|
103 | + 'post_title' => get_the_title($post->ID), |
|
104 | 104 | 'post_type' => $matches[2], |
105 | 105 | ) |
106 | 106 | ); |
107 | 107 | echo "\n"; |
108 | 108 | } |
109 | 109 | } |
110 | - } elseif ( 'taxonomy' === $matches[1] ) { |
|
110 | + } elseif ('taxonomy' === $matches[1]) { |
|
111 | 111 | $terms = get_terms( |
112 | 112 | array( |
113 | 113 | 'taxonomy' => $matches[2], |
@@ -116,13 +116,13 @@ discard block |
||
116 | 116 | 'hide_empty' => false, |
117 | 117 | ) |
118 | 118 | ); |
119 | - if ( empty( $terms ) || is_wp_error( $terms ) ) { |
|
119 | + if (empty($terms) || is_wp_error($terms)) { |
|
120 | 120 | return; |
121 | 121 | } |
122 | - foreach ( (array) $terms as $term ) { |
|
123 | - if ( 'markup' === $response_format ) { |
|
124 | - echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', array( $term ) ), 0, (object) $args ); |
|
125 | - } elseif ( 'json' === $response_format ) { |
|
122 | + foreach ((array) $terms as $term) { |
|
123 | + if ('markup' === $response_format) { |
|
124 | + echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', array($term)), 0, (object) $args); |
|
125 | + } elseif ('json' === $response_format) { |
|
126 | 126 | echo wp_json_encode( |
127 | 127 | array( |
128 | 128 | 'ID' => $term->term_id, |
@@ -145,14 +145,14 @@ discard block |
||
145 | 145 | function wp_nav_menu_setup() { |
146 | 146 | // Register meta boxes. |
147 | 147 | wp_nav_menu_post_type_meta_boxes(); |
148 | - add_meta_box( 'add-custom-links', __( 'Custom Links' ), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default' ); |
|
148 | + add_meta_box('add-custom-links', __('Custom Links'), 'wp_nav_menu_item_link_meta_box', 'nav-menus', 'side', 'default'); |
|
149 | 149 | wp_nav_menu_taxonomy_meta_boxes(); |
150 | 150 | |
151 | 151 | // Register advanced menu items (columns). |
152 | - add_filter( 'manage_nav-menus_columns', 'wp_nav_menu_manage_columns' ); |
|
152 | + add_filter('manage_nav-menus_columns', 'wp_nav_menu_manage_columns'); |
|
153 | 153 | |
154 | 154 | // If first time editing, disable advanced items by default. |
155 | - if ( false === get_user_option( 'managenav-menuscolumnshidden' ) ) { |
|
155 | + if (false === get_user_option('managenav-menuscolumnshidden')) { |
|
156 | 156 | $user = wp_get_current_user(); |
157 | 157 | update_user_meta( |
158 | 158 | $user->ID, |
@@ -178,18 +178,18 @@ discard block |
||
178 | 178 | function wp_initial_nav_menu_meta_boxes() { |
179 | 179 | global $wp_meta_boxes; |
180 | 180 | |
181 | - if ( get_user_option( 'metaboxhidden_nav-menus' ) !== false || ! is_array( $wp_meta_boxes ) ) { |
|
181 | + if (get_user_option('metaboxhidden_nav-menus') !== false || !is_array($wp_meta_boxes)) { |
|
182 | 182 | return; |
183 | 183 | } |
184 | 184 | |
185 | - $initial_meta_boxes = array( 'add-post-type-page', 'add-post-type-post', 'add-custom-links', 'add-category' ); |
|
185 | + $initial_meta_boxes = array('add-post-type-page', 'add-post-type-post', 'add-custom-links', 'add-category'); |
|
186 | 186 | $hidden_meta_boxes = array(); |
187 | 187 | |
188 | - foreach ( array_keys( $wp_meta_boxes['nav-menus'] ) as $context ) { |
|
189 | - foreach ( array_keys( $wp_meta_boxes['nav-menus'][ $context ] ) as $priority ) { |
|
190 | - foreach ( $wp_meta_boxes['nav-menus'][ $context ][ $priority ] as $box ) { |
|
191 | - if ( in_array( $box['id'], $initial_meta_boxes, true ) ) { |
|
192 | - unset( $box['id'] ); |
|
188 | + foreach (array_keys($wp_meta_boxes['nav-menus']) as $context) { |
|
189 | + foreach (array_keys($wp_meta_boxes['nav-menus'][$context]) as $priority) { |
|
190 | + foreach ($wp_meta_boxes['nav-menus'][$context][$priority] as $box) { |
|
191 | + if (in_array($box['id'], $initial_meta_boxes, true)) { |
|
192 | + unset($box['id']); |
|
193 | 193 | } else { |
194 | 194 | $hidden_meta_boxes[] = $box['id']; |
195 | 195 | } |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | } |
199 | 199 | |
200 | 200 | $user = wp_get_current_user(); |
201 | - update_user_meta( $user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes ); |
|
201 | + update_user_meta($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -207,13 +207,13 @@ discard block |
||
207 | 207 | * @since 3.0.0 |
208 | 208 | */ |
209 | 209 | function wp_nav_menu_post_type_meta_boxes() { |
210 | - $post_types = get_post_types( array( 'show_in_nav_menus' => true ), 'object' ); |
|
210 | + $post_types = get_post_types(array('show_in_nav_menus' => true), 'object'); |
|
211 | 211 | |
212 | - if ( ! $post_types ) { |
|
212 | + if (!$post_types) { |
|
213 | 213 | return; |
214 | 214 | } |
215 | 215 | |
216 | - foreach ( $post_types as $post_type ) { |
|
216 | + foreach ($post_types as $post_type) { |
|
217 | 217 | /** |
218 | 218 | * Filters whether a menu items meta box will be added for the current |
219 | 219 | * object type. |
@@ -226,12 +226,12 @@ discard block |
||
226 | 226 | * @param WP_Post_Type|false $post_type The current object to add a menu items |
227 | 227 | * meta box for. |
228 | 228 | */ |
229 | - $post_type = apply_filters( 'nav_menu_meta_box_object', $post_type ); |
|
230 | - if ( $post_type ) { |
|
229 | + $post_type = apply_filters('nav_menu_meta_box_object', $post_type); |
|
230 | + if ($post_type) { |
|
231 | 231 | $id = $post_type->name; |
232 | 232 | // Give pages a higher priority. |
233 | - $priority = ( 'page' === $post_type->name ? 'core' : 'default' ); |
|
234 | - add_meta_box( "add-post-type-{$id}", $post_type->labels->name, 'wp_nav_menu_item_post_type_meta_box', 'nav-menus', 'side', $priority, $post_type ); |
|
233 | + $priority = ('page' === $post_type->name ? 'core' : 'default'); |
|
234 | + add_meta_box("add-post-type-{$id}", $post_type->labels->name, 'wp_nav_menu_item_post_type_meta_box', 'nav-menus', 'side', $priority, $post_type); |
|
235 | 235 | } |
236 | 236 | } |
237 | 237 | } |
@@ -242,18 +242,18 @@ discard block |
||
242 | 242 | * @since 3.0.0 |
243 | 243 | */ |
244 | 244 | function wp_nav_menu_taxonomy_meta_boxes() { |
245 | - $taxonomies = get_taxonomies( array( 'show_in_nav_menus' => true ), 'object' ); |
|
245 | + $taxonomies = get_taxonomies(array('show_in_nav_menus' => true), 'object'); |
|
246 | 246 | |
247 | - if ( ! $taxonomies ) { |
|
247 | + if (!$taxonomies) { |
|
248 | 248 | return; |
249 | 249 | } |
250 | 250 | |
251 | - foreach ( $taxonomies as $tax ) { |
|
251 | + foreach ($taxonomies as $tax) { |
|
252 | 252 | /** This filter is documented in wp-admin/includes/nav-menu.php */ |
253 | - $tax = apply_filters( 'nav_menu_meta_box_object', $tax ); |
|
254 | - if ( $tax ) { |
|
253 | + $tax = apply_filters('nav_menu_meta_box_object', $tax); |
|
254 | + if ($tax) { |
|
255 | 255 | $id = $tax->name; |
256 | - add_meta_box( "add-{$id}", $tax->labels->name, 'wp_nav_menu_item_taxonomy_meta_box', 'nav-menus', 'side', 'default', $tax ); |
|
256 | + add_meta_box("add-{$id}", $tax->labels->name, 'wp_nav_menu_item_taxonomy_meta_box', 'nav-menus', 'side', 'default', $tax); |
|
257 | 257 | } |
258 | 258 | } |
259 | 259 | } |
@@ -270,14 +270,14 @@ discard block |
||
270 | 270 | * @param bool $display Whether to display or just return the string. |
271 | 271 | * @return string|false Disabled attribute if at least one menu exists, false if not. |
272 | 272 | */ |
273 | -function wp_nav_menu_disabled_check( $nav_menu_selected_id, $display = true ) { |
|
273 | +function wp_nav_menu_disabled_check($nav_menu_selected_id, $display = true) { |
|
274 | 274 | global $one_theme_location_no_menus; |
275 | 275 | |
276 | - if ( $one_theme_location_no_menus ) { |
|
276 | + if ($one_theme_location_no_menus) { |
|
277 | 277 | return false; |
278 | 278 | } |
279 | 279 | |
280 | - return disabled( $nav_menu_selected_id, 0, $display ); |
|
280 | + return disabled($nav_menu_selected_id, 0, $display); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | /** |
@@ -297,18 +297,18 @@ discard block |
||
297 | 297 | <div class="customlinkdiv" id="customlinkdiv"> |
298 | 298 | <input type="hidden" value="custom" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-type]" /> |
299 | 299 | <p id="menu-item-url-wrap" class="wp-clearfix"> |
300 | - <label class="howto" for="custom-menu-item-url"><?php _e( 'URL' ); ?></label> |
|
301 | - <input id="custom-menu-item-url" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-url]" type="text"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="code menu-item-textbox form-required" placeholder="https://" /> |
|
300 | + <label class="howto" for="custom-menu-item-url"><?php _e('URL'); ?></label> |
|
301 | + <input id="custom-menu-item-url" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-url]" type="text"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> class="code menu-item-textbox form-required" placeholder="https://" /> |
|
302 | 302 | </p> |
303 | 303 | |
304 | 304 | <p id="menu-item-name-wrap" class="wp-clearfix"> |
305 | - <label class="howto" for="custom-menu-item-name"><?php _e( 'Link Text' ); ?></label> |
|
306 | - <input id="custom-menu-item-name" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-title]" type="text"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="regular-text menu-item-textbox" /> |
|
305 | + <label class="howto" for="custom-menu-item-name"><?php _e('Link Text'); ?></label> |
|
306 | + <input id="custom-menu-item-name" name="menu-item[<?php echo $_nav_menu_placeholder; ?>][menu-item-title]" type="text"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> class="regular-text menu-item-textbox" /> |
|
307 | 307 | </p> |
308 | 308 | |
309 | 309 | <p class="button-controls wp-clearfix"> |
310 | 310 | <span class="add-to-menu"> |
311 | - <input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>" name="add-custom-menu-item" id="submit-customlinkdiv" /> |
|
311 | + <input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> class="button submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-custom-menu-item" id="submit-customlinkdiv" /> |
|
312 | 312 | <span class="spinner"></span> |
313 | 313 | </span> |
314 | 314 | </p> |
@@ -335,17 +335,17 @@ discard block |
||
335 | 335 | * @type WP_Post_Type $args Extra meta box arguments (the post type object for this meta box). |
336 | 336 | * } |
337 | 337 | */ |
338 | -function wp_nav_menu_item_post_type_meta_box( $data_object, $box ) { |
|
338 | +function wp_nav_menu_item_post_type_meta_box($data_object, $box) { |
|
339 | 339 | global $_nav_menu_placeholder, $nav_menu_selected_id; |
340 | 340 | |
341 | 341 | $post_type_name = $box['args']->name; |
342 | - $post_type = get_post_type_object( $post_type_name ); |
|
342 | + $post_type = get_post_type_object($post_type_name); |
|
343 | 343 | $tab_name = $post_type_name . '-tab'; |
344 | 344 | |
345 | 345 | // Paginate browsing for large numbers of post objects. |
346 | 346 | $per_page = 50; |
347 | - $pagenum = isset( $_REQUEST[ $tab_name ] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1; |
|
348 | - $offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0; |
|
347 | + $pagenum = isset($_REQUEST[$tab_name]) && isset($_REQUEST['paged']) ? absint($_REQUEST['paged']) : 1; |
|
348 | + $offset = 0 < $pagenum ? $per_page * ($pagenum - 1) : 0; |
|
349 | 349 | |
350 | 350 | $args = array( |
351 | 351 | 'offset' => $offset, |
@@ -358,8 +358,8 @@ discard block |
||
358 | 358 | 'update_post_meta_cache' => false, |
359 | 359 | ); |
360 | 360 | |
361 | - if ( isset( $box['args']->_default_query ) ) { |
|
362 | - $args = array_merge( $args, (array) $box['args']->_default_query ); |
|
361 | + if (isset($box['args']->_default_query)) { |
|
362 | + $args = array_merge($args, (array) $box['args']->_default_query); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | /* |
@@ -367,21 +367,21 @@ discard block |
||
367 | 367 | * Posts Page and Privacy Policy Page at the top of the list. |
368 | 368 | */ |
369 | 369 | $important_pages = array(); |
370 | - if ( 'page' === $post_type_name ) { |
|
370 | + if ('page' === $post_type_name) { |
|
371 | 371 | $suppress_page_ids = array(); |
372 | 372 | |
373 | 373 | // Insert Front Page or custom Home link. |
374 | - $front_page = 'page' === get_option( 'show_on_front' ) ? (int) get_option( 'page_on_front' ) : 0; |
|
374 | + $front_page = 'page' === get_option('show_on_front') ? (int) get_option('page_on_front') : 0; |
|
375 | 375 | |
376 | 376 | $front_page_obj = null; |
377 | - if ( ! empty( $front_page ) ) { |
|
378 | - $front_page_obj = get_post( $front_page ); |
|
377 | + if (!empty($front_page)) { |
|
378 | + $front_page_obj = get_post($front_page); |
|
379 | 379 | $front_page_obj->front_or_home = true; |
380 | 380 | |
381 | 381 | $important_pages[] = $front_page_obj; |
382 | 382 | $suppress_page_ids[] = $front_page_obj->ID; |
383 | 383 | } else { |
384 | - $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? (int) $_nav_menu_placeholder - 1 : -1; |
|
384 | + $_nav_menu_placeholder = (0 > $_nav_menu_placeholder) ? (int) $_nav_menu_placeholder - 1 : -1; |
|
385 | 385 | $front_page_obj = (object) array( |
386 | 386 | 'front_or_home' => true, |
387 | 387 | 'ID' => 0, |
@@ -389,20 +389,20 @@ discard block |
||
389 | 389 | 'post_content' => '', |
390 | 390 | 'post_excerpt' => '', |
391 | 391 | 'post_parent' => '', |
392 | - 'post_title' => _x( 'Home', 'nav menu home label' ), |
|
392 | + 'post_title' => _x('Home', 'nav menu home label'), |
|
393 | 393 | 'post_type' => 'nav_menu_item', |
394 | 394 | 'type' => 'custom', |
395 | - 'url' => home_url( '/' ), |
|
395 | + 'url' => home_url('/'), |
|
396 | 396 | ); |
397 | 397 | |
398 | 398 | $important_pages[] = $front_page_obj; |
399 | 399 | } |
400 | 400 | |
401 | 401 | // Insert Posts Page. |
402 | - $posts_page = 'page' === get_option( 'show_on_front' ) ? (int) get_option( 'page_for_posts' ) : 0; |
|
402 | + $posts_page = 'page' === get_option('show_on_front') ? (int) get_option('page_for_posts') : 0; |
|
403 | 403 | |
404 | - if ( ! empty( $posts_page ) ) { |
|
405 | - $posts_page_obj = get_post( $posts_page ); |
|
404 | + if (!empty($posts_page)) { |
|
405 | + $posts_page_obj = get_post($posts_page); |
|
406 | 406 | $posts_page_obj->posts_page = true; |
407 | 407 | |
408 | 408 | $important_pages[] = $posts_page_obj; |
@@ -410,11 +410,11 @@ discard block |
||
410 | 410 | } |
411 | 411 | |
412 | 412 | // Insert Privacy Policy Page. |
413 | - $privacy_policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' ); |
|
413 | + $privacy_policy_page_id = (int) get_option('wp_page_for_privacy_policy'); |
|
414 | 414 | |
415 | - if ( ! empty( $privacy_policy_page_id ) ) { |
|
416 | - $privacy_policy_page = get_post( $privacy_policy_page_id ); |
|
417 | - if ( $privacy_policy_page instanceof WP_Post && 'publish' === $privacy_policy_page->post_status ) { |
|
415 | + if (!empty($privacy_policy_page_id)) { |
|
416 | + $privacy_policy_page = get_post($privacy_policy_page_id); |
|
417 | + if ($privacy_policy_page instanceof WP_Post && 'publish' === $privacy_policy_page->post_status) { |
|
418 | 418 | $privacy_policy_page->privacy_policy_page = true; |
419 | 419 | |
420 | 420 | $important_pages[] = $privacy_policy_page; |
@@ -423,27 +423,27 @@ discard block |
||
423 | 423 | } |
424 | 424 | |
425 | 425 | // Add suppression array to arguments for WP_Query. |
426 | - if ( ! empty( $suppress_page_ids ) ) { |
|
426 | + if (!empty($suppress_page_ids)) { |
|
427 | 427 | $args['post__not_in'] = $suppress_page_ids; |
428 | 428 | } |
429 | 429 | } |
430 | 430 | |
431 | 431 | // @todo Transient caching of these results with proper invalidation on updating of a post of this type. |
432 | 432 | $get_posts = new WP_Query; |
433 | - $posts = $get_posts->query( $args ); |
|
433 | + $posts = $get_posts->query($args); |
|
434 | 434 | |
435 | 435 | // Only suppress and insert when more than just suppression pages available. |
436 | - if ( ! $get_posts->post_count ) { |
|
437 | - if ( ! empty( $suppress_page_ids ) ) { |
|
438 | - unset( $args['post__not_in'] ); |
|
436 | + if (!$get_posts->post_count) { |
|
437 | + if (!empty($suppress_page_ids)) { |
|
438 | + unset($args['post__not_in']); |
|
439 | 439 | $get_posts = new WP_Query; |
440 | - $posts = $get_posts->query( $args ); |
|
440 | + $posts = $get_posts->query($args); |
|
441 | 441 | } else { |
442 | - echo '<p>' . __( 'No items.' ) . '</p>'; |
|
442 | + echo '<p>' . __('No items.') . '</p>'; |
|
443 | 443 | return; |
444 | 444 | } |
445 | - } elseif ( ! empty( $important_pages ) ) { |
|
446 | - $posts = array_merge( $important_pages, $posts ); |
|
445 | + } elseif (!empty($important_pages)) { |
|
446 | + $posts = array_merge($important_pages, $posts); |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | $num_pages = $get_posts->max_num_pages; |
@@ -459,31 +459,31 @@ discard block |
||
459 | 459 | ) |
460 | 460 | ), |
461 | 461 | 'format' => '', |
462 | - 'prev_text' => '<span aria-label="' . esc_attr__( 'Previous page' ) . '">' . __( '«' ) . '</span>', |
|
463 | - 'next_text' => '<span aria-label="' . esc_attr__( 'Next page' ) . '">' . __( '»' ) . '</span>', |
|
464 | - 'before_page_number' => '<span class="screen-reader-text">' . __( 'Page' ) . '</span> ', |
|
462 | + 'prev_text' => '<span aria-label="' . esc_attr__('Previous page') . '">' . __('«') . '</span>', |
|
463 | + 'next_text' => '<span aria-label="' . esc_attr__('Next page') . '">' . __('»') . '</span>', |
|
464 | + 'before_page_number' => '<span class="screen-reader-text">' . __('Page') . '</span> ', |
|
465 | 465 | 'total' => $num_pages, |
466 | 466 | 'current' => $pagenum, |
467 | 467 | ) |
468 | 468 | ); |
469 | 469 | |
470 | 470 | $db_fields = false; |
471 | - if ( is_post_type_hierarchical( $post_type_name ) ) { |
|
471 | + if (is_post_type_hierarchical($post_type_name)) { |
|
472 | 472 | $db_fields = array( |
473 | 473 | 'parent' => 'post_parent', |
474 | 474 | 'id' => 'ID', |
475 | 475 | ); |
476 | 476 | } |
477 | 477 | |
478 | - $walker = new Walker_Nav_Menu_Checklist( $db_fields ); |
|
478 | + $walker = new Walker_Nav_Menu_Checklist($db_fields); |
|
479 | 479 | |
480 | 480 | $current_tab = 'most-recent'; |
481 | 481 | |
482 | - if ( isset( $_REQUEST[ $tab_name ] ) && in_array( $_REQUEST[ $tab_name ], array( 'all', 'search' ), true ) ) { |
|
483 | - $current_tab = $_REQUEST[ $tab_name ]; |
|
482 | + if (isset($_REQUEST[$tab_name]) && in_array($_REQUEST[$tab_name], array('all', 'search'), true)) { |
|
483 | + $current_tab = $_REQUEST[$tab_name]; |
|
484 | 484 | } |
485 | 485 | |
486 | - if ( ! empty( $_REQUEST[ 'quick-search-posttype-' . $post_type_name ] ) ) { |
|
486 | + if (!empty($_REQUEST['quick-search-posttype-' . $post_type_name])) { |
|
487 | 487 | $current_tab = 'search'; |
488 | 488 | } |
489 | 489 | |
@@ -499,35 +499,35 @@ discard block |
||
499 | 499 | $most_recent_url = ''; |
500 | 500 | $view_all_url = ''; |
501 | 501 | $search_url = ''; |
502 | - if ( $nav_menu_selected_id ) { |
|
503 | - $most_recent_url = esc_url( add_query_arg( $tab_name, 'most-recent', remove_query_arg( $removed_args ) ) ); |
|
504 | - $view_all_url = esc_url( add_query_arg( $tab_name, 'all', remove_query_arg( $removed_args ) ) ); |
|
505 | - $search_url = esc_url( add_query_arg( $tab_name, 'search', remove_query_arg( $removed_args ) ) ); |
|
502 | + if ($nav_menu_selected_id) { |
|
503 | + $most_recent_url = esc_url(add_query_arg($tab_name, 'most-recent', remove_query_arg($removed_args))); |
|
504 | + $view_all_url = esc_url(add_query_arg($tab_name, 'all', remove_query_arg($removed_args))); |
|
505 | + $search_url = esc_url(add_query_arg($tab_name, 'search', remove_query_arg($removed_args))); |
|
506 | 506 | } |
507 | 507 | ?> |
508 | 508 | <div id="posttype-<?php echo $post_type_name; ?>" class="posttypediv"> |
509 | 509 | <ul id="posttype-<?php echo $post_type_name; ?>-tabs" class="posttype-tabs add-menu-item-tabs"> |
510 | - <li <?php echo ( 'most-recent' === $current_tab ? ' class="tabs"' : '' ); ?>> |
|
511 | - <a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-most-recent" href="<?php echo $most_recent_url; ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent"> |
|
512 | - <?php _e( 'Most Recent' ); ?> |
|
510 | + <li <?php echo ('most-recent' === $current_tab ? ' class="tabs"' : ''); ?>> |
|
511 | + <a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr($post_type_name); ?>-most-recent" href="<?php echo $most_recent_url; ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent"> |
|
512 | + <?php _e('Most Recent'); ?> |
|
513 | 513 | </a> |
514 | 514 | </li> |
515 | - <li <?php echo ( 'all' === $current_tab ? ' class="tabs"' : '' ); ?>> |
|
516 | - <a class="nav-tab-link" data-type="<?php echo esc_attr( $post_type_name ); ?>-all" href="<?php echo $view_all_url; ?>#<?php echo $post_type_name; ?>-all"> |
|
517 | - <?php _e( 'View All' ); ?> |
|
515 | + <li <?php echo ('all' === $current_tab ? ' class="tabs"' : ''); ?>> |
|
516 | + <a class="nav-tab-link" data-type="<?php echo esc_attr($post_type_name); ?>-all" href="<?php echo $view_all_url; ?>#<?php echo $post_type_name; ?>-all"> |
|
517 | + <?php _e('View All'); ?> |
|
518 | 518 | </a> |
519 | 519 | </li> |
520 | - <li <?php echo ( 'search' === $current_tab ? ' class="tabs"' : '' ); ?>> |
|
521 | - <a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr( $post_type_name ); ?>-search" href="<?php echo $search_url; ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-search"> |
|
522 | - <?php _e( 'Search' ); ?> |
|
520 | + <li <?php echo ('search' === $current_tab ? ' class="tabs"' : ''); ?>> |
|
521 | + <a class="nav-tab-link" data-type="tabs-panel-posttype-<?php echo esc_attr($post_type_name); ?>-search" href="<?php echo $search_url; ?>#tabs-panel-posttype-<?php echo $post_type_name; ?>-search"> |
|
522 | + <?php _e('Search'); ?> |
|
523 | 523 | </a> |
524 | 524 | </li> |
525 | 525 | </ul><!-- .posttype-tabs --> |
526 | 526 | |
527 | - <div id="tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent" class="tabs-panel <?php echo ( 'most-recent' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" role="region" aria-label="<?php _e( 'Most Recent' ); ?>" tabindex="0"> |
|
527 | + <div id="tabs-panel-posttype-<?php echo $post_type_name; ?>-most-recent" class="tabs-panel <?php echo ('most-recent' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); ?>" role="region" aria-label="<?php _e('Most Recent'); ?>" tabindex="0"> |
|
528 | 528 | <ul id="<?php echo $post_type_name; ?>checklist-most-recent" class="categorychecklist form-no-clear"> |
529 | 529 | <?php |
530 | - $recent_args = array_merge( |
|
530 | + $recent_args = array_merge( |
|
531 | 531 | $args, |
532 | 532 | array( |
533 | 533 | 'orderby' => 'post_date', |
@@ -535,7 +535,7 @@ discard block |
||
535 | 535 | 'posts_per_page' => 15, |
536 | 536 | ) |
537 | 537 | ); |
538 | - $most_recent = $get_posts->query( $recent_args ); |
|
538 | + $most_recent = $get_posts->query($recent_args); |
|
539 | 539 | $args['walker'] = $walker; |
540 | 540 | |
541 | 541 | /** |
@@ -557,17 +557,17 @@ discard block |
||
557 | 557 | * @param array $box Arguments passed to `wp_nav_menu_item_post_type_meta_box()`. |
558 | 558 | * @param array $recent_args An array of `WP_Query` arguments for 'Most Recent' tab. |
559 | 559 | */ |
560 | - $most_recent = apply_filters( "nav_menu_items_{$post_type_name}_recent", $most_recent, $args, $box, $recent_args ); |
|
560 | + $most_recent = apply_filters("nav_menu_items_{$post_type_name}_recent", $most_recent, $args, $box, $recent_args); |
|
561 | 561 | |
562 | - echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $most_recent ), 0, (object) $args ); |
|
562 | + echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $most_recent), 0, (object) $args); |
|
563 | 563 | ?> |
564 | 564 | </ul> |
565 | 565 | </div><!-- /.tabs-panel --> |
566 | 566 | |
567 | - <div class="tabs-panel <?php echo ( 'search' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" id="tabs-panel-posttype-<?php echo $post_type_name; ?>-search" role="region" aria-label="<?php echo $post_type->labels->search_items; ?>" tabindex="0"> |
|
567 | + <div class="tabs-panel <?php echo ('search' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); ?>" id="tabs-panel-posttype-<?php echo $post_type_name; ?>-search" role="region" aria-label="<?php echo $post_type->labels->search_items; ?>" tabindex="0"> |
|
568 | 568 | <?php |
569 | - if ( isset( $_REQUEST[ 'quick-search-posttype-' . $post_type_name ] ) ) { |
|
570 | - $searched = esc_attr( $_REQUEST[ 'quick-search-posttype-' . $post_type_name ] ); |
|
569 | + if (isset($_REQUEST['quick-search-posttype-' . $post_type_name])) { |
|
570 | + $searched = esc_attr($_REQUEST['quick-search-posttype-' . $post_type_name]); |
|
571 | 571 | $search_results = get_posts( |
572 | 572 | array( |
573 | 573 | 's' => $searched, |
@@ -582,28 +582,28 @@ discard block |
||
582 | 582 | } |
583 | 583 | ?> |
584 | 584 | <p class="quick-search-wrap"> |
585 | - <label for="quick-search-posttype-<?php echo $post_type_name; ?>" class="screen-reader-text"><?php _e( 'Search' ); ?></label> |
|
586 | - <input type="search"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="quick-search" value="<?php echo $searched; ?>" name="quick-search-posttype-<?php echo $post_type_name; ?>" id="quick-search-posttype-<?php echo $post_type_name; ?>" /> |
|
585 | + <label for="quick-search-posttype-<?php echo $post_type_name; ?>" class="screen-reader-text"><?php _e('Search'); ?></label> |
|
586 | + <input type="search"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> class="quick-search" value="<?php echo $searched; ?>" name="quick-search-posttype-<?php echo $post_type_name; ?>" id="quick-search-posttype-<?php echo $post_type_name; ?>" /> |
|
587 | 587 | <span class="spinner"></span> |
588 | - <?php submit_button( __( 'Search' ), 'small quick-search-submit hide-if-js', 'submit', false, array( 'id' => 'submit-quick-search-posttype-' . $post_type_name ) ); ?> |
|
588 | + <?php submit_button(__('Search'), 'small quick-search-submit hide-if-js', 'submit', false, array('id' => 'submit-quick-search-posttype-' . $post_type_name)); ?> |
|
589 | 589 | </p> |
590 | 590 | |
591 | 591 | <ul id="<?php echo $post_type_name; ?>-search-checklist" data-wp-lists="list:<?php echo $post_type_name; ?>" class="categorychecklist form-no-clear"> |
592 | - <?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?> |
|
592 | + <?php if (!empty($search_results) && !is_wp_error($search_results)) : ?> |
|
593 | 593 | <?php |
594 | 594 | $args['walker'] = $walker; |
595 | - echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $search_results ), 0, (object) $args ); |
|
595 | + echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args); |
|
596 | 596 | ?> |
597 | - <?php elseif ( is_wp_error( $search_results ) ) : ?> |
|
597 | + <?php elseif (is_wp_error($search_results)) : ?> |
|
598 | 598 | <li><?php echo $search_results->get_error_message(); ?></li> |
599 | - <?php elseif ( ! empty( $searched ) ) : ?> |
|
600 | - <li><?php _e( 'No results found.' ); ?></li> |
|
599 | + <?php elseif (!empty($searched)) : ?> |
|
600 | + <li><?php _e('No results found.'); ?></li> |
|
601 | 601 | <?php endif; ?> |
602 | 602 | </ul> |
603 | 603 | </div><!-- /.tabs-panel --> |
604 | 604 | |
605 | - <div id="<?php echo $post_type_name; ?>-all" class="tabs-panel tabs-panel-view-all <?php echo ( 'all' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" role="region" aria-label="<?php echo $post_type->labels->all_items; ?>" tabindex="0"> |
|
606 | - <?php if ( ! empty( $page_links ) ) : ?> |
|
605 | + <div id="<?php echo $post_type_name; ?>-all" class="tabs-panel tabs-panel-view-all <?php echo ('all' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); ?>" role="region" aria-label="<?php echo $post_type->labels->all_items; ?>" tabindex="0"> |
|
606 | + <?php if (!empty($page_links)) : ?> |
|
607 | 607 | <div class="add-menu-item-pagelinks"> |
608 | 608 | <?php echo $page_links; ?> |
609 | 609 | </div> |
@@ -612,8 +612,8 @@ discard block |
||
612 | 612 | <?php |
613 | 613 | $args['walker'] = $walker; |
614 | 614 | |
615 | - if ( $post_type->has_archive ) { |
|
616 | - $_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? (int) $_nav_menu_placeholder - 1 : -1; |
|
615 | + if ($post_type->has_archive) { |
|
616 | + $_nav_menu_placeholder = (0 > $_nav_menu_placeholder) ? (int) $_nav_menu_placeholder - 1 : -1; |
|
617 | 617 | array_unshift( |
618 | 618 | $posts, |
619 | 619 | (object) array( |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | 'post_title' => $post_type->labels->archives, |
626 | 626 | 'post_type' => 'nav_menu_item', |
627 | 627 | 'type' => 'post_type_archive', |
628 | - 'url' => get_post_type_archive_link( $post_type_name ), |
|
628 | + 'url' => get_post_type_archive_link($post_type_name), |
|
629 | 629 | ) |
630 | 630 | ); |
631 | 631 | } |
@@ -652,28 +652,28 @@ discard block |
||
652 | 652 | * @param array $args An array of `WP_Query` arguments. |
653 | 653 | * @param WP_Post_Type $post_type The current post type object for this menu item meta box. |
654 | 654 | */ |
655 | - $posts = apply_filters( "nav_menu_items_{$post_type_name}", $posts, $args, $post_type ); |
|
655 | + $posts = apply_filters("nav_menu_items_{$post_type_name}", $posts, $args, $post_type); |
|
656 | 656 | |
657 | - $checkbox_items = walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $posts ), 0, (object) $args ); |
|
657 | + $checkbox_items = walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $posts), 0, (object) $args); |
|
658 | 658 | |
659 | 659 | echo $checkbox_items; |
660 | 660 | ?> |
661 | 661 | </ul> |
662 | - <?php if ( ! empty( $page_links ) ) : ?> |
|
662 | + <?php if (!empty($page_links)) : ?> |
|
663 | 663 | <div class="add-menu-item-pagelinks"> |
664 | 664 | <?php echo $page_links; ?> |
665 | 665 | </div> |
666 | 666 | <?php endif; ?> |
667 | 667 | </div><!-- /.tabs-panel --> |
668 | 668 | |
669 | - <p class="button-controls wp-clearfix" data-items-type="posttype-<?php echo esc_attr( $post_type_name ); ?>"> |
|
669 | + <p class="button-controls wp-clearfix" data-items-type="posttype-<?php echo esc_attr($post_type_name); ?>"> |
|
670 | 670 | <span class="list-controls hide-if-no-js"> |
671 | - <input type="checkbox"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> id="<?php echo esc_attr( $tab_name ); ?>" class="select-all" /> |
|
672 | - <label for="<?php echo esc_attr( $tab_name ); ?>"><?php _e( 'Select All' ); ?></label> |
|
671 | + <input type="checkbox"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> id="<?php echo esc_attr($tab_name); ?>" class="select-all" /> |
|
672 | + <label for="<?php echo esc_attr($tab_name); ?>"><?php _e('Select All'); ?></label> |
|
673 | 673 | </span> |
674 | 674 | |
675 | 675 | <span class="add-to-menu"> |
676 | - <input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>" name="add-post-type-menu-item" id="<?php echo esc_attr( 'submit-posttype-' . $post_type_name ); ?>" /> |
|
676 | + <input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> class="button submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-post-type-menu-item" id="<?php echo esc_attr('submit-posttype-' . $post_type_name); ?>" /> |
|
677 | 677 | <span class="spinner"></span> |
678 | 678 | </span> |
679 | 679 | </p> |
@@ -699,17 +699,17 @@ discard block |
||
699 | 699 | * @type object $args Extra meta box arguments (the taxonomy object for this meta box). |
700 | 700 | * } |
701 | 701 | */ |
702 | -function wp_nav_menu_item_taxonomy_meta_box( $data_object, $box ) { |
|
702 | +function wp_nav_menu_item_taxonomy_meta_box($data_object, $box) { |
|
703 | 703 | global $nav_menu_selected_id; |
704 | 704 | |
705 | 705 | $taxonomy_name = $box['args']->name; |
706 | - $taxonomy = get_taxonomy( $taxonomy_name ); |
|
706 | + $taxonomy = get_taxonomy($taxonomy_name); |
|
707 | 707 | $tab_name = $taxonomy_name . '-tab'; |
708 | 708 | |
709 | 709 | // Paginate browsing for large numbers of objects. |
710 | 710 | $per_page = 50; |
711 | - $pagenum = isset( $_REQUEST[ $tab_name ] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1; |
|
712 | - $offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0; |
|
711 | + $pagenum = isset($_REQUEST[$tab_name]) && isset($_REQUEST['paged']) ? absint($_REQUEST['paged']) : 1; |
|
712 | + $offset = 0 < $pagenum ? $per_page * ($pagenum - 1) : 0; |
|
713 | 713 | |
714 | 714 | $args = array( |
715 | 715 | 'taxonomy' => $taxonomy_name, |
@@ -725,10 +725,10 @@ discard block |
||
725 | 725 | 'pad_counts' => false, |
726 | 726 | ); |
727 | 727 | |
728 | - $terms = get_terms( $args ); |
|
728 | + $terms = get_terms($args); |
|
729 | 729 | |
730 | - if ( ! $terms || is_wp_error( $terms ) ) { |
|
731 | - echo '<p>' . __( 'No items.' ) . '</p>'; |
|
730 | + if (!$terms || is_wp_error($terms)) { |
|
731 | + echo '<p>' . __('No items.') . '</p>'; |
|
732 | 732 | return; |
733 | 733 | } |
734 | 734 | |
@@ -755,31 +755,31 @@ discard block |
||
755 | 755 | ) |
756 | 756 | ), |
757 | 757 | 'format' => '', |
758 | - 'prev_text' => '<span aria-label="' . esc_attr__( 'Previous page' ) . '">' . __( '«' ) . '</span>', |
|
759 | - 'next_text' => '<span aria-label="' . esc_attr__( 'Next page' ) . '">' . __( '»' ) . '</span>', |
|
760 | - 'before_page_number' => '<span class="screen-reader-text">' . __( 'Page' ) . '</span> ', |
|
758 | + 'prev_text' => '<span aria-label="' . esc_attr__('Previous page') . '">' . __('«') . '</span>', |
|
759 | + 'next_text' => '<span aria-label="' . esc_attr__('Next page') . '">' . __('»') . '</span>', |
|
760 | + 'before_page_number' => '<span class="screen-reader-text">' . __('Page') . '</span> ', |
|
761 | 761 | 'total' => $num_pages, |
762 | 762 | 'current' => $pagenum, |
763 | 763 | ) |
764 | 764 | ); |
765 | 765 | |
766 | 766 | $db_fields = false; |
767 | - if ( is_taxonomy_hierarchical( $taxonomy_name ) ) { |
|
767 | + if (is_taxonomy_hierarchical($taxonomy_name)) { |
|
768 | 768 | $db_fields = array( |
769 | 769 | 'parent' => 'parent', |
770 | 770 | 'id' => 'term_id', |
771 | 771 | ); |
772 | 772 | } |
773 | 773 | |
774 | - $walker = new Walker_Nav_Menu_Checklist( $db_fields ); |
|
774 | + $walker = new Walker_Nav_Menu_Checklist($db_fields); |
|
775 | 775 | |
776 | 776 | $current_tab = 'most-used'; |
777 | 777 | |
778 | - if ( isset( $_REQUEST[ $tab_name ] ) && in_array( $_REQUEST[ $tab_name ], array( 'all', 'most-used', 'search' ), true ) ) { |
|
779 | - $current_tab = $_REQUEST[ $tab_name ]; |
|
778 | + if (isset($_REQUEST[$tab_name]) && in_array($_REQUEST[$tab_name], array('all', 'most-used', 'search'), true)) { |
|
779 | + $current_tab = $_REQUEST[$tab_name]; |
|
780 | 780 | } |
781 | 781 | |
782 | - if ( ! empty( $_REQUEST[ 'quick-search-taxonomy-' . $taxonomy_name ] ) ) { |
|
782 | + if (!empty($_REQUEST['quick-search-taxonomy-' . $taxonomy_name])) { |
|
783 | 783 | $current_tab = 'search'; |
784 | 784 | } |
785 | 785 | |
@@ -795,35 +795,35 @@ discard block |
||
795 | 795 | $most_used_url = ''; |
796 | 796 | $view_all_url = ''; |
797 | 797 | $search_url = ''; |
798 | - if ( $nav_menu_selected_id ) { |
|
799 | - $most_used_url = esc_url( add_query_arg( $tab_name, 'most-used', remove_query_arg( $removed_args ) ) ); |
|
800 | - $view_all_url = esc_url( add_query_arg( $tab_name, 'all', remove_query_arg( $removed_args ) ) ); |
|
801 | - $search_url = esc_url( add_query_arg( $tab_name, 'search', remove_query_arg( $removed_args ) ) ); |
|
798 | + if ($nav_menu_selected_id) { |
|
799 | + $most_used_url = esc_url(add_query_arg($tab_name, 'most-used', remove_query_arg($removed_args))); |
|
800 | + $view_all_url = esc_url(add_query_arg($tab_name, 'all', remove_query_arg($removed_args))); |
|
801 | + $search_url = esc_url(add_query_arg($tab_name, 'search', remove_query_arg($removed_args))); |
|
802 | 802 | } |
803 | 803 | ?> |
804 | 804 | <div id="taxonomy-<?php echo $taxonomy_name; ?>" class="taxonomydiv"> |
805 | 805 | <ul id="taxonomy-<?php echo $taxonomy_name; ?>-tabs" class="taxonomy-tabs add-menu-item-tabs"> |
806 | - <li <?php echo ( 'most-used' === $current_tab ? ' class="tabs"' : '' ); ?>> |
|
807 | - <a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-pop" href="<?php echo $most_used_url; ?>#tabs-panel-<?php echo $taxonomy_name; ?>-pop"> |
|
808 | - <?php echo esc_html( $taxonomy->labels->most_used ); ?> |
|
806 | + <li <?php echo ('most-used' === $current_tab ? ' class="tabs"' : ''); ?>> |
|
807 | + <a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr($taxonomy_name); ?>-pop" href="<?php echo $most_used_url; ?>#tabs-panel-<?php echo $taxonomy_name; ?>-pop"> |
|
808 | + <?php echo esc_html($taxonomy->labels->most_used); ?> |
|
809 | 809 | </a> |
810 | 810 | </li> |
811 | - <li <?php echo ( 'all' === $current_tab ? ' class="tabs"' : '' ); ?>> |
|
812 | - <a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr( $taxonomy_name ); ?>-all" href="<?php echo $view_all_url; ?>#tabs-panel-<?php echo $taxonomy_name; ?>-all"> |
|
813 | - <?php _e( 'View All' ); ?> |
|
811 | + <li <?php echo ('all' === $current_tab ? ' class="tabs"' : ''); ?>> |
|
812 | + <a class="nav-tab-link" data-type="tabs-panel-<?php echo esc_attr($taxonomy_name); ?>-all" href="<?php echo $view_all_url; ?>#tabs-panel-<?php echo $taxonomy_name; ?>-all"> |
|
813 | + <?php _e('View All'); ?> |
|
814 | 814 | </a> |
815 | 815 | </li> |
816 | - <li <?php echo ( 'search' === $current_tab ? ' class="tabs"' : '' ); ?>> |
|
817 | - <a class="nav-tab-link" data-type="tabs-panel-search-taxonomy-<?php echo esc_attr( $taxonomy_name ); ?>" href="<?php echo $search_url; ?>#tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>"> |
|
818 | - <?php _e( 'Search' ); ?> |
|
816 | + <li <?php echo ('search' === $current_tab ? ' class="tabs"' : ''); ?>> |
|
817 | + <a class="nav-tab-link" data-type="tabs-panel-search-taxonomy-<?php echo esc_attr($taxonomy_name); ?>" href="<?php echo $search_url; ?>#tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>"> |
|
818 | + <?php _e('Search'); ?> |
|
819 | 819 | </a> |
820 | 820 | </li> |
821 | 821 | </ul><!-- .taxonomy-tabs --> |
822 | 822 | |
823 | - <div id="tabs-panel-<?php echo $taxonomy_name; ?>-pop" class="tabs-panel <?php echo ( 'most-used' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" role="region" aria-label="<?php echo $taxonomy->labels->most_used; ?>" tabindex="0"> |
|
823 | + <div id="tabs-panel-<?php echo $taxonomy_name; ?>-pop" class="tabs-panel <?php echo ('most-used' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); ?>" role="region" aria-label="<?php echo $taxonomy->labels->most_used; ?>" tabindex="0"> |
|
824 | 824 | <ul id="<?php echo $taxonomy_name; ?>checklist-pop" class="categorychecklist form-no-clear" > |
825 | 825 | <?php |
826 | - $popular_terms = get_terms( |
|
826 | + $popular_terms = get_terms( |
|
827 | 827 | array( |
828 | 828 | 'taxonomy' => $taxonomy_name, |
829 | 829 | 'orderby' => 'count', |
@@ -833,13 +833,13 @@ discard block |
||
833 | 833 | ) |
834 | 834 | ); |
835 | 835 | $args['walker'] = $walker; |
836 | - echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $popular_terms ), 0, (object) $args ); |
|
836 | + echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $popular_terms), 0, (object) $args); |
|
837 | 837 | ?> |
838 | 838 | </ul> |
839 | 839 | </div><!-- /.tabs-panel --> |
840 | 840 | |
841 | - <div id="tabs-panel-<?php echo $taxonomy_name; ?>-all" class="tabs-panel tabs-panel-view-all <?php echo ( 'all' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" role="region" aria-label="<?php echo $taxonomy->labels->all_items; ?>" tabindex="0"> |
|
842 | - <?php if ( ! empty( $page_links ) ) : ?> |
|
841 | + <div id="tabs-panel-<?php echo $taxonomy_name; ?>-all" class="tabs-panel tabs-panel-view-all <?php echo ('all' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); ?>" role="region" aria-label="<?php echo $taxonomy->labels->all_items; ?>" tabindex="0"> |
|
842 | + <?php if (!empty($page_links)) : ?> |
|
843 | 843 | <div class="add-menu-item-pagelinks"> |
844 | 844 | <?php echo $page_links; ?> |
845 | 845 | </div> |
@@ -847,20 +847,20 @@ discard block |
||
847 | 847 | <ul id="<?php echo $taxonomy_name; ?>checklist" data-wp-lists="list:<?php echo $taxonomy_name; ?>" class="categorychecklist form-no-clear"> |
848 | 848 | <?php |
849 | 849 | $args['walker'] = $walker; |
850 | - echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $terms ), 0, (object) $args ); |
|
850 | + echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $terms), 0, (object) $args); |
|
851 | 851 | ?> |
852 | 852 | </ul> |
853 | - <?php if ( ! empty( $page_links ) ) : ?> |
|
853 | + <?php if (!empty($page_links)) : ?> |
|
854 | 854 | <div class="add-menu-item-pagelinks"> |
855 | 855 | <?php echo $page_links; ?> |
856 | 856 | </div> |
857 | 857 | <?php endif; ?> |
858 | 858 | </div><!-- /.tabs-panel --> |
859 | 859 | |
860 | - <div class="tabs-panel <?php echo ( 'search' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive' ); ?>" id="tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>" role="region" aria-label="<?php echo $taxonomy->labels->search_items; ?>" tabindex="0"> |
|
860 | + <div class="tabs-panel <?php echo ('search' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); ?>" id="tabs-panel-search-taxonomy-<?php echo $taxonomy_name; ?>" role="region" aria-label="<?php echo $taxonomy->labels->search_items; ?>" tabindex="0"> |
|
861 | 861 | <?php |
862 | - if ( isset( $_REQUEST[ 'quick-search-taxonomy-' . $taxonomy_name ] ) ) { |
|
863 | - $searched = esc_attr( $_REQUEST[ 'quick-search-taxonomy-' . $taxonomy_name ] ); |
|
862 | + if (isset($_REQUEST['quick-search-taxonomy-' . $taxonomy_name])) { |
|
863 | + $searched = esc_attr($_REQUEST['quick-search-taxonomy-' . $taxonomy_name]); |
|
864 | 864 | $search_results = get_terms( |
865 | 865 | array( |
866 | 866 | 'taxonomy' => $taxonomy_name, |
@@ -877,34 +877,34 @@ discard block |
||
877 | 877 | } |
878 | 878 | ?> |
879 | 879 | <p class="quick-search-wrap"> |
880 | - <label for="quick-search-taxonomy-<?php echo $taxonomy_name; ?>" class="screen-reader-text"><?php _e( 'Search' ); ?></label> |
|
880 | + <label for="quick-search-taxonomy-<?php echo $taxonomy_name; ?>" class="screen-reader-text"><?php _e('Search'); ?></label> |
|
881 | 881 | <input type="search" class="quick-search" value="<?php echo $searched; ?>" name="quick-search-taxonomy-<?php echo $taxonomy_name; ?>" id="quick-search-taxonomy-<?php echo $taxonomy_name; ?>" /> |
882 | 882 | <span class="spinner"></span> |
883 | - <?php submit_button( __( 'Search' ), 'small quick-search-submit hide-if-js', 'submit', false, array( 'id' => 'submit-quick-search-taxonomy-' . $taxonomy_name ) ); ?> |
|
883 | + <?php submit_button(__('Search'), 'small quick-search-submit hide-if-js', 'submit', false, array('id' => 'submit-quick-search-taxonomy-' . $taxonomy_name)); ?> |
|
884 | 884 | </p> |
885 | 885 | |
886 | 886 | <ul id="<?php echo $taxonomy_name; ?>-search-checklist" data-wp-lists="list:<?php echo $taxonomy_name; ?>" class="categorychecklist form-no-clear"> |
887 | - <?php if ( ! empty( $search_results ) && ! is_wp_error( $search_results ) ) : ?> |
|
887 | + <?php if (!empty($search_results) && !is_wp_error($search_results)) : ?> |
|
888 | 888 | <?php |
889 | 889 | $args['walker'] = $walker; |
890 | - echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $search_results ), 0, (object) $args ); |
|
890 | + echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $search_results), 0, (object) $args); |
|
891 | 891 | ?> |
892 | - <?php elseif ( is_wp_error( $search_results ) ) : ?> |
|
892 | + <?php elseif (is_wp_error($search_results)) : ?> |
|
893 | 893 | <li><?php echo $search_results->get_error_message(); ?></li> |
894 | - <?php elseif ( ! empty( $searched ) ) : ?> |
|
895 | - <li><?php _e( 'No results found.' ); ?></li> |
|
894 | + <?php elseif (!empty($searched)) : ?> |
|
895 | + <li><?php _e('No results found.'); ?></li> |
|
896 | 896 | <?php endif; ?> |
897 | 897 | </ul> |
898 | 898 | </div><!-- /.tabs-panel --> |
899 | 899 | |
900 | - <p class="button-controls wp-clearfix" data-items-type="taxonomy-<?php echo esc_attr( $taxonomy_name ); ?>"> |
|
900 | + <p class="button-controls wp-clearfix" data-items-type="taxonomy-<?php echo esc_attr($taxonomy_name); ?>"> |
|
901 | 901 | <span class="list-controls hide-if-no-js"> |
902 | - <input type="checkbox"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> id="<?php echo esc_attr( $tab_name ); ?>" class="select-all" /> |
|
903 | - <label for="<?php echo esc_attr( $tab_name ); ?>"><?php _e( 'Select All' ); ?></label> |
|
902 | + <input type="checkbox"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> id="<?php echo esc_attr($tab_name); ?>" class="select-all" /> |
|
903 | + <label for="<?php echo esc_attr($tab_name); ?>"><?php _e('Select All'); ?></label> |
|
904 | 904 | </span> |
905 | 905 | |
906 | 906 | <span class="add-to-menu"> |
907 | - <input type="submit"<?php wp_nav_menu_disabled_check( $nav_menu_selected_id ); ?> class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to Menu' ); ?>" name="add-taxonomy-menu-item" id="<?php echo esc_attr( 'submit-taxonomy-' . $taxonomy_name ); ?>" /> |
|
907 | + <input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> class="button submit-add-to-menu right" value="<?php esc_attr_e('Add to Menu'); ?>" name="add-taxonomy-menu-item" id="<?php echo esc_attr('submit-taxonomy-' . $taxonomy_name); ?>" /> |
|
908 | 908 | <span class="spinner"></span> |
909 | 909 | </span> |
910 | 910 | </p> |
@@ -922,26 +922,26 @@ discard block |
||
922 | 922 | * @param array[] $menu_data The unsanitized POSTed menu item data. |
923 | 923 | * @return int[] The database IDs of the items saved |
924 | 924 | */ |
925 | -function wp_save_nav_menu_items( $menu_id = 0, $menu_data = array() ) { |
|
925 | +function wp_save_nav_menu_items($menu_id = 0, $menu_data = array()) { |
|
926 | 926 | $menu_id = (int) $menu_id; |
927 | 927 | $items_saved = array(); |
928 | 928 | |
929 | - if ( 0 == $menu_id || is_nav_menu( $menu_id ) ) { |
|
929 | + if (0 == $menu_id || is_nav_menu($menu_id)) { |
|
930 | 930 | |
931 | 931 | // Loop through all the menu items' POST values. |
932 | - foreach ( (array) $menu_data as $_possible_db_id => $_item_object_data ) { |
|
932 | + foreach ((array) $menu_data as $_possible_db_id => $_item_object_data) { |
|
933 | 933 | if ( |
934 | 934 | // Checkbox is not checked. |
935 | - empty( $_item_object_data['menu-item-object-id'] ) && |
|
935 | + empty($_item_object_data['menu-item-object-id']) && |
|
936 | 936 | ( |
937 | 937 | // And item type either isn't set. |
938 | - ! isset( $_item_object_data['menu-item-type'] ) || |
|
938 | + !isset($_item_object_data['menu-item-type']) || |
|
939 | 939 | // Or URL is the default. |
940 | - in_array( $_item_object_data['menu-item-url'], array( 'https://', 'http://', '' ), true ) || |
|
940 | + in_array($_item_object_data['menu-item-url'], array('https://', 'http://', ''), true) || |
|
941 | 941 | // Or it's not a custom menu item (but not the custom home page). |
942 | - ! ( 'custom' === $_item_object_data['menu-item-type'] && ! isset( $_item_object_data['menu-item-db-id'] ) ) || |
|
942 | + !('custom' === $_item_object_data['menu-item-type'] && !isset($_item_object_data['menu-item-db-id'])) || |
|
943 | 943 | // Or it *is* a custom menu item that already exists. |
944 | - ! empty( $_item_object_data['menu-item-db-id'] ) |
|
944 | + !empty($_item_object_data['menu-item-db-id']) |
|
945 | 945 | ) |
946 | 946 | ) { |
947 | 947 | // Then this potential menu item is not getting added to this menu. |
@@ -950,8 +950,8 @@ discard block |
||
950 | 950 | |
951 | 951 | // If this possible menu item doesn't actually have a menu database ID yet. |
952 | 952 | if ( |
953 | - empty( $_item_object_data['menu-item-db-id'] ) || |
|
954 | - ( 0 > $_possible_db_id ) || |
|
953 | + empty($_item_object_data['menu-item-db-id']) || |
|
954 | + (0 > $_possible_db_id) || |
|
955 | 955 | $_possible_db_id != $_item_object_data['menu-item-db-id'] |
956 | 956 | ) { |
957 | 957 | $_actual_db_id = 0; |
@@ -960,22 +960,22 @@ discard block |
||
960 | 960 | } |
961 | 961 | |
962 | 962 | $args = array( |
963 | - 'menu-item-db-id' => ( isset( $_item_object_data['menu-item-db-id'] ) ? $_item_object_data['menu-item-db-id'] : '' ), |
|
964 | - 'menu-item-object-id' => ( isset( $_item_object_data['menu-item-object-id'] ) ? $_item_object_data['menu-item-object-id'] : '' ), |
|
965 | - 'menu-item-object' => ( isset( $_item_object_data['menu-item-object'] ) ? $_item_object_data['menu-item-object'] : '' ), |
|
966 | - 'menu-item-parent-id' => ( isset( $_item_object_data['menu-item-parent-id'] ) ? $_item_object_data['menu-item-parent-id'] : '' ), |
|
967 | - 'menu-item-position' => ( isset( $_item_object_data['menu-item-position'] ) ? $_item_object_data['menu-item-position'] : '' ), |
|
968 | - 'menu-item-type' => ( isset( $_item_object_data['menu-item-type'] ) ? $_item_object_data['menu-item-type'] : '' ), |
|
969 | - 'menu-item-title' => ( isset( $_item_object_data['menu-item-title'] ) ? $_item_object_data['menu-item-title'] : '' ), |
|
970 | - 'menu-item-url' => ( isset( $_item_object_data['menu-item-url'] ) ? $_item_object_data['menu-item-url'] : '' ), |
|
971 | - 'menu-item-description' => ( isset( $_item_object_data['menu-item-description'] ) ? $_item_object_data['menu-item-description'] : '' ), |
|
972 | - 'menu-item-attr-title' => ( isset( $_item_object_data['menu-item-attr-title'] ) ? $_item_object_data['menu-item-attr-title'] : '' ), |
|
973 | - 'menu-item-target' => ( isset( $_item_object_data['menu-item-target'] ) ? $_item_object_data['menu-item-target'] : '' ), |
|
974 | - 'menu-item-classes' => ( isset( $_item_object_data['menu-item-classes'] ) ? $_item_object_data['menu-item-classes'] : '' ), |
|
975 | - 'menu-item-xfn' => ( isset( $_item_object_data['menu-item-xfn'] ) ? $_item_object_data['menu-item-xfn'] : '' ), |
|
963 | + 'menu-item-db-id' => (isset($_item_object_data['menu-item-db-id']) ? $_item_object_data['menu-item-db-id'] : ''), |
|
964 | + 'menu-item-object-id' => (isset($_item_object_data['menu-item-object-id']) ? $_item_object_data['menu-item-object-id'] : ''), |
|
965 | + 'menu-item-object' => (isset($_item_object_data['menu-item-object']) ? $_item_object_data['menu-item-object'] : ''), |
|
966 | + 'menu-item-parent-id' => (isset($_item_object_data['menu-item-parent-id']) ? $_item_object_data['menu-item-parent-id'] : ''), |
|
967 | + 'menu-item-position' => (isset($_item_object_data['menu-item-position']) ? $_item_object_data['menu-item-position'] : ''), |
|
968 | + 'menu-item-type' => (isset($_item_object_data['menu-item-type']) ? $_item_object_data['menu-item-type'] : ''), |
|
969 | + 'menu-item-title' => (isset($_item_object_data['menu-item-title']) ? $_item_object_data['menu-item-title'] : ''), |
|
970 | + 'menu-item-url' => (isset($_item_object_data['menu-item-url']) ? $_item_object_data['menu-item-url'] : ''), |
|
971 | + 'menu-item-description' => (isset($_item_object_data['menu-item-description']) ? $_item_object_data['menu-item-description'] : ''), |
|
972 | + 'menu-item-attr-title' => (isset($_item_object_data['menu-item-attr-title']) ? $_item_object_data['menu-item-attr-title'] : ''), |
|
973 | + 'menu-item-target' => (isset($_item_object_data['menu-item-target']) ? $_item_object_data['menu-item-target'] : ''), |
|
974 | + 'menu-item-classes' => (isset($_item_object_data['menu-item-classes']) ? $_item_object_data['menu-item-classes'] : ''), |
|
975 | + 'menu-item-xfn' => (isset($_item_object_data['menu-item-xfn']) ? $_item_object_data['menu-item-xfn'] : ''), |
|
976 | 976 | ); |
977 | 977 | |
978 | - $items_saved[] = wp_update_nav_menu_item( $menu_id, $_actual_db_id, $args ); |
|
978 | + $items_saved[] = wp_update_nav_menu_item($menu_id, $_actual_db_id, $args); |
|
979 | 979 | |
980 | 980 | } |
981 | 981 | } |
@@ -992,23 +992,23 @@ discard block |
||
992 | 992 | * @param object $data_object The post type or taxonomy meta-object. |
993 | 993 | * @return object The post type or taxonomy object. |
994 | 994 | */ |
995 | -function _wp_nav_menu_meta_box_object( $data_object = null ) { |
|
996 | - if ( isset( $data_object->name ) ) { |
|
995 | +function _wp_nav_menu_meta_box_object($data_object = null) { |
|
996 | + if (isset($data_object->name)) { |
|
997 | 997 | |
998 | - if ( 'page' === $data_object->name ) { |
|
998 | + if ('page' === $data_object->name) { |
|
999 | 999 | $data_object->_default_query = array( |
1000 | 1000 | 'orderby' => 'menu_order title', |
1001 | 1001 | 'post_status' => 'publish', |
1002 | 1002 | ); |
1003 | 1003 | |
1004 | 1004 | // Posts should show only published items. |
1005 | - } elseif ( 'post' === $data_object->name ) { |
|
1005 | + } elseif ('post' === $data_object->name) { |
|
1006 | 1006 | $data_object->_default_query = array( |
1007 | 1007 | 'post_status' => 'publish', |
1008 | 1008 | ); |
1009 | 1009 | |
1010 | 1010 | // Categories should be in reverse chronological order. |
1011 | - } elseif ( 'category' === $data_object->name ) { |
|
1011 | + } elseif ('category' === $data_object->name) { |
|
1012 | 1012 | $data_object->_default_query = array( |
1013 | 1013 | 'orderby' => 'id', |
1014 | 1014 | 'order' => 'DESC', |
@@ -1033,18 +1033,18 @@ discard block |
||
1033 | 1033 | * @param int $menu_id Optional. The ID of the menu to format. Default 0. |
1034 | 1034 | * @return string|WP_Error The menu formatted to edit or error object on failure. |
1035 | 1035 | */ |
1036 | -function wp_get_nav_menu_to_edit( $menu_id = 0 ) { |
|
1037 | - $menu = wp_get_nav_menu_object( $menu_id ); |
|
1036 | +function wp_get_nav_menu_to_edit($menu_id = 0) { |
|
1037 | + $menu = wp_get_nav_menu_object($menu_id); |
|
1038 | 1038 | |
1039 | 1039 | // If the menu exists, get its items. |
1040 | - if ( is_nav_menu( $menu ) ) { |
|
1041 | - $menu_items = wp_get_nav_menu_items( $menu->term_id, array( 'post_status' => 'any' ) ); |
|
1040 | + if (is_nav_menu($menu)) { |
|
1041 | + $menu_items = wp_get_nav_menu_items($menu->term_id, array('post_status' => 'any')); |
|
1042 | 1042 | $result = '<div id="menu-instructions" class="post-body-plain'; |
1043 | - $result .= ( ! empty( $menu_items ) ) ? ' menu-instructions-inactive">' : '">'; |
|
1044 | - $result .= '<p>' . __( 'Add menu items from the column on the left.' ) . '</p>'; |
|
1043 | + $result .= (!empty($menu_items)) ? ' menu-instructions-inactive">' : '">'; |
|
1044 | + $result .= '<p>' . __('Add menu items from the column on the left.') . '</p>'; |
|
1045 | 1045 | $result .= '</div>'; |
1046 | 1046 | |
1047 | - if ( empty( $menu_items ) ) { |
|
1047 | + if (empty($menu_items)) { |
|
1048 | 1048 | return $result . ' <ul class="menu" id="menu-to-edit"> </ul>'; |
1049 | 1049 | } |
1050 | 1050 | |
@@ -1056,16 +1056,16 @@ discard block |
||
1056 | 1056 | * @param string $class The walker class to use. Default 'Walker_Nav_Menu_Edit'. |
1057 | 1057 | * @param int $menu_id ID of the menu being rendered. |
1058 | 1058 | */ |
1059 | - $walker_class_name = apply_filters( 'wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $menu_id ); |
|
1059 | + $walker_class_name = apply_filters('wp_edit_nav_menu_walker', 'Walker_Nav_Menu_Edit', $menu_id); |
|
1060 | 1060 | |
1061 | - if ( class_exists( $walker_class_name ) ) { |
|
1061 | + if (class_exists($walker_class_name)) { |
|
1062 | 1062 | $walker = new $walker_class_name; |
1063 | 1063 | } else { |
1064 | 1064 | return new WP_Error( |
1065 | 1065 | 'menu_walker_not_exist', |
1066 | 1066 | sprintf( |
1067 | 1067 | /* translators: %s: Walker class name. */ |
1068 | - __( 'The Walker class named %s does not exist.' ), |
|
1068 | + __('The Walker class named %s does not exist.'), |
|
1069 | 1069 | '<strong>' . $walker_class_name . '</strong>' |
1070 | 1070 | ) |
1071 | 1071 | ); |
@@ -1073,28 +1073,28 @@ discard block |
||
1073 | 1073 | |
1074 | 1074 | $some_pending_menu_items = false; |
1075 | 1075 | $some_invalid_menu_items = false; |
1076 | - foreach ( (array) $menu_items as $menu_item ) { |
|
1077 | - if ( isset( $menu_item->post_status ) && 'draft' === $menu_item->post_status ) { |
|
1076 | + foreach ((array) $menu_items as $menu_item) { |
|
1077 | + if (isset($menu_item->post_status) && 'draft' === $menu_item->post_status) { |
|
1078 | 1078 | $some_pending_menu_items = true; |
1079 | 1079 | } |
1080 | - if ( ! empty( $menu_item->_invalid ) ) { |
|
1080 | + if (!empty($menu_item->_invalid)) { |
|
1081 | 1081 | $some_invalid_menu_items = true; |
1082 | 1082 | } |
1083 | 1083 | } |
1084 | 1084 | |
1085 | - if ( $some_pending_menu_items ) { |
|
1086 | - $result .= '<div class="notice notice-info notice-alt inline"><p>' . __( 'Click Save Menu to make pending menu items public.' ) . '</p></div>'; |
|
1085 | + if ($some_pending_menu_items) { |
|
1086 | + $result .= '<div class="notice notice-info notice-alt inline"><p>' . __('Click Save Menu to make pending menu items public.') . '</p></div>'; |
|
1087 | 1087 | } |
1088 | 1088 | |
1089 | - if ( $some_invalid_menu_items ) { |
|
1090 | - $result .= '<div class="notice notice-error notice-alt inline"><p>' . __( 'There are some invalid menu items. Please check or delete them.' ) . '</p></div>'; |
|
1089 | + if ($some_invalid_menu_items) { |
|
1090 | + $result .= '<div class="notice notice-error notice-alt inline"><p>' . __('There are some invalid menu items. Please check or delete them.') . '</p></div>'; |
|
1091 | 1091 | } |
1092 | 1092 | |
1093 | 1093 | $result .= '<ul class="menu" id="menu-to-edit"> '; |
1094 | - $result .= walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $menu_items ), 0, (object) array( 'walker' => $walker ) ); |
|
1094 | + $result .= walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $menu_items), 0, (object) array('walker' => $walker)); |
|
1095 | 1095 | $result .= ' </ul> '; |
1096 | 1096 | return $result; |
1097 | - } elseif ( is_wp_error( $menu ) ) { |
|
1097 | + } elseif (is_wp_error($menu)) { |
|
1098 | 1098 | return $menu; |
1099 | 1099 | } |
1100 | 1100 | |
@@ -1109,13 +1109,13 @@ discard block |
||
1109 | 1109 | */ |
1110 | 1110 | function wp_nav_menu_manage_columns() { |
1111 | 1111 | return array( |
1112 | - '_title' => __( 'Show advanced menu properties' ), |
|
1112 | + '_title' => __('Show advanced menu properties'), |
|
1113 | 1113 | 'cb' => '<input type="checkbox" />', |
1114 | - 'link-target' => __( 'Link Target' ), |
|
1115 | - 'title-attribute' => __( 'Title Attribute' ), |
|
1116 | - 'css-classes' => __( 'CSS Classes' ), |
|
1117 | - 'xfn' => __( 'Link Relationship (XFN)' ), |
|
1118 | - 'description' => __( 'Description' ), |
|
1114 | + 'link-target' => __('Link Target'), |
|
1115 | + 'title-attribute' => __('Title Attribute'), |
|
1116 | + 'css-classes' => __('CSS Classes'), |
|
1117 | + 'xfn' => __('Link Relationship (XFN)'), |
|
1118 | + 'description' => __('Description'), |
|
1119 | 1119 | ); |
1120 | 1120 | } |
1121 | 1121 | |
@@ -1129,13 +1129,13 @@ discard block |
||
1129 | 1129 | */ |
1130 | 1130 | function _wp_delete_orphaned_draft_menu_items() { |
1131 | 1131 | global $wpdb; |
1132 | - $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS ); |
|
1132 | + $delete_timestamp = time() - (DAY_IN_SECONDS * EMPTY_TRASH_DAYS); |
|
1133 | 1133 | |
1134 | 1134 | // Delete orphaned draft menu items. |
1135 | - $menu_items_to_delete = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts AS p LEFT JOIN $wpdb->postmeta AS m ON p.ID = m.post_id WHERE post_type = 'nav_menu_item' AND post_status = 'draft' AND meta_key = '_menu_item_orphaned' AND meta_value < %d", $delete_timestamp ) ); |
|
1135 | + $menu_items_to_delete = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts AS p LEFT JOIN $wpdb->postmeta AS m ON p.ID = m.post_id WHERE post_type = 'nav_menu_item' AND post_status = 'draft' AND meta_key = '_menu_item_orphaned' AND meta_value < %d", $delete_timestamp)); |
|
1136 | 1136 | |
1137 | - foreach ( (array) $menu_items_to_delete as $menu_item_id ) { |
|
1138 | - wp_delete_post( $menu_item_id, true ); |
|
1137 | + foreach ((array) $menu_items_to_delete as $menu_item_id) { |
|
1138 | + wp_delete_post($menu_item_id, true); |
|
1139 | 1139 | } |
1140 | 1140 | } |
1141 | 1141 | |
@@ -1148,7 +1148,7 @@ discard block |
||
1148 | 1148 | * @param string $nav_menu_selected_title Title of the currently-selected menu. |
1149 | 1149 | * @return array The menu updated message |
1150 | 1150 | */ |
1151 | -function wp_nav_menu_update_menu_items( $nav_menu_selected_id, $nav_menu_selected_title ) { |
|
1151 | +function wp_nav_menu_update_menu_items($nav_menu_selected_id, $nav_menu_selected_title) { |
|
1152 | 1152 | $unsorted_menu_items = wp_get_nav_menu_items( |
1153 | 1153 | $nav_menu_selected_id, |
1154 | 1154 | array( |
@@ -1163,8 +1163,8 @@ discard block |
||
1163 | 1163 | $menu_items = array(); |
1164 | 1164 | |
1165 | 1165 | // Index menu items by DB ID. |
1166 | - foreach ( $unsorted_menu_items as $_item ) { |
|
1167 | - $menu_items[ $_item->db_id ] = $_item; |
|
1166 | + foreach ($unsorted_menu_items as $_item) { |
|
1167 | + $menu_items[$_item->db_id] = $_item; |
|
1168 | 1168 | } |
1169 | 1169 | |
1170 | 1170 | $post_fields = array( |
@@ -1183,77 +1183,77 @@ discard block |
||
1183 | 1183 | 'menu-item-xfn', |
1184 | 1184 | ); |
1185 | 1185 | |
1186 | - wp_defer_term_counting( true ); |
|
1186 | + wp_defer_term_counting(true); |
|
1187 | 1187 | |
1188 | 1188 | // Loop through all the menu items' POST variables. |
1189 | - if ( ! empty( $_POST['menu-item-db-id'] ) ) { |
|
1190 | - foreach ( (array) $_POST['menu-item-db-id'] as $_key => $k ) { |
|
1189 | + if (!empty($_POST['menu-item-db-id'])) { |
|
1190 | + foreach ((array) $_POST['menu-item-db-id'] as $_key => $k) { |
|
1191 | 1191 | |
1192 | 1192 | // Menu item title can't be blank. |
1193 | - if ( ! isset( $_POST['menu-item-title'][ $_key ] ) || '' === $_POST['menu-item-title'][ $_key ] ) { |
|
1193 | + if (!isset($_POST['menu-item-title'][$_key]) || '' === $_POST['menu-item-title'][$_key]) { |
|
1194 | 1194 | continue; |
1195 | 1195 | } |
1196 | 1196 | |
1197 | 1197 | $args = array(); |
1198 | - foreach ( $post_fields as $field ) { |
|
1199 | - $args[ $field ] = isset( $_POST[ $field ][ $_key ] ) ? $_POST[ $field ][ $_key ] : ''; |
|
1198 | + foreach ($post_fields as $field) { |
|
1199 | + $args[$field] = isset($_POST[$field][$_key]) ? $_POST[$field][$_key] : ''; |
|
1200 | 1200 | } |
1201 | 1201 | |
1202 | - $menu_item_db_id = wp_update_nav_menu_item( $nav_menu_selected_id, ( $_POST['menu-item-db-id'][ $_key ] != $_key ? 0 : $_key ), $args ); |
|
1202 | + $menu_item_db_id = wp_update_nav_menu_item($nav_menu_selected_id, ($_POST['menu-item-db-id'][$_key] != $_key ? 0 : $_key), $args); |
|
1203 | 1203 | |
1204 | - if ( is_wp_error( $menu_item_db_id ) ) { |
|
1204 | + if (is_wp_error($menu_item_db_id)) { |
|
1205 | 1205 | $messages[] = '<div id="message" class="error"><p>' . $menu_item_db_id->get_error_message() . '</p></div>'; |
1206 | 1206 | } else { |
1207 | - unset( $menu_items[ $menu_item_db_id ] ); |
|
1207 | + unset($menu_items[$menu_item_db_id]); |
|
1208 | 1208 | } |
1209 | 1209 | } |
1210 | 1210 | } |
1211 | 1211 | |
1212 | 1212 | // Remove menu items from the menu that weren't in $_POST. |
1213 | - if ( ! empty( $menu_items ) ) { |
|
1214 | - foreach ( array_keys( $menu_items ) as $menu_item_id ) { |
|
1215 | - if ( is_nav_menu_item( $menu_item_id ) ) { |
|
1216 | - wp_delete_post( $menu_item_id ); |
|
1213 | + if (!empty($menu_items)) { |
|
1214 | + foreach (array_keys($menu_items) as $menu_item_id) { |
|
1215 | + if (is_nav_menu_item($menu_item_id)) { |
|
1216 | + wp_delete_post($menu_item_id); |
|
1217 | 1217 | } |
1218 | 1218 | } |
1219 | 1219 | } |
1220 | 1220 | |
1221 | 1221 | // Store 'auto-add' pages. |
1222 | - $auto_add = ! empty( $_POST['auto-add-pages'] ); |
|
1223 | - $nav_menu_option = (array) get_option( 'nav_menu_options' ); |
|
1222 | + $auto_add = !empty($_POST['auto-add-pages']); |
|
1223 | + $nav_menu_option = (array) get_option('nav_menu_options'); |
|
1224 | 1224 | |
1225 | - if ( ! isset( $nav_menu_option['auto_add'] ) ) { |
|
1225 | + if (!isset($nav_menu_option['auto_add'])) { |
|
1226 | 1226 | $nav_menu_option['auto_add'] = array(); |
1227 | 1227 | } |
1228 | 1228 | |
1229 | - if ( $auto_add ) { |
|
1230 | - if ( ! in_array( $nav_menu_selected_id, $nav_menu_option['auto_add'], true ) ) { |
|
1229 | + if ($auto_add) { |
|
1230 | + if (!in_array($nav_menu_selected_id, $nav_menu_option['auto_add'], true)) { |
|
1231 | 1231 | $nav_menu_option['auto_add'][] = $nav_menu_selected_id; |
1232 | 1232 | } |
1233 | 1233 | } else { |
1234 | - $key = array_search( $nav_menu_selected_id, $nav_menu_option['auto_add'], true ); |
|
1235 | - if ( false !== $key ) { |
|
1236 | - unset( $nav_menu_option['auto_add'][ $key ] ); |
|
1234 | + $key = array_search($nav_menu_selected_id, $nav_menu_option['auto_add'], true); |
|
1235 | + if (false !== $key) { |
|
1236 | + unset($nav_menu_option['auto_add'][$key]); |
|
1237 | 1237 | } |
1238 | 1238 | } |
1239 | 1239 | |
1240 | 1240 | // Remove non-existent/deleted menus. |
1241 | - $nav_menu_option['auto_add'] = array_intersect( $nav_menu_option['auto_add'], wp_get_nav_menus( array( 'fields' => 'ids' ) ) ); |
|
1242 | - update_option( 'nav_menu_options', $nav_menu_option ); |
|
1241 | + $nav_menu_option['auto_add'] = array_intersect($nav_menu_option['auto_add'], wp_get_nav_menus(array('fields' => 'ids'))); |
|
1242 | + update_option('nav_menu_options', $nav_menu_option); |
|
1243 | 1243 | |
1244 | - wp_defer_term_counting( false ); |
|
1244 | + wp_defer_term_counting(false); |
|
1245 | 1245 | |
1246 | 1246 | /** This action is documented in wp-includes/nav-menu.php */ |
1247 | - do_action( 'wp_update_nav_menu', $nav_menu_selected_id ); |
|
1247 | + do_action('wp_update_nav_menu', $nav_menu_selected_id); |
|
1248 | 1248 | |
1249 | 1249 | $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . |
1250 | 1250 | sprintf( |
1251 | 1251 | /* translators: %s: Nav menu title. */ |
1252 | - __( '%s has been updated.' ), |
|
1252 | + __('%s has been updated.'), |
|
1253 | 1253 | '<strong>' . $nav_menu_selected_title . '</strong>' |
1254 | 1254 | ) . '</p></div>'; |
1255 | 1255 | |
1256 | - unset( $menu_items, $unsorted_menu_items ); |
|
1256 | + unset($menu_items, $unsorted_menu_items); |
|
1257 | 1257 | |
1258 | 1258 | return $messages; |
1259 | 1259 | } |
@@ -1267,36 +1267,36 @@ discard block |
||
1267 | 1267 | * @access private |
1268 | 1268 | */ |
1269 | 1269 | function _wp_expand_nav_menu_post_data() { |
1270 | - if ( ! isset( $_POST['nav-menu-data'] ) ) { |
|
1270 | + if (!isset($_POST['nav-menu-data'])) { |
|
1271 | 1271 | return; |
1272 | 1272 | } |
1273 | 1273 | |
1274 | - $data = json_decode( stripslashes( $_POST['nav-menu-data'] ) ); |
|
1274 | + $data = json_decode(stripslashes($_POST['nav-menu-data'])); |
|
1275 | 1275 | |
1276 | - if ( ! is_null( $data ) && $data ) { |
|
1277 | - foreach ( $data as $post_input_data ) { |
|
1276 | + if (!is_null($data) && $data) { |
|
1277 | + foreach ($data as $post_input_data) { |
|
1278 | 1278 | // For input names that are arrays (e.g. `menu-item-db-id[3][4][5]`), |
1279 | 1279 | // derive the array path keys via regex and set the value in $_POST. |
1280 | - preg_match( '#([^\[]*)(\[(.+)\])?#', $post_input_data->name, $matches ); |
|
1280 | + preg_match('#([^\[]*)(\[(.+)\])?#', $post_input_data->name, $matches); |
|
1281 | 1281 | |
1282 | - $array_bits = array( $matches[1] ); |
|
1282 | + $array_bits = array($matches[1]); |
|
1283 | 1283 | |
1284 | - if ( isset( $matches[3] ) ) { |
|
1285 | - $array_bits = array_merge( $array_bits, explode( '][', $matches[3] ) ); |
|
1284 | + if (isset($matches[3])) { |
|
1285 | + $array_bits = array_merge($array_bits, explode('][', $matches[3])); |
|
1286 | 1286 | } |
1287 | 1287 | |
1288 | 1288 | $new_post_data = array(); |
1289 | 1289 | |
1290 | 1290 | // Build the new array value from leaf to trunk. |
1291 | - for ( $i = count( $array_bits ) - 1; $i >= 0; $i-- ) { |
|
1292 | - if ( count( $array_bits ) - 1 == $i ) { |
|
1293 | - $new_post_data[ $array_bits[ $i ] ] = wp_slash( $post_input_data->value ); |
|
1291 | + for ($i = count($array_bits) - 1; $i >= 0; $i--) { |
|
1292 | + if (count($array_bits) - 1 == $i) { |
|
1293 | + $new_post_data[$array_bits[$i]] = wp_slash($post_input_data->value); |
|
1294 | 1294 | } else { |
1295 | - $new_post_data = array( $array_bits[ $i ] => $new_post_data ); |
|
1295 | + $new_post_data = array($array_bits[$i] => $new_post_data); |
|
1296 | 1296 | } |
1297 | 1297 | } |
1298 | 1298 | |
1299 | - $_POST = array_replace_recursive( $_POST, $new_post_data ); |
|
1299 | + $_POST = array_replace_recursive($_POST, $new_post_data); |
|
1300 | 1300 | } |
1301 | 1301 | } |
1302 | 1302 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * @since 4.9.6 |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! class_exists( 'WP_Privacy_Requests_Table' ) ) { |
|
10 | +if (!class_exists('WP_Privacy_Requests_Table')) { |
|
11 | 11 | require_once ABSPATH . 'wp-admin/includes/class-wp-privacy-requests-table.php'; |
12 | 12 | } |
13 | 13 | |
@@ -43,36 +43,36 @@ discard block |
||
43 | 43 | * @param WP_User_Request $item Item being shown. |
44 | 44 | * @return string Email column markup. |
45 | 45 | */ |
46 | - public function column_email( $item ) { |
|
46 | + public function column_email($item) { |
|
47 | 47 | $row_actions = array(); |
48 | 48 | |
49 | 49 | // Allow the administrator to "force remove" the personal data even if confirmation has not yet been received. |
50 | 50 | $status = $item->status; |
51 | 51 | $request_id = $item->ID; |
52 | 52 | $row_actions = array(); |
53 | - if ( 'request-confirmed' !== $status ) { |
|
53 | + if ('request-confirmed' !== $status) { |
|
54 | 54 | /** This filter is documented in wp-admin/includes/ajax-actions.php */ |
55 | - $erasers = apply_filters( 'wp_privacy_personal_data_erasers', array() ); |
|
56 | - $erasers_count = count( $erasers ); |
|
57 | - $nonce = wp_create_nonce( 'wp-privacy-erase-personal-data-' . $request_id ); |
|
55 | + $erasers = apply_filters('wp_privacy_personal_data_erasers', array()); |
|
56 | + $erasers_count = count($erasers); |
|
57 | + $nonce = wp_create_nonce('wp-privacy-erase-personal-data-' . $request_id); |
|
58 | 58 | |
59 | 59 | $remove_data_markup = '<span class="remove-personal-data force-remove-personal-data" ' . |
60 | - 'data-erasers-count="' . esc_attr( $erasers_count ) . '" ' . |
|
61 | - 'data-request-id="' . esc_attr( $request_id ) . '" ' . |
|
62 | - 'data-nonce="' . esc_attr( $nonce ) . |
|
60 | + 'data-erasers-count="' . esc_attr($erasers_count) . '" ' . |
|
61 | + 'data-request-id="' . esc_attr($request_id) . '" ' . |
|
62 | + 'data-nonce="' . esc_attr($nonce) . |
|
63 | 63 | '">'; |
64 | 64 | |
65 | - $remove_data_markup .= '<span class="remove-personal-data-idle"><button type="button" class="button-link remove-personal-data-handle">' . __( 'Force erase personal data' ) . '</button></span>' . |
|
66 | - '<span class="remove-personal-data-processing hidden">' . __( 'Erasing data...' ) . ' <span class="erasure-progress"></span></span>' . |
|
67 | - '<span class="remove-personal-data-success hidden">' . __( 'Erasure completed.' ) . '</span>' . |
|
68 | - '<span class="remove-personal-data-failed hidden">' . __( 'Force erasure has failed.' ) . ' <button type="button" class="button-link remove-personal-data-handle">' . __( 'Retry' ) . '</button></span>'; |
|
65 | + $remove_data_markup .= '<span class="remove-personal-data-idle"><button type="button" class="button-link remove-personal-data-handle">' . __('Force erase personal data') . '</button></span>' . |
|
66 | + '<span class="remove-personal-data-processing hidden">' . __('Erasing data...') . ' <span class="erasure-progress"></span></span>' . |
|
67 | + '<span class="remove-personal-data-success hidden">' . __('Erasure completed.') . '</span>' . |
|
68 | + '<span class="remove-personal-data-failed hidden">' . __('Force erasure has failed.') . ' <button type="button" class="button-link remove-personal-data-handle">' . __('Retry') . '</button></span>'; |
|
69 | 69 | |
70 | 70 | $remove_data_markup .= '</span>'; |
71 | 71 | |
72 | 72 | $row_actions['remove-data'] = $remove_data_markup; |
73 | 73 | } |
74 | 74 | |
75 | - if ( 'request-completed' !== $status ) { |
|
75 | + if ('request-completed' !== $status) { |
|
76 | 76 | $complete_request_markup = '<span>'; |
77 | 77 | $complete_request_markup .= sprintf( |
78 | 78 | '<a href="%s" class="complete-request" aria-label="%s">%s</a>', |
@@ -81,9 +81,9 @@ discard block |
||
81 | 81 | add_query_arg( |
82 | 82 | array( |
83 | 83 | 'action' => 'complete', |
84 | - 'request_id' => array( $request_id ), |
|
84 | + 'request_id' => array($request_id), |
|
85 | 85 | ), |
86 | - admin_url( 'erase-personal-data.php' ) |
|
86 | + admin_url('erase-personal-data.php') |
|
87 | 87 | ), |
88 | 88 | 'bulk-privacy_requests' |
89 | 89 | ) |
@@ -91,20 +91,20 @@ discard block |
||
91 | 91 | esc_attr( |
92 | 92 | sprintf( |
93 | 93 | /* translators: %s: Request email. */ |
94 | - __( 'Mark export request for “%s” as completed.' ), |
|
94 | + __('Mark export request for “%s” as completed.'), |
|
95 | 95 | $item->email |
96 | 96 | ) |
97 | 97 | ), |
98 | - __( 'Complete request' ) |
|
98 | + __('Complete request') |
|
99 | 99 | ); |
100 | 100 | $complete_request_markup .= '</span>'; |
101 | 101 | } |
102 | 102 | |
103 | - if ( ! empty( $complete_request_markup ) ) { |
|
103 | + if (!empty($complete_request_markup)) { |
|
104 | 104 | $row_actions['complete-request'] = $complete_request_markup; |
105 | 105 | } |
106 | 106 | |
107 | - return sprintf( '<a href="%1$s">%2$s</a> %3$s', esc_url( 'mailto:' . $item->email ), $item->email, $this->row_actions( $row_actions ) ); |
|
107 | + return sprintf('<a href="%1$s">%2$s</a> %3$s', esc_url('mailto:' . $item->email), $item->email, $this->row_actions($row_actions)); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | /** |
@@ -114,39 +114,39 @@ discard block |
||
114 | 114 | * |
115 | 115 | * @param WP_User_Request $item Item being shown. |
116 | 116 | */ |
117 | - public function column_next_steps( $item ) { |
|
117 | + public function column_next_steps($item) { |
|
118 | 118 | $status = $item->status; |
119 | 119 | |
120 | - switch ( $status ) { |
|
120 | + switch ($status) { |
|
121 | 121 | case 'request-pending': |
122 | - esc_html_e( 'Waiting for confirmation' ); |
|
122 | + esc_html_e('Waiting for confirmation'); |
|
123 | 123 | break; |
124 | 124 | case 'request-confirmed': |
125 | 125 | /** This filter is documented in wp-admin/includes/ajax-actions.php */ |
126 | - $erasers = apply_filters( 'wp_privacy_personal_data_erasers', array() ); |
|
127 | - $erasers_count = count( $erasers ); |
|
126 | + $erasers = apply_filters('wp_privacy_personal_data_erasers', array()); |
|
127 | + $erasers_count = count($erasers); |
|
128 | 128 | $request_id = $item->ID; |
129 | - $nonce = wp_create_nonce( 'wp-privacy-erase-personal-data-' . $request_id ); |
|
129 | + $nonce = wp_create_nonce('wp-privacy-erase-personal-data-' . $request_id); |
|
130 | 130 | |
131 | 131 | echo '<div class="remove-personal-data" ' . |
132 | 132 | 'data-force-erase="1" ' . |
133 | - 'data-erasers-count="' . esc_attr( $erasers_count ) . '" ' . |
|
134 | - 'data-request-id="' . esc_attr( $request_id ) . '" ' . |
|
135 | - 'data-nonce="' . esc_attr( $nonce ) . |
|
133 | + 'data-erasers-count="' . esc_attr($erasers_count) . '" ' . |
|
134 | + 'data-request-id="' . esc_attr($request_id) . '" ' . |
|
135 | + 'data-nonce="' . esc_attr($nonce) . |
|
136 | 136 | '">'; |
137 | 137 | |
138 | 138 | ?> |
139 | - <span class="remove-personal-data-idle"><button type="button" class="button-link remove-personal-data-handle"><?php _e( 'Erase personal data' ); ?></button></span> |
|
140 | - <span class="remove-personal-data-processing hidden"><?php _e( 'Erasing data...' ); ?> <span class="erasure-progress"></span></span> |
|
141 | - <span class="remove-personal-data-success success-message hidden" ><?php _e( 'Erasure completed.' ); ?></span> |
|
142 | - <span class="remove-personal-data-failed hidden"><?php _e( 'Data erasure has failed.' ); ?> <button type="button" class="button-link remove-personal-data-handle"><?php _e( 'Retry' ); ?></button></span> |
|
139 | + <span class="remove-personal-data-idle"><button type="button" class="button-link remove-personal-data-handle"><?php _e('Erase personal data'); ?></button></span> |
|
140 | + <span class="remove-personal-data-processing hidden"><?php _e('Erasing data...'); ?> <span class="erasure-progress"></span></span> |
|
141 | + <span class="remove-personal-data-success success-message hidden" ><?php _e('Erasure completed.'); ?></span> |
|
142 | + <span class="remove-personal-data-failed hidden"><?php _e('Data erasure has failed.'); ?> <button type="button" class="button-link remove-personal-data-handle"><?php _e('Retry'); ?></button></span> |
|
143 | 143 | <?php |
144 | 144 | |
145 | 145 | echo '</div>'; |
146 | 146 | |
147 | 147 | break; |
148 | 148 | case 'request-failed': |
149 | - echo '<button type="submit" class="button-link" name="privacy_action_email_retry[' . $item->ID . ']" id="privacy_action_email_retry[' . $item->ID . ']">' . __( 'Retry' ) . '</button>'; |
|
149 | + echo '<button type="submit" class="button-link" name="privacy_action_email_retry[' . $item->ID . ']" id="privacy_action_email_retry[' . $item->ID . ']">' . __('Retry') . '</button>'; |
|
150 | 150 | break; |
151 | 151 | case 'request-completed': |
152 | 152 | echo '<a href="' . esc_url( |
@@ -154,13 +154,13 @@ discard block |
||
154 | 154 | add_query_arg( |
155 | 155 | array( |
156 | 156 | 'action' => 'delete', |
157 | - 'request_id' => array( $item->ID ), |
|
157 | + 'request_id' => array($item->ID), |
|
158 | 158 | ), |
159 | - admin_url( 'erase-personal-data.php' ) |
|
159 | + admin_url('erase-personal-data.php') |
|
160 | 160 | ), |
161 | 161 | 'bulk-privacy_requests' |
162 | 162 | ) |
163 | - ) . '">' . esc_html__( 'Remove request' ) . '</a>'; |
|
163 | + ) . '">' . esc_html__('Remove request') . '</a>'; |
|
164 | 164 | break; |
165 | 165 | } |
166 | 166 | } |
@@ -52,16 +52,16 @@ discard block |
||
52 | 52 | * @param callable $admin_header_callback |
53 | 53 | * @param callable $admin_image_div_callback Optional custom image div output callback. |
54 | 54 | */ |
55 | - public function __construct( $admin_header_callback, $admin_image_div_callback = '' ) { |
|
55 | + public function __construct($admin_header_callback, $admin_image_div_callback = '') { |
|
56 | 56 | $this->admin_header_callback = $admin_header_callback; |
57 | 57 | $this->admin_image_div_callback = $admin_image_div_callback; |
58 | 58 | |
59 | - add_action( 'admin_menu', array( $this, 'init' ) ); |
|
59 | + add_action('admin_menu', array($this, 'init')); |
|
60 | 60 | |
61 | - add_action( 'customize_save_after', array( $this, 'customize_set_last_used' ) ); |
|
62 | - add_action( 'wp_ajax_custom-header-crop', array( $this, 'ajax_header_crop' ) ); |
|
63 | - add_action( 'wp_ajax_custom-header-add', array( $this, 'ajax_header_add' ) ); |
|
64 | - add_action( 'wp_ajax_custom-header-remove', array( $this, 'ajax_header_remove' ) ); |
|
61 | + add_action('customize_save_after', array($this, 'customize_set_last_used')); |
|
62 | + add_action('wp_ajax_custom-header-crop', array($this, 'ajax_header_crop')); |
|
63 | + add_action('wp_ajax_custom-header-add', array($this, 'ajax_header_add')); |
|
64 | + add_action('wp_ajax_custom-header-remove', array($this, 'ajax_header_remove')); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -70,20 +70,20 @@ discard block |
||
70 | 70 | * @since 2.1.0 |
71 | 71 | */ |
72 | 72 | public function init() { |
73 | - $page = add_theme_page( __( 'Header' ), __( 'Header' ), 'edit_theme_options', 'custom-header', array( $this, 'admin_page' ) ); |
|
73 | + $page = add_theme_page(__('Header'), __('Header'), 'edit_theme_options', 'custom-header', array($this, 'admin_page')); |
|
74 | 74 | |
75 | - if ( ! $page ) { |
|
75 | + if (!$page) { |
|
76 | 76 | return; |
77 | 77 | } |
78 | 78 | |
79 | - add_action( "admin_print_scripts-{$page}", array( $this, 'js_includes' ) ); |
|
80 | - add_action( "admin_print_styles-{$page}", array( $this, 'css_includes' ) ); |
|
81 | - add_action( "admin_head-{$page}", array( $this, 'help' ) ); |
|
82 | - add_action( "admin_head-{$page}", array( $this, 'take_action' ), 50 ); |
|
83 | - add_action( "admin_head-{$page}", array( $this, 'js' ), 50 ); |
|
79 | + add_action("admin_print_scripts-{$page}", array($this, 'js_includes')); |
|
80 | + add_action("admin_print_styles-{$page}", array($this, 'css_includes')); |
|
81 | + add_action("admin_head-{$page}", array($this, 'help')); |
|
82 | + add_action("admin_head-{$page}", array($this, 'take_action'), 50); |
|
83 | + add_action("admin_head-{$page}", array($this, 'js'), 50); |
|
84 | 84 | |
85 | - if ( $this->admin_header_callback ) { |
|
86 | - add_action( "admin_head-{$page}", $this->admin_header_callback, 51 ); |
|
85 | + if ($this->admin_header_callback) { |
|
86 | + add_action("admin_head-{$page}", $this->admin_header_callback, 51); |
|
87 | 87 | } |
88 | 88 | } |
89 | 89 | |
@@ -96,45 +96,45 @@ discard block |
||
96 | 96 | get_current_screen()->add_help_tab( |
97 | 97 | array( |
98 | 98 | 'id' => 'overview', |
99 | - 'title' => __( 'Overview' ), |
|
99 | + 'title' => __('Overview'), |
|
100 | 100 | 'content' => |
101 | - '<p>' . __( 'This screen is used to customize the header section of your theme.' ) . '</p>' . |
|
102 | - '<p>' . __( 'You can choose from the theme’s default header images, or use one of your own. You can also customize how your Site Title and Tagline are displayed.' ) . '<p>', |
|
101 | + '<p>' . __('This screen is used to customize the header section of your theme.') . '</p>' . |
|
102 | + '<p>' . __('You can choose from the theme’s default header images, or use one of your own. You can also customize how your Site Title and Tagline are displayed.') . '<p>', |
|
103 | 103 | ) |
104 | 104 | ); |
105 | 105 | |
106 | 106 | get_current_screen()->add_help_tab( |
107 | 107 | array( |
108 | 108 | 'id' => 'set-header-image', |
109 | - 'title' => __( 'Header Image' ), |
|
109 | + 'title' => __('Header Image'), |
|
110 | 110 | 'content' => |
111 | - '<p>' . __( 'You can set a custom image header for your site. Simply upload the image and crop it, and the new header will go live immediately. Alternatively, you can use an image that has already been uploaded to your Media Library by clicking the “Choose Image” button.' ) . '</p>' . |
|
112 | - '<p>' . __( 'Some themes come with additional header images bundled. If you see multiple images displayed, select the one you would like and click the “Save Changes” button.' ) . '</p>' . |
|
113 | - '<p>' . __( 'If your theme has more than one default header image, or you have uploaded more than one custom header image, you have the option of having WordPress display a randomly different image on each page of your site. Click the “Random” radio button next to the Uploaded Images or Default Images section to enable this feature.' ) . '</p>' . |
|
114 | - '<p>' . __( 'If you do not want a header image to be displayed on your site at all, click the “Remove Header Image” button at the bottom of the Header Image section of this page. If you want to re-enable the header image later, you just have to select one of the other image options and click “Save Changes”.' ) . '</p>', |
|
111 | + '<p>' . __('You can set a custom image header for your site. Simply upload the image and crop it, and the new header will go live immediately. Alternatively, you can use an image that has already been uploaded to your Media Library by clicking the “Choose Image” button.') . '</p>' . |
|
112 | + '<p>' . __('Some themes come with additional header images bundled. If you see multiple images displayed, select the one you would like and click the “Save Changes” button.') . '</p>' . |
|
113 | + '<p>' . __('If your theme has more than one default header image, or you have uploaded more than one custom header image, you have the option of having WordPress display a randomly different image on each page of your site. Click the “Random” radio button next to the Uploaded Images or Default Images section to enable this feature.') . '</p>' . |
|
114 | + '<p>' . __('If you do not want a header image to be displayed on your site at all, click the “Remove Header Image” button at the bottom of the Header Image section of this page. If you want to re-enable the header image later, you just have to select one of the other image options and click “Save Changes”.') . '</p>', |
|
115 | 115 | ) |
116 | 116 | ); |
117 | 117 | |
118 | 118 | get_current_screen()->add_help_tab( |
119 | 119 | array( |
120 | 120 | 'id' => 'set-header-text', |
121 | - 'title' => __( 'Header Text' ), |
|
121 | + 'title' => __('Header Text'), |
|
122 | 122 | 'content' => |
123 | 123 | '<p>' . sprintf( |
124 | 124 | /* translators: %s: URL to General Settings screen. */ |
125 | - __( 'For most themes, the header text is your Site Title and Tagline, as defined in the <a href="%s">General Settings</a> section.' ), |
|
126 | - admin_url( 'options-general.php' ) |
|
125 | + __('For most themes, the header text is your Site Title and Tagline, as defined in the <a href="%s">General Settings</a> section.'), |
|
126 | + admin_url('options-general.php') |
|
127 | 127 | ) . |
128 | 128 | '</p>' . |
129 | - '<p>' . __( 'In the Header Text section of this page, you can choose whether to display this text or hide it. You can also choose a color for the text by clicking the Select Color button and either typing in a legitimate HTML hex value, e.g. “#ff0000” for red, or by choosing a color using the color picker.' ) . '</p>' . |
|
130 | - '<p>' . __( 'Do not forget to click “Save Changes” when you are done!' ) . '</p>', |
|
129 | + '<p>' . __('In the Header Text section of this page, you can choose whether to display this text or hide it. You can also choose a color for the text by clicking the Select Color button and either typing in a legitimate HTML hex value, e.g. “#ff0000” for red, or by choosing a color using the color picker.') . '</p>' . |
|
130 | + '<p>' . __('Do not forget to click “Save Changes” when you are done!') . '</p>', |
|
131 | 131 | ) |
132 | 132 | ); |
133 | 133 | |
134 | 134 | get_current_screen()->set_help_sidebar( |
135 | - '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
|
136 | - '<p>' . __( '<a href="https://codex.wordpress.org/Appearance_Header_Screen">Documentation on Custom Header</a>' ) . '</p>' . |
|
137 | - '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>' |
|
135 | + '<p><strong>' . __('For more information:') . '</strong></p>' . |
|
136 | + '<p>' . __('<a href="https://codex.wordpress.org/Appearance_Header_Screen">Documentation on Custom Header</a>') . '</p>' . |
|
137 | + '<p>' . __('<a href="https://wordpress.org/support/">Support</a>') . '</p>' |
|
138 | 138 | ); |
139 | 139 | } |
140 | 140 | |
@@ -146,14 +146,14 @@ discard block |
||
146 | 146 | * @return int Current step. |
147 | 147 | */ |
148 | 148 | public function step() { |
149 | - if ( ! isset( $_GET['step'] ) ) { |
|
149 | + if (!isset($_GET['step'])) { |
|
150 | 150 | return 1; |
151 | 151 | } |
152 | 152 | |
153 | 153 | $step = (int) $_GET['step']; |
154 | - if ( $step < 1 || 3 < $step || |
|
155 | - ( 2 === $step && ! wp_verify_nonce( $_REQUEST['_wpnonce-custom-header-upload'], 'custom-header-upload' ) ) || |
|
156 | - ( 3 === $step && ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'custom-header-crop-image' ) ) |
|
154 | + if ($step < 1 || 3 < $step || |
|
155 | + (2 === $step && !wp_verify_nonce($_REQUEST['_wpnonce-custom-header-upload'], 'custom-header-upload')) || |
|
156 | + (3 === $step && !wp_verify_nonce($_REQUEST['_wpnonce'], 'custom-header-crop-image')) |
|
157 | 157 | ) { |
158 | 158 | return 1; |
159 | 159 | } |
@@ -169,14 +169,14 @@ discard block |
||
169 | 169 | public function js_includes() { |
170 | 170 | $step = $this->step(); |
171 | 171 | |
172 | - if ( ( 1 === $step || 3 === $step ) ) { |
|
172 | + if ((1 === $step || 3 === $step)) { |
|
173 | 173 | wp_enqueue_media(); |
174 | - wp_enqueue_script( 'custom-header' ); |
|
175 | - if ( current_theme_supports( 'custom-header', 'header-text' ) ) { |
|
176 | - wp_enqueue_script( 'wp-color-picker' ); |
|
174 | + wp_enqueue_script('custom-header'); |
|
175 | + if (current_theme_supports('custom-header', 'header-text')) { |
|
176 | + wp_enqueue_script('wp-color-picker'); |
|
177 | 177 | } |
178 | - } elseif ( 2 === $step ) { |
|
179 | - wp_enqueue_script( 'imgareaselect' ); |
|
178 | + } elseif (2 === $step) { |
|
179 | + wp_enqueue_script('imgareaselect'); |
|
180 | 180 | } |
181 | 181 | } |
182 | 182 | |
@@ -188,10 +188,10 @@ discard block |
||
188 | 188 | public function css_includes() { |
189 | 189 | $step = $this->step(); |
190 | 190 | |
191 | - if ( ( 1 === $step || 3 === $step ) && current_theme_supports( 'custom-header', 'header-text' ) ) { |
|
192 | - wp_enqueue_style( 'wp-color-picker' ); |
|
193 | - } elseif ( 2 === $step ) { |
|
194 | - wp_enqueue_style( 'imgareaselect' ); |
|
191 | + if ((1 === $step || 3 === $step) && current_theme_supports('custom-header', 'header-text')) { |
|
192 | + wp_enqueue_style('wp-color-picker'); |
|
193 | + } elseif (2 === $step) { |
|
194 | + wp_enqueue_style('imgareaselect'); |
|
195 | 195 | } |
196 | 196 | } |
197 | 197 | |
@@ -201,54 +201,54 @@ discard block |
||
201 | 201 | * @since 2.6.0 |
202 | 202 | */ |
203 | 203 | public function take_action() { |
204 | - if ( ! current_user_can( 'edit_theme_options' ) ) { |
|
204 | + if (!current_user_can('edit_theme_options')) { |
|
205 | 205 | return; |
206 | 206 | } |
207 | 207 | |
208 | - if ( empty( $_POST ) ) { |
|
208 | + if (empty($_POST)) { |
|
209 | 209 | return; |
210 | 210 | } |
211 | 211 | |
212 | 212 | $this->updated = true; |
213 | 213 | |
214 | - if ( isset( $_POST['resetheader'] ) ) { |
|
215 | - check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' ); |
|
214 | + if (isset($_POST['resetheader'])) { |
|
215 | + check_admin_referer('custom-header-options', '_wpnonce-custom-header-options'); |
|
216 | 216 | |
217 | 217 | $this->reset_header_image(); |
218 | 218 | |
219 | 219 | return; |
220 | 220 | } |
221 | 221 | |
222 | - if ( isset( $_POST['removeheader'] ) ) { |
|
223 | - check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' ); |
|
222 | + if (isset($_POST['removeheader'])) { |
|
223 | + check_admin_referer('custom-header-options', '_wpnonce-custom-header-options'); |
|
224 | 224 | |
225 | 225 | $this->remove_header_image(); |
226 | 226 | |
227 | 227 | return; |
228 | 228 | } |
229 | 229 | |
230 | - if ( isset( $_POST['text-color'] ) && ! isset( $_POST['display-header-text'] ) ) { |
|
231 | - check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' ); |
|
230 | + if (isset($_POST['text-color']) && !isset($_POST['display-header-text'])) { |
|
231 | + check_admin_referer('custom-header-options', '_wpnonce-custom-header-options'); |
|
232 | 232 | |
233 | - set_theme_mod( 'header_textcolor', 'blank' ); |
|
234 | - } elseif ( isset( $_POST['text-color'] ) ) { |
|
235 | - check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' ); |
|
233 | + set_theme_mod('header_textcolor', 'blank'); |
|
234 | + } elseif (isset($_POST['text-color'])) { |
|
235 | + check_admin_referer('custom-header-options', '_wpnonce-custom-header-options'); |
|
236 | 236 | |
237 | - $_POST['text-color'] = str_replace( '#', '', $_POST['text-color'] ); |
|
237 | + $_POST['text-color'] = str_replace('#', '', $_POST['text-color']); |
|
238 | 238 | |
239 | - $color = preg_replace( '/[^0-9a-fA-F]/', '', $_POST['text-color'] ); |
|
239 | + $color = preg_replace('/[^0-9a-fA-F]/', '', $_POST['text-color']); |
|
240 | 240 | |
241 | - if ( strlen( $color ) === 6 || strlen( $color ) === 3 ) { |
|
242 | - set_theme_mod( 'header_textcolor', $color ); |
|
243 | - } elseif ( ! $color ) { |
|
244 | - set_theme_mod( 'header_textcolor', 'blank' ); |
|
241 | + if (strlen($color) === 6 || strlen($color) === 3) { |
|
242 | + set_theme_mod('header_textcolor', $color); |
|
243 | + } elseif (!$color) { |
|
244 | + set_theme_mod('header_textcolor', 'blank'); |
|
245 | 245 | } |
246 | 246 | } |
247 | 247 | |
248 | - if ( isset( $_POST['default-header'] ) ) { |
|
249 | - check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' ); |
|
248 | + if (isset($_POST['default-header'])) { |
|
249 | + check_admin_referer('custom-header-options', '_wpnonce-custom-header-options'); |
|
250 | 250 | |
251 | - $this->set_header_image( $_POST['default-header'] ); |
|
251 | + $this->set_header_image($_POST['default-header']); |
|
252 | 252 | |
253 | 253 | return; |
254 | 254 | } |
@@ -264,11 +264,11 @@ discard block |
||
264 | 264 | public function process_default_headers() { |
265 | 265 | global $_wp_default_headers; |
266 | 266 | |
267 | - if ( ! isset( $_wp_default_headers ) ) { |
|
267 | + if (!isset($_wp_default_headers)) { |
|
268 | 268 | return; |
269 | 269 | } |
270 | 270 | |
271 | - if ( ! empty( $this->default_headers ) ) { |
|
271 | + if (!empty($this->default_headers)) { |
|
272 | 272 | return; |
273 | 273 | } |
274 | 274 | |
@@ -276,15 +276,15 @@ discard block |
||
276 | 276 | $template_directory_uri = get_template_directory_uri(); |
277 | 277 | $stylesheet_directory_uri = get_stylesheet_directory_uri(); |
278 | 278 | |
279 | - foreach ( array_keys( $this->default_headers ) as $header ) { |
|
280 | - $this->default_headers[ $header ]['url'] = sprintf( |
|
281 | - $this->default_headers[ $header ]['url'], |
|
279 | + foreach (array_keys($this->default_headers) as $header) { |
|
280 | + $this->default_headers[$header]['url'] = sprintf( |
|
281 | + $this->default_headers[$header]['url'], |
|
282 | 282 | $template_directory_uri, |
283 | 283 | $stylesheet_directory_uri |
284 | 284 | ); |
285 | 285 | |
286 | - $this->default_headers[ $header ]['thumbnail_url'] = sprintf( |
|
287 | - $this->default_headers[ $header ]['thumbnail_url'], |
|
286 | + $this->default_headers[$header]['thumbnail_url'] = sprintf( |
|
287 | + $this->default_headers[$header]['thumbnail_url'], |
|
288 | 288 | $template_directory_uri, |
289 | 289 | $stylesheet_directory_uri |
290 | 290 | ); |
@@ -302,36 +302,36 @@ discard block |
||
302 | 302 | * @param string $type The header type. One of 'default' (for the Uploaded Images control) |
303 | 303 | * or 'uploaded' (for the Uploaded Images control). |
304 | 304 | */ |
305 | - public function show_header_selector( $type = 'default' ) { |
|
306 | - if ( 'default' === $type ) { |
|
305 | + public function show_header_selector($type = 'default') { |
|
306 | + if ('default' === $type) { |
|
307 | 307 | $headers = $this->default_headers; |
308 | 308 | } else { |
309 | 309 | $headers = get_uploaded_header_images(); |
310 | 310 | $type = 'uploaded'; |
311 | 311 | } |
312 | 312 | |
313 | - if ( 1 < count( $headers ) ) { |
|
313 | + if (1 < count($headers)) { |
|
314 | 314 | echo '<div class="random-header">'; |
315 | - echo '<label><input name="default-header" type="radio" value="random-' . $type . '-image"' . checked( is_random_header_image( $type ), true, false ) . ' />'; |
|
316 | - _e( '<strong>Random:</strong> Show a different image on each page.' ); |
|
315 | + echo '<label><input name="default-header" type="radio" value="random-' . $type . '-image"' . checked(is_random_header_image($type), true, false) . ' />'; |
|
316 | + _e('<strong>Random:</strong> Show a different image on each page.'); |
|
317 | 317 | echo '</label>'; |
318 | 318 | echo '</div>'; |
319 | 319 | } |
320 | 320 | |
321 | 321 | echo '<div class="available-headers">'; |
322 | 322 | |
323 | - foreach ( $headers as $header_key => $header ) { |
|
323 | + foreach ($headers as $header_key => $header) { |
|
324 | 324 | $header_thumbnail = $header['thumbnail_url']; |
325 | 325 | $header_url = $header['url']; |
326 | - $header_alt_text = empty( $header['alt_text'] ) ? '' : $header['alt_text']; |
|
326 | + $header_alt_text = empty($header['alt_text']) ? '' : $header['alt_text']; |
|
327 | 327 | |
328 | 328 | echo '<div class="default-header">'; |
329 | - echo '<label><input name="default-header" type="radio" value="' . esc_attr( $header_key ) . '" ' . checked( $header_url, get_theme_mod( 'header_image' ), false ) . ' />'; |
|
329 | + echo '<label><input name="default-header" type="radio" value="' . esc_attr($header_key) . '" ' . checked($header_url, get_theme_mod('header_image'), false) . ' />'; |
|
330 | 330 | $width = ''; |
331 | - if ( ! empty( $header['attachment_id'] ) ) { |
|
331 | + if (!empty($header['attachment_id'])) { |
|
332 | 332 | $width = ' width="230"'; |
333 | 333 | } |
334 | - echo '<img src="' . set_url_scheme( $header_thumbnail ) . '" alt="' . esc_attr( $header_alt_text ) . '"' . $width . ' /></label>'; |
|
334 | + echo '<img src="' . set_url_scheme($header_thumbnail) . '" alt="' . esc_attr($header_alt_text) . '"' . $width . ' /></label>'; |
|
335 | 335 | echo '</div>'; |
336 | 336 | } |
337 | 337 | |
@@ -346,9 +346,9 @@ discard block |
||
346 | 346 | public function js() { |
347 | 347 | $step = $this->step(); |
348 | 348 | |
349 | - if ( ( 1 === $step || 3 === $step ) && current_theme_supports( 'custom-header', 'header-text' ) ) { |
|
349 | + if ((1 === $step || 3 === $step) && current_theme_supports('custom-header', 'header-text')) { |
|
350 | 350 | $this->js_1(); |
351 | - } elseif ( 2 === $step ) { |
|
351 | + } elseif (2 === $step) { |
|
352 | 352 | $this->js_2(); |
353 | 353 | } |
354 | 354 | } |
@@ -360,16 +360,16 @@ discard block |
||
360 | 360 | */ |
361 | 361 | public function js_1() { |
362 | 362 | $default_color = ''; |
363 | - if ( current_theme_supports( 'custom-header', 'default-text-color' ) ) { |
|
364 | - $default_color = get_theme_support( 'custom-header', 'default-text-color' ); |
|
365 | - if ( $default_color && false === strpos( $default_color, '#' ) ) { |
|
363 | + if (current_theme_supports('custom-header', 'default-text-color')) { |
|
364 | + $default_color = get_theme_support('custom-header', 'default-text-color'); |
|
365 | + if ($default_color && false === strpos($default_color, '#')) { |
|
366 | 366 | $default_color = '#' . $default_color; |
367 | 367 | } |
368 | 368 | } |
369 | 369 | ?> |
370 | 370 | <script type="text/javascript"> |
371 | 371 | (function($){ |
372 | - var default_color = '<?php echo esc_js( $default_color ); ?>', |
|
372 | + var default_color = '<?php echo esc_js($default_color); ?>', |
|
373 | 373 | header_text_fields; |
374 | 374 | |
375 | 375 | function pickColor(color) { |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | } |
406 | 406 | }); |
407 | 407 | $('#display-header-text').click( toggle_text ); |
408 | - <?php if ( ! display_header_text() ) : ?> |
|
408 | + <?php if (!display_header_text()) : ?> |
|
409 | 409 | toggle_text(); |
410 | 410 | <?php endif; ?> |
411 | 411 | } ); |
@@ -431,8 +431,8 @@ discard block |
||
431 | 431 | } |
432 | 432 | |
433 | 433 | jQuery( function() { |
434 | - var xinit = <?php echo absint( get_theme_support( 'custom-header', 'width' ) ); ?>; |
|
435 | - var yinit = <?php echo absint( get_theme_support( 'custom-header', 'height' ) ); ?>; |
|
434 | + var xinit = <?php echo absint(get_theme_support('custom-header', 'width')); ?>; |
|
435 | + var yinit = <?php echo absint(get_theme_support('custom-header', 'height')); ?>; |
|
436 | 436 | var ratio = xinit / yinit; |
437 | 437 | var ximg = jQuery('img#upload').width(); |
438 | 438 | var yimg = jQuery('img#upload').height(); |
@@ -456,21 +456,21 @@ discard block |
||
456 | 456 | x2: xinit, |
457 | 457 | y2: yinit, |
458 | 458 | <?php |
459 | - if ( ! current_theme_supports( 'custom-header', 'flex-height' ) |
|
460 | - && ! current_theme_supports( 'custom-header', 'flex-width' ) |
|
459 | + if (!current_theme_supports('custom-header', 'flex-height') |
|
460 | + && !current_theme_supports('custom-header', 'flex-width') |
|
461 | 461 | ) { |
462 | 462 | ?> |
463 | 463 | aspectRatio: xinit + ':' + yinit, |
464 | 464 | <?php |
465 | 465 | } |
466 | - if ( ! current_theme_supports( 'custom-header', 'flex-height' ) ) { |
|
466 | + if (!current_theme_supports('custom-header', 'flex-height')) { |
|
467 | 467 | ?> |
468 | - maxHeight: <?php echo get_theme_support( 'custom-header', 'height' ); ?>, |
|
468 | + maxHeight: <?php echo get_theme_support('custom-header', 'height'); ?>, |
|
469 | 469 | <?php |
470 | 470 | } |
471 | - if ( ! current_theme_supports( 'custom-header', 'flex-width' ) ) { |
|
471 | + if (!current_theme_supports('custom-header', 'flex-width')) { |
|
472 | 472 | ?> |
473 | - maxWidth: <?php echo get_theme_support( 'custom-header', 'width' ); ?>, |
|
473 | + maxWidth: <?php echo get_theme_support('custom-header', 'width'); ?>, |
|
474 | 474 | <?php |
475 | 475 | } |
476 | 476 | ?> |
@@ -500,172 +500,172 @@ discard block |
||
500 | 500 | ?> |
501 | 501 | |
502 | 502 | <div class="wrap"> |
503 | -<h1><?php _e( 'Custom Header' ); ?></h1> |
|
503 | +<h1><?php _e('Custom Header'); ?></h1> |
|
504 | 504 | |
505 | - <?php if ( current_user_can( 'customize' ) ) { ?> |
|
505 | + <?php if (current_user_can('customize')) { ?> |
|
506 | 506 | <div class="notice notice-info hide-if-no-customize"> |
507 | 507 | <p> |
508 | 508 | <?php |
509 | 509 | printf( |
510 | 510 | /* translators: %s: URL to header image configuration in Customizer. */ |
511 | - __( 'You can now manage and live-preview Custom Header in the <a href="%s">Customizer</a>.' ), |
|
512 | - admin_url( 'customize.php?autofocus[control]=header_image' ) |
|
511 | + __('You can now manage and live-preview Custom Header in the <a href="%s">Customizer</a>.'), |
|
512 | + admin_url('customize.php?autofocus[control]=header_image') |
|
513 | 513 | ); |
514 | 514 | ?> |
515 | 515 | </p> |
516 | 516 | </div> |
517 | 517 | <?php } ?> |
518 | 518 | |
519 | - <?php if ( ! empty( $this->updated ) ) { ?> |
|
519 | + <?php if (!empty($this->updated)) { ?> |
|
520 | 520 | <div id="message" class="updated"> |
521 | 521 | <p> |
522 | 522 | <?php |
523 | 523 | /* translators: %s: Home URL. */ |
524 | - printf( __( 'Header updated. <a href="%s">Visit your site</a> to see how it looks.' ), home_url( '/' ) ); |
|
524 | + printf(__('Header updated. <a href="%s">Visit your site</a> to see how it looks.'), home_url('/')); |
|
525 | 525 | ?> |
526 | 526 | </p> |
527 | 527 | </div> |
528 | 528 | <?php } ?> |
529 | 529 | |
530 | -<h2><?php _e( 'Header Image' ); ?></h2> |
|
530 | +<h2><?php _e('Header Image'); ?></h2> |
|
531 | 531 | |
532 | 532 | <table class="form-table" role="presentation"> |
533 | 533 | <tbody> |
534 | 534 | |
535 | - <?php if ( get_custom_header() || display_header_text() ) : ?> |
|
535 | + <?php if (get_custom_header() || display_header_text()) : ?> |
|
536 | 536 | <tr> |
537 | -<th scope="row"><?php _e( 'Preview' ); ?></th> |
|
537 | +<th scope="row"><?php _e('Preview'); ?></th> |
|
538 | 538 | <td> |
539 | 539 | <?php |
540 | - if ( $this->admin_image_div_callback ) { |
|
541 | - call_user_func( $this->admin_image_div_callback ); |
|
540 | + if ($this->admin_image_div_callback) { |
|
541 | + call_user_func($this->admin_image_div_callback); |
|
542 | 542 | } else { |
543 | 543 | $custom_header = get_custom_header(); |
544 | 544 | $header_image = get_header_image(); |
545 | 545 | |
546 | - if ( $header_image ) { |
|
547 | - $header_image_style = 'background-image:url(' . esc_url( $header_image ) . ');'; |
|
546 | + if ($header_image) { |
|
547 | + $header_image_style = 'background-image:url(' . esc_url($header_image) . ');'; |
|
548 | 548 | } else { |
549 | 549 | $header_image_style = ''; |
550 | 550 | } |
551 | 551 | |
552 | - if ( $custom_header->width ) { |
|
552 | + if ($custom_header->width) { |
|
553 | 553 | $header_image_style .= 'max-width:' . $custom_header->width . 'px;'; |
554 | 554 | } |
555 | - if ( $custom_header->height ) { |
|
555 | + if ($custom_header->height) { |
|
556 | 556 | $header_image_style .= 'height:' . $custom_header->height . 'px;'; |
557 | 557 | } |
558 | 558 | ?> |
559 | 559 | <div id="headimg" style="<?php echo $header_image_style; ?>"> |
560 | 560 | <?php |
561 | - if ( display_header_text() ) { |
|
561 | + if (display_header_text()) { |
|
562 | 562 | $style = ' style="color:#' . get_header_textcolor() . ';"'; |
563 | 563 | } else { |
564 | 564 | $style = ' style="display:none;"'; |
565 | 565 | } |
566 | 566 | ?> |
567 | - <h1><a id="name" class="displaying-header-text" <?php echo $style; ?> onclick="return false;" href="<?php bloginfo( 'url' ); ?>" tabindex="-1"><?php bloginfo( 'name' ); ?></a></h1> |
|
568 | - <div id="desc" class="displaying-header-text" <?php echo $style; ?>><?php bloginfo( 'description' ); ?></div> |
|
567 | + <h1><a id="name" class="displaying-header-text" <?php echo $style; ?> onclick="return false;" href="<?php bloginfo('url'); ?>" tabindex="-1"><?php bloginfo('name'); ?></a></h1> |
|
568 | + <div id="desc" class="displaying-header-text" <?php echo $style; ?>><?php bloginfo('description'); ?></div> |
|
569 | 569 | </div> |
570 | 570 | <?php } ?> |
571 | 571 | </td> |
572 | 572 | </tr> |
573 | 573 | <?php endif; ?> |
574 | 574 | |
575 | - <?php if ( current_user_can( 'upload_files' ) && current_theme_supports( 'custom-header', 'uploads' ) ) : ?> |
|
575 | + <?php if (current_user_can('upload_files') && current_theme_supports('custom-header', 'uploads')) : ?> |
|
576 | 576 | <tr> |
577 | -<th scope="row"><?php _e( 'Select Image' ); ?></th> |
|
577 | +<th scope="row"><?php _e('Select Image'); ?></th> |
|
578 | 578 | <td> |
579 | - <p><?php _e( 'You can select an image to be shown at the top of your site by uploading from your computer or choosing from your media library. After selecting an image you will be able to crop it.' ); ?><br /> |
|
579 | + <p><?php _e('You can select an image to be shown at the top of your site by uploading from your computer or choosing from your media library. After selecting an image you will be able to crop it.'); ?><br /> |
|
580 | 580 | <?php |
581 | - if ( ! current_theme_supports( 'custom-header', 'flex-height' ) |
|
582 | - && ! current_theme_supports( 'custom-header', 'flex-width' ) |
|
581 | + if (!current_theme_supports('custom-header', 'flex-height') |
|
582 | + && !current_theme_supports('custom-header', 'flex-width') |
|
583 | 583 | ) { |
584 | 584 | printf( |
585 | 585 | /* translators: 1: Image width in pixels, 2: Image height in pixels. */ |
586 | - __( 'Images of exactly <strong>%1$d × %2$d pixels</strong> will be used as-is.' ) . '<br />', |
|
587 | - get_theme_support( 'custom-header', 'width' ), |
|
588 | - get_theme_support( 'custom-header', 'height' ) |
|
586 | + __('Images of exactly <strong>%1$d × %2$d pixels</strong> will be used as-is.') . '<br />', |
|
587 | + get_theme_support('custom-header', 'width'), |
|
588 | + get_theme_support('custom-header', 'height') |
|
589 | 589 | ); |
590 | - } elseif ( current_theme_supports( 'custom-header', 'flex-height' ) ) { |
|
591 | - if ( ! current_theme_supports( 'custom-header', 'flex-width' ) ) { |
|
590 | + } elseif (current_theme_supports('custom-header', 'flex-height')) { |
|
591 | + if (!current_theme_supports('custom-header', 'flex-width')) { |
|
592 | 592 | printf( |
593 | 593 | /* translators: %s: Size in pixels. */ |
594 | - __( 'Images should be at least %s wide.' ) . ' ', |
|
594 | + __('Images should be at least %s wide.') . ' ', |
|
595 | 595 | sprintf( |
596 | 596 | /* translators: %d: Custom header width. */ |
597 | - '<strong>' . __( '%d pixels' ) . '</strong>', |
|
598 | - get_theme_support( 'custom-header', 'width' ) |
|
597 | + '<strong>' . __('%d pixels') . '</strong>', |
|
598 | + get_theme_support('custom-header', 'width') |
|
599 | 599 | ) |
600 | 600 | ); |
601 | 601 | } |
602 | - } elseif ( current_theme_supports( 'custom-header', 'flex-width' ) ) { |
|
603 | - if ( ! current_theme_supports( 'custom-header', 'flex-height' ) ) { |
|
602 | + } elseif (current_theme_supports('custom-header', 'flex-width')) { |
|
603 | + if (!current_theme_supports('custom-header', 'flex-height')) { |
|
604 | 604 | printf( |
605 | 605 | /* translators: %s: Size in pixels. */ |
606 | - __( 'Images should be at least %s tall.' ) . ' ', |
|
606 | + __('Images should be at least %s tall.') . ' ', |
|
607 | 607 | sprintf( |
608 | 608 | /* translators: %d: Custom header height. */ |
609 | - '<strong>' . __( '%d pixels' ) . '</strong>', |
|
610 | - get_theme_support( 'custom-header', 'height' ) |
|
609 | + '<strong>' . __('%d pixels') . '</strong>', |
|
610 | + get_theme_support('custom-header', 'height') |
|
611 | 611 | ) |
612 | 612 | ); |
613 | 613 | } |
614 | 614 | } |
615 | 615 | |
616 | - if ( current_theme_supports( 'custom-header', 'flex-height' ) |
|
617 | - || current_theme_supports( 'custom-header', 'flex-width' ) |
|
616 | + if (current_theme_supports('custom-header', 'flex-height') |
|
617 | + || current_theme_supports('custom-header', 'flex-width') |
|
618 | 618 | ) { |
619 | - if ( current_theme_supports( 'custom-header', 'width' ) ) { |
|
619 | + if (current_theme_supports('custom-header', 'width')) { |
|
620 | 620 | printf( |
621 | 621 | /* translators: %s: Size in pixels. */ |
622 | - __( 'Suggested width is %s.' ) . ' ', |
|
622 | + __('Suggested width is %s.') . ' ', |
|
623 | 623 | sprintf( |
624 | 624 | /* translators: %d: Custom header width. */ |
625 | - '<strong>' . __( '%d pixels' ) . '</strong>', |
|
626 | - get_theme_support( 'custom-header', 'width' ) |
|
625 | + '<strong>' . __('%d pixels') . '</strong>', |
|
626 | + get_theme_support('custom-header', 'width') |
|
627 | 627 | ) |
628 | 628 | ); |
629 | 629 | } |
630 | 630 | |
631 | - if ( current_theme_supports( 'custom-header', 'height' ) ) { |
|
631 | + if (current_theme_supports('custom-header', 'height')) { |
|
632 | 632 | printf( |
633 | 633 | /* translators: %s: Size in pixels. */ |
634 | - __( 'Suggested height is %s.' ) . ' ', |
|
634 | + __('Suggested height is %s.') . ' ', |
|
635 | 635 | sprintf( |
636 | 636 | /* translators: %d: Custom header height. */ |
637 | - '<strong>' . __( '%d pixels' ) . '</strong>', |
|
638 | - get_theme_support( 'custom-header', 'height' ) |
|
637 | + '<strong>' . __('%d pixels') . '</strong>', |
|
638 | + get_theme_support('custom-header', 'height') |
|
639 | 639 | ) |
640 | 640 | ); |
641 | 641 | } |
642 | 642 | } |
643 | 643 | ?> |
644 | 644 | </p> |
645 | - <form enctype="multipart/form-data" id="upload-form" class="wp-upload-form" method="post" action="<?php echo esc_url( add_query_arg( 'step', 2 ) ); ?>"> |
|
645 | + <form enctype="multipart/form-data" id="upload-form" class="wp-upload-form" method="post" action="<?php echo esc_url(add_query_arg('step', 2)); ?>"> |
|
646 | 646 | <p> |
647 | - <label for="upload"><?php _e( 'Choose an image from your computer:' ); ?></label><br /> |
|
647 | + <label for="upload"><?php _e('Choose an image from your computer:'); ?></label><br /> |
|
648 | 648 | <input type="file" id="upload" name="import" /> |
649 | 649 | <input type="hidden" name="action" value="save" /> |
650 | - <?php wp_nonce_field( 'custom-header-upload', '_wpnonce-custom-header-upload' ); ?> |
|
651 | - <?php submit_button( __( 'Upload' ), '', 'submit', false ); ?> |
|
650 | + <?php wp_nonce_field('custom-header-upload', '_wpnonce-custom-header-upload'); ?> |
|
651 | + <?php submit_button(__('Upload'), '', 'submit', false); ?> |
|
652 | 652 | </p> |
653 | 653 | <?php |
654 | 654 | $modal_update_href = add_query_arg( |
655 | 655 | array( |
656 | 656 | 'page' => 'custom-header', |
657 | 657 | 'step' => 2, |
658 | - '_wpnonce-custom-header-upload' => wp_create_nonce( 'custom-header-upload' ), |
|
658 | + '_wpnonce-custom-header-upload' => wp_create_nonce('custom-header-upload'), |
|
659 | 659 | ), |
660 | - admin_url( 'themes.php' ) |
|
660 | + admin_url('themes.php') |
|
661 | 661 | ); |
662 | 662 | ?> |
663 | 663 | <p> |
664 | - <label for="choose-from-library-link"><?php _e( 'Or choose an image from your media library:' ); ?></label><br /> |
|
664 | + <label for="choose-from-library-link"><?php _e('Or choose an image from your media library:'); ?></label><br /> |
|
665 | 665 | <button id="choose-from-library-link" class="button" |
666 | - data-update-link="<?php echo esc_url( $modal_update_href ); ?>" |
|
667 | - data-choose="<?php esc_attr_e( 'Choose a Custom Header' ); ?>" |
|
668 | - data-update="<?php esc_attr_e( 'Set as header' ); ?>"><?php _e( 'Choose Image' ); ?></button> |
|
666 | + data-update-link="<?php echo esc_url($modal_update_href); ?>" |
|
667 | + data-choose="<?php esc_attr_e('Choose a Custom Header'); ?>" |
|
668 | + data-update="<?php esc_attr_e('Set as header'); ?>"><?php _e('Choose Image'); ?></button> |
|
669 | 669 | </p> |
670 | 670 | </form> |
671 | 671 | </td> |
@@ -674,109 +674,109 @@ discard block |
||
674 | 674 | </tbody> |
675 | 675 | </table> |
676 | 676 | |
677 | -<form method="post" action="<?php echo esc_url( add_query_arg( 'step', 1 ) ); ?>"> |
|
678 | - <?php submit_button( null, 'screen-reader-text', 'save-header-options', false ); ?> |
|
677 | +<form method="post" action="<?php echo esc_url(add_query_arg('step', 1)); ?>"> |
|
678 | + <?php submit_button(null, 'screen-reader-text', 'save-header-options', false); ?> |
|
679 | 679 | <table class="form-table" role="presentation"> |
680 | 680 | <tbody> |
681 | - <?php if ( get_uploaded_header_images() ) : ?> |
|
681 | + <?php if (get_uploaded_header_images()) : ?> |
|
682 | 682 | <tr> |
683 | -<th scope="row"><?php _e( 'Uploaded Images' ); ?></th> |
|
683 | +<th scope="row"><?php _e('Uploaded Images'); ?></th> |
|
684 | 684 | <td> |
685 | - <p><?php _e( 'You can choose one of your previously uploaded headers, or show a random one.' ); ?></p> |
|
685 | + <p><?php _e('You can choose one of your previously uploaded headers, or show a random one.'); ?></p> |
|
686 | 686 | <?php |
687 | - $this->show_header_selector( 'uploaded' ); |
|
687 | + $this->show_header_selector('uploaded'); |
|
688 | 688 | ?> |
689 | 689 | </td> |
690 | 690 | </tr> |
691 | 691 | <?php |
692 | 692 | endif; |
693 | - if ( ! empty( $this->default_headers ) ) : |
|
693 | + if (!empty($this->default_headers)) : |
|
694 | 694 | ?> |
695 | 695 | <tr> |
696 | -<th scope="row"><?php _e( 'Default Images' ); ?></th> |
|
696 | +<th scope="row"><?php _e('Default Images'); ?></th> |
|
697 | 697 | <td> |
698 | - <?php if ( current_theme_supports( 'custom-header', 'uploads' ) ) : ?> |
|
699 | - <p><?php _e( 'If you don‘t want to upload your own image, you can use one of these cool headers, or show a random one.' ); ?></p> |
|
698 | + <?php if (current_theme_supports('custom-header', 'uploads')) : ?> |
|
699 | + <p><?php _e('If you don‘t want to upload your own image, you can use one of these cool headers, or show a random one.'); ?></p> |
|
700 | 700 | <?php else : ?> |
701 | - <p><?php _e( 'You can use one of these cool headers or show a random one on each page.' ); ?></p> |
|
701 | + <p><?php _e('You can use one of these cool headers or show a random one on each page.'); ?></p> |
|
702 | 702 | <?php endif; ?> |
703 | 703 | <?php |
704 | - $this->show_header_selector( 'default' ); |
|
704 | + $this->show_header_selector('default'); |
|
705 | 705 | ?> |
706 | 706 | </td> |
707 | 707 | </tr> |
708 | 708 | <?php |
709 | 709 | endif; |
710 | - if ( get_header_image() ) : |
|
710 | + if (get_header_image()) : |
|
711 | 711 | ?> |
712 | 712 | <tr> |
713 | -<th scope="row"><?php _e( 'Remove Image' ); ?></th> |
|
713 | +<th scope="row"><?php _e('Remove Image'); ?></th> |
|
714 | 714 | <td> |
715 | - <p><?php _e( 'This will remove the header image. You will not be able to restore any customizations.' ); ?></p> |
|
716 | - <?php submit_button( __( 'Remove Header Image' ), '', 'removeheader', false ); ?> |
|
715 | + <p><?php _e('This will remove the header image. You will not be able to restore any customizations.'); ?></p> |
|
716 | + <?php submit_button(__('Remove Header Image'), '', 'removeheader', false); ?> |
|
717 | 717 | </td> |
718 | 718 | </tr> |
719 | 719 | <?php |
720 | 720 | endif; |
721 | 721 | |
722 | 722 | $default_image = sprintf( |
723 | - get_theme_support( 'custom-header', 'default-image' ), |
|
723 | + get_theme_support('custom-header', 'default-image'), |
|
724 | 724 | get_template_directory_uri(), |
725 | 725 | get_stylesheet_directory_uri() |
726 | 726 | ); |
727 | 727 | |
728 | - if ( $default_image && get_header_image() !== $default_image ) : |
|
728 | + if ($default_image && get_header_image() !== $default_image) : |
|
729 | 729 | ?> |
730 | 730 | <tr> |
731 | -<th scope="row"><?php _e( 'Reset Image' ); ?></th> |
|
731 | +<th scope="row"><?php _e('Reset Image'); ?></th> |
|
732 | 732 | <td> |
733 | - <p><?php _e( 'This will restore the original header image. You will not be able to restore any customizations.' ); ?></p> |
|
734 | - <?php submit_button( __( 'Restore Original Header Image' ), '', 'resetheader', false ); ?> |
|
733 | + <p><?php _e('This will restore the original header image. You will not be able to restore any customizations.'); ?></p> |
|
734 | + <?php submit_button(__('Restore Original Header Image'), '', 'resetheader', false); ?> |
|
735 | 735 | </td> |
736 | 736 | </tr> |
737 | 737 | <?php endif; ?> |
738 | 738 | </tbody> |
739 | 739 | </table> |
740 | 740 | |
741 | - <?php if ( current_theme_supports( 'custom-header', 'header-text' ) ) : ?> |
|
741 | + <?php if (current_theme_supports('custom-header', 'header-text')) : ?> |
|
742 | 742 | |
743 | -<h2><?php _e( 'Header Text' ); ?></h2> |
|
743 | +<h2><?php _e('Header Text'); ?></h2> |
|
744 | 744 | |
745 | 745 | <table class="form-table" role="presentation"> |
746 | 746 | <tbody> |
747 | 747 | <tr> |
748 | -<th scope="row"><?php _e( 'Header Text' ); ?></th> |
|
748 | +<th scope="row"><?php _e('Header Text'); ?></th> |
|
749 | 749 | <td> |
750 | 750 | <p> |
751 | - <label><input type="checkbox" name="display-header-text" id="display-header-text"<?php checked( display_header_text() ); ?> /> <?php _e( 'Show header text with your image.' ); ?></label> |
|
751 | + <label><input type="checkbox" name="display-header-text" id="display-header-text"<?php checked(display_header_text()); ?> /> <?php _e('Show header text with your image.'); ?></label> |
|
752 | 752 | </p> |
753 | 753 | </td> |
754 | 754 | </tr> |
755 | 755 | |
756 | 756 | <tr class="displaying-header-text"> |
757 | -<th scope="row"><?php _e( 'Text Color' ); ?></th> |
|
757 | +<th scope="row"><?php _e('Text Color'); ?></th> |
|
758 | 758 | <td> |
759 | 759 | <p> |
760 | 760 | <?php |
761 | 761 | $default_color = ''; |
762 | - if ( current_theme_supports( 'custom-header', 'default-text-color' ) ) { |
|
763 | - $default_color = get_theme_support( 'custom-header', 'default-text-color' ); |
|
764 | - if ( $default_color && false === strpos( $default_color, '#' ) ) { |
|
762 | + if (current_theme_supports('custom-header', 'default-text-color')) { |
|
763 | + $default_color = get_theme_support('custom-header', 'default-text-color'); |
|
764 | + if ($default_color && false === strpos($default_color, '#')) { |
|
765 | 765 | $default_color = '#' . $default_color; |
766 | 766 | } |
767 | 767 | } |
768 | 768 | |
769 | - $default_color_attr = $default_color ? ' data-default-color="' . esc_attr( $default_color ) . '"' : ''; |
|
769 | + $default_color_attr = $default_color ? ' data-default-color="' . esc_attr($default_color) . '"' : ''; |
|
770 | 770 | |
771 | - $header_textcolor = display_header_text() ? get_header_textcolor() : get_theme_support( 'custom-header', 'default-text-color' ); |
|
772 | - if ( $header_textcolor && false === strpos( $header_textcolor, '#' ) ) { |
|
771 | + $header_textcolor = display_header_text() ? get_header_textcolor() : get_theme_support('custom-header', 'default-text-color'); |
|
772 | + if ($header_textcolor && false === strpos($header_textcolor, '#')) { |
|
773 | 773 | $header_textcolor = '#' . $header_textcolor; |
774 | 774 | } |
775 | 775 | |
776 | - echo '<input type="text" name="text-color" id="text-color" value="' . esc_attr( $header_textcolor ) . '"' . $default_color_attr . ' />'; |
|
777 | - if ( $default_color ) { |
|
776 | + echo '<input type="text" name="text-color" id="text-color" value="' . esc_attr($header_textcolor) . '"' . $default_color_attr . ' />'; |
|
777 | + if ($default_color) { |
|
778 | 778 | /* translators: %s: Default text color. */ |
779 | - echo ' <span class="description hide-if-js">' . sprintf( _x( 'Default: %s', 'color' ), esc_html( $default_color ) ) . '</span>'; |
|
779 | + echo ' <span class="description hide-if-js">' . sprintf(_x('Default: %s', 'color'), esc_html($default_color)) . '</span>'; |
|
780 | 780 | } |
781 | 781 | ?> |
782 | 782 | </p> |
@@ -792,12 +792,12 @@ discard block |
||
792 | 792 | * |
793 | 793 | * @since 3.1.0 |
794 | 794 | */ |
795 | - do_action( 'custom_header_options' ); |
|
795 | + do_action('custom_header_options'); |
|
796 | 796 | |
797 | - wp_nonce_field( 'custom-header-options', '_wpnonce-custom-header-options' ); |
|
797 | + wp_nonce_field('custom-header-options', '_wpnonce-custom-header-options'); |
|
798 | 798 | ?> |
799 | 799 | |
800 | - <?php submit_button( null, 'primary', 'save-header-options' ); ?> |
|
800 | + <?php submit_button(null, 'primary', 'save-header-options'); ?> |
|
801 | 801 | </form> |
802 | 802 | </div> |
803 | 803 | |
@@ -810,62 +810,62 @@ discard block |
||
810 | 810 | * @since 2.1.0 |
811 | 811 | */ |
812 | 812 | public function step_2() { |
813 | - check_admin_referer( 'custom-header-upload', '_wpnonce-custom-header-upload' ); |
|
813 | + check_admin_referer('custom-header-upload', '_wpnonce-custom-header-upload'); |
|
814 | 814 | |
815 | - if ( ! current_theme_supports( 'custom-header', 'uploads' ) ) { |
|
815 | + if (!current_theme_supports('custom-header', 'uploads')) { |
|
816 | 816 | wp_die( |
817 | - '<h1>' . __( 'Something went wrong.' ) . '</h1>' . |
|
818 | - '<p>' . __( 'The active theme does not support uploading a custom header image.' ) . '</p>', |
|
817 | + '<h1>' . __('Something went wrong.') . '</h1>' . |
|
818 | + '<p>' . __('The active theme does not support uploading a custom header image.') . '</p>', |
|
819 | 819 | 403 |
820 | 820 | ); |
821 | 821 | } |
822 | 822 | |
823 | - if ( empty( $_POST ) && isset( $_GET['file'] ) ) { |
|
824 | - $attachment_id = absint( $_GET['file'] ); |
|
825 | - $file = get_attached_file( $attachment_id, true ); |
|
826 | - $url = wp_get_attachment_image_src( $attachment_id, 'full' ); |
|
823 | + if (empty($_POST) && isset($_GET['file'])) { |
|
824 | + $attachment_id = absint($_GET['file']); |
|
825 | + $file = get_attached_file($attachment_id, true); |
|
826 | + $url = wp_get_attachment_image_src($attachment_id, 'full'); |
|
827 | 827 | $url = $url[0]; |
828 | - } elseif ( isset( $_POST ) ) { |
|
828 | + } elseif (isset($_POST)) { |
|
829 | 829 | $data = $this->step_2_manage_upload(); |
830 | 830 | $attachment_id = $data['attachment_id']; |
831 | 831 | $file = $data['file']; |
832 | 832 | $url = $data['url']; |
833 | 833 | } |
834 | 834 | |
835 | - if ( file_exists( $file ) ) { |
|
836 | - list( $width, $height, $type, $attr ) = wp_getimagesize( $file ); |
|
835 | + if (file_exists($file)) { |
|
836 | + list($width, $height, $type, $attr) = wp_getimagesize($file); |
|
837 | 837 | } else { |
838 | - $data = wp_get_attachment_metadata( $attachment_id ); |
|
839 | - $height = isset( $data['height'] ) ? (int) $data['height'] : 0; |
|
840 | - $width = isset( $data['width'] ) ? (int) $data['width'] : 0; |
|
841 | - unset( $data ); |
|
838 | + $data = wp_get_attachment_metadata($attachment_id); |
|
839 | + $height = isset($data['height']) ? (int) $data['height'] : 0; |
|
840 | + $width = isset($data['width']) ? (int) $data['width'] : 0; |
|
841 | + unset($data); |
|
842 | 842 | } |
843 | 843 | |
844 | 844 | $max_width = 0; |
845 | 845 | |
846 | 846 | // For flex, limit size of image displayed to 1500px unless theme says otherwise. |
847 | - if ( current_theme_supports( 'custom-header', 'flex-width' ) ) { |
|
847 | + if (current_theme_supports('custom-header', 'flex-width')) { |
|
848 | 848 | $max_width = 1500; |
849 | 849 | } |
850 | 850 | |
851 | - if ( current_theme_supports( 'custom-header', 'max-width' ) ) { |
|
852 | - $max_width = max( $max_width, get_theme_support( 'custom-header', 'max-width' ) ); |
|
851 | + if (current_theme_supports('custom-header', 'max-width')) { |
|
852 | + $max_width = max($max_width, get_theme_support('custom-header', 'max-width')); |
|
853 | 853 | } |
854 | 854 | |
855 | - $max_width = max( $max_width, get_theme_support( 'custom-header', 'width' ) ); |
|
855 | + $max_width = max($max_width, get_theme_support('custom-header', 'width')); |
|
856 | 856 | |
857 | 857 | // If flexible height isn't supported and the image is the exact right size. |
858 | - if ( ! current_theme_supports( 'custom-header', 'flex-height' ) |
|
859 | - && ! current_theme_supports( 'custom-header', 'flex-width' ) |
|
860 | - && (int) get_theme_support( 'custom-header', 'width' ) === $width |
|
861 | - && (int) get_theme_support( 'custom-header', 'height' ) === $height |
|
858 | + if (!current_theme_supports('custom-header', 'flex-height') |
|
859 | + && !current_theme_supports('custom-header', 'flex-width') |
|
860 | + && (int) get_theme_support('custom-header', 'width') === $width |
|
861 | + && (int) get_theme_support('custom-header', 'height') === $height |
|
862 | 862 | ) { |
863 | 863 | // Add the metadata. |
864 | - if ( file_exists( $file ) ) { |
|
865 | - wp_update_attachment_metadata( $attachment_id, wp_generate_attachment_metadata( $attachment_id, $file ) ); |
|
864 | + if (file_exists($file)) { |
|
865 | + wp_update_attachment_metadata($attachment_id, wp_generate_attachment_metadata($attachment_id, $file)); |
|
866 | 866 | } |
867 | 867 | |
868 | - $this->set_header_image( compact( 'url', 'attachment_id', 'width', 'height' ) ); |
|
868 | + $this->set_header_image(compact('url', 'attachment_id', 'width', 'height')); |
|
869 | 869 | |
870 | 870 | /** |
871 | 871 | * Fires after the header image is set or an error is returned. |
@@ -875,10 +875,10 @@ discard block |
||
875 | 875 | * @param string $file Path to the file. |
876 | 876 | * @param int $attachment_id Attachment ID. |
877 | 877 | */ |
878 | - do_action( 'wp_create_file_in_uploads', $file, $attachment_id ); // For replication. |
|
878 | + do_action('wp_create_file_in_uploads', $file, $attachment_id); // For replication. |
|
879 | 879 | |
880 | 880 | return $this->finished(); |
881 | - } elseif ( $width > $max_width ) { |
|
881 | + } elseif ($width > $max_width) { |
|
882 | 882 | $oitar = $width / $max_width; |
883 | 883 | |
884 | 884 | $image = wp_crop_image( |
@@ -890,17 +890,17 @@ discard block |
||
890 | 890 | $max_width, |
891 | 891 | $height / $oitar, |
892 | 892 | false, |
893 | - str_replace( wp_basename( $file ), 'midsize-' . wp_basename( $file ), $file ) |
|
893 | + str_replace(wp_basename($file), 'midsize-' . wp_basename($file), $file) |
|
894 | 894 | ); |
895 | 895 | |
896 | - if ( ! $image || is_wp_error( $image ) ) { |
|
897 | - wp_die( __( 'Image could not be processed. Please go back and try again.' ), __( 'Image Processing Error' ) ); |
|
896 | + if (!$image || is_wp_error($image)) { |
|
897 | + wp_die(__('Image could not be processed. Please go back and try again.'), __('Image Processing Error')); |
|
898 | 898 | } |
899 | 899 | |
900 | 900 | /** This filter is documented in wp-admin/includes/class-custom-image-header.php */ |
901 | - $image = apply_filters( 'wp_create_file_in_uploads', $image, $attachment_id ); // For replication. |
|
901 | + $image = apply_filters('wp_create_file_in_uploads', $image, $attachment_id); // For replication. |
|
902 | 902 | |
903 | - $url = str_replace( wp_basename( $url ), wp_basename( $image ), $url ); |
|
903 | + $url = str_replace(wp_basename($url), wp_basename($image), $url); |
|
904 | 904 | $width = $width / $oitar; |
905 | 905 | $height = $height / $oitar; |
906 | 906 | } else { |
@@ -909,35 +909,35 @@ discard block |
||
909 | 909 | ?> |
910 | 910 | |
911 | 911 | <div class="wrap"> |
912 | -<h1><?php _e( 'Crop Header Image' ); ?></h1> |
|
912 | +<h1><?php _e('Crop Header Image'); ?></h1> |
|
913 | 913 | |
914 | -<form method="post" action="<?php echo esc_url( add_query_arg( 'step', 3 ) ); ?>"> |
|
915 | - <p class="hide-if-no-js"><?php _e( 'Choose the part of the image you want to use as your header.' ); ?></p> |
|
916 | - <p class="hide-if-js"><strong><?php _e( 'You need JavaScript to choose a part of the image.' ); ?></strong></p> |
|
914 | +<form method="post" action="<?php echo esc_url(add_query_arg('step', 3)); ?>"> |
|
915 | + <p class="hide-if-no-js"><?php _e('Choose the part of the image you want to use as your header.'); ?></p> |
|
916 | + <p class="hide-if-js"><strong><?php _e('You need JavaScript to choose a part of the image.'); ?></strong></p> |
|
917 | 917 | |
918 | 918 | <div id="crop_image" style="position: relative"> |
919 | - <img src="<?php echo esc_url( $url ); ?>" id="upload" width="<?php echo $width; ?>" height="<?php echo $height; ?>" alt="" /> |
|
919 | + <img src="<?php echo esc_url($url); ?>" id="upload" width="<?php echo $width; ?>" height="<?php echo $height; ?>" alt="" /> |
|
920 | 920 | </div> |
921 | 921 | |
922 | 922 | <input type="hidden" name="x1" id="x1" value="0" /> |
923 | 923 | <input type="hidden" name="y1" id="y1" value="0" /> |
924 | - <input type="hidden" name="width" id="width" value="<?php echo esc_attr( $width ); ?>" /> |
|
925 | - <input type="hidden" name="height" id="height" value="<?php echo esc_attr( $height ); ?>" /> |
|
926 | - <input type="hidden" name="attachment_id" id="attachment_id" value="<?php echo esc_attr( $attachment_id ); ?>" /> |
|
927 | - <input type="hidden" name="oitar" id="oitar" value="<?php echo esc_attr( $oitar ); ?>" /> |
|
928 | - <?php if ( empty( $_POST ) && isset( $_GET['file'] ) ) { ?> |
|
924 | + <input type="hidden" name="width" id="width" value="<?php echo esc_attr($width); ?>" /> |
|
925 | + <input type="hidden" name="height" id="height" value="<?php echo esc_attr($height); ?>" /> |
|
926 | + <input type="hidden" name="attachment_id" id="attachment_id" value="<?php echo esc_attr($attachment_id); ?>" /> |
|
927 | + <input type="hidden" name="oitar" id="oitar" value="<?php echo esc_attr($oitar); ?>" /> |
|
928 | + <?php if (empty($_POST) && isset($_GET['file'])) { ?> |
|
929 | 929 | <input type="hidden" name="create-new-attachment" value="true" /> |
930 | 930 | <?php } ?> |
931 | - <?php wp_nonce_field( 'custom-header-crop-image' ); ?> |
|
931 | + <?php wp_nonce_field('custom-header-crop-image'); ?> |
|
932 | 932 | |
933 | 933 | <p class="submit"> |
934 | - <?php submit_button( __( 'Crop and Publish' ), 'primary', 'submit', false ); ?> |
|
934 | + <?php submit_button(__('Crop and Publish'), 'primary', 'submit', false); ?> |
|
935 | 935 | <?php |
936 | - if ( isset( $oitar ) && 1 === $oitar |
|
937 | - && ( current_theme_supports( 'custom-header', 'flex-height' ) |
|
938 | - || current_theme_supports( 'custom-header', 'flex-width' ) ) |
|
936 | + if (isset($oitar) && 1 === $oitar |
|
937 | + && (current_theme_supports('custom-header', 'flex-height') |
|
938 | + || current_theme_supports('custom-header', 'flex-width')) |
|
939 | 939 | ) { |
940 | - submit_button( __( 'Skip Cropping, Publish Image as Is' ), '', 'skip-cropping', false ); |
|
940 | + submit_button(__('Skip Cropping, Publish Image as Is'), '', 'skip-cropping', false); |
|
941 | 941 | } |
942 | 942 | ?> |
943 | 943 | </p> |
@@ -953,25 +953,25 @@ discard block |
||
953 | 953 | * @since 3.4.0 |
954 | 954 | */ |
955 | 955 | public function step_2_manage_upload() { |
956 | - $overrides = array( 'test_form' => false ); |
|
956 | + $overrides = array('test_form' => false); |
|
957 | 957 | |
958 | 958 | $uploaded_file = $_FILES['import']; |
959 | - $wp_filetype = wp_check_filetype_and_ext( $uploaded_file['tmp_name'], $uploaded_file['name'] ); |
|
959 | + $wp_filetype = wp_check_filetype_and_ext($uploaded_file['tmp_name'], $uploaded_file['name']); |
|
960 | 960 | |
961 | - if ( ! wp_match_mime_types( 'image', $wp_filetype['type'] ) ) { |
|
962 | - wp_die( __( 'The uploaded file is not a valid image. Please try again.' ) ); |
|
961 | + if (!wp_match_mime_types('image', $wp_filetype['type'])) { |
|
962 | + wp_die(__('The uploaded file is not a valid image. Please try again.')); |
|
963 | 963 | } |
964 | 964 | |
965 | - $file = wp_handle_upload( $uploaded_file, $overrides ); |
|
965 | + $file = wp_handle_upload($uploaded_file, $overrides); |
|
966 | 966 | |
967 | - if ( isset( $file['error'] ) ) { |
|
968 | - wp_die( $file['error'], __( 'Image Upload Error' ) ); |
|
967 | + if (isset($file['error'])) { |
|
968 | + wp_die($file['error'], __('Image Upload Error')); |
|
969 | 969 | } |
970 | 970 | |
971 | 971 | $url = $file['url']; |
972 | 972 | $type = $file['type']; |
973 | 973 | $file = $file['file']; |
974 | - $filename = wp_basename( $file ); |
|
974 | + $filename = wp_basename($file); |
|
975 | 975 | |
976 | 976 | // Construct the attachment array. |
977 | 977 | $attachment = array( |
@@ -983,9 +983,9 @@ discard block |
||
983 | 983 | ); |
984 | 984 | |
985 | 985 | // Save the data. |
986 | - $attachment_id = wp_insert_attachment( $attachment, $file ); |
|
986 | + $attachment_id = wp_insert_attachment($attachment, $file); |
|
987 | 987 | |
988 | - return compact( 'attachment_id', 'file', 'filename', 'url', 'type' ); |
|
988 | + return compact('attachment_id', 'file', 'filename', 'url', 'type'); |
|
989 | 989 | } |
990 | 990 | |
991 | 991 | /** |
@@ -996,36 +996,36 @@ discard block |
||
996 | 996 | * for retrieving the header image URL. |
997 | 997 | */ |
998 | 998 | public function step_3() { |
999 | - check_admin_referer( 'custom-header-crop-image' ); |
|
999 | + check_admin_referer('custom-header-crop-image'); |
|
1000 | 1000 | |
1001 | - if ( ! current_theme_supports( 'custom-header', 'uploads' ) ) { |
|
1001 | + if (!current_theme_supports('custom-header', 'uploads')) { |
|
1002 | 1002 | wp_die( |
1003 | - '<h1>' . __( 'Something went wrong.' ) . '</h1>' . |
|
1004 | - '<p>' . __( 'The active theme does not support uploading a custom header image.' ) . '</p>', |
|
1003 | + '<h1>' . __('Something went wrong.') . '</h1>' . |
|
1004 | + '<p>' . __('The active theme does not support uploading a custom header image.') . '</p>', |
|
1005 | 1005 | 403 |
1006 | 1006 | ); |
1007 | 1007 | } |
1008 | 1008 | |
1009 | - if ( ! empty( $_POST['skip-cropping'] ) |
|
1010 | - && ! current_theme_supports( 'custom-header', 'flex-height' ) |
|
1011 | - && ! current_theme_supports( 'custom-header', 'flex-width' ) |
|
1009 | + if (!empty($_POST['skip-cropping']) |
|
1010 | + && !current_theme_supports('custom-header', 'flex-height') |
|
1011 | + && !current_theme_supports('custom-header', 'flex-width') |
|
1012 | 1012 | ) { |
1013 | 1013 | wp_die( |
1014 | - '<h1>' . __( 'Something went wrong.' ) . '</h1>' . |
|
1015 | - '<p>' . __( 'The active theme does not support a flexible sized header image.' ) . '</p>', |
|
1014 | + '<h1>' . __('Something went wrong.') . '</h1>' . |
|
1015 | + '<p>' . __('The active theme does not support a flexible sized header image.') . '</p>', |
|
1016 | 1016 | 403 |
1017 | 1017 | ); |
1018 | 1018 | } |
1019 | 1019 | |
1020 | - if ( $_POST['oitar'] > 1 ) { |
|
1020 | + if ($_POST['oitar'] > 1) { |
|
1021 | 1021 | $_POST['x1'] = $_POST['x1'] * $_POST['oitar']; |
1022 | 1022 | $_POST['y1'] = $_POST['y1'] * $_POST['oitar']; |
1023 | 1023 | $_POST['width'] = $_POST['width'] * $_POST['oitar']; |
1024 | 1024 | $_POST['height'] = $_POST['height'] * $_POST['oitar']; |
1025 | 1025 | } |
1026 | 1026 | |
1027 | - $attachment_id = absint( $_POST['attachment_id'] ); |
|
1028 | - $original = get_attached_file( $attachment_id ); |
|
1027 | + $attachment_id = absint($_POST['attachment_id']); |
|
1028 | + $original = get_attached_file($attachment_id); |
|
1029 | 1029 | |
1030 | 1030 | $dimensions = $this->get_header_dimensions( |
1031 | 1031 | array( |
@@ -1036,7 +1036,7 @@ discard block |
||
1036 | 1036 | $height = $dimensions['dst_height']; |
1037 | 1037 | $width = $dimensions['dst_width']; |
1038 | 1038 | |
1039 | - if ( empty( $_POST['skip-cropping'] ) ) { |
|
1039 | + if (empty($_POST['skip-cropping'])) { |
|
1040 | 1040 | $cropped = wp_crop_image( |
1041 | 1041 | $attachment_id, |
1042 | 1042 | (int) $_POST['x1'], |
@@ -1046,39 +1046,39 @@ discard block |
||
1046 | 1046 | $width, |
1047 | 1047 | $height |
1048 | 1048 | ); |
1049 | - } elseif ( ! empty( $_POST['create-new-attachment'] ) ) { |
|
1050 | - $cropped = _copy_image_file( $attachment_id ); |
|
1049 | + } elseif (!empty($_POST['create-new-attachment'])) { |
|
1050 | + $cropped = _copy_image_file($attachment_id); |
|
1051 | 1051 | } else { |
1052 | - $cropped = get_attached_file( $attachment_id ); |
|
1052 | + $cropped = get_attached_file($attachment_id); |
|
1053 | 1053 | } |
1054 | 1054 | |
1055 | - if ( ! $cropped || is_wp_error( $cropped ) ) { |
|
1056 | - wp_die( __( 'Image could not be processed. Please go back and try again.' ), __( 'Image Processing Error' ) ); |
|
1055 | + if (!$cropped || is_wp_error($cropped)) { |
|
1056 | + wp_die(__('Image could not be processed. Please go back and try again.'), __('Image Processing Error')); |
|
1057 | 1057 | } |
1058 | 1058 | |
1059 | 1059 | /** This filter is documented in wp-admin/includes/class-custom-image-header.php */ |
1060 | - $cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication. |
|
1060 | + $cropped = apply_filters('wp_create_file_in_uploads', $cropped, $attachment_id); // For replication. |
|
1061 | 1061 | |
1062 | - $attachment = $this->create_attachment_object( $cropped, $attachment_id ); |
|
1062 | + $attachment = $this->create_attachment_object($cropped, $attachment_id); |
|
1063 | 1063 | |
1064 | - if ( ! empty( $_POST['create-new-attachment'] ) ) { |
|
1065 | - unset( $attachment['ID'] ); |
|
1064 | + if (!empty($_POST['create-new-attachment'])) { |
|
1065 | + unset($attachment['ID']); |
|
1066 | 1066 | } |
1067 | 1067 | |
1068 | 1068 | // Update the attachment. |
1069 | - $attachment_id = $this->insert_attachment( $attachment, $cropped ); |
|
1069 | + $attachment_id = $this->insert_attachment($attachment, $cropped); |
|
1070 | 1070 | |
1071 | - $url = wp_get_attachment_url( $attachment_id ); |
|
1072 | - $this->set_header_image( compact( 'url', 'attachment_id', 'width', 'height' ) ); |
|
1071 | + $url = wp_get_attachment_url($attachment_id); |
|
1072 | + $this->set_header_image(compact('url', 'attachment_id', 'width', 'height')); |
|
1073 | 1073 | |
1074 | 1074 | // Cleanup. |
1075 | - $medium = str_replace( wp_basename( $original ), 'midsize-' . wp_basename( $original ), $original ); |
|
1076 | - if ( file_exists( $medium ) ) { |
|
1077 | - wp_delete_file( $medium ); |
|
1075 | + $medium = str_replace(wp_basename($original), 'midsize-' . wp_basename($original), $original); |
|
1076 | + if (file_exists($medium)) { |
|
1077 | + wp_delete_file($medium); |
|
1078 | 1078 | } |
1079 | 1079 | |
1080 | - if ( empty( $_POST['create-new-attachment'] ) && empty( $_POST['skip-cropping'] ) ) { |
|
1081 | - wp_delete_file( $original ); |
|
1080 | + if (empty($_POST['create-new-attachment']) && empty($_POST['skip-cropping'])) { |
|
1081 | + wp_delete_file($original); |
|
1082 | 1082 | } |
1083 | 1083 | |
1084 | 1084 | return $this->finished(); |
@@ -1100,15 +1100,15 @@ discard block |
||
1100 | 1100 | * @since 2.1.0 |
1101 | 1101 | */ |
1102 | 1102 | public function admin_page() { |
1103 | - if ( ! current_user_can( 'edit_theme_options' ) ) { |
|
1104 | - wp_die( __( 'Sorry, you are not allowed to customize headers.' ) ); |
|
1103 | + if (!current_user_can('edit_theme_options')) { |
|
1104 | + wp_die(__('Sorry, you are not allowed to customize headers.')); |
|
1105 | 1105 | } |
1106 | 1106 | |
1107 | 1107 | $step = $this->step(); |
1108 | 1108 | |
1109 | - if ( 2 === $step ) { |
|
1109 | + if (2 === $step) { |
|
1110 | 1110 | $this->step_2(); |
1111 | - } elseif ( 3 === $step ) { |
|
1111 | + } elseif (3 === $step) { |
|
1112 | 1112 | $this->step_3(); |
1113 | 1113 | } else { |
1114 | 1114 | $this->step_1(); |
@@ -1123,7 +1123,7 @@ discard block |
||
1123 | 1123 | * @param array $form_fields |
1124 | 1124 | * @return array $form_fields |
1125 | 1125 | */ |
1126 | - public function attachment_fields_to_edit( $form_fields ) { |
|
1126 | + public function attachment_fields_to_edit($form_fields) { |
|
1127 | 1127 | return $form_fields; |
1128 | 1128 | } |
1129 | 1129 | |
@@ -1135,7 +1135,7 @@ discard block |
||
1135 | 1135 | * @param array $tabs |
1136 | 1136 | * @return array $tabs |
1137 | 1137 | */ |
1138 | - public function filter_upload_tabs( $tabs ) { |
|
1138 | + public function filter_upload_tabs($tabs) { |
|
1139 | 1139 | return $tabs; |
1140 | 1140 | } |
1141 | 1141 | |
@@ -1151,15 +1151,15 @@ discard block |
||
1151 | 1151 | * the key of an image uploaded for that theme (the attachment ID of the image). |
1152 | 1152 | * Or an array of arguments: attachment_id, url, width, height. All are required. |
1153 | 1153 | */ |
1154 | - final public function set_header_image( $choice ) { |
|
1155 | - if ( is_array( $choice ) || is_object( $choice ) ) { |
|
1154 | + final public function set_header_image($choice) { |
|
1155 | + if (is_array($choice) || is_object($choice)) { |
|
1156 | 1156 | $choice = (array) $choice; |
1157 | 1157 | |
1158 | - if ( ! isset( $choice['attachment_id'] ) || ! isset( $choice['url'] ) ) { |
|
1158 | + if (!isset($choice['attachment_id']) || !isset($choice['url'])) { |
|
1159 | 1159 | return; |
1160 | 1160 | } |
1161 | 1161 | |
1162 | - $choice['url'] = esc_url_raw( $choice['url'] ); |
|
1162 | + $choice['url'] = esc_url_raw($choice['url']); |
|
1163 | 1163 | |
1164 | 1164 | $header_image_data = (object) array( |
1165 | 1165 | 'attachment_id' => $choice['attachment_id'], |
@@ -1169,36 +1169,36 @@ discard block |
||
1169 | 1169 | 'width' => $choice['width'], |
1170 | 1170 | ); |
1171 | 1171 | |
1172 | - update_post_meta( $choice['attachment_id'], '_wp_attachment_is_custom_header', get_stylesheet() ); |
|
1172 | + update_post_meta($choice['attachment_id'], '_wp_attachment_is_custom_header', get_stylesheet()); |
|
1173 | 1173 | |
1174 | - set_theme_mod( 'header_image', $choice['url'] ); |
|
1175 | - set_theme_mod( 'header_image_data', $header_image_data ); |
|
1174 | + set_theme_mod('header_image', $choice['url']); |
|
1175 | + set_theme_mod('header_image_data', $header_image_data); |
|
1176 | 1176 | |
1177 | 1177 | return; |
1178 | 1178 | } |
1179 | 1179 | |
1180 | - if ( in_array( $choice, array( 'remove-header', 'random-default-image', 'random-uploaded-image' ), true ) ) { |
|
1181 | - set_theme_mod( 'header_image', $choice ); |
|
1182 | - remove_theme_mod( 'header_image_data' ); |
|
1180 | + if (in_array($choice, array('remove-header', 'random-default-image', 'random-uploaded-image'), true)) { |
|
1181 | + set_theme_mod('header_image', $choice); |
|
1182 | + remove_theme_mod('header_image_data'); |
|
1183 | 1183 | |
1184 | 1184 | return; |
1185 | 1185 | } |
1186 | 1186 | |
1187 | 1187 | $uploaded = get_uploaded_header_images(); |
1188 | 1188 | |
1189 | - if ( $uploaded && isset( $uploaded[ $choice ] ) ) { |
|
1190 | - $header_image_data = $uploaded[ $choice ]; |
|
1189 | + if ($uploaded && isset($uploaded[$choice])) { |
|
1190 | + $header_image_data = $uploaded[$choice]; |
|
1191 | 1191 | } else { |
1192 | 1192 | $this->process_default_headers(); |
1193 | - if ( isset( $this->default_headers[ $choice ] ) ) { |
|
1194 | - $header_image_data = $this->default_headers[ $choice ]; |
|
1193 | + if (isset($this->default_headers[$choice])) { |
|
1194 | + $header_image_data = $this->default_headers[$choice]; |
|
1195 | 1195 | } else { |
1196 | 1196 | return; |
1197 | 1197 | } |
1198 | 1198 | } |
1199 | 1199 | |
1200 | - set_theme_mod( 'header_image', esc_url_raw( $header_image_data['url'] ) ); |
|
1201 | - set_theme_mod( 'header_image_data', $header_image_data ); |
|
1200 | + set_theme_mod('header_image', esc_url_raw($header_image_data['url'])); |
|
1201 | + set_theme_mod('header_image_data', $header_image_data); |
|
1202 | 1202 | } |
1203 | 1203 | |
1204 | 1204 | /** |
@@ -1207,7 +1207,7 @@ discard block |
||
1207 | 1207 | * @since 3.4.0 |
1208 | 1208 | */ |
1209 | 1209 | final public function remove_header_image() { |
1210 | - $this->set_header_image( 'remove-header' ); |
|
1210 | + $this->set_header_image('remove-header'); |
|
1211 | 1211 | } |
1212 | 1212 | |
1213 | 1213 | /** |
@@ -1219,25 +1219,25 @@ discard block |
||
1219 | 1219 | */ |
1220 | 1220 | final public function reset_header_image() { |
1221 | 1221 | $this->process_default_headers(); |
1222 | - $default = get_theme_support( 'custom-header', 'default-image' ); |
|
1222 | + $default = get_theme_support('custom-header', 'default-image'); |
|
1223 | 1223 | |
1224 | - if ( ! $default ) { |
|
1224 | + if (!$default) { |
|
1225 | 1225 | $this->remove_header_image(); |
1226 | 1226 | return; |
1227 | 1227 | } |
1228 | 1228 | |
1229 | - $default = sprintf( $default, get_template_directory_uri(), get_stylesheet_directory_uri() ); |
|
1229 | + $default = sprintf($default, get_template_directory_uri(), get_stylesheet_directory_uri()); |
|
1230 | 1230 | |
1231 | 1231 | $default_data = array(); |
1232 | - foreach ( $this->default_headers as $header => $details ) { |
|
1233 | - if ( $details['url'] === $default ) { |
|
1232 | + foreach ($this->default_headers as $header => $details) { |
|
1233 | + if ($details['url'] === $default) { |
|
1234 | 1234 | $default_data = $details; |
1235 | 1235 | break; |
1236 | 1236 | } |
1237 | 1237 | } |
1238 | 1238 | |
1239 | - set_theme_mod( 'header_image', $default ); |
|
1240 | - set_theme_mod( 'header_image_data', (object) $default_data ); |
|
1239 | + set_theme_mod('header_image', $default); |
|
1240 | + set_theme_mod('header_image_data', (object) $default_data); |
|
1241 | 1241 | } |
1242 | 1242 | |
1243 | 1243 | /** |
@@ -1248,41 +1248,41 @@ discard block |
||
1248 | 1248 | * @param array $dimensions |
1249 | 1249 | * @return array dst_height and dst_width of header image. |
1250 | 1250 | */ |
1251 | - final public function get_header_dimensions( $dimensions ) { |
|
1251 | + final public function get_header_dimensions($dimensions) { |
|
1252 | 1252 | $max_width = 0; |
1253 | - $width = absint( $dimensions['width'] ); |
|
1254 | - $height = absint( $dimensions['height'] ); |
|
1255 | - $theme_height = get_theme_support( 'custom-header', 'height' ); |
|
1256 | - $theme_width = get_theme_support( 'custom-header', 'width' ); |
|
1257 | - $has_flex_width = current_theme_supports( 'custom-header', 'flex-width' ); |
|
1258 | - $has_flex_height = current_theme_supports( 'custom-header', 'flex-height' ); |
|
1259 | - $has_max_width = current_theme_supports( 'custom-header', 'max-width' ); |
|
1253 | + $width = absint($dimensions['width']); |
|
1254 | + $height = absint($dimensions['height']); |
|
1255 | + $theme_height = get_theme_support('custom-header', 'height'); |
|
1256 | + $theme_width = get_theme_support('custom-header', 'width'); |
|
1257 | + $has_flex_width = current_theme_supports('custom-header', 'flex-width'); |
|
1258 | + $has_flex_height = current_theme_supports('custom-header', 'flex-height'); |
|
1259 | + $has_max_width = current_theme_supports('custom-header', 'max-width'); |
|
1260 | 1260 | $dst = array( |
1261 | 1261 | 'dst_height' => null, |
1262 | 1262 | 'dst_width' => null, |
1263 | 1263 | ); |
1264 | 1264 | |
1265 | 1265 | // For flex, limit size of image displayed to 1500px unless theme says otherwise. |
1266 | - if ( $has_flex_width ) { |
|
1266 | + if ($has_flex_width) { |
|
1267 | 1267 | $max_width = 1500; |
1268 | 1268 | } |
1269 | 1269 | |
1270 | - if ( $has_max_width ) { |
|
1271 | - $max_width = max( $max_width, get_theme_support( 'custom-header', 'max-width' ) ); |
|
1270 | + if ($has_max_width) { |
|
1271 | + $max_width = max($max_width, get_theme_support('custom-header', 'max-width')); |
|
1272 | 1272 | } |
1273 | - $max_width = max( $max_width, $theme_width ); |
|
1273 | + $max_width = max($max_width, $theme_width); |
|
1274 | 1274 | |
1275 | - if ( $has_flex_height && ( ! $has_flex_width || $width > $max_width ) ) { |
|
1276 | - $dst['dst_height'] = absint( $height * ( $max_width / $width ) ); |
|
1277 | - } elseif ( $has_flex_height && $has_flex_width ) { |
|
1275 | + if ($has_flex_height && (!$has_flex_width || $width > $max_width)) { |
|
1276 | + $dst['dst_height'] = absint($height * ($max_width / $width)); |
|
1277 | + } elseif ($has_flex_height && $has_flex_width) { |
|
1278 | 1278 | $dst['dst_height'] = $height; |
1279 | 1279 | } else { |
1280 | 1280 | $dst['dst_height'] = $theme_height; |
1281 | 1281 | } |
1282 | 1282 | |
1283 | - if ( $has_flex_width && ( ! $has_flex_height || $width > $max_width ) ) { |
|
1284 | - $dst['dst_width'] = absint( $width * ( $max_width / $width ) ); |
|
1285 | - } elseif ( $has_flex_width && $has_flex_height ) { |
|
1283 | + if ($has_flex_width && (!$has_flex_height || $width > $max_width)) { |
|
1284 | + $dst['dst_width'] = absint($width * ($max_width / $width)); |
|
1285 | + } elseif ($has_flex_width && $has_flex_height) { |
|
1286 | 1286 | $dst['dst_width'] = $width; |
1287 | 1287 | } else { |
1288 | 1288 | $dst['dst_width'] = $theme_width; |
@@ -1300,17 +1300,17 @@ discard block |
||
1300 | 1300 | * @param int $parent_attachment_id Attachment ID of parent image. |
1301 | 1301 | * @return array An array with attachment object data. |
1302 | 1302 | */ |
1303 | - final public function create_attachment_object( $cropped, $parent_attachment_id ) { |
|
1304 | - $parent = get_post( $parent_attachment_id ); |
|
1305 | - $parent_url = wp_get_attachment_url( $parent->ID ); |
|
1306 | - $url = str_replace( wp_basename( $parent_url ), wp_basename( $cropped ), $parent_url ); |
|
1303 | + final public function create_attachment_object($cropped, $parent_attachment_id) { |
|
1304 | + $parent = get_post($parent_attachment_id); |
|
1305 | + $parent_url = wp_get_attachment_url($parent->ID); |
|
1306 | + $url = str_replace(wp_basename($parent_url), wp_basename($cropped), $parent_url); |
|
1307 | 1307 | |
1308 | - $size = wp_getimagesize( $cropped ); |
|
1309 | - $image_type = ( $size ) ? $size['mime'] : 'image/jpeg'; |
|
1308 | + $size = wp_getimagesize($cropped); |
|
1309 | + $image_type = ($size) ? $size['mime'] : 'image/jpeg'; |
|
1310 | 1310 | |
1311 | 1311 | $attachment = array( |
1312 | 1312 | 'ID' => $parent_attachment_id, |
1313 | - 'post_title' => wp_basename( $cropped ), |
|
1313 | + 'post_title' => wp_basename($cropped), |
|
1314 | 1314 | 'post_mime_type' => $image_type, |
1315 | 1315 | 'guid' => $url, |
1316 | 1316 | 'context' => 'custom-header', |
@@ -1329,15 +1329,15 @@ discard block |
||
1329 | 1329 | * @param string $cropped File path to cropped image. |
1330 | 1330 | * @return int Attachment ID. |
1331 | 1331 | */ |
1332 | - final public function insert_attachment( $attachment, $cropped ) { |
|
1333 | - $parent_id = isset( $attachment['post_parent'] ) ? $attachment['post_parent'] : null; |
|
1334 | - unset( $attachment['post_parent'] ); |
|
1332 | + final public function insert_attachment($attachment, $cropped) { |
|
1333 | + $parent_id = isset($attachment['post_parent']) ? $attachment['post_parent'] : null; |
|
1334 | + unset($attachment['post_parent']); |
|
1335 | 1335 | |
1336 | - $attachment_id = wp_insert_attachment( $attachment, $cropped ); |
|
1337 | - $metadata = wp_generate_attachment_metadata( $attachment_id, $cropped ); |
|
1336 | + $attachment_id = wp_insert_attachment($attachment, $cropped); |
|
1337 | + $metadata = wp_generate_attachment_metadata($attachment_id, $cropped); |
|
1338 | 1338 | |
1339 | 1339 | // If this is a crop, save the original attachment ID as metadata. |
1340 | - if ( $parent_id ) { |
|
1340 | + if ($parent_id) { |
|
1341 | 1341 | $metadata['attachment_parent'] = $parent_id; |
1342 | 1342 | } |
1343 | 1343 | |
@@ -1350,9 +1350,9 @@ discard block |
||
1350 | 1350 | * |
1351 | 1351 | * @param array $metadata Attachment metadata. |
1352 | 1352 | */ |
1353 | - $metadata = apply_filters( 'wp_header_image_attachment_metadata', $metadata ); |
|
1353 | + $metadata = apply_filters('wp_header_image_attachment_metadata', $metadata); |
|
1354 | 1354 | |
1355 | - wp_update_attachment_metadata( $attachment_id, $metadata ); |
|
1355 | + wp_update_attachment_metadata($attachment_id, $metadata); |
|
1356 | 1356 | |
1357 | 1357 | return $attachment_id; |
1358 | 1358 | } |
@@ -1364,13 +1364,13 @@ discard block |
||
1364 | 1364 | * @since 3.9.0 |
1365 | 1365 | */ |
1366 | 1366 | public function ajax_header_crop() { |
1367 | - check_ajax_referer( 'image_editor-' . $_POST['id'], 'nonce' ); |
|
1367 | + check_ajax_referer('image_editor-' . $_POST['id'], 'nonce'); |
|
1368 | 1368 | |
1369 | - if ( ! current_user_can( 'edit_theme_options' ) ) { |
|
1369 | + if (!current_user_can('edit_theme_options')) { |
|
1370 | 1370 | wp_send_json_error(); |
1371 | 1371 | } |
1372 | 1372 | |
1373 | - if ( ! current_theme_supports( 'custom-header', 'uploads' ) ) { |
|
1373 | + if (!current_theme_supports('custom-header', 'uploads')) { |
|
1374 | 1374 | wp_send_json_error(); |
1375 | 1375 | } |
1376 | 1376 | |
@@ -1383,7 +1383,7 @@ discard block |
||
1383 | 1383 | ) |
1384 | 1384 | ); |
1385 | 1385 | |
1386 | - $attachment_id = absint( $_POST['id'] ); |
|
1386 | + $attachment_id = absint($_POST['id']); |
|
1387 | 1387 | |
1388 | 1388 | $cropped = wp_crop_image( |
1389 | 1389 | $attachment_id, |
@@ -1395,32 +1395,32 @@ discard block |
||
1395 | 1395 | (int) $dimensions['dst_height'] |
1396 | 1396 | ); |
1397 | 1397 | |
1398 | - if ( ! $cropped || is_wp_error( $cropped ) ) { |
|
1399 | - wp_send_json_error( array( 'message' => __( 'Image could not be processed. Please go back and try again.' ) ) ); |
|
1398 | + if (!$cropped || is_wp_error($cropped)) { |
|
1399 | + wp_send_json_error(array('message' => __('Image could not be processed. Please go back and try again.'))); |
|
1400 | 1400 | } |
1401 | 1401 | |
1402 | 1402 | /** This filter is documented in wp-admin/includes/class-custom-image-header.php */ |
1403 | - $cropped = apply_filters( 'wp_create_file_in_uploads', $cropped, $attachment_id ); // For replication. |
|
1403 | + $cropped = apply_filters('wp_create_file_in_uploads', $cropped, $attachment_id); // For replication. |
|
1404 | 1404 | |
1405 | - $attachment = $this->create_attachment_object( $cropped, $attachment_id ); |
|
1405 | + $attachment = $this->create_attachment_object($cropped, $attachment_id); |
|
1406 | 1406 | |
1407 | - $previous = $this->get_previous_crop( $attachment ); |
|
1407 | + $previous = $this->get_previous_crop($attachment); |
|
1408 | 1408 | |
1409 | - if ( $previous ) { |
|
1409 | + if ($previous) { |
|
1410 | 1410 | $attachment['ID'] = $previous; |
1411 | 1411 | } else { |
1412 | - unset( $attachment['ID'] ); |
|
1412 | + unset($attachment['ID']); |
|
1413 | 1413 | } |
1414 | 1414 | |
1415 | - $new_attachment_id = $this->insert_attachment( $attachment, $cropped ); |
|
1415 | + $new_attachment_id = $this->insert_attachment($attachment, $cropped); |
|
1416 | 1416 | |
1417 | 1417 | $attachment['attachment_id'] = $new_attachment_id; |
1418 | - $attachment['url'] = wp_get_attachment_url( $new_attachment_id ); |
|
1418 | + $attachment['url'] = wp_get_attachment_url($new_attachment_id); |
|
1419 | 1419 | |
1420 | 1420 | $attachment['width'] = $dimensions['dst_width']; |
1421 | 1421 | $attachment['height'] = $dimensions['dst_height']; |
1422 | 1422 | |
1423 | - wp_send_json_success( $attachment ); |
|
1423 | + wp_send_json_success($attachment); |
|
1424 | 1424 | } |
1425 | 1425 | |
1426 | 1426 | /** |
@@ -1433,20 +1433,20 @@ discard block |
||
1433 | 1433 | * @since 3.9.0 |
1434 | 1434 | */ |
1435 | 1435 | public function ajax_header_add() { |
1436 | - check_ajax_referer( 'header-add', 'nonce' ); |
|
1436 | + check_ajax_referer('header-add', 'nonce'); |
|
1437 | 1437 | |
1438 | - if ( ! current_user_can( 'edit_theme_options' ) ) { |
|
1438 | + if (!current_user_can('edit_theme_options')) { |
|
1439 | 1439 | wp_send_json_error(); |
1440 | 1440 | } |
1441 | 1441 | |
1442 | - $attachment_id = absint( $_POST['attachment_id'] ); |
|
1443 | - if ( $attachment_id < 1 ) { |
|
1442 | + $attachment_id = absint($_POST['attachment_id']); |
|
1443 | + if ($attachment_id < 1) { |
|
1444 | 1444 | wp_send_json_error(); |
1445 | 1445 | } |
1446 | 1446 | |
1447 | 1447 | $key = '_wp_attachment_custom_header_last_used_' . get_stylesheet(); |
1448 | - update_post_meta( $attachment_id, $key, time() ); |
|
1449 | - update_post_meta( $attachment_id, '_wp_attachment_is_custom_header', get_stylesheet() ); |
|
1448 | + update_post_meta($attachment_id, $key, time()); |
|
1449 | + update_post_meta($attachment_id, '_wp_attachment_is_custom_header', get_stylesheet()); |
|
1450 | 1450 | |
1451 | 1451 | wp_send_json_success(); |
1452 | 1452 | } |
@@ -1461,20 +1461,20 @@ discard block |
||
1461 | 1461 | * @since 3.9.0 |
1462 | 1462 | */ |
1463 | 1463 | public function ajax_header_remove() { |
1464 | - check_ajax_referer( 'header-remove', 'nonce' ); |
|
1464 | + check_ajax_referer('header-remove', 'nonce'); |
|
1465 | 1465 | |
1466 | - if ( ! current_user_can( 'edit_theme_options' ) ) { |
|
1466 | + if (!current_user_can('edit_theme_options')) { |
|
1467 | 1467 | wp_send_json_error(); |
1468 | 1468 | } |
1469 | 1469 | |
1470 | - $attachment_id = absint( $_POST['attachment_id'] ); |
|
1471 | - if ( $attachment_id < 1 ) { |
|
1470 | + $attachment_id = absint($_POST['attachment_id']); |
|
1471 | + if ($attachment_id < 1) { |
|
1472 | 1472 | wp_send_json_error(); |
1473 | 1473 | } |
1474 | 1474 | |
1475 | 1475 | $key = '_wp_attachment_custom_header_last_used_' . get_stylesheet(); |
1476 | - delete_post_meta( $attachment_id, $key ); |
|
1477 | - delete_post_meta( $attachment_id, '_wp_attachment_is_custom_header', get_stylesheet() ); |
|
1476 | + delete_post_meta($attachment_id, $key); |
|
1477 | + delete_post_meta($attachment_id, '_wp_attachment_is_custom_header', get_stylesheet()); |
|
1478 | 1478 | |
1479 | 1479 | wp_send_json_success(); |
1480 | 1480 | } |
@@ -1486,23 +1486,23 @@ discard block |
||
1486 | 1486 | * |
1487 | 1487 | * @param WP_Customize_Manager $wp_customize Customize manager. |
1488 | 1488 | */ |
1489 | - public function customize_set_last_used( $wp_customize ) { |
|
1489 | + public function customize_set_last_used($wp_customize) { |
|
1490 | 1490 | |
1491 | - $header_image_data_setting = $wp_customize->get_setting( 'header_image_data' ); |
|
1491 | + $header_image_data_setting = $wp_customize->get_setting('header_image_data'); |
|
1492 | 1492 | |
1493 | - if ( ! $header_image_data_setting ) { |
|
1493 | + if (!$header_image_data_setting) { |
|
1494 | 1494 | return; |
1495 | 1495 | } |
1496 | 1496 | |
1497 | 1497 | $data = $header_image_data_setting->post_value(); |
1498 | 1498 | |
1499 | - if ( ! isset( $data['attachment_id'] ) ) { |
|
1499 | + if (!isset($data['attachment_id'])) { |
|
1500 | 1500 | return; |
1501 | 1501 | } |
1502 | 1502 | |
1503 | 1503 | $attachment_id = $data['attachment_id']; |
1504 | 1504 | $key = '_wp_attachment_custom_header_last_used_' . get_stylesheet(); |
1505 | - update_post_meta( $attachment_id, $key, time() ); |
|
1505 | + update_post_meta($attachment_id, $key, time()); |
|
1506 | 1506 | } |
1507 | 1507 | |
1508 | 1508 | /** |
@@ -1516,24 +1516,24 @@ discard block |
||
1516 | 1516 | $this->process_default_headers(); |
1517 | 1517 | |
1518 | 1518 | // Get the default image if there is one. |
1519 | - $default = get_theme_support( 'custom-header', 'default-image' ); |
|
1519 | + $default = get_theme_support('custom-header', 'default-image'); |
|
1520 | 1520 | |
1521 | - if ( ! $default ) { // If not, easy peasy. |
|
1521 | + if (!$default) { // If not, easy peasy. |
|
1522 | 1522 | return $this->default_headers; |
1523 | 1523 | } |
1524 | 1524 | |
1525 | - $default = sprintf( $default, get_template_directory_uri(), get_stylesheet_directory_uri() ); |
|
1525 | + $default = sprintf($default, get_template_directory_uri(), get_stylesheet_directory_uri()); |
|
1526 | 1526 | |
1527 | 1527 | $already_has_default = false; |
1528 | 1528 | |
1529 | - foreach ( $this->default_headers as $k => $h ) { |
|
1530 | - if ( $h['url'] === $default ) { |
|
1529 | + foreach ($this->default_headers as $k => $h) { |
|
1530 | + if ($h['url'] === $default) { |
|
1531 | 1531 | $already_has_default = true; |
1532 | 1532 | break; |
1533 | 1533 | } |
1534 | 1534 | } |
1535 | 1535 | |
1536 | - if ( $already_has_default ) { |
|
1536 | + if ($already_has_default) { |
|
1537 | 1537 | return $this->default_headers; |
1538 | 1538 | } |
1539 | 1539 | |
@@ -1546,7 +1546,7 @@ discard block |
||
1546 | 1546 | ); |
1547 | 1547 | |
1548 | 1548 | // The rest of the set comes after. |
1549 | - return array_merge( $header_images, $this->default_headers ); |
|
1549 | + return array_merge($header_images, $this->default_headers); |
|
1550 | 1550 | } |
1551 | 1551 | |
1552 | 1552 | /** |
@@ -1561,10 +1561,10 @@ discard block |
||
1561 | 1561 | $timestamp_key = '_wp_attachment_custom_header_last_used_' . get_stylesheet(); |
1562 | 1562 | $alt_text_key = '_wp_attachment_image_alt'; |
1563 | 1563 | |
1564 | - foreach ( $header_images as &$header_image ) { |
|
1565 | - $header_meta = get_post_meta( $header_image['attachment_id'] ); |
|
1566 | - $header_image['timestamp'] = isset( $header_meta[ $timestamp_key ] ) ? $header_meta[ $timestamp_key ] : ''; |
|
1567 | - $header_image['alt_text'] = isset( $header_meta[ $alt_text_key ] ) ? $header_meta[ $alt_text_key ] : ''; |
|
1564 | + foreach ($header_images as &$header_image) { |
|
1565 | + $header_meta = get_post_meta($header_image['attachment_id']); |
|
1566 | + $header_image['timestamp'] = isset($header_meta[$timestamp_key]) ? $header_meta[$timestamp_key] : ''; |
|
1567 | + $header_image['alt_text'] = isset($header_meta[$alt_text_key]) ? $header_meta[$alt_text_key] : ''; |
|
1568 | 1568 | } |
1569 | 1569 | |
1570 | 1570 | return $header_images; |
@@ -1578,18 +1578,18 @@ discard block |
||
1578 | 1578 | * @param array $attachment An array with a cropped attachment object data. |
1579 | 1579 | * @return int|false An attachment ID if one exists. False if none. |
1580 | 1580 | */ |
1581 | - public function get_previous_crop( $attachment ) { |
|
1581 | + public function get_previous_crop($attachment) { |
|
1582 | 1582 | $header_images = $this->get_uploaded_header_images(); |
1583 | 1583 | |
1584 | 1584 | // Bail early if there are no header images. |
1585 | - if ( empty( $header_images ) ) { |
|
1585 | + if (empty($header_images)) { |
|
1586 | 1586 | return false; |
1587 | 1587 | } |
1588 | 1588 | |
1589 | 1589 | $previous = false; |
1590 | 1590 | |
1591 | - foreach ( $header_images as $image ) { |
|
1592 | - if ( $image['attachment_parent'] === $attachment['post_parent'] ) { |
|
1591 | + foreach ($header_images as $image) { |
|
1592 | + if ($image['attachment_parent'] === $attachment['post_parent']) { |
|
1593 | 1593 | $previous = $image['attachment_id']; |
1594 | 1594 | break; |
1595 | 1595 | } |
@@ -8,162 +8,162 @@ |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | // Bookmark hooks. |
11 | -add_action( 'admin_page_access_denied', 'wp_link_manager_disabled_message' ); |
|
11 | +add_action('admin_page_access_denied', 'wp_link_manager_disabled_message'); |
|
12 | 12 | |
13 | 13 | // Dashboard hooks. |
14 | -add_action( 'activity_box_end', 'wp_dashboard_quota' ); |
|
15 | -add_action( 'welcome_panel', 'wp_welcome_panel' ); |
|
14 | +add_action('activity_box_end', 'wp_dashboard_quota'); |
|
15 | +add_action('welcome_panel', 'wp_welcome_panel'); |
|
16 | 16 | |
17 | 17 | // Media hooks. |
18 | -add_action( 'attachment_submitbox_misc_actions', 'attachment_submitbox_metadata' ); |
|
19 | -add_filter( 'plupload_init', 'wp_show_heic_upload_error' ); |
|
18 | +add_action('attachment_submitbox_misc_actions', 'attachment_submitbox_metadata'); |
|
19 | +add_filter('plupload_init', 'wp_show_heic_upload_error'); |
|
20 | 20 | |
21 | -add_action( 'media_upload_image', 'wp_media_upload_handler' ); |
|
22 | -add_action( 'media_upload_audio', 'wp_media_upload_handler' ); |
|
23 | -add_action( 'media_upload_video', 'wp_media_upload_handler' ); |
|
24 | -add_action( 'media_upload_file', 'wp_media_upload_handler' ); |
|
21 | +add_action('media_upload_image', 'wp_media_upload_handler'); |
|
22 | +add_action('media_upload_audio', 'wp_media_upload_handler'); |
|
23 | +add_action('media_upload_video', 'wp_media_upload_handler'); |
|
24 | +add_action('media_upload_file', 'wp_media_upload_handler'); |
|
25 | 25 | |
26 | -add_action( 'post-plupload-upload-ui', 'media_upload_flash_bypass' ); |
|
26 | +add_action('post-plupload-upload-ui', 'media_upload_flash_bypass'); |
|
27 | 27 | |
28 | -add_action( 'post-html-upload-ui', 'media_upload_html_bypass' ); |
|
28 | +add_action('post-html-upload-ui', 'media_upload_html_bypass'); |
|
29 | 29 | |
30 | -add_filter( 'async_upload_image', 'get_media_item', 10, 2 ); |
|
31 | -add_filter( 'async_upload_audio', 'get_media_item', 10, 2 ); |
|
32 | -add_filter( 'async_upload_video', 'get_media_item', 10, 2 ); |
|
33 | -add_filter( 'async_upload_file', 'get_media_item', 10, 2 ); |
|
30 | +add_filter('async_upload_image', 'get_media_item', 10, 2); |
|
31 | +add_filter('async_upload_audio', 'get_media_item', 10, 2); |
|
32 | +add_filter('async_upload_video', 'get_media_item', 10, 2); |
|
33 | +add_filter('async_upload_file', 'get_media_item', 10, 2); |
|
34 | 34 | |
35 | -add_filter( 'media_upload_gallery', 'media_upload_gallery' ); |
|
36 | -add_filter( 'media_upload_library', 'media_upload_library' ); |
|
35 | +add_filter('media_upload_gallery', 'media_upload_gallery'); |
|
36 | +add_filter('media_upload_library', 'media_upload_library'); |
|
37 | 37 | |
38 | -add_filter( 'media_upload_tabs', 'update_gallery_tab' ); |
|
38 | +add_filter('media_upload_tabs', 'update_gallery_tab'); |
|
39 | 39 | |
40 | 40 | // Admin color schemes. |
41 | -add_action( 'admin_init', 'register_admin_color_schemes', 1 ); |
|
42 | -add_action( 'admin_head', 'wp_color_scheme_settings' ); |
|
43 | -add_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' ); |
|
41 | +add_action('admin_init', 'register_admin_color_schemes', 1); |
|
42 | +add_action('admin_head', 'wp_color_scheme_settings'); |
|
43 | +add_action('admin_color_scheme_picker', 'admin_color_scheme_picker'); |
|
44 | 44 | |
45 | 45 | // Misc hooks. |
46 | -add_action( 'admin_init', 'wp_admin_headers' ); |
|
47 | -add_action( 'login_init', 'wp_admin_headers' ); |
|
48 | -add_action( 'admin_init', 'send_frame_options_header', 10, 0 ); |
|
49 | -add_action( 'admin_head', 'wp_admin_canonical_url' ); |
|
50 | -add_action( 'admin_head', 'wp_site_icon' ); |
|
51 | -add_action( 'admin_head', 'wp_admin_viewport_meta' ); |
|
52 | -add_action( 'customize_controls_head', 'wp_admin_viewport_meta' ); |
|
53 | -add_filter( 'nav_menu_meta_box_object', '_wp_nav_menu_meta_box_object' ); |
|
46 | +add_action('admin_init', 'wp_admin_headers'); |
|
47 | +add_action('login_init', 'wp_admin_headers'); |
|
48 | +add_action('admin_init', 'send_frame_options_header', 10, 0); |
|
49 | +add_action('admin_head', 'wp_admin_canonical_url'); |
|
50 | +add_action('admin_head', 'wp_site_icon'); |
|
51 | +add_action('admin_head', 'wp_admin_viewport_meta'); |
|
52 | +add_action('customize_controls_head', 'wp_admin_viewport_meta'); |
|
53 | +add_filter('nav_menu_meta_box_object', '_wp_nav_menu_meta_box_object'); |
|
54 | 54 | |
55 | 55 | // Prerendering. |
56 | -if ( ! is_customize_preview() ) { |
|
57 | - add_filter( 'admin_print_styles', 'wp_resource_hints', 1 ); |
|
56 | +if (!is_customize_preview()) { |
|
57 | + add_filter('admin_print_styles', 'wp_resource_hints', 1); |
|
58 | 58 | } |
59 | 59 | |
60 | -add_action( 'admin_print_scripts', 'print_emoji_detection_script' ); |
|
61 | -add_action( 'admin_print_scripts', 'print_head_scripts', 20 ); |
|
62 | -add_action( 'admin_print_footer_scripts', '_wp_footer_scripts' ); |
|
63 | -add_action( 'admin_print_styles', 'print_emoji_styles' ); |
|
64 | -add_action( 'admin_print_styles', 'print_admin_styles', 20 ); |
|
60 | +add_action('admin_print_scripts', 'print_emoji_detection_script'); |
|
61 | +add_action('admin_print_scripts', 'print_head_scripts', 20); |
|
62 | +add_action('admin_print_footer_scripts', '_wp_footer_scripts'); |
|
63 | +add_action('admin_print_styles', 'print_emoji_styles'); |
|
64 | +add_action('admin_print_styles', 'print_admin_styles', 20); |
|
65 | 65 | |
66 | -add_action( 'admin_print_scripts-index.php', 'wp_localize_community_events' ); |
|
67 | -add_action( 'admin_print_scripts-post.php', 'wp_page_reload_on_back_button_js' ); |
|
68 | -add_action( 'admin_print_scripts-post-new.php', 'wp_page_reload_on_back_button_js' ); |
|
66 | +add_action('admin_print_scripts-index.php', 'wp_localize_community_events'); |
|
67 | +add_action('admin_print_scripts-post.php', 'wp_page_reload_on_back_button_js'); |
|
68 | +add_action('admin_print_scripts-post-new.php', 'wp_page_reload_on_back_button_js'); |
|
69 | 69 | |
70 | -add_action( 'update_option_home', 'update_home_siteurl', 10, 2 ); |
|
71 | -add_action( 'update_option_siteurl', 'update_home_siteurl', 10, 2 ); |
|
72 | -add_action( 'update_option_page_on_front', 'update_home_siteurl', 10, 2 ); |
|
73 | -add_action( 'update_option_admin_email', 'wp_site_admin_email_change_notification', 10, 3 ); |
|
70 | +add_action('update_option_home', 'update_home_siteurl', 10, 2); |
|
71 | +add_action('update_option_siteurl', 'update_home_siteurl', 10, 2); |
|
72 | +add_action('update_option_page_on_front', 'update_home_siteurl', 10, 2); |
|
73 | +add_action('update_option_admin_email', 'wp_site_admin_email_change_notification', 10, 3); |
|
74 | 74 | |
75 | -add_action( 'add_option_new_admin_email', 'update_option_new_admin_email', 10, 2 ); |
|
76 | -add_action( 'update_option_new_admin_email', 'update_option_new_admin_email', 10, 2 ); |
|
75 | +add_action('add_option_new_admin_email', 'update_option_new_admin_email', 10, 2); |
|
76 | +add_action('update_option_new_admin_email', 'update_option_new_admin_email', 10, 2); |
|
77 | 77 | |
78 | -add_filter( 'heartbeat_received', 'wp_check_locked_posts', 10, 3 ); |
|
79 | -add_filter( 'heartbeat_received', 'wp_refresh_post_lock', 10, 3 ); |
|
80 | -add_filter( 'heartbeat_received', 'heartbeat_autosave', 500, 2 ); |
|
78 | +add_filter('heartbeat_received', 'wp_check_locked_posts', 10, 3); |
|
79 | +add_filter('heartbeat_received', 'wp_refresh_post_lock', 10, 3); |
|
80 | +add_filter('heartbeat_received', 'heartbeat_autosave', 500, 2); |
|
81 | 81 | |
82 | -add_filter( 'wp_refresh_nonces', 'wp_refresh_post_nonces', 10, 3 ); |
|
83 | -add_filter( 'wp_refresh_nonces', 'wp_refresh_heartbeat_nonces' ); |
|
82 | +add_filter('wp_refresh_nonces', 'wp_refresh_post_nonces', 10, 3); |
|
83 | +add_filter('wp_refresh_nonces', 'wp_refresh_heartbeat_nonces'); |
|
84 | 84 | |
85 | -add_filter( 'heartbeat_settings', 'wp_heartbeat_set_suspension' ); |
|
85 | +add_filter('heartbeat_settings', 'wp_heartbeat_set_suspension'); |
|
86 | 86 | |
87 | -add_action( 'use_block_editor_for_post_type', '_disable_block_editor_for_navigation_post_type', 10, 2 ); |
|
88 | -add_action( 'edit_form_after_title', '_disable_content_editor_for_navigation_post_type' ); |
|
89 | -add_action( 'edit_form_after_editor', '_enable_content_editor_for_navigation_post_type' ); |
|
87 | +add_action('use_block_editor_for_post_type', '_disable_block_editor_for_navigation_post_type', 10, 2); |
|
88 | +add_action('edit_form_after_title', '_disable_content_editor_for_navigation_post_type'); |
|
89 | +add_action('edit_form_after_editor', '_enable_content_editor_for_navigation_post_type'); |
|
90 | 90 | |
91 | 91 | // Nav Menu hooks. |
92 | -add_action( 'admin_head-nav-menus.php', '_wp_delete_orphaned_draft_menu_items' ); |
|
92 | +add_action('admin_head-nav-menus.php', '_wp_delete_orphaned_draft_menu_items'); |
|
93 | 93 | |
94 | 94 | // Plugin hooks. |
95 | -add_filter( 'allowed_options', 'option_update_filter' ); |
|
95 | +add_filter('allowed_options', 'option_update_filter'); |
|
96 | 96 | |
97 | 97 | // Plugin Install hooks. |
98 | -add_action( 'install_plugins_featured', 'install_dashboard' ); |
|
99 | -add_action( 'install_plugins_upload', 'install_plugins_upload' ); |
|
100 | -add_action( 'install_plugins_search', 'display_plugins_table' ); |
|
101 | -add_action( 'install_plugins_popular', 'display_plugins_table' ); |
|
102 | -add_action( 'install_plugins_recommended', 'display_plugins_table' ); |
|
103 | -add_action( 'install_plugins_new', 'display_plugins_table' ); |
|
104 | -add_action( 'install_plugins_beta', 'display_plugins_table' ); |
|
105 | -add_action( 'install_plugins_favorites', 'display_plugins_table' ); |
|
106 | -add_action( 'install_plugins_pre_plugin-information', 'install_plugin_information' ); |
|
98 | +add_action('install_plugins_featured', 'install_dashboard'); |
|
99 | +add_action('install_plugins_upload', 'install_plugins_upload'); |
|
100 | +add_action('install_plugins_search', 'display_plugins_table'); |
|
101 | +add_action('install_plugins_popular', 'display_plugins_table'); |
|
102 | +add_action('install_plugins_recommended', 'display_plugins_table'); |
|
103 | +add_action('install_plugins_new', 'display_plugins_table'); |
|
104 | +add_action('install_plugins_beta', 'display_plugins_table'); |
|
105 | +add_action('install_plugins_favorites', 'display_plugins_table'); |
|
106 | +add_action('install_plugins_pre_plugin-information', 'install_plugin_information'); |
|
107 | 107 | |
108 | 108 | // Template hooks. |
109 | -add_action( 'admin_enqueue_scripts', array( 'WP_Internal_Pointers', 'enqueue_scripts' ) ); |
|
110 | -add_action( 'user_register', array( 'WP_Internal_Pointers', 'dismiss_pointers_for_new_users' ) ); |
|
109 | +add_action('admin_enqueue_scripts', array('WP_Internal_Pointers', 'enqueue_scripts')); |
|
110 | +add_action('user_register', array('WP_Internal_Pointers', 'dismiss_pointers_for_new_users')); |
|
111 | 111 | |
112 | 112 | // Theme hooks. |
113 | -add_action( 'customize_controls_print_footer_scripts', 'customize_themes_print_templates' ); |
|
113 | +add_action('customize_controls_print_footer_scripts', 'customize_themes_print_templates'); |
|
114 | 114 | |
115 | 115 | // Theme Install hooks. |
116 | -add_action( 'install_themes_pre_theme-information', 'install_theme_information' ); |
|
116 | +add_action('install_themes_pre_theme-information', 'install_theme_information'); |
|
117 | 117 | |
118 | 118 | // User hooks. |
119 | -add_action( 'admin_init', 'default_password_nag_handler' ); |
|
119 | +add_action('admin_init', 'default_password_nag_handler'); |
|
120 | 120 | |
121 | -add_action( 'admin_notices', 'default_password_nag' ); |
|
122 | -add_action( 'admin_notices', 'new_user_email_admin_notice' ); |
|
121 | +add_action('admin_notices', 'default_password_nag'); |
|
122 | +add_action('admin_notices', 'new_user_email_admin_notice'); |
|
123 | 123 | |
124 | -add_action( 'profile_update', 'default_password_nag_edit_user', 10, 2 ); |
|
124 | +add_action('profile_update', 'default_password_nag_edit_user', 10, 2); |
|
125 | 125 | |
126 | -add_action( 'personal_options_update', 'send_confirmation_on_profile_email' ); |
|
126 | +add_action('personal_options_update', 'send_confirmation_on_profile_email'); |
|
127 | 127 | |
128 | 128 | // Update hooks. |
129 | -add_action( 'load-plugins.php', 'wp_plugin_update_rows', 20 ); // After wp_update_plugins() is called. |
|
130 | -add_action( 'load-themes.php', 'wp_theme_update_rows', 20 ); // After wp_update_themes() is called. |
|
129 | +add_action('load-plugins.php', 'wp_plugin_update_rows', 20); // After wp_update_plugins() is called. |
|
130 | +add_action('load-themes.php', 'wp_theme_update_rows', 20); // After wp_update_themes() is called. |
|
131 | 131 | |
132 | -add_action( 'admin_notices', 'update_nag', 3 ); |
|
133 | -add_action( 'admin_notices', 'deactivated_plugins_notice', 5 ); |
|
134 | -add_action( 'admin_notices', 'paused_plugins_notice', 5 ); |
|
135 | -add_action( 'admin_notices', 'paused_themes_notice', 5 ); |
|
136 | -add_action( 'admin_notices', 'maintenance_nag', 10 ); |
|
137 | -add_action( 'admin_notices', 'wp_recovery_mode_nag', 1 ); |
|
132 | +add_action('admin_notices', 'update_nag', 3); |
|
133 | +add_action('admin_notices', 'deactivated_plugins_notice', 5); |
|
134 | +add_action('admin_notices', 'paused_plugins_notice', 5); |
|
135 | +add_action('admin_notices', 'paused_themes_notice', 5); |
|
136 | +add_action('admin_notices', 'maintenance_nag', 10); |
|
137 | +add_action('admin_notices', 'wp_recovery_mode_nag', 1); |
|
138 | 138 | |
139 | -add_filter( 'update_footer', 'core_update_footer' ); |
|
139 | +add_filter('update_footer', 'core_update_footer'); |
|
140 | 140 | |
141 | 141 | // Update Core hooks. |
142 | -add_action( '_core_updated_successfully', '_redirect_to_about_wordpress' ); |
|
142 | +add_action('_core_updated_successfully', '_redirect_to_about_wordpress'); |
|
143 | 143 | |
144 | 144 | // Upgrade hooks. |
145 | -add_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 ); |
|
146 | -add_action( 'upgrader_process_complete', 'wp_version_check', 10, 0 ); |
|
147 | -add_action( 'upgrader_process_complete', 'wp_update_plugins', 10, 0 ); |
|
148 | -add_action( 'upgrader_process_complete', 'wp_update_themes', 10, 0 ); |
|
145 | +add_action('upgrader_process_complete', array('Language_Pack_Upgrader', 'async_upgrade'), 20); |
|
146 | +add_action('upgrader_process_complete', 'wp_version_check', 10, 0); |
|
147 | +add_action('upgrader_process_complete', 'wp_update_plugins', 10, 0); |
|
148 | +add_action('upgrader_process_complete', 'wp_update_themes', 10, 0); |
|
149 | 149 | |
150 | 150 | // Privacy hooks. |
151 | -add_filter( 'wp_privacy_personal_data_erasure_page', 'wp_privacy_process_personal_data_erasure_page', 10, 5 ); |
|
152 | -add_filter( 'wp_privacy_personal_data_export_page', 'wp_privacy_process_personal_data_export_page', 10, 7 ); |
|
153 | -add_action( 'wp_privacy_personal_data_export_file', 'wp_privacy_generate_personal_data_export_file', 10 ); |
|
154 | -add_action( 'wp_privacy_personal_data_erased', '_wp_privacy_send_erasure_fulfillment_notification', 10 ); |
|
151 | +add_filter('wp_privacy_personal_data_erasure_page', 'wp_privacy_process_personal_data_erasure_page', 10, 5); |
|
152 | +add_filter('wp_privacy_personal_data_export_page', 'wp_privacy_process_personal_data_export_page', 10, 7); |
|
153 | +add_action('wp_privacy_personal_data_export_file', 'wp_privacy_generate_personal_data_export_file', 10); |
|
154 | +add_action('wp_privacy_personal_data_erased', '_wp_privacy_send_erasure_fulfillment_notification', 10); |
|
155 | 155 | |
156 | 156 | // Privacy policy text changes check. |
157 | -add_action( 'admin_init', array( 'WP_Privacy_Policy_Content', 'text_change_check' ), 100 ); |
|
157 | +add_action('admin_init', array('WP_Privacy_Policy_Content', 'text_change_check'), 100); |
|
158 | 158 | |
159 | 159 | // Show a "postbox" with the text suggestions for a privacy policy. |
160 | -add_action( 'admin_notices', array( 'WP_Privacy_Policy_Content', 'notice' ) ); |
|
160 | +add_action('admin_notices', array('WP_Privacy_Policy_Content', 'notice')); |
|
161 | 161 | |
162 | 162 | // Add the suggested policy text from WordPress. |
163 | -add_action( 'admin_init', array( 'WP_Privacy_Policy_Content', 'add_suggested_content' ), 1 ); |
|
163 | +add_action('admin_init', array('WP_Privacy_Policy_Content', 'add_suggested_content'), 1); |
|
164 | 164 | |
165 | 165 | // Update the cached policy info when the policy page is updated. |
166 | -add_action( 'post_updated', array( 'WP_Privacy_Policy_Content', '_policy_page_updated' ) ); |
|
166 | +add_action('post_updated', array('WP_Privacy_Policy_Content', '_policy_page_updated')); |
|
167 | 167 | |
168 | 168 | // Append '(Draft)' to draft page titles in the privacy page dropdown. |
169 | -add_filter( 'list_pages', '_wp_privacy_settings_filter_draft_page_titles', 10, 2 ); |
|
169 | +add_filter('list_pages', '_wp_privacy_settings_filter_draft_page_titles', 10, 2); |
@@ -36,18 +36,18 @@ discard block |
||
36 | 36 | * @param array $args Optional. The theme upgrader skin arguments to |
37 | 37 | * override default options. Default empty array. |
38 | 38 | */ |
39 | - public function __construct( $args = array() ) { |
|
39 | + public function __construct($args = array()) { |
|
40 | 40 | $defaults = array( |
41 | 41 | 'url' => '', |
42 | 42 | 'theme' => '', |
43 | 43 | 'nonce' => '', |
44 | - 'title' => __( 'Update Theme' ), |
|
44 | + 'title' => __('Update Theme'), |
|
45 | 45 | ); |
46 | - $args = wp_parse_args( $args, $defaults ); |
|
46 | + $args = wp_parse_args($args, $defaults); |
|
47 | 47 | |
48 | 48 | $this->theme = $args['theme']; |
49 | 49 | |
50 | - parent::__construct( $args ); |
|
50 | + parent::__construct($args); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |
@@ -56,75 +56,75 @@ discard block |
||
56 | 56 | * @since 2.8.0 |
57 | 57 | */ |
58 | 58 | public function after() { |
59 | - $this->decrement_update_count( 'theme' ); |
|
59 | + $this->decrement_update_count('theme'); |
|
60 | 60 | |
61 | 61 | $update_actions = array(); |
62 | 62 | $theme_info = $this->upgrader->theme_info(); |
63 | - if ( $theme_info ) { |
|
64 | - $name = $theme_info->display( 'Name' ); |
|
63 | + if ($theme_info) { |
|
64 | + $name = $theme_info->display('Name'); |
|
65 | 65 | $stylesheet = $this->upgrader->result['destination_name']; |
66 | 66 | $template = $theme_info->get_template(); |
67 | 67 | |
68 | 68 | $activate_link = add_query_arg( |
69 | 69 | array( |
70 | 70 | 'action' => 'activate', |
71 | - 'template' => urlencode( $template ), |
|
72 | - 'stylesheet' => urlencode( $stylesheet ), |
|
71 | + 'template' => urlencode($template), |
|
72 | + 'stylesheet' => urlencode($stylesheet), |
|
73 | 73 | ), |
74 | - admin_url( 'themes.php' ) |
|
74 | + admin_url('themes.php') |
|
75 | 75 | ); |
76 | - $activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet ); |
|
76 | + $activate_link = wp_nonce_url($activate_link, 'switch-theme_' . $stylesheet); |
|
77 | 77 | |
78 | 78 | $customize_url = add_query_arg( |
79 | 79 | array( |
80 | - 'theme' => urlencode( $stylesheet ), |
|
81 | - 'return' => urlencode( admin_url( 'themes.php' ) ), |
|
80 | + 'theme' => urlencode($stylesheet), |
|
81 | + 'return' => urlencode(admin_url('themes.php')), |
|
82 | 82 | ), |
83 | - admin_url( 'customize.php' ) |
|
83 | + admin_url('customize.php') |
|
84 | 84 | ); |
85 | 85 | |
86 | - if ( get_stylesheet() === $stylesheet ) { |
|
87 | - if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { |
|
86 | + if (get_stylesheet() === $stylesheet) { |
|
87 | + if (current_user_can('edit_theme_options') && current_user_can('customize')) { |
|
88 | 88 | $update_actions['preview'] = sprintf( |
89 | 89 | '<a href="%s" class="hide-if-no-customize load-customize">' . |
90 | 90 | '<span aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>', |
91 | - esc_url( $customize_url ), |
|
92 | - __( 'Customize' ), |
|
91 | + esc_url($customize_url), |
|
92 | + __('Customize'), |
|
93 | 93 | /* translators: %s: Theme name. */ |
94 | - sprintf( __( 'Customize “%s”' ), $name ) |
|
94 | + sprintf(__('Customize “%s”'), $name) |
|
95 | 95 | ); |
96 | 96 | } |
97 | - } elseif ( current_user_can( 'switch_themes' ) ) { |
|
98 | - if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { |
|
97 | + } elseif (current_user_can('switch_themes')) { |
|
98 | + if (current_user_can('edit_theme_options') && current_user_can('customize')) { |
|
99 | 99 | $update_actions['preview'] = sprintf( |
100 | 100 | '<a href="%s" class="hide-if-no-customize load-customize">' . |
101 | 101 | '<span aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>', |
102 | - esc_url( $customize_url ), |
|
103 | - __( 'Live Preview' ), |
|
102 | + esc_url($customize_url), |
|
103 | + __('Live Preview'), |
|
104 | 104 | /* translators: %s: Theme name. */ |
105 | - sprintf( __( 'Live Preview “%s”' ), $name ) |
|
105 | + sprintf(__('Live Preview “%s”'), $name) |
|
106 | 106 | ); |
107 | 107 | } |
108 | 108 | |
109 | 109 | $update_actions['activate'] = sprintf( |
110 | 110 | '<a href="%s" class="activatelink">' . |
111 | 111 | '<span aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>', |
112 | - esc_url( $activate_link ), |
|
113 | - __( 'Activate' ), |
|
112 | + esc_url($activate_link), |
|
113 | + __('Activate'), |
|
114 | 114 | /* translators: %s: Theme name. */ |
115 | - sprintf( _x( 'Activate “%s”', 'theme' ), $name ) |
|
115 | + sprintf(_x('Activate “%s”', 'theme'), $name) |
|
116 | 116 | ); |
117 | 117 | } |
118 | 118 | |
119 | - if ( ! $this->result || is_wp_error( $this->result ) || is_network_admin() ) { |
|
120 | - unset( $update_actions['preview'], $update_actions['activate'] ); |
|
119 | + if (!$this->result || is_wp_error($this->result) || is_network_admin()) { |
|
120 | + unset($update_actions['preview'], $update_actions['activate']); |
|
121 | 121 | } |
122 | 122 | } |
123 | 123 | |
124 | 124 | $update_actions['themes_page'] = sprintf( |
125 | 125 | '<a href="%s" target="_parent">%s</a>', |
126 | - self_admin_url( 'themes.php' ), |
|
127 | - __( 'Go to Themes page' ) |
|
126 | + self_admin_url('themes.php'), |
|
127 | + __('Go to Themes page') |
|
128 | 128 | ); |
129 | 129 | |
130 | 130 | /** |
@@ -135,10 +135,10 @@ discard block |
||
135 | 135 | * @param string[] $update_actions Array of theme action links. |
136 | 136 | * @param string $theme Theme directory name. |
137 | 137 | */ |
138 | - $update_actions = apply_filters( 'update_theme_complete_actions', $update_actions, $this->theme ); |
|
138 | + $update_actions = apply_filters('update_theme_complete_actions', $update_actions, $this->theme); |
|
139 | 139 | |
140 | - if ( ! empty( $update_actions ) ) { |
|
141 | - $this->feedback( implode( ' | ', (array) $update_actions ) ); |
|
140 | + if (!empty($update_actions)) { |
|
141 | + $this->feedback(implode(' | ', (array) $update_actions)); |
|
142 | 142 | } |
143 | 143 | } |
144 | 144 | } |
@@ -99,26 +99,26 @@ discard block |
||
99 | 99 | * {@link https://developer.wordpress.org/reference/functions/plugins_api/ function reference article} |
100 | 100 | * for more information on the make-up of possible return values depending on the value of `$action`. |
101 | 101 | */ |
102 | -function plugins_api( $action, $args = array() ) { |
|
102 | +function plugins_api($action, $args = array()) { |
|
103 | 103 | // Include an unmodified $wp_version. |
104 | 104 | require ABSPATH . WPINC . '/version.php'; |
105 | 105 | |
106 | - if ( is_array( $args ) ) { |
|
106 | + if (is_array($args)) { |
|
107 | 107 | $args = (object) $args; |
108 | 108 | } |
109 | 109 | |
110 | - if ( 'query_plugins' === $action ) { |
|
111 | - if ( ! isset( $args->per_page ) ) { |
|
110 | + if ('query_plugins' === $action) { |
|
111 | + if (!isset($args->per_page)) { |
|
112 | 112 | $args->per_page = 24; |
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
116 | - if ( ! isset( $args->locale ) ) { |
|
116 | + if (!isset($args->locale)) { |
|
117 | 117 | $args->locale = get_user_locale(); |
118 | 118 | } |
119 | 119 | |
120 | - if ( ! isset( $args->wp_version ) ) { |
|
121 | - $args->wp_version = substr( $wp_version, 0, 3 ); // x.y |
|
120 | + if (!isset($args->wp_version)) { |
|
121 | + $args->wp_version = substr($wp_version, 0, 3); // x.y |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * @param object $args Plugin API arguments. |
132 | 132 | * @param string $action The type of information being requested from the Plugin Installation API. |
133 | 133 | */ |
134 | - $args = apply_filters( 'plugins_api_args', $args, $action ); |
|
134 | + $args = apply_filters('plugins_api_args', $args, $action); |
|
135 | 135 | |
136 | 136 | /** |
137 | 137 | * Filters the response for the current WordPress.org Plugin Installation API request. |
@@ -147,9 +147,9 @@ discard block |
||
147 | 147 | * @param string $action The type of information being requested from the Plugin Installation API. |
148 | 148 | * @param object $args Plugin API arguments. |
149 | 149 | */ |
150 | - $res = apply_filters( 'plugins_api', false, $action, $args ); |
|
150 | + $res = apply_filters('plugins_api', false, $action, $args); |
|
151 | 151 | |
152 | - if ( false === $res ) { |
|
152 | + if (false === $res) { |
|
153 | 153 | |
154 | 154 | $url = 'http://api.wordpress.org/plugins/info/1.2/'; |
155 | 155 | $url = add_query_arg( |
@@ -161,64 +161,64 @@ discard block |
||
161 | 161 | ); |
162 | 162 | |
163 | 163 | $http_url = $url; |
164 | - $ssl = wp_http_supports( array( 'ssl' ) ); |
|
165 | - if ( $ssl ) { |
|
166 | - $url = set_url_scheme( $url, 'https' ); |
|
164 | + $ssl = wp_http_supports(array('ssl')); |
|
165 | + if ($ssl) { |
|
166 | + $url = set_url_scheme($url, 'https'); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | $http_args = array( |
170 | 170 | 'timeout' => 15, |
171 | - 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ), |
|
171 | + 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url('/'), |
|
172 | 172 | ); |
173 | - $request = wp_remote_get( $url, $http_args ); |
|
173 | + $request = wp_remote_get($url, $http_args); |
|
174 | 174 | |
175 | - if ( $ssl && is_wp_error( $request ) ) { |
|
176 | - if ( ! wp_is_json_request() ) { |
|
175 | + if ($ssl && is_wp_error($request)) { |
|
176 | + if (!wp_is_json_request()) { |
|
177 | 177 | trigger_error( |
178 | 178 | sprintf( |
179 | 179 | /* translators: %s: Support forums URL. */ |
180 | - __( '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="%s">support forums</a>.' ), |
|
181 | - __( 'https://wordpress.org/support/forums/' ) |
|
182 | - ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ), |
|
180 | + __('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="%s">support forums</a>.'), |
|
181 | + __('https://wordpress.org/support/forums/') |
|
182 | + ) . ' ' . __('(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)'), |
|
183 | 183 | headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE |
184 | 184 | ); |
185 | 185 | } |
186 | 186 | |
187 | - $request = wp_remote_get( $http_url, $http_args ); |
|
187 | + $request = wp_remote_get($http_url, $http_args); |
|
188 | 188 | } |
189 | 189 | |
190 | - if ( is_wp_error( $request ) ) { |
|
190 | + if (is_wp_error($request)) { |
|
191 | 191 | $res = new WP_Error( |
192 | 192 | 'plugins_api_failed', |
193 | 193 | sprintf( |
194 | 194 | /* translators: %s: Support forums URL. */ |
195 | - __( '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="%s">support forums</a>.' ), |
|
196 | - __( 'https://wordpress.org/support/forums/' ) |
|
195 | + __('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="%s">support forums</a>.'), |
|
196 | + __('https://wordpress.org/support/forums/') |
|
197 | 197 | ), |
198 | 198 | $request->get_error_message() |
199 | 199 | ); |
200 | 200 | } else { |
201 | - $res = json_decode( wp_remote_retrieve_body( $request ), true ); |
|
202 | - if ( is_array( $res ) ) { |
|
201 | + $res = json_decode(wp_remote_retrieve_body($request), true); |
|
202 | + if (is_array($res)) { |
|
203 | 203 | // Object casting is required in order to match the info/1.0 format. |
204 | 204 | $res = (object) $res; |
205 | - } elseif ( null === $res ) { |
|
205 | + } elseif (null === $res) { |
|
206 | 206 | $res = new WP_Error( |
207 | 207 | 'plugins_api_failed', |
208 | 208 | sprintf( |
209 | 209 | /* translators: %s: Support forums URL. */ |
210 | - __( '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="%s">support forums</a>.' ), |
|
211 | - __( 'https://wordpress.org/support/forums/' ) |
|
210 | + __('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="%s">support forums</a>.'), |
|
211 | + __('https://wordpress.org/support/forums/') |
|
212 | 212 | ), |
213 | - wp_remote_retrieve_body( $request ) |
|
213 | + wp_remote_retrieve_body($request) |
|
214 | 214 | ); |
215 | 215 | } |
216 | 216 | |
217 | - if ( isset( $res->error ) ) { |
|
218 | - $res = new WP_Error( 'plugins_api_failed', $res->error ); |
|
217 | + if (isset($res->error)) { |
|
218 | + $res = new WP_Error('plugins_api_failed', $res->error); |
|
219 | 219 | } |
220 | 220 | } |
221 | - } elseif ( ! is_wp_error( $res ) ) { |
|
221 | + } elseif (!is_wp_error($res)) { |
|
222 | 222 | $res->external = true; |
223 | 223 | } |
224 | 224 | |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * @param string $action The type of information being requested from the Plugin Installation API. |
232 | 232 | * @param object $args Plugin API arguments. |
233 | 233 | */ |
234 | - return apply_filters( 'plugins_api_result', $res, $action, $args ); |
|
234 | + return apply_filters('plugins_api_result', $res, $action, $args); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | /** |
@@ -242,20 +242,20 @@ discard block |
||
242 | 242 | * @param array $args |
243 | 243 | * @return array|WP_Error |
244 | 244 | */ |
245 | -function install_popular_tags( $args = array() ) { |
|
246 | - $key = md5( serialize( $args ) ); |
|
247 | - $tags = get_site_transient( 'poptags_' . $key ); |
|
248 | - if ( false !== $tags ) { |
|
245 | +function install_popular_tags($args = array()) { |
|
246 | + $key = md5(serialize($args)); |
|
247 | + $tags = get_site_transient('poptags_' . $key); |
|
248 | + if (false !== $tags) { |
|
249 | 249 | return $tags; |
250 | 250 | } |
251 | 251 | |
252 | - $tags = plugins_api( 'hot_tags', $args ); |
|
252 | + $tags = plugins_api('hot_tags', $args); |
|
253 | 253 | |
254 | - if ( is_wp_error( $tags ) ) { |
|
254 | + if (is_wp_error($tags)) { |
|
255 | 255 | return $tags; |
256 | 256 | } |
257 | 257 | |
258 | - set_site_transient( 'poptags_' . $key, $tags, 3 * HOUR_IN_SECONDS ); |
|
258 | + set_site_transient('poptags_' . $key, $tags, 3 * HOUR_IN_SECONDS); |
|
259 | 259 | |
260 | 260 | return $tags; |
261 | 261 | } |
@@ -270,36 +270,36 @@ discard block |
||
270 | 270 | ?> |
271 | 271 | |
272 | 272 | <div class="plugins-popular-tags-wrapper"> |
273 | - <h2><?php _e( 'Popular tags' ); ?></h2> |
|
274 | - <p><?php _e( 'You may also browse based on the most popular tags in the Plugin Directory:' ); ?></p> |
|
273 | + <h2><?php _e('Popular tags'); ?></h2> |
|
274 | + <p><?php _e('You may also browse based on the most popular tags in the Plugin Directory:'); ?></p> |
|
275 | 275 | <?php |
276 | 276 | |
277 | 277 | $api_tags = install_popular_tags(); |
278 | 278 | |
279 | 279 | echo '<p class="popular-tags">'; |
280 | - if ( is_wp_error( $api_tags ) ) { |
|
280 | + if (is_wp_error($api_tags)) { |
|
281 | 281 | echo $api_tags->get_error_message(); |
282 | 282 | } else { |
283 | 283 | // Set up the tags in a way which can be interpreted by wp_generate_tag_cloud(). |
284 | 284 | $tags = array(); |
285 | - foreach ( (array) $api_tags as $tag ) { |
|
286 | - $url = self_admin_url( 'plugin-install.php?tab=search&type=tag&s=' . urlencode( $tag['name'] ) ); |
|
285 | + foreach ((array) $api_tags as $tag) { |
|
286 | + $url = self_admin_url('plugin-install.php?tab=search&type=tag&s=' . urlencode($tag['name'])); |
|
287 | 287 | $data = array( |
288 | - 'link' => esc_url( $url ), |
|
288 | + 'link' => esc_url($url), |
|
289 | 289 | 'name' => $tag['name'], |
290 | 290 | 'slug' => $tag['slug'], |
291 | - 'id' => sanitize_title_with_dashes( $tag['name'] ), |
|
291 | + 'id' => sanitize_title_with_dashes($tag['name']), |
|
292 | 292 | 'count' => $tag['count'], |
293 | 293 | ); |
294 | - $tags[ $tag['name'] ] = (object) $data; |
|
294 | + $tags[$tag['name']] = (object) $data; |
|
295 | 295 | } |
296 | 296 | echo wp_generate_tag_cloud( |
297 | 297 | $tags, |
298 | 298 | array( |
299 | 299 | /* translators: %s: Number of plugins. */ |
300 | - 'single_text' => __( '%s plugin' ), |
|
300 | + 'single_text' => __('%s plugin'), |
|
301 | 301 | /* translators: %s: Number of plugins. */ |
302 | - 'multiple_text' => __( '%s plugins' ), |
|
302 | + 'multiple_text' => __('%s plugins'), |
|
303 | 303 | ) |
304 | 304 | ); |
305 | 305 | } |
@@ -314,21 +314,21 @@ discard block |
||
314 | 314 | * |
315 | 315 | * @param bool $deprecated Not used. |
316 | 316 | */ |
317 | -function install_search_form( $deprecated = true ) { |
|
318 | - $type = isset( $_REQUEST['type'] ) ? wp_unslash( $_REQUEST['type'] ) : 'term'; |
|
319 | - $term = isset( $_REQUEST['s'] ) ? wp_unslash( $_REQUEST['s'] ) : ''; |
|
317 | +function install_search_form($deprecated = true) { |
|
318 | + $type = isset($_REQUEST['type']) ? wp_unslash($_REQUEST['type']) : 'term'; |
|
319 | + $term = isset($_REQUEST['s']) ? wp_unslash($_REQUEST['s']) : ''; |
|
320 | 320 | ?> |
321 | 321 | <form class="search-form search-plugins" method="get"> |
322 | 322 | <input type="hidden" name="tab" value="search" /> |
323 | - <label class="screen-reader-text" for="typeselector"><?php _e( 'Search plugins by:' ); ?></label> |
|
323 | + <label class="screen-reader-text" for="typeselector"><?php _e('Search plugins by:'); ?></label> |
|
324 | 324 | <select name="type" id="typeselector"> |
325 | - <option value="term"<?php selected( 'term', $type ); ?>><?php _e( 'Keyword' ); ?></option> |
|
326 | - <option value="author"<?php selected( 'author', $type ); ?>><?php _e( 'Author' ); ?></option> |
|
327 | - <option value="tag"<?php selected( 'tag', $type ); ?>><?php _ex( 'Tag', 'Plugin Installer' ); ?></option> |
|
325 | + <option value="term"<?php selected('term', $type); ?>><?php _e('Keyword'); ?></option> |
|
326 | + <option value="author"<?php selected('author', $type); ?>><?php _e('Author'); ?></option> |
|
327 | + <option value="tag"<?php selected('tag', $type); ?>><?php _ex('Tag', 'Plugin Installer'); ?></option> |
|
328 | 328 | </select> |
329 | - <label class="screen-reader-text" for="search-plugins"><?php _e( 'Search Plugins' ); ?></label> |
|
330 | - <input type="search" name="s" id="search-plugins" value="<?php echo esc_attr( $term ); ?>" class="wp-filter-search" placeholder="<?php esc_attr_e( 'Search plugins...' ); ?>" /> |
|
331 | - <?php submit_button( __( 'Search Plugins' ), 'hide-if-js', false, false, array( 'id' => 'search-submit' ) ); ?> |
|
329 | + <label class="screen-reader-text" for="search-plugins"><?php _e('Search Plugins'); ?></label> |
|
330 | + <input type="search" name="s" id="search-plugins" value="<?php echo esc_attr($term); ?>" class="wp-filter-search" placeholder="<?php esc_attr_e('Search plugins...'); ?>" /> |
|
331 | + <?php submit_button(__('Search Plugins'), 'hide-if-js', false, false, array('id' => 'search-submit')); ?> |
|
332 | 332 | </form> |
333 | 333 | <?php |
334 | 334 | } |
@@ -341,12 +341,12 @@ discard block |
||
341 | 341 | function install_plugins_upload() { |
342 | 342 | ?> |
343 | 343 | <div class="upload-plugin"> |
344 | - <p class="install-help"><?php _e( 'If you have a plugin in a .zip format, you may install or update it by uploading it here.' ); ?></p> |
|
345 | - <form method="post" enctype="multipart/form-data" class="wp-upload-form" action="<?php echo self_admin_url( 'update.php?action=upload-plugin' ); ?>"> |
|
346 | - <?php wp_nonce_field( 'plugin-upload' ); ?> |
|
347 | - <label class="screen-reader-text" for="pluginzip"><?php _e( 'Plugin zip file' ); ?></label> |
|
344 | + <p class="install-help"><?php _e('If you have a plugin in a .zip format, you may install or update it by uploading it here.'); ?></p> |
|
345 | + <form method="post" enctype="multipart/form-data" class="wp-upload-form" action="<?php echo self_admin_url('update.php?action=upload-plugin'); ?>"> |
|
346 | + <?php wp_nonce_field('plugin-upload'); ?> |
|
347 | + <label class="screen-reader-text" for="pluginzip"><?php _e('Plugin zip file'); ?></label> |
|
348 | 348 | <input type="file" id="pluginzip" name="pluginzip" accept=".zip" /> |
349 | - <?php submit_button( __( 'Install Now' ), '', 'install-plugin-submit', false ); ?> |
|
349 | + <?php submit_button(__('Install Now'), '', 'install-plugin-submit', false); ?> |
|
350 | 350 | </form> |
351 | 351 | </div> |
352 | 352 | <?php |
@@ -358,17 +358,17 @@ discard block |
||
358 | 358 | * @since 3.5.0 |
359 | 359 | */ |
360 | 360 | function install_plugins_favorites_form() { |
361 | - $user = get_user_option( 'wporg_favorites' ); |
|
361 | + $user = get_user_option('wporg_favorites'); |
|
362 | 362 | $action = 'save_wporg_username_' . get_current_user_id(); |
363 | 363 | ?> |
364 | - <p><?php _e( 'If you have marked plugins as favorites on WordPress.org, you can browse them here.' ); ?></p> |
|
364 | + <p><?php _e('If you have marked plugins as favorites on WordPress.org, you can browse them here.'); ?></p> |
|
365 | 365 | <form method="get"> |
366 | 366 | <input type="hidden" name="tab" value="favorites" /> |
367 | 367 | <p> |
368 | - <label for="user"><?php _e( 'Your WordPress.org username:' ); ?></label> |
|
369 | - <input type="search" id="user" name="user" value="<?php echo esc_attr( $user ); ?>" /> |
|
370 | - <input type="submit" class="button" value="<?php esc_attr_e( 'Get Favorites' ); ?>" /> |
|
371 | - <input type="hidden" id="wporg-username-nonce" name="_wpnonce" value="<?php echo esc_attr( wp_create_nonce( $action ) ); ?>" /> |
|
368 | + <label for="user"><?php _e('Your WordPress.org username:'); ?></label> |
|
369 | + <input type="search" id="user" name="user" value="<?php echo esc_attr($user); ?>" /> |
|
370 | + <input type="submit" class="button" value="<?php esc_attr_e('Get Favorites'); ?>" /> |
|
371 | + <input type="hidden" id="wporg-username-nonce" name="_wpnonce" value="<?php echo esc_attr(wp_create_nonce($action)); ?>" /> |
|
372 | 372 | </p> |
373 | 373 | </form> |
374 | 374 | <?php |
@@ -384,26 +384,26 @@ discard block |
||
384 | 384 | function display_plugins_table() { |
385 | 385 | global $wp_list_table; |
386 | 386 | |
387 | - switch ( current_filter() ) { |
|
387 | + switch (current_filter()) { |
|
388 | 388 | case 'install_plugins_beta': |
389 | 389 | printf( |
390 | 390 | /* translators: %s: URL to "Features as Plugins" page. */ |
391 | - '<p>' . __( 'You are using a development version of WordPress. These feature plugins are also under development. <a href="%s">Learn more</a>.' ) . '</p>', |
|
391 | + '<p>' . __('You are using a development version of WordPress. These feature plugins are also under development. <a href="%s">Learn more</a>.') . '</p>', |
|
392 | 392 | 'https://make.wordpress.org/core/handbook/about/release-cycle/features-as-plugins/' |
393 | 393 | ); |
394 | 394 | break; |
395 | 395 | case 'install_plugins_featured': |
396 | 396 | printf( |
397 | 397 | /* translators: %s: https://wordpress.org/plugins/ */ |
398 | - '<p>' . __( 'Plugins extend and expand the functionality of WordPress. You may automatically install plugins from the <a href="%s">WordPress Plugin Directory</a> or upload a plugin in .zip format by clicking the button at the top of this page.' ) . '</p>', |
|
399 | - __( 'https://wordpress.org/plugins/' ) |
|
398 | + '<p>' . __('Plugins extend and expand the functionality of WordPress. You may automatically install plugins from the <a href="%s">WordPress Plugin Directory</a> or upload a plugin in .zip format by clicking the button at the top of this page.') . '</p>', |
|
399 | + __('https://wordpress.org/plugins/') |
|
400 | 400 | ); |
401 | 401 | break; |
402 | 402 | case 'install_plugins_recommended': |
403 | - echo '<p>' . __( 'These suggestions are based on the plugins you and other users have installed.' ) . '</p>'; |
|
403 | + echo '<p>' . __('These suggestions are based on the plugins you and other users have installed.') . '</p>'; |
|
404 | 404 | break; |
405 | 405 | case 'install_plugins_favorites': |
406 | - if ( empty( $_GET['user'] ) && ! get_user_option( 'wporg_favorites' ) ) { |
|
406 | + if (empty($_GET['user']) && !get_user_option('wporg_favorites')) { |
|
407 | 407 | return; |
408 | 408 | } |
409 | 409 | break; |
@@ -431,9 +431,9 @@ discard block |
||
431 | 431 | * @type string $file Plugin filename relative to the plugins directory. |
432 | 432 | * } |
433 | 433 | */ |
434 | -function install_plugin_install_status( $api, $loop = false ) { |
|
434 | +function install_plugin_install_status($api, $loop = false) { |
|
435 | 435 | // This function is called recursively, $loop prevents further loops. |
436 | - if ( is_array( $api ) ) { |
|
436 | + if (is_array($api)) { |
|
437 | 437 | $api = (object) $api; |
438 | 438 | } |
439 | 439 | |
@@ -447,62 +447,62 @@ discard block |
||
447 | 447 | * Check to see if this plugin is known to be installed, |
448 | 448 | * and has an update awaiting it. |
449 | 449 | */ |
450 | - $update_plugins = get_site_transient( 'update_plugins' ); |
|
451 | - if ( isset( $update_plugins->response ) ) { |
|
452 | - foreach ( (array) $update_plugins->response as $file => $plugin ) { |
|
453 | - if ( $plugin->slug === $api->slug ) { |
|
450 | + $update_plugins = get_site_transient('update_plugins'); |
|
451 | + if (isset($update_plugins->response)) { |
|
452 | + foreach ((array) $update_plugins->response as $file => $plugin) { |
|
453 | + if ($plugin->slug === $api->slug) { |
|
454 | 454 | $status = 'update_available'; |
455 | 455 | $update_file = $file; |
456 | 456 | $version = $plugin->new_version; |
457 | - if ( current_user_can( 'update_plugins' ) ) { |
|
458 | - $url = wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' . $update_file ), 'upgrade-plugin_' . $update_file ); |
|
457 | + if (current_user_can('update_plugins')) { |
|
458 | + $url = wp_nonce_url(self_admin_url('update.php?action=upgrade-plugin&plugin=' . $update_file), 'upgrade-plugin_' . $update_file); |
|
459 | 459 | } |
460 | 460 | break; |
461 | 461 | } |
462 | 462 | } |
463 | 463 | } |
464 | 464 | |
465 | - if ( 'install' === $status ) { |
|
466 | - if ( is_dir( WP_PLUGIN_DIR . '/' . $api->slug ) ) { |
|
467 | - $installed_plugin = get_plugins( '/' . $api->slug ); |
|
468 | - if ( empty( $installed_plugin ) ) { |
|
469 | - if ( current_user_can( 'install_plugins' ) ) { |
|
470 | - $url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $api->slug ), 'install-plugin_' . $api->slug ); |
|
465 | + if ('install' === $status) { |
|
466 | + if (is_dir(WP_PLUGIN_DIR . '/' . $api->slug)) { |
|
467 | + $installed_plugin = get_plugins('/' . $api->slug); |
|
468 | + if (empty($installed_plugin)) { |
|
469 | + if (current_user_can('install_plugins')) { |
|
470 | + $url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . $api->slug), 'install-plugin_' . $api->slug); |
|
471 | 471 | } |
472 | 472 | } else { |
473 | - $key = array_keys( $installed_plugin ); |
|
473 | + $key = array_keys($installed_plugin); |
|
474 | 474 | // Use the first plugin regardless of the name. |
475 | 475 | // Could have issues for multiple plugins in one directory if they share different version numbers. |
476 | - $key = reset( $key ); |
|
476 | + $key = reset($key); |
|
477 | 477 | |
478 | 478 | $update_file = $api->slug . '/' . $key; |
479 | - if ( version_compare( $api->version, $installed_plugin[ $key ]['Version'], '=' ) ) { |
|
479 | + if (version_compare($api->version, $installed_plugin[$key]['Version'], '=')) { |
|
480 | 480 | $status = 'latest_installed'; |
481 | - } elseif ( version_compare( $api->version, $installed_plugin[ $key ]['Version'], '<' ) ) { |
|
481 | + } elseif (version_compare($api->version, $installed_plugin[$key]['Version'], '<')) { |
|
482 | 482 | $status = 'newer_installed'; |
483 | - $version = $installed_plugin[ $key ]['Version']; |
|
483 | + $version = $installed_plugin[$key]['Version']; |
|
484 | 484 | } else { |
485 | 485 | // If the above update check failed, then that probably means that the update checker has out-of-date information, force a refresh. |
486 | - if ( ! $loop ) { |
|
487 | - delete_site_transient( 'update_plugins' ); |
|
486 | + if (!$loop) { |
|
487 | + delete_site_transient('update_plugins'); |
|
488 | 488 | wp_update_plugins(); |
489 | - return install_plugin_install_status( $api, true ); |
|
489 | + return install_plugin_install_status($api, true); |
|
490 | 490 | } |
491 | 491 | } |
492 | 492 | } |
493 | 493 | } else { |
494 | 494 | // "install" & no directory with that slug. |
495 | - if ( current_user_can( 'install_plugins' ) ) { |
|
496 | - $url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $api->slug ), 'install-plugin_' . $api->slug ); |
|
495 | + if (current_user_can('install_plugins')) { |
|
496 | + $url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . $api->slug), 'install-plugin_' . $api->slug); |
|
497 | 497 | } |
498 | 498 | } |
499 | 499 | } |
500 | - if ( isset( $_GET['from'] ) ) { |
|
501 | - $url .= '&from=' . urlencode( wp_unslash( $_GET['from'] ) ); |
|
500 | + if (isset($_GET['from'])) { |
|
501 | + $url .= '&from=' . urlencode(wp_unslash($_GET['from'])); |
|
502 | 502 | } |
503 | 503 | |
504 | 504 | $file = $update_file; |
505 | - return compact( 'status', 'url', 'version', 'file' ); |
|
505 | + return compact('status', 'url', 'version', 'file'); |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | /** |
@@ -515,19 +515,19 @@ discard block |
||
515 | 515 | function install_plugin_information() { |
516 | 516 | global $tab; |
517 | 517 | |
518 | - if ( empty( $_REQUEST['plugin'] ) ) { |
|
518 | + if (empty($_REQUEST['plugin'])) { |
|
519 | 519 | return; |
520 | 520 | } |
521 | 521 | |
522 | 522 | $api = plugins_api( |
523 | 523 | 'plugin_information', |
524 | 524 | array( |
525 | - 'slug' => wp_unslash( $_REQUEST['plugin'] ), |
|
525 | + 'slug' => wp_unslash($_REQUEST['plugin']), |
|
526 | 526 | ) |
527 | 527 | ); |
528 | 528 | |
529 | - if ( is_wp_error( $api ) ) { |
|
530 | - wp_die( $api ); |
|
529 | + if (is_wp_error($api)) { |
|
530 | + wp_die($api); |
|
531 | 531 | } |
532 | 532 | |
533 | 533 | $plugins_allowedtags = array( |
@@ -536,14 +536,14 @@ discard block |
||
536 | 536 | 'title' => array(), |
537 | 537 | 'target' => array(), |
538 | 538 | ), |
539 | - 'abbr' => array( 'title' => array() ), |
|
540 | - 'acronym' => array( 'title' => array() ), |
|
539 | + 'abbr' => array('title' => array()), |
|
540 | + 'acronym' => array('title' => array()), |
|
541 | 541 | 'code' => array(), |
542 | 542 | 'pre' => array(), |
543 | 543 | 'em' => array(), |
544 | 544 | 'strong' => array(), |
545 | - 'div' => array( 'class' => array() ), |
|
546 | - 'span' => array( 'class' => array() ), |
|
545 | + 'div' => array('class' => array()), |
|
546 | + 'span' => array('class' => array()), |
|
547 | 547 | 'p' => array(), |
548 | 548 | 'br' => array(), |
549 | 549 | 'ul' => array(), |
@@ -560,55 +560,55 @@ discard block |
||
560 | 560 | 'class' => array(), |
561 | 561 | 'alt' => array(), |
562 | 562 | ), |
563 | - 'blockquote' => array( 'cite' => true ), |
|
563 | + 'blockquote' => array('cite' => true), |
|
564 | 564 | ); |
565 | 565 | |
566 | 566 | $plugins_section_titles = array( |
567 | - 'description' => _x( 'Description', 'Plugin installer section title' ), |
|
568 | - 'installation' => _x( 'Installation', 'Plugin installer section title' ), |
|
569 | - 'faq' => _x( 'FAQ', 'Plugin installer section title' ), |
|
570 | - 'screenshots' => _x( 'Screenshots', 'Plugin installer section title' ), |
|
571 | - 'changelog' => _x( 'Changelog', 'Plugin installer section title' ), |
|
572 | - 'reviews' => _x( 'Reviews', 'Plugin installer section title' ), |
|
573 | - 'other_notes' => _x( 'Other Notes', 'Plugin installer section title' ), |
|
567 | + 'description' => _x('Description', 'Plugin installer section title'), |
|
568 | + 'installation' => _x('Installation', 'Plugin installer section title'), |
|
569 | + 'faq' => _x('FAQ', 'Plugin installer section title'), |
|
570 | + 'screenshots' => _x('Screenshots', 'Plugin installer section title'), |
|
571 | + 'changelog' => _x('Changelog', 'Plugin installer section title'), |
|
572 | + 'reviews' => _x('Reviews', 'Plugin installer section title'), |
|
573 | + 'other_notes' => _x('Other Notes', 'Plugin installer section title'), |
|
574 | 574 | ); |
575 | 575 | |
576 | 576 | // Sanitize HTML. |
577 | - foreach ( (array) $api->sections as $section_name => $content ) { |
|
578 | - $api->sections[ $section_name ] = wp_kses( $content, $plugins_allowedtags ); |
|
577 | + foreach ((array) $api->sections as $section_name => $content) { |
|
578 | + $api->sections[$section_name] = wp_kses($content, $plugins_allowedtags); |
|
579 | 579 | } |
580 | 580 | |
581 | - foreach ( array( 'version', 'author', 'requires', 'tested', 'homepage', 'downloaded', 'slug' ) as $key ) { |
|
582 | - if ( isset( $api->$key ) ) { |
|
583 | - $api->$key = wp_kses( $api->$key, $plugins_allowedtags ); |
|
581 | + foreach (array('version', 'author', 'requires', 'tested', 'homepage', 'downloaded', 'slug') as $key) { |
|
582 | + if (isset($api->$key)) { |
|
583 | + $api->$key = wp_kses($api->$key, $plugins_allowedtags); |
|
584 | 584 | } |
585 | 585 | } |
586 | 586 | |
587 | - $_tab = esc_attr( $tab ); |
|
587 | + $_tab = esc_attr($tab); |
|
588 | 588 | |
589 | 589 | // Default to the Description tab, Do not translate, API returns English. |
590 | - $section = isset( $_REQUEST['section'] ) ? wp_unslash( $_REQUEST['section'] ) : 'description'; |
|
591 | - if ( empty( $section ) || ! isset( $api->sections[ $section ] ) ) { |
|
592 | - $section_titles = array_keys( (array) $api->sections ); |
|
593 | - $section = reset( $section_titles ); |
|
590 | + $section = isset($_REQUEST['section']) ? wp_unslash($_REQUEST['section']) : 'description'; |
|
591 | + if (empty($section) || !isset($api->sections[$section])) { |
|
592 | + $section_titles = array_keys((array) $api->sections); |
|
593 | + $section = reset($section_titles); |
|
594 | 594 | } |
595 | 595 | |
596 | - iframe_header( __( 'Plugin Installation' ) ); |
|
596 | + iframe_header(__('Plugin Installation')); |
|
597 | 597 | |
598 | 598 | $_with_banner = ''; |
599 | 599 | |
600 | - if ( ! empty( $api->banners ) && ( ! empty( $api->banners['low'] ) || ! empty( $api->banners['high'] ) ) ) { |
|
600 | + if (!empty($api->banners) && (!empty($api->banners['low']) || !empty($api->banners['high']))) { |
|
601 | 601 | $_with_banner = 'with-banner'; |
602 | - $low = empty( $api->banners['low'] ) ? $api->banners['high'] : $api->banners['low']; |
|
603 | - $high = empty( $api->banners['high'] ) ? $api->banners['low'] : $api->banners['high']; |
|
602 | + $low = empty($api->banners['low']) ? $api->banners['high'] : $api->banners['low']; |
|
603 | + $high = empty($api->banners['high']) ? $api->banners['low'] : $api->banners['high']; |
|
604 | 604 | ?> |
605 | 605 | <style type="text/css"> |
606 | 606 | #plugin-information-title.with-banner { |
607 | - background-image: url( <?php echo esc_url( $low ); ?> ); |
|
607 | + background-image: url( <?php echo esc_url($low); ?> ); |
|
608 | 608 | } |
609 | 609 | @media only screen and ( -webkit-min-device-pixel-ratio: 1.5 ) { |
610 | 610 | #plugin-information-title.with-banner { |
611 | - background-image: url( <?php echo esc_url( $high ); ?> ); |
|
611 | + background-image: url( <?php echo esc_url($high); ?> ); |
|
612 | 612 | } |
613 | 613 | } |
614 | 614 | </style> |
@@ -619,26 +619,26 @@ discard block |
||
619 | 619 | echo "<div id='{$_tab}-title' class='{$_with_banner}'><div class='vignette'></div><h2>{$api->name}</h2></div>"; |
620 | 620 | echo "<div id='{$_tab}-tabs' class='{$_with_banner}'>\n"; |
621 | 621 | |
622 | - foreach ( (array) $api->sections as $section_name => $content ) { |
|
623 | - if ( 'reviews' === $section_name && ( empty( $api->ratings ) || 0 === array_sum( (array) $api->ratings ) ) ) { |
|
622 | + foreach ((array) $api->sections as $section_name => $content) { |
|
623 | + if ('reviews' === $section_name && (empty($api->ratings) || 0 === array_sum((array) $api->ratings))) { |
|
624 | 624 | continue; |
625 | 625 | } |
626 | 626 | |
627 | - if ( isset( $plugins_section_titles[ $section_name ] ) ) { |
|
628 | - $title = $plugins_section_titles[ $section_name ]; |
|
627 | + if (isset($plugins_section_titles[$section_name])) { |
|
628 | + $title = $plugins_section_titles[$section_name]; |
|
629 | 629 | } else { |
630 | - $title = ucwords( str_replace( '_', ' ', $section_name ) ); |
|
630 | + $title = ucwords(str_replace('_', ' ', $section_name)); |
|
631 | 631 | } |
632 | 632 | |
633 | - $class = ( $section_name === $section ) ? ' class="current"' : ''; |
|
633 | + $class = ($section_name === $section) ? ' class="current"' : ''; |
|
634 | 634 | $href = add_query_arg( |
635 | 635 | array( |
636 | 636 | 'tab' => $tab, |
637 | 637 | 'section' => $section_name, |
638 | 638 | ) |
639 | 639 | ); |
640 | - $href = esc_url( $href ); |
|
641 | - $san_section = esc_attr( $section_name ); |
|
640 | + $href = esc_url($href); |
|
641 | + $san_section = esc_attr($section_name); |
|
642 | 642 | echo "\t<a name='$san_section' href='$href' $class>$title</a>\n"; |
643 | 643 | } |
644 | 644 | |
@@ -648,62 +648,62 @@ discard block |
||
648 | 648 | <div id="<?php echo $_tab; ?>-content" class='<?php echo $_with_banner; ?>'> |
649 | 649 | <div class="fyi"> |
650 | 650 | <ul> |
651 | - <?php if ( ! empty( $api->version ) ) { ?> |
|
652 | - <li><strong><?php _e( 'Version:' ); ?></strong> <?php echo $api->version; ?></li> |
|
653 | - <?php } if ( ! empty( $api->author ) ) { ?> |
|
654 | - <li><strong><?php _e( 'Author:' ); ?></strong> <?php echo links_add_target( $api->author, '_blank' ); ?></li> |
|
655 | - <?php } if ( ! empty( $api->last_updated ) ) { ?> |
|
656 | - <li><strong><?php _e( 'Last Updated:' ); ?></strong> |
|
651 | + <?php if (!empty($api->version)) { ?> |
|
652 | + <li><strong><?php _e('Version:'); ?></strong> <?php echo $api->version; ?></li> |
|
653 | + <?php } if (!empty($api->author)) { ?> |
|
654 | + <li><strong><?php _e('Author:'); ?></strong> <?php echo links_add_target($api->author, '_blank'); ?></li> |
|
655 | + <?php } if (!empty($api->last_updated)) { ?> |
|
656 | + <li><strong><?php _e('Last Updated:'); ?></strong> |
|
657 | 657 | <?php |
658 | 658 | /* translators: %s: Human-readable time difference. */ |
659 | - printf( __( '%s ago' ), human_time_diff( strtotime( $api->last_updated ) ) ); |
|
659 | + printf(__('%s ago'), human_time_diff(strtotime($api->last_updated))); |
|
660 | 660 | ?> |
661 | 661 | </li> |
662 | - <?php } if ( ! empty( $api->requires ) ) { ?> |
|
662 | + <?php } if (!empty($api->requires)) { ?> |
|
663 | 663 | <li> |
664 | - <strong><?php _e( 'Requires WordPress Version:' ); ?></strong> |
|
664 | + <strong><?php _e('Requires WordPress Version:'); ?></strong> |
|
665 | 665 | <?php |
666 | 666 | /* translators: %s: Version number. */ |
667 | - printf( __( '%s or higher' ), $api->requires ); |
|
667 | + printf(__('%s or higher'), $api->requires); |
|
668 | 668 | ?> |
669 | 669 | </li> |
670 | - <?php } if ( ! empty( $api->tested ) ) { ?> |
|
671 | - <li><strong><?php _e( 'Compatible up to:' ); ?></strong> <?php echo $api->tested; ?></li> |
|
672 | - <?php } if ( ! empty( $api->requires_php ) ) { ?> |
|
670 | + <?php } if (!empty($api->tested)) { ?> |
|
671 | + <li><strong><?php _e('Compatible up to:'); ?></strong> <?php echo $api->tested; ?></li> |
|
672 | + <?php } if (!empty($api->requires_php)) { ?> |
|
673 | 673 | <li> |
674 | - <strong><?php _e( 'Requires PHP Version:' ); ?></strong> |
|
674 | + <strong><?php _e('Requires PHP Version:'); ?></strong> |
|
675 | 675 | <?php |
676 | 676 | /* translators: %s: Version number. */ |
677 | - printf( __( '%s or higher' ), $api->requires_php ); |
|
677 | + printf(__('%s or higher'), $api->requires_php); |
|
678 | 678 | ?> |
679 | 679 | </li> |
680 | - <?php } if ( isset( $api->active_installs ) ) { ?> |
|
681 | - <li><strong><?php _e( 'Active Installations:' ); ?></strong> |
|
680 | + <?php } if (isset($api->active_installs)) { ?> |
|
681 | + <li><strong><?php _e('Active Installations:'); ?></strong> |
|
682 | 682 | <?php |
683 | - if ( $api->active_installs >= 1000000 ) { |
|
684 | - $active_installs_millions = floor( $api->active_installs / 1000000 ); |
|
683 | + if ($api->active_installs >= 1000000) { |
|
684 | + $active_installs_millions = floor($api->active_installs / 1000000); |
|
685 | 685 | printf( |
686 | 686 | /* translators: %s: Number of millions. */ |
687 | - _nx( '%s+ Million', '%s+ Million', $active_installs_millions, 'Active plugin installations' ), |
|
688 | - number_format_i18n( $active_installs_millions ) |
|
687 | + _nx('%s+ Million', '%s+ Million', $active_installs_millions, 'Active plugin installations'), |
|
688 | + number_format_i18n($active_installs_millions) |
|
689 | 689 | ); |
690 | - } elseif ( $api->active_installs < 10 ) { |
|
691 | - _ex( 'Less Than 10', 'Active plugin installations' ); |
|
690 | + } elseif ($api->active_installs < 10) { |
|
691 | + _ex('Less Than 10', 'Active plugin installations'); |
|
692 | 692 | } else { |
693 | - echo number_format_i18n( $api->active_installs ) . '+'; |
|
693 | + echo number_format_i18n($api->active_installs) . '+'; |
|
694 | 694 | } |
695 | 695 | ?> |
696 | 696 | </li> |
697 | - <?php } if ( ! empty( $api->slug ) && empty( $api->external ) ) { ?> |
|
698 | - <li><a target="_blank" href="<?php echo esc_url( __( 'https://wordpress.org/plugins/' ) . $api->slug ); ?>/"><?php _e( 'WordPress.org Plugin Page »' ); ?></a></li> |
|
699 | - <?php } if ( ! empty( $api->homepage ) ) { ?> |
|
700 | - <li><a target="_blank" href="<?php echo esc_url( $api->homepage ); ?>"><?php _e( 'Plugin Homepage »' ); ?></a></li> |
|
701 | - <?php } if ( ! empty( $api->donate_link ) && empty( $api->contributors ) ) { ?> |
|
702 | - <li><a target="_blank" href="<?php echo esc_url( $api->donate_link ); ?>"><?php _e( 'Donate to this plugin »' ); ?></a></li> |
|
697 | + <?php } if (!empty($api->slug) && empty($api->external)) { ?> |
|
698 | + <li><a target="_blank" href="<?php echo esc_url(__('https://wordpress.org/plugins/') . $api->slug); ?>/"><?php _e('WordPress.org Plugin Page »'); ?></a></li> |
|
699 | + <?php } if (!empty($api->homepage)) { ?> |
|
700 | + <li><a target="_blank" href="<?php echo esc_url($api->homepage); ?>"><?php _e('Plugin Homepage »'); ?></a></li> |
|
701 | + <?php } if (!empty($api->donate_link) && empty($api->contributors)) { ?> |
|
702 | + <li><a target="_blank" href="<?php echo esc_url($api->donate_link); ?>"><?php _e('Donate to this plugin »'); ?></a></li> |
|
703 | 703 | <?php } ?> |
704 | 704 | </ul> |
705 | - <?php if ( ! empty( $api->rating ) ) { ?> |
|
706 | - <h3><?php _e( 'Average Rating' ); ?></h3> |
|
705 | + <?php if (!empty($api->rating)) { ?> |
|
706 | + <h3><?php _e('Average Rating'); ?></h3> |
|
707 | 707 | <?php |
708 | 708 | wp_star_rating( |
709 | 709 | array( |
@@ -717,22 +717,22 @@ discard block |
||
717 | 717 | <?php |
718 | 718 | printf( |
719 | 719 | /* translators: %s: Number of ratings. */ |
720 | - _n( '(based on %s rating)', '(based on %s ratings)', $api->num_ratings ), |
|
721 | - number_format_i18n( $api->num_ratings ) |
|
720 | + _n('(based on %s rating)', '(based on %s ratings)', $api->num_ratings), |
|
721 | + number_format_i18n($api->num_ratings) |
|
722 | 722 | ); |
723 | 723 | ?> |
724 | 724 | </p> |
725 | 725 | <?php |
726 | 726 | } |
727 | 727 | |
728 | - if ( ! empty( $api->ratings ) && array_sum( (array) $api->ratings ) > 0 ) { |
|
728 | + if (!empty($api->ratings) && array_sum((array) $api->ratings) > 0) { |
|
729 | 729 | ?> |
730 | - <h3><?php _e( 'Reviews' ); ?></h3> |
|
731 | - <p class="fyi-description"><?php _e( 'Read all reviews on WordPress.org or write your own!' ); ?></p> |
|
730 | + <h3><?php _e('Reviews'); ?></h3> |
|
731 | + <p class="fyi-description"><?php _e('Read all reviews on WordPress.org or write your own!'); ?></p> |
|
732 | 732 | <?php |
733 | - foreach ( $api->ratings as $key => $ratecount ) { |
|
733 | + foreach ($api->ratings as $key => $ratecount) { |
|
734 | 734 | // Avoid div-by-zero. |
735 | - $_rating = $api->num_ratings ? ( $ratecount / $api->num_ratings ) : 0; |
|
735 | + $_rating = $api->num_ratings ? ($ratecount / $api->num_ratings) : 0; |
|
736 | 736 | $aria_label = esc_attr( |
737 | 737 | sprintf( |
738 | 738 | /* translators: 1: Number of stars (used to determine singular/plural), 2: Number of reviews. */ |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | $key |
743 | 743 | ), |
744 | 744 | $key, |
745 | - number_format_i18n( $ratecount ) |
|
745 | + number_format_i18n($ratecount) |
|
746 | 746 | ) |
747 | 747 | ); |
748 | 748 | ?> |
@@ -754,92 +754,92 @@ discard block |
||
754 | 754 | "https://wordpress.org/support/plugin/{$api->slug}/reviews/?filter={$key}", |
755 | 755 | $aria_label, |
756 | 756 | /* translators: %s: Number of stars. */ |
757 | - sprintf( _n( '%d star', '%d stars', $key ), $key ) |
|
757 | + sprintf(_n('%d star', '%d stars', $key), $key) |
|
758 | 758 | ); |
759 | 759 | ?> |
760 | 760 | </span> |
761 | 761 | <span class="counter-back"> |
762 | 762 | <span class="counter-bar" style="width: <?php echo 92 * $_rating; ?>px;"></span> |
763 | 763 | </span> |
764 | - <span class="counter-count" aria-hidden="true"><?php echo number_format_i18n( $ratecount ); ?></span> |
|
764 | + <span class="counter-count" aria-hidden="true"><?php echo number_format_i18n($ratecount); ?></span> |
|
765 | 765 | </div> |
766 | 766 | <?php |
767 | 767 | } |
768 | 768 | } |
769 | - if ( ! empty( $api->contributors ) ) { |
|
769 | + if (!empty($api->contributors)) { |
|
770 | 770 | ?> |
771 | - <h3><?php _e( 'Contributors' ); ?></h3> |
|
771 | + <h3><?php _e('Contributors'); ?></h3> |
|
772 | 772 | <ul class="contributors"> |
773 | 773 | <?php |
774 | - foreach ( (array) $api->contributors as $contrib_username => $contrib_details ) { |
|
774 | + foreach ((array) $api->contributors as $contrib_username => $contrib_details) { |
|
775 | 775 | $contrib_name = $contrib_details['display_name']; |
776 | - if ( ! $contrib_name ) { |
|
776 | + if (!$contrib_name) { |
|
777 | 777 | $contrib_name = $contrib_username; |
778 | 778 | } |
779 | - $contrib_name = esc_html( $contrib_name ); |
|
779 | + $contrib_name = esc_html($contrib_name); |
|
780 | 780 | |
781 | - $contrib_profile = esc_url( $contrib_details['profile'] ); |
|
782 | - $contrib_avatar = esc_url( add_query_arg( 's', '36', $contrib_details['avatar'] ) ); |
|
781 | + $contrib_profile = esc_url($contrib_details['profile']); |
|
782 | + $contrib_avatar = esc_url(add_query_arg('s', '36', $contrib_details['avatar'])); |
|
783 | 783 | |
784 | 784 | echo "<li><a href='{$contrib_profile}' target='_blank'><img src='{$contrib_avatar}' width='18' height='18' alt='' />{$contrib_name}</a></li>"; |
785 | 785 | } |
786 | 786 | ?> |
787 | 787 | </ul> |
788 | - <?php if ( ! empty( $api->donate_link ) ) { ?> |
|
789 | - <a target="_blank" href="<?php echo esc_url( $api->donate_link ); ?>"><?php _e( 'Donate to this plugin »' ); ?></a> |
|
788 | + <?php if (!empty($api->donate_link)) { ?> |
|
789 | + <a target="_blank" href="<?php echo esc_url($api->donate_link); ?>"><?php _e('Donate to this plugin »'); ?></a> |
|
790 | 790 | <?php } ?> |
791 | 791 | <?php } ?> |
792 | 792 | </div> |
793 | 793 | <div id="section-holder"> |
794 | 794 | <?php |
795 | - $requires_php = isset( $api->requires_php ) ? $api->requires_php : null; |
|
796 | - $requires_wp = isset( $api->requires ) ? $api->requires : null; |
|
795 | + $requires_php = isset($api->requires_php) ? $api->requires_php : null; |
|
796 | + $requires_wp = isset($api->requires) ? $api->requires : null; |
|
797 | 797 | |
798 | - $compatible_php = is_php_version_compatible( $requires_php ); |
|
799 | - $compatible_wp = is_wp_version_compatible( $requires_wp ); |
|
800 | - $tested_wp = ( empty( $api->tested ) || version_compare( get_bloginfo( 'version' ), $api->tested, '<=' ) ); |
|
798 | + $compatible_php = is_php_version_compatible($requires_php); |
|
799 | + $compatible_wp = is_wp_version_compatible($requires_wp); |
|
800 | + $tested_wp = (empty($api->tested) || version_compare(get_bloginfo('version'), $api->tested, '<=')); |
|
801 | 801 | |
802 | - if ( ! $compatible_php ) { |
|
802 | + if (!$compatible_php) { |
|
803 | 803 | echo '<div class="notice notice-error notice-alt"><p>'; |
804 | - _e( '<strong>Error:</strong> This plugin <strong>requires a newer version of PHP</strong>.' ); |
|
805 | - if ( current_user_can( 'update_php' ) ) { |
|
804 | + _e('<strong>Error:</strong> This plugin <strong>requires a newer version of PHP</strong>.'); |
|
805 | + if (current_user_can('update_php')) { |
|
806 | 806 | printf( |
807 | 807 | /* translators: %s: URL to Update PHP page. */ |
808 | - ' ' . __( '<a href="%s" target="_blank">Click here to learn more about updating PHP</a>.' ), |
|
809 | - esc_url( wp_get_update_php_url() ) |
|
808 | + ' ' . __('<a href="%s" target="_blank">Click here to learn more about updating PHP</a>.'), |
|
809 | + esc_url(wp_get_update_php_url()) |
|
810 | 810 | ); |
811 | 811 | |
812 | - wp_update_php_annotation( '</p><p><em>', '</em>' ); |
|
812 | + wp_update_php_annotation('</p><p><em>', '</em>'); |
|
813 | 813 | } else { |
814 | 814 | echo '</p>'; |
815 | 815 | } |
816 | 816 | echo '</div>'; |
817 | 817 | } |
818 | 818 | |
819 | - if ( ! $tested_wp ) { |
|
819 | + if (!$tested_wp) { |
|
820 | 820 | echo '<div class="notice notice-warning notice-alt"><p>'; |
821 | - _e( '<strong>Warning:</strong> This plugin <strong>has not been tested</strong> with your current version of WordPress.' ); |
|
821 | + _e('<strong>Warning:</strong> This plugin <strong>has not been tested</strong> with your current version of WordPress.'); |
|
822 | 822 | echo '</p></div>'; |
823 | - } elseif ( ! $compatible_wp ) { |
|
823 | + } elseif (!$compatible_wp) { |
|
824 | 824 | echo '<div class="notice notice-error notice-alt"><p>'; |
825 | - _e( '<strong>Error:</strong> This plugin <strong>requires a newer version of WordPress</strong>.' ); |
|
826 | - if ( current_user_can( 'update_core' ) ) { |
|
825 | + _e('<strong>Error:</strong> This plugin <strong>requires a newer version of WordPress</strong>.'); |
|
826 | + if (current_user_can('update_core')) { |
|
827 | 827 | printf( |
828 | 828 | /* translators: %s: URL to WordPress Updates screen. */ |
829 | - ' ' . __( '<a href="%s" target="_parent">Click here to update WordPress</a>.' ), |
|
830 | - self_admin_url( 'update-core.php' ) |
|
829 | + ' ' . __('<a href="%s" target="_parent">Click here to update WordPress</a>.'), |
|
830 | + self_admin_url('update-core.php') |
|
831 | 831 | ); |
832 | 832 | } |
833 | 833 | echo '</p></div>'; |
834 | 834 | } |
835 | 835 | |
836 | - foreach ( (array) $api->sections as $section_name => $content ) { |
|
837 | - $content = links_add_base_url( $content, 'https://wordpress.org/plugins/' . $api->slug . '/' ); |
|
838 | - $content = links_add_target( $content, '_blank' ); |
|
836 | + foreach ((array) $api->sections as $section_name => $content) { |
|
837 | + $content = links_add_base_url($content, 'https://wordpress.org/plugins/' . $api->slug . '/'); |
|
838 | + $content = links_add_target($content, '_blank'); |
|
839 | 839 | |
840 | - $san_section = esc_attr( $section_name ); |
|
840 | + $san_section = esc_attr($section_name); |
|
841 | 841 | |
842 | - $display = ( $section_name === $section ) ? 'block' : 'none'; |
|
842 | + $display = ($section_name === $section) ? 'block' : 'none'; |
|
843 | 843 | |
844 | 844 | echo "\t<div id='section-{$san_section}' class='section' style='display: {$display};'>\n"; |
845 | 845 | echo $content; |
@@ -849,39 +849,39 @@ discard block |
||
849 | 849 | echo "</div>\n"; |
850 | 850 | echo "</div>\n"; // #plugin-information-scrollable |
851 | 851 | echo "<div id='$tab-footer'>\n"; |
852 | - if ( ! empty( $api->download_link ) && ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) ) { |
|
853 | - $status = install_plugin_install_status( $api ); |
|
854 | - switch ( $status['status'] ) { |
|
852 | + if (!empty($api->download_link) && (current_user_can('install_plugins') || current_user_can('update_plugins'))) { |
|
853 | + $status = install_plugin_install_status($api); |
|
854 | + switch ($status['status']) { |
|
855 | 855 | case 'install': |
856 | - if ( $status['url'] ) { |
|
857 | - if ( $compatible_php && $compatible_wp ) { |
|
858 | - echo '<a data-slug="' . esc_attr( $api->slug ) . '" id="plugin_install_from_iframe" class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __( 'Install Now' ) . '</a>'; |
|
856 | + if ($status['url']) { |
|
857 | + if ($compatible_php && $compatible_wp) { |
|
858 | + echo '<a data-slug="' . esc_attr($api->slug) . '" id="plugin_install_from_iframe" class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __('Install Now') . '</a>'; |
|
859 | 859 | } else { |
860 | 860 | printf( |
861 | 861 | '<button type="button" class="button button-primary button-disabled right" disabled="disabled">%s</button>', |
862 | - _x( 'Cannot Install', 'plugin' ) |
|
862 | + _x('Cannot Install', 'plugin') |
|
863 | 863 | ); |
864 | 864 | } |
865 | 865 | } |
866 | 866 | break; |
867 | 867 | case 'update_available': |
868 | - if ( $status['url'] ) { |
|
869 | - if ( $compatible_php ) { |
|
870 | - echo '<a data-slug="' . esc_attr( $api->slug ) . '" data-plugin="' . esc_attr( $status['file'] ) . '" id="plugin_update_from_iframe" class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __( 'Install Update Now' ) . '</a>'; |
|
868 | + if ($status['url']) { |
|
869 | + if ($compatible_php) { |
|
870 | + echo '<a data-slug="' . esc_attr($api->slug) . '" data-plugin="' . esc_attr($status['file']) . '" id="plugin_update_from_iframe" class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __('Install Update Now') . '</a>'; |
|
871 | 871 | } else { |
872 | 872 | printf( |
873 | 873 | '<button type="button" class="button button-primary button-disabled right" disabled="disabled">%s</button>', |
874 | - _x( 'Cannot Update', 'plugin' ) |
|
874 | + _x('Cannot Update', 'plugin') |
|
875 | 875 | ); |
876 | 876 | } |
877 | 877 | } |
878 | 878 | break; |
879 | 879 | case 'newer_installed': |
880 | 880 | /* translators: %s: Plugin version. */ |
881 | - echo '<a class="button button-primary right disabled">' . sprintf( __( 'Newer Version (%s) Installed' ), esc_html( $status['version'] ) ) . '</a>'; |
|
881 | + echo '<a class="button button-primary right disabled">' . sprintf(__('Newer Version (%s) Installed'), esc_html($status['version'])) . '</a>'; |
|
882 | 882 | break; |
883 | 883 | case 'latest_installed': |
884 | - echo '<a class="button button-primary right disabled">' . __( 'Latest Version Installed' ) . '</a>'; |
|
884 | + echo '<a class="button button-primary right disabled">' . __('Latest Version Installed') . '</a>'; |
|
885 | 885 | break; |
886 | 886 | } |
887 | 887 | } |
@@ -44,16 +44,16 @@ discard block |
||
44 | 44 | * @param callable $admin_header_callback |
45 | 45 | * @param callable $admin_image_div_callback Optional custom image div output callback. |
46 | 46 | */ |
47 | - public function __construct( $admin_header_callback = '', $admin_image_div_callback = '' ) { |
|
47 | + public function __construct($admin_header_callback = '', $admin_image_div_callback = '') { |
|
48 | 48 | $this->admin_header_callback = $admin_header_callback; |
49 | 49 | $this->admin_image_div_callback = $admin_image_div_callback; |
50 | 50 | |
51 | - add_action( 'admin_menu', array( $this, 'init' ) ); |
|
51 | + add_action('admin_menu', array($this, 'init')); |
|
52 | 52 | |
53 | - add_action( 'wp_ajax_custom-background-add', array( $this, 'ajax_background_add' ) ); |
|
53 | + add_action('wp_ajax_custom-background-add', array($this, 'ajax_background_add')); |
|
54 | 54 | |
55 | 55 | // Unused since 3.5.0. |
56 | - add_action( 'wp_ajax_set-background-image', array( $this, 'wp_set_background_image' ) ); |
|
56 | + add_action('wp_ajax_set-background-image', array($this, 'wp_set_background_image')); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -62,17 +62,17 @@ discard block |
||
62 | 62 | * @since 3.0.0 |
63 | 63 | */ |
64 | 64 | public function init() { |
65 | - $page = add_theme_page( __( 'Background' ), __( 'Background' ), 'edit_theme_options', 'custom-background', array( $this, 'admin_page' ) ); |
|
66 | - if ( ! $page ) { |
|
65 | + $page = add_theme_page(__('Background'), __('Background'), 'edit_theme_options', 'custom-background', array($this, 'admin_page')); |
|
66 | + if (!$page) { |
|
67 | 67 | return; |
68 | 68 | } |
69 | 69 | |
70 | - add_action( "load-{$page}", array( $this, 'admin_load' ) ); |
|
71 | - add_action( "load-{$page}", array( $this, 'take_action' ), 49 ); |
|
72 | - add_action( "load-{$page}", array( $this, 'handle_upload' ), 49 ); |
|
70 | + add_action("load-{$page}", array($this, 'admin_load')); |
|
71 | + add_action("load-{$page}", array($this, 'take_action'), 49); |
|
72 | + add_action("load-{$page}", array($this, 'handle_upload'), 49); |
|
73 | 73 | |
74 | - if ( $this->admin_header_callback ) { |
|
75 | - add_action( "admin_head-{$page}", $this->admin_header_callback, 51 ); |
|
74 | + if ($this->admin_header_callback) { |
|
75 | + add_action("admin_head-{$page}", $this->admin_header_callback, 51); |
|
76 | 76 | } |
77 | 77 | } |
78 | 78 | |
@@ -85,24 +85,24 @@ discard block |
||
85 | 85 | get_current_screen()->add_help_tab( |
86 | 86 | array( |
87 | 87 | 'id' => 'overview', |
88 | - 'title' => __( 'Overview' ), |
|
88 | + 'title' => __('Overview'), |
|
89 | 89 | 'content' => |
90 | - '<p>' . __( 'You can customize the look of your site without touching any of your theme’s code by using a custom background. Your background can be an image or a color.' ) . '</p>' . |
|
91 | - '<p>' . __( 'To use a background image, simply upload it or choose an image that has already been uploaded to your Media Library by clicking the “Choose Image” button. You can display a single instance of your image, or tile it to fill the screen. You can have your background fixed in place, so your site content moves on top of it, or you can have it scroll with your site.' ) . '</p>' . |
|
92 | - '<p>' . __( 'You can also choose a background color by clicking the Select Color button and either typing in a legitimate HTML hex value, e.g. “#ff0000” for red, or by choosing a color using the color picker.' ) . '</p>' . |
|
93 | - '<p>' . __( 'Do not forget to click on the Save Changes button when you are finished.' ) . '</p>', |
|
90 | + '<p>' . __('You can customize the look of your site without touching any of your theme’s code by using a custom background. Your background can be an image or a color.') . '</p>' . |
|
91 | + '<p>' . __('To use a background image, simply upload it or choose an image that has already been uploaded to your Media Library by clicking the “Choose Image” button. You can display a single instance of your image, or tile it to fill the screen. You can have your background fixed in place, so your site content moves on top of it, or you can have it scroll with your site.') . '</p>' . |
|
92 | + '<p>' . __('You can also choose a background color by clicking the Select Color button and either typing in a legitimate HTML hex value, e.g. “#ff0000” for red, or by choosing a color using the color picker.') . '</p>' . |
|
93 | + '<p>' . __('Do not forget to click on the Save Changes button when you are finished.') . '</p>', |
|
94 | 94 | ) |
95 | 95 | ); |
96 | 96 | |
97 | 97 | get_current_screen()->set_help_sidebar( |
98 | - '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
|
99 | - '<p>' . __( '<a href="https://codex.wordpress.org/Appearance_Background_Screen">Documentation on Custom Background</a>' ) . '</p>' . |
|
100 | - '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>' |
|
98 | + '<p><strong>' . __('For more information:') . '</strong></p>' . |
|
99 | + '<p>' . __('<a href="https://codex.wordpress.org/Appearance_Background_Screen">Documentation on Custom Background</a>') . '</p>' . |
|
100 | + '<p>' . __('<a href="https://wordpress.org/support/">Support</a>') . '</p>' |
|
101 | 101 | ); |
102 | 102 | |
103 | 103 | wp_enqueue_media(); |
104 | - wp_enqueue_script( 'custom-background' ); |
|
105 | - wp_enqueue_style( 'wp-color-picker' ); |
|
104 | + wp_enqueue_script('custom-background'); |
|
105 | + wp_enqueue_style('wp-color-picker'); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
@@ -111,110 +111,110 @@ discard block |
||
111 | 111 | * @since 3.0.0 |
112 | 112 | */ |
113 | 113 | public function take_action() { |
114 | - if ( empty( $_POST ) ) { |
|
114 | + if (empty($_POST)) { |
|
115 | 115 | return; |
116 | 116 | } |
117 | 117 | |
118 | - if ( isset( $_POST['reset-background'] ) ) { |
|
119 | - check_admin_referer( 'custom-background-reset', '_wpnonce-custom-background-reset' ); |
|
118 | + if (isset($_POST['reset-background'])) { |
|
119 | + check_admin_referer('custom-background-reset', '_wpnonce-custom-background-reset'); |
|
120 | 120 | |
121 | - remove_theme_mod( 'background_image' ); |
|
122 | - remove_theme_mod( 'background_image_thumb' ); |
|
121 | + remove_theme_mod('background_image'); |
|
122 | + remove_theme_mod('background_image_thumb'); |
|
123 | 123 | |
124 | 124 | $this->updated = true; |
125 | 125 | return; |
126 | 126 | } |
127 | 127 | |
128 | - if ( isset( $_POST['remove-background'] ) ) { |
|
128 | + if (isset($_POST['remove-background'])) { |
|
129 | 129 | // @todo Uploaded files are not removed here. |
130 | - check_admin_referer( 'custom-background-remove', '_wpnonce-custom-background-remove' ); |
|
130 | + check_admin_referer('custom-background-remove', '_wpnonce-custom-background-remove'); |
|
131 | 131 | |
132 | - set_theme_mod( 'background_image', '' ); |
|
133 | - set_theme_mod( 'background_image_thumb', '' ); |
|
132 | + set_theme_mod('background_image', ''); |
|
133 | + set_theme_mod('background_image_thumb', ''); |
|
134 | 134 | |
135 | 135 | $this->updated = true; |
136 | - wp_safe_redirect( $_POST['_wp_http_referer'] ); |
|
136 | + wp_safe_redirect($_POST['_wp_http_referer']); |
|
137 | 137 | return; |
138 | 138 | } |
139 | 139 | |
140 | - if ( isset( $_POST['background-preset'] ) ) { |
|
141 | - check_admin_referer( 'custom-background' ); |
|
140 | + if (isset($_POST['background-preset'])) { |
|
141 | + check_admin_referer('custom-background'); |
|
142 | 142 | |
143 | - if ( in_array( $_POST['background-preset'], array( 'default', 'fill', 'fit', 'repeat', 'custom' ), true ) ) { |
|
143 | + if (in_array($_POST['background-preset'], array('default', 'fill', 'fit', 'repeat', 'custom'), true)) { |
|
144 | 144 | $preset = $_POST['background-preset']; |
145 | 145 | } else { |
146 | 146 | $preset = 'default'; |
147 | 147 | } |
148 | 148 | |
149 | - set_theme_mod( 'background_preset', $preset ); |
|
149 | + set_theme_mod('background_preset', $preset); |
|
150 | 150 | } |
151 | 151 | |
152 | - if ( isset( $_POST['background-position'] ) ) { |
|
153 | - check_admin_referer( 'custom-background' ); |
|
152 | + if (isset($_POST['background-position'])) { |
|
153 | + check_admin_referer('custom-background'); |
|
154 | 154 | |
155 | - $position = explode( ' ', $_POST['background-position'] ); |
|
155 | + $position = explode(' ', $_POST['background-position']); |
|
156 | 156 | |
157 | - if ( in_array( $position[0], array( 'left', 'center', 'right' ), true ) ) { |
|
157 | + if (in_array($position[0], array('left', 'center', 'right'), true)) { |
|
158 | 158 | $position_x = $position[0]; |
159 | 159 | } else { |
160 | 160 | $position_x = 'left'; |
161 | 161 | } |
162 | 162 | |
163 | - if ( in_array( $position[1], array( 'top', 'center', 'bottom' ), true ) ) { |
|
163 | + if (in_array($position[1], array('top', 'center', 'bottom'), true)) { |
|
164 | 164 | $position_y = $position[1]; |
165 | 165 | } else { |
166 | 166 | $position_y = 'top'; |
167 | 167 | } |
168 | 168 | |
169 | - set_theme_mod( 'background_position_x', $position_x ); |
|
170 | - set_theme_mod( 'background_position_y', $position_y ); |
|
169 | + set_theme_mod('background_position_x', $position_x); |
|
170 | + set_theme_mod('background_position_y', $position_y); |
|
171 | 171 | } |
172 | 172 | |
173 | - if ( isset( $_POST['background-size'] ) ) { |
|
174 | - check_admin_referer( 'custom-background' ); |
|
173 | + if (isset($_POST['background-size'])) { |
|
174 | + check_admin_referer('custom-background'); |
|
175 | 175 | |
176 | - if ( in_array( $_POST['background-size'], array( 'auto', 'contain', 'cover' ), true ) ) { |
|
176 | + if (in_array($_POST['background-size'], array('auto', 'contain', 'cover'), true)) { |
|
177 | 177 | $size = $_POST['background-size']; |
178 | 178 | } else { |
179 | 179 | $size = 'auto'; |
180 | 180 | } |
181 | 181 | |
182 | - set_theme_mod( 'background_size', $size ); |
|
182 | + set_theme_mod('background_size', $size); |
|
183 | 183 | } |
184 | 184 | |
185 | - if ( isset( $_POST['background-repeat'] ) ) { |
|
186 | - check_admin_referer( 'custom-background' ); |
|
185 | + if (isset($_POST['background-repeat'])) { |
|
186 | + check_admin_referer('custom-background'); |
|
187 | 187 | |
188 | 188 | $repeat = $_POST['background-repeat']; |
189 | 189 | |
190 | - if ( 'no-repeat' !== $repeat ) { |
|
190 | + if ('no-repeat' !== $repeat) { |
|
191 | 191 | $repeat = 'repeat'; |
192 | 192 | } |
193 | 193 | |
194 | - set_theme_mod( 'background_repeat', $repeat ); |
|
194 | + set_theme_mod('background_repeat', $repeat); |
|
195 | 195 | } |
196 | 196 | |
197 | - if ( isset( $_POST['background-attachment'] ) ) { |
|
198 | - check_admin_referer( 'custom-background' ); |
|
197 | + if (isset($_POST['background-attachment'])) { |
|
198 | + check_admin_referer('custom-background'); |
|
199 | 199 | |
200 | 200 | $attachment = $_POST['background-attachment']; |
201 | 201 | |
202 | - if ( 'fixed' !== $attachment ) { |
|
202 | + if ('fixed' !== $attachment) { |
|
203 | 203 | $attachment = 'scroll'; |
204 | 204 | } |
205 | 205 | |
206 | - set_theme_mod( 'background_attachment', $attachment ); |
|
206 | + set_theme_mod('background_attachment', $attachment); |
|
207 | 207 | } |
208 | 208 | |
209 | - if ( isset( $_POST['background-color'] ) ) { |
|
210 | - check_admin_referer( 'custom-background' ); |
|
209 | + if (isset($_POST['background-color'])) { |
|
210 | + check_admin_referer('custom-background'); |
|
211 | 211 | |
212 | - $color = preg_replace( '/[^0-9a-fA-F]/', '', $_POST['background-color'] ); |
|
212 | + $color = preg_replace('/[^0-9a-fA-F]/', '', $_POST['background-color']); |
|
213 | 213 | |
214 | - if ( strlen( $color ) === 6 || strlen( $color ) === 3 ) { |
|
215 | - set_theme_mod( 'background_color', $color ); |
|
214 | + if (strlen($color) === 6 || strlen($color) === 3) { |
|
215 | + set_theme_mod('background_color', $color); |
|
216 | 216 | } else { |
217 | - set_theme_mod( 'background_color', '' ); |
|
217 | + set_theme_mod('background_color', ''); |
|
218 | 218 | } |
219 | 219 | } |
220 | 220 | |
@@ -229,58 +229,58 @@ discard block |
||
229 | 229 | public function admin_page() { |
230 | 230 | ?> |
231 | 231 | <div class="wrap" id="custom-background"> |
232 | -<h1><?php _e( 'Custom Background' ); ?></h1> |
|
232 | +<h1><?php _e('Custom Background'); ?></h1> |
|
233 | 233 | |
234 | - <?php if ( current_user_can( 'customize' ) ) { ?> |
|
234 | + <?php if (current_user_can('customize')) { ?> |
|
235 | 235 | <div class="notice notice-info hide-if-no-customize"> |
236 | 236 | <p> |
237 | 237 | <?php |
238 | 238 | printf( |
239 | 239 | /* translators: %s: URL to background image configuration in Customizer. */ |
240 | - __( 'You can now manage and live-preview Custom Backgrounds in the <a href="%s">Customizer</a>.' ), |
|
241 | - admin_url( 'customize.php?autofocus[control]=background_image' ) |
|
240 | + __('You can now manage and live-preview Custom Backgrounds in the <a href="%s">Customizer</a>.'), |
|
241 | + admin_url('customize.php?autofocus[control]=background_image') |
|
242 | 242 | ); |
243 | 243 | ?> |
244 | 244 | </p> |
245 | 245 | </div> |
246 | 246 | <?php } ?> |
247 | 247 | |
248 | - <?php if ( ! empty( $this->updated ) ) { ?> |
|
248 | + <?php if (!empty($this->updated)) { ?> |
|
249 | 249 | <div id="message" class="updated"> |
250 | 250 | <p> |
251 | 251 | <?php |
252 | 252 | /* translators: %s: Home URL. */ |
253 | - printf( __( 'Background updated. <a href="%s">Visit your site</a> to see how it looks.' ), home_url( '/' ) ); |
|
253 | + printf(__('Background updated. <a href="%s">Visit your site</a> to see how it looks.'), home_url('/')); |
|
254 | 254 | ?> |
255 | 255 | </p> |
256 | 256 | </div> |
257 | 257 | <?php } ?> |
258 | 258 | |
259 | -<h2><?php _e( 'Background Image' ); ?></h2> |
|
259 | +<h2><?php _e('Background Image'); ?></h2> |
|
260 | 260 | |
261 | 261 | <table class="form-table" role="presentation"> |
262 | 262 | <tbody> |
263 | 263 | <tr> |
264 | -<th scope="row"><?php _e( 'Preview' ); ?></th> |
|
264 | +<th scope="row"><?php _e('Preview'); ?></th> |
|
265 | 265 | <td> |
266 | 266 | <?php |
267 | - if ( $this->admin_image_div_callback ) { |
|
268 | - call_user_func( $this->admin_image_div_callback ); |
|
267 | + if ($this->admin_image_div_callback) { |
|
268 | + call_user_func($this->admin_image_div_callback); |
|
269 | 269 | } else { |
270 | 270 | $background_styles = ''; |
271 | 271 | $bgcolor = get_background_color(); |
272 | - if ( $bgcolor ) { |
|
272 | + if ($bgcolor) { |
|
273 | 273 | $background_styles .= 'background-color: #' . $bgcolor . ';'; |
274 | 274 | } |
275 | 275 | |
276 | 276 | $background_image_thumb = get_background_image(); |
277 | - if ( $background_image_thumb ) { |
|
278 | - $background_image_thumb = esc_url( set_url_scheme( get_theme_mod( 'background_image_thumb', str_replace( '%', '%%', $background_image_thumb ) ) ) ); |
|
279 | - $background_position_x = get_theme_mod( 'background_position_x', get_theme_support( 'custom-background', 'default-position-x' ) ); |
|
280 | - $background_position_y = get_theme_mod( 'background_position_y', get_theme_support( 'custom-background', 'default-position-y' ) ); |
|
281 | - $background_size = get_theme_mod( 'background_size', get_theme_support( 'custom-background', 'default-size' ) ); |
|
282 | - $background_repeat = get_theme_mod( 'background_repeat', get_theme_support( 'custom-background', 'default-repeat' ) ); |
|
283 | - $background_attachment = get_theme_mod( 'background_attachment', get_theme_support( 'custom-background', 'default-attachment' ) ); |
|
277 | + if ($background_image_thumb) { |
|
278 | + $background_image_thumb = esc_url(set_url_scheme(get_theme_mod('background_image_thumb', str_replace('%', '%%', $background_image_thumb)))); |
|
279 | + $background_position_x = get_theme_mod('background_position_x', get_theme_support('custom-background', 'default-position-x')); |
|
280 | + $background_position_y = get_theme_mod('background_position_y', get_theme_support('custom-background', 'default-position-y')); |
|
281 | + $background_size = get_theme_mod('background_size', get_theme_support('custom-background', 'default-size')); |
|
282 | + $background_repeat = get_theme_mod('background_repeat', get_theme_support('custom-background', 'default-repeat')); |
|
283 | + $background_attachment = get_theme_mod('background_attachment', get_theme_support('custom-background', 'default-attachment')); |
|
284 | 284 | |
285 | 285 | // Background-image URL must be single quote, see below. |
286 | 286 | $background_styles .= " background-image: url('$background_image_thumb');" |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | } |
292 | 292 | ?> |
293 | 293 | <div id="custom-background-image" style="<?php echo $background_styles; ?>"><?php // Must be double quote, see above. ?> |
294 | - <?php if ( $background_image_thumb ) { ?> |
|
294 | + <?php if ($background_image_thumb) { ?> |
|
295 | 295 | <img class="custom-background-image" src="<?php echo $background_image_thumb; ?>" style="visibility:hidden;" alt="" /><br /> |
296 | 296 | <img class="custom-background-image" src="<?php echo $background_image_thumb; ?>" style="visibility:hidden;" alt="" /> |
297 | 297 | <?php } ?> |
@@ -300,49 +300,49 @@ discard block |
||
300 | 300 | </td> |
301 | 301 | </tr> |
302 | 302 | |
303 | - <?php if ( get_background_image() ) : ?> |
|
303 | + <?php if (get_background_image()) : ?> |
|
304 | 304 | <tr> |
305 | -<th scope="row"><?php _e( 'Remove Image' ); ?></th> |
|
305 | +<th scope="row"><?php _e('Remove Image'); ?></th> |
|
306 | 306 | <td> |
307 | 307 | <form method="post"> |
308 | - <?php wp_nonce_field( 'custom-background-remove', '_wpnonce-custom-background-remove' ); ?> |
|
309 | - <?php submit_button( __( 'Remove Background Image' ), '', 'remove-background', false ); ?><br/> |
|
310 | - <?php _e( 'This will remove the background image. You will not be able to restore any customizations.' ); ?> |
|
308 | + <?php wp_nonce_field('custom-background-remove', '_wpnonce-custom-background-remove'); ?> |
|
309 | + <?php submit_button(__('Remove Background Image'), '', 'remove-background', false); ?><br/> |
|
310 | + <?php _e('This will remove the background image. You will not be able to restore any customizations.'); ?> |
|
311 | 311 | </form> |
312 | 312 | </td> |
313 | 313 | </tr> |
314 | 314 | <?php endif; ?> |
315 | 315 | |
316 | - <?php $default_image = get_theme_support( 'custom-background', 'default-image' ); ?> |
|
317 | - <?php if ( $default_image && get_background_image() !== $default_image ) : ?> |
|
316 | + <?php $default_image = get_theme_support('custom-background', 'default-image'); ?> |
|
317 | + <?php if ($default_image && get_background_image() !== $default_image) : ?> |
|
318 | 318 | <tr> |
319 | -<th scope="row"><?php _e( 'Restore Original Image' ); ?></th> |
|
319 | +<th scope="row"><?php _e('Restore Original Image'); ?></th> |
|
320 | 320 | <td> |
321 | 321 | <form method="post"> |
322 | - <?php wp_nonce_field( 'custom-background-reset', '_wpnonce-custom-background-reset' ); ?> |
|
323 | - <?php submit_button( __( 'Restore Original Image' ), '', 'reset-background', false ); ?><br/> |
|
324 | - <?php _e( 'This will restore the original background image. You will not be able to restore any customizations.' ); ?> |
|
322 | + <?php wp_nonce_field('custom-background-reset', '_wpnonce-custom-background-reset'); ?> |
|
323 | + <?php submit_button(__('Restore Original Image'), '', 'reset-background', false); ?><br/> |
|
324 | + <?php _e('This will restore the original background image. You will not be able to restore any customizations.'); ?> |
|
325 | 325 | </form> |
326 | 326 | </td> |
327 | 327 | </tr> |
328 | 328 | <?php endif; ?> |
329 | 329 | |
330 | - <?php if ( current_user_can( 'upload_files' ) ) : ?> |
|
330 | + <?php if (current_user_can('upload_files')) : ?> |
|
331 | 331 | <tr> |
332 | -<th scope="row"><?php _e( 'Select Image' ); ?></th> |
|
332 | +<th scope="row"><?php _e('Select Image'); ?></th> |
|
333 | 333 | <td><form enctype="multipart/form-data" id="upload-form" class="wp-upload-form" method="post"> |
334 | 334 | <p> |
335 | - <label for="upload"><?php _e( 'Choose an image from your computer:' ); ?></label><br /> |
|
335 | + <label for="upload"><?php _e('Choose an image from your computer:'); ?></label><br /> |
|
336 | 336 | <input type="file" id="upload" name="import" /> |
337 | 337 | <input type="hidden" name="action" value="save" /> |
338 | - <?php wp_nonce_field( 'custom-background-upload', '_wpnonce-custom-background-upload' ); ?> |
|
339 | - <?php submit_button( __( 'Upload' ), '', 'submit', false ); ?> |
|
338 | + <?php wp_nonce_field('custom-background-upload', '_wpnonce-custom-background-upload'); ?> |
|
339 | + <?php submit_button(__('Upload'), '', 'submit', false); ?> |
|
340 | 340 | </p> |
341 | 341 | <p> |
342 | - <label for="choose-from-library-link"><?php _e( 'Or choose an image from your media library:' ); ?></label><br /> |
|
342 | + <label for="choose-from-library-link"><?php _e('Or choose an image from your media library:'); ?></label><br /> |
|
343 | 343 | <button id="choose-from-library-link" class="button" |
344 | - data-choose="<?php esc_attr_e( 'Choose a Background Image' ); ?>" |
|
345 | - data-update="<?php esc_attr_e( 'Set as background' ); ?>"><?php _e( 'Choose Image' ); ?></button> |
|
344 | + data-choose="<?php esc_attr_e('Choose a Background Image'); ?>" |
|
345 | + data-update="<?php esc_attr_e('Set as background'); ?>"><?php _e('Choose Image'); ?></button> |
|
346 | 346 | </p> |
347 | 347 | </form> |
348 | 348 | </td> |
@@ -351,75 +351,75 @@ discard block |
||
351 | 351 | </tbody> |
352 | 352 | </table> |
353 | 353 | |
354 | -<h2><?php _e( 'Display Options' ); ?></h2> |
|
354 | +<h2><?php _e('Display Options'); ?></h2> |
|
355 | 355 | <form method="post"> |
356 | 356 | <table class="form-table" role="presentation"> |
357 | 357 | <tbody> |
358 | - <?php if ( get_background_image() ) : ?> |
|
358 | + <?php if (get_background_image()) : ?> |
|
359 | 359 | <input name="background-preset" type="hidden" value="custom"> |
360 | 360 | |
361 | 361 | <?php |
362 | 362 | $background_position = sprintf( |
363 | 363 | '%s %s', |
364 | - get_theme_mod( 'background_position_x', get_theme_support( 'custom-background', 'default-position-x' ) ), |
|
365 | - get_theme_mod( 'background_position_y', get_theme_support( 'custom-background', 'default-position-y' ) ) |
|
364 | + get_theme_mod('background_position_x', get_theme_support('custom-background', 'default-position-x')), |
|
365 | + get_theme_mod('background_position_y', get_theme_support('custom-background', 'default-position-y')) |
|
366 | 366 | ); |
367 | 367 | |
368 | 368 | $background_position_options = array( |
369 | 369 | array( |
370 | 370 | 'left top' => array( |
371 | - 'label' => __( 'Top Left' ), |
|
371 | + 'label' => __('Top Left'), |
|
372 | 372 | 'icon' => 'dashicons dashicons-arrow-left-alt', |
373 | 373 | ), |
374 | 374 | 'center top' => array( |
375 | - 'label' => __( 'Top' ), |
|
375 | + 'label' => __('Top'), |
|
376 | 376 | 'icon' => 'dashicons dashicons-arrow-up-alt', |
377 | 377 | ), |
378 | 378 | 'right top' => array( |
379 | - 'label' => __( 'Top Right' ), |
|
379 | + 'label' => __('Top Right'), |
|
380 | 380 | 'icon' => 'dashicons dashicons-arrow-right-alt', |
381 | 381 | ), |
382 | 382 | ), |
383 | 383 | array( |
384 | 384 | 'left center' => array( |
385 | - 'label' => __( 'Left' ), |
|
385 | + 'label' => __('Left'), |
|
386 | 386 | 'icon' => 'dashicons dashicons-arrow-left-alt', |
387 | 387 | ), |
388 | 388 | 'center center' => array( |
389 | - 'label' => __( 'Center' ), |
|
389 | + 'label' => __('Center'), |
|
390 | 390 | 'icon' => 'background-position-center-icon', |
391 | 391 | ), |
392 | 392 | 'right center' => array( |
393 | - 'label' => __( 'Right' ), |
|
393 | + 'label' => __('Right'), |
|
394 | 394 | 'icon' => 'dashicons dashicons-arrow-right-alt', |
395 | 395 | ), |
396 | 396 | ), |
397 | 397 | array( |
398 | 398 | 'left bottom' => array( |
399 | - 'label' => __( 'Bottom Left' ), |
|
399 | + 'label' => __('Bottom Left'), |
|
400 | 400 | 'icon' => 'dashicons dashicons-arrow-left-alt', |
401 | 401 | ), |
402 | 402 | 'center bottom' => array( |
403 | - 'label' => __( 'Bottom' ), |
|
403 | + 'label' => __('Bottom'), |
|
404 | 404 | 'icon' => 'dashicons dashicons-arrow-down-alt', |
405 | 405 | ), |
406 | 406 | 'right bottom' => array( |
407 | - 'label' => __( 'Bottom Right' ), |
|
407 | + 'label' => __('Bottom Right'), |
|
408 | 408 | 'icon' => 'dashicons dashicons-arrow-right-alt', |
409 | 409 | ), |
410 | 410 | ), |
411 | 411 | ); |
412 | 412 | ?> |
413 | 413 | <tr> |
414 | -<th scope="row"><?php _e( 'Image Position' ); ?></th> |
|
415 | -<td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Image Position' ); ?></span></legend> |
|
414 | +<th scope="row"><?php _e('Image Position'); ?></th> |
|
415 | +<td><fieldset><legend class="screen-reader-text"><span><?php _e('Image Position'); ?></span></legend> |
|
416 | 416 | <div class="background-position-control"> |
417 | - <?php foreach ( $background_position_options as $group ) : ?> |
|
417 | + <?php foreach ($background_position_options as $group) : ?> |
|
418 | 418 | <div class="button-group"> |
419 | - <?php foreach ( $group as $value => $input ) : ?> |
|
419 | + <?php foreach ($group as $value => $input) : ?> |
|
420 | 420 | <label> |
421 | - <input class="ui-helper-hidden-accessible" name="background-position" type="radio" value="<?php echo esc_attr( $value ); ?>"<?php checked( $value, $background_position ); ?>> |
|
422 | - <span class="button display-options position"><span class="<?php echo esc_attr( $input['icon'] ); ?>" aria-hidden="true"></span></span> |
|
421 | + <input class="ui-helper-hidden-accessible" name="background-position" type="radio" value="<?php echo esc_attr($value); ?>"<?php checked($value, $background_position); ?>> |
|
422 | + <span class="button display-options position"><span class="<?php echo esc_attr($input['icon']); ?>" aria-hidden="true"></span></span> |
|
423 | 423 | <span class="screen-reader-text"><?php echo $input['label']; ?></span> |
424 | 424 | </label> |
425 | 425 | <?php endforeach; ?> |
@@ -430,49 +430,49 @@ discard block |
||
430 | 430 | </tr> |
431 | 431 | |
432 | 432 | <tr> |
433 | -<th scope="row"><label for="background-size"><?php _e( 'Image Size' ); ?></label></th> |
|
434 | -<td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Image Size' ); ?></span></legend> |
|
433 | +<th scope="row"><label for="background-size"><?php _e('Image Size'); ?></label></th> |
|
434 | +<td><fieldset><legend class="screen-reader-text"><span><?php _e('Image Size'); ?></span></legend> |
|
435 | 435 | <select id="background-size" name="background-size"> |
436 | -<option value="auto"<?php selected( 'auto', get_theme_mod( 'background_size', get_theme_support( 'custom-background', 'default-size' ) ) ); ?>><?php _ex( 'Original', 'Original Size' ); ?></option> |
|
437 | -<option value="contain"<?php selected( 'contain', get_theme_mod( 'background_size', get_theme_support( 'custom-background', 'default-size' ) ) ); ?>><?php _e( 'Fit to Screen' ); ?></option> |
|
438 | -<option value="cover"<?php selected( 'cover', get_theme_mod( 'background_size', get_theme_support( 'custom-background', 'default-size' ) ) ); ?>><?php _e( 'Fill Screen' ); ?></option> |
|
436 | +<option value="auto"<?php selected('auto', get_theme_mod('background_size', get_theme_support('custom-background', 'default-size'))); ?>><?php _ex('Original', 'Original Size'); ?></option> |
|
437 | +<option value="contain"<?php selected('contain', get_theme_mod('background_size', get_theme_support('custom-background', 'default-size'))); ?>><?php _e('Fit to Screen'); ?></option> |
|
438 | +<option value="cover"<?php selected('cover', get_theme_mod('background_size', get_theme_support('custom-background', 'default-size'))); ?>><?php _e('Fill Screen'); ?></option> |
|
439 | 439 | </select> |
440 | 440 | </fieldset></td> |
441 | 441 | </tr> |
442 | 442 | |
443 | 443 | <tr> |
444 | -<th scope="row"><?php _ex( 'Repeat', 'Background Repeat' ); ?></th> |
|
445 | -<td><fieldset><legend class="screen-reader-text"><span><?php _ex( 'Repeat', 'Background Repeat' ); ?></span></legend> |
|
444 | +<th scope="row"><?php _ex('Repeat', 'Background Repeat'); ?></th> |
|
445 | +<td><fieldset><legend class="screen-reader-text"><span><?php _ex('Repeat', 'Background Repeat'); ?></span></legend> |
|
446 | 446 | <input name="background-repeat" type="hidden" value="no-repeat"> |
447 | -<label><input type="checkbox" name="background-repeat" value="repeat"<?php checked( 'repeat', get_theme_mod( 'background_repeat', get_theme_support( 'custom-background', 'default-repeat' ) ) ); ?>> <?php _e( 'Repeat Background Image' ); ?></label> |
|
447 | +<label><input type="checkbox" name="background-repeat" value="repeat"<?php checked('repeat', get_theme_mod('background_repeat', get_theme_support('custom-background', 'default-repeat'))); ?>> <?php _e('Repeat Background Image'); ?></label> |
|
448 | 448 | </fieldset></td> |
449 | 449 | </tr> |
450 | 450 | |
451 | 451 | <tr> |
452 | -<th scope="row"><?php _ex( 'Scroll', 'Background Scroll' ); ?></th> |
|
453 | -<td><fieldset><legend class="screen-reader-text"><span><?php _ex( 'Scroll', 'Background Scroll' ); ?></span></legend> |
|
452 | +<th scope="row"><?php _ex('Scroll', 'Background Scroll'); ?></th> |
|
453 | +<td><fieldset><legend class="screen-reader-text"><span><?php _ex('Scroll', 'Background Scroll'); ?></span></legend> |
|
454 | 454 | <input name="background-attachment" type="hidden" value="fixed"> |
455 | -<label><input name="background-attachment" type="checkbox" value="scroll" <?php checked( 'scroll', get_theme_mod( 'background_attachment', get_theme_support( 'custom-background', 'default-attachment' ) ) ); ?>> <?php _e( 'Scroll with Page' ); ?></label> |
|
455 | +<label><input name="background-attachment" type="checkbox" value="scroll" <?php checked('scroll', get_theme_mod('background_attachment', get_theme_support('custom-background', 'default-attachment'))); ?>> <?php _e('Scroll with Page'); ?></label> |
|
456 | 456 | </fieldset></td> |
457 | 457 | </tr> |
458 | 458 | <?php endif; // get_background_image() ?> |
459 | 459 | <tr> |
460 | -<th scope="row"><?php _e( 'Background Color' ); ?></th> |
|
461 | -<td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Background Color' ); ?></span></legend> |
|
460 | +<th scope="row"><?php _e('Background Color'); ?></th> |
|
461 | +<td><fieldset><legend class="screen-reader-text"><span><?php _e('Background Color'); ?></span></legend> |
|
462 | 462 | <?php |
463 | 463 | $default_color = ''; |
464 | - if ( current_theme_supports( 'custom-background', 'default-color' ) ) { |
|
465 | - $default_color = ' data-default-color="#' . esc_attr( get_theme_support( 'custom-background', 'default-color' ) ) . '"'; |
|
464 | + if (current_theme_supports('custom-background', 'default-color')) { |
|
465 | + $default_color = ' data-default-color="#' . esc_attr(get_theme_support('custom-background', 'default-color')) . '"'; |
|
466 | 466 | } |
467 | 467 | ?> |
468 | -<input type="text" name="background-color" id="background-color" value="#<?php echo esc_attr( get_background_color() ); ?>"<?php echo $default_color; ?>> |
|
468 | +<input type="text" name="background-color" id="background-color" value="#<?php echo esc_attr(get_background_color()); ?>"<?php echo $default_color; ?>> |
|
469 | 469 | </fieldset></td> |
470 | 470 | </tr> |
471 | 471 | </tbody> |
472 | 472 | </table> |
473 | 473 | |
474 | - <?php wp_nonce_field( 'custom-background' ); ?> |
|
475 | - <?php submit_button( null, 'primary', 'save-background-options' ); ?> |
|
474 | + <?php wp_nonce_field('custom-background'); ?> |
|
475 | + <?php submit_button(null, 'primary', 'save-background-options'); ?> |
|
476 | 476 | </form> |
477 | 477 | |
478 | 478 | </div> |
@@ -485,30 +485,30 @@ discard block |
||
485 | 485 | * @since 3.0.0 |
486 | 486 | */ |
487 | 487 | public function handle_upload() { |
488 | - if ( empty( $_FILES ) ) { |
|
488 | + if (empty($_FILES)) { |
|
489 | 489 | return; |
490 | 490 | } |
491 | 491 | |
492 | - check_admin_referer( 'custom-background-upload', '_wpnonce-custom-background-upload' ); |
|
492 | + check_admin_referer('custom-background-upload', '_wpnonce-custom-background-upload'); |
|
493 | 493 | |
494 | - $overrides = array( 'test_form' => false ); |
|
494 | + $overrides = array('test_form' => false); |
|
495 | 495 | |
496 | 496 | $uploaded_file = $_FILES['import']; |
497 | - $wp_filetype = wp_check_filetype_and_ext( $uploaded_file['tmp_name'], $uploaded_file['name'] ); |
|
498 | - if ( ! wp_match_mime_types( 'image', $wp_filetype['type'] ) ) { |
|
499 | - wp_die( __( 'The uploaded file is not a valid image. Please try again.' ) ); |
|
497 | + $wp_filetype = wp_check_filetype_and_ext($uploaded_file['tmp_name'], $uploaded_file['name']); |
|
498 | + if (!wp_match_mime_types('image', $wp_filetype['type'])) { |
|
499 | + wp_die(__('The uploaded file is not a valid image. Please try again.')); |
|
500 | 500 | } |
501 | 501 | |
502 | - $file = wp_handle_upload( $uploaded_file, $overrides ); |
|
502 | + $file = wp_handle_upload($uploaded_file, $overrides); |
|
503 | 503 | |
504 | - if ( isset( $file['error'] ) ) { |
|
505 | - wp_die( $file['error'] ); |
|
504 | + if (isset($file['error'])) { |
|
505 | + wp_die($file['error']); |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | $url = $file['url']; |
509 | 509 | $type = $file['type']; |
510 | 510 | $file = $file['file']; |
511 | - $filename = wp_basename( $file ); |
|
511 | + $filename = wp_basename($file); |
|
512 | 512 | |
513 | 513 | // Construct the attachment array. |
514 | 514 | $attachment = array( |
@@ -520,19 +520,19 @@ discard block |
||
520 | 520 | ); |
521 | 521 | |
522 | 522 | // Save the data. |
523 | - $id = wp_insert_attachment( $attachment, $file ); |
|
523 | + $id = wp_insert_attachment($attachment, $file); |
|
524 | 524 | |
525 | 525 | // Add the metadata. |
526 | - wp_update_attachment_metadata( $id, wp_generate_attachment_metadata( $id, $file ) ); |
|
527 | - update_post_meta( $id, '_wp_attachment_is_custom_background', get_option( 'stylesheet' ) ); |
|
526 | + wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $file)); |
|
527 | + update_post_meta($id, '_wp_attachment_is_custom_background', get_option('stylesheet')); |
|
528 | 528 | |
529 | - set_theme_mod( 'background_image', esc_url_raw( $url ) ); |
|
529 | + set_theme_mod('background_image', esc_url_raw($url)); |
|
530 | 530 | |
531 | - $thumbnail = wp_get_attachment_image_src( $id, 'thumbnail' ); |
|
532 | - set_theme_mod( 'background_image_thumb', esc_url_raw( $thumbnail[0] ) ); |
|
531 | + $thumbnail = wp_get_attachment_image_src($id, 'thumbnail'); |
|
532 | + set_theme_mod('background_image_thumb', esc_url_raw($thumbnail[0])); |
|
533 | 533 | |
534 | 534 | /** This action is documented in wp-admin/includes/class-custom-image-header.php */ |
535 | - do_action( 'wp_create_file_in_uploads', $file, $id ); // For replication. |
|
535 | + do_action('wp_create_file_in_uploads', $file, $id); // For replication. |
|
536 | 536 | $this->updated = true; |
537 | 537 | } |
538 | 538 | |
@@ -545,18 +545,18 @@ discard block |
||
545 | 545 | * @since 4.1.0 |
546 | 546 | */ |
547 | 547 | public function ajax_background_add() { |
548 | - check_ajax_referer( 'background-add', 'nonce' ); |
|
548 | + check_ajax_referer('background-add', 'nonce'); |
|
549 | 549 | |
550 | - if ( ! current_user_can( 'edit_theme_options' ) ) { |
|
550 | + if (!current_user_can('edit_theme_options')) { |
|
551 | 551 | wp_send_json_error(); |
552 | 552 | } |
553 | 553 | |
554 | - $attachment_id = absint( $_POST['attachment_id'] ); |
|
555 | - if ( $attachment_id < 1 ) { |
|
554 | + $attachment_id = absint($_POST['attachment_id']); |
|
555 | + if ($attachment_id < 1) { |
|
556 | 556 | wp_send_json_error(); |
557 | 557 | } |
558 | 558 | |
559 | - update_post_meta( $attachment_id, '_wp_attachment_is_custom_background', get_stylesheet() ); |
|
559 | + update_post_meta($attachment_id, '_wp_attachment_is_custom_background', get_stylesheet()); |
|
560 | 560 | |
561 | 561 | wp_send_json_success(); |
562 | 562 | } |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | * @param array $form_fields |
569 | 569 | * @return array $form_fields |
570 | 570 | */ |
571 | - public function attachment_fields_to_edit( $form_fields ) { |
|
571 | + public function attachment_fields_to_edit($form_fields) { |
|
572 | 572 | return $form_fields; |
573 | 573 | } |
574 | 574 | |
@@ -579,7 +579,7 @@ discard block |
||
579 | 579 | * @param array $tabs |
580 | 580 | * @return array $tabs |
581 | 581 | */ |
582 | - public function filter_upload_tabs( $tabs ) { |
|
582 | + public function filter_upload_tabs($tabs) { |
|
583 | 583 | return $tabs; |
584 | 584 | } |
585 | 585 | |
@@ -588,38 +588,38 @@ discard block |
||
588 | 588 | * @deprecated 3.5.0 |
589 | 589 | */ |
590 | 590 | public function wp_set_background_image() { |
591 | - check_ajax_referer( 'custom-background' ); |
|
591 | + check_ajax_referer('custom-background'); |
|
592 | 592 | |
593 | - if ( ! current_user_can( 'edit_theme_options' ) || ! isset( $_POST['attachment_id'] ) ) { |
|
593 | + if (!current_user_can('edit_theme_options') || !isset($_POST['attachment_id'])) { |
|
594 | 594 | exit; |
595 | 595 | } |
596 | 596 | |
597 | - $attachment_id = absint( $_POST['attachment_id'] ); |
|
597 | + $attachment_id = absint($_POST['attachment_id']); |
|
598 | 598 | |
599 | 599 | $sizes = array_keys( |
600 | 600 | /** This filter is documented in wp-admin/includes/media.php */ |
601 | 601 | apply_filters( |
602 | 602 | 'image_size_names_choose', |
603 | 603 | array( |
604 | - 'thumbnail' => __( 'Thumbnail' ), |
|
605 | - 'medium' => __( 'Medium' ), |
|
606 | - 'large' => __( 'Large' ), |
|
607 | - 'full' => __( 'Full Size' ), |
|
604 | + 'thumbnail' => __('Thumbnail'), |
|
605 | + 'medium' => __('Medium'), |
|
606 | + 'large' => __('Large'), |
|
607 | + 'full' => __('Full Size'), |
|
608 | 608 | ) |
609 | 609 | ) |
610 | 610 | ); |
611 | 611 | |
612 | 612 | $size = 'thumbnail'; |
613 | - if ( in_array( $_POST['size'], $sizes, true ) ) { |
|
614 | - $size = esc_attr( $_POST['size'] ); |
|
613 | + if (in_array($_POST['size'], $sizes, true)) { |
|
614 | + $size = esc_attr($_POST['size']); |
|
615 | 615 | } |
616 | 616 | |
617 | - update_post_meta( $attachment_id, '_wp_attachment_is_custom_background', get_option( 'stylesheet' ) ); |
|
617 | + update_post_meta($attachment_id, '_wp_attachment_is_custom_background', get_option('stylesheet')); |
|
618 | 618 | |
619 | - $url = wp_get_attachment_image_src( $attachment_id, $size ); |
|
620 | - $thumbnail = wp_get_attachment_image_src( $attachment_id, 'thumbnail' ); |
|
621 | - set_theme_mod( 'background_image', esc_url_raw( $url[0] ) ); |
|
622 | - set_theme_mod( 'background_image_thumb', esc_url_raw( $thumbnail[0] ) ); |
|
619 | + $url = wp_get_attachment_image_src($attachment_id, $size); |
|
620 | + $thumbnail = wp_get_attachment_image_src($attachment_id, 'thumbnail'); |
|
621 | + set_theme_mod('background_image', esc_url_raw($url[0])); |
|
622 | + set_theme_mod('background_image_thumb', esc_url_raw($thumbnail[0])); |
|
623 | 623 | exit; |
624 | 624 | } |
625 | 625 | } |
@@ -29,11 +29,11 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @param array $args An associative array of arguments. |
31 | 31 | */ |
32 | - public function __construct( $args = array() ) { |
|
32 | + public function __construct($args = array()) { |
|
33 | 33 | parent::__construct( |
34 | 34 | array( |
35 | 35 | 'ajax' => true, |
36 | - 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
|
36 | + 'screen' => isset($args['screen']) ? $args['screen'] : null, |
|
37 | 37 | ) |
38 | 38 | ); |
39 | 39 | } |
@@ -43,43 +43,43 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function ajax_user_can() { |
45 | 45 | // Do not check edit_theme_options here. Ajax calls for available themes require switch_themes. |
46 | - return current_user_can( 'switch_themes' ); |
|
46 | + return current_user_can('switch_themes'); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
50 | 50 | */ |
51 | 51 | public function prepare_items() { |
52 | - $themes = wp_get_themes( array( 'allowed' => true ) ); |
|
52 | + $themes = wp_get_themes(array('allowed' => true)); |
|
53 | 53 | |
54 | - if ( ! empty( $_REQUEST['s'] ) ) { |
|
55 | - $this->search_terms = array_unique( array_filter( array_map( 'trim', explode( ',', strtolower( wp_unslash( $_REQUEST['s'] ) ) ) ) ) ); |
|
54 | + if (!empty($_REQUEST['s'])) { |
|
55 | + $this->search_terms = array_unique(array_filter(array_map('trim', explode(',', strtolower(wp_unslash($_REQUEST['s'])))))); |
|
56 | 56 | } |
57 | 57 | |
58 | - if ( ! empty( $_REQUEST['features'] ) ) { |
|
58 | + if (!empty($_REQUEST['features'])) { |
|
59 | 59 | $this->features = $_REQUEST['features']; |
60 | 60 | } |
61 | 61 | |
62 | - if ( $this->search_terms || $this->features ) { |
|
63 | - foreach ( $themes as $key => $theme ) { |
|
64 | - if ( ! $this->search_theme( $theme ) ) { |
|
65 | - unset( $themes[ $key ] ); |
|
62 | + if ($this->search_terms || $this->features) { |
|
63 | + foreach ($themes as $key => $theme) { |
|
64 | + if (!$this->search_theme($theme)) { |
|
65 | + unset($themes[$key]); |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
70 | - unset( $themes[ get_option( 'stylesheet' ) ] ); |
|
71 | - WP_Theme::sort_by_name( $themes ); |
|
70 | + unset($themes[get_option('stylesheet')]); |
|
71 | + WP_Theme::sort_by_name($themes); |
|
72 | 72 | |
73 | 73 | $per_page = 36; |
74 | 74 | $page = $this->get_pagenum(); |
75 | 75 | |
76 | - $start = ( $page - 1 ) * $per_page; |
|
76 | + $start = ($page - 1) * $per_page; |
|
77 | 77 | |
78 | - $this->items = array_slice( $themes, $start, $per_page, true ); |
|
78 | + $this->items = array_slice($themes, $start, $per_page, true); |
|
79 | 79 | |
80 | 80 | $this->set_pagination_args( |
81 | 81 | array( |
82 | - 'total_items' => count( $themes ), |
|
82 | + 'total_items' => count($themes), |
|
83 | 83 | 'per_page' => $per_page, |
84 | 84 | 'infinite_scroll' => true, |
85 | 85 | ) |
@@ -89,38 +89,38 @@ discard block |
||
89 | 89 | /** |
90 | 90 | */ |
91 | 91 | public function no_items() { |
92 | - if ( $this->search_terms || $this->features ) { |
|
93 | - _e( 'No items found.' ); |
|
92 | + if ($this->search_terms || $this->features) { |
|
93 | + _e('No items found.'); |
|
94 | 94 | return; |
95 | 95 | } |
96 | 96 | |
97 | 97 | $blog_id = get_current_blog_id(); |
98 | - if ( is_multisite() ) { |
|
99 | - if ( current_user_can( 'install_themes' ) && current_user_can( 'manage_network_themes' ) ) { |
|
98 | + if (is_multisite()) { |
|
99 | + if (current_user_can('install_themes') && current_user_can('manage_network_themes')) { |
|
100 | 100 | printf( |
101 | 101 | /* translators: 1: URL to Themes tab on Edit Site screen, 2: URL to Add Themes screen. */ |
102 | - __( 'You only have one theme enabled for this site right now. Visit the Network Admin to <a href="%1$s">enable</a> or <a href="%2$s">install</a> more themes.' ), |
|
103 | - network_admin_url( 'site-themes.php?id=' . $blog_id ), |
|
104 | - network_admin_url( 'theme-install.php' ) |
|
102 | + __('You only have one theme enabled for this site right now. Visit the Network Admin to <a href="%1$s">enable</a> or <a href="%2$s">install</a> more themes.'), |
|
103 | + network_admin_url('site-themes.php?id=' . $blog_id), |
|
104 | + network_admin_url('theme-install.php') |
|
105 | 105 | ); |
106 | 106 | |
107 | 107 | return; |
108 | - } elseif ( current_user_can( 'manage_network_themes' ) ) { |
|
108 | + } elseif (current_user_can('manage_network_themes')) { |
|
109 | 109 | printf( |
110 | 110 | /* translators: %s: URL to Themes tab on Edit Site screen. */ |
111 | - __( 'You only have one theme enabled for this site right now. Visit the Network Admin to <a href="%s">enable</a> more themes.' ), |
|
112 | - network_admin_url( 'site-themes.php?id=' . $blog_id ) |
|
111 | + __('You only have one theme enabled for this site right now. Visit the Network Admin to <a href="%s">enable</a> more themes.'), |
|
112 | + network_admin_url('site-themes.php?id=' . $blog_id) |
|
113 | 113 | ); |
114 | 114 | |
115 | 115 | return; |
116 | 116 | } |
117 | 117 | // Else, fallthrough. install_themes doesn't help if you can't enable it. |
118 | 118 | } else { |
119 | - if ( current_user_can( 'install_themes' ) ) { |
|
119 | + if (current_user_can('install_themes')) { |
|
120 | 120 | printf( |
121 | 121 | /* translators: %s: URL to Add Themes screen. */ |
122 | - __( 'You only have one theme installed right now. Live a little! You can choose from over 1,000 free themes in the WordPress Theme Directory at any time: just click on the <a href="%s">Install Themes</a> tab above.' ), |
|
123 | - admin_url( 'theme-install.php' ) |
|
122 | + __('You only have one theme installed right now. Live a little! You can choose from over 1,000 free themes in the WordPress Theme Directory at any time: just click on the <a href="%s">Install Themes</a> tab above.'), |
|
123 | + admin_url('theme-install.php') |
|
124 | 124 | ); |
125 | 125 | |
126 | 126 | return; |
@@ -129,21 +129,21 @@ discard block |
||
129 | 129 | // Fallthrough. |
130 | 130 | printf( |
131 | 131 | /* translators: %s: Network title. */ |
132 | - __( 'Only the active theme is available to you. Contact the %s administrator for information about accessing additional themes.' ), |
|
133 | - get_site_option( 'site_name' ) |
|
132 | + __('Only the active theme is available to you. Contact the %s administrator for information about accessing additional themes.'), |
|
133 | + get_site_option('site_name') |
|
134 | 134 | ); |
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
138 | 138 | * @param string $which |
139 | 139 | */ |
140 | - public function tablenav( $which = 'top' ) { |
|
141 | - if ( $this->get_pagination_arg( 'total_pages' ) <= 1 ) { |
|
140 | + public function tablenav($which = 'top') { |
|
141 | + if ($this->get_pagination_arg('total_pages') <= 1) { |
|
142 | 142 | return; |
143 | 143 | } |
144 | 144 | ?> |
145 | 145 | <div class="tablenav themes <?php echo $which; ?>"> |
146 | - <?php $this->pagination( $which ); ?> |
|
146 | + <?php $this->pagination($which); ?> |
|
147 | 147 | <span class="spinner"></span> |
148 | 148 | <br class="clear" /> |
149 | 149 | </div> |
@@ -158,15 +158,15 @@ discard block |
||
158 | 158 | * @since 3.1.0 |
159 | 159 | */ |
160 | 160 | public function display() { |
161 | - wp_nonce_field( 'fetch-list-' . get_class( $this ), '_ajax_fetch_list_nonce' ); |
|
161 | + wp_nonce_field('fetch-list-' . get_class($this), '_ajax_fetch_list_nonce'); |
|
162 | 162 | ?> |
163 | - <?php $this->tablenav( 'top' ); ?> |
|
163 | + <?php $this->tablenav('top'); ?> |
|
164 | 164 | |
165 | 165 | <div id="availablethemes"> |
166 | 166 | <?php $this->display_rows_or_placeholder(); ?> |
167 | 167 | </div> |
168 | 168 | |
169 | - <?php $this->tablenav( 'bottom' ); ?> |
|
169 | + <?php $this->tablenav('bottom'); ?> |
|
170 | 170 | <?php |
171 | 171 | } |
172 | 172 | |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | /** |
181 | 181 | */ |
182 | 182 | public function display_rows_or_placeholder() { |
183 | - if ( $this->has_items() ) { |
|
183 | + if ($this->has_items()) { |
|
184 | 184 | $this->display_rows(); |
185 | 185 | } else { |
186 | 186 | echo '<div class="no-items">'; |
@@ -194,65 +194,65 @@ discard block |
||
194 | 194 | public function display_rows() { |
195 | 195 | $themes = $this->items; |
196 | 196 | |
197 | - foreach ( $themes as $theme ) : |
|
197 | + foreach ($themes as $theme) : |
|
198 | 198 | ?> |
199 | 199 | <div class="available-theme"> |
200 | 200 | <?php |
201 | 201 | |
202 | 202 | $template = $theme->get_template(); |
203 | 203 | $stylesheet = $theme->get_stylesheet(); |
204 | - $title = $theme->display( 'Name' ); |
|
205 | - $version = $theme->display( 'Version' ); |
|
206 | - $author = $theme->display( 'Author' ); |
|
204 | + $title = $theme->display('Name'); |
|
205 | + $version = $theme->display('Version'); |
|
206 | + $author = $theme->display('Author'); |
|
207 | 207 | |
208 | - $activate_link = wp_nonce_url( 'themes.php?action=activate&template=' . urlencode( $template ) . '&stylesheet=' . urlencode( $stylesheet ), 'switch-theme_' . $stylesheet ); |
|
208 | + $activate_link = wp_nonce_url('themes.php?action=activate&template=' . urlencode($template) . '&stylesheet=' . urlencode($stylesheet), 'switch-theme_' . $stylesheet); |
|
209 | 209 | |
210 | 210 | $actions = array(); |
211 | 211 | $actions['activate'] = sprintf( |
212 | 212 | '<a href="%s" class="activatelink" title="%s">%s</a>', |
213 | 213 | $activate_link, |
214 | 214 | /* translators: %s: Theme name. */ |
215 | - esc_attr( sprintf( _x( 'Activate “%s”', 'theme' ), $title ) ), |
|
216 | - __( 'Activate' ) |
|
215 | + esc_attr(sprintf(_x('Activate “%s”', 'theme'), $title)), |
|
216 | + __('Activate') |
|
217 | 217 | ); |
218 | 218 | |
219 | - if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { |
|
219 | + if (current_user_can('edit_theme_options') && current_user_can('customize')) { |
|
220 | 220 | $actions['preview'] .= sprintf( |
221 | 221 | '<a href="%s" class="load-customize hide-if-no-customize">%s</a>', |
222 | - wp_customize_url( $stylesheet ), |
|
223 | - __( 'Live Preview' ) |
|
222 | + wp_customize_url($stylesheet), |
|
223 | + __('Live Preview') |
|
224 | 224 | ); |
225 | 225 | } |
226 | 226 | |
227 | - if ( ! is_multisite() && current_user_can( 'delete_themes' ) ) { |
|
227 | + if (!is_multisite() && current_user_can('delete_themes')) { |
|
228 | 228 | $actions['delete'] = sprintf( |
229 | 229 | '<a class="submitdelete deletion" href="%s" onclick="return confirm( \'%s\' );">%s</a>', |
230 | - wp_nonce_url( 'themes.php?action=delete&stylesheet=' . urlencode( $stylesheet ), 'delete-theme_' . $stylesheet ), |
|
230 | + wp_nonce_url('themes.php?action=delete&stylesheet=' . urlencode($stylesheet), 'delete-theme_' . $stylesheet), |
|
231 | 231 | /* translators: %s: Theme name. */ |
232 | - esc_js( sprintf( __( "You are about to delete this theme '%s'\n 'Cancel' to stop, 'OK' to delete." ), $title ) ), |
|
233 | - __( 'Delete' ) |
|
232 | + esc_js(sprintf(__("You are about to delete this theme '%s'\n 'Cancel' to stop, 'OK' to delete."), $title)), |
|
233 | + __('Delete') |
|
234 | 234 | ); |
235 | 235 | } |
236 | 236 | |
237 | 237 | /** This filter is documented in wp-admin/includes/class-wp-ms-themes-list-table.php */ |
238 | - $actions = apply_filters( 'theme_action_links', $actions, $theme, 'all' ); |
|
238 | + $actions = apply_filters('theme_action_links', $actions, $theme, 'all'); |
|
239 | 239 | |
240 | 240 | /** This filter is documented in wp-admin/includes/class-wp-ms-themes-list-table.php */ |
241 | - $actions = apply_filters( "theme_action_links_{$stylesheet}", $actions, $theme, 'all' ); |
|
242 | - $delete_action = isset( $actions['delete'] ) ? '<div class="delete-theme">' . $actions['delete'] . '</div>' : ''; |
|
243 | - unset( $actions['delete'] ); |
|
241 | + $actions = apply_filters("theme_action_links_{$stylesheet}", $actions, $theme, 'all'); |
|
242 | + $delete_action = isset($actions['delete']) ? '<div class="delete-theme">' . $actions['delete'] . '</div>' : ''; |
|
243 | + unset($actions['delete']); |
|
244 | 244 | |
245 | 245 | $screenshot = $theme->get_screenshot(); |
246 | 246 | ?> |
247 | 247 | |
248 | 248 | <span class="screenshot hide-if-customize"> |
249 | - <?php if ( $screenshot ) : ?> |
|
250 | - <img src="<?php echo esc_url( $screenshot . '?ver=' . $theme->version ); ?>" alt="" /> |
|
249 | + <?php if ($screenshot) : ?> |
|
250 | + <img src="<?php echo esc_url($screenshot . '?ver=' . $theme->version); ?>" alt="" /> |
|
251 | 251 | <?php endif; ?> |
252 | 252 | </span> |
253 | - <a href="<?php echo wp_customize_url( $stylesheet ); ?>" class="screenshot load-customize hide-if-no-customize"> |
|
254 | - <?php if ( $screenshot ) : ?> |
|
255 | - <img src="<?php echo esc_url( $screenshot . '?ver=' . $theme->version ); ?>" alt="" /> |
|
253 | + <a href="<?php echo wp_customize_url($stylesheet); ?>" class="screenshot load-customize hide-if-no-customize"> |
|
254 | + <?php if ($screenshot) : ?> |
|
255 | + <img src="<?php echo esc_url($screenshot . '?ver=' . $theme->version); ?>" alt="" /> |
|
256 | 256 | <?php endif; ?> |
257 | 257 | </a> |
258 | 258 | |
@@ -260,31 +260,31 @@ discard block |
||
260 | 260 | <div class="theme-author"> |
261 | 261 | <?php |
262 | 262 | /* translators: %s: Theme author. */ |
263 | - printf( __( 'By %s' ), $author ); |
|
263 | + printf(__('By %s'), $author); |
|
264 | 264 | ?> |
265 | 265 | </div> |
266 | 266 | <div class="action-links"> |
267 | 267 | <ul> |
268 | - <?php foreach ( $actions as $action ) : ?> |
|
268 | + <?php foreach ($actions as $action) : ?> |
|
269 | 269 | <li><?php echo $action; ?></li> |
270 | 270 | <?php endforeach; ?> |
271 | - <li class="hide-if-no-js"><a href="#" class="theme-detail"><?php _e( 'Details' ); ?></a></li> |
|
271 | + <li class="hide-if-no-js"><a href="#" class="theme-detail"><?php _e('Details'); ?></a></li> |
|
272 | 272 | </ul> |
273 | 273 | <?php echo $delete_action; ?> |
274 | 274 | |
275 | - <?php theme_update_available( $theme ); ?> |
|
275 | + <?php theme_update_available($theme); ?> |
|
276 | 276 | </div> |
277 | 277 | |
278 | 278 | <div class="themedetaildiv hide-if-js"> |
279 | - <p><strong><?php _e( 'Version:' ); ?></strong> <?php echo $version; ?></p> |
|
280 | - <p><?php echo $theme->display( 'Description' ); ?></p> |
|
279 | + <p><strong><?php _e('Version:'); ?></strong> <?php echo $version; ?></p> |
|
280 | + <p><?php echo $theme->display('Description'); ?></p> |
|
281 | 281 | <?php |
282 | - if ( $theme->parent() ) { |
|
282 | + if ($theme->parent()) { |
|
283 | 283 | printf( |
284 | 284 | /* translators: 1: Link to documentation on child themes, 2: Name of parent theme. */ |
285 | - ' <p class="howto">' . __( 'This <a href="%1$s">child theme</a> requires its parent theme, %2$s.' ) . '</p>', |
|
286 | - __( 'https://developer.wordpress.org/themes/advanced-topics/child-themes/' ), |
|
287 | - $theme->parent()->display( 'Name' ) |
|
285 | + ' <p class="howto">' . __('This <a href="%1$s">child theme</a> requires its parent theme, %2$s.') . '</p>', |
|
286 | + __('https://developer.wordpress.org/themes/advanced-topics/child-themes/'), |
|
287 | + $theme->parent()->display('Name') |
|
288 | 288 | ); |
289 | 289 | } |
290 | 290 | ?> |
@@ -299,32 +299,32 @@ discard block |
||
299 | 299 | * @param WP_Theme $theme |
300 | 300 | * @return bool |
301 | 301 | */ |
302 | - public function search_theme( $theme ) { |
|
302 | + public function search_theme($theme) { |
|
303 | 303 | // Search the features. |
304 | - foreach ( $this->features as $word ) { |
|
305 | - if ( ! in_array( $word, $theme->get( 'Tags' ), true ) ) { |
|
304 | + foreach ($this->features as $word) { |
|
305 | + if (!in_array($word, $theme->get('Tags'), true)) { |
|
306 | 306 | return false; |
307 | 307 | } |
308 | 308 | } |
309 | 309 | |
310 | 310 | // Match all phrases. |
311 | - foreach ( $this->search_terms as $word ) { |
|
312 | - if ( in_array( $word, $theme->get( 'Tags' ), true ) ) { |
|
311 | + foreach ($this->search_terms as $word) { |
|
312 | + if (in_array($word, $theme->get('Tags'), true)) { |
|
313 | 313 | continue; |
314 | 314 | } |
315 | 315 | |
316 | - foreach ( array( 'Name', 'Description', 'Author', 'AuthorURI' ) as $header ) { |
|
316 | + foreach (array('Name', 'Description', 'Author', 'AuthorURI') as $header) { |
|
317 | 317 | // Don't mark up; Do translate. |
318 | - if ( false !== stripos( strip_tags( $theme->display( $header, false, true ) ), $word ) ) { |
|
318 | + if (false !== stripos(strip_tags($theme->display($header, false, true)), $word)) { |
|
319 | 319 | continue 2; |
320 | 320 | } |
321 | 321 | } |
322 | 322 | |
323 | - if ( false !== stripos( $theme->get_stylesheet(), $word ) ) { |
|
323 | + if (false !== stripos($theme->get_stylesheet(), $word)) { |
|
324 | 324 | continue; |
325 | 325 | } |
326 | 326 | |
327 | - if ( false !== stripos( $theme->get_template(), $word ) ) { |
|
327 | + if (false !== stripos($theme->get_template(), $word)) { |
|
328 | 328 | continue; |
329 | 329 | } |
330 | 330 | |
@@ -341,21 +341,21 @@ discard block |
||
341 | 341 | * |
342 | 342 | * @param array $extra_args |
343 | 343 | */ |
344 | - public function _js_vars( $extra_args = array() ) { |
|
345 | - $search_string = isset( $_REQUEST['s'] ) ? esc_attr( wp_unslash( $_REQUEST['s'] ) ) : ''; |
|
344 | + public function _js_vars($extra_args = array()) { |
|
345 | + $search_string = isset($_REQUEST['s']) ? esc_attr(wp_unslash($_REQUEST['s'])) : ''; |
|
346 | 346 | |
347 | 347 | $args = array( |
348 | 348 | 'search' => $search_string, |
349 | 349 | 'features' => $this->features, |
350 | 350 | 'paged' => $this->get_pagenum(), |
351 | - 'total_pages' => ! empty( $this->_pagination_args['total_pages'] ) ? $this->_pagination_args['total_pages'] : 1, |
|
351 | + 'total_pages' => !empty($this->_pagination_args['total_pages']) ? $this->_pagination_args['total_pages'] : 1, |
|
352 | 352 | ); |
353 | 353 | |
354 | - if ( is_array( $extra_args ) ) { |
|
355 | - $args = array_merge( $args, $extra_args ); |
|
354 | + if (is_array($extra_args)) { |
|
355 | + $args = array_merge($args, $extra_args); |
|
356 | 356 | } |
357 | 357 | |
358 | - printf( "<script type='text/javascript'>var theme_list_args = %s;</script>\n", wp_json_encode( $args ) ); |
|
358 | + printf("<script type='text/javascript'>var theme_list_args = %s;</script>\n", wp_json_encode($args)); |
|
359 | 359 | parent::_js_vars(); |
360 | 360 | } |
361 | 361 | } |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | * @since 4.3.0 |
70 | 70 | */ |
71 | 71 | public function __construct() { |
72 | - add_action( 'delete_attachment', array( $this, 'delete_attachment_data' ) ); |
|
73 | - add_filter( 'get_post_metadata', array( $this, 'get_post_metadata' ), 10, 4 ); |
|
72 | + add_action('delete_attachment', array($this, 'delete_attachment_data')); |
|
73 | + add_filter('get_post_metadata', array($this, 'get_post_metadata'), 10, 4); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -82,17 +82,17 @@ discard block |
||
82 | 82 | * @param int $parent_attachment_id Attachment ID of parent image. |
83 | 83 | * @return array An array with attachment object data. |
84 | 84 | */ |
85 | - public function create_attachment_object( $cropped, $parent_attachment_id ) { |
|
86 | - $parent = get_post( $parent_attachment_id ); |
|
87 | - $parent_url = wp_get_attachment_url( $parent->ID ); |
|
88 | - $url = str_replace( wp_basename( $parent_url ), wp_basename( $cropped ), $parent_url ); |
|
85 | + public function create_attachment_object($cropped, $parent_attachment_id) { |
|
86 | + $parent = get_post($parent_attachment_id); |
|
87 | + $parent_url = wp_get_attachment_url($parent->ID); |
|
88 | + $url = str_replace(wp_basename($parent_url), wp_basename($cropped), $parent_url); |
|
89 | 89 | |
90 | - $size = wp_getimagesize( $cropped ); |
|
91 | - $image_type = ( $size ) ? $size['mime'] : 'image/jpeg'; |
|
90 | + $size = wp_getimagesize($cropped); |
|
91 | + $image_type = ($size) ? $size['mime'] : 'image/jpeg'; |
|
92 | 92 | |
93 | 93 | $attachment = array( |
94 | 94 | 'ID' => $parent_attachment_id, |
95 | - 'post_title' => wp_basename( $cropped ), |
|
95 | + 'post_title' => wp_basename($cropped), |
|
96 | 96 | 'post_content' => $url, |
97 | 97 | 'post_mime_type' => $image_type, |
98 | 98 | 'guid' => $url, |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | * @param string $file File path of the attached image. |
112 | 112 | * @return int Attachment ID. |
113 | 113 | */ |
114 | - public function insert_attachment( $attachment, $file ) { |
|
115 | - $attachment_id = wp_insert_attachment( $attachment, $file ); |
|
116 | - $metadata = wp_generate_attachment_metadata( $attachment_id, $file ); |
|
114 | + public function insert_attachment($attachment, $file) { |
|
115 | + $attachment_id = wp_insert_attachment($attachment, $file); |
|
116 | + $metadata = wp_generate_attachment_metadata($attachment_id, $file); |
|
117 | 117 | |
118 | 118 | /** |
119 | 119 | * Filters the site icon attachment metadata. |
@@ -124,8 +124,8 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @param array $metadata Attachment metadata. |
126 | 126 | */ |
127 | - $metadata = apply_filters( 'site_icon_attachment_metadata', $metadata ); |
|
128 | - wp_update_attachment_metadata( $attachment_id, $metadata ); |
|
127 | + $metadata = apply_filters('site_icon_attachment_metadata', $metadata); |
|
128 | + wp_update_attachment_metadata($attachment_id, $metadata); |
|
129 | 129 | |
130 | 130 | return $attachment_id; |
131 | 131 | } |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | * @param array[] $sizes Array of arrays containing information for additional sizes. |
139 | 139 | * @return array[] Array of arrays containing additional image sizes. |
140 | 140 | */ |
141 | - public function additional_sizes( $sizes = array() ) { |
|
141 | + public function additional_sizes($sizes = array()) { |
|
142 | 142 | $only_crop_sizes = array(); |
143 | 143 | |
144 | 144 | /** |
@@ -148,22 +148,22 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @param int[] $site_icon_sizes Array of sizes available for the Site Icon. |
150 | 150 | */ |
151 | - $this->site_icon_sizes = apply_filters( 'site_icon_image_sizes', $this->site_icon_sizes ); |
|
151 | + $this->site_icon_sizes = apply_filters('site_icon_image_sizes', $this->site_icon_sizes); |
|
152 | 152 | |
153 | 153 | // Use a natural sort of numbers. |
154 | - natsort( $this->site_icon_sizes ); |
|
155 | - $this->site_icon_sizes = array_reverse( $this->site_icon_sizes ); |
|
154 | + natsort($this->site_icon_sizes); |
|
155 | + $this->site_icon_sizes = array_reverse($this->site_icon_sizes); |
|
156 | 156 | |
157 | 157 | // Ensure that we only resize the image into sizes that allow cropping. |
158 | - foreach ( $sizes as $name => $size_array ) { |
|
159 | - if ( isset( $size_array['crop'] ) ) { |
|
160 | - $only_crop_sizes[ $name ] = $size_array; |
|
158 | + foreach ($sizes as $name => $size_array) { |
|
159 | + if (isset($size_array['crop'])) { |
|
160 | + $only_crop_sizes[$name] = $size_array; |
|
161 | 161 | } |
162 | 162 | } |
163 | 163 | |
164 | - foreach ( $this->site_icon_sizes as $size ) { |
|
165 | - if ( $size < $this->min_size ) { |
|
166 | - $only_crop_sizes[ 'site_icon-' . $size ] = array( |
|
164 | + foreach ($this->site_icon_sizes as $size) { |
|
165 | + if ($size < $this->min_size) { |
|
166 | + $only_crop_sizes['site_icon-' . $size] = array( |
|
167 | 167 | 'width ' => $size, |
168 | 168 | 'height' => $size, |
169 | 169 | 'crop' => true, |
@@ -182,10 +182,10 @@ discard block |
||
182 | 182 | * @param string[] $sizes Array of image size names. |
183 | 183 | * @return string[] Array of image size names. |
184 | 184 | */ |
185 | - public function intermediate_image_sizes( $sizes = array() ) { |
|
185 | + public function intermediate_image_sizes($sizes = array()) { |
|
186 | 186 | /** This filter is documented in wp-admin/includes/class-wp-site-icon.php */ |
187 | - $this->site_icon_sizes = apply_filters( 'site_icon_image_sizes', $this->site_icon_sizes ); |
|
188 | - foreach ( $this->site_icon_sizes as $size ) { |
|
187 | + $this->site_icon_sizes = apply_filters('site_icon_image_sizes', $this->site_icon_sizes); |
|
188 | + foreach ($this->site_icon_sizes as $size) { |
|
189 | 189 | $sizes[] = 'site_icon-' . $size; |
190 | 190 | } |
191 | 191 | |
@@ -199,11 +199,11 @@ discard block |
||
199 | 199 | * |
200 | 200 | * @param int $post_id Attachment ID. |
201 | 201 | */ |
202 | - public function delete_attachment_data( $post_id ) { |
|
203 | - $site_icon_id = get_option( 'site_icon' ); |
|
202 | + public function delete_attachment_data($post_id) { |
|
203 | + $site_icon_id = get_option('site_icon'); |
|
204 | 204 | |
205 | - if ( $site_icon_id && $post_id == $site_icon_id ) { |
|
206 | - delete_option( 'site_icon' ); |
|
205 | + if ($site_icon_id && $post_id == $site_icon_id) { |
|
206 | + delete_option('site_icon'); |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | |
@@ -219,12 +219,12 @@ discard block |
||
219 | 219 | * @param bool $single Whether to return only the first value of the specified `$meta_key`. |
220 | 220 | * @return array|null|string The attachment metadata value, array of values, or null. |
221 | 221 | */ |
222 | - public function get_post_metadata( $value, $post_id, $meta_key, $single ) { |
|
223 | - if ( $single && '_wp_attachment_backup_sizes' === $meta_key ) { |
|
224 | - $site_icon_id = get_option( 'site_icon' ); |
|
222 | + public function get_post_metadata($value, $post_id, $meta_key, $single) { |
|
223 | + if ($single && '_wp_attachment_backup_sizes' === $meta_key) { |
|
224 | + $site_icon_id = get_option('site_icon'); |
|
225 | 225 | |
226 | - if ( $post_id == $site_icon_id ) { |
|
227 | - add_filter( 'intermediate_image_sizes', array( $this, 'intermediate_image_sizes' ) ); |
|
226 | + if ($post_id == $site_icon_id) { |
|
227 | + add_filter('intermediate_image_sizes', array($this, 'intermediate_image_sizes')); |
|
228 | 228 | } |
229 | 229 | } |
230 | 230 |