SlideShare a Scribd company logo
BOOTSTRAPPING
YOUR PLUGIN
Marko Heijnen

WordCamp NYC 2014
MARKO HEIJNEN
•Founder  of  CodeKitchen  
•Work  for  1&1  
•Lead  developer  of  GlotPress  
•Core  contributor  for  WordPress
WORDPRESS DEVELOPER
The Netherlands
TODAY’S

TOPICS
• Features of a plugin

• Setting up your plugin

• Automation of your tasks
THE START
You have a great idea and want to build it. You first start by
writing what it should do and plan ahead.
IN
TERN
ATIO
N
ALIZATIO
N
C
SS
/JAVASC
RIPT
VERSIO
N
C
O
N
TRO
L
C
O
M
PILIN
G
LESS/SASS
C
O
N
C
ATEN
ATE
JSH
IN
T
PH
PU
N
IT
/Q
U
N
IT
C
O
M
PRESS
PLU
G
IN
H
EADERS
&
READM
E
BU
ILD
PRO
C
ESS
M
IN
IFIC
ATIO
N
EAC
E
DESIG
N
LO
C
ALIZATIO
N
KEEP
U
P
TO
DATE
LO
G
O
TY
REQUIREMENTS
OF A PLUGIN
SETTING UP
YOUR PLUGIN
DO IT YOUR SELF
Doing the same things again, over and over
MAIN FILE
<?php
/*
Plugin Name: Tabify edit screen
Plugin URI: http://rocksta.rs/plugin/tabify-edit-
screen
Description: Enables tabs in the edit screen and
manage them from the back-end
Author: Marko Heijnen
Text Domain: tabify-edit-screen
Version: 0.8.3
Author URI: http://markoheijnen.com
*/
USE A SCAFFOLD
wp  scaffold  plugin  my-­‐cool-­‐plugin  
!
[--plugin_name=<title>]

What to put in the ‘Plugin Name:’ header

[--skip-tests]

Don’t generate files for unit testing.

[--activate]

Activate the newly generated plugin.
AND YOU WRITE
YOUR PLUGIN
But creating your plugin isn’t all about the code. It also mean
maintenance of it.
SETTING UP
YOUR UNIT TESTS
wp  scaffold  plugin-­‐tests  
• phpunit.xml is the configuration file for
PHPUnit

• .travis.yml is the configuration file for
Travis CI

• tests/bootstrap.php is the file that makes
the current plugin active when running the
test suite

• tests/test-sample.php is a sample file
containing the actual tests
11
SETTING UP
YOUR UNIT TESTS
My  basic  tests  are:  
• test_tested_up_to

• test_stable_tag

• test_package_json
12
h>ps://github.com/markoheijnen/tabify-­‐edit-­‐screen/blob/master/tests/test-­‐plugin.php
AUTOMATION OF
YOUR TASKS
YOUR NORMALLY

TASKS
• Minify CSS/JS

• Compress CSS/JS/Images

• Concatenate CSS/JS

• Validate JS

• Create new pot file

• Download translations

• Unit test

• Deploy
GRUNT
•Running  tasks  by  using  CLI  
•Easy  to  use,  harder  to  configure  
•Extendable  with  your  own  plugins  
•Uses  npm  for  plugin  management  
THE JAVASCRIPT TASK RUNNER
http://gruntjs.com
THE BASIC SETUP
A typical setup will involve adding two
files to your project: package.json and
the Gruntfile

• package.json

This file is used by npm to store
metadata for projects published as
npm modules. You will list grunt and
the Grunt plugins your project needs
as devDependencies in this file.

• Gruntfile

Is used to configure or define tasks
and load Grunt plugins.
PACKAGE.JSON
{

	 "name": "tabify-edit-screen",

	 "version": "0.8.3",

	 "description": "Enables tabs in the edit screen and manage them from the back-end",

	 "repository": { "type": “git", "url": “https://github.com/markoheijnen/tabify-edit-screen.git" },

	 "author": "Marko Heijnen",

	 "license": "GPLv2 or later",

	 "devDependencies": {

	 	 "grunt": "~0.4.5",

	 	 "grunt-contrib-clean": "~0.5.0",

	 	 "grunt-contrib-copy": "~0.5.0",

	 	 "grunt-contrib-cssmin": "~0.10.0",

	 	 "grunt-contrib-uglify": "~0.5.0",

	 	 "grunt-glotpress": "~0.1.0",

	 	 "grunt-wp-i18n": "~0.4.6"

	 }

}
INSTALLING DEPENDENCIES
• npm install

