SlideShare a Scribd company logo
1 of 57
WordPress Plugin #2
May 14th, 2015
Changwoo
Today’s Topics
1.Hooks in Nutshell
2.Database Tables in Nutshell
Recap
- Your first plugin
- Hello Dolly plugin
- action, and callback
Recap
Plugin Header:
/*
Plugin Name: Hello Dolly
Plugin URI: http://wordpress.org/plugins/hello-dolly/
Description: This is not just a plugin, it symbolizes the hope and enthusiasm of an
entire generation summed up in two words sung most famously by Louis Armstrong: Hello,
Dolly. When activated you will randomly see a lyric from <cite>Hello, Dolly</cite> in
the upper right of your admin screen on every page.
Author: Matt Mullenweg
Version: 1.6
Author URI: http://ma.tt/
*/
Recap
Callback Mechanism:
add_action( ‘admin_notices’, ‘hello_dolly’ );
function hello_dolly() {
...
}
Name of hook
Callback function
WP function for hook
Recap
Planning your own plugin, and ...
submission!
Hooks in Nutshell
Hook: an Event
Plugin programming:
- Hook-driven programming.
- A hook means an event.
Hello dolly’s case
2 actions: admin_notices, admin_head
● admin_notices codex
● admin_head codex
Hello dolly’s case
2 actions: admin_notices, admin_head
Let’s find source code.
$ fgrep -Rn do_action( 'admin_notices' ) *
wp-admin/admin-header.php:238: do_action( 'admin_notices' );
$ fgrep -Rn do_action( 'admin_head' ) *
wp-admin/includes/media.php:491: do_action( 'admin_head' );
wp-admin/includes/template.php:1627:do_action( 'admin_head' );
wp-admin/includes/class-wp-press-this.php:1267: do_action( 'admin_head' );
wp-admin/admin-header.php:125:do_action( 'admin_head' );
show source codes
Hook interface
wp-includes/plugin.php
What is action?
What is filter?
● add_filter()
● has_filter()
● apply_filters()
● add_action()
● has_action()
● do_action()
Task Separation
Themes: visual part
Plugins: functional part
Actions: structural part
Filters: information part
Task Separation
Q. I want to add extra contents to every post to be
displayed. Which one do I have to use?
Q. I want to a add menu page to admin page. Which one?
Q. I want to customize the table columns of pages screen.
Q. I want to do something when a post is updated.
Task Separation (solution)
Q. I want to add extra contents to every post to be
displayed. Which one do I have to use?
Q. I want to a add menu page to admin page. Which one?
Q. I want to customize the table columns of pages screen.
Q. I want to do something when a post is updated.
A. filter. ‘the_content’ hook.
A. action. ‘admin_menu’ hook.
A. filter. ‘manage_pages_columns’ hook.
A. action. ‘post_updated’ hook.
Task separation
Do not have to remember them all.
Moreover, actually,
add_action == add_filter
Action, Filter definition
wp-includes/plugin.php
function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1) {
return add_filter($tag, $function_to_add, $priority, $accepted_args);
}
add_action() is mere an alias of add_filter()
Then, why add_action() is created?
Because they want to get more detailed code.
They just wanted detailed conception. That’s cool.
do_action, add_action feedback
do_action:
fires registered action
add_action:
loads any actions
No restriction. you can define your own
hooks.
callback functions...
....
..
.
$wp_filter
add_action(
$tag,
$callback,
$priority,
$num_args
);
callback functions...
....
..
.
$wp_filter
add_action(
‘my_hook’,
‘my_callback’,
10,
1
);
callback functions...
....
..
.
my_hook - my_callback
$wp_filter
add_action(
‘my_hook’,
‘my_callback’,
10,
1
);
callback functions...
....
..
.
my_hook - my_callback
$wp_filter
add_action(
‘my_hook’,
‘my_callback’,
10,
1
);
somewhere in your code
...
do_action(
‘my_hook’
);
...
callback functions...
....
..
.
my_hook - my_callback
$wp_filter
add_action(
‘my_hook’,
‘my_callback’,
10,
1
);
somewhere in your code
...
do_action(
‘my_hook’
);
...
callback functions...
....
..
.
my_hook - my_callback
$wp_filter
add_action(
‘my_hook’,
‘my_callback’,
10,
1
);
somewhere in your code
...
do_action(
‘my_hook’
);
...
by my_hook:
my_callback()
do_action
inside of do_action:
● retrieve the callback functions by their tags (hook)
● sort by priority
● call_user_func()
do {
foreach ( (array) current($wp_filter[$tag]) as $the_ )
if ( !is_null($the_['function']) )
call_user_func_array($the_['function'],
array_slice($args, 0, (int) $the_['accepted_args']));
} while ( next($wp_filter[$tag]) !== false );
add_action
function add_filter( $tag, $function_to_add, $priority = 10, $accepted_args = 1 ) {
global $wp_filter, $merged_filters;
$idx = _wp_filter_build_unique_id($tag, $function_to_add, $priority);
$wp_filter[$tag][$priority][$idx] = array('function' => $function_to_add,
'accepted_args' => $accepted_args);
unset( $merged_filters[ $tag ] );
return true;
}
$wp_filter is an array.
Check it out!
Build a plugin that dumps all registered
actions or filters.
Add your own hook and call it.
Download template code and edit.
http://<myip>/wp-admin/ (meetup / 1)
ftp://<myip> (meetup / 1)
Summary
● filter and action are the same. action is alias.
o structure, data separation
● In fact, this is like a fine wrapper for call_user_func.
o do_action() fires callback functions when the hook
is available
o add_action() loads callback functions.
● There are huge amount of hooks: see reference.
● You can also define your own hooks.
Database Tables in Nutshell
Database: the Root
Database: backbone of web apps.
A good app without understanding
its db structure: just an illusion.
Database description
https://codex.wordpress.org/Database_Description
● parent - meta styles
o wp_comments - wp_commentmeta
o wp_user - wp_usermeta
o wp_posts - wp_postmeta
o wp_options
● wp_terms - wp_term_taxonomy - wp_term_relationships
Meta table
Every *meta table has
● meta_key
● meta_value
closely related to “hashing”
Commentmeta structure
Postmeta structure
Usermeta structure
Options structure
Hashing
key - value pair.
key is short / value is often long.
key is searchable.
Hashing often called (implemented) as
“dictionary”, or “associative array”.
Meta key: benefits
Flexible, extendable
Ordinary tables can’t do these:
● Creating fields “on demands”
● This is one reason why WordPress is
a very versaitle, general, and
easy-to-customize CMS.
Meta key sample: user info
You want to add “Kakaotalk ID”
for every user:
just add “kakaotalk_id” meta key.
Meta in edit screen
Does it matter?
Yes! When fresh install,
WordPress: 11+ tables
74 tables
49 tables
79 tables
Jomla:
Drupal:
XpressEngine:
Meta key: Hazards
No type checking, validation
Meta key consistency
Efficiency
Nothing is perfect!
next: terms, taxonomies, ...
Terms and Taxonomies
Terms: a word
Taxonomy: classification of terms
Terms and Taxonomies
iron
??
Home appliance Metal ???
Adding Terms in Posts
Posts have basically two taxonomies:
● tags
● categories
Adding tag/category = adding term
Adding Terms in Posts
<terms>
term_id: 2
name: MyCategory
slug: my-category
term_group: 0
Adding Terms in Posts
<term_taxonomy>
term_taxonomy_id: 2
term_id: 2
taxonomy: category
/ post_tag
description:
parent: 0
count: 0
Category Setting
<term_relationships>
object_id: 1
term_taxonomy_id: 2
term_order: 0
Post ID: 75 term_relationships.object_id
term_relationships.term_taxonomy_id
Post ID: 75 term_relationships.object_id
term_relationships.term_taxonomy_id
Post ID: 75 term_relationships.object_id
term_relationships.term_taxonomy_id
term_taxonomy.term_taxonomy_id
term_taxonomy.term_id
term_taxonomy.taxonomy ★
Post ID: 75 term_relationships.object_id
term_relationships.term_taxonomy_id
term_taxonomy.term_taxonomy_id
term_taxonomy.term_id
term_taxonomy.taxonomy ★
Post ID: 75 term_relationships.object_id
term_relationships.term_taxonomy_id
terms.term_id
terms.name ★
terms.slug
term_taxonomy.term_taxonomy_id
term_taxonomy.term_id
term_taxonomy.taxonomy ★
Post ID: 75 term_relationships.object_id
term_relationships.term_taxonomy_id
terms.term_id
terms.name ★
terms.slug
term_taxonomy.term_taxonomy_id
term_taxonomy.term_id
term_taxonomy.taxonomy ★
Initial Taxonomies
< wp-includes/taxonomy.php >
function register_taxonomy(
$taxonomy, $object_type, $args = array() ) { ... }
function create_initial_taxonomies() {
register_taxonomy( 'category', 'post', array(...) );
register_taxonomy( 'post_tag', 'post', array(...) );
... and so on ...
create_initial_taxonomies() is called in wp-settings.php
Summary
● Wordpress Datbase table uses metadata
style strategy
● meta tables have key / value fields
o flexible, easy to extend
o while it can have some disadvantages
Summary
● Taxonomy: classification of term
● You can add taxonomies (as well as terms)
● Taxonomy can be flat or hierarchical
● term_taxonomy: taxonomy -
term
● term_relationship: posts - taxonomy
Next week
Admin Menu
● Almost every plugin has its menu
● Easy WP Plugin API
Admin Post
● POST type data submission
URL Query
AJAX Data handling
Wordpress Posts in Nutshell

More Related Content

What's hot

Empowering users: modifying the admin experience
Empowering users: modifying the admin experienceEmpowering users: modifying the admin experience
Empowering users: modifying the admin experienceBeth Soderberg
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the FinishYehuda Katz
 
Dagger 2 vs koin
Dagger 2 vs koinDagger 2 vs koin
Dagger 2 vs koinJintin Lin
 
Practical Protocol-Oriented-Programming
Practical Protocol-Oriented-ProgrammingPractical Protocol-Oriented-Programming
Practical Protocol-Oriented-ProgrammingNatasha Murashev
 
Optimizing Magento by Preloading Data
Optimizing Magento by Preloading DataOptimizing Magento by Preloading Data
Optimizing Magento by Preloading DataIvan Chepurnyi
 
Android Sliding Menu dengan Navigation Drawer
Android Sliding Menu dengan Navigation DrawerAndroid Sliding Menu dengan Navigation Drawer
Android Sliding Menu dengan Navigation DrawerAgus Haryanto
 
Owl: The New Odoo UI Framework
Owl: The New Odoo UI FrameworkOwl: The New Odoo UI Framework
Owl: The New Odoo UI FrameworkOdoo
 
Maven plugin guide using Modello Framework
Maven plugin guide using Modello FrameworkMaven plugin guide using Modello Framework
Maven plugin guide using Modello Frameworkfulvio russo
 
Love and Loss: A Symfony Security Play
Love and Loss: A Symfony Security PlayLove and Loss: A Symfony Security Play
Love and Loss: A Symfony Security PlayKris Wallsmith
 
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterSymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterHaehnchen
 
#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...탑크리에듀(구로디지털단지역3번출구 2분거리)
 
Developing New Widgets for your Views in Owl
Developing New Widgets for your Views in OwlDeveloping New Widgets for your Views in Owl
Developing New Widgets for your Views in OwlOdoo
 
Curso Symfony - Clase 2
Curso Symfony - Clase 2Curso Symfony - Clase 2
Curso Symfony - Clase 2Javier Eguiluz
 
Design how your objects talk through mocking
Design how your objects talk through mockingDesign how your objects talk through mocking
Design how your objects talk through mockingKonstantin Kudryashov
 
OSCON Google App Engine Codelab - July 2010
OSCON Google App Engine Codelab - July 2010OSCON Google App Engine Codelab - July 2010
OSCON Google App Engine Codelab - July 2010ikailan
 
Curso Symfony - Clase 4
Curso Symfony - Clase 4Curso Symfony - Clase 4
Curso Symfony - Clase 4Javier Eguiluz
 
React & Redux for noobs
React & Redux for noobsReact & Redux for noobs
React & Redux for noobs[T]echdencias
 

What's hot (20)

Empowering users: modifying the admin experience
Empowering users: modifying the admin experienceEmpowering users: modifying the admin experience
Empowering users: modifying the admin experience
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the Finish
 
Dagger 2 vs koin
Dagger 2 vs koinDagger 2 vs koin
Dagger 2 vs koin
 
Practical Protocol-Oriented-Programming
Practical Protocol-Oriented-ProgrammingPractical Protocol-Oriented-Programming
Practical Protocol-Oriented-Programming
 
Optimizing Magento by Preloading Data
Optimizing Magento by Preloading DataOptimizing Magento by Preloading Data
Optimizing Magento by Preloading Data
 
Android Sliding Menu dengan Navigation Drawer
Android Sliding Menu dengan Navigation DrawerAndroid Sliding Menu dengan Navigation Drawer
Android Sliding Menu dengan Navigation Drawer
 
Owl: The New Odoo UI Framework
Owl: The New Odoo UI FrameworkOwl: The New Odoo UI Framework
Owl: The New Odoo UI Framework
 
Maven plugin guide using Modello Framework
Maven plugin guide using Modello FrameworkMaven plugin guide using Modello Framework
Maven plugin guide using Modello Framework
 
Love and Loss: A Symfony Security Play
Love and Loss: A Symfony Security PlayLove and Loss: A Symfony Security Play
Love and Loss: A Symfony Security Play
 
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterSymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
 
Extend sdk
Extend sdkExtend sdk
Extend sdk
 
#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#31.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
 
Developing New Widgets for your Views in Owl
Developing New Widgets for your Views in OwlDeveloping New Widgets for your Views in Owl
Developing New Widgets for your Views in Owl
 
Matters of State
Matters of StateMatters of State
Matters of State
 
Curso Symfony - Clase 2
Curso Symfony - Clase 2Curso Symfony - Clase 2
Curso Symfony - Clase 2
 
Eclipse Tricks
Eclipse TricksEclipse Tricks
Eclipse Tricks
 
Design how your objects talk through mocking
Design how your objects talk through mockingDesign how your objects talk through mocking
Design how your objects talk through mocking
 
OSCON Google App Engine Codelab - July 2010
OSCON Google App Engine Codelab - July 2010OSCON Google App Engine Codelab - July 2010
OSCON Google App Engine Codelab - July 2010
 
Curso Symfony - Clase 4
Curso Symfony - Clase 4Curso Symfony - Clase 4
Curso Symfony - Clase 4
 
React & Redux for noobs
React & Redux for noobsReact & Redux for noobs
React & Redux for noobs
 

Viewers also liked

WordPress development paradigms, idiosyncrasies and other big words
WordPress development paradigms, idiosyncrasies and other big wordsWordPress development paradigms, idiosyncrasies and other big words
WordPress development paradigms, idiosyncrasies and other big wordsTomAuger
 
WordPress Coding Standards & WP Hooks
WordPress Coding Standards & WP HooksWordPress Coding Standards & WP Hooks
WordPress Coding Standards & WP HooksEunus Hosen
 
WordPress pizza sessie
WordPress pizza sessieWordPress pizza sessie
WordPress pizza sessieBarry Kooij
 
WordPress hooks - WPLDN July 2013 Meetup
WordPress hooks - WPLDN July 2013 MeetupWordPress hooks - WPLDN July 2013 Meetup
WordPress hooks - WPLDN July 2013 Meetupl3rady
 
Let’s write a plugin
Let’s write a pluginLet’s write a plugin
Let’s write a pluginBrian Layman
 
Intro to Php Security
Intro to Php SecurityIntro to Php Security
Intro to Php SecurityDave Ross
 
Magento eCommerce And The Next Generation Of PHP
Magento eCommerce And The Next Generation Of PHPMagento eCommerce And The Next Generation Of PHP
Magento eCommerce And The Next Generation Of PHPvarien
 
Web Application Security with PHP
Web Application Security with PHPWeb Application Security with PHP
Web Application Security with PHPjikbal
 
Designing WordPress - Heart&Sole2011
Designing WordPress - Heart&Sole2011Designing WordPress - Heart&Sole2011
Designing WordPress - Heart&Sole2011John O'Nolan
 

Viewers also liked (12)

WordPress development paradigms, idiosyncrasies and other big words
WordPress development paradigms, idiosyncrasies and other big wordsWordPress development paradigms, idiosyncrasies and other big words
WordPress development paradigms, idiosyncrasies and other big words
 
WordPress Coding Standards & WP Hooks
WordPress Coding Standards & WP HooksWordPress Coding Standards & WP Hooks
WordPress Coding Standards & WP Hooks
 
WordPress pizza sessie
WordPress pizza sessieWordPress pizza sessie
WordPress pizza sessie
 
WordPress hooks - WPLDN July 2013 Meetup
WordPress hooks - WPLDN July 2013 MeetupWordPress hooks - WPLDN July 2013 Meetup
WordPress hooks - WPLDN July 2013 Meetup
 
Hooks WCSD12
Hooks WCSD12Hooks WCSD12
Hooks WCSD12
 
Let’s write a plugin
Let’s write a pluginLet’s write a plugin
Let’s write a plugin
 
Intro to Php Security
Intro to Php SecurityIntro to Php Security
Intro to Php Security
 
Magento eCommerce And The Next Generation Of PHP
Magento eCommerce And The Next Generation Of PHPMagento eCommerce And The Next Generation Of PHP
Magento eCommerce And The Next Generation Of PHP
 
PHP Security
PHP SecurityPHP Security
PHP Security
 
Best PHP Frameworks
Best PHP FrameworksBest PHP Frameworks
Best PHP Frameworks
 
Web Application Security with PHP
Web Application Security with PHPWeb Application Security with PHP
Web Application Security with PHP
 
Designing WordPress - Heart&Sole2011
Designing WordPress - Heart&Sole2011Designing WordPress - Heart&Sole2011
Designing WordPress - Heart&Sole2011
 

Similar to WordPress plugin #2

Demystifying Hooks, Actions & Filters - WordCamp Belfast 2018
Demystifying Hooks, Actions & Filters - WordCamp Belfast 2018Demystifying Hooks, Actions & Filters - WordCamp Belfast 2018
Demystifying Hooks, Actions & Filters - WordCamp Belfast 2018Damien Carbery
 
WordPress Structure and Best Practices
WordPress Structure and Best PracticesWordPress Structure and Best Practices
WordPress Structure and Best Practicesmarkparolisi
 
Plug in development
Plug in developmentPlug in development
Plug in developmentLucky Ali
 
WordPress plugin #1
WordPress plugin #1WordPress plugin #1
WordPress plugin #1giwoolee
 
Write your first WordPress plugin
Write your first WordPress pluginWrite your first WordPress plugin
Write your first WordPress pluginAnthony Montalbano
 
My first WordPress Plugin
My first WordPress PluginMy first WordPress Plugin
My first WordPress PluginAbbas Siddiqi
 
How To Write a WordPress Plugin
How To Write a WordPress PluginHow To Write a WordPress Plugin
How To Write a WordPress PluginAndy Stratton
 
WordPress basic fundamental of plugin development and creating shortcode
WordPress basic fundamental of plugin development and creating shortcodeWordPress basic fundamental of plugin development and creating shortcode
WordPress basic fundamental of plugin development and creating shortcodeRakesh Kushwaha
 
WordPress Plugin Basics
WordPress Plugin BasicsWordPress Plugin Basics
WordPress Plugin BasicsAmanda Giles
 
Stop Hacking WordPress, Start Working with it - Charly Leetham - WordCamp Syd...
Stop Hacking WordPress, Start Working with it - Charly Leetham - WordCamp Syd...Stop Hacking WordPress, Start Working with it - Charly Leetham - WordCamp Syd...
Stop Hacking WordPress, Start Working with it - Charly Leetham - WordCamp Syd...WordCamp Sydney
 
Ruby on rails
Ruby on rails Ruby on rails
Ruby on rails Mohit Jain
 
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)arcware
 
