Skip to content

Commit e43d2a7

Browse files
committed
Fix some hackificator odds and ends in wp-admin:
* `wp-activate.php` and `wp-admin/themes.php` don't need the closing PHP tag * Switch single quotes for HTML attribute values to double in a few places * Convert `include_once file.php` syntax to `include_once( 'file.php' )` * Add access modifiers to methods/members in: `_WP_List_Table_Compat`, `Walker_Nav_Menu_Edit`, `Walker_Nav_Menu_Checklist`, `WP_Screen`, `Walker_Category_Checklist` * `edit_user()` doesn't need to import the `$wpdb` global * `wp_list_widgets()` doesn't need to import the `$sidebars_widgets` global * switch/endswitch syntax is not supported in Hack * A `<ul>` in `wp-admin/users.php` is unclosed See #27881. git-svn-id: https://develop.svn.wordpress.org/trunk@28500 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 7b2c87d commit e43d2a7

27 files changed

Lines changed: 71 additions & 68 deletions

src/wp-activate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,4 @@ function wpmu_activate_stylesheet() {
128128
var key_input = document.getElementById('key');
129129
key_input && key_input.focus();
130130
</script>
131-
<?php get_footer(); ?>
131+
<?php get_footer();

src/wp-admin/includes/class-wp-comments-list-table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ public function extra_tablenav( $which ) {
248248
) );
249249

250250
foreach ( $comment_types as $type => $label )
251-
echo "\t<option value='" . esc_attr( $type ) . "'" . selected( $comment_type, $type, false ) . ">$label</option>\n";
251+
echo "\t" . '<option value="' . esc_attr( $type ) . '"' . selected( $comment_type, $type, false ) . ">$label</option>\n";
252252
?>
253253
</select>
254254
<?php

