The document discusses best practices for building WordPress plugins, including improving one's workflow with version control and text editors, understanding WordPress code structure and APIs, following coding standards, defining a plugin's focus and structure, and testing plugins. It also provides examples from the speaker's own plugins and mistakes made. The speaker advocates investing in one's skills and producing well-coded, unique plugins that address user experience through standards compliance and robust testing.
2. Who I am?
• Marko Heijnen
• Founder of CodeKitchen
• Working at 1&1
• WordPress core contributor
• GlotPress core developer
• Recent rockstar of 3.4
• Co author of WP_Image_Editor
WordCamp Sofia 2013
CodeKitchen
3. You want to build a
great plugin
WordCamp Sofia 2013
CodeKitchen
9. My setup
• Using Sublime Text editor
• Using Git as version control
• Open source projects on GitHub
• Private projects on an own VPS with GitLab
• Using Tower as a GUI for Git
• For WordPress.org it’s SVN and I use svnX
WordCamp Sofia 2013
CodeKitchen
15. Hooks is what makes
WordPress run
• Almost everything can be adjusted with a
hook
• Even WordPress core uses hooks a lot to
do adjustments
• Understanding them is then really
important
WordCamp Sofia 2013
CodeKitchen
22. And there are
so many more
http://codex.wordpress.org/WordPress_Coding_Standards
WordCamp Sofia 2013
CodeKitchen
23. Why is this important?
• Readability of the code
• Makes your code looks great
• Seeing mistakes more easier
• Using a standard makes collaboration easier
WordCamp Sofia 2013
CodeKitchen
27. Define structure
• Main file for initialization
• Use the plugin name as the main file name
• Rest of the files in folders
• OOP based / naming convention
• Folders like:
css, images, js, inc, lib, languages
WordCamp Sofia 2013
CodeKitchen
28. How does a main
plugin file look like
WordCamp Sofia 2013
CodeKitchen
29. !
!
!
!
<?php
/*
Plugin Name:
Plugin URI:
Description:
Author:
Version:
Author URI:
Text Domain:
Domain Path:
*/
Improved image editor
https://github.com/markoheijnen/Improved-image-editor
WordPress needs a better image editor UI so let this be it
Marko Heijnen
0.1
http://markoheijnen.com
improved-image-editor
/languages/
if ( ! defined( 'ABSPATH' ) ) {
header( 'Status: 403 Forbidden’ );
header( 'HTTP/1.1 403 Forbidden’ );
}
include 'inc/overwrite.php';
WordCamp Sofia 2013
CodeKitchen
33. I released a few plugins
on WordPress.org
WordCamp Sofia 2013
CodeKitchen
34. Tabify Edit Screen
• Enable tabs in the edit screen and manage
them from the back-end
• Cleans up the interface when you have lots
of metaboxes
• Manage it all from the WordPress back-end
WordCamp Sofia 2013
CodeKitchen
35. Biggest issue
• Plugins that don’t add meta boxes with
add_meta_boxes
• Only call the hook when on a certain page
• Mostly because of weird lazy loading or
combining that code with loading JS.
WordCamp Sofia 2013
CodeKitchen
42. What makes this a good plugin
• It’s an unique plugin that cares about UX
• No PHP notices that I know of
• Takes care if plugins fails to add meta boxes
correctly
• Some specific designs for color schemes
• It works decent for non JS
WordCamp Sofia 2013
CodeKitchen