SlideShare una empresa de Scribd logo
1 de 24
Descargar para leer sin conexión
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

Más contenido relacionado

La actualidad más candente

Using Git with WordPress - Presented by Nigel Rodgers.
Using Git with WordPress - Presented by Nigel Rodgers.Using Git with WordPress - Presented by Nigel Rodgers.
Using Git with WordPress - Presented by Nigel Rodgers.WordCamp Harare
 
How to outsource the pain of drupal translation to smartling from loparev
How to outsource the pain of drupal translation to smartling from loparevHow to outsource the pain of drupal translation to smartling from loparev
How to outsource the pain of drupal translation to smartling from loparevOleksii Bogush
 
Plugin Development for Beginners
Plugin Development for BeginnersPlugin Development for Beginners
Plugin Development for BeginnersJoe Cartonia
 
Moderne Android Builds mit Gradle
Moderne Android Builds mit GradleModerne Android Builds mit Gradle
Moderne Android Builds mit Gradleinovex GmbH
 
Going Global with WordPress Multilingual (WordCamp Denpasar 2016)
Going Global with WordPress Multilingual (WordCamp Denpasar 2016)Going Global with WordPress Multilingual (WordCamp Denpasar 2016)
Going Global with WordPress Multilingual (WordCamp Denpasar 2016)Dat Hoang
 
Don't Code, Bake. An introduction to CakePHP ~PHP Hampshire Oct 2014
Don't Code, Bake. An introduction to CakePHP ~PHP Hampshire Oct 2014Don't Code, Bake. An introduction to CakePHP ~PHP Hampshire Oct 2014
Don't Code, Bake. An introduction to CakePHP ~PHP Hampshire Oct 2014David Yell
 
Writing a Java Extension for LibreOffice with LOEclipse
Writing a Java Extension for LibreOffice with LOEclipseWriting a Java Extension for LibreOffice with LOEclipse
Writing a Java Extension for LibreOffice with LOEclipseSamuel Mehrbrodt
 
Efficient, Error-Free Drupal Development with JS Build Tools
Efficient, Error-Free Drupal Development with JS Build ToolsEfficient, Error-Free Drupal Development with JS Build Tools
Efficient, Error-Free Drupal Development with JS Build ToolsAcquia
 
Web development meetingup
Web development meetingupWeb development meetingup
Web development meetingupPiTechnologies
 
My Contributor Story
My Contributor StoryMy Contributor Story
My Contributor StoryMarko Heijnen
 
Github developing stack
Github developing stackGithub developing stack
Github developing stackVicente Bolea
 
Full-Stack Development
Full-Stack DevelopmentFull-Stack Development
Full-Stack DevelopmentDhilipsiva DS
 
Improving your code design using Java
Improving your code design using JavaImproving your code design using Java
Improving your code design using JavaRoan Brasil Monteiro
 
WordPress on the Jamstack by rtCamper Muhammad Muhsin @ WordPress Colombo Meetup
WordPress on the Jamstack by rtCamper Muhammad Muhsin @ WordPress Colombo MeetupWordPress on the Jamstack by rtCamper Muhammad Muhsin @ WordPress Colombo Meetup
WordPress on the Jamstack by rtCamper Muhammad Muhsin @ WordPress Colombo MeetuprtCamp
 
Overview of SharePoint Framework (SPFx)
Overview of SharePoint Framework (SPFx)Overview of SharePoint Framework (SPFx)
Overview of SharePoint Framework (SPFx)Małgorzata Borzęcka
 
Ppt full stack developer
Ppt full stack developerPpt full stack developer
Ppt full stack developerSudhirVarpe1
 

La actualidad más candente (20)

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

Similar a Bootstrapping your plugin

Efficient development workflows with composer
Efficient development workflows with composerEfficient development workflows with composer
Efficient development workflows with composernuppla
 
The Self-Service Developer - GOTOCon CPH
The Self-Service Developer - GOTOCon CPHThe Self-Service Developer - GOTOCon CPH
The Self-Service Developer - GOTOCon CPHLaszlo Fogas
 
Efficient development workflows with composer
Efficient development workflows with composerEfficient development workflows with composer
Efficient development workflows with composernuppla
 
