SlideShare a Scribd company logo
an easy start guide for
Plugin Development
WordPress Meet-up!
on 2014/05/29!
in Bangkok, Thailand!
by Shinichi Nishikawa
about Me
❖ ผมชื่อชิน (Shinichi Nishikawa)!
❖ อยู่ที่กรุงเทพฯปีครึ่ง

Lived in Bangkok for half a year!
❖ สร้าง themes และ plugin ให้ลูกค้า

Building themes and plugins for customers!
❖ ผมชอบเขียนบล็อก เขียนหนังสือเกี่ยวกับ WordPress และจัด
WordPress Events ที่ญี่ปุ่นด้วย.

I write blogs with WP, I write books of WP, I ran WP events
Challenge
❖ ผมจะสอนวิธีทำpluginอย่างง่าย

I will try to explain how to make plugins as easy as
possible.!
❖ หากคุณมีคำถาม คุณถามได้ทุกเวลา

Don’t hesitate to ask questions any time!!
❖ คุณสามารถดาวน์โหลด presentation และ codesนี้ได้

Presentation and codes online will be uploaded.
Menu
❖ plugin ขั้นพื้นฐาน

Plugin basic!
❖ WordPress ทำงานอย่างไร

How WordPress works!
❖ plugin ทำงานกับ WordPress อย่างไร

How plugins work together with WordPress!
❖ ผมมีตัวอย่างpluginง่ายๆ3แบบ ที่จะทำให้คุณเข้าใจ

You will see 3 example plugins and understand them
After session
❖ คุณสามารถจะทำpluginอย่างง่ายได้

You can make a simple plugin!
❖ คุณจะรู้ว่าpluginทำหน้าที่อะไร

You will know what plugins do!
❖ คุณจะชอบWordPressมากขึ้น

You will be more interested in WordPress core
Enquete
❖ ใครทำWordPress Themeได้บ้าง

Anyone who can make WP Theme?!
❖ ใครทำPluginได้บ้าง

Anyone who can make WP Plugin?!
❖ ใครรู้จักphpบ้าง

Who knows php?
plugin คือ อะไร

