Make WordPress Core

Changes between Version 1 and Version 2 of Ticket #40927, comment 18


Ignore:
Timestamp:
02/14/2022 02:49:57 PM (4 years ago)
Author:
Cybr
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #40927, comment 18

    v1 v2  
    11I found I linked to the changeset incorrectly, which should lead here: https://core.trac.wordpress.org/changeset/52569.
    22
    3 Attached I copied the handling of `$menu` to `$submenu`.
     3In "40927.1.patch" I copied the handling of `$menu` to `$submenu`.
    44I removed all strict type checks and simplified the code.
    55
     
    88Since PHP converts all numerics to weakly typed integers (`$a['1'] === $a[1]`), we can safely cast the position to a string value.
    99
    10 No changes should be noticed by the developers. I suggest allowing `int|float` for `$position` in the PHPDocs; perhaps even the string-equivalent thereof, although I recognize that is difficult to convey.
     10No changes should be noticed by plugin developers. I suggest allowing `int|float` for `$position` in the PHPDocs; perhaps even the string-equivalent thereof, although I recognize that is difficult to convey.
     11
     12Aside: I found that `$menu` is sorted only once, but `add_submenu_page()` keeps re-sorting the submenu with every item added. This isn't a big issue, but it's not the most efficient. In any case, I copied the sorting algorithm used for `$menu` and applied it to `$submenu`.
    1113
    1214''I see I uploaded a patch of the wrong iteration of my work -- 40927.1.patch will resolve that momentarily.''