From 3549683ca362f824fd55e7e96d853328dc7b7ae8 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Mon, 29 Oct 2018 08:30:14 +0000 Subject: [PATCH] Meta boxes: Don't assume that callback args are an array. While the documentation for `add_meta_box()` specifices that `$callback_args` should be an array, this has never been enforced, and we have workarounds in place for when it's passed as something other than an array. Rather than break sites that are passing unexpected data, we can quietly just allow for it, instead. Props johnjamesjacoby, birgire. Fixes #45206. Built from https://develop.svn.wordpress.org/branches/5.0@43838 git-svn-id: http://core.svn.wordpress.org/branches/5.0@43667 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/template.php | 34 ++++++++++++++++++---------------- wp-includes/version.php | 2 +- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index e51903e442..708c8c3a2c 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -1052,25 +1052,27 @@ function do_meta_boxes( $screen, $context, $object ) { if ( false == $box || ! $box['title'] ) continue; - // Don't show boxes in the block editor, if they're just here for back compat. - if ( $screen->is_block_editor() && isset( $box['args']['__back_compat_meta_box'] ) && $box['args']['__back_compat_meta_box'] ) { - continue; - } + if ( is_array( $box[ 'args' ] ) ) { + // If a meta box is just here for back compat, don't show it in the block editor. + if ( $screen->is_block_editor() && isset( $box['args']['__back_compat_meta_box'] ) && $box['args']['__back_compat_meta_box'] ) { + continue; + } - // Don't show boxes in the block editor that aren't compatible with the block editor. - if ( $screen->is_block_editor() && isset( $box['args']['__block_editor_compatible_meta_box'] ) && ! $box['args']['__block_editor_compatible_meta_box'] ) { - continue; - } + // If a meta box doesn't work in the block editor, don't show it in the block editor. + if ( $screen->is_block_editor() && isset( $box['args']['__block_editor_compatible_meta_box'] ) && ! $box['args']['__block_editor_compatible_meta_box'] ) { + continue; + } - $block_compatible = true; - if ( isset( $box['args']['__block_editor_compatible_meta_box'] ) ) { - $block_compatible = (bool) $box['args']['__block_editor_compatible_meta_box']; - unset( $box['args']['__block_editor_compatible_meta_box'] ); - } + $block_compatible = true; + if ( isset( $box['args']['__block_editor_compatible_meta_box'] ) ) { + $block_compatible = (bool) $box['args']['__block_editor_compatible_meta_box']; + unset( $box['args']['__block_editor_compatible_meta_box'] ); + } - if ( isset( $box['args']['__back_compat_meta_box'] ) ) { - $block_compatible |= (bool) $box['args']['__back_compat_meta_box']; - unset( $box['args']['__back_compat_meta_box'] ); + if ( isset( $box['args']['__back_compat_meta_box'] ) ) { + $block_compatible = $block_compatible || (bool) $box['args']['__back_compat_meta_box']; + unset( $box['args']['__back_compat_meta_box'] ); + } } $i++; diff --git a/wp-includes/version.php b/wp-includes/version.php index 6127a576e4..99a0392596 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '5.0-beta1-43837'; +$wp_version = '5.0-beta1-43838'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.