โค้ด: เลือกทั้งหมด
public function modify_text_for_display_after($event) {
$text = $event['text'];
if (preg_match_all('/href\=\"(.*?)\"/', $text, $data)) {
// หาลิงค์ url ลำดับเเรกจากเนื้อหาข้อความทั้งหมด
foreach ($data[1] as $key => $url) { // จากนั้นดึงค่า url ออกมา
//print_r($data[1]);
if (!preg_match('#^' . preg_quote(generate_board_url(), '#') . get_preg_expression('relative_url') . '$#iu', $url)) {
// คำสั่งเช็คเงื่อนไขว่าเป็น Domain เดียวกันหรือไม่
// $text = preg_replace('/(class="postlink")/', 'class="postlink" rel="nofollow" ', $text);
$text = str_replace('href="'.$url.'"', 'href="'.$url.'" rel="nofollow" ', $text);
}
}
}
$event['text'] = $text;
}