Skip to:
Content

BuddyPress.org

Changeset 12500


Ignore:
Timestamp:
11/29/2019 06:06:30 AM (5 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

Fixes #8163 (5.0 branch)

Location:
branches/5.0
Files:
6 added
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.0/Gruntfile.js

    r12472 r12500  
    270270        },
    271271        phplint: {
    272             good: ['src/**/*.php'].concat( BP_EXCLUDED_MISC )
     272            good: ['src/**/*.php', '!src/bp-core/compat/php56/*.php'].concat( BP_EXCLUDED_MISC )
    273273        },
    274274        postcss: {
  • branches/5.0/src/bp-core/classes/class-bp-walker-nav-menu.php

    r11363 r12500  
    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 5.1.0 Method was renamed from `walk` to `do_walk` to ensure PHP 5.3 compatibility
    5051     *
    5152     * @see Walker::walk()
     
    5354     * @param array $elements  See {@link Walker::walk()}.
    5455     * @param int   $max_depth See {@link Walker::walk()}.
     56     * @param array $args      Optional additional arguments.
    5557     * @return string See {@link Walker::walk()}.
    5658     */
    57     public function walk( $elements, $max_depth ) {
    58         $args   = array_slice( func_get_args(), 2 );
     59    public function do_walk( $elements, $max_depth, $args = array() ) {
    5960        $output = '';
    6061
     
    212213    }
    213214}
     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.