WordPress Plugin Development- Rich Media Institute Workshop


Published on

“Plug-ins can extend WordPress to do almost anything you can imagine.” In this workshop we will cover the following areas, Extending WordPress, Customizing WordPress Plug-ins, Tips On Writing WordPress Plug-ins, Writing WordPress Plug-ins, and Essential WordPress Plug-ins. Plus, that isn’t enough, we will build a simple Flash plug-in by the end of the workshop that you can take with you!"

Published in: Technology, Business
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

WordPress Plugin Development- Rich Media Institute Workshop

  1. 1. WordPress Plug-in Development Rich Media Institute Brendan Sera-Shriar BackSpaceStudios.com
  2. 2. Extending WordPress <ul><li>“ Plug-ins can extend WordPress to do almost anything you can imagine.” </li></ul><ul><li>-WordPress.org </li></ul><ul><li>Well almost! There is a limit to what a plug-in can do. Quite often in order to achieve the desired functionality there is some customization of code required. </li></ul><ul><li>WordPress plug-ins help enhance and simplify the blogging experience of advanced users , especially web developers and designers. </li></ul>
  3. 3. Customizing WordPress Plug-ins <ul><li>Not all plug-ins work out of the box! A good majority of powerful and essential plug-ins will require some customization. This means CODE! </li></ul><ul><ul><li>A blogger with basic to expert knowledge of HTML/CSS, and for a lot plugins, PHP and MySQL experience is highly recommended. </li></ul></ul><ul><ul><li>A blogger who needs to display complex content in posts and pages like displaying and colorizing code snippets, running custom scripts only on certain posts or pages, incorporating custom web forms, etc. </li></ul></ul><ul><ul><li>A blogger who knows what they’re doing - The default configuration of WordPress is too &quot;fool-proof&quot;. For example, with the visual editor turned on, it will add unexpected indents and line breaks even inside <pre> tags. Additionally, it blocks you from adding <div> tags, automatically &quot;sanitizing&quot; them into <p> tags. </li></ul></ul>
  4. 4. Tips On Writing WordPress Plug-ins <ul><li>When all else fails! You don’t have to be a PHP or WordPress expert, anyone can create useful WordPress plug-ins without being a hacker. </li></ul><ul><ul><li>Check out the Source of Plug-ins </li></ul></ul><ul><ul><li>One of the most helpful ways to improve your coding is by checking out the other plug-ins source code. Each plug-in author has a completely unique style of coding, and this can vary from super-advanced like the Google Sitemap Generator plug-in to the incredibly-simple like the AskApache Search Engine Verify plug-in. </li></ul></ul><ul><ul><li>Research with a Purpose </li></ul></ul><ul><ul><li>Instead of just picking plug-ins at random to reverse-engineer, surf the WordPress plug-in repository for unique plug-ins that perform a specific function or feature. For example; If you wanted to learn about MySQL search and replace code for WordPress, check out the source code of the excellent Search Regex plugin. </li></ul></ul><ul><ul><li>Use a plug-in Template </li></ul></ul><ul><ul><li>Any good Web Developer knows the extreme value of using modular, templateable code. CSS, XHTML, javascript, and PHP, all are geared towards templates. WordPress is one of the mack-daddies of templates, so why not use a template for plug-in files? </li></ul></ul>
  5. 5. Let’s look at a few examples
  6. 6. BackSpaceStudios Extended/Custom Plug-Ins Custom Logins
  7. 7. BackSpaceStudios Extended/Custom Plug-Ins Login Redirect
  8. 8. BackSpaceStudios Extended/Custom Plug-Ins Random Flash Loader
  9. 9. BackSpaceStudios Extended/Custom Plug-Ins Event Calendar
  10. 10. BackSpaceStudios Extended/Custom Plug-Ins Custom Admin – Current Post View
  11. 11. BackSpaceStudios Extended/Custom Plug-Ins Custom Admin – DashView
  12. 12. BackSpaceStudios Extended/Custom Plug-Ins 1 WordPress Install, 2 designs – Custom MU
  13. 13. Writing WordPress Plug-ins <ul><li>Conventions </li></ul><ul><li>For each new plug-in I create a folder in the /wp-content/plugins/ pluginname / and then in that folder I create the main plug-in file with the same name as the folder + .php so the plug-in file is /wp-content/plugins/pluginname/ pluginname.php . </li></ul><ul><li>I usually start by converting a php function that I have built or found and convert it by adding the necessary WP code. </li></ul><ul><li>Main Elements </li></ul><ul><ul><li>Header Stuff (Name, version, etc…) </li></ul></ul><ul><ul><li>Add Menu Option </li></ul></ul><ul><ul><li>Set Up the Options Page </li></ul></ul><ul><ul><li>Register the Activation and Deactivation Hooks </li></ul></ul><ul><ul><li>The Main Function </li></ul></ul><ul><ul><li>*Always make sure to include a readme.txt with your plug-in package. </li></ul></ul>
  14. 14. Let’s build a plug-in
  15. 15. Writing WordPress Plug-ins <ul><li>We will convert a simple php function that randomly loads Flash files from any local or remote URL. </li></ul><ul><li>Lets take a look > http://backspacestudios.com/RMI/flashloader.php </li></ul>
  16. 16. Writing WordPress Plug-ins <ul><li>randomflashloader.php header stuff </li></ul><ul><li><?php </li></ul><ul><li>/* </li></ul><ul><li>Plugin Name: RandomFlashLoader </li></ul><ul><li>Plugin URI: http://www.backspacestudois.com/ </li></ul><ul><li>Description: Randomly loads a flash file from your wp-content/plugins/randomflashloader/swf direcotry </li></ul><ul><li>Version: 1.0 </li></ul><ul><li>Author: GeoffPalin, Brendan Sera-Shriar </li></ul><ul><li>Author URI: http://www.backspacestudios.com </li></ul><ul><li>*/   </li></ul>
  17. 17. Writing WordPress Plug-ins <ul><li>Continued… </li></ul><ul><li>/* </li></ul><ul><li>== Installation ==   </li></ul><ul><li>Put Your Steps Here </li></ul><ul><li>/* </li></ul><ul><li>/* </li></ul><ul><li>Add GPL License Here </li></ul><ul><li>*/ </li></ul><ul><li>Add Option Menu </li></ul><ul><li>add_action('admin_menu', 'random_flash_loader_options_setup'); </li></ul>
  18. 18. Writing WordPress Plug-ins <ul><li>Continued… </li></ul><ul><li>Setup the Options Page </li></ul><ul><li>function random_flash_loader_options_setup() </li></ul><ul><li>{ </li></ul><ul><li>global $random_flash_loader_data; </li></ul><ul><li>add_options_page($random_flash_loader_data['Name'], 'RandomFlashLoader', 8, basename(__FILE__), 'random_flash_loader_page'); </li></ul><ul><li>} </li></ul><ul><li>Register the Activation and Deactivation Hooks </li></ul><ul><li>register_deactivation_hook(__FILE__, 'random_flash_loader_deactivate'); </li></ul><ul><li>register_activation_hook(__FILE__, 'random_flash_loader_activate'); </li></ul>
  19. 19. Writing WordPress Plug-ins <ul><li>Continued… </li></ul><ul><ul><li>Random Flash Function </li></ul></ul><ul><ul><li>function randomflashloader(){ </li></ul></ul><ul><ul><li>srand(microtime() *1000000); </li></ul></ul><ul><ul><li>$num= rand (0,3); </li></ul></ul><ul><ul><li>$loadswf = array(); </li></ul></ul><ul><ul><li>$loadswf[0] = &quot;http://pv3world.com/labs/PV3interactive/pv3world_cube.swf&quot;; </li></ul></ul><ul><ul><li>$loadswf[1] = &quot;http://pv3world.com/labs/rays/rays.swf&quot;; </li></ul></ul><ul><ul><li>$loadswf[2] = &quot;http://pv3world.com/labs/PV3Galaxy/galaxy_cubes_interactive.swf&quot;; </li></ul></ul><ul><ul><li>$loadswf[3] = &quot;http://pv3world.com/labs/graffitiplane/graffiti_plane2.swf&quot;; </li></ul></ul><ul><ul><li>$displayswf.= &quot;<center>&quot;; </li></ul></ul><ul><ul><li>$displayswf.= &quot;<embed src=&quot;$loadswf[$num]&quot; &quot;; </li></ul></ul><ul><ul><li>$displayswf.= &quot;width =&quot;300&quot; height=&quot;250&quot; bgcolor=&quot;#000000&quot; border=&quot;0&quot;/>&quot;; </li></ul></ul><ul><ul><li>$displayswf.= &quot;</a>&quot;; </li></ul></ul><ul><ul><li>echo($displayswf); </li></ul></ul><ul><ul><li>}   </li></ul></ul>
  20. 20. <ul><li>Bridging Two Worlds! </li></ul><ul><li>FlashPress is an extension to WordPress, which allows Flash designers/developers to use the WordPress engine to communicate with a Flash site. The use of the WordPress CMS in Flash overcomes many obstacles involved with maintaining and updating a Flash site. </li></ul><ul><li>The FlashPress development thread is restricted to contributors of this group. If you would like to contribute to this project please contact us at [email_address] </li></ul><ul><li>Launching soon http://www.flashpress.ca and http://www.flashpressdevelopers.com </li></ul><ul><li>We will be launching FlashPress at FITC Toronto 2009! </li></ul>
  21. 21. <ul><li>FREE PHUG Workshops </li></ul><ul><li>Current Scheduled Workshops: </li></ul><ul><li>Tiki Wiki </li></ul><ul><li>FBML and Facebook Fan Pages </li></ul><ul><li>The Power of Twitter </li></ul><ul><li>Advertising for the Social Web </li></ul><ul><li>Customizing WP2.7 Admin </li></ul><ul><li>We would like to thank some of our sponsors and affiliates: </li></ul><ul><li>PHUG, Lifecapture Interactive Inc., BackSpaceStudios, Mozilla Firefox, WordPress.org, Drupal.org, </li></ul><ul><li>FITC ( Flash In The Can ), RMI ( Rich Media Institute ), TikiWiki, Citadel Rock. </li></ul><ul><li>If you would like to present or no someone who does we are still taking applications. Please send us an </li></ul><ul><li>email at [email_address] </li></ul><ul><li>http://workshops.phug.ca </li></ul>
  22. 22. <ul><li>WordCamp Toronto 2009 </li></ul><ul><li>Hosted by PHUG </li></ul><ul><li>WordCamp is a conference type of event that focuses squarely on everything WordPress. Everyone from casual end users all the way up to core developers show up to these events. These events are usually highlighted by speeches or keynotes by various people. </li></ul><ul><li>http://www.wordcamptoronto.com </li></ul>
  23. 23. Other Ways to Stay in Touch PHUG – Open Source Culture http://www.facebook.com/group.php?sid=17f1d77e9310971276dc2fd49210fa18&gid=5470619311 WordCamp Toronto http://www.facebook.com/group.php?gid=50753366566#/group.php?gid=50753366566 PHUG – Open Source Culture http://twitter.com/PHUGCulture WordCamp Toronto http://twitter.com/WordCampTO
  24. 24. Resources <ul><ul><li>http://www.backspacestudios.com </li></ul></ul><ul><ul><li>http://www.phug.ca </li></ul></ul><ul><ul><li>http://codex.wordpress.org/Working_with_WordPress#WordPress_Features </li></ul></ul><ul><ul><li>http://codex.wordpress.org/Template_Hierarchy </li></ul></ul><ul><ul><li>http://codex.wordpress.org/Conditional_Tags </li></ul></ul><ul><ul><li>http://codex.wordpress.org/Templates </li></ul></ul><ul><ul><li>http://codex.wordpress.org/Customizing_Your_Sidebar </li></ul></ul><ul><ul><li>http://www.tamba2.org.uk/wordpress/graphicalcss/ </li></ul></ul><ul><ul><li>http://www.ndesign-studio.com </li></ul></ul><ul><ul><li>http://www.webdesignerwall.com </li></ul></ul><ul><ul><li>http://bloggingsquared.com </li></ul></ul><ul><ul><li>http://automattic.com </li></ul></ul><ul><ul><li>http://www.blog.spoongraphics.co.uk </li></ul></ul><ul><ul><li>http://www.webappers.com </li></ul></ul><ul><ul><li>http://www.wppotential.com </li></ul></ul>
  25. 25. Thank You <ul><li>WordPress Theme Design Workshop at RMI </li></ul><ul><li>Brendan Sera-Shriar, Director BackSpaceStudios </li></ul><ul><li>http://www.backspacestudios.com </li></ul><ul><li>[email_address] </li></ul><ul><li>Founder of PHUG – Open Source Culture </li></ul><ul><li>http://www.phug.ca </li></ul>