SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.
SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.
Successfully reported this slideshow.
Activate your 14 day free trial to unlock unlimited reading.
Tales of a Plugin Developer, or: Don't repeat my mistakes, please!
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.
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.
• 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.
• 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.
• 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.
• 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.
Data Storage
Options API
• wp_options database table
• might be autoloaded
• unexpected location
Custom Post Type
• wp_posts database table
• loaded when needed
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.
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.
Decisions, not Options!
WP-Table Reloaded
• three JS libraries
• many configuration options
TablePress
• one JS library
• much fewer options
as checkboxes
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.
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.
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.
Local tools
Online tools
WordPress resources
Workflow
18.
Local tools
MAMP TextWrangler
SourceTree Chrome/Dev Tools
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.
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.
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>