Support » Plugin: Auto-hyperlink URLs » Auto-hyperlink includes period at end of sentence

  • Resolved Charlie

    (@cdarling)


    I’ve got a new site running WP 3.4.2. I installed the latest “Auto-hyperlink URLs” plug-in and it seems to work fine for e-mail addresses, and for URLs that end with a TLD (ie xyz.com). Example of it working right.

    However, for URLs that continue after the TLD (ie xyz.com/abc), the plug-in seems to always include the end-of-sentence period in the hyperlink, which it shouldn’t. Example of it working wrong.

    Any suggestions on what might be wrong and/or how to fix it?

    Thanks!

    http://wordpress.org/extend/plugins/auto-hyperlink-urls/

Viewing 1 replies (of 1 total)
  • Thread Starter Charlie

    (@cdarling)

    I hacked autohyperlink-urls.php as follows, and that seems to have fixed it. (The example of it not working, above, no longer shows it not working, because I fixed it.)

    public function do_hyperlink_url( $matches ) {
    		$options = $this->get_options();
    
    		/* If the URL ends in a period, that's a mistake, so drop the trailing period. */
    		$cbd_drop_trailing_period = $matches[2];
    		if ( substr($cbd_drop_trailing_period,-1,1) == '.' )
    			$cbd_drop_trailing_period = substr($cbd_drop_trailing_period,0,-1) ;
    
    		$link_text = $options['strip_protocol'] ? $matches[4] : $matches[2];
    
    		/* Use the URL that's had any trailing period stripped */
    		return $matches[1] . '<a href="' . esc_attr( $cbd_drop_trailing_period ) . '" ' . $this->get_link_attributes( $matches[2] ) .'>' . $this->truncate_link( $link_text ) . '</a>';
    	}
    
    	public function do_hyperlink_url_no_proto( $matches ) {
    
    		/* If the URL ends in a period, that's a mistake, so drop the trailing period. */
    		$cbd_drop_trailing_period = $matches[2] . '.' . $matches[3] . $matches[4] ;
    		if ( substr($cbd_drop_trailing_period,-1,1) == '.' )
    			$cbd_drop_trailing_period = substr($cbd_drop_trailing_period,0,-1) ;
    
    		$dest = $matches[2] . '.' . $matches[3] . $matches[4];
    		return $matches[1] . '<a href="http://' . esc_attr( $cbd_drop_trailing_period ) . '" ' . $this->get_link_attributes( "http://$dest" ) .'>' . $this->truncate_link( $dest ) . '</a>';
    	}
Viewing 1 replies (of 1 total)
  • The topic ‘Auto-hyperlink includes period at end of sentence’ is closed to new replies.