• This will install all plugins inside
node_modules
GRUNTFILE.JS
module.exports = function(grunt) {

	 grunt.initConfig({

	 	 

	 });

};
WHICH I’M USING
Copy  files  and  folders. Compress  CSS  files.
InternaPonalize  
WordPress  themes  and  
plugins
Gets  translaPons  from  a  
GlotPress  installaPon
Clean  files  and  folders.
Minify  javascript  files  
with  UglifyJS.
GRUNT-CONTRIB-CLEAN GRUNT-CONTRIB-COPY GRUNT-CONTRIB-CSSMIN
GRUNT-CONTRIB-UGLIFY GRUNT-WP-I18N GRUNT-GLOTPRESS
CREATING POT FILE
grunt.initConfig({

	 makepot: {

	 	 core: {

	 	 	 options: {

	 	 	 	 domainPath: '/languages',

	 	 	 	 type: 'wp-plugin',

	 	 	 }

	 	 }

	 },

});

!
grunt.loadNpmTasks(‘grunt-wp-i18n’);

!
grunt.registerTask('default', ['makepot:core']);
DOWNLOADING TRANSLATIONS
grunt.initConfig({

	 glotpress_download: {

	 	 core: {

	 	 	 options: {

	 	 	 	 domainPath: 'languages',

	 	 	 	 url: 'http://wp-translate.org',

	 	 	 	 slug: 'tabify-edit-screen',

	 	 	 	 textdomain: 'tabify-edit-screen'

	 	 	 }

	 	 }

	 },

});

