From a32ed9e1ea3226d374ad3c36fed9b639b03f670d Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 27 Oct 2014 12:57:24 +0000 Subject: [PATCH] Remove one-time loop and redundant isset() checks in do_meta_boxes(). See [30022] for do_accordion_sections(). props ipm-frommen. fixes #30093. git-svn-id: https://develop.svn.wordpress.org/trunk@30040 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/template.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/wp-admin/includes/template.php b/src/wp-admin/includes/template.php index 2a1623b876..4fa9f0c38b 100644 --- a/src/wp-admin/includes/template.php +++ b/src/wp-admin/includes/template.php @@ -1004,25 +1004,25 @@ function do_meta_boxes( $screen, $context, $object ) { printf('
', htmlspecialchars($context)); - $i = 0; - do { - // Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose - if ( !$already_sorted && $sorted = get_user_option( "meta-box-order_$page" ) ) { - foreach ( $sorted as $box_context => $ids ) { - foreach ( explode(',', $ids ) as $id ) { - if ( $id && 'dashboard_browser_nag' !== $id ) - add_meta_box( $id, null, null, $screen, $box_context, 'sorted' ); + // Grab the ones the user has manually sorted. Pull them out of their previous context/priority and into the one the user chose + if ( ! $already_sorted && $sorted = get_user_option( "meta-box-order_$page" ) ) { + foreach ( $sorted as $box_context => $ids ) { + foreach ( explode( ',', $ids ) as $id ) { + if ( $id && 'dashboard_browser_nag' !== $id ) { + add_meta_box( $id, null, null, $screen, $box_context, 'sorted' ); } } } - $already_sorted = true; + } - if ( !isset($wp_meta_boxes) || !isset($wp_meta_boxes[$page]) || !isset($wp_meta_boxes[$page][$context]) ) - break; + $already_sorted = true; - foreach ( array('high', 'sorted', 'core', 'default', 'low') as $priority ) { - if ( isset($wp_meta_boxes[$page][$context][$priority]) ) { - foreach ( (array) $wp_meta_boxes[$page][$context][$priority] as $box ) { + $i = 0; + + if ( isset( $wp_meta_boxes[ $page ][ $context ] ) ) { + foreach ( array( 'high', 'sorted', 'core', 'default', 'low' ) as $priority ) { + if ( isset( $wp_meta_boxes[ $page ][ $context ][ $priority ]) ) { + foreach ( (array) $wp_meta_boxes[ $page ][ $context ][ $priority ] as $box ) { if ( false == $box || ! $box['title'] ) continue; $i++; @@ -1038,7 +1038,7 @@ function do_meta_boxes( $screen, $context, $object ) { } } } - } while(0); + } echo "
";