WordPress Plugin development
WordPress Plugin developmentWordPress Plugin development
WordPress Plugin developmentMostafa Soufi
 
WordPress Hooks Action & Filters
WordPress Hooks Action & FiltersWordPress Hooks Action & Filters
WordPress Hooks Action & FiltersNirav Mehta
 
Intro to WordPress Plugin Development
Intro to WordPress Plugin DevelopmentIntro to WordPress Plugin Development
Intro to WordPress Plugin DevelopmentBrad Williams
 
Word press Plugins by WordPress Experts
Word press Plugins by WordPress ExpertsWord press Plugins by WordPress Experts
Word press Plugins by WordPress ExpertsYameen Khan
 
Working With The Symfony Admin Generator
Working With The Symfony Admin GeneratorWorking With The Symfony Admin Generator
Working With The Symfony Admin GeneratorJohn Cleveley
 
Creating Your First WordPress Plugin
Creating Your First WordPress PluginCreating Your First WordPress Plugin
Creating Your First WordPress PluginBrad Williams
 

Similar to WordPress plugin #2 (20)

Demystifying Hooks, Actions & Filters - WordCamp Belfast 2018
Demystifying Hooks, Actions & Filters - WordCamp Belfast 2018Demystifying Hooks, Actions & Filters - WordCamp Belfast 2018
Demystifying Hooks, Actions & Filters - WordCamp Belfast 2018
 
