Make WordPress Core

Ticket #20506: 20506.2.diff

File 20506.2.diff, 5.0 KB (added by ryan, 13 years ago)

Cast user option to int. Remove auto check.

  • wp-admin/includes/dashboard.php

     
    193193 * @since 2.5.0
    194194 */
    195195function wp_dashboard() {
    196         global $screen_layout_columns;
    197 
    198196        $screen = get_current_screen();
    199         $class = 'columns-' . $screen_layout_columns;
     197        $class = 'columns-' . get_current_screen()->get_option( 'num_columns' );
    200198
    201199?>
    202200<div id="dashboard-widgets" class="metabox-holder <?php echo $class; ?>">
  • wp-admin/includes/screen.php

     
    566566         *
    567567         * @param string $option Option ID.
    568568         * @param mixed $key Optional. Specific array key for when the option is an array.
     569         * @param mixed $default Optional. The value to return if the option is not set. Default is null.
    569570         */
    570         public function get_option( $option, $key = false ) {
     571        public function get_option( $option, $key = false, $default = null ) {
    571572                if ( ! isset( $this->_options[ $option ] ) )
    572                         return null;
     573                        return $default;
    573574                if ( $key ) {
    574575                        if ( isset( $this->_options[ $option ][ $key ] ) )
    575576                                return $this->_options[ $option ][ $key ];
    576                         return null;
     577                        return $default;
    577578                }
    578579                return $this->_options[ $option ];
    579580        }
     
    665666        public function get_help_sidebar() {
    666667                return $this->_help_sidebar;
    667668        }
    668        
     669
    669670        /**
    670671         * Add a sidebar to the contextual help for the screen.
    671672         * Call this in template files after admin.php is loaded and before admin-header.php is loaded to add a sidebar to the contextual help.
     
    773774                                </div>
    774775                        </div>
    775776                <?php
     777                // Setup layout columns
     778
     779                // Back compat for plugins using the filter instead of add_screen_option()
     780                $columns = apply_filters( 'screen_layout_columns', array(), $this->id, $this );
     781
     782                if ( ! empty( $columns ) && isset( $columns[ $this->id ] ) )
     783                        $this->add_option( 'layout_columns', array('max' => $columns[ $this->id ] ) );
     784
     785                global $screen_layout_columns; // Global for back-compat.
     786                $screen_layout_columns = 0;
     787                if ( $this->get_option( 'layout_columns' ) ) {
     788                        $screen_layout_columns = (int) get_user_option("screen_layout_$this->id");
     789                        $num = $this->get_option( 'layout_columns', 'max' );
     790       
     791                        if ( ! $screen_layout_columns ) {
     792                                if ( $this->get_option( 'layout_columns', 'default' ) )
     793                                        $screen_layout_columns = $this->get_option( 'layout_columns', 'default' );
     794                        }
     795                }
     796                $this->add_option( 'num_columns', $screen_layout_columns );
     797
    776798                // Add screen options
    777799                if ( $this->show_screen_options() )
    778800                        $this->render_screen_options();
     
    907929         * @since 3.3.0
    908930         */
    909931        function render_screen_layout() {
    910                 global $screen_layout_columns;
    911 
    912                 // Back compat for plugins using the filter instead of add_screen_option()
    913                 $columns = apply_filters( 'screen_layout_columns', array(), $this->id, $this );
    914 
    915                 if ( ! empty( $columns ) && isset( $columns[ $this->id ] ) )
    916                         $this->add_option( 'layout_columns', array('max' => $columns[ $this->id ] ) );
    917 
    918                 if ( ! $this->get_option('layout_columns') ) {
    919                         $screen_layout_columns = 0;
     932                if ( ! $this->get_option('layout_columns') )
    920933                        return;
    921                 }
    922934
    923                 $screen_layout_columns = get_user_option("screen_layout_$this->id");
     935                $screen_layout_columns = $this->get_option( 'num_columns' );
    924936                $num = $this->get_option( 'layout_columns', 'max' );
    925937
    926                 if ( ! $screen_layout_columns || 'auto' == $screen_layout_columns ) {
    927                         if ( $this->get_option( 'layout_columns', 'default' ) )
    928                                 $screen_layout_columns = $this->get_option( 'layout_columns', 'default' );
    929                 }
    930 
    931938                ?>
    932939                <h5 class="screen-layout"><?php _e('Screen Layout'); ?></h5>
    933940                <div class='columns-prefs'><?php
  • wp-admin/edit-link-form.php

     
    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 1 == get_current_screen()->get_option( 'num_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/edit-form-advanced.php

     
    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 1 == get_current_screen()->get_option( 'num_columns' ) ? '1' : '2'; ?>">
    281281<div id="post-body-content">
    282282<?php if ( post_type_supports($post_type, 'title') ) { ?>
    283283<div id="titlediv">