wpseek.com
Outil de recherche WordPress pour les développeurs et auteurs de thèmes



links_add_base_url › WordPress Function

Depuis2.7.0
Dépréciéen/a
links_add_base_url ( $content, $base, $attrs = array('src', 'href') )
Paramètres: (3)
  • (string) $content String to search for links in.
    Requis: Oui
  • (string) $base The base URL to prefix to links.
    Requis: Oui
  • (array) $attrs The attributes which should be processed.
    Requis: Non
    Défaut: array('src', 'href')
Retourne:
  • (string) The processed content.
Défini(e) dans:
Codex:

Adds a base URL to relative links in passed content.

By default, this function supports the 'src' and 'href' attributes. However, this can be modified via the $attrs parameter.


Source

function links_add_base_url( $content, $base, $attrs = array( 'src', 'href' ) ) {
	global $_links_add_base;
	$_links_add_base = $base;
	$attrs           = implode( '|', (array) $attrs );
	return preg_replace_callback( "!($attrs)=(['\"])(.+?)\\2!i", '_links_add_base', $content );
}