WordPress Structure and Best Practices
WordPress Structure and Best PracticesWordPress Structure and Best Practices
WordPress Structure and Best Practices
 
Plug in development
Plug in developmentPlug in development
Plug in development
 
WordPress plugin #1
WordPress plugin #1WordPress plugin #1
WordPress plugin #1
 
Write your first WordPress plugin
Write your first WordPress pluginWrite your first WordPress plugin
Write your first WordPress plugin
 
My first WordPress Plugin
My first WordPress PluginMy first WordPress Plugin
My first WordPress Plugin
 
How To Write a WordPress Plugin
How To Write a WordPress PluginHow To Write a WordPress Plugin
How To Write a WordPress Plugin
 
WordPress basic fundamental of plugin development and creating shortcode
WordPress basic fundamental of plugin development and creating shortcodeWordPress basic fundamental of plugin development and creating shortcode
WordPress basic fundamental of plugin development and creating shortcode
 
WordPress Plugin Basics
WordPress Plugin BasicsWordPress Plugin Basics
WordPress Plugin Basics
 
Stop Hacking WordPress, Start Working with it - Charly Leetham - WordCamp Syd...
Stop Hacking WordPress, Start Working with it - Charly Leetham - WordCamp Syd...Stop Hacking WordPress, Start Working with it - Charly Leetham - WordCamp Syd...
Stop Hacking WordPress, Start Working with it - Charly Leetham - WordCamp Syd...
 