Grunt - The JavaScript Task Runner
Grunt - The JavaScript Task RunnerGrunt - The JavaScript Task Runner
Grunt - The JavaScript Task RunnerMohammed Arif
 
Using PHP with IBM Bluemix
Using PHP with IBM BluemixUsing PHP with IBM Bluemix
Using PHP with IBM Bluemixvvaswani
 
Xdebug for Beginners
Xdebug for BeginnersXdebug for Beginners
Xdebug for BeginnersSean Prunka
 
Grunt js and WordPress
Grunt js and WordPressGrunt js and WordPress
Grunt js and WordPressWP Australia
 
ZendCon 2015 - DevOps for Small Teams
ZendCon 2015 - DevOps for Small TeamsZendCon 2015 - DevOps for Small Teams
ZendCon 2015 - DevOps for Small TeamsJoe Ferguson
 
How to Create the API Document from Real API and Localization
How to Create the API Document from Real API and Localization How to Create the API Document from Real API and Localization
How to Create the API Document from Real API and Localization Pronovix
 
Madison PHP 2015 - DevOps For Small Teams
Madison PHP 2015 - DevOps For Small TeamsMadison PHP 2015 - DevOps For Small Teams
Madison PHP 2015 - DevOps For Small TeamsJoe Ferguson
 
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud RunDesigning flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Runwesley chun
 
Stop making, start composing - Using Composer for Drupal development
Stop making, start composing - Using Composer for Drupal developmentStop making, start composing - Using Composer for Drupal development
Stop making, start composing - Using Composer for Drupal developmentkaspergarnaes
 
Drupal + composer = new love !?
Drupal + composer = new love !?Drupal + composer = new love !?
Drupal + composer = new love !?nuppla
 
Django Article V0
Django Article V0Django Article V0
Django Article V0Udi Bauman
 
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20Michael Lihs
 
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...Alexander Dean
 
Using Composer with Drupal and Drush
Using Composer with Drupal and DrushUsing Composer with Drupal and Drush
Using Composer with Drupal and DrushPantheon
 
Dependent things dependency management for apple sw - slideshare
Dependent things   dependency management for apple sw - slideshareDependent things   dependency management for apple sw - slideshare
Dependent things dependency management for apple sw - slideshareCavelle Benjamin
 

Similar a Bootstrapping your plugin (20)

Efficient development workflows with composer
Efficient development workflows with composerEfficient development workflows with composer
Efficient development workflows with composer
 
The Self-Service Developer - GOTOCon CPH
The Self-Service Developer - GOTOCon CPHThe Self-Service Developer - GOTOCon CPH
The Self-Service Developer - GOTOCon CPH
 
Efficient development workflows with composer
Efficient development workflows with composerEfficient development workflows with composer
Efficient development workflows with composer
 
Grunt - The JavaScript Task Runner
Grunt - The JavaScript Task RunnerGrunt - The JavaScript Task Runner
Grunt - The JavaScript Task Runner
 
Using PHP with IBM Bluemix
Using PHP with IBM BluemixUsing PHP with IBM Bluemix
Using PHP with IBM Bluemix
 
Xdebug for Beginners
Xdebug for BeginnersXdebug for Beginners
Xdebug for Beginners
 
Grunt js and WordPress
Grunt js and WordPressGrunt js and WordPress
Grunt js and WordPress
 
ZendCon 2015 - DevOps for Small Teams
ZendCon 2015 - DevOps for Small TeamsZendCon 2015 - DevOps for Small Teams
ZendCon 2015 - DevOps for Small Teams
 
How to Create the API Document from Real API and Localization
How to Create the API Document from Real API and Localization How to Create the API Document from Real API and Localization
How to Create the API Document from Real API and Localization
 
Madison PHP 2015 - DevOps For Small Teams
Madison PHP 2015 - DevOps For Small TeamsMadison PHP 2015 - DevOps For Small Teams
Madison PHP 2015 - DevOps For Small Teams
 
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud RunDesigning flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
Designing flexible apps deployable to App Engine, Cloud Functions, or Cloud Run
 