!
grunt.registerTask('default', [‘glotpress_download:core']);
OTHER COOL PLUGINS
Minify  GIF,  JPEG,  PNG  
and  SVG  images
Run  QUnit  unit  tests  in  a  
headless  PhantomJS  
instance.
Compile  Sass  to  CSS Deploys  a  git  Repo  to  
the  WordPress  SVN  repo
Validate  files  with  
JSHint.
Run  predefined  tasks  
whenever  watched  file  
pa>erns  are  added,  
changed  or  deleted.
GRUNT-CONTRIB-JSHINT GRUNT-CONTRIB-IMAGEMIN GRUNT-CONTRIB-QUNIT
GRUNT-CONTRIB-WATCH GRUNT-SASS GRUNT-WP-DEPLOY
THANKS

QUESTIONS?

@markoheijnen - markoheijnen.com

More Related Content

PDF
Building plugins like a pro
ODP
How I built web services in CakePHP
ODP
PHP Berkshire October 2015
PDF
Django Deployer
PPTX
Building End to-End Web Apps Using TypeScript
PPTX
HTML5 for dummies
PDF
VersionPress - WordPress + Git
PDF
Front-End Modernization for Mortals
Building plugins like a pro
How I built web services in CakePHP
PHP Berkshire October 2015
Django Deployer
Building End to-End Web Apps Using TypeScript
HTML5 for dummies
VersionPress - WordPress + Git
Front-End Modernization for Mortals

What's hot (20)

PPTX
Using Git with WordPress - Presented by Nigel Rodgers.
PPTX
How to outsource the pain of drupal translation to smartling from loparev
PDF
Plugin Development for Beginners
ODP
OpenNTF Essentials
PDF
Moderne Android Builds mit Gradle
PDF
Going Global with WordPress Multilingual (WordCamp Denpasar 2016)
ODP
Don't Code, Bake. An introduction to CakePHP ~PHP Hampshire Oct 2014
ODP
Writing a Java Extension for LibreOffice with LOEclipse
PPTX
Meetup gitbook
PPT
MVP with GWT and GWTP
PDF
Efficient, Error-Free Drupal Development with JS Build Tools
PDF
Web development meetingup
PDF
My Contributor Story
PPTX
Github developing stack
PDF
Full-Stack Development
PDF
Improving your code design using Java
PDF
WordPress on the Jamstack by rtCamper Muhammad Muhsin @ WordPress Colombo Meetup
PPTX
Overview of SharePoint Framework (SPFx)
PDF
SydJS.com
PPTX
Ppt full stack developer
Using Git with WordPress - Presented by Nigel Rodgers.
How to outsource the pain of drupal translation to smartling from loparev
Plugin Development for Beginners
OpenNTF Essentials
Moderne Android Builds mit Gradle
Going Global with WordPress Multilingual (WordCamp Denpasar 2016)
Don't Code, Bake. An introduction to CakePHP ~PHP Hampshire Oct 2014
Writing a Java Extension for LibreOffice with LOEclipse
Meetup gitbook
MVP with GWT and GWTP
Efficient, Error-Free Drupal Development with JS Build Tools
Web development meetingup
My Contributor Story
Github developing stack
Full-Stack Development
Improving your code design using Java
WordPress on the Jamstack by rtCamper Muhammad Muhsin @ WordPress Colombo Meetup
Overview of SharePoint Framework (SPFx)
SydJS.com
Ppt full stack developer
Ad

Similar to Bootstrapping your plugin (20)

PDF
Efficient development workflows with composer
PDF
The Self-Service Developer - GOTOCon CPH
PDF
Efficient development workflows with composer
PPTX
Grunt - The JavaScript Task Runner
ODP
Using PHP with IBM Bluemix
ODP
Xdebug for Beginners
PDF
Grunt js and WordPress
PDF
ZendCon 2015 - DevOps for Small Teams
PDF
How to Create the API Document from Real API and Localization
PDF
Madison PHP 2015 - DevOps For Small Teams
PDF
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
PDF
Stop making, start composing - Using Composer for Drupal development
PDF
Drupal + composer = new love !?
PPTX
Diploma 1st Year Project Internship Presentation.pptx
PDF
Django Article V0
PDF
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
PPTX
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...
PPTX
Javascript mynotes
PDF
Using Composer with Drupal and Drush
Efficient development workflows with composer
The Self-Service Developer - GOTOCon CPH
Efficient development workflows with composer
Grunt - The JavaScript Task Runner
Using PHP with IBM Bluemix
Xdebug for Beginners
Grunt js and WordPress
ZendCon 2015 - DevOps for Small Teams
How to Create the API Document from Real API and Localization
Madison PHP 2015 - DevOps For Small Teams
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
Stop making, start composing - Using Composer for Drupal development
Drupal + composer = new love !?
Diploma 1st Year Project Internship Presentation.pptx
Django Article V0
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...
Javascript mynotes
Using Composer with Drupal and Drush
Ad

More from Marko Heijnen (20)

PDF
Custom coded projects
PDF
Security, more important than ever!
PDF
WooCommerce & Apple TV
PDF
The moment my site got hacked - WordCamp Sofia
PDF
Mijn site beveiliging
PDF
The moment my site got hacked
PDF
My complicated WordPress site
PDF
Node.js to the rescue
PDF
Protecting your site by detection
PDF
GlotPress aka translate.wordpress.org
PDF
Writing clean and maintainable code
PDF
Extending WordPress as a pro
PDF
Let's create a multilingual site in WordPress
PDF
The development and future of GlotPress
PDF
Why Javascript matters
PDF
The code history of WordPress
PDF
Perfect your images using WordPress - WordCamp Europe 2013
PDF
Dealing with media
PDF
The awesome things you can do with images inside WordPress
PDF
De nieuwe media flow in WordPress en hoe verder
Custom coded projects
Security, more important than ever!
WooCommerce & Apple TV
The moment my site got hacked - WordCamp Sofia
Mijn site beveiliging
The moment my site got hacked
My complicated WordPress site
Node.js to the rescue
Protecting your site by detection
GlotPress aka translate.wordpress.org
Writing clean and maintainable code
Extending WordPress as a pro
Let's create a multilingual site in WordPress
The development and future of GlotPress
Why Javascript matters
The code history of WordPress
Perfect your images using WordPress - WordCamp Europe 2013
Dealing with media
The awesome things you can do with images inside WordPress
De nieuwe media flow in WordPress en hoe verder

Recently uploaded (20)

PDF
Encapsulation theory and applications.pdf
PPTX
Machine Learning_overview_presentation.pptx
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Empathic Computing: Creating Shared Understanding
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PDF
Machine learning based COVID-19 study performance prediction
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
1. Introduction to Computer Programming.pptx
PDF
MIND Revenue Release Quarter 2 2025 Press Release
Encapsulation theory and applications.pdf
Machine Learning_overview_presentation.pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Empathic Computing: Creating Shared Understanding
Advanced methodologies resolving dimensionality complications for autism neur...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Spectral efficient network and resource selection model in 5G networks
Diabetes mellitus diagnosis method based random forest with bat algorithm
Assigned Numbers - 2025 - Bluetooth® Document
gpt5_lecture_notes_comprehensive_20250812015547.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
20250228 LYD VKU AI Blended-Learning.pptx
Programs and apps: productivity, graphics, security and other tools
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Machine learning based COVID-19 study performance prediction
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Mobile App Security Testing_ A Comprehensive Guide.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
1. Introduction to Computer Programming.pptx
MIND Revenue Release Quarter 2 2025 Press Release

Bootstrapping your plugin

  • 2. MARKO HEIJNEN •Founder  of  CodeKitchen   •Work  for  1&1   •Lead  developer  of  GlotPress   •Core  contributor  for  WordPress WORDPRESS DEVELOPER The Netherlands
  • 3. TODAY’S
 TOPICS • Features of a plugin • Setting up your plugin • Automation of your tasks
  • 4. THE START You have a great idea and want to build it. You first start by writing what it should do and plan ahead.
  • 7. DO IT YOUR SELF Doing the same things again, over and over
  • 8. MAIN FILE <?php /* Plugin Name: Tabify edit screen Plugin URI: http://rocksta.rs/plugin/tabify-edit- screen Description: Enables tabs in the edit screen and manage them from the back-end Author: Marko Heijnen Text Domain: tabify-edit-screen Version: 0.8.3 Author URI: http://markoheijnen.com */
  • 9. USE A SCAFFOLD wp  scaffold  plugin  my-­‐cool-­‐plugin   ! [--plugin_name=<title>] What to put in the ‘Plugin Name:’ header [--skip-tests] Don’t generate files for unit testing. [--activate] Activate the newly generated plugin.
  • 10. AND YOU WRITE YOUR PLUGIN But creating your plugin isn’t all about the code. It also mean maintenance of it.
  • 11. SETTING UP YOUR UNIT TESTS wp  scaffold  plugin-­‐tests   • phpunit.xml is the configuration file for PHPUnit • .travis.yml is the configuration file for Travis CI • tests/bootstrap.php is the file that makes the current plugin active when running the test suite • tests/test-sample.php is a sample file containing the actual tests 11
  • 12. SETTING UP YOUR UNIT TESTS My  basic  tests  are:   • test_tested_up_to • test_stable_tag • test_package_json 12 h>ps://github.com/markoheijnen/tabify-­‐edit-­‐screen/blob/master/tests/test-­‐plugin.php
  • 14. YOUR NORMALLY
 TASKS • Minify CSS/JS • Compress CSS/JS/Images • Concatenate CSS/JS • Validate JS • Create new pot file • Download translations • Unit test • Deploy
  • 15. GRUNT •Running  tasks  by  using  CLI   •Easy  to  use,  harder  to  configure   •Extendable  with  your  own  plugins   •Uses  npm  for  plugin  management   THE JAVASCRIPT TASK RUNNER http://gruntjs.com
  • 16. THE BASIC SETUP A typical setup will involve adding two files to your project: package.json and the Gruntfile
 • package.json
 This file is used by npm to store metadata for projects published as npm modules. You will list grunt and the Grunt plugins your project needs as devDependencies in this file. • Gruntfile
 Is used to configure or define tasks and load Grunt plugins.
  • 17. PACKAGE.JSON { "name": "tabify-edit-screen", "version": "0.8.3", "description": "Enables tabs in the edit screen and manage them from the back-end", "repository": { "type": “git", "url": “https://github.com/markoheijnen/tabify-edit-screen.git" }, "author": "Marko Heijnen", "license": "GPLv2 or later", "devDependencies": { "grunt": "~0.4.5", "grunt-contrib-clean": "~0.5.0", "grunt-contrib-copy": "~0.5.0", "grunt-contrib-cssmin": "~0.10.0", "grunt-contrib-uglify": "~0.5.0", "grunt-glotpress": "~0.1.0", "grunt-wp-i18n": "~0.4.6" } }
  • 18. INSTALLING DEPENDENCIES • npm install • This will install all plugins inside node_modules
  • 19. GRUNTFILE.JS module.exports = function(grunt) { grunt.initConfig({ }); };
  • 20. WHICH I’M USING Copy  files  and  folders. Compress  CSS  files. InternaPonalize   WordPress  themes  and   plugins Gets  translaPons  from  a   GlotPress  installaPon Clean  files  and  folders. Minify  javascript  files   with  UglifyJS. GRUNT-CONTRIB-CLEAN GRUNT-CONTRIB-COPY GRUNT-CONTRIB-CSSMIN GRUNT-CONTRIB-UGLIFY GRUNT-WP-I18N GRUNT-GLOTPRESS
  • 21. CREATING POT FILE grunt.initConfig({ makepot: { core: { options: { domainPath: '/languages', type: 'wp-plugin', } } }, }); ! grunt.loadNpmTasks(‘grunt-wp-i18n’); ! grunt.registerTask('default', ['makepot:core']);
  • 22. DOWNLOADING TRANSLATIONS grunt.initConfig({ glotpress_download: { core: { options: { domainPath: 'languages', url: 'http://wp-translate.org', slug: 'tabify-edit-screen', textdomain: 'tabify-edit-screen' } } }, }); ! grunt.registerTask('default', [‘glotpress_download:core']);
  • 23. OTHER COOL PLUGINS Minify  GIF,  JPEG,  PNG   and  SVG  images Run  QUnit  unit  tests  in  a   headless  PhantomJS   instance. Compile  Sass  to  CSS Deploys  a  git  Repo  to   the  WordPress  SVN  repo Validate  files  with   JSHint. Run  predefined  tasks   whenever  watched  file   pa>erns  are  added,   changed  or  deleted. GRUNT-CONTRIB-JSHINT GRUNT-CONTRIB-IMAGEMIN GRUNT-CONTRIB-QUNIT GRUNT-CONTRIB-WATCH GRUNT-SASS GRUNT-WP-DEPLOY