_make_web_ftp_clickable_cb

函式
_make_web_ftp_clickable_cb ( $matches )
Access
Private
引數
  • (array) $matches Single Regex Match.
    Required:
返回值
  • (string) HTML A element with URL address.
定義位置
相關方法
_make_email_clickable_cb_make_url_clickable_cbmake_clickablewp_make_theme_file_tree
引入
2.3.2
棄用
-

_make_web_ftp_clickable_cb: 此函式用於將文章內容中的FTP或基於網路的檔案傳輸的URL轉換為可點選的連結。

回撥,將URL匹配轉換為HTML A元素。

該函式已從2.5.0回傳到2.3.2。make_clickable()的Regex回撥。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function _make_web_ftp_clickable_cb( $matches ) {
$ret = '';
$dest = $matches[2];
$dest = 'http://' . $dest;
// Removed trailing [.,;:)] from URL.
$last_char = substr( $dest, -1 );
if ( in_array( $last_char, array( '.', ',', ';', ':', ')' ), true ) === true ) {
$ret = $last_char;
$dest = substr( $dest, 0, strlen( $dest ) - 1 );
}
$dest = esc_url( $dest );
if ( empty( $dest ) ) {
return $matches[0];
}
if ( 'comment_text' === current_filter() ) {
$rel = 'nofollow ugc';
} else {
$rel = 'nofollow';
}
/** This filter is documented in wp-includes/formatting.php */
$rel = apply_filters( 'make_clickable_rel', $rel, $dest );
$rel = esc_attr( $rel );
return $matches[1] . "<a href="$dest" rel="$rel">$dest</a>$ret";
}
function _make_web_ftp_clickable_cb( $matches ) { $ret = ''; $dest = $matches[2]; $dest = 'http://' . $dest; // Removed trailing [.,;:)] from URL. $last_char = substr( $dest, -1 ); if ( in_array( $last_char, array( '.', ',', ';', ':', ')' ), true ) === true ) { $ret = $last_char; $dest = substr( $dest, 0, strlen( $dest ) - 1 ); } $dest = esc_url( $dest ); if ( empty( $dest ) ) { return $matches[0]; } if ( 'comment_text' === current_filter() ) { $rel = 'nofollow ugc'; } else { $rel = 'nofollow'; } /** This filter is documented in wp-includes/formatting.php */ $rel = apply_filters( 'make_clickable_rel', $rel, $dest ); $rel = esc_attr( $rel ); return $matches[1] . "<a href="$dest" rel="$rel">$dest</a>$ret"; }
function _make_web_ftp_clickable_cb( $matches ) {
	$ret  = '';
	$dest = $matches[2];
	$dest = 'http://' . $dest;

	// Removed trailing [.,;:)] from URL.
	$last_char = substr( $dest, -1 );
	if ( in_array( $last_char, array( '.', ',', ';', ':', ')' ), true ) === true ) {
		$ret  = $last_char;
		$dest = substr( $dest, 0, strlen( $dest ) - 1 );
	}

	$dest = esc_url( $dest );
	if ( empty( $dest ) ) {
		return $matches[0];
	}

	if ( 'comment_text' === current_filter() ) {
		$rel = 'nofollow ugc';
	} else {
		$rel = 'nofollow';
	}

	/** This filter is documented in wp-includes/formatting.php */
	$rel = apply_filters( 'make_clickable_rel', $rel, $dest );
	$rel = esc_attr( $rel );

	return $matches[1] . "<a href="$dest" rel="$rel">$dest</a>$ret";
}

常見問題

FAQs
檢視更多 >