SlideShare a Scribd company logo
WordPress Development Paradigms, Idiosyncrasies and Other Big Words Tom Auger, Zeitguys inc. WordCamp Montreal, 2011
Introduction ,[object Object],[object Object],[object Object],[object Object],[object Object]
Surprising Learning Curve ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The biggest challenge... ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Meh. ,[object Object],[object Object]
DIY Approach = Low Level ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
The Bad News ,[object Object],[object Object],[object Object],[object Object],[object Object]
Example: Adding <p> to content ,[object Object],$posts = get_posts(array( 'post_type' => 'my-custom-type' )); foreach($posts as $post){ echo '<div>'; echo $post->post_content; echo '<div>'; }
Option 1: Manually Wrap ,[object Object],$posts = get_posts(array( 'post_type' => 'my-custom-type' )); foreach($posts as $post){ echo '<div>'; echo '<p>'.$post->post_content.'</p>; echo '<div>'; }
Option 1b: RegEx ,[object Object],$blockElements = implode(&quot;|&quot;, array('ADDRESS','BLOCKQUOTE','CENTER','DIR','DIV','DL', etc...); $added_p = preg_replace( '/(?:*<('.$blockElements.')(?:+[^>]+*)*>*(.+?)*<>(?:||$)*)|(?:*(.+?)*(?:||$|(?=<(?:'.$blockElements.')>))+)/is','<p$1>$2$3<p>', $post->post_content);
But wait... doesn't WP already do this? ,[object Object],foreach($posts as $post){ echo '<div>'; echo  wpautop($post->post_content); echo '<div>'; }
So what about the_content()? ,[object Object],foreach($posts as $post){ setup_postdata($post); echo '<div>'; the_content(); echo '<div>'; } wp_reset_postdata();
So how does the_content() do it? ,[object Object],[object Object],function the_content($more_link_text = null, $stripteaser = 0) { $content = get_the_content($more_link_text, $stripteaser); $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]&gt;', $content); echo $content; }
Keep following the White Rabbit ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
I want all that other good stuff, too! ,[object Object],foreach($posts as $post){ echo '<div>'; echo apply_filters( 'the_content',  $page->post_content );   echo '<div>'; }
The lesson thus far ,[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object]
Big Words ,[object Object],[object Object],[object Object]
WordPress Paradigms and Patterns ,[object Object],[object Object],[object Object],[object Object]
WordPress Idioms ,[object Object],[object Object]
WordPress Idiosyncrasies ,[object Object],[object Object],[object Object],[object Object],[object Object]
Paradigm: Plugins ,[object Object],[object Object],[object Object],<?php  /* Plugin Name: Name Of The Plugin */ ?>
Paradigm: Themes and Templates
Themes ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Child Themes ,[object Object],[object Object],[object Object],%> wp-content/themes/my-child-theme/style.css /* Theme Name: Twenty Ten Child Theme Template: twentyten */ @import url('../twentyten/style.css');
Template Files ,[object Object],[object Object],[object Object]
 
Template Parts ,[object Object],[object Object],[object Object],[object Object],[object Object],include(locate_template('template-part')); get_template_part('template', 'part');
Page Templates ,[object Object],<?php /* Template Name: 3 Column */ ?>
Post Formats ,[object Object],[object Object],[object Object],<?php  get_template_part( 'format', get_post_format()); ?>
Paradigm: Hooks, Actions and Filters
[object Object],[object Object]
Hooks ,[object Object],[object Object],[object Object],[object Object]
Actions vs. Filters ,[object Object],[object Object],// set up action hook do_action('hook-name');  // set up filter hook $variable = apply_filters('filter-name', $variable);
Leveraging Action Hooks ,[object Object],[object Object],add_action('init', 'stuff_to_do_at_init');
General Execution Order ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],http://codex.wordpress.org/Plugin_API/Action_Reference#Actions_Run_During_a_Typical_Request
Action examples add_action('init', 'register_my_custom_post');   add_action('init', 'register_my_custom_taxonomy');   add_action('widgets_init', 'register_my_widget');   add_action('wp_enqueue_scripts', 'add_my_js_libs');   add_action('save_post', 'save_my_custom_meta');
Leveraging Filter Hooks ,[object Object],add_filter('the_content', 'change_content');  function change_content($content){ $content = 'All your base are belong to us!!!'; return $content; }
Priority and Parameters ,[object Object],add_filter('contextual_help', 'my_help', 10, 3); function my_help($text, $screen_id, $screen){ if ($screen_id == 'edit-my_custom_post_type'){ $text = '<p>You are on your own pal</p>'; } return $text; }
Filter Examples add_filter( 'excerpt_more', 'custom_more' ); add_filter( 'excerpt_length', 'my_length', 999 ); function my_length($length){ return 6; // six is average, right? }
Existing Filters and Actions ,[object Object],[object Object],[object Object],[object Object]
So How Do I Find Them? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Good Citizenship ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Idiom: The Loop and The Query
Getting Your Content: &quot;The Loop&quot; ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Secondary Loops ,[object Object],[object Object],[object Object],[object Object],[object Object]
Suspicious Stuff ,[object Object],[object Object],[object Object],$the_query = new WP_Query( $args ); while ( $the_query->have_posts() ){  $the_query->the_post(); the_title(); } wp_reset_postdata();
Template Tags and get_ ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Template Tag vs. get_ ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Idiosyncrasy: $wpdb
wpdb Class ,[object Object],[object Object],[object Object],[object Object],[object Object]
Example: Events ,[object Object],[object Object],[object Object],[object Object]
Pure SQL select * from wp_posts join wp_term_relationships on ID = object_id join wp_term_taxonomy on wp_term_taxonomy.term_taxonomy_id = wp_term_relationships.term_taxonomy_id and taxonomy = 'event-type' join wp_terms on wp_term_taxonomy.term_id = wp_terms.term_id and wp_terms.slug = 'speaking' join wp_postmeta on wp_postmeta.post_id = ID and meta_key = 'event-date' and meta_value = '2011-07-09' where post_type = 'event' and post_status = 'published'
More Properer SQL select * from wp_posts  as P join wp_term_relationships  TR_EVENT on  P .ID =  TR_EVENT .object_id join wp_term_taxonomy  TT_EVENT on  TT_EVENT .term_taxonomy_id = TR_EVENT .term_taxonomy_id TT_EVENT .taxonomy = 'event-type' join wp_terms  T_EVENT on  TT_EVENT .term_id =  T_EVENT .term_id and  T_EVENT .slug = 'speaking' join wp_postmeta  M_DATE on  M_DATE .post_id = P.ID and  M_DATE .meta_key = 'event-date' and  M_DATE .meta_value = '2011-07-09' where P .post_type = 'event' and  P .post_status = 'published'
Don't Use Table Names! select * from  {$wpdb->posts}  P join  {$wpdb->term_relationships}  TR_EVENT on P.ID = TR_EVENT.object_id join  {$wpdb->term_taxonomy}  TT_EVENT on TT_EVENT.term_taxonomy_id = TR_EVENT.term_taxonomy_id TT_EVENT.taxonomy = 'event-type' join  {$wpdb->terms}  T_EVENT on TT_EVENT.term_id =T_EVENT.term_id and T_EVENT.slug = 'speaking' join  {$wpdb->postmeta}  M_DATE on M_DATE.post_id = P.ID and M_DATE.meta_key = 'event-date' and M_DATE.meta_value = '2011-07-09' where P.post_type = 'event' and P.post_status = 'published'
More Saferer Query $wpdb->prepare (&quot;select * from {$wpdb->posts} P join {$wpdb->term_relationships} TR_EVENT on P.ID = TR_EVENT.object_id join {$wpdb->term_taxonomy} TT_EVENT on TT_EVENT.term_taxonomy_id = TR_EVENT.term_taxonomy_id TT_EVENT.taxonomy = 'event-type' join {$wpdb->terms} T_EVENT on TT_EVENT.term_id =T_EVENT.term_id and T_EVENT.slug =  %s join {$wpdb->postmeta} M_DATE on M_DATE.post_id = P.ID and M_DATE.meta_key = 'event-date' and M_DATE.meta_value =  %s where P.post_type = 'event' and P.post_status = 'published'&quot;, 'speaking', '2011-07-09' );
But, Whenever We Can... get_posts(array( 'post_type' => 'event', 'tax_query' => array(array( 'taxonomy' => 'event-type', 'field' => 'slug' 'terms' => 'speaking' )), 'meta_query' => array(array( 'key' => 'event-date', 'value' => $todays_date )) ));
Use Built-Ins Whenever You Can ,[object Object],[object Object],[object Object],[object Object],[object Object]
Idiosyncrasy: wp_enqueue_script
We Love jQuery ,[object Object],[object Object],[object Object],[object Object],[object Object]
Enqueue = The Canadian Way, eh? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
No One Likes Conflict ,[object Object],jQuery(document).ready(function($) { $('#mydiv').css({color:'red', border:'2px solid red'}); }); (function($) { var test = &quot;hello, world!&quot;; function testMe(){ alert(test); } $(document).ready(testMe); })(jQuery);
Resources and Forums ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Thanks! www.tomauger.com www.zeitguys.com @TomAuger
Other Stuff for more time
Paradigm: Post Types and Taxonomies
Posts ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Taxonomies ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What About Meta? ,[object Object],[object Object],[object Object]
Custom Post vs. Custom Tax ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Custom Post vs. Custom Tax ,[object Object],[object Object],[object Object],[object Object],[object Object]

More Related Content

What's hot

jQuery UI and Plugins
jQuery UI and PluginsjQuery UI and Plugins
jQuery UI and Plugins
Marc Grabanski
 
jQuery For Beginners - jQuery Conference 2009
jQuery For Beginners - jQuery Conference 2009jQuery For Beginners - jQuery Conference 2009
jQuery For Beginners - jQuery Conference 2009
Ralph Whitbeck
 
Architecture | Busy Java Developers Guide to NoSQL | Ted Neward
Architecture | Busy Java Developers Guide to NoSQL | Ted NewardArchitecture | Busy Java Developers Guide to NoSQL | Ted Neward
Architecture | Busy Java Developers Guide to NoSQL | Ted Neward
JAX London
 
JD17NL Joomla! Overrides and alternate layouts
JD17NL Joomla! Overrides and alternate layoutsJD17NL Joomla! Overrides and alternate layouts
JD17NL Joomla! Overrides and alternate layouts
Hans Kuijpers
 
Ant User Guide
Ant User GuideAnt User Guide
Ant User Guide
Muthuselvam RS
 
Css, xhtml, javascript
Css, xhtml, javascriptCss, xhtml, javascript
Css, xhtml, javascript
Trần Khải Hoàng
 
Creating GUI Component APIs in Angular and Web Components
Creating GUI Component APIs in Angular and Web ComponentsCreating GUI Component APIs in Angular and Web Components
Creating GUI Component APIs in Angular and Web Components
Rachael L Moore
 
Creating GUI container components in Angular and Web Components
Creating GUI container components in Angular and Web ComponentsCreating GUI container components in Angular and Web Components
Creating GUI container components in Angular and Web Components
Rachael L Moore
 
WordPress and Ajax
WordPress and AjaxWordPress and Ajax
WordPress and Ajax
Ronald Huereca
 
Android | Busy Java Developers Guide to Android: UI | Ted Neward
Android | Busy Java Developers Guide to Android: UI | Ted NewardAndroid | Busy Java Developers Guide to Android: UI | Ted Neward
Android | Busy Java Developers Guide to Android: UI | Ted NewardJAX London
 
WordPress Theme Workshop: Part 3
WordPress Theme Workshop: Part 3WordPress Theme Workshop: Part 3
WordPress Theme Workshop: Part 3
David Bisset
 
WordPress Theme Development for Designers
WordPress Theme Development for DesignersWordPress Theme Development for Designers
WordPress Theme Development for Designers
elliotjaystocks
 
BDD - Writing better scenario
BDD - Writing better scenarioBDD - Writing better scenario
BDD - Writing better scenario
Arnauld Loyer
 
Javascript coding-and-design-patterns
Javascript coding-and-design-patternsJavascript coding-and-design-patterns
Javascript coding-and-design-patterns
Hernan Mammana
 
Abstracting functionality with centralised content
Abstracting functionality with centralised contentAbstracting functionality with centralised content
Abstracting functionality with centralised contentMichael Peacock
 
Cartegraph Live HTML, CSS, JavaScript and jQuery Training
Cartegraph Live HTML, CSS, JavaScript and jQuery TrainingCartegraph Live HTML, CSS, JavaScript and jQuery Training
Cartegraph Live HTML, CSS, JavaScript and jQuery Training
Shane Church
 
Hanoi php day 2008 - 01.pham cong dinh - how.to.build.your.own.framework
Hanoi php day 2008 - 01.pham cong dinh - how.to.build.your.own.frameworkHanoi php day 2008 - 01.pham cong dinh - how.to.build.your.own.framework
Hanoi php day 2008 - 01.pham cong dinh - how.to.build.your.own.frameworkNguyen Duc Phu
 
2012.sandiego.wordcamp
2012.sandiego.wordcamp2012.sandiego.wordcamp
2012.sandiego.wordcampBrandon Dove
 
Joomla! Day UK 2009 Template Design
Joomla! Day UK 2009 Template DesignJoomla! Day UK 2009 Template Design
Joomla! Day UK 2009 Template Design
Andy Wallace
 

What's hot (19)

jQuery UI and Plugins
jQuery UI and PluginsjQuery UI and Plugins
jQuery UI and Plugins
 
jQuery For Beginners - jQuery Conference 2009
jQuery For Beginners - jQuery Conference 2009jQuery For Beginners - jQuery Conference 2009
jQuery For Beginners - jQuery Conference 2009
 
Architecture | Busy Java Developers Guide to NoSQL | Ted Neward
Architecture | Busy Java Developers Guide to NoSQL | Ted NewardArchitecture | Busy Java Developers Guide to NoSQL | Ted Neward
Architecture | Busy Java Developers Guide to NoSQL | Ted Neward
 
JD17NL Joomla! Overrides and alternate layouts
JD17NL Joomla! Overrides and alternate layoutsJD17NL Joomla! Overrides and alternate layouts
JD17NL Joomla! Overrides and alternate layouts
 
Ant User Guide
Ant User GuideAnt User Guide
Ant User Guide
 
Css, xhtml, javascript
Css, xhtml, javascriptCss, xhtml, javascript
Css, xhtml, javascript
 
Creating GUI Component APIs in Angular and Web Components
Creating GUI Component APIs in Angular and Web ComponentsCreating GUI Component APIs in Angular and Web Components
Creating GUI Component APIs in Angular and Web Components
 
Creating GUI container components in Angular and Web Components
Creating GUI container components in Angular and Web ComponentsCreating GUI container components in Angular and Web Components
Creating GUI container components in Angular and Web Components
 
WordPress and Ajax
WordPress and AjaxWordPress and Ajax
WordPress and Ajax
 
Android | Busy Java Developers Guide to Android: UI | Ted Neward
Android | Busy Java Developers Guide to Android: UI | Ted NewardAndroid | Busy Java Developers Guide to Android: UI | Ted Neward
Android | Busy Java Developers Guide to Android: UI | Ted Neward
 
WordPress Theme Workshop: Part 3
WordPress Theme Workshop: Part 3WordPress Theme Workshop: Part 3
WordPress Theme Workshop: Part 3
 
WordPress Theme Development for Designers
WordPress Theme Development for DesignersWordPress Theme Development for Designers
WordPress Theme Development for Designers
 
BDD - Writing better scenario
BDD - Writing better scenarioBDD - Writing better scenario
BDD - Writing better scenario
 
Javascript coding-and-design-patterns
Javascript coding-and-design-patternsJavascript coding-and-design-patterns
Javascript coding-and-design-patterns
 
Abstracting functionality with centralised content
Abstracting functionality with centralised contentAbstracting functionality with centralised content
Abstracting functionality with centralised content
 
Cartegraph Live HTML, CSS, JavaScript and jQuery Training
Cartegraph Live HTML, CSS, JavaScript and jQuery TrainingCartegraph Live HTML, CSS, JavaScript and jQuery Training
Cartegraph Live HTML, CSS, JavaScript and jQuery Training
 
Hanoi php day 2008 - 01.pham cong dinh - how.to.build.your.own.framework
Hanoi php day 2008 - 01.pham cong dinh - how.to.build.your.own.frameworkHanoi php day 2008 - 01.pham cong dinh - how.to.build.your.own.framework
Hanoi php day 2008 - 01.pham cong dinh - how.to.build.your.own.framework
 
2012.sandiego.wordcamp
2012.sandiego.wordcamp2012.sandiego.wordcamp
2012.sandiego.wordcamp
 
Joomla! Day UK 2009 Template Design
Joomla! Day UK 2009 Template DesignJoomla! Day UK 2009 Template Design
Joomla! Day UK 2009 Template Design
 

Similar to WordPress development paradigms, idiosyncrasies and other big words

How to learn to build your own PHP framework
How to learn to build your own PHP frameworkHow to learn to build your own PHP framework
How to learn to build your own PHP framework
Dinh Pham
 
Introduction to Plugin Programming, WordCamp Miami 2011
Introduction to Plugin Programming, WordCamp Miami 2011Introduction to Plugin Programming, WordCamp Miami 2011
Introduction to Plugin Programming, WordCamp Miami 2011
David Carr
 
Getting Started With WordPress Development
Getting Started With WordPress DevelopmentGetting Started With WordPress Development
Getting Started With WordPress Development
Andy Brudtkuhl
 
WordPress Development Confoo 2010
WordPress Development Confoo 2010WordPress Development Confoo 2010
WordPress Development Confoo 2010
Brendan Sera-Shriar
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalyst
dwm042
 
Custom WordPress theme development
Custom WordPress theme developmentCustom WordPress theme development
Custom WordPress theme development
Tammy Hart
 
Childthemes ottawa-word camp-1919
Childthemes ottawa-word camp-1919Childthemes ottawa-word camp-1919
Childthemes ottawa-word camp-1919
Paul Bearne
 
Optimize Site Deployments with Drush (DrupalCamp WNY 2011)
Optimize Site Deployments with Drush (DrupalCamp WNY 2011)Optimize Site Deployments with Drush (DrupalCamp WNY 2011)
Optimize Site Deployments with Drush (DrupalCamp WNY 2011)
Jon Peck
 
Wordpress Meetup 2 23 10
Wordpress Meetup 2 23 10Wordpress Meetup 2 23 10
Wordpress Meetup 2 23 10
boonebgorges
 
WordPress Structure and Best Practices
WordPress Structure and Best PracticesWordPress Structure and Best Practices
WordPress Structure and Best Practices
markparolisi
 
Exploring Symfony's Code
Exploring Symfony's CodeExploring Symfony's Code
Exploring Symfony's Code
Wildan Maulana
 
The Way to Theme Enlightenment
The Way to Theme EnlightenmentThe Way to Theme Enlightenment
The Way to Theme Enlightenment
Amanda Giles
 
Javascript
JavascriptJavascript
Javascripttimsplin
 
WordPress 3.0 at DC PHP
WordPress 3.0 at DC PHPWordPress 3.0 at DC PHP
WordPress 3.0 at DC PHP
andrewnacin
 
WordCamp Detroit 2010 Wordpress Theme Hacks
WordCamp Detroit 2010 Wordpress Theme HacksWordCamp Detroit 2010 Wordpress Theme Hacks
WordCamp Detroit 2010 Wordpress Theme Hacks
John Pratt
 
The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017
Amanda Giles
 
Introduction to WordPress Hooks 2016
Introduction to WordPress Hooks 2016Introduction to WordPress Hooks 2016
Introduction to WordPress Hooks 2016
Ian Wilson
 
Getting started with WordPress development
Getting started with WordPress developmentGetting started with WordPress development
Getting started with WordPress development
Steve Mortiboy
 
عرض حول وردبريس
عرض حول وردبريسعرض حول وردبريس
عرض حول وردبريس
Mohammed SAHLI
 

Similar to WordPress development paradigms, idiosyncrasies and other big words (20)

How to learn to build your own PHP framework
How to learn to build your own PHP frameworkHow to learn to build your own PHP framework
How to learn to build your own PHP framework
 
Introduction to Plugin Programming, WordCamp Miami 2011
Introduction to Plugin Programming, WordCamp Miami 2011Introduction to Plugin Programming, WordCamp Miami 2011
Introduction to Plugin Programming, WordCamp Miami 2011
 
Getting Started With WordPress Development
Getting Started With WordPress DevelopmentGetting Started With WordPress Development
Getting Started With WordPress Development
 
WordPress Development Confoo 2010
WordPress Development Confoo 2010WordPress Development Confoo 2010
WordPress Development Confoo 2010
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalyst
 
Custom WordPress theme development
Custom WordPress theme developmentCustom WordPress theme development
Custom WordPress theme development
 
Childthemes ottawa-word camp-1919
Childthemes ottawa-word camp-1919Childthemes ottawa-word camp-1919
Childthemes ottawa-word camp-1919
 
Optimize Site Deployments with Drush (DrupalCamp WNY 2011)
Optimize Site Deployments with Drush (DrupalCamp WNY 2011)Optimize Site Deployments with Drush (DrupalCamp WNY 2011)
Optimize Site Deployments with Drush (DrupalCamp WNY 2011)
 
Wordpress Meetup 2 23 10
Wordpress Meetup 2 23 10Wordpress Meetup 2 23 10
Wordpress Meetup 2 23 10
 
WordPress Structure and Best Practices
WordPress Structure and Best PracticesWordPress Structure and Best Practices
WordPress Structure and Best Practices
 
Exploring Symfony's Code
Exploring Symfony's CodeExploring Symfony's Code
Exploring Symfony's Code
 
Seven deadly theming sins
Seven deadly theming sinsSeven deadly theming sins
Seven deadly theming sins
 
The Way to Theme Enlightenment
The Way to Theme EnlightenmentThe Way to Theme Enlightenment
The Way to Theme Enlightenment
 
Javascript
JavascriptJavascript
Javascript
 
WordPress 3.0 at DC PHP
WordPress 3.0 at DC PHPWordPress 3.0 at DC PHP
WordPress 3.0 at DC PHP
 
WordCamp Detroit 2010 Wordpress Theme Hacks
WordCamp Detroit 2010 Wordpress Theme HacksWordCamp Detroit 2010 Wordpress Theme Hacks
WordCamp Detroit 2010 Wordpress Theme Hacks
 
The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017
 
Introduction to WordPress Hooks 2016
Introduction to WordPress Hooks 2016Introduction to WordPress Hooks 2016
Introduction to WordPress Hooks 2016
 
Getting started with WordPress development
Getting started with WordPress developmentGetting started with WordPress development
Getting started with WordPress development
 
عرض حول وردبريس
عرض حول وردبريسعرض حول وردبريس
عرض حول وردبريس
 

Recently uploaded

Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Jeffrey Haguewood
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 

Recently uploaded (20)

Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 

WordPress development paradigms, idiosyncrasies and other big words

  • 1. WordPress Development Paradigms, Idiosyncrasies and Other Big Words Tom Auger, Zeitguys inc. WordCamp Montreal, 2011
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23. Paradigm: Themes and Templates
  • 24.
  • 25.
  • 26.
  • 27.  
  • 28.
  • 29.
  • 30.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37. Action examples add_action('init', 'register_my_custom_post'); add_action('init', 'register_my_custom_taxonomy'); add_action('widgets_init', 'register_my_widget'); add_action('wp_enqueue_scripts', 'add_my_js_libs'); add_action('save_post', 'save_my_custom_meta');
  • 38.
  • 39.
  • 40. Filter Examples add_filter( 'excerpt_more', 'custom_more' ); add_filter( 'excerpt_length', 'my_length', 999 ); function my_length($length){ return 6; // six is average, right? }
  • 41.
  • 42.
  • 43.
  • 44. Idiom: The Loop and The Query
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 51.
  • 52.
  • 53. Pure SQL select * from wp_posts join wp_term_relationships on ID = object_id join wp_term_taxonomy on wp_term_taxonomy.term_taxonomy_id = wp_term_relationships.term_taxonomy_id and taxonomy = 'event-type' join wp_terms on wp_term_taxonomy.term_id = wp_terms.term_id and wp_terms.slug = 'speaking' join wp_postmeta on wp_postmeta.post_id = ID and meta_key = 'event-date' and meta_value = '2011-07-09' where post_type = 'event' and post_status = 'published'
  • 54. More Properer SQL select * from wp_posts as P join wp_term_relationships TR_EVENT on P .ID = TR_EVENT .object_id join wp_term_taxonomy TT_EVENT on TT_EVENT .term_taxonomy_id = TR_EVENT .term_taxonomy_id TT_EVENT .taxonomy = 'event-type' join wp_terms T_EVENT on TT_EVENT .term_id = T_EVENT .term_id and T_EVENT .slug = 'speaking' join wp_postmeta M_DATE on M_DATE .post_id = P.ID and M_DATE .meta_key = 'event-date' and M_DATE .meta_value = '2011-07-09' where P .post_type = 'event' and P .post_status = 'published'
  • 55. Don't Use Table Names! select * from {$wpdb->posts} P join {$wpdb->term_relationships} TR_EVENT on P.ID = TR_EVENT.object_id join {$wpdb->term_taxonomy} TT_EVENT on TT_EVENT.term_taxonomy_id = TR_EVENT.term_taxonomy_id TT_EVENT.taxonomy = 'event-type' join {$wpdb->terms} T_EVENT on TT_EVENT.term_id =T_EVENT.term_id and T_EVENT.slug = 'speaking' join {$wpdb->postmeta} M_DATE on M_DATE.post_id = P.ID and M_DATE.meta_key = 'event-date' and M_DATE.meta_value = '2011-07-09' where P.post_type = 'event' and P.post_status = 'published'
  • 56. More Saferer Query $wpdb->prepare (&quot;select * from {$wpdb->posts} P join {$wpdb->term_relationships} TR_EVENT on P.ID = TR_EVENT.object_id join {$wpdb->term_taxonomy} TT_EVENT on TT_EVENT.term_taxonomy_id = TR_EVENT.term_taxonomy_id TT_EVENT.taxonomy = 'event-type' join {$wpdb->terms} T_EVENT on TT_EVENT.term_id =T_EVENT.term_id and T_EVENT.slug = %s join {$wpdb->postmeta} M_DATE on M_DATE.post_id = P.ID and M_DATE.meta_key = 'event-date' and M_DATE.meta_value = %s where P.post_type = 'event' and P.post_status = 'published'&quot;, 'speaking', '2011-07-09' );
  • 57. But, Whenever We Can... get_posts(array( 'post_type' => 'event', 'tax_query' => array(array( 'taxonomy' => 'event-type', 'field' => 'slug' 'terms' => 'speaking' )), 'meta_query' => array(array( 'key' => 'event-date', 'value' => $todays_date )) ));
  • 58.
  • 60.
  • 61.
  • 62.
  • 63.
  • 65. Other Stuff for more time
  • 66. Paradigm: Post Types and Taxonomies
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.