Symfony Live San Franciso 2017 - BDD API Development with Symfony and Behat
WordPress Plugin Development
1.
2. Who Am I?
Developer/Evangelist at LaunchKey
Organizer of Las Vegas Python User Group
Founder/Co-Organizer of Las Vegas PHP UG
Co-Organizer of Las Vegas Developer UG
National Junior Basketball Coach
3. WordPress Overview
• Open Source CMS
• First released in 2003
• 24.1% of all websites as of July 2015*
• 60.2% CMS market share as of July 2015*
• Over 38,000 Plugins with nearly 1 billion total
downloads
* W3Techs Usage statistics and market share of WordPress for websites
4. WordPress Extensibility
Theme system for user interface
Plugin system for add and/or customizing
functionality
Event system for triggering events
Filter system for adding or modifying content
7. Plugin Development
Know what is required of your plugin:
https://codex.wordpress.org/Plugin_Submission_and_Promotion
Follow Plugin Development suggestions
User built in internationalization
Be prepared for some archaic nonsense
Steal from popular plugins for ideas on
implementation and less than obvious tricks
8. MVC Lessons
Use view files to separate that from your event methods
Make sure to use translations
If you need to persist options, use a single option with
filters to validate and sanitize the data. Do not circumvent
the system.
If you have complex configuration, make a simple
controller to manage flow.
Use plugins_url to determine location of files
9. JavaScript
JQuery included – Check your version
wp_enqueue_script
Add scripts to the HEAD or bottom of BODY
Allows for dependencies determining load order
Use version for cache busting
wp_localize_script
Configure data to be used by your plugin
11. Plugin Structure
Use plugin base file for bootstrapping
Provide uninstall.php file to allow clean removal
Give each directory a blank index.php to prevent
directory browsing
If you have static assets, use a separate directory for
those files
12. Dependencies
Prefer WordPress provided functionality over
external libraries
Reduces the size of your plugin
Better interoperability with other plugins
Works on nearly every installation
No built in solution for external dependencies
13. Using Composer
Use a build system to not include extraneous files
like tests and docs in your plugin
Load the autoloader in the plugin root file
Use only what is required
14. Unit Testing
Separate your code into classes
Dependency injection happens in the root file
Create a façade for global functions. WordPress is ALL
global functions.
You may need to write some Output Buffer wrapping
methods in the façade. WordPress loves to echo and
error_log directly.
Test PHP 5.3 – 7.0 and HHVM
15. Integration Testing
Test as many versions as possible
Manual and automated testing
Docker Container for automated testing:
https://github.com/LaunchKey/docker-wordpress