Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




links_add_target [ WordPress Function ]

links_add_target ( $content, $target = '_blank', $tags = array('a') )
Parameters:
  • (string) $content String to search for links in.
  • (string) $target The Target to add to the links.
  • (array) $tags An array of tags to apply to.
Returns:
  • (string) The processed content.
Defined at:



Adds a Target attribute to all links in passed content.

This function by default only applies to tags, however this can be modified by the 3rd param.

NOTE: Any current target attributed will be stripped and replaced.

Source


<?php
function links_add_target$content$target '_blank'$tags = array('a') ) {
    global 
$_links_add_target;
    
$_links_add_target $target;
    
$tags implode('|', (array)$tags);
    return 
preg_replace_callback"!<($tags)(.+?)>!i"'_links_add_target'$content );
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Dahasý ...

Kullanýcý Tartýþmalarý [ wordpress.org ]

- Bulunamadý -

Yeni bir konu yaz ...

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics