SlideShare una empresa de Scribd logo
1 de 53
Descargar para leer sin conexión
Debugging in WordPress


WordCamp San Francisco 2011
August 13, 2011
Andrew Nacin
Core Developer of WordPress
Tech Ninja at Audrey Capital
nacin@wordpress.org
@nacin on Twitter
var_dump( $data );
      die( );
      // fin.
“I love suppressing error
messages!” — no one, ever.
So let's start with
WP_DEBUG
define( 'WP_DEBUG', true );
What WP_DEBUG does:
— Sets the error reporting level to
include PHP notices
— Bypasses some error suppression
— Triggers notices for deprecated
usage (more on that later)
You can change its output:
// A default of true forces on display_errors.
define( 'WP_DEBUG_DISPLAY', true );

// Setting it to false will let PHP (php.ini) decide.
define( 'WP_DEBUG_DISPLAY', false );
// So, if your php.ini has display_errors on,
   you'll also need to turn it off:
ini_set( 'display_errors', 0 );
Likely being simplified in 3.3:
// A default of true forces on display_errors.
define( 'WP_DEBUG_DISPLAY', true );

// False forces off display_errors.
define( 'WP_DEBUG_DISPLAY', false );

// Null will let PHP (php.ini) decide.
define( 'WP_DEBUG_DISPLAY', null );
You can specify an error log:
// wp-content/debug.log
define( 'WP_DEBUG_LOG', true );

// New in 3.3! (Likely.)
define( 'WP_DEBUG_LOG', '/tmp/php-errors' );

// Follow ticket #18391, created last night.
Debug admin CSS & JS with
SCRIPT_DEBUG
define( 'SCRIPT_DEBUG', true );
SCRIPT_DEBUG prevents
minification and concatenation of
core scripts and styles.

load-scripts.php?c=1&load=global,wp-admin,ms…
versus global.dev.css, wp-admin.dev.css, ms.dev.css
SCRIPT_DEBUG is good for:
— Finding bugs in your admin screens
— Studying the admin theme
— Contributing to core
Debug queries with
SAVEQUERIES
define( 'SAVEQUERIES', true );
SAVEQUERIES stores query data in
$wpdb->queries.

(OMG BBQ:
This is NOT for production.)
Query: SELECT * FROM wp_users
WHERE user_login = 'nacin'
Backtrace: WP->init,
wp_get_current_user,
get_currentuserinfo,
wp_validate_auth_cookie,
get_user_by
Execution time: 0.4ms
On using these in production:
WP_DEBUG
— Don't display errors
— Don't log to wp-content/error.log
SCRIPT_DEBUG
— Bad idea.
SAVEQUERIES
— Barry will hunt you down.
Plugins
Your new best friend:
The Debug Bar
It’s like Firebug for your WordPress.
Debug Bar Console
A Firebug-like console for
PHP and MySQL (really)
What's stopping you from
building your own Debug
Bar extension?
Nothing.
Log Deprecated Notices
— Logs the usage of deprecated files,
functions, and function arguments.
— Pinpoints where the deprecated
functionality is being used.
— NEVER use in production.
Theme Check
— Test your theme for the latest
WordPress standards and practices.
— Required for the theme directory.
Common functions when
debugging
— error_log and var_export / print_r
— var_dump and sometimes die
— debug_backtrace
Tracking it down
Step 1
Disable plugins
Switch to default theme
What might be left behind?
Cron, Rewrites,
Roles/Capabilities
Drop-ins
— advanced-cache.php
— db.php
— object-cache.php
— mu-plugins
What's going on?
Query vars set properly?
Main query SQL look right?
Rewrite rule matched?
Funny redirect?
Confirm it's canonical.
remove_action( 'template_redirect',
                   'redirect_canonical' );
Testing multisite?


I leave this in my config:
// define( 'MULTISITE', true );
Dig into the codebase.
Your friends are phpxref, grep.
Learn the stack.
Learn what things call what.
Some common traps
Step 1
Is your code even running?
(Spell the hook right?)
die( 'wtf' ); or error_log( )
White screen on the
frontend, no errors?

Appearance > Themes
User interface doesn't work?
Check the browser's JS console
for an error, usually a conflict.
Internal server errors?
Infinite redirects. Check:
— home and siteurl
— then .htaccess
— then canonical
Widgets got moved around?
Do the sidebars have IDs?
Otherwise, it's the order in which
register_sidebar() is called.
Lots of pages? Slow site?
My next Q: What's your
permalink structure?
No longer an issue in 3.3!
Weird Bug #1
Somewhere deep in style.css:
“Template: home.php”
Miscalculated as a multisite bug:
activated on single site before
style.css had the headers.
Weird Bug #2
The admin looked weird
Weird Bug #2
The admin looked weird

Trigger: Upgrade from 2.5 to 3.1
Weird Bug #2
The admin looked weird

Trigger: Upgrade from 2.5 to 3.1
Problem: No MySQL ALTER
permissions
Weird Bug #3
Some bbPress rewrites
failed after activation
Weird Bug #3
Some bbPress rewrites
failed after activation
Problem: Custom post type
rewrites aren't registered on
activation
// Say you have:
add_action( 'generate_rewrite_rules',
               function( $wp_rewrite ) { … } );
// And:
register_activation_hook( __FILE__, function() {
     flush_rewrite_rules( );
} );
// But! This won't work for CPTs. Try this:
add_action( 'init', 'my_register_post_types' );
register_activation_hook( __FILE__, function( ) {
     my_register_post_types( );
     flush_rewrite_rules( );
} );
Local Development
/etc/hosts
127.0.0.1 andrewnacin.com
Configure virtual hosts
Install local WordPress
Replace links with an
output buffer for
development or staging
environments
// Run this on development or staging.
// A development wp-config.php
   or local-config.php is fine.

ob_start( 'nacin_dev_urls' );
function nacin_dev_urls( $buffer ) {
  $live = 'http://andrewnacin.com';
  $dev = 'http://dev.andrewnacin.com';
  return str_replace( $live, $dev, $buffer );
}
URLs are more portable
when they're absolute.

Really.*

The serialized stuff is lame though.
Start of a conversation
Xdebug (backtraces, profiling)
KCacheGrind (visualization)
Using an IDE
Unit testing
And finally, remember:
Friends don't let friends
develop without
WP_DEBUG.
Thanks! Questions?


@nacin

Más contenido relacionado

La actualidad más candente

