Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have now updated the code and added this

remove_submenu_page( $menu_slug, $submenu_slug )

function so the page can be accessed even when hidden.

    function ccms_developer_theme_menu() {

    $options = get_option('ccms_developer_options');

    if( $options['show_admin_dev'] ==1 )
        $show_dev = 1;
    else
        $show_dev = 0;

    add_submenu_page(
            'ccms',                     // The ID of the top-level menu page to which this submenu item belongs
            __( 'Developer Options', 'ccms' ),          // The value used to populate the browser's title bar when the menu page is active
            __( 'Developer Options', 'ccms' ),          // The label of this submenu item displayed in the menu
            'administrator',                            // What roles are able to access this submenu item
            'ccms-dev',                                 // The ID used to represent this submenu item
            'ccms_developer_display'                    // The callback function used to render the options for this submenu item
        );

    if( $show_dev ==0 )
        remove_submenu_page( 'ccms', 'ccms-dev' );

} // end ccms_developer_theme_menu

But when accessing the page while its hidden i now get this warning and no page outputs.

Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'ccms_developer_options' not found or invalid function name in E:\composite-cms\test\wp-includes\plugin.php on line 406

the full code can be found on github

share|improve this question
1  
Your problem is elsewhere, it's surely not in adding and removing the submenu or showing its page. The error notice is telling you that the function ccms_developer_options does not exist, and that's correct. Your naming convention seems a bit confusing, what about ccms_options, ccms_settings and ccms_callback? – brasofilo Dec 27 '12 at 16:43
The naming is like this as there are arround about 15 pages added by my theme framework all needing to be toggleable from this page. – CompositeUK Dec 28 '12 at 1:41

closed as too localized by kaiser, brasofilo, toscho Dec 28 '12 at 1:47

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.

1 Answer

Fixed the issue, the function ccms_developer_display had to be updated to ccms_developer_options so the function name matched the option name.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.