WordPress.org

Make WordPress Core

Ticket #15000: 15000.6-refresh-2.diff

File 15000.6-refresh-2.diff, 3.2 KB (added by meloniq, 6 years ago)

Refreshed last one patch (6) to current version of WP (rev. 34900). Also moved the Screen ID check out of the loop.

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

     
    857857 * @param string           $title         Title of the meta box.
    858858 * @param callable         $callback      Function that fills the box with the desired content.
    859859 *                                        The function should echo its output.
    860  * @param string|WP_Screen $screen        Optional. The screen on which to show the box (like a post
     860 * @param string|array|WP_Screen $screen  Optional. The screen on which to show the box (like a post
    861861 *                                        type, 'link', or 'comment'). Default is the current screen.
     862 *                                        Also accepts an array of post type slugs.
    862863 * @param string           $context       Optional. The context within the screen where the boxes
    863864 *                                        should display. Available contexts vary from screen to
    864865 *                                        screen. Post edit screen contexts include 'normal', 'side',
     
    874875function add_meta_box( $id, $title, $callback, $screen = null, $context = 'advanced', $priority = 'default', $callback_args = null ) {
    875876        global $wp_meta_boxes;
    876877
    877         if ( empty( $screen ) )
     878        if ( empty( $screen ) ) {
    878879                $screen = get_current_screen();
    879         elseif ( is_string( $screen ) )
     880        } elseif ( is_string( $screen ) ) {
    880881                $screen = convert_to_screen( $screen );
     882        } elseif ( is_array( $screen ) ) {
     883                foreach ( $screen as $single_screen ) {
     884                        add_meta_box( $id, $title, $callback, $single_screen, $context, $priority, $callback_args );
     885                }
     886        }
    881887
     888        if ( ! isset( $screen->id ) ) {
     889                return;
     890        }
     891
    882892        $page = $screen->id;
    883893
    884894        if ( !isset($wp_meta_boxes) )
     
    10171027 *
    10181028 * @global array $wp_meta_boxes
    10191029 *
    1020  * @param string        $id      String for use in the 'id' attribute of tags.
    1021  * @param string|object $screen  The screen on which to show the box (post, page, link).
    1022  * @param string        $context The context within the page where the boxes should show ('normal', 'advanced').
     1030 * @param string              $id      String for use in the 'id' attribute of tags.
     1031 * @param string|array|object $screen  The screen on which to show the box (post, page, link). Also accepts an
     1032 *                                     array of post type slugs from which to remove the box from.
     1033 * @param string              $context The context within the page where the boxes should show ('normal', 'advanced').
    10231034 */
    1024 function remove_meta_box($id, $screen, $context) {
     1035function remove_meta_box( $id, $screen, $context ) {
    10251036        global $wp_meta_boxes;
    10261037
    1027         if ( empty( $screen ) )
     1038        if ( empty( $screen ) ) {
    10281039                $screen = get_current_screen();
    1029         elseif ( is_string( $screen ) )
     1040        } elseif ( is_string( $screen ) ) {
    10301041                $screen = convert_to_screen( $screen );
     1042        } elseif ( is_array( $screen ) ) {
     1043                foreach ( $screen as $single_screen ) {
     1044                        remove_meta_box( $id, $single_screen, $context );
     1045                }
     1046        }
    10311047
     1048        if ( ! isset( $screen->id ) ) {
     1049                return;
     1050        }
     1051
    10321052        $page = $screen->id;
    10331053
    10341054        if ( !isset($wp_meta_boxes) )