Solved

Wordpress plugin sub menu issue

Posted on 2015-01-19
1
85 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Like there are many different versions of Wordpress, there are also a handful of related side projects WordPress users should be familiar with.   All of these projects are open source and GPL licensed, which means there are few restrictions to us…
In Part I (http://www.experts-exchange.com/Web_Development/Blogs/WordPress/A_8410-Getting-Started-In-WordPress-Part-I.html), I introduced you to the powerful WordPress backend, the WordPress administrative Dashboard.  In Part II, I will introduce yo…
The purpose of this video is to demonstrate how to create a Printer Friendly PDF on a WordPress Page. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome Screenshot” Google Chrome Extension, and SmallPDF.com Log…
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…

760 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

21 Experts available now in Live!

Get 1:1 Help Now