WordPress.org

Make WordPress Core

Ticket #32582: 32582.2.diff

File 32582.2.diff, 1.3 KB (added by swissspidy, 4 years ago)

Even simpler usort patch

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

    diff --git src/wp-admin/includes/screen.php src/wp-admin/includes/screen.php
    index 582c659..1a43236 100644
    function meta_box_prefs( $screen ) { 
    7878        $hidden = get_hidden_meta_boxes($screen);
    7979
    8080        foreach ( array_keys($wp_meta_boxes[$screen->id]) as $context ) {
    81                 foreach ( array_keys($wp_meta_boxes[$screen->id][$context]) as $priority ) {
     81                $priorities = array_keys( $wp_meta_boxes[$screen->id][$context] );
     82                usort( $priorities, '_usort_meta_box_prefs_by_priority' );
     83
     84                foreach ( $priorities as $priority ) {
    8285                        foreach ( $wp_meta_boxes[$screen->id][$context][$priority] as $box ) {
    8386                                if ( false == $box || ! $box['title'] )
    8487                                        continue;
    function meta_box_prefs( $screen ) { 
    9598}
    9699
    97100/**
     101 * Sort meta box priorities.
     102 *
     103 * Used by usort() as a callback, should not be used directly.
     104 *
     105 * @since 4.3.0
     106 * @access private
     107 *
     108 * @param string $a
     109 * @param string $b
     110 *
     111 * @return int
     112 */
     113function _usort_meta_box_prefs_by_priority( $a, $b ) {
     114        $priorities = array(
     115                'high'    => 10,
     116                'core'    => 8,
     117                'default' => 5,
     118                'low'     => 1,
     119        );
     120
     121        return $priorities[ $b ] - $priorities[ $a ];
     122}
     123
     124/**
    98125 * Get Hidden Meta Boxes
    99126 *
    100127 * @since 2.7.0