![]() |
How To Debug Your WordPress Upgrade By Alister CameronThis week I upgraded a new client's WordPress blog from version 2.6 to 2.9.2. All went just dandy. Then today he emailed me to say that he'd noticed his post excerpts were not appearing where they were supposed to, in single post pages. On closer inspection I noticed that the excerpts displayed fine on the homepage, but - despite the same exact code being used - they weren't showing up on single post pages. In both cases the the_excerpt() function was being used without parameters. Weird.How would you go about debugging this one? My immediate thought was to blame a plugin. Why? Because WordPress's great coding strength is also its weakness - hooks and filters give plugin authors the ability to mess with the output of "core" WordPress functions. But it's really hard to tell if any messing around is going on, in order to debug problems. Question then: how do you figure out if one or more plugins is using a hook/filter to mess with the output of a given WordPress function? If you have shell access to your WordPress host I've got a little treasure for you today. A simple enough shell command that will make your life a lot easier. (If you're a "real" programmer you'll almost certainly know about this already, but if you're not, you're gonna love it!) Now, shell access (SSH) gives you "command-line" control of the operating system on which your WordPress blog resides. If your hosting provider has given that to you and you know how to use it, you can do cool stuff like ZIP up all the content in one hit so you can back it up really easily, say. Lots of fun to be had. Today I want to show you how to return search results for all the instances where a certain string appears in your plugins' PHP files. That's how we're going to debug my problem with the Here's the command to run at your SSH prompt when you've navigated into your wp-content/plugins directory:
(Note that on older systems that last plus sign might need to be replaced with a semicolon ";".) That command simply isolates all php files and searches through each in turn for each occurrence of "mystringhere". For each occurrence it finds, it shows you that line of code preceded by the filename and line number. Easy! Because I don't like the black and white of my Terminal application, I then copy out all the results found into my code editor, so that I get to see the code in all the pretty colours that Coda puts it in. That's up to you. For purposes of example, here are the results I got from my client's plugin directory(pops up a new window). Yes it looks like a huge mess, but you can see now that it's really easy for me, in my code editor, to search through all that for "add_filter" and "add_action", to see where any plugin is messing with the output of the About the author: Alister Cameron is an accomplished web designer and internet marketing consultant who turns established subject-matter experts into expert bloggers. Alister's clients are using blogging and social media to leverage their offline expertise in the online world, and engage Alister to build their blogging platform or social network; to train them in writing and online marketing strategy; and to help them stay up with the latest developments in blogging and online marketing. Alister's blog is a rich tapestry of advice, anecdotes and reflections from the frontline of professional blogging, social media and search engine marketing, and never without generous dollops of humor and wit. | |||||||||
|
-- DevWebProAU is an iEntry, Inc. publication -- iEntry, Inc. 2549 Richmond Rd. Lexington KY, 40509 2010 iEntry, Inc. All Rights Reserved Privacy Policy Legal
|