Make WordPress Core

Ticket #20506: edit-form-fix.2.diff

File edit-form-fix.2.diff, 5.4 KB (added by griffinjt, 13 years ago)
  • wp-admin/includes/screen.php

     
    773773                                </div>
    774774                        </div>
    775775                <?php
     776                // Get the screen layout since we need it for class identifiers
     777                $this->get_screen_layout();
     778               
    776779                // Add screen options
    777780                if ( $this->show_screen_options() )
    778781                        $this->render_screen_options();
     
    902905        }
    903906
    904907        /**
    905          * Render the option for number of columns on the page
     908         * Render the HTML for the number of columns on the page.
    906909         *
    907910         * @since 3.3.0
     911         *
     912         * @global int $screen_layout_columns The number of columns on the page
    908913         */
    909914        function render_screen_layout() {
    910915                global $screen_layout_columns;
     916                $num = $this->get_option( 'layout_columns', 'max' );
     917                ?>
     918                <h5 class="screen-layout"><?php _e('Screen Layout'); ?></h5>
     919                <div class='columns-prefs'><?php
     920                        _e('Number of Columns:');
     921                        for ( $i = 1; $i <= $num; ++$i ):
     922                                ?>
     923                                <label class="columns-prefs-<?php echo $i; ?>">
     924                                        <input type='radio' name='screen_columns' value='<?php echo esc_attr( $i ); ?>'
     925                                                <?php checked( $screen_layout_columns, $i ); ?> />
     926                                        <?php echo esc_html( $i ); ?>
     927                                </label>
     928                                <?php
     929                        endfor; ?>
     930                </div>
     931                <?php
     932        }
     933       
     934        /**
     935         * Set up the global $screen_layout_columns to determine the number of metabox
     936         * columns on the page.
     937         *
     938         * @since 3.4.0
     939         *
     940         * @global int $screen_layout_columns The number of columns on the page
     941         */
     942        function get_screen_layout() {
     943       
     944                global $screen_layout_columns;
    911945
    912946                // Back compat for plugins using the filter instead of add_screen_option()
    913947                $columns = apply_filters( 'screen_layout_columns', array(), $this->id, $this );
     
    921955                }
    922956
    923957                $screen_layout_columns = get_user_option("screen_layout_$this->id");
    924                 $num = $this->get_option( 'layout_columns', 'max' );
    925958
    926959                if ( ! $screen_layout_columns || 'auto' == $screen_layout_columns ) {
    927960                        if ( $this->get_option( 'layout_columns', 'default' ) )
    928961                                $screen_layout_columns = $this->get_option( 'layout_columns', 'default' );
    929962                }
    930 
    931                 ?>
    932                 <h5 class="screen-layout"><?php _e('Screen Layout'); ?></h5>
    933                 <div class='columns-prefs'><?php
    934                         _e('Number of Columns:');
    935                         for ( $i = 1; $i <= $num; ++$i ):
    936                                 ?>
    937                                 <label class="columns-prefs-<?php echo $i; ?>">
    938                                         <input type='radio' name='screen_columns' value='<?php echo esc_attr( $i ); ?>'
    939                                                 <?php checked( $screen_layout_columns, $i ); ?> />
    940                                         <?php echo esc_html( $i ); ?>
    941                                 </label>
    942                                 <?php
    943                         endfor; ?>
    944                 </div>
    945                 <?php
     963               
     964                /** Have the method return the number of columns as well */
     965                return $screen_layout_columns;
     966       
    946967        }
    947968
    948969        /**
  • wp-admin/edit-form-advanced.php

     
    243243require_once('./admin-header.php');
    244244?>
    245245
    246 <div class="wrap columns-<?php echo (int) $screen_layout_columns ? (int) $screen_layout_columns : 'auto'; ?>">
     246<div class="wrap columns-<?php echo !empty( $screen_layout_columns ) ? (int) $screen_layout_columns : 'auto'; ?>">
    247247<?php screen_icon(); ?>
    248248<h2><?php echo esc_html( $title ); ?><?php if ( isset( $post_new_file ) ) : ?> <a href="<?php echo esc_url( $post_new_file ) ?>" class="add-new-h2"><?php echo esc_html($post_type_object->labels->add_new); ?></a><?php endif; ?></h2>
    249249<?php if ( $notice ) : ?>
     
    277277
    278278<div id="poststuff">
    279279
    280 <div id="post-body" class="metabox-holder columns-<?php echo 1 == $screen_layout_columns ? '1' : '2'; ?>">
     280<div id="post-body" class="metabox-holder columns-<?php echo !empty( $screen_layout_columns ) && 1 == $screen_layout_columns ? '1' : '2'; ?>">
    281281<div id="post-body-content">
    282282<?php if ( post_type_supports($post_type, 'title') ) { ?>
    283283<div id="titlediv">
  • wp-admin/edit-link-form.php

     
    5757require_once ('admin-header.php');
    5858?>
    5959
    60 <div class="wrap columns-<?php echo (int) $screen_layout_columns ? (int) $screen_layout_columns : 'auto'; ?>">
     60<div class="wrap columns-<?php echo !empty( $screen_layout_columns ) ? (int) $screen_layout_columns : 'auto'; ?>">
    6161<?php screen_icon(); ?>
    6262<h2><?php echo esc_html( $title ); ?>  <a href="link-add.php" class="add-new-h2"><?php echo esc_html_x('Add New', 'link'); ?></a></h2>
    6363
     
    7777
    7878<div id="poststuff">
    7979
    80 <div id="post-body" class="metabox-holder columns-<?php echo 1 == $screen_layout_columns ? '1' : '2'; ?>">
     80<div id="post-body" class="metabox-holder columns-<?php echo !empty( $screen_layout_columns ) && 1 == $screen_layout_columns ? '1' : '2'; ?>">
    8181<div id="post-body-content">
    8282<div id="namediv" class="stuffbox">
    8383<h3><label for="link_name"><?php _ex('Name', 'link name') ?></label></h3>
  • wp-admin/includes/dashboard.php

     
    196196        global $screen_layout_columns;
    197197
    198198        $screen = get_current_screen();
    199         $class = 'columns-' . $screen_layout_columns;
     199        if ( !empty( $screen_layout_columns ) )
     200                $class = 'columns-' . $screen_layout_columns;
    200201
    201202?>
    202203<div id="dashboard-widgets" class="metabox-holder <?php echo $class; ?>">