SlideShare une entreprise Scribd logo
1  sur  40
Télécharger pour lire hors ligne
Becoming a better
   WordPress
   Developer
     Joey Kudish
      @jkudish
      slides.jkudish.com
why am I here?
• developing with WordPress since 2007
• previously: high scale WP client sites +
  custom plugins
• currently: Code Wrangler for
  WordPress.com / Automattic
• I want to share my experience and
  knowledge
what is WordPress
 development?
themes, plugins, html,
javascript, css, php, html5,
css3, mysql, code, blah,
blah, blah...
all these things come
       together
WordPress core
contribute to core
• contributing makes you feel good, and helps
  others
• submit a ticket / bug report
• write a patch
• answer support forum questions
• help document something
make.wordpress.org/
  core/handbook/
use core to your
  advantage
use built-in APIs
• WP_HTTP: http://codex.wordpress.org/HTTP_API
• Filesystem: http://codex.wordpress.org/Filesystem_API
• Settings: http://codex.wordpress.org/Settings_API
• CPTs/Taxonomies: http://codex.wordpress.org/Post_Types
• WPDB: http://codex.wordpress.org/Class_Reference/wpdb
• Hooks
• And much much more...
action hooks
Actions allow you to run arbitrary code at a
specific point during WordPress code
execution


do_action( 'wp_head' );

add_action( 'wp_head', 'jkudish_head' );
filter hooks
   Filters allow you to modify a variable (before it is
   output, saved, used, whatever...)


apply_filters( 'the_content', $post_content );

add_filter( 'the_content', 'jkudish_filter' );
hooks API FTW
do_action( 'the_action',
$addtl_arg1, $addtl_arg2 [...] );


$variable =
apply_filters( 'the_filter',
$variable, $addtl_arg1,
$addtl_arg2 [...] );
registering hooks
• Actions:
     add_action( 'the_action',
     'callback_func', 10, 3 );
• Filters:
     add_filter( 'the_filter',
     'callback_func', 10, 3 );
• Callback function:
     function callback_func( $value,
     $addtl_arg1, $addtl_arg2 ... )
finding the right
          hooks
• Search through core
• Plugin API on the Codex: codex.wordpress.org/
   Plugin_API

• Adam Brown's Hook Database: adambrown.info/p/
   wp_hooks

• WP Candy Article on hooks: wpcandy.com/teaches/
   how-to-use-wordpress-hooks
better yet
add_action( 'all',
'jkudish_all_the_hooks' ) );



function jkudish_all_the_hooks() {

    error_log( print_r(
    current_filter(), true ) );

}
other helpers
has_action();
has_filter();
did_action();
remove_action();
remove_all_actions();
remove_all_filters();
where to put your
       code
• themes
     templates for display on the front-end
     and related helper functions
• plugins
     code that can be toggled on/off and
     modifies the behaviour of WordPress in
     some way or provides additional
     functionality
• mu-plugins
     just like plugins but automatically loaded
     to run on each page load
let core tell you
when you are wrong
• WP_DEBUG
• _doing_it_wrong();
• unit tests
• watch Mo’s presentation :)
code is poetry
make things legible, classy & elegant;
 follow the WP coding standards
   http://codex.wordpress.org/WordPress_Coding_Standards
<?php vs <?
single quotes unless you
need to evaluate a variable

 <?php echo 'a great string'; ?>

      vs
 <?php

 $dog_name = 'Winston';

 echo "my dog's name is: $dog_name";

 ?>
naming is important
• not so much:
       $myGreatVariable = 2;
• even worse:
       $MygreatVariable = myFunction();

• just stupid:
       $mygReAtvariAble = FUNcTiO_n();
• correct:
       $my_great_variable = my_function();
spacing for legibility
• not so much:
       foreach($posts as $post)
• even worse:
       for($i<5;$i=0;$i++)
• just stupid:
       if($coDeisineLigible)
       {$youcantReadthis=true;}
• correct:
       foreach ( $posts as $post )
brackets, indentation
   + empty lines
 if ( is_page() ) {

     echo 'this is a page';

 } elseif ( is_single() ) {

     echo 'this is a post';
     echo '<br>how wonderful!';

 } else {

     echo 'not a page or post';

 }
