xfn_check

函式
xfn_check ( $xfn_relationship, $xfn_value = '', $deprecated = '' )
引數
  • (string) $xfn_relationship XFN relationship category. Possible values are: 'friendship', 'physical', 'professional', 'geographical', 'family', 'romantic', 'identity'.
    Required:
  • (string) $xfn_value Optional. The XFN value to mark as checked if it matches the current link's relationship. Default empty string.
    Required:
    Default: (empty)
  • (mixed) $deprecated Deprecated. Not used.
    Required:
    Default: (empty)
定義位置
相關方法
checkedwp_checkdatewp_version_checkms_site_checkwp_auth_check
引入
1.0.1
棄用
-

xfn_check: 這個函式用來檢查WordPress文章中的XHTML好友網路(XFN)關係。XFN是表示一個文章的作者和文章中的連結之間關係的一種方式。例如,一個作者可能表示他們與他們所連結的人是朋友: 這個函式檢查文章中的XFN關係,如果無效則返回一個錯誤。

顯示XFN微格式選項的’勾選’覈取方塊屬性。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function xfn_check( $xfn_relationship, $xfn_value = '', $deprecated = '' ) {
global $link;
if ( ! empty( $deprecated ) ) {
_deprecated_argument( __FUNCTION__, '2.5.0' ); // Never implemented.
}
$link_rel = isset( $link->link_rel ) ? $link->link_rel : ''; // In PHP 5.3: $link_rel = $link->link_rel ?: '';
$link_rels = preg_split( '/s+/', $link_rel );
// Mark the specified value as checked if it matches the current link's relationship.
if ( '' !== $xfn_value && in_array( $xfn_value, $link_rels, true ) ) {
echo ' checked="checked"';
}
if ( '' === $xfn_value ) {
// Mark the 'none' value as checked if the current link does not match the specified relationship.
if ( 'family' === $xfn_relationship
&& ! array_intersect( $link_rels, array( 'child', 'parent', 'sibling', 'spouse', 'kin' ) )
) {
echo ' checked="checked"';
}
if ( 'friendship' === $xfn_relationship
&& ! array_intersect( $link_rels, array( 'friend', 'acquaintance', 'contact' ) )
) {
echo ' checked="checked"';
}
if ( 'geographical' === $xfn_relationship
&& ! array_intersect( $link_rels, array( 'co-resident', 'neighbor' ) )
) {
echo ' checked="checked"';
}
// Mark the 'me' value as checked if it matches the current link's relationship.
if ( 'identity' === $xfn_relationship
&& in_array( 'me', $link_rels, true )
) {
echo ' checked="checked"';
}
}
}
function xfn_check( $xfn_relationship, $xfn_value = '', $deprecated = '' ) { global $link; if ( ! empty( $deprecated ) ) { _deprecated_argument( __FUNCTION__, '2.5.0' ); // Never implemented. } $link_rel = isset( $link->link_rel ) ? $link->link_rel : ''; // In PHP 5.3: $link_rel = $link->link_rel ?: ''; $link_rels = preg_split( '/s+/', $link_rel ); // Mark the specified value as checked if it matches the current link's relationship. if ( '' !== $xfn_value && in_array( $xfn_value, $link_rels, true ) ) { echo ' checked="checked"'; } if ( '' === $xfn_value ) { // Mark the 'none' value as checked if the current link does not match the specified relationship. if ( 'family' === $xfn_relationship && ! array_intersect( $link_rels, array( 'child', 'parent', 'sibling', 'spouse', 'kin' ) ) ) { echo ' checked="checked"'; } if ( 'friendship' === $xfn_relationship && ! array_intersect( $link_rels, array( 'friend', 'acquaintance', 'contact' ) ) ) { echo ' checked="checked"'; } if ( 'geographical' === $xfn_relationship && ! array_intersect( $link_rels, array( 'co-resident', 'neighbor' ) ) ) { echo ' checked="checked"'; } // Mark the 'me' value as checked if it matches the current link's relationship. if ( 'identity' === $xfn_relationship && in_array( 'me', $link_rels, true ) ) { echo ' checked="checked"'; } } }
function xfn_check( $xfn_relationship, $xfn_value = '', $deprecated = '' ) {
	global $link;

	if ( ! empty( $deprecated ) ) {
		_deprecated_argument( __FUNCTION__, '2.5.0' ); // Never implemented.
	}

	$link_rel  = isset( $link->link_rel ) ? $link->link_rel : ''; // In PHP 5.3: $link_rel = $link->link_rel ?: '';
	$link_rels = preg_split( '/s+/', $link_rel );

	// Mark the specified value as checked if it matches the current link's relationship.
	if ( '' !== $xfn_value && in_array( $xfn_value, $link_rels, true ) ) {
		echo ' checked="checked"';
	}

	if ( '' === $xfn_value ) {
		// Mark the 'none' value as checked if the current link does not match the specified relationship.
		if ( 'family' === $xfn_relationship
			&& ! array_intersect( $link_rels, array( 'child', 'parent', 'sibling', 'spouse', 'kin' ) )
		) {
			echo ' checked="checked"';
		}

		if ( 'friendship' === $xfn_relationship
			&& ! array_intersect( $link_rels, array( 'friend', 'acquaintance', 'contact' ) )
		) {
			echo ' checked="checked"';
		}

		if ( 'geographical' === $xfn_relationship
			&& ! array_intersect( $link_rels, array( 'co-resident', 'neighbor' ) )
		) {
			echo ' checked="checked"';
		}

		// Mark the 'me' value as checked if it matches the current link's relationship.
		if ( 'identity' === $xfn_relationship
			&& in_array( 'me', $link_rels, true )
		) {
			echo ' checked="checked"';
		}
	}
}

常見問題

FAQs
檢視更多 >