Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Starting With WordPress Plugins

G. Gombay
December 10, 2015

Starting With WordPress Plugins

A "lightning talk" given regarding some of my experiences in building and getting my first plugin approved for distribution by WordPress.org

G. Gombay

December 10, 2015
Tweet

More Decks by G. Gombay

Other Decks in Programming

Transcript

  1. What This “Lightning” Talk Will Cover  Introduction.  About

    WordPress.  Recap: What Are WordPress Plugins?  Objectives For My First “Public” Plugin.  My “Day Spelled” Plugin – What It Does  “Day Spelled” – Nuts & Bolts  Elements Of The Framework Used  Some Surprises and “Gotcha’s” encountered.  Conclusion. Starting with WordPress Plugins
  2. Site “Go Live” – For Better Results Introduction  Last

    November 20th, my plugin “Day Spelled” was accepted for distribution by WordPress.org .  A brief overview of: • How I went about building this plugin. • Some of the lessons Learned.  But this is not a “how to write plugins” tutorial!  For a guide to building WordPress plugins, please refer to our April 2015 talk by Hugh Lashbrooke. Starting with WordPress Plugins
  3. Total web sites globally > 150 million (estimate). WordPress: Content

    Management System (CMS) As of end October 2015: • Sites running on WP are 25% of global total (est.) • WP estimated to have 58% of CMS market. (Notable other major contenders; Joomla, Drupal) WP is open source; it is free! WordPress is built on a foundation of PHP. Starting with WordPress Plugins About WordPress (WP)
  4.  WordPress architecture: an open platform! Plugins: enable the community

    to augment and/or manipulate functionality of a WP site. • Plugins allow extensions to WP via the latter’s A.P.I. Without change to any of the core WP files. Just like WP itself, plugins are written in PHP. You can make your own custom plugin to extend WordPress anyway you see fit. Plugins distributed via WordPress.org must also use the GPLv2 code license. Starting with WordPress Plugins Recap: What are WordPress Plugins?
  5. Previously wrote 8 / 10 “quick-and-dirty” plugins for home use

    – simple play stuff, nothing original. Leverage existing know-how (PHP, CSS, HTM etc.) Next  a “formal” plugin qualifying for distribution by WordPress.org (“industrial strength”.) Erect a framework with all needed bells & whistles. (Invest a one-time effort for acceding to WP niche ecology.) Satisfy the WordPress criterion – Not done already. Simple guinea-pig plugin; infrastructure the priority Last but not least; have fun & add new tools/skills  Starting with WordPress Plugins Objectives For My First “Public” Plugin
  6.  WP shows its articles’ creation dates by default. (Precisely

    where displayed depends on theme you use.) What if you want to insert within the body of a page, text-box, widget etc. a current or future date?  Display a date with day & month named, overriding default if it was set to mm/dd/yy, dd month yyyy, etc. To personalize an article, to emphasize a deadline or the timing of an event, ( in contrast to dd/mm/yy) Automatic translation to the language of the given locale.(e.g. French day & month names in France.) Starting with WordPress Plugins The “Day Spelled” Plugin – What it Does
  7. The plugin defines its own custom “Shortcode”. These are like

    text macros in MS Word. Insert anywhere in WP, the shortcode : [dayspell when=‘yyyy-mm-dd’]  e.g. Beware of pranksters on [dayspell when=’2106-04-01’].  Beware of pranksters on Friday, April 1, 2106.  Default to current date if ‘when’ parameter omitted. Somes 60 lines of PHP code, that also: • Give day, month name in langs supported by WP locales. • Do comprehensive validation of parameter “when” • Generate diagnostics (at this time) also in French, German Starting with WordPress Plugins “Day Spelled” Plugin – Nuts & Bolts
  8. Elements Of The Framework Used (Minimum)  WAMP stack on

    local host. • Win, MySql, Apache, PHP • phpMyAdmin  Wordpress under WAMP.  Dreamweaver used as IDE • Also built-in FTP client!  “TortoiseSVN” client*, with local subversion repository*.  WordAster.com website: • Plugin’s Home page*. • Author home page*.  “Poedit”; code translations.  ZIP file compression* S/W.  Paypal donate link / button  Plugins’ readme.txt* validator from WordPress.org Starting with WordPress Plugins ----------------------------------------------------------------------------------------------- *Note that star’ed text correspond to elements expected by WordPress.org
  9. Set-up of a sub-framework to translate code / strings •

    Poedit, POT (Portable Object Template), .PO & .MO files • Effort to understand and learn their operation badly under- estimated. Wordpres.org’s plugin readme.txt; • Highly specific content and format requirements with its own markup language • Very finicky and time-consuming the 1st time around. As source to load the initial plugin’s zip code; • WordPress.org wanted a plugin home page from me. • WP relented since then, can now use other (e.g. Github). Starting with WordPress Plugins Some Development Surprises & “Gotcha’s”
  10. The basics of writing plugins actually quite simple. Time from

    start to finish some 3 / 4 weeks part-time. WordPress.org generally helpful & accommodating; • e.g. My plugin was reviewed & approved within 36 hrs.  Doing this imparted great sense of accomplishment. Parting thought: Go write a plugin! - Thank you for your attention. – Wordaster.com George Gombay Starting with WordPress Plug In Conclusion