Make WordPress Core

Changeset 28500


Ignore:
Timestamp:
05/19/2014 05:03:44 AM (11 years ago)
Author:
wonderboymusic
Message:

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.

Location:
trunk/src
Files:
27 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-activate.php

    r28373 r28500  
    129129    key_input && key_input.focus();
    130130</script>
    131 <?php get_footer(); ?>
     131<?php get_footer();
  • trunk/src/wp-admin/includes/class-wp-comments-list-table.php

    r28486 r28500  
    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>
  • trunk/src/wp-admin/includes/class-wp-filesystem-ftpsockets.php

    r28490 r28500  
    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
  • trunk/src/wp-admin/includes/class-wp-list-table.php

    r28497 r28500  
    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 ) {
  • trunk/src/wp-admin/includes/class-wp-upgrader-skins.php

    r28495 r28500  
    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() ) )
  • trunk/src/wp-admin/includes/export.php

    r27048 r28500  
    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>
  • trunk/src/wp-admin/includes/list-table.php

    r25254 r28500  
    8585 */
    8686class _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 );
     
    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 );
     
    108108    }
    109109
    110     function get_columns() {
     110    public function get_columns() {
    111111        return $this->_columns;
    112112    }
  • trunk/src/wp-admin/includes/menu.php

    r27671 r28500  
    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             }
    81         }
    82         unset($index, $data);
    83 
    84         if ( empty(${$sub_loop}[$parent]) )
    85             unset(${$sub_loop}[$parent]);
    86     }
    87     unset($sub, $parent);
    88 }
    89 unset($sub_loop);
     74foreach ($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;
     79        }
     80    }
     81    unset($index, $data);
     82
     83    if ( empty($submenu[$parent]) )
     84        unset($submenu[$parent]);
     85}
     86unset($sub, $parent);
    9087
    9188/*
  • trunk/src/wp-admin/includes/nav-menu.php

    r28300 r28500  
    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    /**
     
    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    /**
     
    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;
     
    236236 */
    237237class 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;
     
    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";
     
    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>";
     
    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
  • trunk/src/wp-admin/includes/revision.php

    r28264 r28500  
    127127
    128128    $can_restore = current_user_can( 'edit_post', $post->ID );
     129    $current_id = false;
    129130
    130131    foreach ( $revisions as $revision ) {
  • trunk/src/wp-admin/includes/screen.php

    r28348 r28500  
    531531     * @since 3.3.0
    532532     */
    533     function set_current_screen() {
     533    public function set_current_screen() {
    534534        global $current_screen, $taxnow, $typenow;
    535535        $current_screen = $this;
     
    582582     * @param string $help Help text.
    583583     */
    584     static function add_old_compat_help( $screen, $help ) {
     584    public static function add_old_compat_help( $screen, $help ) {
    585585        self::$_old_compat_help[ $screen->id ] = $help;
    586586    }
     
    594594     * @param string $parent_file The parent file of the screen. Typically the $parent_file global.
    595595     */
    596     function set_parentage( $parent_file ) {
     596    public function set_parentage( $parent_file ) {
    597597        $this->parent_file = $parent_file;
    598598        list( $this->parent_base ) = explode( '?', $parent_file );
     
    10901090     * @since 3.3.0
    10911091     */
    1092     function render_screen_layout() {
     1092    public function render_screen_layout() {
    10931093        if ( ! $this->get_option('layout_columns') )
    10941094            return;
     
    11191119     * @since 3.3.0
    11201120     */
    1121     function render_per_page_options() {
     1121    public function render_per_page_options() {
    11221122        if ( ! $this->get_option( 'per_page' ) )
    11231123            return;
  • trunk/src/wp-admin/includes/taxonomy.php

    r28474 r28500  
    237237    $tags = wp_get_post_terms($post_id, $taxonomy, array());
    238238
    239     if ( !$tags )
     239    if ( !$tags ) {
    240240        return false;
    241 
    242     if ( is_wp_error($tags) )
     241    }
     242    if ( is_wp_error($tags) ) {
    243243        return $tags;
    244 
    245     foreach ( $tags as $tag )
     244    }
     245    $tag_names = array();
     246    foreach ( $tags as $tag ) {
    246247        $tag_names[] = $tag->name;
    247     $tags_to_edit = join( ',', $tag_names );
    248     $tags_to_edit = esc_attr( $tags_to_edit );
     248    }
     249
     250    $tags_to_edit = esc_attr( join( ',', $tag_names ) );
    249251
    250252    /**
  • trunk/src/wp-admin/includes/template.php

    r28411 r28500  
    3636     * @param array  $args   An array of arguments. @see wp_terms_checklist()
    3737     */
    38     function start_lvl( &$output, $depth = 0, $args = array() ) {
     38    public function start_lvl( &$output, $depth = 0, $args = array() ) {
    3939        $indent = str_repeat("\t", $depth);
    4040        $output .= "$indent<ul class='children'>\n";
     
    5252     * @param array  $args   An array of arguments. @see wp_terms_checklist()
    5353     */
    54     function end_lvl( &$output, $depth = 0, $args = array() ) {
     54    public function end_lvl( &$output, $depth = 0, $args = array() ) {
    5555        $indent = str_repeat("\t", $depth);
    5656        $output .= "$indent</ul>\n";
     
    7070     * @param int    $id       ID of the current term.
    7171     */
    72     function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
     72    public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) {
    7373        if ( empty( $args['taxonomy'] ) ) {
    7474            $taxonomy = 'category';
     
    107107     * @param array  $args     An array of arguments. @see wp_terms_checklist()
    108108     */
    109     function end_el( &$output, $category, $depth = 0, $args = array() ) {
     109    public function end_el( &$output, $category, $depth = 0, $args = array() ) {
    110110        $output .= "</li>\n";
    111111    }
  • trunk/src/wp-admin/includes/update.php

    r28479 r28500  
    7575        return false;
    7676
    77     include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     77    include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
    7878
    7979    $auto_update = false;
  • trunk/src/wp-admin/includes/user.php

    r27467 r28500  
    2929 */
    3030function edit_user( $user_id = 0 ) {
    31     global $wp_roles, $wpdb;
     31    global $wp_roles;
    3232    $user = new stdClass;
    3333    if ( $user_id ) {
  • trunk/src/wp-admin/includes/widgets.php

    r27324 r28500  
    1313 */
    1414function wp_list_widgets() {
    15     global $wp_registered_widgets, $sidebars_widgets, $wp_registered_widget_controls;
     15    global $wp_registered_widgets, $wp_registered_widget_controls;
    1616
    1717    $sort = $wp_registered_widgets;
  • trunk/src/wp-admin/media.php

    r28497 r28500  
    1515wp_reset_vars(array('action'));
    1616
    17 switch( $action ) :
     17switch ( $action ) {
    1818case 'editattachment' :
    1919    $attachment_id = (int) $_POST['attachment_id'];
     
    144144    exit;
    145145
    146 endswitch;
     146}
  • trunk/src/wp-admin/network/upgrade.php

    r27469 r28500  
    8787        echo "</ul>";
    8888        ?><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>
    89         <script type='text/javascript'>
     89        <script type="text/javascript">
    9090        <!--
    9191        function nextpage() {
  • trunk/src/wp-admin/network/users.php

    r28497 r28500  
    286286    </form>
    287287
    288     <form id="form-user-list" action='users.php?action=allusers' method='post'>
     288    <form id="form-user-list" action="users.php?action=allusers" method="post">
    289289        <?php $wp_list_table->display(); ?>
    290290    </form>
  • trunk/src/wp-admin/options.php

    r28083 r28500  
    205205  <?php wp_nonce_field('options-options') ?>
    206206  <input type="hidden" name="action" value="update" />
    207   <input type='hidden' name='option_page' value='options' />
     207  <input type="hidden" name="option_page" value="options" />
    208208  <table class="form-table">
    209209<?php
  • trunk/src/wp-admin/revision.php

    r27469 r28500  
    3030$redirect = 'edit.php';
    3131
    32 switch ( $action ) :
     32switch ( $action ) {
    3333case 'restore' :
    3434    if ( ! $revision = wp_get_post_revision( $revision_id ) )
     
    8181    $redirect = false;
    8282    break;
    83 endswitch;
     83}
    8484
    8585// Empty post_type means either malformed object found, or no valid parent was found.
  • trunk/src/wp-admin/theme-editor.php

    r28313 r28500  
    122122    }
    123123
    124     ?>
    125 <?php if ( isset( $_GET['updated'] ) ) : ?>
     124    if ( isset( $_GET['updated'] ) ) : ?>
    126125 <div id="message" class="updated"><p><?php _e( 'File edited successfully.' ) ?></p></div>
    127126<?php endif;
  • trunk/src/wp-admin/themes.php

    r27936 r28500  
    368368</script>
    369369
    370 <?php require( ABSPATH . 'wp-admin/admin-footer.php' ); ?>
     370<?php require( ABSPATH . 'wp-admin/admin-footer.php' );
  • trunk/src/wp-admin/update-core.php

    r28314 r28500  
    364364    global $wp_filesystem;
    365365
    366     include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     366    include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
    367367
    368368    if ( $reinstall )
     
    583583    echo '<div class="wrap">';
    584584    echo '<h2>' . esc_html__('Update Plugins') . '</h2>';
    585     echo "<iframe src='$url' style='width: 100%; height: 100%; min-height: 750px;' frameborder='0'></iframe>";
     585    echo '<iframe src="', $url, '" style="width: 100%; height: 100%; min-height: 750px;" frameborder="0"></iframe>';
    586586    echo '</div>';
    587587    include(ABSPATH . 'wp-admin/admin-footer.php');
  • trunk/src/wp-admin/update.php

    r28126 r28500  
    1313require_once( dirname( __FILE__ ) . '/admin.php' );
    1414
    15 include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
     15include_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
    1616
    1717if ( isset($_GET['action']) ) {
     
    9696            wp_die( __( 'You do not have sufficient permissions to install plugins on this site.' ) );
    9797
    98         include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; //for plugins_api..
     98        include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api..
    9999
    100100        check_admin_referer('install-plugin_' . $plugin);
     
    201201            wp_die( __( 'You do not have sufficient permissions to install themes on this site.' ) );
    202202
    203         include_once ABSPATH . 'wp-admin/includes/theme-install.php'; //for themes_api..
     203        include_once( ABSPATH . 'wp-admin/includes/theme-install.php' ); //for themes_api..
    204204
    205205        check_admin_referer( 'install-theme_' . $theme );
  • trunk/src/wp-admin/users.php

    r28315 r28500  
    335335    }
    336336    ?>
     337</ul>
    337338<?php if ( $go_remove ) : ?>
    338339        <input type="hidden" name="action" value="doremove" />
  • trunk/src/wp-includes/update.php

    r28479 r28500  
    460460 */
    461461function wp_maybe_auto_update() {
    462     include_once ABSPATH . '/wp-admin/includes/admin.php';
    463     include_once ABSPATH . '/wp-admin/includes/class-wp-upgrader.php';
     462    include_once( ABSPATH . '/wp-admin/includes/admin.php' );
     463    include_once( ABSPATH . '/wp-admin/includes/class-wp-upgrader.php' );
    464464
    465465    $upgrader = new WP_Automatic_Updater;
Note: See TracChangeset for help on using the changeset viewer.