1

I was working on adding a tracking script onto our website and it worked, but it messed up some of the scripts that were already on the site.

This is what I was trying to add:

function my_custom_js() {
echo '<script type="text/JavaScript" src="https://secure.ifbyphone.com/js/ibp_clickto_referral.js"></script>

and it also added 2 hooks:

// Add hook for admin add_action('admin_head', 'my_custom_js');

// Add hook for front-end add_action('wp_head', 'my_custom_js');

now the "latest posts widget" is not working - gives the error

"Warning: DOMDocument::load(): Extra content at the end of the document in http://www.givnerkaye.com/feed/, line: 2 in /home/givnerk/public_html/wp-content/plugins/php-code-widget/execphp.php(27) : eval()'d code on line 4"

And when I try to login to the admin I see:

"Warning: Cannot modify header information - headers already sent by (output started at /home/givnerk/public_html/wp-content/themes/thesis_18/thesis_18/functions.php:1) in /home/givnerk/public_html/wp-includes/pluggable.php on line 1173"

you can view the live page page at www.givnerkaye.com

How can these issues be resolved?

Paul
  • 26,170
  • 12
  • 85
  • 119
SerratoJJ
  • 11
  • 2
  • This is how it should be done, not by `echo` - http://codex.wordpress.org/Function_Reference/wp_enqueue_script – Cheery Oct 31 '14 at 04:53
  • `echo` definitely isn't valid Javascript. It is valid PHP. People can get easily confused mixing the two, which, of course PHP's design makes tempting. – Paul Oct 31 '14 at 05:00
  • Thank you for your response - I had indeed looked at something similar to that. Any tips on how to clean up this mess I made? – SerratoJJ Oct 31 '14 at 05:03
  • @Paul there is no mess, he is creating plugin for Wordpress that inserts this load of js into the html page. That it ok, only the way it is done is not good. More details are given on the codex page of wordpress. @SerratoJJ - all details are here, there is no `echo` at all - http://codex.wordpress.org/Function_Reference/wp_enqueue_script your `echo` outputs before the headers are sent to browser and not in the correct place of html page, that is the reason of those messages. – Cheery Oct 31 '14 at 05:12
  • @SerratoJJ or, may be, check for BOM mark (http://en.wikipedia.org/wiki/Byte_order_mark) or spaces before ` – Cheery Oct 31 '14 at 05:16
  • @Cheery I removed what I added from my functions.php file but I still get the messages. How would I go about removing it? – SerratoJJ Oct 31 '14 at 16:30
  • @Cheery I was able to get the site back to normal, Thank you so much for your great suggestions. =) – SerratoJJ Oct 31 '14 at 17:26

0 Answers0