What is a plugin?
What is a plugin?
❖ Tool to extend WordPress functionality!
❖ Without changing Core codes!
❖ Over 30,000 plugins at WordPress.org/plugins/
ต้องมีอะไรบ้าง
What do we need?
What do we need?
a WordPress
Get a clean install of a WordPress.
What do we need?
php, html, css, js
Plugins are written in php.!
!
Many plugins have html & css.!
!
Some plugins have Javascript.
php / basics
❖ variables!
✓ $a!
✓ $hubba!
✓ $posts
❖ functions!
function my_func() {

do_something();

}
❖ others!
✓ if!
✓ foreach!
✓ array
php / template tags
❖ the_title()!
❖ the_permalink()!
❖ the_date()!
❖ the_content()
❖ wp_title()!
❖ body_class()!
❖ get_post_thumbnail_id()!
❖ wp_nav_menu()
basic
wp-content/plugins/easy-plugin.php
WPจะรู้ว่านี่เป็นplugin.
WP knows it’s a plugin.
This comment is called plugin
header.
An easy guide to Plugin Development
wp-admin/plugins.php
WP shows the plugin “Plugin Name: ” comes here.
More Plugin Header
<?php!
/*!
Plugin Name: Plugin ง่าย มาก!!
Plugin URI: http://nskw-style.com/my-plugin!
Description: plugin แรกของผม!
Version: 0.1!
Author: Shinichi Nishikawa!
Author URI: http://nskw-style.com!
License: GPLv2 or later!
Text Domain: easiest!
*/
wp-admin/plugins.php
WP shows the plugin
Those are required if you
want your plugin to be in
wordpress.org site.
An easy guide to Plugin Development
ตัวอย่าง
Examples
ผมทำตัวอย่าง plugin 3 แบบ!
I made 3 plugins for tonight.
คุณจะเข้าใจใน 30 นาที!
!
It may seem difficult but!
you’ll understand in 30 minutes.
1 ใจเย็นๆ
<?php!
/*!
Plugin Name: ใจเย็นๆ!
Description: Tell people to take it easy.!
*/
An easy guide to Plugin Development
1 ใจเย็นๆ
2 สุภาพ
<?php!
/*!
Plugin Name: สุภาพ!
Description: This plugin make all content polite.!
*/
An easy guide to Plugin Development
2 สุภาพ
3 สบายใจ login
<?php!
/*!
Plugin Name: สบายใจ login!
Description: This plugin make login screen happy.!
*/
plugin.com/wp-login.php
3 สบายใจ login
Plugins have codes like,!
!
add_action( ‘location’, ‘function’ );!
or!
add_filter( ‘location’, ‘function’ );!
Let’s see how 3 plugins work.
I will explain the concept of plugin!
and!
we come back to these examples.
Concept of Plugin
We need to know how!
WordPress works.
WordPress Process
WordPress Process
WordPress process
WordPress Process
request: example.com/category/food
User sees the page.
WordPress process
WordPress Process
request: example.com/category/food
User sees the page.
Get DB info from
wp-config.php
connect to DB
WordPress Process
request: example.com/category/food
User sees the page.
Get DB info from
wp-config.php
connect to DB
load core functions
load plugins
load functions.php
WordPress Process
request: example.com/category/food
User sees the page.
Get DB info from
wp-config.php
connect to DB
load core functions
load plugins
load functions.php
query from URL
get post(s)
data from DB
WordPress Process
request: example.com/category/food
User sees the page.
Get DB info from
wp-config.php
connect to DB
load core functions
load plugins
load functions.php
template file
decided.
(category.php)
query from URL
get post(s)
data from DB
category.php!
header.php
loop
sidebar.php
footer.php
WordPress Process
request: example.com/category/food
User sees the page.
WordPress process
WordPress Process
request: example.com/wp-admin/post-new.php
User sees the page.
WordPress process
WordPress Processes can be …
!
✓ displaying home page
✓ displaying admin page
✓ displaying login page
✓ or any other things WordPress does
WordPress Process
request: example.com/wp-login.php
User sees the page.
WordPress process
WordPress Processes can be …
!
✓ displaying home page
✓ displaying admin page
✓ displaying login page
✓ or any other things WordPress does
That’s how WordPress works.
Now, the question is!
!
“how can plugins work!
with the process of WordPress?”
I need to talk about “Hooks”,!
the Secret Key of WordPress.
Hooks
WordPress process
Hooks
WordPress process
Hooks?
❖ Plugins access to hooks to put extra functions
to WordPress!
❖ There are 2 types of hooks.!
✓ Filter Hooks!
✓ Action Hooks
Hooks
Filter Hooks
WordPress process
Action Hooks
Actions!
&!
Filters
action
❖ Action is to do something.!
✓ to echo something!
✓ to save something!
✓ to redirect somewhere
filter
❖ Filter is to change something!
✓ change original text to your text!
✓ change original html to your html!
✓ change original php values to your values.
How hooks look like
apply_filters( ‘location1’, $value );
do_action( ‘location2’ );
filter hook
action hook
How hooks look like
❖ apply_filters( ‘location_name’, $value );!
❖ do_action( ‘location_name’ );
case: in Templates
apply_filters( ‘the_content’, $value );
do_action( ‘wp_footer’ );
ex ) example.com/about
filter hook
action hook
case: login screen
apply_filters( ‘login_message’, $value );
do_action( ‘login_footer’ );
ex ) example.com/wp-login.php
filter hook
action hook
case: admin pages
apply_filters( ‘admin_body_class’, $value );
do_action( ‘admin_head’ );
ex ) example.com/wp-admin/
filter hook
action hook
There are many hooks
name1 name2 name3 name5 name6 name7name4
there are
1,000+ filter hooks & 500+ action hooks
in WordPress
How to hook
How to register
apply_filters( ‘location1’, $value ); do_action( ‘location2’ );
Hooking Filters & Actions
❖ add_filter( ‘location’, ‘your_func_name’ );!
❖ add_action( ‘location’, ‘your_func_name’ );
Hooking Filters & Actions
❖ add_filter( ‘location’, ‘your_func_name’ );

function your_func_name( $default ) {



// do something



return $new;



}
Hooking Filters & Actions
❖ add_action( ‘location’, ‘your_func_name’ );

