Solved

Wordpress plugin sub menu issue

Posted on 2015-01-19
1
86 Views
Last Modified: 2015-02-27
Hi,

I'm creating a wordpress plugin and I'm stuck on something that I just can't figure out.

I have the following method which creates the plugin menu.

function nl_create_menu() {
    add_menu_page('National Locums Timesheets','Timesheets','administrator',__FILE__,'nl_ts_admin');
    add_submenu_page(__FILE__, 'National Locums Timesheet Import','Import','administrator',__FILE__.'&act=nl_ts_import','nl_ts_import');
}

Open in new window


I then have two methods define to handle each link;

function nl_ts_import() {
    echo 'import';

    // Include view
    include_once __NL_TIMESHEET_PLUGIN_PATH . 'view/admin_import.view.php';
}

function nl_ts_admin() {
    echo 'Admin index';
}

Open in new window


The problem I'm having is that clicking the Import link in the sub menu doesn't load the 'nl_ts_import' function, it's called the nl_ts_admin function instead.

I'm sure it's a really simple thing to fix, but I cannot figure out where I'm going wrong.
0
Comment
Question by:SheppardDigital
1 Comment
 

Accepted Solution

by:
SheppardDigital earned 0 total points
ID: 40635076
I managed to resolve this my changing the code that created the link.

function nl_create_menu() {
    add_menu_page('National Locums Timesheets','Timesheets','administrator',__FILE__,'nl_ts_admin2');
    add_submenu_page(__FILE__, 'National Locums Timesheet Import','Import','administrator',__FILE__.'_nl_ts_import','nl_ts_import');
    add_submenu_page(__FILE__, 'National Locums Discipline Targets','Discipline Targets','administrator',__FILE__.'_nl_ts_targets','nl_ts_targets');
    add_submenu_page(__FILE__, 'National Locums Discipline Months','Months','administrator',__FILE__.'_nl_ts_months','nl_ts_months');
    add_submenu_page(__FILE__, 'National Locums Discipline Data Editor','Data Editor','administrator',__FILE__.'_nl_ts_data_editor','nl_ts_data_editor');
}

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MySql Database Installation 5 80
WordPress Child Theme Issue 19 40
Link to post behind image slider 1 49
WP_Query multiple custom taxonomies 5 24
How to create your own WordPress Theme Before I begin with the theme design tutorial, I would like to give you the basics of what is required to make a WordPress Theme. The most basic WordPress theme only requires 2 files: a style.css file and an…
Do you think that WordPress is just for blogs?  Think again!  WordPress is really a fantastic all around platform that you can use to develop websites on.  Integrated into its basic functionality is the ability to create pages using your choice of a…
The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Go t…

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now