Plugin
                     Development
                                           - Joey Kudish

                         http://slides.jkudish.com
Friday, 11 January, 13
About me
                 • WordPress developer since 2007
                 • Initially built sites for a variety of clients
                 • Freelance plugin development
                 • Code Wrangler at WordPress.com / Automattic
                 since May 2011
                 • Originally from Montreal, moved to Vancouver
                 in 2011



Friday, 11 January, 13
Friday, 11 January, 13
What’s a
                         plugin?
Friday, 11 January, 13
A plugin extends or
                    modi!es WordPress
                     to do something it
                    didn’t previously do

Friday, 11 January, 13
Themes can act as
           plugins. Oh and there’s
              mu-plugins too.


Friday, 11 January, 13
Plugins can be
                         huge...


Friday, 11 January, 13
... or tiny.
Friday, 11 January, 13
What’s in a plugin?




Friday, 11 January, 13
Where does it
                       go?
     wp-content/plugins/[plugin_name]
        or wp-content/mu-plugins/

Friday, 11 January, 13
In order to ā€œhookā€
                    into WordPress, we
                    use action and !lter
                           hooks

Friday, 11 January, 13
Action hooks allow
                         you to add your own
                         code to WordPress’
                               call stack

Friday, 11 January, 13
Filter hooks allow
                     you to modify an
                   existing variable or
                   piece of information

Friday, 11 January, 13
Demo time

Friday, 11 January, 13
Let’s add Google
                           Webmaster Tools
                         veri!cation to our site




Friday, 11 January, 13
Friday, 11 January, 13
Friday, 11 January, 13
Friday, 11 January, 13
Finding hooks
                 • WordPress.org Codex (http://
                 codex.wordpress.org/)
                 • http://adambrown.info/p/wp_hooks
                 • Debug Bar + Debug Bar Action Hooks plugin
                 (http://wordpress.org/extend/plugins/debug-bar-
                 action-hooks/)
                 • Search core (use your IDE or a command line
                 tool like ack)


Friday, 11 January, 13
Some pro tips

Friday, 11 January, 13
Use built-in APIs,
                         don’t re-invent the
                                wheel


Friday, 11 January, 13
Use WordPress coding
                              standards




Friday, 11 January, 13
Be nice to other devs.
                 Namespace your classes
                  and functions. Leave
                    hooks for others.


Friday, 11 January, 13
Demo time

Friday, 11 January, 13
Friday, 11 January, 13
Friday, 11 January, 13
Friday, 11 January, 13
Friday, 11 January, 13
hey that’s the
                         !le we want to hook
                         into




Friday, 11 January, 13
Friday, 11 January, 13
Friday, 11 January, 13
Friday, 11 January, 13
Friday, 11 January, 13
Let’s create our
                              plugin




Friday, 11 January, 13
Friday, 11 January, 13
Friday, 11 January, 13
Friday, 11 January, 13
Friday, 11 January, 13
Friday, 11 January, 13
Friday, 11 January, 13
Friday, 11 January, 13
Friday, 11 January, 13
It works, now let’s
                     have some fun


Friday, 11 January, 13
Friday, 11 January, 13
Friday, 11 January, 13
Friday, 11 January, 13
Friday, 11 January, 13
Finished plugin




Friday, 11 January, 13
A word on
                          Security

Friday, 11 January, 13
don’t trust
                           users

Friday, 11 January, 13
sanitize input,
                         escape output
               http://codex.wordpress.org/Data_Validation

Friday, 11 January, 13
protect users from
                   malicious attacks,
                      use nonces to
                  validate user actions
         http://codex.wordpress.org/WordPress_Nonces
Friday, 11 January, 13
Plugin
                         Distribution

Friday, 11 January, 13
Friday, 11 January, 13
Friday, 11 January, 13
Friday, 11 January, 13
Further
                         reading

Friday, 11 January, 13
Friday, 11 January, 13
Friday, 11 January, 13
Friday, 11 January, 13
http://www.wrox.com/WileyCDA/WroxTitle/   http://www.packtpub.com/wordpress-plugin-
      Professional-WordPress-Plugin-            development-cookbook/book
      Development.productCd-0470916222.html

Friday, 11 January, 13
Thanks!
                          Q&A
                         http://slides.jkudish.com
Friday, 11 January, 13

WordCamp Victoria 2013: Plugin Development 2013