Upload
nanang-f-rozi
View
216
Download
0
Embed Size (px)
Citation preview
8/11/2019 writeyourfirstwordpressplugin-090328165830-phpapp02
1/18
Write your first WordPress Plugin
Ibrahim Abdel Fattah Mohamed , aka bingorabbit www.bingorabbit.comTwitter: @bingorabbit
.. and I HEART WordPress
http://www.bingorabbit.com/http://www.bingorabbit.com/8/11/2019 writeyourfirstwordpressplugin-090328165830-phpapp02
2/18
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
8/11/2019 writeyourfirstwordpressplugin-090328165830-phpapp02
3/18
What is a WordPress Plugin?
$ piece of code, written to sol"e a problem or toadd a specific functionality that is not there.
8/11/2019 writeyourfirstwordpressplugin-090328165830-phpapp02
4/18
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?
8/11/2019 writeyourfirstwordpressplugin-090328165830-phpapp02
5/18
How can I write a plugin?
)ind a problem you need to sol"e, orsomething new to add.
Warm your hands. *hoose a descripti"e name. !ocument e"ery little thing. Think about the license. Then start coding it..
8/11/2019 writeyourfirstwordpressplugin-090328165830-phpapp02
6/18
Structure
Wordpress/|- wp-content/
|- plugins/
|- YourPlugin/|- mainfile.php|- js/|- css/|- php/
8/11/2019 writeyourfirstwordpressplugin-090328165830-phpapp02
7/18
Headers
http://path.to/plugin/http://path.to/you/http://path.to/you/http://path.to/plugin/8/11/2019 writeyourfirstwordpressplugin-090328165830-phpapp02
8/18
Hooks are +ust..hooks.. sed to attach your plugin to a working system. Two types of Hook- $ctions and )ilters
Hooks
8/11/2019 writeyourfirstwordpressplugin-090328165830-phpapp02
9/18
$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
8/11/2019 writeyourfirstwordpressplugin-090328165830-phpapp02
10/18
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]);
8/11/2019 writeyourfirstwordpressplugin-090328165830-phpapp02
11/18
Sample Plugin:Email Friends on ew Post
8/11/2019 writeyourfirstwordpressplugin-090328165830-phpapp02
12/18
Important !inks
Writing a Plugin /http:00code(.wordpress.org0Writing1a1Plugin 2
Plugin $PI /http:00code(.wordpress.org0Plugin1$PI 2 $ctions 3eference /
http:00code(.wordpress.org0Plugin1$PI0$ction13eference 2 )ilters 3eference /
http:00code(.wordpress.org0Plugin1$PI0)ilter13eference 2
WordPress *oding %tandards /http:00code(.wordpress.org0WordPress1*oding1%tandards 2
http://codex.wordpress.org/Writing_a_Pluginhttp://codex.wordpress.org/Plugin_APIhttp://codex.wordpress.org/Plugin_API/Action_Referencehttp://codex.wordpress.org/Plugin_API/Filter_Referencehttp://codex.wordpress.org/WordPress_Coding_Standardshttp://codex.wordpress.org/WordPress_Coding_Standardshttp://codex.wordpress.org/Plugin_API/Filter_Referencehttp://codex.wordpress.org/Plugin_API/Action_Referencehttp://codex.wordpress.org/Plugin_APIhttp://codex.wordpress.org/Writing_a_Plugin8/11/2019 writeyourfirstwordpressplugin-090328165830-phpapp02
13/18
"ontri#uting to WordPress$$
8/11/2019 writeyourfirstwordpressplugin-090328165830-phpapp02
14/18
Why?
Impro"e the software you use.. eing a part of the community, learning and
e(perience.
8/11/2019 writeyourfirstwordpressplugin-090328165830-phpapp02
15/18
Where?
!ocumentation, aka *ode( /http:00code(.wordpress.org0*ode(:*ontributing 2
Translation /http:00code(.wordpress.org0Translating1WordPress 2
%upport )orum /http:00www.wordpress.org0support 2 I3* *hannel /4WordPress5de" on )reenode2 !e"elopment /6e(t %lide?2
http://codex.wordpress.org/Codex:Contributinghttp://codex.wordpress.org/Translating_WordPresshttp://www.wordpress.org/supporthttp://www.wordpress.org/supporthttp://codex.wordpress.org/Translating_WordPresshttp://codex.wordpress.org/Codex:Contributing8/11/2019 writeyourfirstwordpressplugin-090328165830-phpapp02
16/18
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
8/11/2019 writeyourfirstwordpressplugin-090328165830-phpapp02
17/18
Any %uestions?$$
8/11/2019 writeyourfirstwordpressplugin-090328165830-phpapp02
18/18
&hanks'$$ brahim Abdel Fattah Mohamed
www.bingorabbit.comwww.catreloaded.net