Yoda conditions
What happens if you accidentally forget a '=' ?


   if ( $city == 'Montreal' )
                      vs.
   if ( 'Montreal' == $city )
don’t get too clever
Clever, but do you know what it does?
    isset( $var ) || $var = some_function();


Easier to read:
    if ( ! isset( $var ) )
      $var = some_function();
keep it elegant,
simple and avoid
useless comments
What not to do
<?php

/* Get all our options from the database */

global $options;

foreach ($options as $value) {

	 if (get_settings( $value['id'] ) ===
FALSE) { $$value['id'] = $value['std'];

	 } else { $$value['id'] =
get_settings( $value['id'] ); }

}
doing it right
<?php
class WP_My_House {
  var $bricks = 0;
  function add_brick() {
    if ( ! $this->is_made_of_cement() )
     return false;


      $this->bricks++;
      return true;
  }
      ...
}
$my_house = new WP_My_House();
beyond the
 standards
$wpdb->escape();
$wpdb->prepare();
  sanitize_*();
escape all the things
• esc_attr(): escape                       an html attribute
• intval(): make                    sure the value is an integer
• wp_kses(): strip                  unwanted html tags
• esc_html(): encodes                         html so it can be
    output as text
• esc_js(): encodes                      strings to be used in
    javascript
• esc_url(): encodes                        and validates URLs
•   Full list at: codex.wordpress.org/Data_Validation or in wp-includes/formatting.php
internationalize
__( 'Hello World', 'my-plugin' );
_e( 'Hello World', 'my-plugin' );
_n( 'Comment', 'Comments', $comment_count,
'my-plugin' );