WordPress Migrations 101 - WordCamp Orlando
WordPress Migrations 101 - WordCamp OrlandoWordPress Migrations 101 - WordCamp Orlando
WordPress Migrations 101 - WordCamp OrlandoSiteGround.com
 
Theming in WordPress - Where do I Start?
Theming in WordPress - Where do I Start?Theming in WordPress - Where do I Start?
Theming in WordPress - Where do I Start?Edmund Turbin
 
I Can Haz More Performanz?
I Can Haz More Performanz?I Can Haz More Performanz?
I Can Haz More Performanz?Andy Melichar
 
High Performance WordPress
High Performance WordPressHigh Performance WordPress
High Performance WordPressvnsavage
 
"Ensuring chances of theme acceptance in wordpress.org directory" on WordCamp...
"Ensuring chances of theme acceptance in wordpress.org directory" on WordCamp..."Ensuring chances of theme acceptance in wordpress.org directory" on WordCamp...
"Ensuring chances of theme acceptance in wordpress.org directory" on WordCamp...Sudeep Balchhaudi
 
Empowering Non-Profits with WordPress
Empowering Non-Profits with WordPressEmpowering Non-Profits with WordPress
Empowering Non-Profits with WordPressCliff Seal
 
Why it's dangerous to turn off automatic updates and here's how to do it
Why it's dangerous to turn off automatic updates and here's how to do itWhy it's dangerous to turn off automatic updates and here's how to do it
Why it's dangerous to turn off automatic updates and here's how to do itOnni Hakala
 
Speed up Your Joomla Site for Ultimate Performance
Speed up Your Joomla Site for Ultimate PerformanceSpeed up Your Joomla Site for Ultimate Performance
Speed up Your Joomla Site for Ultimate PerformanceJoomlaDay Australia
 
Child Themes in WordPress
Child Themes in WordPressChild Themes in WordPress
Child Themes in WordPressJeff Cohan
 
The Power of a Video Library - WordCamp Raleigh
The  Power of a Video Library - WordCamp RaleighThe  Power of a Video Library - WordCamp Raleigh
The Power of a Video Library - WordCamp RaleighLauren Jeffcoat
 
Piecing Together the WordPress Puzzle
Piecing Together the WordPress PuzzlePiecing Together the WordPress Puzzle
Piecing Together the WordPress PuzzleBusiness Vitality LLC
 
WordPress REST API v2: Overview & Exploring
WordPress REST API v2: Overview & ExploringWordPress REST API v2: Overview & Exploring
WordPress REST API v2: Overview & ExploringNick Pelton
 
Squeeze Maximum Performance From Your Joomla Website
Squeeze Maximum Performance From Your Joomla WebsiteSqueeze Maximum Performance From Your Joomla Website
Squeeze Maximum Performance From Your Joomla WebsiteSiteGround.com
 
How to develope plugin in wordpress: 6 simple steps.
How to develope plugin in wordpress: 6 simple steps.How to develope plugin in wordpress: 6 simple steps.
How to develope plugin in wordpress: 6 simple steps.Jay Bharat
 
Hidden Secrets For A Hack-Proof Joomla! Site
Hidden Secrets For A Hack-Proof Joomla! SiteHidden Secrets For A Hack-Proof Joomla! Site
Hidden Secrets For A Hack-Proof Joomla! SiteDaniel Kanchev
 
Extending Custom Post Types
Extending Custom Post Types Extending Custom Post Types
Extending Custom Post Types ryanduff
 
DrupalCon Barcelona 2015
DrupalCon Barcelona 2015DrupalCon Barcelona 2015
DrupalCon Barcelona 2015Daniel Kanchev
 
Doing Things the WordPress Way
Doing Things the WordPress WayDoing Things the WordPress Way
Doing Things the WordPress WayMatt Wiebe
 

La actualidad más candente (20)

WAG the Blog
WAG the BlogWAG the Blog
WAG the Blog
 
What is (not) WordPress
What is (not) WordPressWhat is (not) WordPress
What is (not) WordPress
 
WordPress Migrations 101 - WordCamp Orlando
WordPress Migrations 101 - WordCamp OrlandoWordPress Migrations 101 - WordCamp Orlando
WordPress Migrations 101 - WordCamp Orlando
 
Theming in WordPress - Where do I Start?
Theming in WordPress - Where do I Start?Theming in WordPress - Where do I Start?
Theming in WordPress - Where do I Start?
 
I Can Haz More Performanz?
I Can Haz More Performanz?I Can Haz More Performanz?
I Can Haz More Performanz?
 
High Performance WordPress
High Performance WordPressHigh Performance WordPress
High Performance WordPress
 
"Ensuring chances of theme acceptance in wordpress.org directory" on WordCamp...
"Ensuring chances of theme acceptance in wordpress.org directory" on WordCamp..."Ensuring chances of theme acceptance in wordpress.org directory" on WordCamp...
"Ensuring chances of theme acceptance in wordpress.org directory" on WordCamp...
 
Empowering Non-Profits with WordPress
Empowering Non-Profits with WordPressEmpowering Non-Profits with WordPress
Empowering Non-Profits with WordPress
 
Why it's dangerous to turn off automatic updates and here's how to do it
Why it's dangerous to turn off automatic updates and here's how to do itWhy it's dangerous to turn off automatic updates and here's how to do it
Why it's dangerous to turn off automatic updates and here's how to do it
 
Speed up Your Joomla Site for Ultimate Performance
Speed up Your Joomla Site for Ultimate PerformanceSpeed up Your Joomla Site for Ultimate Performance
Speed up Your Joomla Site for Ultimate Performance
 
Child Themes in WordPress
Child Themes in WordPressChild Themes in WordPress
Child Themes in WordPress
 
The Power of a Video Library - WordCamp Raleigh
The  Power of a Video Library - WordCamp RaleighThe  Power of a Video Library - WordCamp Raleigh
The Power of a Video Library - WordCamp Raleigh
 
Piecing Together the WordPress Puzzle
Piecing Together the WordPress PuzzlePiecing Together the WordPress Puzzle
Piecing Together the WordPress Puzzle
 
WordPress REST API v2: Overview & Exploring
WordPress REST API v2: Overview & ExploringWordPress REST API v2: Overview & Exploring
WordPress REST API v2: Overview & Exploring
 
