[theme-reviewers] Questions about ticket no. 2811

Otto otto at ottodestruct.com
Tue May 24 18:16:41 UTC 2011

On Tue, May 24, 2011 at 12:32 PM, Angelo Bertolli
<angelo.bertolli at gmail.com> wrote:
> (1) So my first question isn't a problem but... why are we required to
> include a comments.php file?  I removed my comments.php file for
> simplicity after I learned that WordPress automatically inserts the
> comment code when there isn't one.  It seemed better to default to WP's
> default functionality.  But when I tried to upload, it was automatically
> rejected.

WP's comments.php file is there for backward compatibility. It really
shouldn't be used as a crutch to avoid making a proper theme. If you
want, just copy the default comments.php file into your theme.

The point is that a theme should be reasonably complete, and not
dependent on functionality that may change or go away in the future.
The backwards compatible default templates will very likely go away at
some future point which is ill-defined.

> (2) I'm in some general confusion about the other errors...
> => Undefined variable: text_domain in \themes\dragonskin\functions.php
> on line 11
> => Undefined variable: text_domain in \themes\dragonskin\functions.php
> on line 12
> This code is straight from the WordPress documentation on:
> http://codex.wordpress.org/Function_Reference/dynamic_sidebar

The wiki provides examples, and not all of them are meant to be taken
as literal working code. A lot of the pages assume you know PHP in
general and some of the basics of WordPress in specific.

The underlying problem is that you haven't defined your text_domain
variable. The text domain bits are used if you make your theme capable
of internationalization. See this for more info:

> => Undefined property: stdClass::$user_url in
> \themes\dragonskin\single.php on line 34
> It is defined here (and works):
> http://codex.wordpress.org/Author_Templates#Custom_Author_Information

That page is referring to Author Templates. The single.php file is not
an Author Template, it's the Single Post template. That particular
code won't work on that template.

> The rest seem like errors generated resultant from previous issues.
> => Undefined index: action in \themes\dragonskin\functions.php on line 97
> => Undefined index: action in \themes\dragonskin\functions.php on line 108
> => Undefined index: saved in \themes\dragonskin\functions.php on line 127
> => Undefined index: reset in \themes\dragonskin\functions.php on line 128

Whenever you check something like $_REQUEST['action'] or something
like that, it's best to check if it's actually set first. This avoids
the PHP "Notice" when you put it in debug mode. It's common practice
to not bother, but still, that's where the warnings come from.

So instead of this:
if ( 'save' == $_REQUEST['action'] ) {

You'd do something like this:
if ( isset($_REQUEST['action']) && 'save' == $_REQUEST['action'] ) {

It's not actually required to fix notices, I don't think, but it is
good practice. Having notices makes it less obvious where real errors
are, and harder to debug.

> => Undefined index: sidebar-1 in
> C:\xampp\htdocs\wp\wp-includes\widgets.php on line 954
> => Undefined index: top-menu in
> C:\xampp\htdocs\wp\wp-includes\widgets.php on line 954

You can ignore any notices that are generated from wp's own files. WP
itself isn't perfect in this respect. However, it's good to look at
these notices and see if they result from you possibly using a
function incorrectly. I don't think they do in this case.

> But I followed the directions on the WordPress Codex, I believe.

Never trust any source of information completely. The codex is a wiki,
edited by volunteers or anybody who happens to notice something and
correct or add it. It is not actively maintained, really. So
information in it may be incomplete, out-of-date, or unevenly edited.
Sometimes, it's just plain wrong. It's a resource, and it's a good
one, but it is not the end-all-be-all of correctness or information.

The best place to figure something out is to read the source code of
WordPress itself. Really. It can't be mistaken.


More information about the theme-reviewers mailing list