$mood = 'Cruel';
printf( _x( 'Hello %s World', 'intro to the
world', 'my-plugin' ), $mood );


read more: http://codex.wordpress.org/I18n_for_WordPress_Developers
allow for others to
           hook in
  do_action( 'jkudish_setup_cpt' );



$sky_color =
apply_filters( 'jkudish_sky_color', 'blue' );
open source
code review
collaborate
WordPress
Q&A
Merci!
slides.jkudish.com

Contenu connexe

Tendances

jQuery Tips Tricks Trivia
jQuery Tips Tricks TriviajQuery Tips Tricks Trivia
jQuery Tips Tricks TriviaCognizant
 
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
 
The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017Amanda Giles
 
Extending Custom Post Types
Extending Custom Post Types Extending Custom Post Types
Extending Custom Post Types ryanduff
 
Intro to WordPress theme development
Intro to WordPress theme developmentIntro to WordPress theme development
Intro to WordPress theme developmentThad Allender
 
Introduction to Custom WordPress Themeing
Introduction to Custom WordPress ThemeingIntroduction to Custom WordPress Themeing
Introduction to Custom WordPress ThemeingJamie Schmid
 
WordPress Theme Development for Designers
WordPress Theme Development for DesignersWordPress Theme Development for Designers
WordPress Theme Development for Designerselliotjaystocks
 
Put a little Backbone in your WordPress
Put a little Backbone in your WordPressPut a little Backbone in your WordPress
Put a little Backbone in your WordPressadamsilverstein
 
Associations & JavaScript
Associations & JavaScriptAssociations & JavaScript
Associations & JavaScriptJoost Elfering
 
WordPress Theme Structure
WordPress Theme StructureWordPress Theme Structure
WordPress Theme Structurekeithdevon
 
Advanced WordPress Development Environments
Advanced WordPress Development EnvironmentsAdvanced WordPress Development Environments
Advanced WordPress Development EnvironmentsBeau Lebens
 
How to start developing apps for Firefox OS
How to start developing apps for Firefox OSHow to start developing apps for Firefox OS
How to start developing apps for Firefox OSbenko
 
Ingo Muschenetz: Titanium Studio Deep Dive
Ingo Muschenetz: Titanium Studio Deep DiveIngo Muschenetz: Titanium Studio Deep Dive
Ingo Muschenetz: Titanium Studio Deep DiveAxway Appcelerator
 
WordPress as the Backbone(.js)
WordPress as the Backbone(.js)WordPress as the Backbone(.js)
WordPress as the Backbone(.js)Beau Lebens
 
Childthemes ottawa-word camp-1919
Childthemes ottawa-word camp-1919Childthemes ottawa-word camp-1919
Childthemes ottawa-word camp-1919Paul Bearne
 
Building themesfromscratchwithframeworks
Building themesfromscratchwithframeworksBuilding themesfromscratchwithframeworks
Building themesfromscratchwithframeworksDavid Brattoli
 

Tendances (20)

Custom Fields & Custom Metaboxes Overview
Custom Fields & Custom Metaboxes OverviewCustom Fields & Custom Metaboxes Overview
Custom Fields & Custom Metaboxes Overview
 
jQuery Tips Tricks Trivia
jQuery Tips Tricks TriviajQuery Tips Tricks Trivia
jQuery Tips Tricks Trivia
 
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
 
The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017The Way to Theme Enlightenment 2017
The Way to Theme Enlightenment 2017
 
Extending Custom Post Types
Extending Custom Post Types Extending Custom Post Types
Extending Custom Post Types
 
Intro to WordPress theme development
Intro to WordPress theme developmentIntro to WordPress theme development
Intro to WordPress theme development
 
Introduction to Custom WordPress Themeing
Introduction to Custom WordPress ThemeingIntroduction to Custom WordPress Themeing
Introduction to Custom WordPress Themeing
 
WordPress Theme Development for Designers
WordPress Theme Development for DesignersWordPress Theme Development for Designers
WordPress Theme Development for Designers
 
Put a little Backbone in your WordPress
Put a little Backbone in your WordPressPut a little Backbone in your WordPress
Put a little Backbone in your WordPress
 
Associations & JavaScript
Associations & JavaScriptAssociations & JavaScript
Associations & JavaScript
 
WordPress Theme Structure
WordPress Theme StructureWordPress Theme Structure
WordPress Theme Structure
 
Advanced WordPress Development Environments
Advanced WordPress Development EnvironmentsAdvanced WordPress Development Environments
Advanced WordPress Development Environments
 
Theming 101
Theming 101Theming 101
Theming 101
 
How to start developing apps for Firefox OS
How to start developing apps for Firefox OSHow to start developing apps for Firefox OS
How to start developing apps for Firefox OS
 
Extending WordPress
Extending WordPressExtending WordPress
Extending WordPress
 
Ingo Muschenetz: Titanium Studio Deep Dive
Ingo Muschenetz: Titanium Studio Deep DiveIngo Muschenetz: Titanium Studio Deep Dive
Ingo Muschenetz: Titanium Studio Deep Dive
 
WordPress as the Backbone(.js)
WordPress as the Backbone(.js)WordPress as the Backbone(.js)
WordPress as the Backbone(.js)
 
Death of a Themer
Death of a ThemerDeath of a Themer
Death of a Themer
 
Childthemes ottawa-word camp-1919
Childthemes ottawa-word camp-1919Childthemes ottawa-word camp-1919
Childthemes ottawa-word camp-1919
 
Building themesfromscratchwithframeworks
Building themesfromscratchwithframeworksBuilding themesfromscratchwithframeworks
Building themesfromscratchwithframeworks
 

En vedette

WordCamp Victoria 2013: Plugin Development 2013
WordCamp Victoria 2013: Plugin Development 2013WordCamp Victoria 2013: Plugin Development 2013
WordCamp Victoria 2013: Plugin Development 2013Joey Kudish
 
Rapid CMS enabled site development with Wordpress
Rapid CMS enabled site development with WordpressRapid CMS enabled site development with Wordpress
Rapid CMS enabled site development with WordpressPeter Kaizer
 
125 An Interview With A Teacher
125 An Interview With A Teacher125 An Interview With A Teacher
125 An Interview With A Teacherstarcookie
 
Nate Reist WCGR WP AJAX presentation
Nate Reist WCGR WP AJAX presentationNate Reist WCGR WP AJAX presentation
Nate Reist WCGR WP AJAX presentationnatereist
 
Responsive Theme Workshop - WordCamp Columbus 2015
Responsive Theme Workshop - WordCamp Columbus 2015Responsive Theme Workshop - WordCamp Columbus 2015
Responsive Theme Workshop - WordCamp Columbus 2015Joe Querin
 
Angular js introduction by Tania Gonzales
Angular js introduction by Tania GonzalesAngular js introduction by Tania Gonzales
Angular js introduction by Tania GonzalesThoughtworks
 
The Future of WordPress and JavaScript
The Future of WordPress and JavaScriptThe Future of WordPress and JavaScript
The Future of WordPress and JavaScriptAndrew Duthie
 
Custom Post Types--Front End
Custom Post Types--Front EndCustom Post Types--Front End
Custom Post Types--Front EndBill Robbins
 
Advanced Custom Post Types
Advanced Custom Post TypesAdvanced Custom Post Types
Advanced Custom Post TypesAndy Stratton
 
WP 201 Custom Post Types - Custom Fields - WordCamp Columbus 2015
WP 201   Custom Post Types - Custom Fields - WordCamp Columbus 2015WP 201   Custom Post Types - Custom Fields - WordCamp Columbus 2015
WP 201 Custom Post Types - Custom Fields - WordCamp Columbus 2015Joe Querin
 
Wordpress as a Backend
Wordpress as a BackendWordpress as a Backend
Wordpress as a BackendAndrew Duthie
 
Launching a WordPress Site 101 (Cincinnati WordPress, August 2015)
Launching a WordPress Site 101 (Cincinnati WordPress, August 2015)Launching a WordPress Site 101 (Cincinnati WordPress, August 2015)
Launching a WordPress Site 101 (Cincinnati WordPress, August 2015)Andrew Duthie
 
Hcc45 Principals01082007
Hcc45 Principals01082007Hcc45 Principals01082007
Hcc45 Principals01082007roger96
 
Building a JavaScript App powered by WordPress & AngularJS
Building a JavaScript App powered by WordPress & AngularJSBuilding a JavaScript App powered by WordPress & AngularJS
Building a JavaScript App powered by WordPress & AngularJSRoy Sivan
 
Webinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST APIWebinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST APIWP Engine
 

En vedette (20)

WordCamp Victoria 2013: Plugin Development 2013
WordCamp Victoria 2013: Plugin Development 2013WordCamp Victoria 2013: Plugin Development 2013
WordCamp Victoria 2013: Plugin Development 2013
 
WordPress Security
WordPress SecurityWordPress Security
WordPress Security
 
SSDs are Awesome
SSDs are AwesomeSSDs are Awesome
SSDs are Awesome
 
Rapid CMS enabled site development with Wordpress
Rapid CMS enabled site development with WordpressRapid CMS enabled site development with Wordpress
Rapid CMS enabled site development with Wordpress
 
125 An Interview With A Teacher
125 An Interview With A Teacher125 An Interview With A Teacher
125 An Interview With A Teacher
 
Nate Reist WCGR WP AJAX presentation
Nate Reist WCGR WP AJAX presentationNate Reist WCGR WP AJAX presentation
Nate Reist WCGR WP AJAX presentation
 
Responsive Theme Workshop - WordCamp Columbus 2015
Responsive Theme Workshop - WordCamp Columbus 2015Responsive Theme Workshop - WordCamp Columbus 2015
Responsive Theme Workshop - WordCamp Columbus 2015
 
Angular js introduction by Tania Gonzales
Angular js introduction by Tania GonzalesAngular js introduction by Tania Gonzales
Angular js introduction by Tania Gonzales
 
The Future of WordPress and JavaScript
The Future of WordPress and JavaScriptThe Future of WordPress and JavaScript
The Future of WordPress and JavaScript
 
Curso AngularJS - 1. introducción
Curso AngularJS - 1. introducciónCurso AngularJS - 1. introducción
Curso AngularJS - 1. introducción
 
Custom Post Types--Front End
Custom Post Types--Front EndCustom Post Types--Front End
Custom Post Types--Front End
 
Advanced Custom Post Types
Advanced Custom Post TypesAdvanced Custom Post Types
Advanced Custom Post Types
 
WP 201 Custom Post Types - Custom Fields - WordCamp Columbus 2015
WP 201   Custom Post Types - Custom Fields - WordCamp Columbus 2015WP 201   Custom Post Types - Custom Fields - WordCamp Columbus 2015
WP 201 Custom Post Types - Custom Fields - WordCamp Columbus 2015
 
Wordpress as a Backend
Wordpress as a BackendWordpress as a Backend
Wordpress as a Backend
 
Launching a WordPress Site 101 (Cincinnati WordPress, August 2015)
Launching a WordPress Site 101 (Cincinnati WordPress, August 2015)Launching a WordPress Site 101 (Cincinnati WordPress, August 2015)
Launching a WordPress Site 101 (Cincinnati WordPress, August 2015)
 
Hcc45 Principals01082007
Hcc45 Principals01082007Hcc45 Principals01082007
Hcc45 Principals01082007
 
Introducción a Angular JS
Introducción a Angular JSIntroducción a Angular JS
Introducción a Angular JS
 
Building a JavaScript App powered by WordPress & AngularJS
Building a JavaScript App powered by WordPress & AngularJSBuilding a JavaScript App powered by WordPress & AngularJS
Building a JavaScript App powered by WordPress & AngularJS
 
Webinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST APIWebinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST API
 
Angular js
Angular jsAngular js
Angular js
 

Similaire à Becoming a better WordPress Developer

[Bristol WordPress] Supercharging WordPress Development
[Bristol WordPress] Supercharging WordPress Development[Bristol WordPress] Supercharging WordPress Development
[Bristol WordPress] Supercharging WordPress DevelopmentAdam Tomat
 
Quality assurance for php projects with PHPStorm
Quality assurance for php projects with PHPStormQuality assurance for php projects with PHPStorm
Quality assurance for php projects with PHPStormMichelangelo van Dam
 
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)Mike Schinkel
 
Supercharging WordPress Development - Wordcamp Brighton 2019
Supercharging WordPress Development - Wordcamp Brighton 2019Supercharging WordPress Development - Wordcamp Brighton 2019
Supercharging WordPress Development - Wordcamp Brighton 2019Adam Tomat
 
You're Doing it Wrong - WordCamp Orlando
You're Doing it Wrong - WordCamp OrlandoYou're Doing it Wrong - WordCamp Orlando
You're Doing it Wrong - WordCamp OrlandoChris Scott
 
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
 
Using Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkUsing Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkDirk Haun
 
Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12Michelangelo van Dam
 
Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012Michelangelo van Dam
 
You're Doing it Wrong - WordCamp Atlanta
You're Doing it Wrong - WordCamp AtlantaYou're Doing it Wrong - WordCamp Atlanta
You're Doing it Wrong - WordCamp AtlantaChris Scott
 
Wordless, stop writing WordPress themes like it's 1998
Wordless, stop writing WordPress themes like it's 1998Wordless, stop writing WordPress themes like it's 1998
Wordless, stop writing WordPress themes like it's 1998Filippo Dino
 
Как получить чёрный пояс по WordPress?
Как получить чёрный пояс по WordPress?Как получить чёрный пояс по WordPress?
Как получить чёрный пояс по WordPress?Yevhen Kotelnytskyi
 
Debugging WordPress
Debugging WordPressDebugging WordPress
Debugging WordPressMario Peshev
 
[WLDN] Supercharging word press development in 2018
[WLDN] Supercharging word press development in 2018[WLDN] Supercharging word press development in 2018
[WLDN] Supercharging word press development in 2018Adam Tomat
 
Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2Shinya Ohyanagi
 
5 Reasons To Love CodeIgniter
5 Reasons To Love CodeIgniter5 Reasons To Love CodeIgniter
5 Reasons To Love CodeIgniternicdev
 

Similaire à Becoming a better WordPress Developer (20)

[Bristol WordPress] Supercharging WordPress Development
[Bristol WordPress] Supercharging WordPress Development[Bristol WordPress] Supercharging WordPress Development
[Bristol WordPress] Supercharging WordPress Development
 
Quality assurance for php projects with PHPStorm
Quality assurance for php projects with PHPStormQuality assurance for php projects with PHPStorm
Quality assurance for php projects with PHPStorm
 
Fatc
FatcFatc
Fatc
 
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
Hardcore URL Routing for WordPress - WordCamp Atlanta 2014 (PPT)
 
Supercharging WordPress Development - Wordcamp Brighton 2019
Supercharging WordPress Development - Wordcamp Brighton 2019Supercharging WordPress Development - Wordcamp Brighton 2019
Supercharging WordPress Development - Wordcamp Brighton 2019
 
You're Doing it Wrong - WordCamp Orlando
You're Doing it Wrong - WordCamp OrlandoYou're Doing it Wrong - WordCamp Orlando
You're Doing it Wrong - WordCamp Orlando
 
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)
 
