Solved

Wordpress plugin sub menu issue

Posted on 2015-01-19
1
93 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

How to install BuddyPress on your self-hosted WordPress site It’s been called everything from “social networking in a box” to “Facebook without the terms of service,” but until Feb. 16, BuddyPress was a relatively unknown outside the WordPress MU…
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
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 Test the speed of a WordPress Website. Site Speed is an important metric of a site’s health. Slow site speed can result in viewers leaving your site quickly and not seeing your content. This…
Suggested Courses

636 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