Ruby on rails
Ruby on rails Ruby on rails
Ruby on rails
 
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
 
WordPress Plugin development
WordPress Plugin developmentWordPress Plugin development
WordPress Plugin development
 
WordPress Hooks Action & Filters
WordPress Hooks Action & FiltersWordPress Hooks Action & Filters
WordPress Hooks Action & Filters
 
Intro to WordPress Plugin Development
Intro to WordPress Plugin DevelopmentIntro to WordPress Plugin Development
Intro to WordPress Plugin Development
 
Word press Plugins by WordPress Experts
Word press Plugins by WordPress ExpertsWord press Plugins by WordPress Experts
Word press Plugins by WordPress Experts
 
WordPress Plugins
WordPress PluginsWordPress Plugins
WordPress Plugins
 
Working With The Symfony Admin Generator
Working With The Symfony Admin GeneratorWorking With The Symfony Admin Generator
Working With The Symfony Admin Generator
 
Magento++
Magento++Magento++
Magento++
 
Creating Your First WordPress Plugin
Creating Your First WordPress PluginCreating Your First WordPress Plugin
Creating Your First WordPress Plugin
 

Recently uploaded

Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls DubaiDubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubaikojalkojal131
 
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...Call Girls in Nagpur High Profile
 
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort ServiceBusty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort ServiceDelhi Call girls
 
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...SUHANI PANDEY
 
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...SUHANI PANDEY
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC
 