Using Geeklog as a Web Application Framework
Using Geeklog as a Web Application FrameworkUsing Geeklog as a Web Application Framework
Using Geeklog as a Web Application Framework
 
Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12Workshop quality assurance for php projects tek12
Workshop quality assurance for php projects tek12
 
Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012Quality Assurance for PHP projects - ZendCon 2012
Quality Assurance for PHP projects - ZendCon 2012
 
You're Doing it Wrong - WordCamp Atlanta
You're Doing it Wrong - WordCamp AtlantaYou're Doing it Wrong - WordCamp Atlanta
You're Doing it Wrong - WordCamp Atlanta
 
Wordless, stop writing WordPress themes like it's 1998
Wordless, stop writing WordPress themes like it's 1998Wordless, stop writing WordPress themes like it's 1998
Wordless, stop writing WordPress themes like it's 1998
 
Как получить чёрный пояс по WordPress?
Как получить чёрный пояс по WordPress?Как получить чёрный пояс по WordPress?
Как получить чёрный пояс по WordPress?
 
Debugging WordPress
Debugging WordPressDebugging WordPress
Debugging WordPress
 
Blog Hacks 2011
Blog Hacks 2011Blog Hacks 2011
Blog Hacks 2011
 
[WLDN] Supercharging word press development in 2018
[WLDN] Supercharging word press development in 2018[WLDN] Supercharging word press development in 2018
[WLDN] Supercharging word press development in 2018
 
Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2
 
