Next Level Plugin Development - Jonathan Desrosiers...Date Next Level Plugin Development Jonathan...
Transcript of Next Level Plugin Development - Jonathan Desrosiers...Date Next Level Plugin Development Jonathan...
![Page 1: Next Level Plugin Development - Jonathan Desrosiers...Date Next Level Plugin Development Jonathan Desrosiers - @Desrosj WordCamp Providence 2013](https://reader033.fdocuments.us/reader033/viewer/2022052815/60a104f0ad73b82e68341302/html5/thumbnails/1.jpg)
Date
Next Level Plugin DevelopmentJonathan Desrosiers - @Desrosj
WordCamp Providence 2013
![Page 2: Next Level Plugin Development - Jonathan Desrosiers...Date Next Level Plugin Development Jonathan Desrosiers - @Desrosj WordCamp Providence 2013](https://reader033.fdocuments.us/reader033/viewer/2022052815/60a104f0ad73b82e68341302/html5/thumbnails/2.jpg)
Jonathan Desrosiers
✤ Dartmouth, Massachusetts
✤ Coding on WordPress for about 7 years
✤ Seven plugins (and counting) in thepublic repo.
✤ 2+ Years working on VIP themes.
✤ Work for Linchpin in Pawtucket, RI
![Page 3: Next Level Plugin Development - Jonathan Desrosiers...Date Next Level Plugin Development Jonathan Desrosiers - @Desrosj WordCamp Providence 2013](https://reader033.fdocuments.us/reader033/viewer/2022052815/60a104f0ad73b82e68341302/html5/thumbnails/3.jpg)
What I Will Talk About
✤ Best practices that will make it easier for you to maintain your plugin.
✤ APIs within WordPress that make your job boatloads easier.
✤ Things I have found useful thathopefully will help you.
![Page 4: Next Level Plugin Development - Jonathan Desrosiers...Date Next Level Plugin Development Jonathan Desrosiers - @Desrosj WordCamp Providence 2013](https://reader033.fdocuments.us/reader033/viewer/2022052815/60a104f0ad73b82e68341302/html5/thumbnails/4.jpg)
What makes a successful plugin?
✤ Works.
✤ Doesn’t break anything else.
✤ Maintainable.
✤ Most importantly to me: Other devs can easily alter your plugin’s functionality.
![Page 5: Next Level Plugin Development - Jonathan Desrosiers...Date Next Level Plugin Development Jonathan Desrosiers - @Desrosj WordCamp Providence 2013](https://reader033.fdocuments.us/reader033/viewer/2022052815/60a104f0ad73b82e68341302/html5/thumbnails/5.jpg)
Coding Best Practices
✤ http://make.wordpress.org/core/handbook/coding-standards/php/
✤ Some parts of the WordPress code structure for PHP markup are inconsistent in their style. WordPress is working to gradually improve this by helping users maintain a consistent style so the code can become clean and easy to read at a glance.
![Page 6: Next Level Plugin Development - Jonathan Desrosiers...Date Next Level Plugin Development Jonathan Desrosiers - @Desrosj WordCamp Providence 2013](https://reader033.fdocuments.us/reader033/viewer/2022052815/60a104f0ad73b82e68341302/html5/thumbnails/6.jpg)
Plugin API
✤ Actions & Filters
✤ Actions: allow you to DO something at a given point in WordPress
✤ Filters: Allow you to CHANGE something at a given point.
![Page 7: Next Level Plugin Development - Jonathan Desrosiers...Date Next Level Plugin Development Jonathan Desrosiers - @Desrosj WordCamp Providence 2013](https://reader033.fdocuments.us/reader033/viewer/2022052815/60a104f0ad73b82e68341302/html5/thumbnails/7.jpg)
Plugin API
![Page 8: Next Level Plugin Development - Jonathan Desrosiers...Date Next Level Plugin Development Jonathan Desrosiers - @Desrosj WordCamp Providence 2013](https://reader033.fdocuments.us/reader033/viewer/2022052815/60a104f0ad73b82e68341302/html5/thumbnails/8.jpg)
Plugin API
![Page 9: Next Level Plugin Development - Jonathan Desrosiers...Date Next Level Plugin Development Jonathan Desrosiers - @Desrosj WordCamp Providence 2013](https://reader033.fdocuments.us/reader033/viewer/2022052815/60a104f0ad73b82e68341302/html5/thumbnails/9.jpg)
Plugin API
✤ You can also add your own actions & filters.
![Page 10: Next Level Plugin Development - Jonathan Desrosiers...Date Next Level Plugin Development Jonathan Desrosiers - @Desrosj WordCamp Providence 2013](https://reader033.fdocuments.us/reader033/viewer/2022052815/60a104f0ad73b82e68341302/html5/thumbnails/10.jpg)
Plugin API
![Page 11: Next Level Plugin Development - Jonathan Desrosiers...Date Next Level Plugin Development Jonathan Desrosiers - @Desrosj WordCamp Providence 2013](https://reader033.fdocuments.us/reader033/viewer/2022052815/60a104f0ad73b82e68341302/html5/thumbnails/11.jpg)
Enqueueing JS Files
✤ Prevents JS libraries from loading more than once.
✤ Allows files to be loaded in the correct order based on dependencies
![Page 12: Next Level Plugin Development - Jonathan Desrosiers...Date Next Level Plugin Development Jonathan Desrosiers - @Desrosj WordCamp Providence 2013](https://reader033.fdocuments.us/reader033/viewer/2022052815/60a104f0ad73b82e68341302/html5/thumbnails/12.jpg)
Enqueueing JS Files
✤ `
![Page 13: Next Level Plugin Development - Jonathan Desrosiers...Date Next Level Plugin Development Jonathan Desrosiers - @Desrosj WordCamp Providence 2013](https://reader033.fdocuments.us/reader033/viewer/2022052815/60a104f0ad73b82e68341302/html5/thumbnails/13.jpg)
Localizing JS Files
✤ Allows the passing of data from PHP into JS
✤ Useful for passing a URL, or a specific option value.
![Page 14: Next Level Plugin Development - Jonathan Desrosiers...Date Next Level Plugin Development Jonathan Desrosiers - @Desrosj WordCamp Providence 2013](https://reader033.fdocuments.us/reader033/viewer/2022052815/60a104f0ad73b82e68341302/html5/thumbnails/14.jpg)
Load Only What Is Needed
![Page 15: Next Level Plugin Development - Jonathan Desrosiers...Date Next Level Plugin Development Jonathan Desrosiers - @Desrosj WordCamp Providence 2013](https://reader033.fdocuments.us/reader033/viewer/2022052815/60a104f0ad73b82e68341302/html5/thumbnails/15.jpg)
HTTP API
✤ Allows you to send HTTP requests.
✤ POST
✤ GET
✤ HEAD
![Page 16: Next Level Plugin Development - Jonathan Desrosiers...Date Next Level Plugin Development Jonathan Desrosiers - @Desrosj WordCamp Providence 2013](https://reader033.fdocuments.us/reader033/viewer/2022052815/60a104f0ad73b82e68341302/html5/thumbnails/16.jpg)
HTTP API
![Page 17: Next Level Plugin Development - Jonathan Desrosiers...Date Next Level Plugin Development Jonathan Desrosiers - @Desrosj WordCamp Providence 2013](https://reader033.fdocuments.us/reader033/viewer/2022052815/60a104f0ad73b82e68341302/html5/thumbnails/17.jpg)
HTTP API
![Page 18: Next Level Plugin Development - Jonathan Desrosiers...Date Next Level Plugin Development Jonathan Desrosiers - @Desrosj WordCamp Providence 2013](https://reader033.fdocuments.us/reader033/viewer/2022052815/60a104f0ad73b82e68341302/html5/thumbnails/18.jpg)
Options API
✤ The Options API is a simple and standardized way of storing data in the database.
✤ Great for information that does not change too often.
![Page 19: Next Level Plugin Development - Jonathan Desrosiers...Date Next Level Plugin Development Jonathan Desrosiers - @Desrosj WordCamp Providence 2013](https://reader033.fdocuments.us/reader033/viewer/2022052815/60a104f0ad73b82e68341302/html5/thumbnails/19.jpg)
Transient API
✤ Simple and standardized way of storing cached data in the database temporarily by giving it a custom name and a timeframe after which it will expire and be deleted.
✤ Great for information that needs to be refreshed.
![Page 20: Next Level Plugin Development - Jonathan Desrosiers...Date Next Level Plugin Development Jonathan Desrosiers - @Desrosj WordCamp Providence 2013](https://reader033.fdocuments.us/reader033/viewer/2022052815/60a104f0ad73b82e68341302/html5/thumbnails/20.jpg)
Transient API
![Page 21: Next Level Plugin Development - Jonathan Desrosiers...Date Next Level Plugin Development Jonathan Desrosiers - @Desrosj WordCamp Providence 2013](https://reader033.fdocuments.us/reader033/viewer/2022052815/60a104f0ad73b82e68341302/html5/thumbnails/21.jpg)
Transient API
✤ Really useful for displaying feeds.
✤ We don’t want to hit the feed every page load.
✤ That information probably does not change very often anyways.
![Page 22: Next Level Plugin Development - Jonathan Desrosiers...Date Next Level Plugin Development Jonathan Desrosiers - @Desrosj WordCamp Providence 2013](https://reader033.fdocuments.us/reader033/viewer/2022052815/60a104f0ad73b82e68341302/html5/thumbnails/22.jpg)
Transient API
![Page 23: Next Level Plugin Development - Jonathan Desrosiers...Date Next Level Plugin Development Jonathan Desrosiers - @Desrosj WordCamp Providence 2013](https://reader033.fdocuments.us/reader033/viewer/2022052815/60a104f0ad73b82e68341302/html5/thumbnails/23.jpg)
Transient API
![Page 24: Next Level Plugin Development - Jonathan Desrosiers...Date Next Level Plugin Development Jonathan Desrosiers - @Desrosj WordCamp Providence 2013](https://reader033.fdocuments.us/reader033/viewer/2022052815/60a104f0ad73b82e68341302/html5/thumbnails/24.jpg)
Data Validation/Sanitization
✤ Sanitize & Validate Everything!
✤ Never trust user input.
✤ santize_text_field()
✤ esc_attr()
✤ esc_js()
✤ esc_url()
✤ sanitize_html_class()
![Page 25: Next Level Plugin Development - Jonathan Desrosiers...Date Next Level Plugin Development Jonathan Desrosiers - @Desrosj WordCamp Providence 2013](https://reader033.fdocuments.us/reader033/viewer/2022052815/60a104f0ad73b82e68341302/html5/thumbnails/25.jpg)
Data Validation/Sanitization
✤ array_map()
![Page 26: Next Level Plugin Development - Jonathan Desrosiers...Date Next Level Plugin Development Jonathan Desrosiers - @Desrosj WordCamp Providence 2013](https://reader033.fdocuments.us/reader033/viewer/2022052815/60a104f0ad73b82e68341302/html5/thumbnails/26.jpg)
Namespace Your Functions
✤ Namespace everything.
✤ Functions
✤ Classes
✤ Localized JS variables
![Page 27: Next Level Plugin Development - Jonathan Desrosiers...Date Next Level Plugin Development Jonathan Desrosiers - @Desrosj WordCamp Providence 2013](https://reader033.fdocuments.us/reader033/viewer/2022052815/60a104f0ad73b82e68341302/html5/thumbnails/27.jpg)
Namespace Your Functions
✤ Avoid conflicting function and class names
![Page 28: Next Level Plugin Development - Jonathan Desrosiers...Date Next Level Plugin Development Jonathan Desrosiers - @Desrosj WordCamp Providence 2013](https://reader033.fdocuments.us/reader033/viewer/2022052815/60a104f0ad73b82e68341302/html5/thumbnails/28.jpg)
WordPress Features & APIs
✤ Internationalization (I18n)
✤ Nonces (Number used Once)
✤ Metadata API
✤ Shortcode API
✤ Widget API
✤ Theme Customization API
✤ File System API
✤ Rewrite API
✤ Quicktags API
✤ File Header API
✤ WordPress.com API
✤ Settings API
✤ WP_List_Table
![Page 29: Next Level Plugin Development - Jonathan Desrosiers...Date Next Level Plugin Development Jonathan Desrosiers - @Desrosj WordCamp Providence 2013](https://reader033.fdocuments.us/reader033/viewer/2022052815/60a104f0ad73b82e68341302/html5/thumbnails/29.jpg)
Thanks For Listening!
• Tweet me
• @Desrosj
• Check out my plugins on the WordPress Plugin Repo
• http://profiles.wordpress.org/desrosj
• Come to the WordPress Providence Meetups!