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(
                    'post_link',
                    'post_type_link',
                    'page_link',
                    'attachment_link',
                    'post_type_archive_link',
                    'get_pagenum_link',
                    'get_comments_pagenum_link',
                    'term_link',
                    'search_link',
                    'day_link',
                    'month_link',
                    'year_link',
                    'option_siteurl',
                    'blog_option_siteurl',
                    'option_home',
                    'admin_url',
                    'home_url',
                    'includes_url',
                    'site_url',
                    'site_option_siteurl',
                    'get_the_author_url',
                    'get_comment_link',
                    'wp_get_attachment_image_src',
                    'wp_get_attachment_thumb_url',
                    'wp_get_attachment_url',
                    'wp_login_url',
                    'wp_logout_url',
                    'wp_lostpassword_url',
                );
    
                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.

    http://wordpress.org/plugins/disqus-comment-system/

Viewing 1 replies (of 1 total)
  • Matt Keys

    (@mattkeys)

    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.