Squeeze Maximum Performance From Your Joomla Website
Squeeze Maximum Performance From Your Joomla WebsiteSqueeze Maximum Performance From Your Joomla Website
Squeeze Maximum Performance From Your Joomla Website
 
How to develope plugin in wordpress: 6 simple steps.
How to develope plugin in wordpress: 6 simple steps.How to develope plugin in wordpress: 6 simple steps.
How to develope plugin in wordpress: 6 simple steps.
 
Hidden Secrets For A Hack-Proof Joomla! Site
Hidden Secrets For A Hack-Proof Joomla! SiteHidden Secrets For A Hack-Proof Joomla! Site
Hidden Secrets For A Hack-Proof Joomla! Site
 
Extending Custom Post Types
Extending Custom Post Types Extending Custom Post Types
Extending Custom Post Types
 
DrupalCon Barcelona 2015
DrupalCon Barcelona 2015DrupalCon Barcelona 2015
DrupalCon Barcelona 2015
 
Doing Things the WordPress Way
Doing Things the WordPress WayDoing Things the WordPress Way
Doing Things the WordPress Way
 

Destacado

eMusic: WordPress in the Enterprise
eMusic: WordPress in the EnterpriseeMusic: WordPress in the Enterprise
eMusic: WordPress in the EnterpriseScott Taylor
 
WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...
WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...
WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...andrewnacin
 
E-commerce & WordPress: Navigating the Minefield
E-commerce & WordPress: Navigating the MinefieldE-commerce & WordPress: Navigating the Minefield
E-commerce & WordPress: Navigating the MinefieldIngenesis Limited
 
Coding, Scaling, and Deploys... Oh My!
Coding, Scaling, and Deploys... Oh My!Coding, Scaling, and Deploys... Oh My!
Coding, Scaling, and Deploys... Oh My!Mark Jaquith
 
Taking WordPress to the World : Options for a Multilingual Site | WordCamp Sa...
Taking WordPress to the World : Options for a Multilingual Site | WordCamp Sa...Taking WordPress to the World : Options for a Multilingual Site | WordCamp Sa...
Taking WordPress to the World : Options for a Multilingual Site | WordCamp Sa...Shannon Smith
 
Don't Repeat Your Mistakes: JavaScript Unit Testing
Don't Repeat Your Mistakes: JavaScript Unit TestingDon't Repeat Your Mistakes: JavaScript Unit Testing
Don't Repeat Your Mistakes: JavaScript Unit Testingaaronjorbin
 
DNS exfiltration using sqlmap
DNS exfiltration using sqlmapDNS exfiltration using sqlmap
DNS exfiltration using sqlmapMiroslav Stampar
 
State of the Word 2016
State of the Word 2016State of the Word 2016
State of the Word 2016photomatt
 
Pushing Python: Building a High Throughput, Low Latency System
Pushing Python: Building a High Throughput, Low Latency SystemPushing Python: Building a High Throughput, Low Latency System
Pushing Python: Building a High Throughput, Low Latency SystemKevin Ballard
 
State of the Word 2015, WordCamp US
State of the Word 2015, WordCamp USState of the Word 2015, WordCamp US
State of the Word 2015, WordCamp USphotomatt
 
Twitter Presentation: #APIConSF
Twitter Presentation: #APIConSFTwitter Presentation: #APIConSF
Twitter Presentation: #APIConSFRyan Choi
 
Time to climb-- results of national study of disadvantaged entrepreneurs ...
Time to climb-- results of national study of disadvantaged entrepreneurs ...Time to climb-- results of national study of disadvantaged entrepreneurs ...
Time to climb-- results of national study of disadvantaged entrepreneurs ...Richard Swart, PhD
 
ColdFusion for Penetration Testers
ColdFusion for Penetration TestersColdFusion for Penetration Testers
ColdFusion for Penetration TestersChris Gates
 
Ako na rýchly web - WordCamp Žilina 2016 - xKatka
Ako na rýchly web - WordCamp Žilina 2016 - xKatkaAko na rýchly web - WordCamp Žilina 2016 - xKatka
Ako na rýchly web - WordCamp Žilina 2016 - xKatkaKatarina Novotna
 
Customize Your WordPress Theme the Right Way
Customize Your WordPress Theme the Right WayCustomize Your WordPress Theme the Right Way
Customize Your WordPress Theme the Right WayDustin Hartzler
 
The power of a video library
The power of a video libraryThe power of a video library
The power of a video libraryLauren Jeffcoat
 
Lecture - (WordPress) Usability Issues
Lecture - (WordPress) Usability IssuesLecture - (WordPress) Usability Issues
Lecture - (WordPress) Usability IssuesRadka Nacheva
 
5-Point Online Marketing Training Regimen
5-Point Online Marketing Training Regimen5-Point Online Marketing Training Regimen
5-Point Online Marketing Training RegimenStoney deGeyter
 
WordCamp Nashville 2016 "Imposter Syndrome'
WordCamp Nashville 2016   "Imposter Syndrome'WordCamp Nashville 2016   "Imposter Syndrome'
WordCamp Nashville 2016 "Imposter Syndrome'Beth Downey
 

Destacado (20)

eMusic: WordPress in the Enterprise
eMusic: WordPress in the EnterpriseeMusic: WordPress in the Enterprise
eMusic: WordPress in the Enterprise
 
WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...
WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...
WordCamp San Francisco 2011: Transients, Caching, and the Complexities of Mul...
 
How Testing Changed My Life
How Testing Changed My LifeHow Testing Changed My Life
How Testing Changed My Life
 
E-commerce & WordPress: Navigating the Minefield
E-commerce & WordPress: Navigating the MinefieldE-commerce & WordPress: Navigating the Minefield
E-commerce & WordPress: Navigating the Minefield
 
Coding, Scaling, and Deploys... Oh My!
Coding, Scaling, and Deploys... Oh My!Coding, Scaling, and Deploys... Oh My!
Coding, Scaling, and Deploys... Oh My!
 
Taking WordPress to the World : Options for a Multilingual Site | WordCamp Sa...
Taking WordPress to the World : Options for a Multilingual Site | WordCamp Sa...Taking WordPress to the World : Options for a Multilingual Site | WordCamp Sa...
Taking WordPress to the World : Options for a Multilingual Site | WordCamp Sa...
 
Don't Repeat Your Mistakes: JavaScript Unit Testing
Don't Repeat Your Mistakes: JavaScript Unit TestingDon't Repeat Your Mistakes: JavaScript Unit Testing
Don't Repeat Your Mistakes: JavaScript Unit Testing
 
