Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/29/2019 03:46:56 AM (7 years ago)
Author:
imath
Message:

Compat classes to handle Walker_Nav_Menu::walk() changes in WP 5.3

WordPress 5.3 modified the Walker_Nav_Menu::walk() signature adding a third parameter to the method that is using the spread operator. johnjamesjacoby quickly fixed the issue in [12497] when PHP >=5.6.

As our current PHP required version is 5.3, we need to provide a temporary compatibility mechanism to make sure our BP_Walker_Nav_Menu will not generate errors when the PHP version is lower than 5.6 before raising the PHP required version in our next major release.

props timothybjacobs, boonebgorges, imath

See #8163 (Trunk)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/classes/class-bp-walker-nav-menu.php

    r12497 r12498  
    1212
    1313/**
    14  * Create HTML list of BP nav items.
     14 * Compatibility Class to make BP_Walker_Nav_Menu::walk() compatible
     15 * from PHP 5.3 to 5.6 and up.
    1516 *
    16  * @since 1.7.0
     17 * @since 5.1.0
    1718 */
    18 class BP_Walker_Nav_Menu extends Walker_Nav_Menu {
    19 
     19class BP_Walker_Nav_Menu_Compat extends Walker_Nav_Menu {
    2020        /**
    2121         * Description of fields indexes for building markup.
    … …  
    4848         *
    4949         * @since 1.7.0
    50          * @since 6.0.0 Formalized the existing `...$args` parameter by adding it
    51          *              to the function signature to match WordPress 5.3.
     50         * @since 5.1.0 Method was renamed from `walk` to `do_walk` to ensure PHP 5.3 compatibility
     51         *
    5252         * @see Walker::walk()
    5353         *
    5454         * @param array $elements  See {@link Walker::walk()}.
    5555         * @param int   $max_depth See {@link Walker::walk()}.
    56          * @param mixed ...$args   Optional additional arguments.
     56         * @param array $args      Optional additional arguments.
    5757         * @return string See {@link Walker::walk()}.
    5858         */
    59         public function walk( $elements, $max_depth, ...$args ) {
     59        public function do_walk( $elements, $max_depth, $args = array() ) {
    6060                $output = '';
    6161
    … …  
    213213        }
    214214}
     215
     216if ( PHP_VERSION_ID >= 50600 ) {
     217        require_once dirname( __DIR__ ) . '/compat/php56/class-bp-compat-walker-nav-menu.php';
     218} else {
     219        require_once dirname( __DIR__ ) . '/compat/php53/class-bp-compat-walker-nav-menu.php';
     220}
Note: See TracChangeset for help on using the changeset viewer.