function your_func_name(){



// do something



}
Register filter
add_filter( ‘location1’, ‘func1’ );
function func1($value){
// make a filter here
return $value
}
apply_filters( ‘location1’, $value ); do_action( ‘location2’ );
Register action
add_action( ‘location2’, ‘func2’ );
function func2(){
// do something
}
apply_filters( ‘location1’, $value ); do_action( ‘location2’ );
Plugin Hook Concept
add_filter( ‘location1’, ‘func1’ );
function func1($value){
// make a filter here
return $value
}
add_action( ‘location2’, ‘func2’ );
function func2(){
// do something
}
apply_filters( ‘location1’, $value ); do_action( ‘location2’ );
Plugin Hook Concept
Plugin is a set of add_action() & add_filter()
add_filter( ‘location1’, ‘func1’ );
function func1($value){
// make a filter here
return $value
}
add_action( ‘location2’, ‘func2’ );
function func2(){
// do something
}
apply_filters( ‘location1’, $value ); do_action( ‘location2’ );
Plugin Hook Concept
Large plugins have many functions in them.
apply_filters( ‘location1’, $value ); do_action( ‘location2’ );
we go back to example plugins
ใจเย็นๆ
An easy guide to Plugin Development
ใจเย็นๆ
request: example.com/category/food
User sees the page.
Get DB info from
wp-config.php
connect to DB
load core functions
load plugins
load functions.php
template file
decided.
(category.php)
query from URL
get post(s)
data from DB
category.php!
header.php
loop
sidebar.php
footer.php
wp_head();
wp_footer();
An easy guide to Plugin Development
An easy guide to Plugin Development
สุภาพ
สุภาพ
สุภาพ
request: example.com/category/food
User sees the page.
Get DB info from
wp-config.php
connect to DB
load core functions
load plugins
load functions.php
template file
decided.
(category.php)
query from URL
get post(s)
data from DB
category.php!
header.php
loop
sidebar.php
footer.php
apply_filters(
‘the_content’,
$content
);
An easy guide to Plugin Development
สุภาพ
a little advanced
This is also possible.
สบายใจ login
สบายใจ login
สบายใจ login
request: example.com/wp-login.php
User sees the page.
check cookies
see ssl
condition
check errors
show logo
& message<html>
</head>
show <form>
do_action(‘login_footer’);
!
in plugin: echo <video>
display login footer
do_action(‘login_head’);
!
in plugin: echo <style>
สบายใจ login
More things you can do with
plugins.
add favicon to admin pages
change excerpt “[…]”
Hide admin notice of upgrades
shortcode
Resources
Resources
❖ Codex!
✓ http://codex.wordpress.org/Writing_a_Plugin!
✓ http://codex.wordpress.org/Plugin_API!
✓ http://codex.wordpress.org/Plugin_Resources!
❖ wordpress.org!
✓ http://developer.wordpress.org/reference/
Next meet-up!
!
“How to build theme properly”!
and!
“How to sell it on WordPress.com”
แนะนำหัวข้อที่น่าสนใจได้นะครับ!
Any suggestions for coming meet-up?

More Related Content

PDF
Jumping Into WordPress Plugin Programming
PDF
So, you want to be a plugin developer?
KEY
Writing your Third Plugin
ODP
The Future Of WordPress Presentation
PDF
Intro to WordPress Plugin Development
PDF
Cucumber Ru09 Web
PDF
Writing Software not Code with Cucumber
PDF
Introduction to WordPress Hooks 2016
Jumping Into WordPress Plugin Programming
So, you want to be a plugin developer?
Writing your Third Plugin
The Future Of WordPress Presentation
Intro to WordPress Plugin Development
Cucumber Ru09 Web
Writing Software not Code with Cucumber
Introduction to WordPress Hooks 2016

What's hot (20)

