Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

xymalf on "how do I add an application page to this code."

$
0
0

`add_action('admin_menu', 'my_plugin_menu');

// Here you can check if plugin is configured (e.g. check if some option is set). If not, add new hook.
// In this example hook is always added.
add_action( 'admin_notices', 'my_plugin_admin_notices' );

function my_plugin_menu() {
// Add the new admin menu and page and save the returned hook suffix
$hook_suffix = add_options_page('My Plugin Options', 'My Plugin', 'manage_options', 'my-unique-identifier', 'my_plugin_options');
// Use the hook suffix to compose the hook and register an action executed when plugin's options page is loaded
add_action( 'load-' . $hook_suffix , 'my_load_function' );
}

function my_load_function() {
// Current admin page is the options page for our plugin, so do not display the notice
// (remove the action responsible for this)
remove_action( 'admin_notices', 'my_plugin_admin_notices' );
}

function my_plugin_admin_notices() {
echo "<div id='notice' class='updated fade'><p>My Plugin is not configured yet. Please do it now.</p></div>\n";
}

function my_plugin_options() {
if (!current_user_can('manage_options')) {
wp_die( __('You do not have sufficient permissions to access this page.') );
}
echo '<div class="wrap">';
echo '<p>Here is where the form would go if I actually had options.</p>';
echo '</div>';
}
?>

I want to add a sub menu item - application to above. How do I do it assuming I want to call the app app.php


Viewing all articles
Browse latest Browse all 8245

Trending Articles