Add Plugin options as subpage to Theme options page

I have my own Theme with an options page. Now I am developing a new Plugin which should have an options page that should be a subpage of the Theme options page.

Theme options.php:

?php
function xx_theme_admin_menu() {
    add_menu_page(
        'Theme Settings',
        'Theme Settings',
        'manage_options',
        'xx-settings',
        'xx_theme_admin_page' ,
        '/wp-content/themes/xx/assets/img/logo-Grayscale-30x25.png'
    );
}
add_action( 'admin_menu', 'xx_theme_admin_menu' );

function xx_theme_admin_page() {
    ...
}

Plugin options.php:

?php
function xx_cookie_banner_admin_menu() {
    add_submenu_page(
        'xx-settings',
        'Cookie Banner',
        'Cookie Banner',
        'manage_options',
        'xx-cookie-banner',
        'xx_cookie_banner_admin_page'
    );
}
add_action( 'admin_menu', 'xx_cookie_banner_admin_menu' );

function xx_cookie_banner_admin_page() {
    ...
} ?

With the above code, as soon as I access the subpage, I see the error "You are not allowed to access this page". Also, I am getting this error for the Theme options page because it does now link to the subpage, too:

So both, Theme options page and Plugin options subpage have the link to the Plugin options subpage.

Without the Plugin options subpage, the Theme options page works perfectly.

Any ideas on this?

Topic plugin-options theme-options plugin-development options plugins Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.