Support » Plugin: Disqus Comment System » get_permalink(); in comments.php is affected by wp_make_link_relative

  • Hi,

    I have a filter set up got wp_make_link_relative to remove the site url from most of the links.

    Surprisingly the new version of Disqus released a few days ago ended up having an error on my site which was caused be the relative url in disqus_url variable.

    To avoid this, I added a very ugly quick-fix to the plugin:
    comments.php, line #46

    -    var disqus_url = '<?php echp get_permalink();'?>
    +    var disqus_url = '<?php $plink = get_permalink(); $url = get_bloginfo('url'); if ( !strstr( $url, $plink ) ) $plink = $url . $plink; echo $plink; ?>';

    The filter code I’m using in functions.php:

    $this->urlfilters = array(
                if ( ! is_feed()  && ! get_query_var( 'sitemap' ) ) {
                    foreach ( $this->urlfilters as $filter ) {
                        add_filter( $filter, 'wp_make_link_relative' );

    I know this is a rare case but it might affect others as well in the future.

Viewing 1 replies (of 1 total)
  • Matt Keys


    Thanks for sharing, I did run into this as well. Just FYI your strstr() function has the haystack and needle flipped. It should be:

    var disqus_url = '<?php $plink = get_permalink(); $url = get_bloginfo("url"); if ( !strstr( $plink, $url ) ) $plink = $url . $plink; echo $plink; ?>';

    I was using the root relative urls plugin, however I keep running into instances where plugins are relying on an absolute URL which makes me leery to continue using root relative urls.

Viewing 1 replies (of 1 total)
  • The topic ‘get_permalink(); in comments.php is affected by wp_make_link_relative’ is closed to new replies.