After each update of the plugin, I have to fix the error in this line.
It looks like the site has menu items without a title. But it’s not forbidden.
My revision of this line:
// For MENUCERBER* See cerber_nav_menu_box() !!!
if ( array_key_exists(‘title’, $atts) && ( 0 === strpos( $atts[‘title’], ‘MENUCERBER*’ ) ) ) {
Please share the full piece of code where you’re experiencing the issue.
Code:
// Set actual URL for a menu item based on a special value in title attribute
add_filter( 'nav_menu_link_attributes', function ( $atts ) {
// For *MENU*CERBER* See cerber_nav_menu_box() !!!
if ( 0 === strpos( $atts['title'], '*MENU*CERBER*' ) ) {
$title = explode( '|', $atts['title'] );
$atts['title'] = '';
$url = '#';
// See cerber_nav_menu_items() !!!
switch ( $title[1] ) {
$atts[‘title’] - At this point, the array element is accessed unconditionally by key. Without checking whether there is such an element or not.
Hi, you’re absolutely right to add that check, and we appreciate you pointing it out. But technically, WordPress does pass the 'title'
key in the $atts
array — unless a filter in another plugin decided it knows better and simply removed it. That’s not normal behavior, but unfortunately, it’s not unheard of either.
As it stands, WP Cerber’s code assumes 'title'
is always there, and doesn’t explicitly check for it before accessing. That’s clearly not ideal, especially in more complex environments where third-party filters may interfere. Your fix is absolutely the right approach, and I’ll make sure WP Cerber gets this defensive check in the update coming next week.
Thanks for taking the time to report the issue.
This bug has been fixed in version 9.6.9. Please update to the latest version if you haven’t already.