src/wp-admin/includes/class-wp-filesystem-ftpsockets.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ public function __construct($opt = '') {
2424
$this->errors = new WP_Error();
2525

2626
// Check if possible to use ftp functions.
27-
if ( ! @include_once ABSPATH . 'wp-admin/includes/class-ftp.php' )
28-
return false;
27+
if ( ! @include_once( ABSPATH . 'wp-admin/includes/class-ftp.php' ) ) {
28+
return false;
29+
}
2930
$this->ftp = new ftp();
3031

3132
if ( empty($opt['port']) )

src/wp-admin/includes/class-wp-list-table.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ protected function months_dropdown( $post_type ) {
421421
$m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0;
422422
?>
423423
<select name="m">
424-
<option<?php selected( $m, 0 ); ?> value='0'><?php _e( 'All dates' ); ?></option>
424+
<option<?php selected( $m, 0 ); ?> value="0"><?php _e( 'All dates' ); ?></option>
425425
<?php
426426
foreach ( $months as $arc_row ) {
427427
if ( 0 == $arc_row->year )

src/wp-admin/includes/class-wp-upgrader-skins.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ public function error($error) {
227227
$this->error = $this->upgrader->strings[$error];
228228

229229
if ( is_wp_error($error) ) {
230+
$messages = array();
230231
foreach ( $error->get_error_messages() as $emessage ) {
231232
if ( $error->get_error_data() && is_string( $error->get_error_data() ) )
232233
$messages[] = $emessage . ' ' . esc_html( strip_tags( $error->get_error_data() ) );

src/wp-admin/includes/export.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,9 @@ function wxr_filter_postmeta( $return_me, $meta_key ) {
441441
<wp:meta_key><?php echo $meta->meta_key; ?></wp:meta_key>
442442
<wp:meta_value><?php echo wxr_cdata( $meta->meta_value ); ?></wp:meta_value>
443443
</wp:postmeta>
444-
<?php endforeach; ?>
445-
<?php $comments = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved <> 'spam'", $post->ID ) );
444+
<?php endforeach;
445+
446+
$comments = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved <> 'spam'", $post->ID ) );
446447
foreach ( $comments as $c ) : ?>
447448
<wp:comment>
448449
<wp:comment_id><?php echo $c->comment_ID; ?></wp:comment_id>

src/wp-admin/includes/list-table.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ function print_column_headers($screen, $id = true) {
8484
* @since 3.1.0
8585
*/
8686
class _WP_List_Table_Compat extends WP_List_Table {
87-
var $_screen;
88-
var $_columns;
87+
public $_screen;
88+
public $_columns;
8989

90-
function _WP_List_Table_Compat( $screen, $columns = array() ) {
90+
public function _WP_List_Table_Compat( $screen, $columns = array() ) {
9191
if ( is_string( $screen ) )
9292
$screen = convert_to_screen( $screen );
9393

@@ -99,15 +99,15 @@ function _WP_List_Table_Compat( $screen, $columns = array() ) {
9999
}
100100
}
101101

102-
function get_column_info() {
102+
public function get_column_info() {
103103
$columns = get_column_headers( $this->_screen );
104104
$hidden = get_hidden_columns( $this->_screen );
105105
$sortable = array();
106106

107107
return array( $columns, $hidden, $sortable );
108108
}
109109

110-
function get_columns() {
110+
public function get_columns() {
111111
return $this->_columns;
112112
}
113113
}

src/wp-admin/includes/menu.php

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,19 @@
7171
$_wp_submenu_nopriv = array();
7272
$_wp_menu_nopriv = array();
7373
// Loop over submenus and remove pages for which the user does not have privs.
74-
foreach ( array( 'submenu' ) as $sub_loop ) {
75-
foreach ($$sub_loop as $parent => $sub) {
76-
foreach ($sub as $index => $data) {
77-
if ( ! current_user_can($data[1]) ) {
78-
unset(${$sub_loop}[$parent][$index]);
79-
$_wp_submenu_nopriv[$parent][$data[2]] = true;
80-
}
74+
foreach ($submenu as $parent => $sub) {
75+
foreach ($sub as $index => $data) {
76+
if ( ! current_user_can($data[1]) ) {
77+
unset($submenu[$parent][$index]);
78+
$_wp_submenu_nopriv[$parent][$data[2]] = true;
8179
}
82-
unset($index, $data);
83-
84-
if ( empty(${$sub_loop}[$parent]) )
85-
unset(${$sub_loop}[$parent]);
8680
}
87-
unset($sub, $parent);
81+
unset($index, $data);
82+
83+
if ( empty($submenu[$parent]) )
84+
unset($submenu[$parent]);
8885
}
89-
unset($sub_loop);
86+
unset($sub, $parent);
9087

9188
/*
9289
* Loop over the top-level menu.

src/wp-admin/includes/nav-menu.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
1919
* @param int $depth Depth of menu item. Used for padding.
2020
* @param array $args Not used.
2121
*/
22-
function start_lvl( &$output, $depth = 0, $args = array() ) {}
22+
public function start_lvl( &$output, $depth = 0, $args = array() ) {}
2323

2424
/**
2525
* Ends the list of after the elements are added.
@@ -32,7 +32,7 @@ function start_lvl( &$output, $depth = 0, $args = array() ) {}
3232
* @param int $depth Depth of menu item. Used for padding.
3333
* @param array $args Not used.
3434
*/
35-
function end_lvl( &$output, $depth = 0, $args = array() ) {}
35+
public function end_lvl( &$output, $depth = 0, $args = array() ) {}
3636

3737
/**
3838
* Start the element output.
@@ -46,7 +46,7 @@ function end_lvl( &$output, $depth = 0, $args = array() ) {}
4646
* @param array $args Not used.
4747
* @param int $id Not used.
4848
*/
49-
function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
49+
public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
5050
global $_wp_nav_menu_max_depth;
5151
$_wp_nav_menu_max_depth = $depth > $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth;
5252

@@ -235,7 +235,7 @@ function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
235235
* @uses Walker_Nav_Menu
236236
*/
237237
class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {
238-
function __construct( $fields = false ) {
238+
public function __construct( $fields = false ) {
239239
if ( $fields ) {
240240
$this->db_fields = $fields;
241241
}
@@ -252,7 +252,7 @@ function __construct( $fields = false ) {
252252
* @param int $depth Depth of page. Used for padding.
253253
* @param array $args Not used.
254254
*/
255-
function start_lvl( &$output, $depth = 0, $args = array() ) {
255+
public function start_lvl( &$output, $depth = 0, $args = array() ) {
256256
$indent = str_repeat( "\t", $depth );
257257
$output .= "\n$indent<ul class='children'>\n";
258258
}
@@ -268,7 +268,7 @@ function start_lvl( &$output, $depth = 0, $args = array() ) {
268268
* @param int $depth Depth of page. Used for padding.
269269
* @param array $args Not used.
270270
*/
271-
function end_lvl( &$output, $depth = 0, $args = array() ) {
271+
public function end_lvl( &$output, $depth = 0, $args = array() ) {
272272
$indent = str_repeat( "\t", $depth );
273273
$output .= "\n$indent</ul>";
274274
}
@@ -286,7 +286,7 @@ function end_lvl( &$output, $depth = 0, $args = array() ) {
286286
* @param array $args Not used.
287287
* @param int $id Not used.
288288
*/
289-
function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
289+
public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
290290
global $_nav_menu_placeholder;
291291

292292
$_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1;

src/wp-admin/includes/revision.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ function wp_prepare_revisions_for_js( $post, $selected_revision_id, $from = null
126126
cache_users( wp_list_pluck( $revisions, 'post_author' ) );
127127

128128
$can_restore = current_user_can( 'edit_post', $post->ID );
129+
$current_id = false;
129130

130131
foreach ( $revisions as $revision ) {
131132
$modified = strtotime( $revision->post_modified );

0 commit comments

Comments
 (0)