Android Upgrade In Progress Samsung Galaxy S2
Google Android OS upgrading in progress, visible via Samsung Galaxy S 2 device.

Fixing an older WordPress theme with the help of Theme Check

The Theme Check plugin is a valuable tool for a developer that wishes to migrate any older WordPress themes or just to check their quality of compliance with the Theme Review guidelines.

Once installed and enabled, the Theme Check plugin is available in the address /wp-admin/themes.php?page=themecheck of the given WordPress installation.

Missing license

Messages such as:

REQUIRED:License: is missing from your style.css header.
REQUIRED:License URI: is missing from your style.css header.

Select a suitable license from the open source license list and add its name and URI to the heading comment of style.css:

License: MIT
License URI: http://opensource.org/licenses/MIT

Missing CSS classes

REQUIRED:.gallery-caption css class is needed in your theme css.
REQUIRED:.bypostauthor css class is needed in your theme css.

The gallery-caption class is used on media galleries, as the name implies.

The bypostauthor class is used to mark a comment author when the given user was also the author of the post.

These two issues can be fixed just by adding the given CSS selectors in the styles.css, with some styles that are consistent with the other styles defined for this theme.

.gallery-caption {
  color: #D70807;
}

.bypostauthor {
  font-weight: 600;
}

Registration for a hook missing

REQUIRED: Sidebars need to be registered in a custom function hooked to the widgets_init action. See: register_sidebar().

The given hooks are described in the Widgets API documentation.

Existing code:

if ( function_exists('register_sidebar') )
    register_sidebar(array(
        'before_widget' => '<li id="%1$s" class="widget %2$s">',
        'after_widget' => '</li>',
        'before_title' => '',
        'after_title' => '',
    ));

Changed to:

function stardust_register_sidebar() {
    register_sidebar(array(
        'before_widget' => '<li id="%1$s" class="widget %2$s">',
        'after_widget' => '</li>',
        'before_title' => '',
        'after_title' => '',
    ));
}
add_action('widgets_init', 'stardust_register_sidebar');

The register_sidebar method used in the above example is described in its Function Reference/register sidebar.

Missing text domain

RECOMMENDED: Text domain problems in sidebar.php. You have not included a text domain!

Line 7: <?php wp_list_pages('title_li=' . __('Pages:')); ?>

Line 11: <li id='meta'><?php _e('Meta:'); ?>

Find the occurrences of any localisation related methods with a regular expression:

(_[_ex])\((['"](.+?)['"])\)

and use the back references to add text domain, for example when the domain is stardust:

$1($2, 'stardust')

This will not exclude those use cases where the domain has already been used.

In case the text domain name is not easily guessed, it can be found by looking for calls to the load_theme_textdomain method.

Blog info references

REQUIRED: bloginfo('url') was found in the file header.php.
  Use echo esc_url( home_url() ) instead.
REQUIRED: bloginfo('template_url') was found in the file searchform.php.
  Use echo esc_url( get_template_directory_uri() ) instead.
RECOMMENDED: bloginfo(url) was found in the file header.php.
  Use echo home_url() instead.
RECOMMENDED: bloginfo(template_url) was found in the file header.php.
  Use get_template_directory_uri() instead.

For some reason these bloginfo usages come out twice, first as REQUIRED and then as RECOMMENDED. Anyhow they are pretty trivial to change as the recommendation contains the fix.

Other important stuff

WARNING: The flexible-width and fixed-width tags changed to fluid-layout and fixed-layout tags in WordPress 3.8.
  Additionally, the responsive-layout tag was added. Please change to using one of the new tags.

The description of the theme contains tags which are used on the WordPress Theme web site where the given tags help users to find suitable themes for their purposes. The description of this issue contains the fix, renaming the tags in question.

REQUIRED: The <title> tags can only contain a call to wp_title(). Use the wp_title filter to modify the output

As the description suggests, the <title> element should only contain a call to the wp_title() method. Perhaps in the past the given method did not contain the blog name, thus it was added in this case and thus creating the issue.

REQUIRED: Could not find comment_form. See: comment_form

The theme might have removed all comment related functionality in the hope of removing the commenting system from the site. The given error message is about not finding the use of comment_form method, which is [described in the template API documentation][comment_form]

RECOMMENDED: could not find the file readme.txt in the theme. Please see Theme_Documentation for more information.

The readme.txt is the place where all details about the plugins or themes within the WordPress ecosystem should be places. If it is missing, only the header comment of styles.css is relied on.

Themes are required to provide sufficient documentation to explain the use of any custom features or options.

The readme.txt file for themes follows the same rules, properties and syntax as they are described for the plugins.

RECOMMENDED: Screenshot size should be 880x660, to account for HiDPI displays. Any 4:3 image size is acceptable, but 880x660 is preferred.
RECOMMENDED: Screenshot is wrong size! Detected: 1000x535px. Maximum allowed size is 880x660px.
RECOMMENDED: Screenshot dimensions are wrong! Ratio of width to height should be 4:3.

How about taking a screen shot of the site while the browser is not wider than 1000px? Then crop the image to match the given 880x660 pixels and save as screenshot.png.

RECOMMENDED: No reference to post-thumbnails was found in the theme.
  If the theme has a thumbnail like functionality, it should be implemented with add_theme_support( "post-thumbnails" )in the functions.php file.
RECOMMENDED: No reference to the_post_thumbnail() was found in the theme.
  It is recommended that the theme implement this functionality instead of using custom fields for thumbnails.
RECOMMENDED: No reference to add_theme_support( "custom-header", $args ) was found in the theme.
  It is recommended that the theme implement this functionality if using an image for the header.
RECOMMENDED: No reference to add_theme_support( "custom-background", $args ) was found in the theme.
  If the theme uses background images or solid colors for the background, then it is recommended that the theme implement this functionality.
RECOMMENDED: No reference to add_editor_style() was found in the theme.
  It is recommended that the theme implement editor styling, so as to make the editor content match the resulting post output in the theme, for a better user experience.

Finally other notable things

INFO: Possible hard-coded links were found in the file footer.php.
INFO: Could not find the comment-reply script enqueued, however a reference to 'comment-reply' was found.
  Make sure that the comment-reply script is being enqueued properly on singular pages.

Hard coded URLs could be made by the theme author for linking to the possible support pages and other similar links that could be done via readme.txt.

Given the example code below, using the wp_get_theme method for getting the information of the current theme, any hard coded links that are available via theme data could be changed:

<?php $theme = wp_get_theme(); ?>

<a href="<?php echo $theme->get( 'AuthorURI' ); ?>" title="<?php echo $theme->get( 'Name' ); ?>">
  <?php echo $theme->get( 'Author' ); ?>
</a>

In the given theme, comments were removed at some point in its life, but as the script usage demonstrates, there were some left overs. As in the previous section, the comments functionality should be managed from the WordPress configuration instead from the theme.

Further fixes outside the original scope

Following up the tidying by applying WordPress Coding Standards for HTML, CSS, PHP and where possible, to JavaScript.

Instead of going at it by manually changing everything, some tools such as JetBrains PhpStorm, from version 8.0, has a built-in support for WordPress and can automatically format a given code to match the above standards.

[comment_form]: http://codex.wordpress.org/Template_Tags/comment_form “”