Professional Documents
Culture Documents
• Pre‐development issues
– Wordpress Plugin Directory
– Plugin and File Names
– File Headers
• Wordpress Plugin Hooks
– Actions
– Filters
• Adding data to wordpress database
– Creating tables with plugins
• Adding Administration Menus
– Creating options page
• “Hello Dolly” example
Wordpress Plugin Development ‐ A Short
11/10/2008 2
Tutorial
Pre‐development issues (1)
Wordpress Plugin Directory
code
javascript
It is good for the names of your php files to be derived
from your chosen plugin name.
Hooks
Action Event
Wordpress Plugin Development ‐ A Short
11/10/2008 7
Tutorial
Wordpress Plugin Hooks (3)
Hooks = Actions + Filters
Filters - Functions
DATA
Steps…
1. Write a PHP function that creates the table.
2. Ensure that WordPress calls the function when the plugin is activated.
3. Create an upgrade function, if a new version of your plugin needs to have a
different table structure.
http://codex.wordpress.org/Creating_Tables_with_Plugins#Create_Database_Tables
Wordpress Plugin Development ‐ A Short
11/10/2008 9
Tutorial
A simple example
$table_name = $wpdb->prefix . "liveshoutbox";
// SQL Statement
$sql = "CREATE TABLE " . $table_name . " (
id mediumint(9) NOT NULL AUTO_INCREMENT,
time bigint(11) DEFAULT '0' NOT NULL,
name tinytext NOT NULL,
text text NOT NULL,
url VARCHAR(55) NOT NULL,
UNIQUE KEY id (id)
);";
// SQL Statememt
$insert = "INSERT INTO " . $table_name .
" (time, name, text) " .
"VALUES ('" . time() . "','" . $wpdb->escape($welcome_name) . "','" . $wpdb->escape($welcome_text) .
"')";
add_action('admin_footer', 'hello_dolly');
14th place
The 25 most influential
people on the web
(2008)
http://codex.wordpress.org/Writing_a_Plugin#WordPress_Plugin_Hooks
http://codex.wordpress.org/Plugin_API
http://codex.wordpress.org/Creating_Tables_with_Plugins
http://codex.wordpress.org/Adding_Administration_Menus
Thank you!