PPTX
Plugin development wpmeetup010
PDF
Outside-in Development with Cucumber and Rspec
PDF
greach 2014 marco vermeulen bdd using cucumber jvm and groovy
PDF
Continuous Deployment at Etsy
PDF
Ako na vlastne WP temy
PDF
WordPress Theme Development for Designers
PDF
Workshop On WP-CLI
KEY
How To Write a WordPress Plugin
PDF
WordPress Realtime - WordCamp São Paulo 2015
PDF
Getting big without getting fat, in perl
PPTX
Rebrand WordPress Admin
PDF
Grand Rapids PHP Meetup: Behavioral Driven Development with Behat
PPTX
WordPress Structure and Best Practices
PDF
Drupal 8: Huge wins, a Bigger Community, and why you (and I) will Love it
PPT
jQuery For Developers Stack Overflow Dev Days Toronto
PDF
Continuous Deployment at Scale, PHPConfAsia 2016
PPT
Week 9 - Introduction to Child Themes
PDF
Jquery tutorial
PDF
Introduction to VueJS & The WordPress REST API
PDF
JD17NL Joomla! Overrides and alternate layouts
Plugin development wpmeetup010
Outside-in Development with Cucumber and Rspec
greach 2014 marco vermeulen bdd using cucumber jvm and groovy
Continuous Deployment at Etsy
Ako na vlastne WP temy
WordPress Theme Development for Designers
Workshop On WP-CLI
How To Write a WordPress Plugin
WordPress Realtime - WordCamp São Paulo 2015
Getting big without getting fat, in perl
Rebrand WordPress Admin
Grand Rapids PHP Meetup: Behavioral Driven Development with Behat
WordPress Structure and Best Practices
Drupal 8: Huge wins, a Bigger Community, and why you (and I) will Love it
jQuery For Developers Stack Overflow Dev Days Toronto
Continuous Deployment at Scale, PHPConfAsia 2016
Week 9 - Introduction to Child Themes
Jquery tutorial
Introduction to VueJS & The WordPress REST API
JD17NL Joomla! Overrides and alternate layouts
Ad

Viewers also liked (10)

PDF
Building GPE: What We Learned
PDF
Best Practices in Plugin Development (WordCamp Seattle)
PDF
Building an Eclipse plugin to recommend changes to developers
KEY
jQuery Plugin Creation
PPTX
The Open-source Eclipse Plugin for Force.com Development, Summer ‘14
PDF
Plugin jQuery, Design Patterns
PPTX
Eclipse Overview
PDF
A Simple Plugin Architecture for Wicket
PPTX
Configuration as Code: The Job DSL Plugin
PPTX
Creating a Plug-In Architecture
Building GPE: What We Learned
Best Practices in Plugin Development (WordCamp Seattle)
Building an Eclipse plugin to recommend changes to developers
jQuery Plugin Creation
The Open-source Eclipse Plugin for Force.com Development, Summer ‘14
Plugin jQuery, Design Patterns
Eclipse Overview
A Simple Plugin Architecture for Wicket
Configuration as Code: The Job DSL Plugin
Creating a Plug-In Architecture
Ad

Similar to An easy guide to Plugin Development (20)

KEY
Using PHP
PDF
Plugin development demystified 2017
PDF
Javascript and jQuery PennApps Tech Talk, Fall 2014
KEY
Intro to WordPress Plugins
PPTX
How to create your own WordPress plugin
ZIP
Mojolicious
PDF
Plugging into plugins
PDF
Creating Your First WordPress Plugin
PPTX
CUCUMBER - Making BDD Fun
PPTX
Django Girls Tutorial
PDF
Collective.amberjack ploneconf2010
PDF
Creating Extensible Plugins for WordPress
KEY
Plugin Development Practices
PDF
Wordcamp 2010 presentation
PDF
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
PDF
Write your first WordPress plugin
PPTX
Power of mu plugins
PDF
Twig for Drupal 8 and PHP | Presented at OC Drupal
PDF
Theming Wordpress with Adobe
PPT
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Using PHP
Plugin development demystified 2017
Javascript and jQuery PennApps Tech Talk, Fall 2014
Intro to WordPress Plugins
How to create your own WordPress plugin
Mojolicious
Plugging into plugins
Creating Your First WordPress Plugin
CUCUMBER - Making BDD Fun
Django Girls Tutorial
Collective.amberjack ploneconf2010
Creating Extensible Plugins for WordPress
Plugin Development Practices
Wordcamp 2010 presentation
Continuous Integration with Open Source Tools - PHPUgFfm 2014-11-20
Write your first WordPress plugin
Power of mu plugins
Twig for Drupal 8 and PHP | Presented at OC Drupal
Theming Wordpress with Adobe
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)

