Professional Documents
Culture Documents
Plug in Development
Plug in Development
WordCamp Providence
1
Break the Ice
Twitter: @Desrosj
✤ From Dartmouth, Massachusetts
2
WordPress Experience
✤ Developing for WordPress since about 2008 (Can’t remember the love
at first site moment)
3
Goals Here
4
5
What The Heck’s A Plugin?
6
Examples Please?
✤ Jetpack by WordPress.com
✤ Adds WordPress.com features to your self hosted WordPress sites such as Gravatar
Hovercards, Social Media Sharing and more.
✤ Gravity Forms
7
How To Make A Plugin
✤ Four Stages
✤ Planning
✤ Implementation
✤ Release
✤ Support
8
Use The WordPress Codex
9
1. Planning
10
2. Implementation
✤ http://codex.wordpress.org/WordPress_Coding_Standards
11
What Makes A Good Plugin
✤ If the user can tell where WordPress ends and your plugin begins,
you probably should try to do things differently.
12
Don’t Reinvent The Wheel
13
Naming
14
Plugin Header
✤ Plugin Header
15
Actions & Filters
16
Actions
17
Action Example
18
Some Useful Action Hooks
✤ save_post
✤ Runs when a post is saved.
✤ init
✤ Used to create widget areas, nav menu locations, etc.
✤ wp_enqueue_scripts
✤ Used to enqueue scripts and stylesheets.
✤ admin_menu
19
Filters
✤ Filters sit between the database & output, or input and the
database.
✤ Almost every input and output to the site is passed through at least
one filter.
✤ Allows you to alter things to display or save the way you need.
20
Filter Example
21
Some Useful Filters
✤ the_content
✤ the_excerpt
22
Actions & Filters
✤ Allow you to alter the output and functionality of the site without
having to alter Core WordPress (which you should never do).
23
Loading Scripts The Right Way
24
Loading Scripts The Right Way
25
Loading Scripts The Right Way
26
Loading Scripts The Right Way
27
Loading Scripts The Right Way
28
Works For Stylesheets Too!
29
Admin Only Scripts/Styles
30
Passing Dynamic Info to JS
31
Input & Output Sanitation
✤ NEVER trust user input. Always make sure your output is formatted
properly.
32
Input & Output Sanitation
33
Namespace Your Functions
✤ jwp_function_name()
34
Namespace Your Functions
✤ Class Approach
35
Settings, Post Meta, User Meta
✤ Namespace all settings, post meta, and user meta to avoid conflict!
✤ jwp_user_meta_key
✤ jwp_option_name
36
Only Run Code When Needed!
✤ Be specific with your action & filter hooks.
✤ Most hooks not only run the default, but also run more specific
actions or filters.
37
Only Run Code When Needed!
38
1?IA8@*ts%7 (aka I’m Stuck!)
39
1?IA8@*ts%7 (aka I’m Stuck!)
40
Uninstalling Your Plugin
41
Uninstalling Your Plugin
42
The Next Level
43
The Next Level
✤ I18n (Internationalization)
✤ Integrate Crons
44
Web Designer's Guide to
WordPress
45
Questions? Comments? Compliments?
✤ Twitter: @Desrosj
✤ http://jonathandesrosiers.com
46