Hard Coded Links in Theme File Causing Error

The Theme Check plugin checks for errors in your design or coding of WordPress themes.

If you are getting “INFO: Possible hard-coded links were found”, that literally means you have hard-coded links, you typed the URL in. Proper links should have been “escaped”, or passed through a function to make sure they contain only characters that are valid in URLs. If the URL is used in multiple places, you also should consider putting the URL in a PHP variable so if you need to change it, you change it in only one place.

http://codex.wordpress.org/Theme_Development
“Untrusted Data
“You should escape dynamically generated content in your Theme, especially content that is output to HTML attributes. As noted in WordPress Coding Standards, text that goes into attributes should be run through esc_attr() so that single or double quotes do not end the attribute value and invalidate the XHTML and cause a security issue. Common places to check are title, alt, and value attributes.”

http://codex.wordpress.org/Function_Reference/esc_url
Here is an example from the twentyfourten theme footer:

<div class="site-info">
<?php do_action( 'twentyfourteen_credits' ); ?>
<a href="<?php echo esc_url( __( 'http://wordpress.org/', 'twentyfourteen' ) ); ?>"><?php printf( __( 'Proudly powered by %s', 'twentyfourteen' ), 'WordPress' ); ?></a>
</div><!-- .site-info -->

Original:

my domain

Try this instead of your original:

<a href="<?php echo esc_url( __('http://mydomain.com', 'mytheme'));?>" target="_blank">my domain</a>

That is underscore underscore parenthesis (for translating your theme to other languages), see http://codex.wordpress.org/Function_Reference/_2


Posted

in

by

Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.