Wordpress theme check/debug


#1

How can I debug a Wordpress theme? I’m trying to debug/check for deprecated(forbiden) functions etc. I have installed Theme Check Plugin but looks like itself is broken and does not work.

ThemeCheck plugin return me 1xxxxx lines of notices(errors) and a fatal error to the end(Fatal error: Maximum execution time of 30 seconds exceeded in D:\xampp\htdocs\wordpress342\wp-content\plugins\theme-check\checks\i18n.php on line 28). Anyway this is not the problem.

Which plugins do you use to check your themes for errors? Please advice. :slight_smile:


#2

Enable WP_DEBUG and fix all the notices and warnings

  • Debug Bar Cron
  • Log Deprecated Notices
  • Monster Widget

    ** Theme Check

#3

If Theme Check itself isn’t working, trying disabling all plugins and using the default theme, and then gradually re-enable things to see which is breaking the site.


#4
Smartik said

ThemeCheck plugin return me 1xxxxx lines of notices(errors) and a fatal error to the end(Fatal error: Maximum execution time of 30 seconds exceeded in D:\xampp\htdocs\wordpress342\wp-content\plugins\theme-check\checks\i18n.php on line 28). Anyway this is not the problem.

I’ve experienced this strange one before. After countless hours investigation, I found the issue came from bad written code in one line!!! I need to move the files on my theme and then include it one by one to find the culprit. Sorry, I couldn’t share the example, I forgot to save it… :frowning:

Right now, every time I make small changes to my code, I always test it using Theme Check, to make sure it doesn’t happen to me again in the future…


#5

Thanks for replies. I appreciate that.

I forgot to say that my theme works perfectly, I always have WP_DEBUG enabled and I have 0 warnings/notices even on a clean instalation. Looks like I did a mistake somewhere, that’s why ThemeCheck plugin does not work.( http://wordpress.org/support/topic/plugin-theme-check-notice-uninitialized-string-offset-7952-in-i18nphp-on-line-27 ).


#6

Hi,

I have the same issue.

PrimaThemes can you tell us which line of code it was? It might be the same issue for me. What would be the best way to investigate which theme code could be causing this?

Thanks in advance!


#7

I think is a good idea to answer my own question with a solution since I found it.

The problem was that I had html tags inside of translation functions.
Example:

_e('<strong>Here is my text to translate.</strong>','text_domain')

changed to this:

echo '<strong>'. _e('Here is my text to translate.','text_domain') .'</strong>';

:whistle:


#8

Excellent work finding that! Thanks for posting the solution too :slight_smile:


#9

Post a bit old but I think it’s important to say.
I’m developing my first premium theme and I had the same issue.
The problem was related to translation functions too. In this case, an open parenthesis.

_e('Sorry =(  I dont have any posts with: ', 'text_domain')

That face =( was creating the problem. So I got rid of it. Now it’s just:

_e('Sorry , I dont have any posts with: ', 'text_domain')

#10
Smartik said

I think is a good idea to answer my own question with a solution since I found it.

The problem was that I had html tags inside of translation functions.
Example:

_e('<strong>Here is my text to translate.</strong>','text_domain')

changed to this:

echo '<strong>'. _e('Here is my text to translate.','text_domain') .'</strong>';

:whistle:

You should not use _e under echo (use __()):

echo '<strong>'. __('Here is my text to translate.','text_domain') .'</strong>';

#11

Just thought I would chime in :smiley:

I have used html within our translation a few times,

Our latest we accidently used:

__("<li>Please enter an e-mail address.</li>","textdomain");

We had this there for about a month until a buyer pointed it out, then we changed it, this was a mistake but it still worked.

The only difference I have is that I have used double quotes which may or may not be making it work.

**** EDIT ****

Envato please sort our the pre tags, it drives me made that you can not use them correctly within comments and forums :frowning:

I have had to show code with the html name instead of the < etc etc. :frowning:

A simple algorithm sorts this out


#12

I got the same problem with theme check plugin.

But I found that it’s not my theme, it’s node_module folder of grunt. When I removed it, theme check worked well. I guess that it’s related to translation string. Hope my solution can help other people.


#13
haintheme said

I got the same problem with theme check plugin.

But I found that it’s not my theme, it’s node_module folder of grunt. When I removed it, theme check worked well. I guess that it’s related to translation string. Hope my solution can help other people.

In some ways, it makes the most sense to use Theme Check to test a theme that’s been prepared for release, rather than while it’s still in development. (e.g. the build rather than the src.)

So you wouldn’t have node_modules in build anyway.


#14
Japh said
haintheme said

I got the same problem with theme check plugin.

But I found that it’s not my theme, it’s node_module folder of grunt. When I removed it, theme check worked well. I guess that it’s related to translation string. Hope my solution can help other people.

In some ways, it makes the most sense to use Theme Check to test a theme that’s been prepared for release, rather than while it’s still in development. (e.g. the build rather than the src.)

So you wouldn’t have node_modules in build anyway.

Yes, you're right. I will create 2 branch, 1 for development, another for production. :)