WordPress Debugging Tips and Tricks

Preview:

Citation preview

WordPress Debugging Tips and Tricks

KEANAN KOPPENHAVER

KEANAN@DOEJO.COM

! @KKOPPENHAVER

This is one of those audience participation

talks.

Step 1: Identify the problem

Step 2: Find the cause

Step 3: Find the solution

Step 4: Repeat

Part 1 | Front End

What are Dev Tools?

(Spoiler Alert: They help with debugging

step 2)

Developer Tools

• Bundled with most major browsers (Chrome, Firefox, Safari)

• Allow you to inspect elements, console, network traffic and much more

• You can even code in dev tools (please don’t)

Demo: Chrome Dev Tools

Bonus Tip: Safari Dev Tools work with iOS

simulator

Part 2 | Back End

if ( $env == ‘development’ ) { PLEASE USE WP_DEBUG; (or WP_DEBUG_LOG) }

Query Monitor

• Dev plugin runs in the background on every page when enabled

• You can monitor much more than queries…

• Hooks, theme info, request info, oh my!

Demo: Query Monitor

Let’s talk about server logs

[03-May-2016 21:12:56 UTC] PHP Fatal error: Uncaught Error: Cannot use object of type stdClass as array in /Users/doejo/code/Dev/wordpress/wp-content/themes/clientname/lib/admin-helpers.php:303 Stack trace: #0 /Users/doejo/code/Dev/wordpress/wp-includes/plugin.php(525): Roots\Sage\Extras\restrict_adding_tags('') #1 /Users/doejo/code/Dev/wordpress/wp-settings.php(393): do_action('init') #2 /Users/doejo/code/Dev/wordpress/wp-config.php(85): require_once('/Users/doejo/co...') #3 /Users/doejo/code/Dev/wordpress/wp-load.php(37): require_once('/Users/doejo/co...') #4 /Users/doejo/code/Dev/wordpress/wp-admin/admin.php(31): require_once('/Users/doejo/co...') #5 /Users/doejo/code/Dev/wordpress/wp-admin/post.php(12): require_once('/Users/doejo/co...') #6 {main} thrown in /Users/doejo/code/Dev/wordpress/wp-content/themes/clientname/lib/admin-helpers.php on line 303

[03-May-2016 21:12:56 UTC] PHP Fatal error: Uncaught Error: Cannot use object of type stdClass as array in /Users/doejo/code/Dev/wordpress/wp-content/themes/clientname/lib/admin-helpers.php:303

Questions?KEANAN KOPPENHAVER

KEANAN@DOEJO.COM

! @KKOPPENHAVER

Recommended