Wordcamp2012 build your plugin
-
Upload
alexandre-marreiros -
Category
Documents
-
view
112 -
download
0
description
Transcript of Wordcamp2012 build your plugin
![Page 1: Wordcamp2012 build your plugin](https://reader033.fdocuments.net/reader033/viewer/2022061300/54c88d674a79594d648b4614/html5/thumbnails/1.jpg)
Build your own Plugin
![Page 2: Wordcamp2012 build your plugin](https://reader033.fdocuments.net/reader033/viewer/2022061300/54c88d674a79594d648b4614/html5/thumbnails/2.jpg)
SpeakerAlexandre Marreiros
Tech Trainner and Speaker and Consultnat as Independent
CTO Innovagency
Contacts@alexmarreiros | [email protected] digitalmindignition.com
Build your own WordPress Plugin
![Page 3: Wordcamp2012 build your plugin](https://reader033.fdocuments.net/reader033/viewer/2022061300/54c88d674a79594d648b4614/html5/thumbnails/3.jpg)
Plugin“Plug-ins are a great way to enhance the functionality of your blog or WebSite by adding in extra features. These can be placed anywhere inside your template by function hooks. Over time the extensibility of WordPress’ plug-in system has allow tremendous growth and hundreds of developer-submitted pieces of software.”
Build your own WordPress Plugin
![Page 4: Wordcamp2012 build your plugin](https://reader033.fdocuments.net/reader033/viewer/2022061300/54c88d674a79594d648b4614/html5/thumbnails/4.jpg)
What i need to build plugin’sKnowledge of PHP (Rudimentar)
Basic understanding of the WordPress file structure
Good Ideias or problems
Build your own WordPress Plugin
![Page 5: Wordcamp2012 build your plugin](https://reader033.fdocuments.net/reader033/viewer/2022061300/54c88d674a79594d648b4614/html5/thumbnails/5.jpg)
Why Build Plugin’sWhen you need to solve a recorrent WordPress development need
When you need to extende the plataform
To a better understaning of the WordPress Backend
Build your own WordPress Plugin
![Page 6: Wordcamp2012 build your plugin](https://reader033.fdocuments.net/reader033/viewer/2022061300/54c88d674a79594d648b4614/html5/thumbnails/6.jpg)
Where Plugin’s Live?
Build your own WordPress Plugin
![Page 7: Wordcamp2012 build your plugin](https://reader033.fdocuments.net/reader033/viewer/2022061300/54c88d674a79594d648b4614/html5/thumbnails/7.jpg)
Best Pratice 1Give a “Home” to your Plugin this way you simplify Plugin file system struture
Create a readme.txt file to explain who are the person who knows how the Plugin is built
Build your own WordPress Plugin
![Page 8: Wordcamp2012 build your plugin](https://reader033.fdocuments.net/reader033/viewer/2022061300/54c88d674a79594d648b4614/html5/thumbnails/8.jpg)
To Start Create the base PHP file for your Plugin
You must start with the plugin declaration
Build your own WordPress Plugin
![Page 9: Wordcamp2012 build your plugin](https://reader033.fdocuments.net/reader033/viewer/2022061300/54c88d674a79594d648b4614/html5/thumbnails/9.jpg)
2 Build Aproaches Create an entire class system to avoid collisions with functions and variable names that already exist.
just write your code in sample functions.
Build your own WordPress Plugin
![Page 10: Wordcamp2012 build your plugin](https://reader033.fdocuments.net/reader033/viewer/2022061300/54c88d674a79594d648b4614/html5/thumbnails/10.jpg)
Best Pratice 2Don’t do Suicide if your plugin is simple don’t start building a entire new class ecosystem for him.
Build your own WordPress Plugin
![Page 11: Wordcamp2012 build your plugin](https://reader033.fdocuments.net/reader033/viewer/2022061300/54c88d674a79594d648b4614/html5/thumbnails/11.jpg)
Best Pratice 3
To avoid duplication use prefixing labels to all your variables and function names.
Build your own WordPress Plugin
![Page 12: Wordcamp2012 build your plugin](https://reader033.fdocuments.net/reader033/viewer/2022061300/54c88d674a79594d648b4614/html5/thumbnails/12.jpg)
Actions and Filters“Actions and Filters allow for plug-in developers to update bits of code throughout the WordPress admin panel pertaining to your new plug-in. This means you could add a new tab in the sidebar or additional settings links for your Plug-in options.”
Build your own WordPress Plugin
![Page 13: Wordcamp2012 build your plugin](https://reader033.fdocuments.net/reader033/viewer/2022061300/54c88d674a79594d648b4614/html5/thumbnails/13.jpg)
FilterA filter is used on data being passed into
WordPress. With filters you are quite literally able to filter content through your own custom written functions to change data in any way.
Used in cases like writing a sidebar widgets or smaller functions to change how a post should be displayed.
Build your own WordPress Plugin
![Page 14: Wordcamp2012 build your plugin](https://reader033.fdocuments.net/reader033/viewer/2022061300/54c88d674a79594d648b4614/html5/thumbnails/14.jpg)
ActionsTarget pre-defined areas in your templates and admin panel. Is important if your Plugin intend to be triggered when something happens in your WordPress event Pipeline.
Build your own WordPress Plugin
publish_post – called when a post is published or when status is changed into “published”save_post – called when a post/page is created from start or updatedwp_head – called when the template is loaded and runs the wp_head() functionloop_end – called immediately after the final post has been processed through the WordPress looptrackback_post – called whenever a new trackback is added into a post
![Page 15: Wordcamp2012 build your plugin](https://reader033.fdocuments.net/reader033/viewer/2022061300/54c88d674a79594d648b4614/html5/thumbnails/15.jpg)
Plugin Registering
Build your own WordPress Plugin
Plugin is installed
Plugin Creates his Hooks in
WP
Register functions as a Action Listener
Register functions as a Filter Listen
Plugin is “hooked” to WordPress
![Page 16: Wordcamp2012 build your plugin](https://reader033.fdocuments.net/reader033/viewer/2022061300/54c88d674a79594d648b4614/html5/thumbnails/16.jpg)
When Plugin is Called
Build your own WordPress Plugin
Wordpress executes an
action or render s
Wordpress Validates all the
register functions
If any
Call Plugins functions
(considering registering order)
![Page 17: Wordcamp2012 build your plugin](https://reader033.fdocuments.net/reader033/viewer/2022061300/54c88d674a79594d648b4614/html5/thumbnails/17.jpg)
Best Pratice 4
Be carefull not to destruct what plugin’s that came before you had made.
Build your own WordPress Plugin
![Page 18: Wordcamp2012 build your plugin](https://reader033.fdocuments.net/reader033/viewer/2022061300/54c88d674a79594d648b4614/html5/thumbnails/18.jpg)
Demo
Build your own WordPress Plugin
Let’s Play
![Page 19: Wordcamp2012 build your plugin](https://reader033.fdocuments.net/reader033/viewer/2022061300/54c88d674a79594d648b4614/html5/thumbnails/19.jpg)
Questions
http://codex.wordpress.org/Writing_a_PluginProfessional WordPress Plugin Development
by Brad Williams, Ozh Richard and Justin TadlockWordPress 3 Plugin Development Essentials by
B Bondari and E Griffiths (24 Mar 2011)
Resources
Your turn to Talk
Build your own WordPress Plugin
![Page 20: Wordcamp2012 build your plugin](https://reader033.fdocuments.net/reader033/viewer/2022061300/54c88d674a79594d648b4614/html5/thumbnails/20.jpg)
Thank You All !!
Special
Congrats and Thanks2
Lisbon WordCamp Crew