Skip to content

Commit

Permalink
Fix some hackificator odds and ends in wp-admin:
Browse files Browse the repository at this point in the history
* `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.

Built from https://develop.svn.wordpress.org/trunk@28500


git-svn-id: http://core.svn.wordpress.org/trunk@28326 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
staylor committed May 19, 2014
1 parent 511eabe commit 2f513d3
Show file tree
Hide file tree
Showing 27 changed files with 71 additions and 68 deletions.
2 changes: 1 addition & 1 deletion wp-activate.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,4 @@ function wpmu_activate_stylesheet() {
var key_input = document.getElementById('key');
key_input && key_input.focus();
</script>
<?php get_footer(); ?>
<?php get_footer();
2 changes: 1 addition & 1 deletion wp-admin/includes/class-wp-comments-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public function extra_tablenav( $which ) {
) );

foreach ( $comment_types as $type => $label )
echo "\t<option value='" . esc_attr( $type ) . "'" . selected( $comment_type, $type, false ) . ">$label</option>\n";
echo "\t" . '<option value="' . esc_attr( $type ) . '"' . selected( $comment_type, $type, false ) . ">$label</option>\n";
?>
</select>
<?php
Expand Down
5 changes: 3 additions & 2 deletions wp-admin/includes/class-wp-filesystem-ftpsockets.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ public function __construct($opt = '') {
$this->errors = new WP_Error();

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

if ( empty($opt['port']) )
Expand Down
2 changes: 1 addition & 1 deletion wp-admin/includes/class-wp-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ protected function months_dropdown( $post_type ) {
$m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0;
?>
<select name="m">
<option<?php selected( $m, 0 ); ?> value='0'><?php _e( 'All dates' ); ?></option>
<option<?php selected( $m, 0 ); ?> value="0"><?php _e( 'All dates' ); ?></option>
<?php
foreach ( $months as $arc_row ) {
if ( 0 == $arc_row->year )
Expand Down
1 change: 1 addition & 0 deletions wp-admin/includes/class-wp-upgrader-skins.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ public function error($error) {
$this->error = $this->upgrader->strings[$error];

if ( is_wp_error($error) ) {
$messages = array();
foreach ( $error->get_error_messages() as $emessage ) {
if ( $error->get_error_data() && is_string( $error->get_error_data() ) )
$messages[] = $emessage . ' ' . esc_html( strip_tags( $error->get_error_data() ) );
Expand Down
5 changes: 3 additions & 2 deletions wp-admin/includes/export.php
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,9 @@ function wxr_filter_postmeta( $return_me, $meta_key ) {
<wp:meta_key><?php echo $meta->meta_key; ?></wp:meta_key>
<wp:meta_value><?php echo wxr_cdata( $meta->meta_value ); ?></wp:meta_value>
</wp:postmeta>
<?php endforeach; ?>
<?php $comments = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved <> 'spam'", $post->ID ) );
<?php endforeach;

$comments = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved <> 'spam'", $post->ID ) );
foreach ( $comments as $c ) : ?>
<wp:comment>
<wp:comment_id><?php echo $c->comment_ID; ?></wp:comment_id>
Expand Down
10 changes: 5 additions & 5 deletions wp-admin/includes/list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ function print_column_headers($screen, $id = true) {
* @since 3.1.0
*/
class _WP_List_Table_Compat extends WP_List_Table {
var $_screen;
var $_columns;
public $_screen;
public $_columns;

function _WP_List_Table_Compat( $screen, $columns = array() ) {
public function _WP_List_Table_Compat( $screen, $columns = array() ) {
if ( is_string( $screen ) )
$screen = convert_to_screen( $screen );

Expand All @@ -99,15 +99,15 @@ function _WP_List_Table_Compat( $screen, $columns = array() ) {
}
}

function get_column_info() {
public function get_column_info() {
$columns = get_column_headers( $this->_screen );
$hidden = get_hidden_columns( $this->_screen );
$sortable = array();

return array( $columns, $hidden, $sortable );
}

function get_columns() {
public function get_columns() {
return $this->_columns;
}
}
23 changes: 10 additions & 13 deletions wp-admin/includes/menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,19 @@
$_wp_submenu_nopriv = array();
$_wp_menu_nopriv = array();
// Loop over submenus and remove pages for which the user does not have privs.
foreach ( array( 'submenu' ) as $sub_loop ) {
foreach ($$sub_loop as $parent => $sub) {
foreach ($sub as $index => $data) {
if ( ! current_user_can($data[1]) ) {
unset(${$sub_loop}[$parent][$index]);
$_wp_submenu_nopriv[$parent][$data[2]] = true;
}
foreach ($submenu as $parent => $sub) {
foreach ($sub as $index => $data) {
if ( ! current_user_can($data[1]) ) {
unset($submenu[$parent][$index]);
$_wp_submenu_nopriv[$parent][$data[2]] = true;
}
unset($index, $data);

if ( empty(${$sub_loop}[$parent]) )
unset(${$sub_loop}[$parent]);
}
unset($sub, $parent);
unset($index, $data);

if ( empty($submenu[$parent]) )
unset($submenu[$parent]);
}
unset($sub_loop);
unset($sub, $parent);

/*
* Loop over the top-level menu.
Expand Down
14 changes: 7 additions & 7 deletions wp-admin/includes/nav-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
* @param int $depth Depth of menu item. Used for padding.
* @param array $args Not used.
*/
function start_lvl( &$output, $depth = 0, $args = array() ) {}
public function start_lvl( &$output, $depth = 0, $args = array() ) {}

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

/**
* Start the element output.
Expand All @@ -46,7 +46,7 @@ function end_lvl( &$output, $depth = 0, $args = array() ) {}
* @param array $args Not used.
* @param int $id Not used.
*/
function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
global $_wp_nav_menu_max_depth;
$_wp_nav_menu_max_depth = $depth > $_wp_nav_menu_max_depth ? $depth : $_wp_nav_menu_max_depth;

Expand Down Expand Up @@ -235,7 +235,7 @@ function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
* @uses Walker_Nav_Menu
*/
class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {
function __construct( $fields = false ) {
public function __construct( $fields = false ) {
if ( $fields ) {
$this->db_fields = $fields;
}
Expand All @@ -252,7 +252,7 @@ function __construct( $fields = false ) {
* @param int $depth Depth of page. Used for padding.
* @param array $args Not used.
*/
function start_lvl( &$output, $depth = 0, $args = array() ) {
public function start_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat( "\t", $depth );
$output .= "\n$indent<ul class='children'>\n";
}
Expand All @@ -268,7 +268,7 @@ function start_lvl( &$output, $depth = 0, $args = array() ) {
* @param int $depth Depth of page. Used for padding.
* @param array $args Not used.
*/
function end_lvl( &$output, $depth = 0, $args = array() ) {
public function end_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat( "\t", $depth );
$output .= "\n$indent</ul>";
}
Expand All @@ -286,7 +286,7 @@ function end_lvl( &$output, $depth = 0, $args = array() ) {
* @param array $args Not used.
* @param int $id Not used.
*/
function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
public function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
global $_nav_menu_placeholder;

$_nav_menu_placeholder = ( 0 > $_nav_menu_placeholder ) ? intval($_nav_menu_placeholder) - 1 : -1;
Expand Down
1 change: 1 addition & 0 deletions wp-admin/includes/revision.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ function wp_prepare_revisions_for_js( $post, $selected_revision_id, $from = null
cache_users( wp_list_pluck( $revisions, 'post_author' ) );

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

foreach ( $revisions as $revision ) {
$modified = strtotime( $revision->post_modified );
Expand Down
10 changes: 5 additions & 5 deletions wp-admin/includes/screen.php
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ public static function get( $hook_name = '' ) {
* @see set_current_screen()
* @since 3.3.0
*/
function set_current_screen() {
public function set_current_screen() {
global $current_screen, $taxnow, $typenow;
$current_screen = $this;
$taxnow = $this->taxonomy;
Expand Down Expand Up @@ -581,7 +581,7 @@ public function in_admin( $admin = null ) {
* @param WP_Screen $screen A screen object.
* @param string $help Help text.
*/
static function add_old_compat_help( $screen, $help ) {
public static function add_old_compat_help( $screen, $help ) {
self::$_old_compat_help[ $screen->id ] = $help;
}

Expand All @@ -593,7 +593,7 @@ static function add_old_compat_help( $screen, $help ) {
*
* @param string $parent_file The parent file of the screen. Typically the $parent_file global.
*/
function set_parentage( $parent_file ) {
public function set_parentage( $parent_file ) {
$this->parent_file = $parent_file;
list( $this->parent_base ) = explode( '?', $parent_file );
$this->parent_base = str_replace( '.php', '', $this->parent_base );
Expand Down Expand Up @@ -1089,7 +1089,7 @@ public function render_screen_options() {
*
* @since 3.3.0
*/
function render_screen_layout() {
public function render_screen_layout() {
if ( ! $this->get_option('layout_columns') )
return;

Expand Down Expand Up @@ -1118,7 +1118,7 @@ function render_screen_layout() {
*
* @since 3.3.0
*/
function render_per_page_options() {
public function render_per_page_options() {
if ( ! $this->get_option( 'per_page' ) )
return;

Expand Down
16 changes: 9 additions & 7 deletions wp-admin/includes/taxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,16 +236,18 @@ function get_terms_to_edit( $post_id, $taxonomy = 'post_tag' ) {

$tags = wp_get_post_terms($post_id, $taxonomy, array());

if ( !$tags )
if ( !$tags ) {
return false;

if ( is_wp_error($tags) )
}
if ( is_wp_error($tags) ) {
return $tags;

foreach ( $tags as $tag )
}
$tag_names = array();
foreach ( $tags as $tag ) {
$tag_names[] = $tag->name;
$tags_to_edit = join( ',', $tag_names );
$tags_to_edit = esc_attr( $tags_to_edit );
}

$tags_to_edit = esc_attr( join( ',', $tag_names ) );

/**
* Filter the comma-separated list of terms available to edit.
Expand Down
8 changes: 4 additions & 4 deletions wp-admin/includes/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Walker_Category_Checklist extends Walker {
* @param int $depth Depth of category. Used for tab indentation.
* @param array $args An array of arguments. @see wp_terms_checklist()
*/
function start_lvl( &$output, $depth = 0, $args = array() ) {
public function start_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat("\t", $depth);
$output .= "$indent<ul class='children'>\n";
}
Expand All @@ -51,7 +51,7 @@ function start_lvl( &$output, $depth = 0, $args = array() ) {
* @param int $depth Depth of category. Used for tab indentation.
* @param array $args An array of arguments. @see wp_terms_checklist()
*/
function end_lvl( &$output, $depth = 0, $args = array() ) {
public function end_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat("\t", $depth);
$output .= "$indent</ul>\n";
}
Expand All @@ -69,7 +69,7 @@ function end_lvl( &$output, $depth = 0, $args = array() ) {
* @param array $args An array of arguments. @see wp_terms_checklist()
* @param int $id ID of the current term.
*/
function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
if ( empty( $args['taxonomy'] ) ) {
$taxonomy = 'category';
} else {
Expand Down Expand Up @@ -106,7 +106,7 @@ function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
* @param int $depth Depth of the term in reference to parents. Default 0.
* @param array $args An array of arguments. @see wp_terms_checklist()
*/
function end_el( &$output, $category, $depth = 0, $args = array() ) {
public function end_el( &$output, $category, $depth = 0, $args = array() ) {
$output .= "</li>\n";
}
}
Expand Down
2 changes: 1 addition & 1 deletion wp-admin/includes/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function find_core_auto_update() {
if ( ! $updates || empty( $updates->updates ) )
return false;

include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );

$auto_update = false;
$upgrader = new WP_Automatic_Updater;
Expand Down
2 changes: 1 addition & 1 deletion wp-admin/includes/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function add_user() {
* @return int user id of the updated user
*/
function edit_user( $user_id = 0 ) {
global $wp_roles, $wpdb;
global $wp_roles;
$user = new stdClass;
if ( $user_id ) {
$update = true;
Expand Down
2 changes: 1 addition & 1 deletion wp-admin/includes/widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* @since 2.5.0
*/
function wp_list_widgets() {
global $wp_registered_widgets, $sidebars_widgets, $wp_registered_widget_controls;
global $wp_registered_widgets, $wp_registered_widget_controls;

$sort = $wp_registered_widgets;
usort( $sort, '_sort_name_callback' );
Expand Down
4 changes: 2 additions & 2 deletions wp-admin/media.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

wp_reset_vars(array('action'));

switch( $action ) :
switch ( $action ) {
case 'editattachment' :
$attachment_id = (int) $_POST['attachment_id'];
check_admin_referer('media-form');
Expand Down Expand Up @@ -143,4 +143,4 @@
wp_redirect( admin_url('upload.php') );
exit;

endswitch;
}
2 changes: 1 addition & 1 deletion wp-admin/network/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
}
echo "</ul>";
?><p><?php _e( 'If your browser doesn&#8217;t start loading the next page automatically, click this link:' ); ?> <a class="button" href="upgrade.php?action=upgrade&amp;n=<?php echo ($n + 5) ?>"><?php _e("Next Sites"); ?></a></p>
<script type='text/javascript'>
<script type="text/javascript">
<!--
function nextpage() {
location.href = "upgrade.php?action=upgrade&n=<?php echo ($n + 5) ?>";
Expand Down
2 changes: 1 addition & 1 deletion wp-admin/network/users.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ function confirm_delete_users( $users ) {
<?php $wp_list_table->search_box( __( 'Search Users' ), 'all-user' ); ?>
</form>

<form id="form-user-list" action='users.php?action=allusers' method='post'>
<form id="form-user-list" action="users.php?action=allusers" method="post">
<?php $wp_list_table->display(); ?>
</form>
</div>
Expand Down
2 changes: 1 addition & 1 deletion wp-admin/options.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
<form name="form" action="options.php" method="post" id="all-options">
<?php wp_nonce_field('options-options') ?>
<input type="hidden" name="action" value="update" />
<input type='hidden' name='option_page' value='options' />
<input type="hidden" name="option_page" value="options" />
<table class="form-table">
<?php
$options = $wpdb->get_results( "SELECT * FROM $wpdb->options ORDER BY option_name" );
Expand Down
4 changes: 2 additions & 2 deletions wp-admin/revision.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
$revision_id = absint( $to );
$redirect = 'edit.php';

switch ( $action ) :
switch ( $action ) {
case 'restore' :
if ( ! $revision = wp_get_post_revision( $revision_id ) )
break;
Expand Down Expand Up @@ -80,7 +80,7 @@

$redirect = false;
break;
endswitch;
}

// Empty post_type means either malformed object found, or no valid parent was found.
if ( ! $redirect && empty( $post->post_type ) )
Expand Down
3 changes: 1 addition & 2 deletions wp-admin/theme-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@
$content = esc_textarea( $content );
}

?>
<?php if ( isset( $_GET['updated'] ) ) : ?>
if ( isset( $_GET['updated'] ) ) : ?>
<div id="message" class="updated"><p><?php _e( 'File edited successfully.' ) ?></p></div>
<?php endif;

Expand Down
Loading

0 comments on commit 2f513d3

Please sign in to comment.