More from Shinichi Nishikawa (20)

PDF
WordPress Community in Japan
PDF
GPL: WordPress 4つの自由と ビジネスモデル / WordCamp Tokyo 2015 講演スライド
PDF
Learning from theme review requirements
PDF
Child Theme
PDF
Wordpress Community in Japan
PDF
WordPress community and events in Japan. presented at #wp10 meet up in Bangko...
PDF
WordCamp Seoul: WordPress Based web services in Japan / WordCamp 서울 : 일본에서 워드...
PDF
2013年3月16日のWordBench大阪
PDF
アプリケーションプラットフォームとしてのWordPressの序論。ころぐとBookPressを事例に!WordBench福岡の資料!20130323
PDF
電子出版プラットフォーム『BookPress』にみるAWSと電子出版の素敵な関係
PDF
子育てとブログを考える「ころぐ講演」
PDF
WordPressでウェブサービスを作ろう! #wbNagoya
PDF
WordCamp Tokyo 2012 Concept
PDF
CodaでClipを使ってWordPress開発を早くするススメ。
PDF
第三章ナビゲーション &lt; 第4回デザイニング・インターフェース勉強会
PDF
WordCampTokyo2012 開催のお知らせとスタッフ募集
PDF
WordPressマルチサイト機能を使ってブログポータルを作ってみよう!
PDF
4時間まったりWordPressテーマ作成講座
KEY
WordPress中級者への道!テンプレートタグはどう動くのか!?
ZIP
WordPressの管理画面を徹底カスタマイズ!
WordPress Community in Japan
GPL: WordPress 4つの自由と ビジネスモデル / WordCamp Tokyo 2015 講演スライド
Learning from theme review requirements
Child Theme
Wordpress Community in Japan
WordPress community and events in Japan. presented at #wp10 meet up in Bangko...
WordCamp Seoul: WordPress Based web services in Japan / WordCamp 서울 : 일본에서 워드...
2013年3月16日のWordBench大阪
アプリケーションプラットフォームとしてのWordPressの序論。ころぐとBookPressを事例に!WordBench福岡の資料!20130323
電子出版プラットフォーム『BookPress』にみるAWSと電子出版の素敵な関係
子育てとブログを考える「ころぐ講演」
WordPressでウェブサービスを作ろう! #wbNagoya
WordCamp Tokyo 2012 Concept
CodaでClipを使ってWordPress開発を早くするススメ。
第三章ナビゲーション &lt; 第4回デザイニング・インターフェース勉強会
WordCampTokyo2012 開催のお知らせとスタッフ募集
WordPressマルチサイト機能を使ってブログポータルを作ってみよう!
4時間まったりWordPressテーマ作成講座
WordPress中級者への道!テンプレートタグはどう動くのか!?
WordPressの管理画面を徹底カスタマイズ!

Recently uploaded (20)

PDF
CIFDAQ's Market Wrap: Ethereum Leads, Bitcoin Lags, Institutions Shift
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
PDF
Advanced Soft Computing BINUS July 2025.pdf
PDF
Chapter 2 Digital Image Fundamentals.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Sensors and Actuators in IoT Systems using pdf
PPTX
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Empathic Computing: Creating Shared Understanding
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Modernizing your data center with Dell and AMD
PDF
Advanced IT Governance
PDF
cuic standard and advanced reporting.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
CIFDAQ's Market Wrap: Ethereum Leads, Bitcoin Lags, Institutions Shift
20250228 LYD VKU AI Blended-Learning.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
How Onsite IT Support Drives Business Efficiency, Security, and Growth.pdf
Advanced Soft Computing BINUS July 2025.pdf
Chapter 2 Digital Image Fundamentals.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Sensors and Actuators in IoT Systems using pdf
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
“AI and Expert System Decision Support & Business Intelligence Systems”
Empathic Computing: Creating Shared Understanding
Advanced methodologies resolving dimensionality complications for autism neur...
Modernizing your data center with Dell and AMD
Advanced IT Governance
cuic standard and advanced reporting.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
GDG Cloud Iasi [PUBLIC] Florian Blaga - Unveiling the Evolution of Cybersecur...
NewMind AI Weekly Chronicles - August'25 Week I
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy

An easy guide to Plugin Development