Resolve WordPress Theme Check Issue

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

WordPress Theme check Issue

Many of new WordPress developer are facing issue with themes when they are trying to submit theme to WP directory or checking theme with theme check or debug plugin.

Theme Check Issue:

  • WARNING: The theme uses the add_shortcode() function. Custom post-content shortcodes are plugin-territory functionality.

In this case WordPress Guidelines say you can’t use short code because this is plugin territory. So you need to remove it from file but it could be use out side WP directory.

  • WARNING: Found pub-xxxxxxxxxxxx in the file Georgia.ttf. Google advertising code detected.
    Line 2122: data-ad-client='ca-pub-xxxxxxxxxxxxx'
    Line 2198: data-ad-client='ca-pub-xxxxxxxxxxxxx'
    Line 2265: data-ad-client='ca-pub-xxxxxxxxxxxxx'

That detect as spam within file you need to remove it from effected file.

  • WARNING: error_log PHP error log found.

Error Log file normally found within main folder of you theme or plugin it must not present some time when you upload theme to server this file was created.

  • INFO: Possible hard-coded links were found in the file

for Example like this link:

<a href="http://www.insertcart.com/magazine-style">Magazine Style</a>

Replace it with below properly

<a href="<?php echo esc_url( __( 'http://www.insertcart.com/magazine-style', 'magazine' ) ); ?>" title="<?php esc_attr_e( 'Magazine Style', 'magazine' ); ?>"><strong><?php printf( __( 'Magazine Style %s', 'magazine' ),''); ?></strong></a>

Redux framework issue:

PHP Short Tags Issue

  • WARNING: Found PHP short tags in file parsedown.php.
    Line 838: if (preg_match('/^\[(.+?)\]:[ ]* ?(?:[ ]+['\'(](.+)['\')])?[ ]*$/', $Line['text'], $matches))

First open redux framework path admin\redux-framework\ReduxCore\inc\fields\raw\field_raw.php and search for below line (about line no: 55) and remove it.Then remove parsedown.php file as well into this folder.

 

if ( ! empty( $this->field['content'] ) && isset( $this->field['content'] ) ) {
if ( isset( $this->field['markdown'] ) && $this->field['markdown'] == true ) {
require_once dirname( __FILE__ ) . "/parsedown.php";
$Parsedown = new Parsedown();
echo $Parsedown->text( $this->field['content'] );
} else {
echo $this->field['content'];
}
}

File_put_contents Issue

  • WARNING: file_put_contents was found in the file class.redux_filesystem.php File operations should use the WP_Filesystem methods instead of direct PHP filesystem calls.
    Line 118: $res = file_put_contents( $file, $content );

To resolve this code open redux framework path admin\redux-framework\ReduxCore\inc\class.redux_filesystem.php

and change file_put_contents to WP_Filesystem

  • WARNING: file_get_contents was found in the file sample-config.php File operations should use the WP_Filesystem methods instead of direct PHP filesystem calls.
    Line 1343: 'content' => file_get_contents( dirname( __FILE__ ) . '/../README.md' )
    Line 1568: 'content' => nl2br( file_get_contents( trailingslashit( dirname( __FILE__ ) ) . 'README.html' )

There is a folder into admin\redux-framework named Sample you can delete that or change file_put_contents to WP_Filesystem

  • WARNING: file_get_contents was found in the file class.redux_filesystem.php File operations should use the WP_Filesystem methods instead of direct PHP filesystem calls.
    Line 126: $res = file_get_contents( $file );

To resolve this code open redux framework path admin\redux-framework\ReduxCore\inc\class.redux_filesystem.php
And change file_get_contents to WP_Filesystem

  • WARNING: .jshintrc .tx .editorconfig Hidden Files or Folders found.

About These file you need to remove them because they hidden which carry unusual data of plugin.

  • WARNING: curl_init was found in the file p.php File operations should use the WP_Filesystem methods instead of direct PHP filesystem calls.
    Line 185: $ch = curl_init( $url );

Search into file admin\redux-framework\ReduxCore\inc\p.php then do search replace: curl_init change it to WP_Filesystem.

 

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

Remove Every thing extra in <title>..</title> Tag just put wp_title( ‘|’, true, ‘right’ ); using PHP tags .

 

  • RECOMMENDED: Tags: is either empty or missing in style.css header.

Some time this Error is caused because of missing tags into style please define tags or May be your style.css is edited by notepad please use Notepad++ for unix edit. Dos\Windows editor cause these kinds of warnings.

 

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

It mean you have not defined style for your gallery-caption example .gallery-caption{font-size:13px; color:#f03;} put code like these code into style.css

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

Text Domain missing that means theme isn’t translation ready you need to add a Text-domain in style.css then change and update code into theme ” _e(‘This is my text’); ” change to ” _e(‘This is my text’ , ‘textdomain’); ” that’s it.

Comment form missing or using old code please update your code to default wordpress comment form read instruction from link.

  • REQUIRED: get_the_author_email() found in the file myfile.php. Deprecated since version 2.8. Use get_the_author_meta(’email’) instead.

Need to update code for example if your are using “echo get_avatar( get_the_author_email(), ’48’ ); “ change to “echo get_avatar( get_the_author_meta(), ’48’ ); ” Problem will be resolved.

 

  • REQUIRED: get_bloginfo(‘url’) was found in the file myfile.php. Use home_url() instead.

This code is outdated update with new one for example <link rel=’canonical’ href=”.get_bloginfo(‘url’).” /> change it to <link rel=’canonical’ href=”.home_url(‘url’).” />

  • REQUIRED: get_bloginfo(‘template_url’) was found in the file Myfile.php. Use get_template_directory_uri() instead.

Code is outdated change same as above code example: wp_enqueue_script(‘jquery’, get_bloginfo(‘template_url’).’/includes/js/jquery.min.js’, false, ‘1.4.2’);  Change to wp_enqueue_script(‘jquery’, get_template_directory_uri().’/includes/js/jquery.min.js’, false, ‘1.4.2’);

 

I’m also a developer like you whenever problem came to me i write about here with solution. May be some times i was wrong please apologize me for that and correct me. Share your views and comments here

personal technology columnist, author and founder of wRock.org, a widely read tech and how-to blog since 2009. Wants to explore and share interesting Tips, Tutorials and More. Also WordPress Theme Designer @ here. Contact: Contact

Leave a Reply

Your email address will not be published. Required fields are marked *