MyPlugin V1

โ€”

by

in

Snippets from a WordPress plugin I am working on… I spent a little time
hacking on this to get used to the structure. It’s pretty sweet and thanks to
the "Writing
a Plugin
" page it isn’t even crazy hard. Here is a step by step breakdown of
an actual, functioning (but lame) plugin called "MyPlugin".

<?php

/*
Plugin Name: MyPlugin
Plugin URI: http://www.soulhuntre.com
Description: An example, minimalist WordPress plug-in
Version: 1.0
Author: Soulhuntre
Author URI: http://www.soulhuntre.com
*/

// To register your plug-in with the menu system (under options)
// first you have to define a function that registers your new
administration page.
// lets add our panel to the admin page, under "options"

function MyPlugin_addmenu() {
    if (function_exists(‘add_options_page’)) {
        add_options_page(
            ‘MyPlugin’,
// plugin name
            ‘MyPlugin’,
// plugin name
            10, // only
admins can use this
           
basename(__FILE__), // a filename (unique)
            ‘MyPlugin_adminpage’
// the render function
        );
    }
}

// Then, you need render function to actually display your admin page
when the time is right…
// notice how it is defined in the add_options_page call above?
function MyPlugin_adminpage(){
    echo "<h2>Hello World!</h2>";
}

// And finally, we register a handler with WordPress
// so that our add
to menu function will be called at the right time…
add_action(‘admin_menu’, ‘MyPlugin_addmenu’);

?>