SlideShare a Scribd company logo
PLUGIN DEVELOPMENT
#wpmeetup010
BARRY KOOIJ
Twitter : @cageNL
Lead Developer WordPress @ INDICIA
Freelance @ Cageworks
Plugin developer
What The File
Sub Posts
Contributor EDD & extensies
Core contributor
Moderator WPNL forum
PLUGIN DEVELOPMENT
MIJN SETUP
Device
IDE
Versiebeheer

MacBook Air
PhpStorm
GIT, GitHub / private server
Commandline
ALTERNATIEVEN
IDE
GIT
SVN

NuSphere PhpED
Bitbucket, GitLab
Tower
Versions / Tortoise
DEBUGGIN
G
define( 'WP_DEBUG', true );
if ( WP_DEBUG ) {
define( 'SCRIPT_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', true );
@ini_set( 'display_errors', 0 );
}
display_errors = On;
error_reporting = E_ALL | E_STRICT;
CODE TEMPLATES
https://gist.github.com/barrykooij/7632945
WORDPRESS CORE
Open source, maak hier gebruik van!
API’s, API’S, API’s
Filters & Hooks
API’S
Dashboard Widgets API
Database API
HTTP API
File Header API
Filesystem API
Metadata API
Options API
Plugin API
Quicktags API

Rewrite API
Settings API
Shortcode API
Theme Modification API
Theme Customization API
Transients API
Widgets API
XML-RPC WordPress API
FILTERS & HOOKS
add_action( ‘hook_name’, ‘my_function’ );
do_action( ‘hook_name’ );
JS “HOOKS” (EVENTS)
$('body').bind(’event’, function(event,
the_value) {
});

