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
This commit is contained in:
Scott Taylor
2014-05-19 05:03:44 +00:00
parent 7b2c87df9a
commit e43d2a73d8
27 changed files with 71 additions and 68 deletions
@@ -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
@@ -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']) )
@@ -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 )
@@ -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() ) );
+3 -2
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>
+5 -5
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;
}
}
+10 -13
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.
+7 -7
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;
+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 );
+5 -5
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;
+9 -7
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.
+4 -4
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";
}
}
+1 -1
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;
+1 -1
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;
+1 -1
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' );