xfn_check() WordPress Function

The xfn_check() function is used to check if a given URL is an XFN (XHTML Friends Network) URL. This function is useful for checking if a given URL is valid for use with the rel="me" attribute.

xfn_check( string $xfn_relationship, string $xfn_value = '', mixed $deprecated = '' ) #

Displays ‘checked’ checkboxes attribute for XFN microformat options.


Parameters

$xfn_relationship

(string)(Required)XFN relationship category. Possible values are: 'friendship', 'physical', 'professional', 'geographical', 'family', 'romantic', 'identity'.

$xfn_value

(string)(Optional) The XFN value to mark as checked if it matches the current link's relationship.

Default value: ''

$deprecated

(mixed)(Optional)Deprecated. Not used.

Default value: ''


Top ↑

Source

File: wp-admin/includes/meta-boxes.php

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"';
		}
	}
}


Top ↑

Changelog

Changelog
VersionDescription
1.0.1Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.