Make WordPress Core


Ignore:
Timestamp:
09/13/2019 05:57:57 PM (7 years ago)
Author:
desrosj
Message:

Menus: Nav menu locations should not be integers.

When nav menu location slugs are integers, some hard to debug results can occur. register_nav_menus() utilizes array_merge() which renumbers numeric indexes, starting from 0. Because of this, numeric menu locations will almost always be changed.

This change introduces a _doing_it_wrong() notice to inform developers that nav menu locations should always be strings.

Props audrasjb, desrosj, welcher.
Fixes #45361.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/menu/nav-menu.php

    r45588 r46102  
    183183         * Technically possible to register menu locations numerically.
    184184         *
     185         * @expectedIncorrectUsage register_nav_menus
     186         *
    185187         * @covers ::wp_map_nav_menu_locations()
    186188         */
     
    205207        /**
    206208         * Technically possible old nav menu locations were registered numerically.
     209         *
     210         * @expectedIncorrectUsage register_nav_menus
    207211         *
    208212         * @covers wp_map_nav_menu_locations()
Note: See TracChangeset for help on using the changeset viewer.