DNS exfiltration using sqlmap
DNS exfiltration using sqlmapDNS exfiltration using sqlmap
DNS exfiltration using sqlmap
 
State of the Word 2016
State of the Word 2016State of the Word 2016
State of the Word 2016
 
Pushing Python: Building a High Throughput, Low Latency System
Pushing Python: Building a High Throughput, Low Latency SystemPushing Python: Building a High Throughput, Low Latency System
Pushing Python: Building a High Throughput, Low Latency System
 
State of the Word 2015, WordCamp US
State of the Word 2015, WordCamp USState of the Word 2015, WordCamp US
State of the Word 2015, WordCamp US
 
Twitter Presentation: #APIConSF
Twitter Presentation: #APIConSFTwitter Presentation: #APIConSF
Twitter Presentation: #APIConSF
 
Time to climb-- results of national study of disadvantaged entrepreneurs ...
Time to climb-- results of national study of disadvantaged entrepreneurs ...Time to climb-- results of national study of disadvantaged entrepreneurs ...
Time to climb-- results of national study of disadvantaged entrepreneurs ...
 
ColdFusion for Penetration Testers
ColdFusion for Penetration TestersColdFusion for Penetration Testers
ColdFusion for Penetration Testers
 
Ako na rýchly web - WordCamp Žilina 2016 - xKatka
Ako na rýchly web - WordCamp Žilina 2016 - xKatkaAko na rýchly web - WordCamp Žilina 2016 - xKatka
Ako na rýchly web - WordCamp Žilina 2016 - xKatka
 
Customize Your WordPress Theme the Right Way
Customize Your WordPress Theme the Right WayCustomize Your WordPress Theme the Right Way
Customize Your WordPress Theme the Right Way
 
The power of a video library
The power of a video libraryThe power of a video library
The power of a video library
 
Lecture - (WordPress) Usability Issues
Lecture - (WordPress) Usability IssuesLecture - (WordPress) Usability Issues
Lecture - (WordPress) Usability Issues
 
5-Point Online Marketing Training Regimen
5-Point Online Marketing Training Regimen5-Point Online Marketing Training Regimen
5-Point Online Marketing Training Regimen
 
WordCamp Nashville 2016 "Imposter Syndrome'
WordCamp Nashville 2016   "Imposter Syndrome'WordCamp Nashville 2016   "Imposter Syndrome'
WordCamp Nashville 2016 "Imposter Syndrome'
 

Similar a WordCamp SF 2011: Debugging in WordPress

Debugging - Figuring it out yourself (WordCamp Dublin 2019)
Debugging - Figuring it out yourself (WordCamp Dublin 2019)Debugging - Figuring it out yourself (WordCamp Dublin 2019)
Debugging - Figuring it out yourself (WordCamp Dublin 2019)Damien Carbery
 
Joomla! Day Chicago 2011 Presentation - Steven Pignataro
Joomla! Day Chicago 2011 Presentation - Steven PignataroJoomla! Day Chicago 2011 Presentation - Steven Pignataro
Joomla! Day Chicago 2011 Presentation - Steven PignataroSteven Pignataro
 
Getting started with WordPress development
Getting started with WordPress developmentGetting started with WordPress development
Getting started with WordPress developmentSteve Mortiboy
 
Developers, Be a Bada$$ with WP-CLI
Developers, Be a Bada$$ with WP-CLIDevelopers, Be a Bada$$ with WP-CLI
Developers, Be a Bada$$ with WP-CLIWP Engine
 
Mastering WordPress Vol.1
Mastering WordPress Vol.1Mastering WordPress Vol.1
Mastering WordPress Vol.1Wataru OKAMOTO
 
Here Be Dragons - Debugging WordPress
Here Be Dragons - Debugging WordPressHere Be Dragons - Debugging WordPress
Here Be Dragons - Debugging WordPressRami Sayar
 
WordCamp Belfast DevOps for Beginners
WordCamp Belfast DevOps for BeginnersWordCamp Belfast DevOps for Beginners
WordCamp Belfast DevOps for BeginnersStewart Ritchie
 
Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010
Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010
Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010singingfish
 
Behat - Drupal South 2018
Behat  - Drupal South 2018Behat  - Drupal South 2018
Behat - Drupal South 2018Berend de Boer
 
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
 
How to? Drupal developer toolkit. Dennis Povshedny.
How to? Drupal developer toolkit. Dennis Povshedny.How to? Drupal developer toolkit. Dennis Povshedny.
How to? Drupal developer toolkit. Dennis Povshedny.DrupalCampDN
 
Behavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWestBehavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWestJoshua Warren
 
php-and-zend-framework-getting-started
php-and-zend-framework-getting-startedphp-and-zend-framework-getting-started
php-and-zend-framework-getting-startedtutorialsruby
 

Similar a WordCamp SF 2011: Debugging in WordPress (20)

WPDay Bologna 2013
WPDay Bologna 2013WPDay Bologna 2013
WPDay Bologna 2013
 
Debugging - Figuring it out yourself (WordCamp Dublin 2019)
Debugging - Figuring it out yourself (WordCamp Dublin 2019)Debugging - Figuring it out yourself (WordCamp Dublin 2019)
Debugging - Figuring it out yourself (WordCamp Dublin 2019)
 
Joomla! Day Chicago 2011 Presentation - Steven Pignataro
Joomla! Day Chicago 2011 Presentation - Steven PignataroJoomla! Day Chicago 2011 Presentation - Steven Pignataro
Joomla! Day Chicago 2011 Presentation - Steven Pignataro
 
Getting started with WordPress development
Getting started with WordPress developmentGetting started with WordPress development
Getting started with WordPress development
 
Developers, Be a Bada$$ with WP-CLI
Developers, Be a Bada$$ with WP-CLIDevelopers, Be a Bada$$ with WP-CLI
Developers, Be a Bada$$ with WP-CLI
 
Mastering WordPress Vol.1
Mastering WordPress Vol.1Mastering WordPress Vol.1
Mastering WordPress Vol.1
 
Here Be Dragons - Debugging WordPress
Here Be Dragons - Debugging WordPressHere Be Dragons - Debugging WordPress
Here Be Dragons - Debugging WordPress
 
WordCamp Belfast DevOps for Beginners
WordCamp Belfast DevOps for BeginnersWordCamp Belfast DevOps for Beginners
WordCamp Belfast DevOps for Beginners
 
Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010
Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010
Don't RTFM, WTFM - Open Source Documentation - German Perl Workshop 2010
 