Katraj ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For S...
Katraj ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For S...Katraj ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For S...
Katraj ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For S...tanu pandey
 
Dubai Call Girls Milky O525547819 Call Girls Dubai Soft Dating
Dubai Call Girls Milky O525547819 Call Girls Dubai Soft DatingDubai Call Girls Milky O525547819 Call Girls Dubai Soft Dating
Dubai Call Girls Milky O525547819 Call Girls Dubai Soft Datingkojalkojal131
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...tanu pandey
 
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...Escorts Call Girls
 
Enjoy Night⚡Call Girls Samalka Delhi >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Samalka Delhi >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Samalka Delhi >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Samalka Delhi >༒8448380779 Escort ServiceDelhi Call girls
 
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...Neha Pandey
 
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...tanu pandey
 
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...singhpriety023
 
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)Delhi Call girls
 
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.soniya singh
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...Diya Sharma
 

Recently uploaded (20)

Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls DubaiDubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
Dubai=Desi Dubai Call Girls O525547819 Outdoor Call Girls Dubai
 
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
 
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort ServiceBusty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
Busty Desi⚡Call Girls in Vasundhara Ghaziabad >༒8448380779 Escort Service
 
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
VVIP Pune Call Girls Sinhagad WhatSapp Number 8005736733 With Elite Staff And...
 
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
Shikrapur - Call Girls in Pune Neha 8005736733 | 100% Gennuine High Class Ind...
 
APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53APNIC Updates presented by Paul Wilson at ARIN 53
APNIC Updates presented by Paul Wilson at ARIN 53
 
Katraj ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For S...
Katraj ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For S...Katraj ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For S...
Katraj ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For S...
 
Dubai Call Girls Milky O525547819 Call Girls Dubai Soft Dating
Dubai Call Girls Milky O525547819 Call Girls Dubai Soft DatingDubai Call Girls Milky O525547819 Call Girls Dubai Soft Dating
Dubai Call Girls Milky O525547819 Call Girls Dubai Soft Dating
 
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
 
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
 
Enjoy Night⚡Call Girls Samalka Delhi >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Samalka Delhi >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Samalka Delhi >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Samalka Delhi >༒8448380779 Escort Service
 
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
 
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
valsad Escorts Service ☎️ 6378878445 ( Sakshi Sinha ) High Profile Call Girls...
 
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
 
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting  High Prof...
VIP Model Call Girls Hadapsar ( Pune ) Call ON 9905417584 Starting High Prof...
 
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
 
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
(INDIRA) Call Girl Pune Call Now 8250077686 Pune Escorts 24x7
 
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Sarai Rohilla Escort Service Delhi N.C.R.
 
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
 

WordPress plugin #2

  • 1. WordPress Plugin #2 May 14th, 2015 Changwoo
  • 2. Today’s Topics 1.Hooks in Nutshell 2.Database Tables in Nutshell
  • 3. Recap - Your first plugin - Hello Dolly plugin - action, and callback
  • 4. Recap Plugin Header: /* Plugin Name: Hello Dolly Plugin URI: http://wordpress.org/plugins/hello-dolly/ Description: This is not just a plugin, it symbolizes the hope and enthusiasm of an entire generation summed up in two words sung most famously by Louis Armstrong: Hello, Dolly. When activated you will randomly see a lyric from <cite>Hello, Dolly</cite> in the upper right of your admin screen on every page. Author: Matt Mullenweg Version: 1.6 Author URI: http://ma.tt/ */
  • 5. Recap Callback Mechanism: add_action( ‘admin_notices’, ‘hello_dolly’ ); function hello_dolly() { ... } Name of hook Callback function WP function for hook
  • 6. Recap Planning your own plugin, and ... submission!
  • 8. Hook: an Event Plugin programming: - Hook-driven programming. - A hook means an event.
  • 9. Hello dolly’s case 2 actions: admin_notices, admin_head ● admin_notices codex ● admin_head codex
  • 10. Hello dolly’s case 2 actions: admin_notices, admin_head Let’s find source code. $ fgrep -Rn do_action( 'admin_notices' ) * wp-admin/admin-header.php:238: do_action( 'admin_notices' ); $ fgrep -Rn do_action( 'admin_head' ) * wp-admin/includes/media.php:491: do_action( 'admin_head' ); wp-admin/includes/template.php:1627:do_action( 'admin_head' ); wp-admin/includes/class-wp-press-this.php:1267: do_action( 'admin_head' ); wp-admin/admin-header.php:125:do_action( 'admin_head' ); show source codes
  • 11. Hook interface wp-includes/plugin.php What is action? What is filter? ● add_filter() ● has_filter() ● apply_filters() ● add_action() ● has_action() ● do_action()
  • 12. Task Separation Themes: visual part Plugins: functional part Actions: structural part Filters: information part
  • 13. Task Separation Q. I want to add extra contents to every post to be displayed. Which one do I have to use? Q. I want to a add menu page to admin page. Which one? Q. I want to customize the table columns of pages screen. Q. I want to do something when a post is updated.
  • 14. Task Separation (solution) Q. I want to add extra contents to every post to be displayed. Which one do I have to use? Q. I want to a add menu page to admin page. Which one? Q. I want to customize the table columns of pages screen. Q. I want to do something when a post is updated. A. filter. ‘the_content’ hook. A. action. ‘admin_menu’ hook. A. filter. ‘manage_pages_columns’ hook. A. action. ‘post_updated’ hook.
  • 15. Task separation Do not have to remember them all. Moreover, actually, add_action == add_filter
  • 16. Action, Filter definition wp-includes/plugin.php function add_action($tag, $function_to_add, $priority = 10, $accepted_args = 1) { return add_filter($tag, $function_to_add, $priority, $accepted_args); } add_action() is mere an alias of add_filter() Then, why add_action() is created? Because they want to get more detailed code. They just wanted detailed conception. That’s cool.
  • 17. do_action, add_action feedback do_action: fires registered action add_action: loads any actions No restriction. you can define your own hooks.
  • 20. callback functions... .... .. . my_hook - my_callback $wp_filter add_action( ‘my_hook’, ‘my_callback’, 10, 1 );
  • 21. callback functions... .... .. . my_hook - my_callback $wp_filter add_action( ‘my_hook’, ‘my_callback’, 10, 1 ); somewhere in your code ... do_action( ‘my_hook’ ); ...
  • 22. callback functions... .... .. . my_hook - my_callback $wp_filter add_action( ‘my_hook’, ‘my_callback’, 10, 1 ); somewhere in your code ... do_action( ‘my_hook’ ); ...
  • 23. callback functions... .... .. . my_hook - my_callback $wp_filter add_action( ‘my_hook’, ‘my_callback’, 10, 1 ); somewhere in your code ... do_action( ‘my_hook’ ); ... by my_hook: my_callback()
  • 24. do_action inside of do_action: ● retrieve the callback functions by their tags (hook) ● sort by priority ● call_user_func() do { foreach ( (array) current($wp_filter[$tag]) as $the_ ) if ( !is_null($the_['function']) ) call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args'])); } while ( next($wp_filter[$tag]) !== false );
  • 25. add_action function add_filter( $tag, $function_to_add, $priority = 10, $accepted_args = 1 ) { global $wp_filter, $merged_filters; $idx = _wp_filter_build_unique_id($tag, $function_to_add, $priority); $wp_filter[$tag][$priority][$idx] = array('function' => $function_to_add, 'accepted_args' => $accepted_args); unset( $merged_filters[ $tag ] ); return true; } $wp_filter is an array.
  • 26. Check it out! Build a plugin that dumps all registered actions or filters. Add your own hook and call it. Download template code and edit. http://<myip>/wp-admin/ (meetup / 1) ftp://<myip> (meetup / 1)
  • 27. Summary ● filter and action are the same. action is alias. o structure, data separation ● In fact, this is like a fine wrapper for call_user_func. o do_action() fires callback functions when the hook is available o add_action() loads callback functions. ● There are huge amount of hooks: see reference. ● You can also define your own hooks.
  • 28. Database Tables in Nutshell
  • 29. Database: the Root Database: backbone of web apps. A good app without understanding its db structure: just an illusion.
  • 30. Database description https://codex.wordpress.org/Database_Description ● parent - meta styles o wp_comments - wp_commentmeta o wp_user - wp_usermeta o wp_posts - wp_postmeta o wp_options ● wp_terms - wp_term_taxonomy - wp_term_relationships
  • 31. Meta table Every *meta table has ● meta_key ● meta_value closely related to “hashing”
  • 36. Hashing key - value pair. key is short / value is often long. key is searchable. Hashing often called (implemented) as “dictionary”, or “associative array”.
  • 37. Meta key: benefits Flexible, extendable Ordinary tables can’t do these: ● Creating fields “on demands” ● This is one reason why WordPress is a very versaitle, general, and easy-to-customize CMS.
  • 38. Meta key sample: user info You want to add “Kakaotalk ID” for every user: just add “kakaotalk_id” meta key.
  • 39. Meta in edit screen
  • 40. Does it matter? Yes! When fresh install, WordPress: 11+ tables 74 tables 49 tables 79 tables Jomla: Drupal: XpressEngine:
  • 41. Meta key: Hazards No type checking, validation Meta key consistency Efficiency Nothing is perfect! next: terms, taxonomies, ...
  • 42. Terms and Taxonomies Terms: a word Taxonomy: classification of terms
  • 43. Terms and Taxonomies iron ?? Home appliance Metal ???
  • 44. Adding Terms in Posts Posts have basically two taxonomies: ● tags ● categories Adding tag/category = adding term
  • 45. Adding Terms in Posts <terms> term_id: 2 name: MyCategory slug: my-category term_group: 0
  • 46. Adding Terms in Posts <term_taxonomy> term_taxonomy_id: 2 term_id: 2 taxonomy: category / post_tag description: parent: 0 count: 0
  • 48. Post ID: 75 term_relationships.object_id term_relationships.term_taxonomy_id
  • 49. Post ID: 75 term_relationships.object_id term_relationships.term_taxonomy_id
  • 50. Post ID: 75 term_relationships.object_id term_relationships.term_taxonomy_id term_taxonomy.term_taxonomy_id term_taxonomy.term_id term_taxonomy.taxonomy ★
  • 51. Post ID: 75 term_relationships.object_id term_relationships.term_taxonomy_id term_taxonomy.term_taxonomy_id term_taxonomy.term_id term_taxonomy.taxonomy ★
  • 52. Post ID: 75 term_relationships.object_id term_relationships.term_taxonomy_id terms.term_id terms.name ★ terms.slug term_taxonomy.term_taxonomy_id term_taxonomy.term_id term_taxonomy.taxonomy ★
  • 53. Post ID: 75 term_relationships.object_id term_relationships.term_taxonomy_id terms.term_id terms.name ★ terms.slug term_taxonomy.term_taxonomy_id term_taxonomy.term_id term_taxonomy.taxonomy ★
  • 54. Initial Taxonomies < wp-includes/taxonomy.php > function register_taxonomy( $taxonomy, $object_type, $args = array() ) { ... } function create_initial_taxonomies() { register_taxonomy( 'category', 'post', array(...) ); register_taxonomy( 'post_tag', 'post', array(...) ); ... and so on ... create_initial_taxonomies() is called in wp-settings.php
  • 55. Summary ● Wordpress Datbase table uses metadata style strategy ● meta tables have key / value fields o flexible, easy to extend o while it can have some disadvantages
  • 56. Summary ● Taxonomy: classification of term ● You can add taxonomies (as well as terms) ● Taxonomy can be flat or hierarchical ● term_taxonomy: taxonomy - term ● term_relationship: posts - taxonomy
  • 57. Next week Admin Menu ● Almost every plugin has its menu ● Easy WP Plugin API Admin Post ● POST type data submission URL Query AJAX Data handling Wordpress Posts in Nutshell