wordpress plugin development- rich media institute workshop
DESCRIPTION
“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!"TRANSCRIPT
WordPress Plug-in DevelopmentRich Media Institute
Brendan Sera-ShriarBackSpaceStudios.com
Extending WordPress
“Plug-ins can extend WordPress to do almost anything you can imagine.”
-WordPress.org
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.
WordPress plug-ins help enhance and simplify the blogging experience of advanced users, especially web developers and designers.
Customizing WordPress Plug-ins
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!
• A blogger with basic to expert knowledge of HTML/CSS, and for a lot plugins, PHP and MySQL experience is highly recommended.
• 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.
• A blogger who knows what they’re doing - The default configuration of WordPress is too "fool-proof". 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 "sanitizing" them into <p> tags.
Tips On Writing WordPress Plug-insWhen 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.
Check out the Source of Plug-ins
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.
Research with a Purpose
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.
Use a plug-in Template
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?
Let’s look at a few examples
BackSpaceStudios Extended/Custom Plug-Ins
Custom Logins
BackSpaceStudios Extended/Custom Plug-Ins
Login Redirect
BackSpaceStudios Extended/Custom Plug-Ins
Random Flash Loader
BackSpaceStudios Extended/Custom Plug-Ins
Event Calendar
BackSpaceStudios Extended/Custom Plug-Ins
Custom Admin – Current Post View
BackSpaceStudios Extended/Custom Plug-Ins
Custom Admin – DashView
BackSpaceStudios Extended/Custom Plug-Ins
1 WordPress Install, 2 designs – Custom MU
Writing WordPress Plug-ins
ConventionsFor 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.
I usually start by converting a php function that I have built or found and convert it by adding the necessary WP code.
Main Elements• Header Stuff (Name, version, etc…)• Add Menu Option• Set Up the Options Page• Register the Activation and Deactivation Hooks• The Main Function
*Always make sure to include a readme.txt with your plug-in package.
Let’s build a plug-in
Writing WordPress Plug-ins
We will convert a simple php function that randomly loads Flash files from any
local or remote URL.
Lets take a look > http://backspacestudios.com/RMI/flashloader.php
Writing WordPress Plug-ins
randomflashloader.php header stuff
<?php /* Plugin Name: RandomFlashLoaderPlugin URI: http://www.backspacestudois.com/Description: Randomly loads a flash file from your wp-content/plugins/randomflashloader/swf direcotry Version: 1.0Author: GeoffPalin, Brendan Sera-ShriarAuthor URI: http://www.backspacestudios.com*/
Writing WordPress Plug-ins
Continued…
/* == Installation == Put Your Steps Here
/*
/*Add GPL License Here*/
Add Option Menuadd_action('admin_menu', 'random_flash_loader_options_setup');
Writing WordPress Plug-ins
Continued…
Setup the Options Pagefunction random_flash_loader_options_setup() {
global $random_flash_loader_data;add_options_page($random_flash_loader_data['Name'], 'RandomFlashLoader',
8, basename(__FILE__), 'random_flash_loader_page');}
Register the Activation and Deactivation Hooksregister_deactivation_hook(__FILE__, 'random_flash_loader_deactivate');register_activation_hook(__FILE__, 'random_flash_loader_activate');
Writing WordPress Plug-ins
Continued…
Random Flash Functionfunction randomflashloader(){ srand(microtime() *1000000); $num= rand (0,3); $loadswf = array(); $loadswf[0] = "http://pv3world.com/labs/PV3interactive/pv3world_cube.swf"; $loadswf[1] = "http://pv3world.com/labs/rays/rays.swf"; $loadswf[2] = "http://pv3world.com/labs/PV3Galaxy/galaxy_cubes_interactive.swf"; $loadswf[3] = "http://pv3world.com/labs/graffitiplane/graffiti_plane2.swf"; $displayswf.= "<center>"; $displayswf.= "<embed src=\"$loadswf[$num]\" "; $displayswf.= "width =\"300\" height=\"250\" bgcolor=\"#000000\" border=\"0\"/>"; $displayswf.= "</a>"; echo($displayswf);}
Bridging Two Worlds!
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.
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 protected]
Launching soon http://www.flashpress.ca and http://www.flashpressdevelopers.com
We will be launching FlashPress at FITC Toronto 2009!
FREE PHUG WorkshopsCurrent Scheduled Workshops:
Tiki WikiFBML and Facebook Fan PagesThe Power of TwitterAdvertising for the Social WebCustomizing WP2.7 Admin
We would like to thank some of our sponsors and affiliates:PHUG, Lifecapture Interactive Inc., BackSpaceStudios, Mozilla Firefox, WordPress.org, Drupal.org, FITC ( Flash In The Can ), RMI ( Rich Media Institute ), TikiWiki, Citadel Rock.
If you would like to present or no someone who does we are still taking applications. Please send us anemail at [email protected].
http://workshops.phug.ca
WordCamp Toronto 2009Hosted by PHUG
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.
http://www.wordcamptoronto.com
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
Resources
• http://www.backspacestudios.com
• http://www.phug.ca
• http://codex.wordpress.org/Working_with_WordPress#WordPress_Features
• http://codex.wordpress.org/Template_Hierarchy
• http://codex.wordpress.org/Conditional_Tags
• http://codex.wordpress.org/Templates
• http://codex.wordpress.org/Customizing_Your_Sidebar
• http://www.tamba2.org.uk/wordpress/graphicalcss/
• http://www.ndesign-studio.com
• http://www.webdesignerwall.com
• http://bloggingsquared.com
• http://automattic.com
• http://www.blog.spoongraphics.co.uk
• http://www.webappers.com
• http://www.wppotential.com
Thank You
WordPress Theme Design Workshop at RMI
Brendan Sera-Shriar, Director BackSpaceStudios
http://www.backspacestudios.com
Founder of PHUG – Open Source Culture
http://www.phug.ca