Support Forum
Support › MB Settings Page › Notice: Undefined index: parentResolved
Hello,
I since last update I have a notice on my development websites
Notice: Undefined index: parent in /var/www/html/web/app/plugins/meta-box-aio/vendor/meta-box/mb-settings-page/src/Loader.php on line 22
Code location at this line
// Sort setting page array by "parent".
usort( $settings_pages, function ( $a, $b ) {
return strlen( $a['parent'] ) - strlen( $b['parent'] );
} );
I checked on old websites without last update, this code doesn't exist.
Fix idea is to check 'parent' flag exist or not.
On the documentation, this parameter is optional.
Maybe this fix could be ok.
// Sort setting page array by "parent".
usort( $settings_pages, function ( $a, $b ) {
return (isset($a['parent']) ? strlen( $a['parent'] ) : 0) - (isset($b['parent']) ? strlen( $b['parent'] ) : 0);
} );
I apply temporary this fix on my side.
I forgot my code for testing
public function my_settings( $settings_pages ) {
// Top level
$settings_pages[] = array(
'id' => 'my-settings-id',
'option_name' => 'My Settings',
'menu_title' => 'Settings',
'icon_url' => 'dashicons-admin-settings',
'submenu_title' => 'Général',
'style' => 'no-boxes',
'columns' => 1,
'position' => 80,
);
return $settings_pages;
}
Hi Julien, I have the same issue, the solution I found is put this in top level pages.
'parent' => 0
Using your example code:
public function my_settings( $settings_pages ) {
// Top level
$settings_pages[] = array(
'id' => 'my-settings-id',
'option_name' => 'My Settings',
'menu_title' => 'Settings',
'icon_url' => 'dashicons-admin-settings',
'submenu_title' => 'Général',
'parent' => 0,
'style' => 'no-boxes',
'columns' => 1,
'position' => 80,
);
return $settings_pages;
}
Yep it could work too but it's not really ok with documentation provided by metabox.io
I have more than 50 websites in production with metabox.io (without errors displayed), if documentation change, I will make adaptations.
Hi,
Thank you for your feedback and solution.
This issue has been fixed in a new commit, it will be included in the next update of this plugin.