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

GrumpyBum84 on "Simple Menu"

$
0
0

Hi All,

I have been working with PHP for some time now and thought I would give WordPress a shot, but I am getting lost on some basic functionality and I have been pulling my hair out trying to understand what I am doing so wrong.

All I am after is a simple menu item for settings and despite all my research I cannot do it :(
My code is as follows,

add_action('admin_menu', 'testPluginMenu');

function testPluginMenu() {
	add_options_page('Testing Plugin', 'Testing 3 Plugin', 'administrator', 'test-plugin', 'pluginAdminMenu');
}

function pluginAdminMenu() {
	echo '<h1>Test Plugin Admin Menu</h1>';
	echo '<p>This is a test</p>';
}

Code I copied off the WordPress Codex Site, http://codex.wordpress.org/Adding_Administration_Menus

/** Step 2 (from text above). */
add_action( 'admin_menu', 'my_plugin_menu' );

/** Step 1. */
function my_plugin_menu() {
	add_options_page( 'My Plugin Options', 'My Plugin', 'manage_options', 'my-unique-identifier', 'my_plugin_options' );
}

/** Step 3. */
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>';
}

The problem is, the code from codex works and mine does not.
I am pulling my hair out trying to find out what makes then different but the more I go over these the more they look to be the same patteren and code set :(

Can anyone please point this out to me? Yes, I want you to point out my noob mistake as I am going crazy just trying to sort this basic function.

Thanks all


Viewing all articles
Browse latest Browse all 8245

Trending Articles