QA for PHP projects
QA for PHP projectsQA for PHP projects
QA for PHP projects
 
I Love codeigniter, You?
I Love codeigniter, You?I Love codeigniter, You?
I Love codeigniter, You?
 
5 Reasons To Love CodeIgniter
5 Reasons To Love CodeIgniter5 Reasons To Love CodeIgniter
5 Reasons To Love CodeIgniter
 

Dernier

Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
"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
 
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
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
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
 
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
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
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
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 

Dernier (20)

Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
"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...
 
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
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
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
 
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)
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
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
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 

Becoming a better WordPress Developer

  • 1. Becoming a better WordPress Developer Joey Kudish @jkudish slides.jkudish.com
  • 2. why am I here? • developing with WordPress since 2007 • previously: high scale WP client sites + custom plugins • currently: Code Wrangler for WordPress.com / Automattic • I want to share my experience and knowledge
  • 3. what is WordPress development? themes, plugins, html, javascript, css, php, html5, css3, mysql, code, blah, blah, blah...
  • 4. all these things come together
  • 6.
  • 7. contribute to core • contributing makes you feel good, and helps others • submit a ticket / bug report • write a patch • answer support forum questions • help document something
  • 8.
  • 10. use core to your advantage
  • 11. use built-in APIs • WP_HTTP: http://codex.wordpress.org/HTTP_API • Filesystem: http://codex.wordpress.org/Filesystem_API • Settings: http://codex.wordpress.org/Settings_API • CPTs/Taxonomies: http://codex.wordpress.org/Post_Types • WPDB: http://codex.wordpress.org/Class_Reference/wpdb • Hooks • And much much more...
  • 12. action hooks Actions allow you to run arbitrary code at a specific point during WordPress code execution do_action( 'wp_head' ); add_action( 'wp_head', 'jkudish_head' );
  • 13. filter hooks Filters allow you to modify a variable (before it is output, saved, used, whatever...) apply_filters( 'the_content', $post_content ); add_filter( 'the_content', 'jkudish_filter' );
  • 14. hooks API FTW do_action( 'the_action', $addtl_arg1, $addtl_arg2 [...] ); $variable = apply_filters( 'the_filter', $variable, $addtl_arg1, $addtl_arg2 [...] );
  • 15. registering hooks • Actions: add_action( 'the_action', 'callback_func', 10, 3 ); • Filters: add_filter( 'the_filter', 'callback_func', 10, 3 ); • Callback function: function callback_func( $value, $addtl_arg1, $addtl_arg2 ... )
  • 16. finding the right hooks • Search through core • Plugin API on the Codex: codex.wordpress.org/ Plugin_API • Adam Brown's Hook Database: adambrown.info/p/ wp_hooks • WP Candy Article on hooks: wpcandy.com/teaches/ how-to-use-wordpress-hooks
  • 17. better yet add_action( 'all', 'jkudish_all_the_hooks' ) ); function jkudish_all_the_hooks() { error_log( print_r( current_filter(), true ) ); }
  • 19. where to put your code • themes templates for display on the front-end and related helper functions • plugins code that can be toggled on/off and modifies the behaviour of WordPress in some way or provides additional functionality • mu-plugins just like plugins but automatically loaded to run on each page load
  • 20. let core tell you when you are wrong • WP_DEBUG • _doing_it_wrong(); • unit tests • watch Mo’s presentation :)
  • 21. code is poetry make things legible, classy & elegant; follow the WP coding standards http://codex.wordpress.org/WordPress_Coding_Standards
  • 23. single quotes unless you need to evaluate a variable <?php echo 'a great string'; ?> vs <?php $dog_name = 'Winston'; echo "my dog's name is: $dog_name"; ?>
  • 24. naming is important • not so much: $myGreatVariable = 2; • even worse: $MygreatVariable = myFunction(); • just stupid: $mygReAtvariAble = FUNcTiO_n(); • correct: $my_great_variable = my_function();
  • 25. spacing for legibility • not so much: foreach($posts as $post) • even worse: for($i<5;$i=0;$i++) • just stupid: if($coDeisineLigible) {$youcantReadthis=true;} • correct: foreach ( $posts as $post )
  • 26. brackets, indentation + empty lines if ( is_page() ) {     echo 'this is a page'; } elseif ( is_single() ) {     echo 'this is a post';     echo '<br>how wonderful!'; } else {     echo 'not a page or post'; }
  • 27. Yoda conditions What happens if you accidentally forget a '=' ? if ( $city == 'Montreal' ) vs. if ( 'Montreal' == $city )
  • 28. don’t get too clever Clever, but do you know what it does? isset( $var ) || $var = some_function(); Easier to read: if ( ! isset( $var ) ) $var = some_function();
  • 29. keep it elegant, simple and avoid useless comments
  • 30. What not to do <?php /* Get all our options from the database */ global $options; foreach ($options as $value) { if (get_settings( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else { $$value['id'] = get_settings( $value['id'] ); } }
  • 32. <?php class WP_My_House { var $bricks = 0; function add_brick() { if ( ! $this->is_made_of_cement() ) return false; $this->bricks++; return true; } ... } $my_house = new WP_My_House();
  • 34.
  • 36. escape all the things • esc_attr(): escape an html attribute • intval(): make sure the value is an integer • wp_kses(): strip unwanted html tags • esc_html(): encodes html so it can be output as text • esc_js(): encodes strings to be used in javascript • esc_url(): encodes and validates URLs • Full list at: codex.wordpress.org/Data_Validation or in wp-includes/formatting.php
  • 37. internationalize __( 'Hello World', 'my-plugin' ); _e( 'Hello World', 'my-plugin' ); _n( 'Comment', 'Comments', $comment_count, 'my-plugin' ); $mood = 'Cruel'; printf( _x( 'Hello %s World', 'intro to the world', 'my-plugin' ), $mood ); read more: http://codex.wordpress.org/I18n_for_WordPress_Developers
  • 38. allow for others to hook in do_action( 'jkudish_setup_cpt' ); $sky_color = apply_filters( 'jkudish_sky_color', 'blue' );