Make WordPress Core

Changeset 53555


Ignore:
Timestamp:
06/22/2022 02:53:49 PM (2 years ago)
Author:
SergeyBiryukov
Message:

Code Modernization: Use the integer portion of an item position in add_submenu_page().

This fixes an Implicit conversion from float to int loses precision PHP 8.1 deprecation notice when adding a new admin menu item with a float value passed as the $position parameter.

This change is covered by existing unit tests and addresses 8 errors when running the test suite on PHP 8.1.

References:

Follow-up to [52569], [53104].

Props jrf.
See #55656, #54798.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/plugin.php

    r53426 r53555  
    14551455            array_unshift( $submenu[ $parent_slug ], $new_sub_menu );
    14561456        } else {
     1457            $position = absint( $position );
    14571458            // Grab all of the items before the insertion point.
    14581459            $before_items = array_slice( $submenu[ $parent_slug ], 0, $position, true );
Note: See TracChangeset for help on using the changeset viewer.