instaling
instalinginstaling
instaling
 
instaling
instalinginstaling
instaling
 
instaling
instalinginstaling
instaling
 
instaling
instalinginstaling
instaling
 
os-php-wiki5-a4
os-php-wiki5-a4os-php-wiki5-a4
os-php-wiki5-a4
 
os-php-wiki5-a4
os-php-wiki5-a4os-php-wiki5-a4
os-php-wiki5-a4
 
Behat - Drupal South 2018
Behat  - Drupal South 2018Behat  - Drupal South 2018
Behat - Drupal South 2018
 
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)
 
How to? Drupal developer toolkit. Dennis Povshedny.
How to? Drupal developer toolkit. Dennis Povshedny.How to? Drupal developer toolkit. Dennis Povshedny.
How to? Drupal developer toolkit. Dennis Povshedny.
 
Behavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWestBehavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWest
 
php-and-zend-framework-getting-started
php-and-zend-framework-getting-startedphp-and-zend-framework-getting-started
php-and-zend-framework-getting-started
 

Más de andrewnacin

Challenges Building the WordPress REST API (API Strategy & Practice, Chicago ...
Challenges Building the WordPress REST API (API Strategy & Practice, Chicago ...Challenges Building the WordPress REST API (API Strategy & Practice, Chicago ...
Challenges Building the WordPress REST API (API Strategy & Practice, Chicago ...andrewnacin
 
WordCamp Netherlands 2012: WordPress in 2012
WordCamp Netherlands 2012: WordPress in 2012WordCamp Netherlands 2012: WordPress in 2012
WordCamp Netherlands 2012: WordPress in 2012andrewnacin
 
You Don't Know Query (WordCamp Netherlands 2012)
You Don't Know Query (WordCamp Netherlands 2012)You Don't Know Query (WordCamp Netherlands 2012)
You Don't Know Query (WordCamp Netherlands 2012)andrewnacin
 
You Don't Know Query - WordCamp Portland 2011
You Don't Know Query - WordCamp Portland 2011You Don't Know Query - WordCamp Portland 2011
You Don't Know Query - WordCamp Portland 2011andrewnacin
 
Open Source (and you can too) - 2011 Teens in Tech Conference
Open Source (and you can too) - 2011 Teens in Tech ConferenceOpen Source (and you can too) - 2011 Teens in Tech Conference
Open Source (and you can too) - 2011 Teens in Tech Conferenceandrewnacin
 
WordCamp Columbus 2011 - What's Next for WordPress
WordCamp Columbus 2011 - What's Next for WordPressWordCamp Columbus 2011 - What's Next for WordPress
WordCamp Columbus 2011 - What's Next for WordPressandrewnacin
 
TEDxYouth@DowntownDC
TEDxYouth@DowntownDCTEDxYouth@DowntownDC
TEDxYouth@DowntownDCandrewnacin
 
Best Practices in Plugin Development (WordCamp Seattle)
Best Practices in Plugin Development (WordCamp Seattle)Best Practices in Plugin Development (WordCamp Seattle)
Best Practices in Plugin Development (WordCamp Seattle)andrewnacin
 
Ask Not What WordPress Can Do For You (Ignite - WordCamp Seattle)
Ask Not What WordPress Can Do For You (Ignite - WordCamp Seattle)Ask Not What WordPress Can Do For You (Ignite - WordCamp Seattle)
Ask Not What WordPress Can Do For You (Ignite - WordCamp Seattle)andrewnacin
 
Hidden Features (WordPress DC)
Hidden Features (WordPress DC)Hidden Features (WordPress DC)
Hidden Features (WordPress DC)andrewnacin
 
Lightning Talk: Mistakes (WordCamp Phoenix 2011)
Lightning Talk: Mistakes (WordCamp Phoenix 2011)Lightning Talk: Mistakes (WordCamp Phoenix 2011)
Lightning Talk: Mistakes (WordCamp Phoenix 2011)andrewnacin
 
WordPress at Web Content Mavens (Jan. 2011)
WordPress at Web Content Mavens (Jan. 2011)WordPress at Web Content Mavens (Jan. 2011)
WordPress at Web Content Mavens (Jan. 2011)andrewnacin
 
WordPress 3.1 at DC PHP
WordPress 3.1 at DC PHPWordPress 3.1 at DC PHP
WordPress 3.1 at DC PHPandrewnacin
 
What's Next for WordPress at WordCamp Netherlands
What's Next for WordPress at WordCamp NetherlandsWhat's Next for WordPress at WordCamp Netherlands
What's Next for WordPress at WordCamp Netherlandsandrewnacin
 
What's Next for WordPress: WordCamp Birmingham 2010
What's Next for WordPress: WordCamp Birmingham 2010What's Next for WordPress: WordCamp Birmingham 2010
What's Next for WordPress: WordCamp Birmingham 2010andrewnacin
 
WordPress 3.0 at DC PHP
WordPress 3.0 at DC PHPWordPress 3.0 at DC PHP
WordPress 3.0 at DC PHPandrewnacin
 
Advanced and Hidden WordPress APIs
Advanced and Hidden WordPress APIsAdvanced and Hidden WordPress APIs
Advanced and Hidden WordPress APIsandrewnacin
 

Más de andrewnacin (17)

Challenges Building the WordPress REST API (API Strategy & Practice, Chicago ...
Challenges Building the WordPress REST API (API Strategy & Practice, Chicago ...Challenges Building the WordPress REST API (API Strategy & Practice, Chicago ...
Challenges Building the WordPress REST API (API Strategy & Practice, Chicago ...
 
WordCamp Netherlands 2012: WordPress in 2012
WordCamp Netherlands 2012: WordPress in 2012WordCamp Netherlands 2012: WordPress in 2012
WordCamp Netherlands 2012: WordPress in 2012
 
You Don't Know Query (WordCamp Netherlands 2012)
You Don't Know Query (WordCamp Netherlands 2012)You Don't Know Query (WordCamp Netherlands 2012)
You Don't Know Query (WordCamp Netherlands 2012)
 
You Don't Know Query - WordCamp Portland 2011
You Don't Know Query - WordCamp Portland 2011You Don't Know Query - WordCamp Portland 2011
You Don't Know Query - WordCamp Portland 2011
 
Open Source (and you can too) - 2011 Teens in Tech Conference
Open Source (and you can too) - 2011 Teens in Tech ConferenceOpen Source (and you can too) - 2011 Teens in Tech Conference
Open Source (and you can too) - 2011 Teens in Tech Conference
 
WordCamp Columbus 2011 - What's Next for WordPress
WordCamp Columbus 2011 - What's Next for WordPressWordCamp Columbus 2011 - What's Next for WordPress
WordCamp Columbus 2011 - What's Next for WordPress
 
TEDxYouth@DowntownDC
TEDxYouth@DowntownDCTEDxYouth@DowntownDC
TEDxYouth@DowntownDC
 
Best Practices in Plugin Development (WordCamp Seattle)
Best Practices in Plugin Development (WordCamp Seattle)Best Practices in Plugin Development (WordCamp Seattle)
Best Practices in Plugin Development (WordCamp Seattle)
 
Ask Not What WordPress Can Do For You (Ignite - WordCamp Seattle)
Ask Not What WordPress Can Do For You (Ignite - WordCamp Seattle)Ask Not What WordPress Can Do For You (Ignite - WordCamp Seattle)
Ask Not What WordPress Can Do For You (Ignite - WordCamp Seattle)
 
Hidden Features (WordPress DC)
Hidden Features (WordPress DC)Hidden Features (WordPress DC)
Hidden Features (WordPress DC)
 
Lightning Talk: Mistakes (WordCamp Phoenix 2011)
Lightning Talk: Mistakes (WordCamp Phoenix 2011)Lightning Talk: Mistakes (WordCamp Phoenix 2011)
Lightning Talk: Mistakes (WordCamp Phoenix 2011)
 
WordPress at Web Content Mavens (Jan. 2011)
WordPress at Web Content Mavens (Jan. 2011)WordPress at Web Content Mavens (Jan. 2011)
WordPress at Web Content Mavens (Jan. 2011)
 
WordPress 3.1 at DC PHP
WordPress 3.1 at DC PHPWordPress 3.1 at DC PHP
WordPress 3.1 at DC PHP
 
What's Next for WordPress at WordCamp Netherlands
What's Next for WordPress at WordCamp NetherlandsWhat's Next for WordPress at WordCamp Netherlands
What's Next for WordPress at WordCamp Netherlands
 
What's Next for WordPress: WordCamp Birmingham 2010
What's Next for WordPress: WordCamp Birmingham 2010What's Next for WordPress: WordCamp Birmingham 2010
What's Next for WordPress: WordCamp Birmingham 2010
 
WordPress 3.0 at DC PHP
WordPress 3.0 at DC PHPWordPress 3.0 at DC PHP
WordPress 3.0 at DC PHP
 
Advanced and Hidden WordPress APIs
Advanced and Hidden WordPress APIsAdvanced and Hidden WordPress APIs
Advanced and Hidden WordPress APIs
 

Último

Introducing the Analogic framework for business planning applications
Introducing the Analogic framework for business planning applicationsIntroducing the Analogic framework for business planning applications
Introducing the Analogic framework for business planning applicationsKnowledgeSeed
 
How Generative AI Is Transforming Your Business | Byond Growth Insights | Apr...
How Generative AI Is Transforming Your Business | Byond Growth Insights | Apr...How Generative AI Is Transforming Your Business | Byond Growth Insights | Apr...
How Generative AI Is Transforming Your Business | Byond Growth Insights | Apr...Hector Del Castillo, CPM, CPMM
 
Planetary and Vedic Yagyas Bring Positive Impacts in Life
Planetary and Vedic Yagyas Bring Positive Impacts in LifePlanetary and Vedic Yagyas Bring Positive Impacts in Life
Planetary and Vedic Yagyas Bring Positive Impacts in LifeBhavana Pujan Kendra
 
How To Simplify Your Scheduling with AI Calendarfly The Hassle-Free Online Bo...
How To Simplify Your Scheduling with AI Calendarfly The Hassle-Free Online Bo...How To Simplify Your Scheduling with AI Calendarfly The Hassle-Free Online Bo...
How To Simplify Your Scheduling with AI Calendarfly The Hassle-Free Online Bo...SOFTTECHHUB
 
WSMM Media and Entertainment Feb_March_Final.pdf
WSMM Media and Entertainment Feb_March_Final.pdfWSMM Media and Entertainment Feb_March_Final.pdf
WSMM Media and Entertainment Feb_March_Final.pdfJamesConcepcion7
 
Interoperability and ecosystems: Assembling the industrial metaverse
Interoperability and ecosystems:  Assembling the industrial metaverseInteroperability and ecosystems:  Assembling the industrial metaverse
Interoperability and ecosystems: Assembling the industrial metaverseSiemens
 
EUDR Info Meeting Ethiopian coffee exporters
EUDR Info Meeting Ethiopian coffee exportersEUDR Info Meeting Ethiopian coffee exporters
EUDR Info Meeting Ethiopian coffee exportersPeter Horsten
 
Traction part 2 - EOS Model JAX Bridges.
Traction part 2 - EOS Model JAX Bridges.Traction part 2 - EOS Model JAX Bridges.
Traction part 2 - EOS Model JAX Bridges.Anamaria Contreras
 
WSMM Technology February.March Newsletter_vF.pdf
WSMM Technology February.March Newsletter_vF.pdfWSMM Technology February.March Newsletter_vF.pdf
WSMM Technology February.March Newsletter_vF.pdfJamesConcepcion7
 
The McKinsey 7S Framework: A Holistic Approach to Harmonizing All Parts of th...
The McKinsey 7S Framework: A Holistic Approach to Harmonizing All Parts of th...The McKinsey 7S Framework: A Holistic Approach to Harmonizing All Parts of th...
The McKinsey 7S Framework: A Holistic Approach to Harmonizing All Parts of th...Operational Excellence Consulting
 
NAB Show Exhibitor List 2024 - Exhibitors Data
NAB Show Exhibitor List 2024 - Exhibitors DataNAB Show Exhibitor List 2024 - Exhibitors Data
NAB Show Exhibitor List 2024 - Exhibitors DataExhibitors Data
 
trending-flavors-and-ingredients-in-salty-snacks-us-2024_Redacted-V2.pdf
trending-flavors-and-ingredients-in-salty-snacks-us-2024_Redacted-V2.pdftrending-flavors-and-ingredients-in-salty-snacks-us-2024_Redacted-V2.pdf
trending-flavors-and-ingredients-in-salty-snacks-us-2024_Redacted-V2.pdfMintel Group
 
Guide Complete Set of Residential Architectural Drawings PDF
Guide Complete Set of Residential Architectural Drawings PDFGuide Complete Set of Residential Architectural Drawings PDF
Guide Complete Set of Residential Architectural Drawings PDFChandresh Chudasama
 
Excvation Safety for safety officers reference
Excvation Safety for safety officers referenceExcvation Safety for safety officers reference
Excvation Safety for safety officers referencessuser2c065e
 
business environment micro environment macro environment.pptx
business environment micro environment macro environment.pptxbusiness environment micro environment macro environment.pptx
business environment micro environment macro environment.pptxShruti Mittal
 
Darshan Hiranandani [News About Next CEO].pdf
Darshan Hiranandani [News About Next CEO].pdfDarshan Hiranandani [News About Next CEO].pdf
Darshan Hiranandani [News About Next CEO].pdfShashank Mehta
 
Driving Business Impact for PMs with Jon Harmer
Driving Business Impact for PMs with Jon HarmerDriving Business Impact for PMs with Jon Harmer
Driving Business Impact for PMs with Jon HarmerAggregage
 
Cyber Security Training in Office Environment
Cyber Security Training in Office EnvironmentCyber Security Training in Office Environment
Cyber Security Training in Office Environmentelijahj01012
 

Último (20)

Introducing the Analogic framework for business planning applications
Introducing the Analogic framework for business planning applicationsIntroducing the Analogic framework for business planning applications
Introducing the Analogic framework for business planning applications
 
How Generative AI Is Transforming Your Business | Byond Growth Insights | Apr...
How Generative AI Is Transforming Your Business | Byond Growth Insights | Apr...How Generative AI Is Transforming Your Business | Byond Growth Insights | Apr...
How Generative AI Is Transforming Your Business | Byond Growth Insights | Apr...
 
Planetary and Vedic Yagyas Bring Positive Impacts in Life
Planetary and Vedic Yagyas Bring Positive Impacts in LifePlanetary and Vedic Yagyas Bring Positive Impacts in Life
Planetary and Vedic Yagyas Bring Positive Impacts in Life
 
WAM Corporate Presentation April 12 2024.pdf
WAM Corporate Presentation April 12 2024.pdfWAM Corporate Presentation April 12 2024.pdf
WAM Corporate Presentation April 12 2024.pdf
 
The Bizz Quiz-E-Summit-E-Cell-IITPatna.pptx
The Bizz Quiz-E-Summit-E-Cell-IITPatna.pptxThe Bizz Quiz-E-Summit-E-Cell-IITPatna.pptx
The Bizz Quiz-E-Summit-E-Cell-IITPatna.pptx
 
How To Simplify Your Scheduling with AI Calendarfly The Hassle-Free Online Bo...
How To Simplify Your Scheduling with AI Calendarfly The Hassle-Free Online Bo...How To Simplify Your Scheduling with AI Calendarfly The Hassle-Free Online Bo...
How To Simplify Your Scheduling with AI Calendarfly The Hassle-Free Online Bo...
 
WSMM Media and Entertainment Feb_March_Final.pdf
WSMM Media and Entertainment Feb_March_Final.pdfWSMM Media and Entertainment Feb_March_Final.pdf
WSMM Media and Entertainment Feb_March_Final.pdf
 
Interoperability and ecosystems: Assembling the industrial metaverse
Interoperability and ecosystems:  Assembling the industrial metaverseInteroperability and ecosystems:  Assembling the industrial metaverse
Interoperability and ecosystems: Assembling the industrial metaverse
 
EUDR Info Meeting Ethiopian coffee exporters
EUDR Info Meeting Ethiopian coffee exportersEUDR Info Meeting Ethiopian coffee exporters
EUDR Info Meeting Ethiopian coffee exporters
 
Traction part 2 - EOS Model JAX Bridges.
Traction part 2 - EOS Model JAX Bridges.Traction part 2 - EOS Model JAX Bridges.
Traction part 2 - EOS Model JAX Bridges.
 
WSMM Technology February.March Newsletter_vF.pdf
WSMM Technology February.March Newsletter_vF.pdfWSMM Technology February.March Newsletter_vF.pdf
WSMM Technology February.March Newsletter_vF.pdf
 
The McKinsey 7S Framework: A Holistic Approach to Harmonizing All Parts of th...
The McKinsey 7S Framework: A Holistic Approach to Harmonizing All Parts of th...The McKinsey 7S Framework: A Holistic Approach to Harmonizing All Parts of th...
The McKinsey 7S Framework: A Holistic Approach to Harmonizing All Parts of th...
 
NAB Show Exhibitor List 2024 - Exhibitors Data
NAB Show Exhibitor List 2024 - Exhibitors DataNAB Show Exhibitor List 2024 - Exhibitors Data
NAB Show Exhibitor List 2024 - Exhibitors Data
 
trending-flavors-and-ingredients-in-salty-snacks-us-2024_Redacted-V2.pdf
trending-flavors-and-ingredients-in-salty-snacks-us-2024_Redacted-V2.pdftrending-flavors-and-ingredients-in-salty-snacks-us-2024_Redacted-V2.pdf
trending-flavors-and-ingredients-in-salty-snacks-us-2024_Redacted-V2.pdf
 
Guide Complete Set of Residential Architectural Drawings PDF
Guide Complete Set of Residential Architectural Drawings PDFGuide Complete Set of Residential Architectural Drawings PDF
Guide Complete Set of Residential Architectural Drawings PDF
 
Excvation Safety for safety officers reference
Excvation Safety for safety officers referenceExcvation Safety for safety officers reference
Excvation Safety for safety officers reference
 
business environment micro environment macro environment.pptx
business environment micro environment macro environment.pptxbusiness environment micro environment macro environment.pptx
business environment micro environment macro environment.pptx
 
Darshan Hiranandani [News About Next CEO].pdf
Darshan Hiranandani [News About Next CEO].pdfDarshan Hiranandani [News About Next CEO].pdf
Darshan Hiranandani [News About Next CEO].pdf
 
Driving Business Impact for PMs with Jon Harmer
Driving Business Impact for PMs with Jon HarmerDriving Business Impact for PMs with Jon Harmer
Driving Business Impact for PMs with Jon Harmer
 
Cyber Security Training in Office Environment
Cyber Security Training in Office EnvironmentCyber Security Training in Office Environment
Cyber Security Training in Office Environment
 

WordCamp SF 2011: Debugging in WordPress

  • 1. Debugging in WordPress WordCamp San Francisco 2011 August 13, 2011
  • 2. Andrew Nacin Core Developer of WordPress Tech Ninja at Audrey Capital nacin@wordpress.org @nacin on Twitter
  • 3. var_dump( $data ); die( ); // fin.
  • 4. “I love suppressing error messages!” — no one, ever.
  • 5. So let's start with WP_DEBUG define( 'WP_DEBUG', true );
  • 6. What WP_DEBUG does: — Sets the error reporting level to include PHP notices — Bypasses some error suppression — Triggers notices for deprecated usage (more on that later)
  • 7. You can change its output: // A default of true forces on display_errors. define( 'WP_DEBUG_DISPLAY', true ); // Setting it to false will let PHP (php.ini) decide. define( 'WP_DEBUG_DISPLAY', false ); // So, if your php.ini has display_errors on, you'll also need to turn it off: ini_set( 'display_errors', 0 );
  • 8. Likely being simplified in 3.3: // A default of true forces on display_errors. define( 'WP_DEBUG_DISPLAY', true ); // False forces off display_errors. define( 'WP_DEBUG_DISPLAY', false ); // Null will let PHP (php.ini) decide. define( 'WP_DEBUG_DISPLAY', null );
  • 9. You can specify an error log: // wp-content/debug.log define( 'WP_DEBUG_LOG', true ); // New in 3.3! (Likely.) define( 'WP_DEBUG_LOG', '/tmp/php-errors' ); // Follow ticket #18391, created last night.
  • 10. Debug admin CSS & JS with SCRIPT_DEBUG define( 'SCRIPT_DEBUG', true );
  • 11. SCRIPT_DEBUG prevents minification and concatenation of core scripts and styles. load-scripts.php?c=1&load=global,wp-admin,ms… versus global.dev.css, wp-admin.dev.css, ms.dev.css
  • 12. SCRIPT_DEBUG is good for: — Finding bugs in your admin screens — Studying the admin theme — Contributing to core
  • 13. Debug queries with SAVEQUERIES define( 'SAVEQUERIES', true );
  • 14. SAVEQUERIES stores query data in $wpdb->queries. (OMG BBQ: This is NOT for production.)
  • 15. Query: SELECT * FROM wp_users WHERE user_login = 'nacin' Backtrace: WP->init, wp_get_current_user, get_currentuserinfo, wp_validate_auth_cookie, get_user_by Execution time: 0.4ms
  • 16. On using these in production: WP_DEBUG — Don't display errors — Don't log to wp-content/error.log SCRIPT_DEBUG — Bad idea. SAVEQUERIES — Barry will hunt you down.
  • 18. Your new best friend: The Debug Bar It’s like Firebug for your WordPress.
  • 19. Debug Bar Console A Firebug-like console for PHP and MySQL (really)
  • 20. What's stopping you from building your own Debug Bar extension? Nothing.
  • 21. Log Deprecated Notices — Logs the usage of deprecated files, functions, and function arguments. — Pinpoints where the deprecated functionality is being used. — NEVER use in production.
  • 22. Theme Check — Test your theme for the latest WordPress standards and practices. — Required for the theme directory.
  • 23. Common functions when debugging — error_log and var_export / print_r — var_dump and sometimes die — debug_backtrace
  • 25. Step 1 Disable plugins Switch to default theme
  • 26. What might be left behind? Cron, Rewrites, Roles/Capabilities
  • 27. Drop-ins — advanced-cache.php — db.php — object-cache.php — mu-plugins
  • 28. What's going on? Query vars set properly? Main query SQL look right? Rewrite rule matched?
  • 29. Funny redirect? Confirm it's canonical. remove_action( 'template_redirect', 'redirect_canonical' );
  • 30. Testing multisite? I leave this in my config: // define( 'MULTISITE', true );
  • 31. Dig into the codebase. Your friends are phpxref, grep. Learn the stack. Learn what things call what.
  • 33. Step 1 Is your code even running? (Spell the hook right?) die( 'wtf' ); or error_log( )
  • 34. White screen on the frontend, no errors? Appearance > Themes
  • 35. User interface doesn't work? Check the browser's JS console for an error, usually a conflict.
  • 36. Internal server errors? Infinite redirects. Check: — home and siteurl — then .htaccess — then canonical
  • 37. Widgets got moved around? Do the sidebars have IDs? Otherwise, it's the order in which register_sidebar() is called.
  • 38. Lots of pages? Slow site? My next Q: What's your permalink structure? No longer an issue in 3.3!
  • 39. Weird Bug #1 Somewhere deep in style.css: “Template: home.php” Miscalculated as a multisite bug: activated on single site before style.css had the headers.
  • 40. Weird Bug #2 The admin looked weird
  • 41. Weird Bug #2 The admin looked weird Trigger: Upgrade from 2.5 to 3.1
  • 42. Weird Bug #2 The admin looked weird Trigger: Upgrade from 2.5 to 3.1 Problem: No MySQL ALTER permissions
  • 43. Weird Bug #3 Some bbPress rewrites failed after activation
  • 44. Weird Bug #3 Some bbPress rewrites failed after activation Problem: Custom post type rewrites aren't registered on activation
  • 45. // Say you have: add_action( 'generate_rewrite_rules', function( $wp_rewrite ) { … } ); // And: register_activation_hook( __FILE__, function() { flush_rewrite_rules( ); } ); // But! This won't work for CPTs. Try this: add_action( 'init', 'my_register_post_types' ); register_activation_hook( __FILE__, function( ) { my_register_post_types( ); flush_rewrite_rules( ); } );
  • 48. Replace links with an output buffer for development or staging environments
  • 49. // Run this on development or staging. // A development wp-config.php or local-config.php is fine. ob_start( 'nacin_dev_urls' ); function nacin_dev_urls( $buffer ) { $live = 'http://andrewnacin.com'; $dev = 'http://dev.andrewnacin.com'; return str_replace( $live, $dev, $buffer ); }
  • 50. URLs are more portable when they're absolute. Really.* The serialized stuff is lame though.
  • 51. Start of a conversation Xdebug (backtraces, profiling) KCacheGrind (visualization) Using an IDE Unit testing
  • 52. And finally, remember: Friends don't let friends develop without WP_DEBUG.