WordPress.org

Ready to get started?Download WordPress

Forums

Google Analytics for WordPress
HowTo: Remove unwanted inserted space char from links (4 posts)

  1. Ov3rfly
    Member
    Posted 1 year ago #

    If outbound tracking is not used, the plugin still inserts an extra space at the end of link attributes (right after the "http://whatever") like this:

    <a href="http://whatever" >Whatever</a>

    If you do not want that extra space char, locate this code in line 1187 of file googleanalytics.php, version 4.2.4:

    return '<a ' . $matches[1] . 'href="' . $matches[2] . '//' . $matches[3] . '"' . ' ' . $matches[4] . '>' . $matches[5] . '</a>';

    Replace with these two lines:

    $matches_4_fix = ($matches[4] != '') ? ' ' . $matches[4] : '';
    return '<a ' . $matches[1] . 'href="' . $matches[2] . '//' . $matches[3] . '"' . $matches_4_fix . '>' . $matches[5] . '</a>';

    Then your links will look like this in HTML source:

    <a href="http://whatever">Whatever</a>

    http://wordpress.org/extend/plugins/google-analytics-for-wordpress/

  2. Ov3rfly
    Member
    Posted 1 year ago #

    Same problem/fix for version 4.2.5, line 1244 in googleanalytics.php

  3. Ov3rfly
    Member
    Posted 1 year ago #

    Same problem/fix for version 4.2.7, line 1249 in googleanalytics.php

  4. Ov3rfly
    Member
    Posted 1 year ago #

    Same problem/fix for version 4.2.8, line 1249 in googleanalytics.php

    @autor: Please include this fix in a coming release.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic