Successfully reported this slideshow.

Tales of a Plugin Developer, or: Don't repeat my mistakes, please!

1

Share

Upcoming SlideShare
Kellogg XML Holland Speech
Kellogg XML Holland Speech
Loading in …3
×
1 of 25
1 of 25

More Related Content

Related Books

Free with a 14 day trial from Scribd

See all

Tales of a Plugin Developer, or: Don't repeat my mistakes, please!

  1. 1. Tales of a Plugin Developer WordCamp Chicago · June 29, 2013 Or: Don‟t repeat my mistakes, please! Tobias Bäthge
  2. 2. Who am I? • Magdeburg, Germany • “Engineering Cybernetics” • Go Mariners! Tobias Bäthge @TobiasBg wordpress@tobias.baethge.com
  3. 3. 2006: personal blog/diary 2008: baseball team„s website 2009: WP-Table Reloaded 2012: TablePress WordCamps 2009: Jena, Germany 2010: Berlin, Germany 2013: Chicago WordPress timeline
  4. 4. WP-Table Reloaded and TablePress TablePress enables you to create and manage tables, without having to write HTML code, and it adds valuable functions for your visitors. „
  5. 5. Need Tables on a baseball website First solution Write tables in HTML code Better solution A plugin! A brief history I’ll write my own plugin!
  6. 6. • started in April 2009 • almost 600,000 downloads • was in Top 20 of highest rated plugins for a long time tobias.baethge.com/wordpress-plugins/wp-table-reloaded-english/ WP-Table Reloaded Deprecated!
  7. 7. • Bugs Bad design decisions – Data Storage – Data Format – Form Submission – “Options, not Decisions!” – “Try to solve everything a lot of things.” • Doesn‟t use current best practices – AJAX – Roles and Capabilities • (and people got name wrong all the time) WP-Table Reloaded Fix it!
  8. 8. • enhancements: – Data Storage: Custom Post Type – Data Format: JSON – Form Submission: AJAX – Decisions, not Options! – Do one thing right! • (new features) – formulas, speed, bulk import/export, default styling, … TablePress @TablePress tablepress.org
  9. 9. • Hooks/Filters • Scripts/Styles enqueuing • i18n • Shortcodes • Security (escaping, WP_Roles/capabilities) • AJAX (admin-ajax.php) • Custom Post Types • Transients • HTTP API • WP_List_Table • TinyMCE integration • Writing Files (WP_Filesystem) • WP_Cron (in Extensions) Used Techniques and APIs
  10. 10. Data Storage Options API • wp_options database table • might be autoloaded • unexpected location Custom Post Type • wp_posts database table • loaded when needed
  11. 11. Data Format PHP Serialized Strings a:2:{i:0;a:2:{i:0;s:6:"Cell 1";i:1;s:6:"Cell 2";}i:1;a:2:{i:0;s:6:"Cell 3";i:1;s:6:"Cell 4";}} • length information • database search/replace breaks it • Unicode characters might break it JSON [["Cell 1","Cell 2"],["Cell 3","Cell 4"]] • no length information • database search/replace no problem • native Unicode support Cell 1 Cell 2 Cell 3 Cell 4
  12. 12. Form Submission „plain“ HTTP POST • one variable for each form element • full page reload (sloooow) • security extensions can cause data loss AJAX • form elements JSONified to one string variable • no full page reload (fast!) • no more data loss • bonus: more client-side JS
  13. 13. Decisions, not Options! WP-Table Reloaded • three JS libraries • many configuration options TablePress • one JS library • much fewer options as checkboxes
  14. 14. Don’t solve everything! WP-Table Reloaded • „Custom Data Fields“ • DataTables TableTools JS lib • XML import/export format TablePress • gone • as a TablePress Extension • gone
  15. 15. Data Storage Choose location wisely! Data Format Be careful with serialized strings! Form Submission Be careful when dealing with many form elements! Decisions, not Options! Don‟t offer a checkbox for everything! Don’t solve everything, but do one thing right! Consider moving extra functionality out of the plugin! TL;DR
  16. 16. 80/20 rule You can„t make everyone happy! Document code! Yes, everything. Admit, that your plugin might not be the right tool for every use case! (Surprised?) Principles
  17. 17. Local tools Online tools WordPress resources Workflow
  18. 18. Local tools MAMP TextWrangler SourceTree Chrome/Dev Tools
  19. 19. Online tools JS closure compiler closure-compiler.appspot.com CSS minifier www.freeformatter.com/css- minifier.html Data URI generator dataurl.net GitHub github.com
  20. 20. WordPress resources Core Trac • Patches/Changesets/Commit messages! core.trac.wordpress.org Core Code • Cross Reference (xRef) phpxref.ftwr.co.uk/wordpress/ WordPress Codex • Examples! codex.wordpress.org Google • search term plus “wordpress“
  21. 21. Support your plugin Website • Demo! FAQ • Yes, people will not read them. Documentation • Yes, people will also not read that. Support Forums • Website comments don„t work. wordpress.org/support/plugin/ <plugin-slug>
  22. 22. Have Fun!
  23. 23. The last slide! Tobias Bäthge @TobiasBg wordpress@tobias.baethge.com @TablePress tablepress.org

×