W3cubDocs

/WordPress

xfn_check( string $class, string $value = '', mixed $deprecated = '' )

Display checked checkboxes attribute for xfn microformat options.

Parameters

$class

(string) (Required)

$value

(string) (Optional)

Default value: ''

$deprecated

(mixed) (Optional) Never used.

Default value: ''

Source

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

function xfn_check( $class, $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 ?: '';
	$rels     = preg_split( '/\s+/', $link_rel );

	if ( '' !== $value && in_array( $value, $rels, true ) ) {
		echo ' checked="checked"';
	}

	if ( '' === $value ) {
		if ( 'family' === $class && strpos( $link_rel, 'child' ) === false && strpos( $link_rel, 'parent' ) === false && strpos( $link_rel, 'sibling' ) === false && strpos( $link_rel, 'spouse' ) === false && strpos( $link_rel, 'kin' ) === false ) {
			echo ' checked="checked"';
		}
		if ( 'friendship' === $class && strpos( $link_rel, 'friend' ) === false && strpos( $link_rel, 'acquaintance' ) === false && strpos( $link_rel, 'contact' ) === false ) {
			echo ' checked="checked"';
		}
		if ( 'geographical' === $class && strpos( $link_rel, 'co-resident' ) === false && strpos( $link_rel, 'neighbor' ) === false ) {
			echo ' checked="checked"';
		}
		if ( 'identity' === $class && in_array( 'me', $rels, true ) ) {
			echo ' checked="checked"';
		}
	}
}

Changelog

Version Description
1.0.1 Introduced.

© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/xfn_check