SlideShare una empresa de Scribd logo
1 de 71
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]

Más contenido relacionado

La actualidad más candente

jQuery For Beginners - jQuery Conference 2009
jQuery For Beginners - jQuery Conference 2009jQuery For Beginners - jQuery Conference 2009
jQuery For Beginners - jQuery Conference 2009Ralph 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 NewardJAX London
 
JD17NL Joomla! Overrides and alternate layouts
JD17NL Joomla! Overrides and alternate layoutsJD17NL Joomla! Overrides and alternate layouts
JD17NL Joomla! Overrides and alternate layoutsHans Kuijpers
 
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 ComponentsRachael 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 ComponentsRachael L Moore
 
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 3David Bisset
 
WordPress Theme Development for Designers
WordPress Theme Development for DesignersWordPress Theme Development for Designers
WordPress Theme Development for Designerselliotjaystocks
 
BDD - Writing better scenario
BDD - Writing better scenarioBDD - Writing better scenario
BDD - Writing better scenarioArnauld Loyer
 
Javascript coding-and-design-patterns
Javascript coding-and-design-patternsJavascript coding-and-design-patterns
Javascript coding-and-design-patternsHernan 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 TrainingShane 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 DesignAndy Wallace
 

La actualidad más candente (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 a 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 frameworkDinh 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 2011David Carr
 
Getting Started With WordPress Development
Getting Started With WordPress DevelopmentGetting Started With WordPress Development
Getting Started With WordPress DevelopmentAndy Brudtkuhl
 
WordPress Development Confoo 2010
WordPress Development Confoo 2010WordPress Development Confoo 2010
WordPress Development Confoo 2010Brendan Sera-Shriar
 
Practical catalyst
Practical catalystPractical catalyst
Practical catalystdwm042
 
Custom WordPress theme development
Custom WordPress theme developmentCustom WordPress theme development
Custom WordPress theme developmentTammy Hart
 
Childthemes ottawa-word camp-1919
Childthemes ottawa-word camp-1919Childthemes ottawa-word camp-1919
Childthemes ottawa-word camp-1919Paul 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 10boonebgorges
 
WordPress Structure and Best Practices
WordPress Structure and Best PracticesWordPress Structure and Best Practices
WordPress Structure and Best Practicesmarkparolisi
 
Exploring Symfony's Code
Exploring Symfony's CodeExploring Symfony's Code
Exploring Symfony's CodeWildan Maulana
 
The Way to Theme Enlightenment
The Way to Theme EnlightenmentThe Way to Theme Enlightenment
The Way to Theme EnlightenmentAmanda 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 PHPandrewnacin
 
WordCamp Detroit 2010 Wordpress Theme Hacks
WordCamp Detroit 2010 Wordpress Theme HacksWordCamp Detroit 2010 Wordpress Theme Hacks
WordCamp Detroit 2010 Wordpress Theme HacksJohn Pratt
 
The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017Amanda Giles
 
Introduction to WordPress Hooks 2016
Introduction to WordPress Hooks 2016Introduction to WordPress Hooks 2016
Introduction to WordPress Hooks 2016Ian Wilson
 
Getting started with WordPress development
Getting started with WordPress developmentGetting started with WordPress development
Getting started with WordPress developmentSteve Mortiboy
 
عرض حول وردبريس
عرض حول وردبريسعرض حول وردبريس
عرض حول وردبريسMohammed SAHLI
 

Similar a 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
 
عرض حول وردبريس
عرض حول وردبريسعرض حول وردبريس
عرض حول وردبريس
 

Último

Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 

Último (20)

Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 

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.