I'm using the nettuts options panel: [[LINK href="http://net.tutsplus.com/tutorials/wordpress/how-to-create-a-better-wordpress-options-panel/"]]http://net.tutsplus.com/tutorials/wordpress/how-to-create-a-better-wordpress-options-panel/[[/LINK]]
The code has a flaw... when I paste my Google Analytics code into the Google Analytics box it creates in the options panel I get this error...
<strong>Error Line 21, Column 14: an attribute value must be a literal unless it contains only name characters
<script type=\"text/javascript\"></strong>
For some reason an extra "\" is being added to the code I paste in.
Source code for the options panel: [[LINK href="http://d2o0t5hpnwv4c1.cloudfront.net/575_wp/source.zip"]]http://d2o0t5hpnwv4c1.cloudfront.net/575_wp/source.zip[[/LINK]]
In my functions....
array( "name" => "Google Analytics Code",
"desc" => "You can paste your Google Analytics or other tracking code in this box. This will be automatically added to the header to track your stats.",
"id" => $shortname."_ga_code",
"type" => "textarea",
"std" => ""),
$var = get_option('to_ga_code');
Calling the code:
<?php echo get_option('to_ga_code'); ?>
<strong>The important question: What can I change to make sure when I paste the Google Analytics code into my options panel box it validates. Give me a fix through functions.php.</strong>
Christianto answers:
Hi,
you can use stripslashes function.
<?php echo stripslashes(get_option('to_ga_code')); ?>
Christianto comments:
Did it happen only when you add <script> tag?
Did your magic magic_quotes_gpc on your php setting turn on?
you can disable magic_quotes_gpc if you don't want to use stripslashes().