Click here to load reader

WordCamp Atlanta Presentation

  • View
    887

  • Download
    1

Embed Size (px)

DESCRIPTION

My presentation for WordCamp Atlanta 2012 titled "Got Awesome Theme Functionality? It Probably Needs a Plugin". Sorry for the crazy font - SS didn't want to process it right. :-)

Text of WordCamp Atlanta Presentation

  • 1. GOT AWESOMETHEMEFUNCTIONALITY?!IT PROBABLYNEEDS A PLUGINCore Functionality Plugin + TGM Plugin Activation + WP_FilesystemBy: Thomas Grifn / @jthomasgrifn / thomasgrifnmedia.com

2. A LITTLE BIT!ABOUT MEI DEVELOP WORDPRESS FOR A LIVINGI hold a degree in Business Management andAdministration from the best college in theworld Appalachian State University.I ofcially started September 2010, but havebeen at this whole developing thing for aroundtwo years.Fun fact: I am a scratch golfer. 3. THE DOWN!AND DIRTY WHERE ARE WE GOING TODAY? 1. Core Functionality plugin1. Anatomy of a plugin2. What is a core functionality plugin andwhy is it important? 2. TGM Plugin Activation class1. Leveraging plugins for your users2. Requiring/recommending plugins withyour themes3. Practical examples 3. WP_Filesystem (if we have time)1. Brief tutorial and how-tos 4. Q and A 4. PLUGINS, PLUGINS,! PROTECT YOURSELFPLUGINS ! A core functionality plugin contains (what should be) themeCOREindependent elements of a site.FUNCTIONALITY PLUGINS This can be a range of things, but generally this includes shortcodes,PROTECT metaboxes and CPTs/CTs.YOU FROM Why? Users expect these things toANGRY, SNARKY, UPSET, RUDE, INSENSITIVE remain when switching themes. AtIRATE, IRRITATED, ANNOYED & PEEVED worst, this saves you hours of support calls.USERS AND CLIENTSThemes shouldnt be the end-all- be-all for your projects. Ever. 5. BECAUSE IF YOU DONT, THIS HAPPENS 6. BUILDING A PLUGINPLUGIN REQUIREMENTS Plugin Name Plugin URI Description Author Author URI (optional) License (optional) License URI 7. BUILDING A PLUGIN (CONT) 8. BUILDING A PLUGIN (CONT) 9. BUILDING A PLUGIN (CONT)A COUPLE OF USEFUL FUNCTIONS plugin_dir_path( __FILE__ ) __FILE__ is a PHP constant that gets the full path and lename of the current le plugins_url( $path, $plugin ) $path is the path to whatever you are calling (e.g. an image or script) $plugin is the path to the plugin (we can use __FILE__ here) Both are documented in the Codex look them up 10. BUT WAITI KNOW YOU ARE THINKINGHow can I include plugins within a theme?How will users know how to install them?How can I give users a way to install them?What about private plugins?Can I pull plugins from WordPress repo?What about pre-packaged plugins?ENTER TGM PLUGIN ACTIVATION 11. TGM PLUGIN!ACTIVATIONTGM PLUGIN ACTIVATION is a PHPlibrary that allows you to easily require orrecommend plugins for your WordPressthemes (and plugins). It allows your usersto install and even automatically activateplugins in singular or bulk fashion usingnative WordPress classes, functions andinterfaces. You can reference pre-packaged plugins, plugins from theWordPress Plugin Repository or evenplugins hosted elsewhere on the internet.http://tgmpluginactivation.com 12. WHY !USE IT? SIMPLE: IT IS SILLY NOT TO The library uses all of WordPress own classes and methods in the installation process.It even works for those users who have strict permissions. And it works for MultiSite, too. 13. WHY !USE IT? (CONT)The are a number of benets to using aplugin for your functionality vs. including itdirectly in the theme:1. To reiterate, it saves you from having todeal with urgent messes later2. Easy updating and management (WPrepo or even your own private repo)3. If the project allows, you can share yourcode with others4. Users cant mess their own site up (noWSOD if they edit it incorrectly)Lets dive into the library, shall we? 14. WP_FILESYSTEMWP_Filesystem is a function used to call various WP_Filesystem_*classes depending on a users server setup.There are 4 different methods that WP_Filesystem uses:1. Direct2. FTP3. FTP Sockets4. SSH2WP_Filesystem will automatically choose the best method basedon the server setup. 15. WHY WP_FILESYSTEM?Writing local les, if not done correctly (err, not done withWP_Filesystem), poses security risks.Why? It is highly unlikely that your webserver user and your useraccount are one in the same. Consider shared hosting it has awebserver user and lots of other users (like you on it). Give thewebserver user ownership of your les and now everyone hasaccess to them no bueno.In effect, WP_Filesystem makes sure that you in fact are the onemaking changes to your les. 16. USING WP_FILESYSTEM?Due to a lack of time, well dive into the TGM Plugin Activationlibrary to see how WP_Filesystem is setup to process plugininstallations.There is one important function you need to know, though:request_lesystem_credentials( $form_post, $type, $error = false,$context, $extra_elds )And once setup, you can call the WP_Filesystem object:global $wp_lesystem 17. WRAPPING UP1. Use a core functionality plugin when working on projects2. Dont include functionality in a theme that should be in a plugin3. Require/recommend plugins within your distributed/commercial themes with the TGM Plugin Activation library4. Use WP_Filesystem to do any local le writing within yourplugins or themes 18. THANKS!FOR !LISTENING!QUESTIONS?http://thomasgrifnmedia.comhttp://twitter.com/jthomasgrifnhttp://facebook.com/thomasgrifnmedia

Search related