WordPress.org

Make WordPress Core

Ticket #47704: 47704-WP_Customize_Nav_Menu_Item_.patch

File 47704-WP_Customize_Nav_Menu_Item_.patch, 1.7 KB (added by jrf, 6 months ago)

PHP 7.4/array-access: Fix WP_Customize_Nav_Menu_Item_Setting::filter_wp_get_nav_menu_items() - fixes 1 error

  • src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php

    From bedef71388e054a77a059a91c74ebb798a624099 Mon Sep 17 00:00:00 2001
    From: jrfnl <jrfnl@users.noreply.github.com>
    Date: Mon, 15 Jul 2019 00:29:32 +0200
    Subject: [PATCH] PHP 7.4/array-access: Fix
     WP_Customize_Nav_Menu_Item_Setting::filter_wp_get_nav_menu_items()
    
    ---
     .../class-wp-customize-nav-menu-item-setting.php         | 9 ++++++---
     1 file changed, 6 insertions(+), 3 deletions(-)
    
    diff --git a/src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php b/src/wp-includes/customize/class-wp-customize-nav-menu-item-setting.php
    index bccf1d9388..5f66023b43 100644
    a b class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting { 
    477477         */
    478478        public function filter_wp_get_nav_menu_items( $items, $menu, $args ) {
    479479                $this_item                = $this->value();
    480                 $current_nav_menu_term_id = $this_item['nav_menu_term_id'];
    481                 unset( $this_item['nav_menu_term_id'] );
     480                $current_nav_menu_term_id = null;
     481                if ( isset( $this_item['nav_menu_term_id'] ) ) {
     482                        $current_nav_menu_term_id = $this_item['nav_menu_term_id'];
     483                        unset( $this_item['nav_menu_term_id'] );
     484                }
    482485
    483486                $should_filter = (
    484487                        $menu->term_id === $this->original_nav_menu_term_id
    class WP_Customize_Nav_Menu_Item_Setting extends WP_Customize_Setting { 
    493496                $should_remove = (
    494497                        false === $this_item
    495498                        ||
    496                         true === $this_item['_invalid']
     499                        ( isset( $this_item['_invalid'] ) && true === $this_item['_invalid'] )
    497500                        ||
    498501                        (
    499502                                $this->original_nav_menu_term_id === $menu->term_id