Marko Heijnen discussed several ways to extend WordPress, including hooks, drop-ins, pluggable functions, and pluggable classes. He demonstrated wpcentral.io, which collects WordPress usage data, and opensesh.org, a conference platform built with Node.js. He explained how to build extensions for the future by future-proofing code and looking at new technologies like Node.js.
2. MARKO HEIJNEN
⢠Founder  of  CodeKitchen Â
⢠Working  for  1&1 Â
⢠Lead  developer  of  GlotPress Â
⢠Core  contributor  for  WordPress Â
⢠Plugin  developer Â
⢠Organizer  for  WordCamp  Belgradeâ¨
http://2015.belgrade.wordcamp.org/
WORDPRESS DEVELOPER
The Netherlands
3. TODAYâSâ¨
TOPICS
⢠Current ways to extend WordPress
⢠Expect the unexpectable
⢠Demo wpcentral.io
⢠Build for the future
⢠Look at new technologies
⢠Demo opensesh.org
⢠Questions
5. HOOKS
⢠Hooks are a way for one piece of code to interact
with and modify another piece of code. They make
up the foundation for how plugins and themes
interact with WordPress Core, but theyâre also
used extensively by Core itself
⢠Two types of hooks: Actions and Filters
7. PLUGGABLE FUNCTIONS
⢠These functions let you override certain core
functions via plugins
⢠Pluggable functions are no longer being added to
WordPress core
⢠All new functions instead use filters on their output
to allow for similar overriding of their functionality
⢠See http://codex.wordpress.org/Pluggable_Functions
8. PLUGGABLE CLASSES
⢠Using a filter to replace the class that should be
loaded like session_token_manager
⢠Be able to add your class to be loaded like
wp_image_editors filter
10. WP CENTRALâ¨
WHAT IS IT?
⢠Showing download history
⢠Showing version usage history
⢠List all locales and their current state
⢠Showing contributors data (currently API only)
⢠Collects history of locale progress
15. WP CENTRALâ¨
HOW IT WORKS
⢠A lot of data handling by wp_remote_get
⢠Scrapping profiles.WordPress.org to read data
⢠Bugs
⢠Storing 0 values
⢠Storing invalid data after failed wp_remote_get
requests
⢠Not checking HTML output fromâ¨
DOMDocument / DomXPath
16. WP CENTRAL
CACHING STRATEGY
⢠Expensive query result caching
⢠Cron job to retrieve download counts and version
usage
⢠24 hour cache per locale on request with a max of
5 locales per time
⢠Using WP CLI to run it command line
⢠Creating contributor data on request of the API
18. BUILD FOR THE FUTURE
⢠When writing code, keep the changes you want to
make in mind
⢠Future proofing is making sure you can easily add
code/features without breaking existing
functionality
⢠Make the code robust against unexpected problem
situations allowing for graceful recovery or fail-fast,
but do not write code for possible future uses.
21. NODE.JS
NODEJS.ORG
⢠JavaScript platform
⢠Uses an event-driven, non-blocking I/O model
⢠Lightweight and eďŹcient
⢠Ideal for real time application
⢠Lotâs of modules you can use
⢠Manage with NPM - https://www.npmjs.org
23. OPENSESH.ORG
⢠A platform for conferences like WordSesh
⢠Community driven project for the open source community
⢠Node.js lets you push new sessions
⢠This with the help of Socket.IO
⢠When the session is over, you can simply replace it
⢠Be able to use YouTube ďŹles as wait music
⢠Possible other ideas:
⢠Create a hangout through WordPress
⢠Have a personal schedule
27. CONNECTING TO WORDPRESS
⢠Node.js checks cookie data to indicate if user is logged in
⢠Validates over JSON API and retrieve more user data
⢠Returns a WP_User object
⢠Has basic capability check support
29. SERVER HANDLER (PART 1)
function handler(req, res) {
if (req.url == "/status") {
res.writeHead( 200 );
res.end();
return;
}
var wp_user = wordpress.connect( req.headers.cookie, req.headers['x-token'] );
if ( wp_user ) { // More code to come }
res.end();
}