WordPress.org

Make WordPress Core

Ticket #15000: 15000.6.diff

File 15000.6.diff, 2.6 KB (added by madalin.ungureanu, 7 years ago)

Added the same functionality for remove_meta_box() function and made some modiffications in the description of the functions

  • src/wp-admin/includes/template.php

     
    900900 * @param string           $title         Title of the meta box.
    901901 * @param callback         $callback      Function that fills the box with the desired content.
    902902 *                                        The function should echo its output.
    903  * @param string|WP_Screen $screen        Optional. The screen on which to show the box (like a post
     903 * @param string|WP_Screen|array $screen  Optional. The screen on which to show the box (like a post
    904904 *                                        type, 'link', or 'comment'). Default is the current screen.
     905 *                                        Also accepts an array of post type slugs.
    905906 * @param string           $context       Optional. The context within the screen where the boxes
    906907 *                                        should display. Available contexts vary from screen to
    907908 *                                        screen. Post edit screen contexts include 'normal', 'side',
     
    921922                $screen = get_current_screen();
    922923        elseif ( is_string( $screen ) )
    923924                $screen = convert_to_screen( $screen );
     925    elseif ( is_array( $screen ) ){
     926        foreach ( $screen as $single_screen ){
     927            add_meta_box( $id, $title, $callback, $single_screen, $context, $priority, $callback_args );
     928            }
     929        if( !isset( $screen->id ) )
     930            return;
     931        }
    924932
    925         $page = $screen->id;
     933    $page = $screen->id;
    926934
    927935        if ( !isset($wp_meta_boxes) )
    928936                $wp_meta_boxes = array();
     
    10521060 * @since 2.6.0
    10531061 *
    10541062 * @param string $id String for use in the 'id' attribute of tags.
    1055  * @param string|object $screen The screen on which to show the box (post, page, link).
     1063 * @param string|object|array $screen The screen on which to remove the box from (post, page, link). Also accepts an array of post type slugs from which to remove the box from.
    10561064 * @param string $context The context within the page where the boxes should show ('normal', 'advanced').
    10571065 */
    10581066function remove_meta_box($id, $screen, $context) {
     
    10621070                $screen = get_current_screen();
    10631071        elseif ( is_string( $screen ) )
    10641072                $screen = convert_to_screen( $screen );
     1073    elseif ( is_array( $screen ) ){
     1074        foreach ( $screen as $single_screen ){
     1075            remove_meta_box( $id, $single_screen, $context );
     1076        }
     1077        if( !isset( $screen->id ) )
     1078            return;
     1079    }
    10651080
    10661081        $page = $screen->id;
    10671082