Jump to content

Simple: open <a href="<php... in new window


eevan79

Recommended Posts

Well I didnt think of it til just now but you can do this with a plugin. Create a new file called comment-author-edit.php in the wp-content/plugins/ folder, and put the following in it

<?php

/*
Plugin Name: Edit Comment Author
Version: 0.1
Description: Automatically adds target="_blank" to comment author links
Author: Jay Gilford
Author URI: http://www.jaygilford.com/
Plugin URI: http://www.jaygilford.com/
*/

/* Version Check */
global $wp_version;

$exit_message = 'This plugin requires Wordpress 2.5 or newer. <a href="http://codex.wordpress.org/Upgrading_WordPress">Please Update!</a>';

if(version_compare($wp_version, '2.5', '<')) {
exit($exit_message);
}

/* FILTERS */
add_filter('get_comment_author_link', 'comment_author_link_edit');

function comment_author_link_edit($content) {
    $content = str_replace('<a ', '<a target="_blank"', $content);
    return $content;
}

Save it, then look for Edit Comment Author in your plugin menu in the dashboard, and enable it

Link to comment
https://forums.phpfreaks.com/topic/183928-simple-open/#findComment-970965
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.