0

I'm attempting to create a simple menu layout for a plugin. This is my first attempt at creating a plugin so apologies for what probably an obvious mistake here. This is the code I have to create the menu

    add_action( 'admin_menu', 'register_menu_page' );
    add_action( 'admin_menu', 'register_submenu_page' );

function register_menu_page()
    {
    add_menu_page( 'Broughton Admin', 'Broughton Admin', 'manage_options', 'broughton-admin-page', 'broughton_admin_page' ); 
    }

function register_submenu_page() {
    add_submenu_page( 'broughton-admin-page', 'Upload XML', 'Upload XML', 'manage_options', 'upload-xml-page', 'upload_xml_page' ); 
    add_submenu_page( 'broughton-admin-page', 'Archive XML', 'Archive XML', 'manage_options', 'archive-xml-page', 'archive_xml_page' );

function broughton_admin_page()
    {
        echo '<p>Menu Page</p>';
    }

function upload_xml_page() 
    {
    echo '<p>Upload submenu page</p>';
    }

function archive_xml_page()
    {
    echo '<p>Archive subment page</p>';
    }

The code doesn't work, I just get a white screen when I attempt to login as an admin. The error log rather ambiguously reports: "syntax error, unexpected end of file". Can anyone see the issue here?

2

This function is still open!

Add "}" at the end.

function register_submenu_page() {
  add_submenu_page( 'broughton-admin-page', 'Upload XML', 'Upload XML',        'manage_options', 'upload-xml-page', 'upload_xml_page' ); 
  add_submenu_page( 'broughton-admin-page', 'Archive XML', 'Archive XML', 'manage_options', 'archive-xml-page', 'archive_xml_page' );
}
| improve this answer | |
  • This is awkward. I've been starting at that for 20 minutes convinced it was an error with the way I was passing values in the function calls. Thanks for that! – Liam Nov 11 '15 at 10:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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