$('body').trigger(’event', [ value ]);
BACKWARDS COMPATABILITY
Deprecate code
Pas later geen unit tests aan, maar voeg unit
tests toe
CODE STANDARDS
http://codex.wordpress.org/WordPress_Coding_Standards
NAMING CONVENTIONS
function some_name( $some_variable ) { [...] }
class Walker_Category extends Walker { [...] }
class WP_HTTP { [...] }
my-plugin-name.php
class-my-class.php
DATABASES
Gebruik altijd de API!
$wpdb->prepare
$wpdb->prepare( "SELECT * FROM {$wpdb>posts}" WHERE `ID` = %d", $special_id );
YODA CONDITIONS
if ( true == $the_force ) {
$victorious = you_will( $be );
}
A little bizarre, it is, to read. Get used to it, you will.
UNIT TESTING
PHPUnit
/**
* @ticket 22212
*/
function test_get_multiple_roles_by_user_query() {
$this->factory->user->create_many( 2, array( 'role' => 'subscriber’ ) );
$this->factory->user->create_many( 3, array( 'role' => 'editor’ ) );
$wp_user_search = new WP_User_Query( array( 'role' => array( 'subscriber’,
'editor' ) ) );
$users = $wp_user_search->get_results();
$this->assertEquals( 5, count( $users ) );
}
CHANGELOG
Hou bij wat je wanneer veranderd hebt
SUPPORT
Als je iets bouwt, support het dan
Geef op je website je support tijden aan
Support systemen
WORDPRESS.ORG REPO
Header afbeelding
Duidelijk omschrijving
Downloads i.c.m. rating
Vraag om ratings!
Plugin development wpmeetup010
CONDITIONAL LOADING OF CODE
Laad code enkel waar nodig
is_admin()
DOCUMENTATION
Schrijf je code doc direct
Betere IDE suggesties
CODE
OBJECTGEORIËNTEERD
OOP
Singleton pattern
class My_Plugin {
private static $instance = null;
public static function get() {
if( null == self::$instance ) {
self::$instance = new self();
}
return self::$instance;
}

private function __construct() {
}
}
function My_Plugin() {
return My_Plugin::get();
}
add_action( 'plugins_loaded', function() {My_Plugin::get(); });
PLUGIN DIR & FILE
if ( ! defined( ’X_PLUGIN_DIR' ) ) {
define( 'X_PLUGIN_DIR’, plugin_dir_path( __FILE__ ) );
}
if ( ! defined( ’X_PLUGIN_FILE' ) ) {
define( ’X_PLUGIN_FILE', __FILE__ );
}
PREFIXES
WordPress : PHP version 5.2.4 or greater
Namespaces : 5.3.0 or greater
Tot die tijd, prefixen.

class SP_Post_Link_Manager { [...] }
SANITIZE & ESCAPE
sanitize_title
is_email
http://codex.wordpress.org/Data_Validation#In
put_Validation
esc_url
esc_html
CAPABILITIES
if ( ! current_user_can( SP_Cap_Manager::get_capability(
$_GET['sp_post_link'] ) ) ) {
return;
}
NONCES
Number used ONCE
wp_nonce_field( plugin_basename( __FILE__ ),
'sp_sortable_nonce' );

if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce(
$_POST['nonce'], plugin_basename( __FILE__ ) ) ) {
return;
}
DIRECT ACCESS
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if
accessed directly
I18N
load_plugin_textdomain( 'sub-posts', false,
dirname( plugin_basename( __FILE__ ) ) .
'/languages/' );

_e( ‘my-string’, ‘sub-posts’ );
Q&
A
Twitter @cageNL
WordPress & Github: barrykooij
7 januari meetup in Tilburg

More Related Content

What's hot (20)

PDF
WordPress Realtime - WordCamp São Paulo 2015
Fernando Daciuk
 
PPT
WordPress Plugin Basics
Amanda Giles
 
PDF
Python Flask app deployed to OPenShift using Wercker CI
Bruno Rocha
 
PPTX
Code ceptioninstallation
Andrii Lagovskiy
 
PDF
Django cms best practices
Iacopo Spalletti
 
PDF
워드프레스 플러그인 개발 입문
Donghyeok Kang
 
PDF
What The Flask? and how to use it with some Google APIs
Bruno Rocha
 
PDF
Ane for 9ria_cn
sonicxs
 
PPTX
Eclipse Overview
Lars Vogel
 
ODP
The Future Of WordPress Presentation
Dougal Campbell
 
PDF
JavaScript, React Native and Performance at react-europe 2016
Tadeu Zagallo
 
PPTX
Webinar: AngularJS and the WordPress REST API
WP Engine UK
 
PDF
A Simple Plugin Architecture for Wicket
nielsvk
 
PDF
Introduction to VueJS & The WordPress REST API
Caldera Labs
 
KEY
Plugin Development Practices
danpastori
 
PDF
First steps with django cms
Iacopo Spalletti
 
KEY
WordPress Bootcamp Part 2 - Extending WordPress
Metronet
 
PDF
Behaviour Driven Development con Behat & Drupal
sparkfabrik
 
PDF
WPtech: L'API Customizer pour les plugins
corsonr
 
PDF
Build website in_django
swee meng ng
 
WordPress Realtime - WordCamp São Paulo 2015
Fernando Daciuk
 
WordPress Plugin Basics
Amanda Giles
 
Python Flask app deployed to OPenShift using Wercker CI
Bruno Rocha
 
Code ceptioninstallation
Andrii Lagovskiy
 
Django cms best practices
Iacopo Spalletti
 
워드프레스 플러그인 개발 입문
Donghyeok Kang
 
What The Flask? and how to use it with some Google APIs
Bruno Rocha
 
Ane for 9ria_cn
sonicxs
 
Eclipse Overview
Lars Vogel
 
The Future Of WordPress Presentation
Dougal Campbell
 
JavaScript, React Native and Performance at react-europe 2016
Tadeu Zagallo
 
Webinar: AngularJS and the WordPress REST API
WP Engine UK
 
A Simple Plugin Architecture for Wicket
nielsvk
 
Introduction to VueJS & The WordPress REST API
Caldera Labs
 
Plugin Development Practices
danpastori
 
First steps with django cms
Iacopo Spalletti
 
WordPress Bootcamp Part 2 - Extending WordPress
Metronet
 
Behaviour Driven Development con Behat & Drupal
sparkfabrik
 
WPtech: L'API Customizer pour les plugins
corsonr
 
Build website in_django
swee meng ng
 

Viewers also liked (6)

PDF
Unit testing @ WordPress Meetup Tilburg 7 januari 2014
Barry Kooij
 
PPTX
Cmat 101 final project
cmat101clubs
 
PPTX
CMAT 101 Clubs
cmat101clubs
 
PDF
Logosweldproducts
Logos Weld Products, Coimbatore
 
PDF
Related Content
Barry Kooij
 
PPTX
Cmat 101 final project
cmat101clubs
 
Unit testing @ WordPress Meetup Tilburg 7 januari 2014
Barry Kooij
 
Cmat 101 final project
cmat101clubs
 
CMAT 101 Clubs
cmat101clubs
 
Related Content
Barry Kooij
 
Cmat 101 final project
cmat101clubs
 
Ad

More from Barry Kooij (7)

PDF
Plugin Development - WP Meetup Antwerp
Barry Kooij
 
PDF
Unit Testing in WordPress
Barry Kooij
 
PDF
We Will VAT You
Barry Kooij
 
PDF
Customizing Your WooCommerce Store
Barry Kooij
 
PDF
Automating your releases with shell scripts - WordCamp Netherlands 2014
Barry Kooij
 
PDF
Plugin Development @ WordCamp Norway 2014
Barry Kooij
 
PPTX
WordPress pizza sessie
Barry Kooij
 
Plugin Development - WP Meetup Antwerp
Barry Kooij
 
Unit Testing in WordPress
Barry Kooij
 
We Will VAT You
Barry Kooij
 
Customizing Your WooCommerce Store
Barry Kooij
 
Automating your releases with shell scripts - WordCamp Netherlands 2014
Barry Kooij
 
Plugin Development @ WordCamp Norway 2014
Barry Kooij
 
WordPress pizza sessie
Barry Kooij
 
Ad

Recently uploaded (20)

PPTX
Simple and concise overview about Quantum computing..pptx
mughal641
 
PDF
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
PPTX
Agile Chennai 18-19 July 2025 | Workshop - Enhancing Agile Collaboration with...
AgileNetwork
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PDF
RAT Builders - How to Catch Them All [DeepSec 2024]
malmoeb
 
PDF
Market Insight : ETH Dominance Returns
CIFDAQ
 
PDF
Generative AI vs Predictive AI-The Ultimate Comparison Guide
Lily Clark
 
PDF
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
PDF
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PDF
State-Dependent Conformal Perception Bounds for Neuro-Symbolic Verification
Ivan Ruchkin
 
PPTX
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
PDF
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PPTX
The Future of AI & Machine Learning.pptx
pritsen4700
 
PDF
introduction to computer hardware and sofeware
chauhanshraddha2007
 
PPTX
Farrell_Programming Logic and Design slides_10e_ch02_PowerPoint.pptx
bashnahara11
 
PDF
NewMind AI Weekly Chronicles – July’25, Week III
NewMind AI
 
PPTX
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
Simple and concise overview about Quantum computing..pptx
mughal641
 
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
Agile Chennai 18-19 July 2025 | Workshop - Enhancing Agile Collaboration with...
AgileNetwork
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
RAT Builders - How to Catch Them All [DeepSec 2024]
malmoeb
 
Market Insight : ETH Dominance Returns
CIFDAQ
 
Generative AI vs Predictive AI-The Ultimate Comparison Guide
Lily Clark
 
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
State-Dependent Conformal Perception Bounds for Neuro-Symbolic Verification
Ivan Ruchkin
 
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
Peak of Data & AI Encore - Real-Time Insights & Scalable Editing with ArcGIS
Safe Software
 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
The Future of AI & Machine Learning.pptx
pritsen4700
 
introduction to computer hardware and sofeware
chauhanshraddha2007
 
Farrell_Programming Logic and Design slides_10e_ch02_PowerPoint.pptx
bashnahara11
 
NewMind AI Weekly Chronicles – July’25, Week III
NewMind AI
 
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 

Plugin development wpmeetup010

Editor's Notes

  • #9: Naastdocumentatiekan je dusook in je eigen IDE vaakdoorklikkennaar de bron