Stop making, start composing - Using Composer for Drupal development
Stop making, start composing - Using Composer for Drupal developmentStop making, start composing - Using Composer for Drupal development
Stop making, start composing - Using Composer for Drupal development
 
Drupal + composer = new love !?
Drupal + composer = new love !?Drupal + composer = new love !?
Drupal + composer = new love !?
 
Composer
ComposerComposer
Composer
 
Django Article V0
Django Article V0Django Article V0
Django Article V0
 
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
 
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...
From Zero to Hadoop: a tutorial for getting started writing Hadoop jobs on Am...
 
Javascript mynotes
Javascript mynotesJavascript mynotes
Javascript mynotes
 
Using Composer with Drupal and Drush
Using Composer with Drupal and DrushUsing Composer with Drupal and Drush
Using Composer with Drupal and Drush
 
Dependent things dependency management for apple sw - slideshare
Dependent things   dependency management for apple sw - slideshareDependent things   dependency management for apple sw - slideshare
Dependent things dependency management for apple sw - slideshare
 

Más de Marko Heijnen

Custom coded projects
Custom coded projectsCustom coded projects
Custom coded projectsMarko Heijnen
 
Security, more important than ever!
Security, more important than ever!Security, more important than ever!
Security, more important than ever!Marko Heijnen
 
WooCommerce & Apple TV
WooCommerce & Apple TVWooCommerce & Apple TV
WooCommerce & Apple TVMarko Heijnen
 
The moment my site got hacked - WordCamp Sofia
The moment my site got hacked - WordCamp SofiaThe moment my site got hacked - WordCamp Sofia
The moment my site got hacked - WordCamp SofiaMarko Heijnen
 
Mijn site beveiliging
Mijn site beveiligingMijn site beveiliging
Mijn site beveiligingMarko Heijnen
 
The moment my site got hacked
The moment my site got hackedThe moment my site got hacked
The moment my site got hackedMarko Heijnen
 
My complicated WordPress site
My complicated WordPress siteMy complicated WordPress site
My complicated WordPress siteMarko Heijnen
 
Node.js to the rescue
Node.js to the rescueNode.js to the rescue
Node.js to the rescueMarko Heijnen
 
Protecting your site by detection
Protecting your site by detectionProtecting your site by detection
Protecting your site by detectionMarko Heijnen
 
GlotPress aka translate.wordpress.org
GlotPress aka translate.wordpress.orgGlotPress aka translate.wordpress.org
GlotPress aka translate.wordpress.orgMarko Heijnen
 
Writing clean and maintainable code
Writing clean and maintainable codeWriting clean and maintainable code
Writing clean and maintainable codeMarko Heijnen
 
Extending WordPress as a pro
Extending WordPress as a proExtending WordPress as a pro
Extending WordPress as a proMarko Heijnen
 
Let's create a multilingual site in WordPress
Let's create a multilingual site in WordPressLet's create a multilingual site in WordPress
Let's create a multilingual site in WordPressMarko Heijnen
 
The development and future of GlotPress
The development and future of GlotPressThe development and future of GlotPress
The development and future of GlotPressMarko Heijnen
 
Why Javascript matters
Why Javascript mattersWhy Javascript matters
Why Javascript mattersMarko Heijnen
 
The code history of WordPress
The code history of WordPressThe code history of WordPress
The code history of WordPressMarko Heijnen
 
Perfect your images using WordPress - WordCamp Europe 2013
Perfect your images using WordPress - WordCamp Europe 2013Perfect your images using WordPress - WordCamp Europe 2013
Perfect your images using WordPress - WordCamp Europe 2013Marko Heijnen
 
The awesome things you can do with images inside WordPress
The awesome things you can do with images inside WordPressThe awesome things you can do with images inside WordPress
The awesome things you can do with images inside WordPressMarko Heijnen
 
De nieuwe media flow in WordPress en hoe verder
De nieuwe media flow in WordPress en hoe verderDe nieuwe media flow in WordPress en hoe verder
De nieuwe media flow in WordPress en hoe verderMarko Heijnen
 

Más de Marko Heijnen (20)

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

Último

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 

Último (20)

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

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