Write your first WordPress Plugin

Ibrahim Abdel Fattah Mohamed, aka bingorabbit
www.bingorabbit.com
Twitter: @bingorabbit
.. and I HEART WordPress


What is a WordPress Plugin?

Why do I need to write a WordPress Plugin?

Plugin files structure and headers.

How to add my plugin to my WordPress log.

How to contribute to WordPress !e"elopment?

#uestions..
Agenda

What is a WordPress Plugin?
$ piece of code, written to sol"e a problem or to
add a specific functionality that is not there.

Why do I need to write a WordPress Plugin?

%ol"ing a problem.

$dd new functionality

&ou lo"e it, but ha"e a better implementation?

'odify it, e(tend it

Want to make money?

How can I write a plugin?

)ind a problem you need to sol"e, or
something new to add.

Warm your hands.

*hoose a descripti"e name.

!ocument e"ery little thing.

Think about the license.

Then start coding it..

Structure
Wordpress/
|- wp-content/
|- plugins/
|- YourPlugin/
|- mainfile.php
|- js/
|- css/
|- php/

Headers
<?php
/*
Plugin Name: Your desired name
Plugin URI: http://path.to/plugin/
Description: What does it actually do?
Version: x.Y
Author: This should be you
Author URI: http://path.to/you/
*/
?>


Hooks are +ust..hooks..

,sed to attach your plugin to a working system.

Two types of Hook- $ctions and )ilters
Hooks


$ctions, are +ust actions..

$ctions triggers an e"ent or a function.

When a post is published (action), send an email
to the administrator (function, event or reaction).
add_action('hook_name',
'your_function_name', [priority],
[accepted_args]);
Actions

Filters
Database/User <! Filters <! Data

)ilters are also +ust..)ilters..

.(ample, add some te(t +ust after e"ery post.
add_filter('hook_name',
'your_function_name', [priority],
[accepted_args]);

Sample Plugin:
Email Friends on ew Post

Important !inks

Writing a Plugin /
http:00code(.wordpress.org0Writing1a1Plugin2

Plugin $PI /http:00code(.wordpress.org0Plugin1$PI2

$ctions 3eference /
http:00code(.wordpress.org0Plugin1$PI0$ction13eference2

)ilters 3eference /
http:00code(.wordpress.org0Plugin1$PI0)ilter13eference2

WordPress *oding %tandards /
http:00code(.wordpress.org0WordPress1*oding1%tandards2

"ontri#uting to WordPress$$

Why?

Impro"e the software you use..

eing a part of the community, learning and
e(perience.

Where?

!ocumentation, aka *ode( /
http:00code(.wordpress.org0*ode(:*ontributing2

Translation /
http:00code(.wordpress.org0Translating1WordPress2

%upport )orum /http:00www.wordpress.org0support2

I3* *hannel /4WordPress5de" on )reenode2

!e"elopment /6e(t %lide?2

How?

Trac /http:00trac.wordpress.org02

*ode it, refine it, or +ust test it..

7ot a bug? 7o and report it..
http:00wordpress.org0de"elopment0899:09;0contributing5to5wordpress5part5i5de"elopment0

Any %uestions?$$

&hanks'$$
Ibrahi m Abdel Fattah Mohamed
www.bingorabbit.com
www.catreloaded.net