Bug with Custom Code
There is still this quite old bug in the with the custom code preference. I’ll be copy and pasting from one of my older posts on this:
Description of the issue:
to the custom code section,
is stored in the database and this is reflected by looking at this option again after adding it for the first time. The result when loading the page however is
and that is working well.
Now when you just hit save on the analytics settings page for the second time, the following will be stored in the database:
When loading the page again
will be the result and that’s where the analytic code breaks and stops recording.
So there seems to be an issue with escaping special characters when storing this value. The first time the ‘ will get escaped to \’ and that just seems to be fine. But on a subsequent save both the escaping character as well as the original ones will be escaped again, resulting in the \\\’ which breaks it. Assuming that each subsequent save will add a lot of backslashes.
Here is the fix:
Look for the following line in wp-content/plugins/google-analytics-for-wordpress/admin/class-admin.php and change it from
‘content’ => $this->textinput( ‘customcode’ ),
‘content’ => stripslashes($this->textinput( ‘customcode’ )),
This adds the same function call for reading the customcode variable as used by the code that actually inserts the variable into the tracking code when building a page.
- The topic ‘Bug with Custom Code’ is closed to new replies.