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.

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


git-svn-id: http://core.svn.wordpress.org/trunk@28326 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2014-05-19 05:04:16 +00:00
parent 511eabe5f3
commit 2f513d3320
27 changed files with 71 additions and 68 deletions

View File

@ -128,4 +128,4 @@ get_header();
var key_input = document.getElementById('key');
key_input && key_input.focus();
</script>
<?php get_footer(); ?>
<?php get_footer();

View File

@ -248,7 +248,7 @@ class WP_Comments_List_Table extends WP_List_Table {
) );
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

View File

@ -24,8 +24,9 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
$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']) )

View File

@ -421,7 +421,7 @@ class WP_List_Table {
$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 )

View File

@ -227,6 +227,7 @@ class Bulk_Upgrader_Skin extends WP_Upgrader_Skin {
$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() ) );

View File

@ -441,8 +441,9 @@ function export_wp( $args = array() ) {
<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>

View File

@ -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 );
@ -99,7 +99,7 @@ class _WP_List_Table_Compat extends WP_List_Table {
}
}
function get_column_info() {
public function get_column_info() {
$columns = get_column_headers( $this->_screen );
$hidden = get_hidden_columns( $this->_screen );
$sortable = array();
@ -107,7 +107,7 @@ class _WP_List_Table_Compat extends WP_List_Table {
return array( $columns, $hidden, $sortable );
}
function get_columns() {
public function get_columns() {
return $this->_columns;
}
}

View File

@ -71,22 +71,19 @@ unset($menu_page, $compat);
$_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.

View File

@ -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.
@ -32,7 +32,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 end_lvl( &$output, $depth = 0, $args = array() ) {}
public function end_lvl( &$output, $depth = 0, $args = array() ) {}
/**
* Start the element output.
@ -46,7 +46,7 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
* @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;
@ -235,7 +235,7 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
* @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;
}
@ -252,7 +252,7 @@ class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {
* @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";
}
@ -268,7 +268,7 @@ class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {
* @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>";
}
@ -286,7 +286,7 @@ class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {
* @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;

View File

@ -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 );

View File

@ -530,7 +530,7 @@ final class WP_Screen {
* @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;
@ -581,7 +581,7 @@ final class WP_Screen {
* @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;
}
@ -593,7 +593,7 @@ final class WP_Screen {
*
* @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 );
@ -1089,7 +1089,7 @@ final class WP_Screen {
*
* @since 3.3.0
*/
function render_screen_layout() {
public function render_screen_layout() {
if ( ! $this->get_option('layout_columns') )
return;
@ -1118,7 +1118,7 @@ final class WP_Screen {
*
* @since 3.3.0
*/
function render_per_page_options() {
public function render_per_page_options() {
if ( ! $this->get_option( 'per_page' ) )
return;

View File

@ -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.

View File

@ -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";
}
@ -51,7 +51,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 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";
}
@ -69,7 +69,7 @@ class Walker_Category_Checklist extends Walker {
* @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 {
@ -106,7 +106,7 @@ class Walker_Category_Checklist extends Walker {
* @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";
}
}

View File

@ -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;

View File

@ -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;

View File

@ -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' );

View File

@ -14,7 +14,7 @@ $submenu_file = 'upload.php';
wp_reset_vars(array('action'));
switch( $action ) :
switch ( $action ) {
case 'editattachment' :
$attachment_id = (int) $_POST['attachment_id'];
check_admin_referer('media-form');
@ -143,4 +143,4 @@ default:
wp_redirect( admin_url('upload.php') );
exit;
endswitch;
}

View File

@ -86,7 +86,7 @@ switch ( $action ) {
}
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) ?>";

View File

@ -285,7 +285,7 @@ if ( isset( $_REQUEST['updated'] ) && $_REQUEST['updated'] == 'true' && ! empty(
<?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>

View File

@ -204,7 +204,7 @@ include( ABSPATH . 'wp-admin/admin-header.php' ); ?>
<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" );

View File

@ -29,7 +29,7 @@ if ( ! $revision_id )
$revision_id = absint( $to );
$redirect = 'edit.php';
switch ( $action ) :
switch ( $action ) {
case 'restore' :
if ( ! $revision = wp_get_post_revision( $revision_id ) )
break;
@ -80,7 +80,7 @@ default :
$redirect = false;
break;
endswitch;
}
// Empty post_type means either malformed object found, or no valid parent was found.
if ( ! $redirect && empty( $post->post_type ) )

View File

@ -121,8 +121,7 @@ default:
$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;

View File

@ -367,4 +367,4 @@ if ( ! is_multisite() && current_user_can('edit_themes') && $broken_themes = wp_
</div>
</script>
<?php require( ABSPATH . 'wp-admin/admin-footer.php' ); ?>
<?php require( ABSPATH . 'wp-admin/admin-footer.php' );

View File

@ -363,7 +363,7 @@ function list_translation_updates() {
function do_core_upgrade( $reinstall = false ) {
global $wp_filesystem;
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
if ( $reinstall )
$url = 'update-core.php?action=do-core-reinstall';
@ -582,7 +582,7 @@ if ( 'upgrade-core' == $action ) {
require_once(ABSPATH . 'wp-admin/admin-header.php');
echo '<div class="wrap">';
echo '<h2>' . esc_html__('Update Plugins') . '</h2>';
echo "<iframe src='$url' style='width: 100%; height: 100%; min-height: 750px;' frameborder='0'></iframe>";
echo '<iframe src="', $url, '" style="width: 100%; height: 100%; min-height: 750px;" frameborder="0"></iframe>';
echo '</div>';
include(ABSPATH . 'wp-admin/admin-footer.php');

View File

@ -12,7 +12,7 @@ if ( ! defined( 'IFRAME_REQUEST' ) && isset( $_GET['action'] ) && in_array( $_GE
/** WordPress Administration Bootstrap */
require_once( dirname( __FILE__ ) . '/admin.php' );
include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
if ( isset($_GET['action']) ) {
$plugin = isset($_REQUEST['plugin']) ? trim($_REQUEST['plugin']) : '';
@ -95,7 +95,7 @@ if ( isset($_GET['action']) ) {
if ( ! current_user_can('install_plugins') )
wp_die( __( 'You do not have sufficient permissions to install plugins on this site.' ) );
include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; //for plugins_api..
include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api..
check_admin_referer('install-plugin_' . $plugin);
$api = plugins_api('plugin_information', array('slug' => $plugin, 'fields' => array('sections' => false) ) ); //Save on a bit of bandwidth.
@ -200,7 +200,7 @@ if ( isset($_GET['action']) ) {
if ( ! current_user_can('install_themes') )
wp_die( __( 'You do not have sufficient permissions to install themes on this site.' ) );
include_once ABSPATH . 'wp-admin/includes/theme-install.php'; //for themes_api..
include_once( ABSPATH . 'wp-admin/includes/theme-install.php' ); //for themes_api..
check_admin_referer( 'install-theme_' . $theme );
$api = themes_api('theme_information', array('slug' => $theme, 'fields' => array('sections' => false, 'tags' => false) ) ); //Save on a bit of bandwidth.

View File

@ -334,6 +334,7 @@ case 'remove':
}
}
?>
</ul>
<?php if ( $go_remove ) : ?>
<input type="hidden" name="action" value="doremove" />
<?php submit_button( __('Confirm Removal'), 'secondary' ); ?>

View File

@ -459,8 +459,8 @@ function wp_update_themes( $extra_stats = array() ) {
* @since 3.7.0
*/
function wp_maybe_auto_update() {
include_once ABSPATH . '/wp-admin/includes/admin.php';
include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php';
include_once( ABSPATH . '/wp-admin/includes/admin.php' );
include_once( ABSPATH . '/wp-admin/includes/class-wp-upgrader.php' );
$upgrader = new WP_Automatic_Updater;
$upgrader->run();