Make WordPress Core

Ticket #15000: 15000.2.diff

File 15000.2.diff, 4.1 KB (added by iamfriendly, 11 years ago)

Refreshed patch. Now accepts an array of post types or an array of screen objects

  • wp-admin/includes/template.php

    diff --git wp-admin/includes/template.php wp-admin/includes/template.php
    index 95a3bf9..7f432c0 100644
    function wp_import_upload_form( $action ) { 
    895895 *
    896896 * @since 2.5.0
    897897 *
    898  * @param string           $id            String for use in the 'id' attribute of tags.
    899  * @param string           $title         Title of the meta box.
    900  * @param callback         $callback      Function that fills the box with the desired content.
    901  *                                        The function should echo its output.
    902  * @param string|WP_Screen $screen        Optional. The screen on which to show the box (like a post
    903  *                                        type, 'link', or 'comment'). Default is the current screen.
    904  * @param string           $context       Optional. The context within the screen where the boxes
    905  *                                        should display. Available contexts vary from screen to
    906  *                                        screen. Post edit screen contexts include 'normal', 'side',
    907  *                                        and 'advanced'. Comments screen contexts include 'normal'
    908  *                                        and 'side'. Menus meta boxes (accordion sections) all use
    909  *                                        the 'side' context. Global default is 'advanced'.
    910  * @param string           $priority      Optional. The priority within the context where the boxes
    911  *                                        should show ('high', 'low'). Default 'default'.
    912  * @param array            $callback_args Optional. Data that should be set as the $args property
    913  *                                        of the box array (which is the second parameter passed
    914  *                                        to your callback). Default null.
     898 * @param string                                $id             String for use in the 'id' attribute of tags.
     899 * @param string                                $title          Title of the meta box.
     900 * @param callback                              $callback       Function that fills the box with the desired content.
     901 *                                                      The function should echo its output.
     902 * @param string|WP_Screen|array        $screen         Optional. The screen on which to show the box (like a post
     903 *                                                      type, 'link', or 'comment'). Default is the current screen.
     904 * @param string                                $context        Optional. The context within the screen where the boxes
     905 *                                                              should display. Available contexts vary from screen to
     906 *                                                              screen. Post edit screen contexts include 'normal', 'side',
     907 *                                                              and 'advanced'. Comments screen contexts include 'normal'
     908 *                                                              and 'side'. Menus meta boxes (accordion sections) all use
     909 *                                                              the 'side' context. Global default is 'advanced'.
     910 * @param string                                $priority       Optional. The priority within the context where the boxes
     911 *                                                      should show ('high', 'low'). Default 'default'.
     912 * @param array                                 $callback_args  Optional. Data that should be set as the $args property
     913 *                                                      of the box array (which is the second parameter passed
     914 *                                                              to your callback). Default null.
    915915 */
    916916function add_meta_box( $id, $title, $callback, $screen = null, $context = 'advanced', $priority = 'default', $callback_args = null ) {
    917917        global $wp_meta_boxes;
    918918
    919         if ( empty( $screen ) )
     919        if ( empty( $screen ) ){
    920920                $screen = get_current_screen();
    921         elseif ( is_string( $screen ) )
     921        }elseif ( is_string( $screen ) ){
    922922                $screen = convert_to_screen( $screen );
     923        }elseif ( is_array( $screen ) ){
     924                foreach ( $screen as $single_screen ){
     925                        add_meta_box( $id, $title, $callback, $single_screen, $context, $priority, $callback_args );
     926                }
     927        }
     928
     929        if( !isset( $screen->id ) ){
     930                return;
     931        }
    923932
    924933        $page = $screen->id;
    925934