Make WordPress Core

Ticket #18785: 18785.2.diff

File 18785.2.diff, 24.0 KB (added by nacin, 13 years ago)
  • wp-admin/includes/deprecated.php

     
    805805        $current_screen->render_screen_meta();
    806806}
    807807
     808/**
     809 * Favorite actions were deprecated in version 3.2. Use the admin bar instead.
     810 *
     811 * @since 2.7.0
     812 * @deprecated 3.2.0
     813 */
     814function favorite_actions() {
     815        _deprecated_function( __FUNCTION__, '3.2', 'WP_Admin_Bar' );
     816}
     817
    808818function media_upload_image() {
    809819        __deprecated_function( __FUNCTION__, '3.3', 'wp_media_upload_handler()' );
    810820        return wp_media_upload_handler();
  • wp-admin/includes/screen.php

     
    1111 *
    1212 * @since 2.7.0
    1313 *
    14  * @param string|object $screen The screen you want the headers for
     14 * @param string|WP_Screen $screen The screen you want the headers for
    1515 * @return array Containing the headers in the format id => UI String
    1616 */
    1717function get_column_headers( $screen ) {
     
    3131 *
    3232 * @since 2.7.0
    3333 *
    34  * @param string|object $screen The screen you want the hidden columns for
     34 * @param string|WP_Screen $screen The screen you want the hidden columns for
    3535 * @return array
    3636 */
    3737function get_hidden_columns( $screen ) {
     
    4242}
    4343
    4444/**
    45  * {@internal Missing Short Description}}
     45 * Prints the meta box preferences for screen meta.
    4646 *
    4747 * @since 2.7.0
    4848 *
    49  * @param unknown_type $screen
     49 * @param string|WP_Screen $screen
    5050 */
    5151function meta_box_prefs( $screen ) {
    5252        global $wp_meta_boxes;
    5353
    54         if ( is_string($screen) )
    55                 $screen = convert_to_screen($screen);
     54        if ( is_string( $screen ) )
     55                $screen = convert_to_screen( $screen );
    5656
    5757        if ( empty($wp_meta_boxes[$screen->id]) )
    5858                return;
     
    8181 *
    8282 * @since 2.7.0
    8383 *
    84  * @param string|object $screen Screen identifier
     84 * @param string|WP_Screen $screen Screen
    8585 * @return array Hidden Meta Boxes
    8686 */
    8787function get_hidden_meta_boxes( $screen ) {
     
    9090
    9191        $hidden = get_user_option( "metaboxhidden_{$screen->id}" );
    9292
     93        $defaults = ! is_array( $hidden );
     94
    9395        // Hide slug boxes by default
    94         if ( !is_array( $hidden ) ) {
     96        if ( $defaults ) {
    9597                if ( 'post' == $screen->base || 'page' == $screen->base )
    9698                        $hidden = array('slugdiv', 'trackbacksdiv', 'postcustom', 'postexcerpt', 'commentstatusdiv', 'commentsdiv', 'authordiv', 'revisionsdiv');
    9799                else
     
    99101                $hidden = apply_filters('default_hidden_meta_boxes', $hidden, $screen);
    100102        }
    101103
    102         return $hidden;
     104        return apply_filters( 'hidden_meta_boxes', $hidden, $screen, $defaults );
    103105}
    104106
    105107/**
    106  * {@internal Missing Short Description}}
    107  *
    108  * @since 2.7.0
    109  */
    110 function favorite_actions( $screen = null ) {
    111         $default_action = false;
    112 
    113         if ( is_string($screen) )
    114                 $screen = convert_to_screen($screen);
    115 
    116         if ( $screen->is_user )
    117                 return;
    118 
    119         if ( isset($screen->post_type) ) {
    120                 $post_type_object = get_post_type_object($screen->post_type);
    121                 if ( 'add' != $screen->action )
    122                         $default_action = array('post-new.php?post_type=' . $post_type_object->name => array($post_type_object->labels->new_item, $post_type_object->cap->edit_posts));
    123                 else
    124                         $default_action = array('edit.php?post_type=' . $post_type_object->name => array($post_type_object->labels->name, $post_type_object->cap->edit_posts));
    125         }
    126 
    127         if ( !$default_action ) {
    128                 if ( $screen->is_network ) {
    129                         $default_action = array('sites.php' => array( __('Sites'), 'manage_sites'));
    130                 } else {
    131                         switch ( $screen->id ) {
    132                                 case 'upload':
    133                                         $default_action = array('media-new.php' => array(__('New Media'), 'upload_files'));
    134                                         break;
    135                                 case 'media':
    136                                         $default_action = array('upload.php' => array(__('Edit Media'), 'upload_files'));
    137                                         break;
    138                                 case 'link-manager':
    139                                 case 'link':
    140                                         if ( 'add' != $screen->action )
    141                                                 $default_action = array('link-add.php' => array(__('New Link'), 'manage_links'));
    142                                         else
    143                                                 $default_action = array('link-manager.php' => array(__('Edit Links'), 'manage_links'));
    144                                         break;
    145                                 case 'users':
    146                                         $default_action = array('user-new.php' => array(__('New User'), 'create_users'));
    147                                         break;
    148                                 case 'user':
    149                                         $default_action = array('users.php' => array(__('Edit Users'), 'edit_users'));
    150                                         break;
    151                                 case 'plugins':
    152                                         $default_action = array('plugin-install.php' => array(__('Install Plugins'), 'install_plugins'));
    153                                         break;
    154                                 case 'plugin-install':
    155                                         $default_action = array('plugins.php' => array(__('Manage Plugins'), 'activate_plugins'));
    156                                         break;
    157                                 case 'themes':
    158                                         $default_action = array('theme-install.php' => array(__('Install Themes'), 'install_themes'));
    159                                         break;
    160                                 case 'theme-install':
    161                                         $default_action = array('themes.php' => array(__('Manage Themes'), 'switch_themes'));
    162                                         break;
    163                                 default:
    164                                         $default_action = array('post-new.php' => array(__('New Post'), 'edit_posts'));
    165                                         break;
    166                         }
    167                 }
    168         }
    169 
    170         if ( !$screen->is_network ) {
    171                 $actions = array(
    172                         'post-new.php' => array(__('New Post'), 'edit_posts'),
    173                         'edit.php?post_status=draft' => array(__('Drafts'), 'edit_posts'),
    174                         'post-new.php?post_type=page' => array(__('New Page'), 'edit_pages'),
    175                         'media-new.php' => array(__('Upload'), 'upload_files'),
    176                         'edit-comments.php' => array(__('Comments'), 'moderate_comments')
    177                         );
    178         } else {
    179                 $actions = array(
    180                         'sites.php' => array( __('Sites'), 'manage_sites'),
    181                         'users.php' => array( __('Users'), 'manage_network_users')
    182                 );
    183         }
    184 
    185         $default_key = array_keys($default_action);
    186         $default_key = $default_key[0];
    187         if ( isset($actions[$default_key]) )
    188                 unset($actions[$default_key]);
    189         $actions = array_merge($default_action, $actions);
    190         $actions = apply_filters( 'favorite_actions', $actions, $screen );
    191 
    192         $allowed_actions = array();
    193         foreach ( $actions as $action => $data ) {
    194                 if ( current_user_can($data[1]) )
    195                         $allowed_actions[$action] = $data[0];
    196         }
    197 
    198         if ( empty($allowed_actions) )
    199                 return;
    200 
    201         $first = array_keys($allowed_actions);
    202         $first = $first[0];
    203         echo '<div id="favorite-actions">';
    204         echo '<div id="favorite-first"><a href="' . $first . '">' . $allowed_actions[$first] . '</a></div><div id="favorite-toggle"><br /></div>';
    205         echo '<div id="favorite-inside">';
    206 
    207         array_shift($allowed_actions);
    208 
    209         foreach ( $allowed_actions as $action => $label) {
    210                 echo "<div class='favorite-action'><a href='$action'>";
    211                 echo $label;
    212                 echo "</a></div>\n";
    213         }
    214         echo "</div></div>\n";
    215 }
    216 
    217 /**
    218108 * Convert a screen string to a screen object
    219109 *
    220110 * @since 3.0.0
    221111 *
    222  * @param string $screen The name of the screen
    223  * @return object An object containing the safe screen name and id
     112 * @param string $hook_name The hook name (also known as the hook suffix) used to determine the screen.
     113 * @return WP_Screen Screen object.
    224114 */
    225 function convert_to_screen( $screen ) {
    226         $screen = str_replace( array('.php', '-new', '-add', '-network', '-user' ), '', $screen);
    227 
    228         if ( is_network_admin() )
    229                 $screen .= '-network';
    230         elseif ( is_user_admin() )
    231                 $screen .= '-user';
    232 
    233         $screen = (string) apply_filters( 'screen_meta_screen', $screen );
    234         $screen = (object) array( 'id' => $screen, 'base' => $screen );
    235         return $screen;
     115function convert_to_screen( $hook_name ) {
     116        return WP_Screen::get( $hook_name );
    236117}
    237118
    238119/**
     
    251132        if ( is_string( $screen ) )
    252133                $screen = convert_to_screen( $screen );
    253134
    254         WP_Screen::add_old_compat_help( $screen->id, $help );
     135        WP_Screen::add_old_compat_help( $screen, $help );
    255136}
    256137
    257138/**
     
    272153        return $current_screen->add_option( $option, $args );
    273154}
    274155
     156/**
     157 * Displays a screen icon.
     158 *
     159 * @uses get_screen_icon()
     160 * @since 2.7.0
     161 *
     162 * @param string|WP_Screen $screen Optional. Accepts a screen object (and defaults to the current screen object)
     163 *      which it uses to determine an icon HTML ID. Or, if a string is provided, it is used to form the icon HTML ID.
     164 */
    275165function screen_icon( $screen = '' ) {
    276166        echo get_screen_icon( $screen );
    277167}
    278168
     169/**
     170 * Gets a screen icon.
     171 *
     172 * @since 3.2.0
     173 *
     174 * @param string|WP_Screen $screen Optional. Accepts a screen object (and defaults to the current screen object)
     175 *      which it uses to determine an icon HTML ID. Or, if a string is provided, it is used to form the icon HTML ID.
     176 * @return string HTML for the screen icon.
     177 */
    279178function get_screen_icon( $screen = '' ) {
    280         global $current_screen, $typenow;
     179        if ( empty( $screen ) )
     180                $screen = get_current_screen();
     181        elseif ( is_string( $screen ) )
     182                $icon_id = $screen;
    281183
    282         if ( empty($screen) )
    283                 $screen = $current_screen;
    284         elseif ( is_string($screen) )
    285                 $name = $screen;
    286 
    287184        $class = 'icon32';
    288185
    289         if ( empty($name) ) {
    290                 if ( !empty($screen->parent_base) )
    291                         $name = $screen->parent_base;
     186        if ( empty( $icon_id ) ) {
     187                if ( $screen->parent_base )
     188                        $icon_id = $screen->parent_base;
    292189                else
    293                         $name = $screen->base;
     190                        $icon_id = $screen->base;
    294191
    295                 if ( 'edit' == $name && isset($screen->post_type) && 'page' == $screen->post_type )
    296                         $name = 'edit-pages';
     192                if ( 'edit' == $icon_id && $screen->post_type && 'page' == $screen->post_type )
     193                        $icon_id = 'edit-pages';
    297194
    298                 $post_type = '';
    299                 if ( isset( $screen->post_type ) )
    300                         $post_type = $screen->post_type;
    301                 elseif ( $current_screen == $screen )
    302                         $post_type = $typenow;
    303                 if ( $post_type )
    304                         $class .= ' ' . sanitize_html_class( 'icon32-posts-' . $post_type );
     195                if ( $screen->post_type )
     196                        $class .= ' ' . sanitize_html_class( 'icon32-posts-' . $screen->post_type );
    305197        }
    306198
    307         return '<div id="icon-' . esc_attr( $name ) . '" class="' . $class . '"><br /></div>';
     199        return '<div id="icon-' . esc_attr( $icon_id ) . '" class="' . $class . '"><br /></div>';
    308200}
    309201
    310202/**
    311  *  Get the current screen object
     203 * Get the current screen object
    312204 *
    313  *  @since 3.1.0
     205 * @since 3.1.0
    314206 *
    315  * @return object Current screen object
     207 * @return WP_Screen Current screen object
    316208 */
    317209function get_current_screen() {
    318210        global $current_screen;
    319211
    320         if ( !isset($current_screen) )
     212        if ( ! isset( $current_screen ) )
    321213                return null;
    322214
    323215        return $current_screen;
     
    330222 *
    331223 * @uses $current_screen
    332224 *
    333  * @param string $id Screen id, optional.
     225 * @param string $hook_name Optional. The hook name (also known as the hook suffix) used to determine the screen,
     226 *      or an existing screen object.
    334227 */
    335 function set_current_screen( $id =  '' ) {
    336         global $current_screen;
    337 
    338         $current_screen = new WP_Screen( $id );
    339 
    340         $current_screen = apply_filters('current_screen', $current_screen);
     228function set_current_screen( $hook_name =  '' ) {
     229        $screen = WP_Screen::get( $hook_name );
     230        $screen->set_current_screen();
    341231}
    342232
    343233/**
    344  * A class representing the current admin screen.
     234 * A class representing the admin screen.
    345235 *
    346236 * @since 3.3.0
    347237 * @access public
    348238 */
    349239final class WP_Screen {
    350240        /**
    351          * Any action associated with the screen.  'add' for *-add.php and *-new.php screens.  Empty otherwise.
     241         * Any action associated with the screen. 'add' for *-add.php and *-new.php screens.  Empty otherwise.
    352242         *
    353243         * @since 3.3.0
    354244         * @var string
     
    440330         * @var array
    441331         * @access private
    442332         */
    443         private static $_help_tabs = array();
     333        private $_help_tabs = array();
    444334 
    445335        /**
    446336         * The help sidebar data associated with screens, if any.
     
    449339         * @var string
    450340         * @access private
    451341         */
    452         private static $_help_sidebar = array();
     342        private $_help_sidebar = '';
    453343
    454344        /**
    455345         * Stores old string-based help.
     
    463353         * @var array
    464354         * @access private
    465355         */
    466         private static $_options = array();
     356        private $_options = array();
    467357
    468358        /**
     359         * The screen object registry.
     360         *
     361         * @since 3.3.0
     362         * @var array
     363         * @access private
     364         */
     365        private static $_registry = array();
     366
     367        /**
    469368         * Stores the result of the public show_screen_options function.
    470369         *
    471370         * @since 3.3.0
     
    484383        private $_screen_settings;
    485384
    486385        /**
    487          * Constructor
     386         * Fetches a screen object.
    488387         *
    489388         * @since 3.3.0
     389         * @access public
    490390         *
    491          * @param string $id A screen id.  If empty, the $hook_suffix global is used to derive the ID.
     391         * @param string $hook_name Optional. The hook name (also known as the hook suffix) used to determine the screen.
     392         *      Defaults to the current $hook_suffix global.
     393         * @return WP_Screen Screen object.
    492394         */
    493         public function __construct( $id = '' ) {
    494                 global $hook_suffix, $typenow, $taxnow;
     395        public function get( $hook_name = '' ) {
    495396
    496                 $action = '';
     397                if ( is_a( $hook_name, 'WP_Screen' ) )
     398                        return $hook_name;
    497399
    498                 if ( empty( $id ) ) {
    499                         $screen = $hook_suffix;
    500                         $screen = str_replace('.php', '', $screen);
    501                         if ( preg_match('/-add|-new$/', $screen) )
    502                                 $action = 'add';
    503                         $screen = str_replace('-new', '', $screen);
    504                         $screen = str_replace('-add', '', $screen);
    505                         $this->id = $this->base = $screen;
    506                 } else {
    507                         $id = sanitize_key( $id );
    508                         if ( false !== strpos($id, '-') ) {
    509                                 list( $id, $typenow ) = explode('-', $id, 2);
    510                                 if ( taxonomy_exists( $typenow ) ) {
     400                $action = $post_type = $taxonomy = '';
     401
     402                if ( $hook_name ) {
     403                        if ( '-network' == substr( $hook_name, -8 ) )
     404                                $hook_name = str_replace( '-network', '', $hook_name );
     405                        elseif ( '-user' == substr( $hook_name, -5 ) )
     406                                $hook_name = str_replace( '-user', '', $hook_name );
     407                        $id = sanitize_key( $hook_name );
     408                        if ( false !== strpos( $id, '-' ) ) {
     409                                list( $id, $second ) = explode( '-', $id, 2 );
     410                                if ( taxonomy_exists( $second ) ) {
    511411                                        $id = 'edit-tags';
    512                                         $taxnow = $typenow;
    513                                         $typenow = '';
     412                                        $taxonomy = $second;
     413                                } elseif ( post_type_exists( $second ) ) {
     414                                        $post_type = $second;
     415                                } else {
     416                                        $id .= '-' . $second;
    514417                                }
    515418                        }
    516                         $this->id = $this->base = $id;
     419                } else {
     420                        $id = $GLOBALS['hook_suffix'];
     421                        $id = str_replace( '.php', '', $id );
     422                        if ( in_array( substr( $id, -4 ), array( '-add', '-new' ) ) )
     423                                $action = 'add';
     424                        $id = str_replace( array( '-new', '-add' ), '', $id );
    517425                }
    518426
    519                 $this->action = $action;
     427                if ( 'index' == $id )
     428                        $id = 'dashboard';
    520429
    521                 // Map index to dashboard
    522                 if ( 'index' == $this->base )
    523                         $this->base = 'dashboard';
    524                 if ( 'index' == $this->id )
    525                         $this->id = 'dashboard';
     430                $base = $id;
    526431
    527                 if ( 'edit' == $this->id ) {
    528                         if ( empty($typenow) )
    529                                 $typenow = 'post';
    530                         $this->id .= '-' . $typenow;
    531                         $this->post_type = $typenow;
    532                 } elseif ( 'post' == $this->id ) {
    533                         if ( empty($typenow) )
    534                                 $typenow = 'post';
    535                         $this->id = $typenow;
    536                         $this->post_type = $typenow;
    537                 } elseif ( 'edit-tags' == $this->id ) {
    538                         if ( empty($taxnow) )
    539                                 $taxnow = 'post_tag';
    540                         $this->id = 'edit-' . $taxnow;
    541                         $this->taxonomy = $taxnow;
     432                // If this is the current screen, see if we can be more accurate for post types and taxonomies.
     433                if ( ! $hook_name ) {
     434                        switch ( $base ) {
     435                                case 'post' :
     436                                        if ( isset( $_GET['post'] ) )
     437                                                $post_id = (int) $_GET['post'];
     438                                        elseif ( isset( $_POST['post_ID'] ) )
     439                                                $post_id = (int) $_POST['post_ID'];
     440                                        else
     441                                                $post_id = 0;
     442
     443                                        if ( $post_id ) {
     444                                                $post = get_post( $post_id );
     445                                                if ( $post )
     446                                                        $post_type = $post->post_type;
     447                                        } elseif ( isset( $_POST['post_type'] ) && post_type_exists( $_POST['post_type'] ) ) {
     448                                                $post_type = $_GET['post_type'];
     449                                        } elseif ( $action == 'add' && isset( $_GET['post_type'] ) && post_type_exists( $_GET['post_type'] ) ) {
     450                                                $post_type = $_GET['post_type'];
     451                                        }
     452                                        break;
     453                                case 'edit' :
     454                                        if ( isset( $_GET['post_type'] ) && post_type_exists( $_GET['post_type'] ) )
     455                                                $post_type = $_GET['post_type'];
     456                                        break;
     457                                case 'edit-tags' :
     458                                        if ( isset( $_REQUEST['taxonomy'] ) && taxonomy_exists( $_REQUEST['taxonomy'] ) )
     459                                                $taxonomy = $_REQUEST['taxonomy'];
     460                                        break;
     461                        }
    542462                }
    543463
    544                 $this->is_network = is_network_admin();
    545                 $this->is_user = is_user_admin();
     464                switch ( $id ) {
     465                        case 'post' :
     466                                if ( ! $post_type )
     467                                        $post_type = 'post';
     468                                $id = $post_type;
     469                                break;
     470                        case 'edit' :
     471                                if ( ! $post_type )
     472                                        $post_type = 'post';
     473                                $id .= '-' . $post_type;
     474                                break;
     475                        case 'edit-tags' :
     476                                if ( ! $taxonomy )
     477                                        $taxonomy = 'post_tag';
     478                                $id = 'edit-' . $taxonomy;
     479                                break;
     480                }
    546481
    547                 if ( $this->is_network ) {
    548                         $this->base .= '-network';
    549                         $this->id .= '-network';
    550                 } elseif ( $this->is_user ) {
    551                         $this->base .= '-user';
    552                         $this->id .= '-user';
     482                if ( is_network_admin() ) {
     483                        $id  .= '-network';
     484                        $base .= '-network';
     485                } elseif ( is_user_admin() ) {
     486                        $id  .= '-user';
     487                        $base .= '-user';
    553488                }
    554489
    555                 if ( ! isset( self::$_help_tabs[ $this->id ] ) )
    556                         self::$_help_tabs[ $this->id ] = array();
    557                 if ( ! isset( self::$_help_sidebar[ $this->id ] ) )
    558                         self::$_help_sidebar[ $this->id ] = '';
    559                 if ( ! isset( self::$_options[ $this->id ] ) )
    560                         self::$_options[ $this->id ] = array();
     490                if ( isset( self::$_registry[ $id ] ) )
     491                        return self::$_registry[ $id ];
     492
     493                $screen = new WP_Screen();
     494                $screen->id         = $id;
     495                $screen->base       = $base;
     496                $screen->action     = $action;
     497                $screen->post_type  = $post_type;
     498                $screen->taxonomy   = $taxonomy;
     499                $screen->is_user    = is_user_admin();
     500                $screen->is_network = is_network_admin();
     501
     502                self::$_registry[ $id ] = $screen;
     503
     504                return $screen;
    561505        }
    562506
     507        /**
     508         * Makes the screen object the current screen.
     509         *
     510         * @see set_current_screen()
     511         * @since 3.3.0
     512         */
     513        function set_current_screen() {
     514                global $current_screen, $taxnow, $typenow;
     515                $current_screen = $this;
     516                $taxnow = $this->taxonomy;
     517                $typenow = $this->post_type;
     518                $current_screen = apply_filters( 'current_screen', $current_screen );
     519        }
     520
     521        /**
     522         * Constructor
     523         *
     524         * @since 3.3.0
     525         * @access private
     526         */
     527        private function __construct() {}
     528
     529        /**
     530         * Sets the old string-based contextual help for the screen.
     531         *
     532         * For backwards compatibility.
     533         *
     534         * @since 3.3.0
     535         *
     536         * @param WP_Screen $screen A screen object.
     537         * @param string $help Help text.
     538         */
    563539        static function add_old_compat_help( $screen, $help ) {
    564                 self::$_old_compat_help[ $screen ] = $help;     
     540                self::$_old_compat_help[ $screen->id ] = $help;
    565541        }
    566542
    567543        /**
     
    588564         * @param mixed $args Option-dependent arguments.
    589565         */
    590566        public function add_option( $option, $args = array() ) {
    591                 self::$_options[ $this->id ][ $option ] = $args;
     567                $this->_options[ $option ] = $args;
    592568        }
    593569
    594570        /**
     
    599575         * @param string
    600576         */
    601577        public function get_option( $option, $key = false ) {
    602                 if ( ! isset( self::$_options[ $this->id ][ $option ] ) )
     578                if ( ! isset( $this->_options[ $option ] ) )
    603579                        return null;
    604580                if ( $key ) {
    605                         if ( isset( self::$_options[ $this->id ][ $option ][ $key ] ) )
    606                                 return self::$_options[ $this->id ][ $option ][ $key ];
     581                        if ( isset( $this->_options[ $option ][ $key ] ) )
     582                                return $this->_options[ $option ][ $key ];
    607583                        return null;
    608584                }
    609                 return self::$_options[ $this->id ][ $option ];
     585                return $this->_options[ $option ];
    610586        }
    611587
    612588        /**
     
    637613                if ( ! $args['id'] || ! $args['title'] )
    638614                        return;
    639615
    640                 self::$_help_tabs[ $this->id ][] = $args;
     616                $this->_help_tabs[] = $args;
    641617        }
    642618
    643619        /**
     
    649625         * @param string $content Sidebar content in plain text or HTML.
    650626         */
    651627        public function add_help_sidebar( $content ) {
    652                 self::$_help_sidebar[ $this->id ] = $content;
     628                $this->_help_sidebar = $content;
    653629        }
    654630
    655631        /**
     
    664640                // Call old contextual_help_list filter.
    665641                self::$_old_compat_help = apply_filters( 'contextual_help_list', self::$_old_compat_help, $this );
    666642
    667                 if ( isset( self::$_old_compat_help[ $this->id ] ) || empty(self::$_help_tabs[ $this->id ] ) ) {
     643                if ( isset( self::$_old_compat_help[ $this->id ] ) || empty( $this->_help_tabs ) ) {
    668644                        // Call old contextual_help filter.
    669645                        if ( isset( self::$_old_compat_help[ $this->id ] ) )
    670646                                $contextual_help = apply_filters( 'contextual_help', self::$_old_compat_help[ $this->id ], $this->id, $this );
     
    690666                                'title'    => __('Screen Options'),
    691667                                'callback' => array( $this, 'render_screen_options' ),
    692668                        ) );
    693                         $_options_tab = array_pop( self::$_help_tabs[ $this->id ] );
    694                         array_unshift( self::$_help_tabs[ $this->id ], $_options_tab );
     669                        $_options_tab = array_pop( $this->_help_tabs );
     670                        array_unshift( $this->_help_tabs, $_options_tab );
    695671                }
    696672
    697673                // Time to render!
     
    701677                        <div id="contextual-help-wrap" class="hidden">
    702678                                <div class="contextual-help-tabs">
    703679                                        <ul>
    704                                         <?php foreach ( self::$_help_tabs[ $this->id ] as $i => $tab ):
     680                                        <?php foreach ( $this->_help_tabs as $i => $tab ):
    705681                                                $link_id  = "tab-link-{$tab['id']}";
    706682                                                $panel_id = "tab-panel-{$tab['id']}";
    707683                                                $classes  = ( $i == 0 ) ? 'active' : '';
     
    716692                                        </ul>
    717693                                </div>
    718694
    719                                 <?php if ( ! empty( self::$_help_sidebar[ $this->id ] ) ) : ?>
     695                                <?php if ( ! empty( $this->_help_sidebar ) ) : ?>
    720696                                <div class="contextual-help-sidebar">
    721                                         <?php echo self::$_help_sidebar[ $this->id ]; ?>
     697                                        <?php echo $this->_help_sidebar; ?>
    722698                                </div>
    723699                                <?php endif; ?>
    724700
    725701                                <div class="contextual-help-tabs-wrap">
    726                                         <?php foreach ( self::$_help_tabs[ $this->id ] as $i => $tab ):
     702                                        <?php foreach ( $this->_help_tabs as $i => $tab ):
    727703                                                $panel_id = "tab-panel-{$tab['id']}";
    728704                                                $classes  = ( $i == 0 ) ? 'active' : '';
    729705                                                $classes .= ' help-tab-content';
     
    747723        }
    748724
    749725        public function show_screen_options() {
    750                 global $wp_meta_boxes, $wp_list_table;
     726                global $wp_meta_boxes;
    751727
    752728                if ( is_bool( $this->_show_screen_options ) )
    753729                        return $this->_show_screen_options;
     
    759735                        $show_screen = true;
    760736
    761737                // Check if there are per-page options.
    762                 $show_screen = $show_screen || $this->get_option('per_page');
     738                if ( $this->get_option( 'per_page' ) )
     739                        $show_screen = true;
    763740
    764741                $this->_screen_settings = apply_filters( 'screen_settings', '', $this );
    765742
    766743                switch ( $this->id ) {
    767744                        case 'widgets':
    768745                                $this->_screen_settings = '<p><a id="access-on" href="widgets.php?widgets-access=on">' . __('Enable accessibility mode') . '</a><a id="access-off" href="widgets.php?widgets-access=off">' . __('Disable accessibility mode') . "</a></p>\n";
    769                                 $show_screen = true;
    770746                                break;
    771747                }
    772748
    773                 if ( ! empty( $this->_screen_settings ) )
     749                if ( $this->_screen_settings || $this->_options )
    774750                        $show_screen = true;
    775751
    776                 if ( ! empty( self::$_options[ $this->id ] ) )
    777                         $show_screen = true;
    778 
    779752                $this->_show_screen_options = apply_filters( 'screen_options_show_screen', $show_screen, $this );
    780753                return $this->_show_screen_options;
    781754        }
     
    786759         * @since 3.3.0
    787760         */
    788761        public function render_screen_options() {
    789                 global $wp_meta_boxes, $wp_list_table;
     762                global $wp_meta_boxes;
    790763
    791764                $columns = get_column_headers( $this );
    792765                $hidden  = get_hidden_columns( $this );
  • wp-admin/post.php

     
    1616
    1717wp_reset_vars(array('action', 'safe_mode', 'withcomments', 'posts', 'content', 'edited_post_title', 'comment_error', 'profile', 'trackback_url', 'excerpt', 'showcomments', 'commentstart', 'commentend', 'commentorder'));
    1818
    19 if ( isset($_GET['post']) )
     19if ( isset( $_GET['post'] ) )
    2020        $post_id = (int) $_GET['post'];
    21 elseif ( isset($_POST['post_ID']) )
     21elseif ( isset( $_POST['post_ID'] ) )
    2222        $post_id = (int) $_POST['post_ID'];
    2323else
    2424        $post_id = 0;
     25
    2526$post_ID = $post_id;
    26 $post = null;
    27 $post_type_object = null;
    28 $post_type = null;
    29 if ( $post_id ) {
    30         $post = get_post($post_id);
    31         if ( $post ) {
    32                 $post_type_object = get_post_type_object($post->post_type);
    33                 if ( $post_type_object ) {
    34                         $post_type = $post->post_type;
    35                         $current_screen->post_type = $post->post_type;
    36                         $current_screen->id = $current_screen->post_type;
    37                 }
    38         }
    39 } elseif ( isset($_POST['post_type']) ) {
    40         $post_type_object = get_post_type_object($_POST['post_type']);
    41         if ( $post_type_object ) {
    42                 $post_type = $post_type_object->name;
    43                 $current_screen->post_type = $post_type;
    44                 $current_screen->id = $current_screen->post_type;
    45         }
     27$post = $post_type = $post_type_object = null;
     28
     29if ( $post_id )
     30        $post = get_post( $post_id );
     31
     32if ( $post ) {
     33        $post_type = $post->post_type;
     34        $post_type_object = get_post_type_object( $post_type );
    4635}
    4736
    4837/**