W3cubDocs

/WordPress

__checked_selected_helper( mixed $helper, mixed $current, bool $display, string $type ): string

Private helper function for checked, selected, disabled and readonly.

Description

Compares the first two arguments and if identical marks as $type.

Parameters

$helpermixedrequired
One of the values to compare.
$currentmixedrequired
The other value to compare if not just true.
$displayboolrequired
Whether to echo or just return the string.
$typestringrequired
The type of checked|selected|disabled|readonly we are doing.

Return

string HTML attribute or empty string.

Source

function __checked_selected_helper( $helper, $current, $display, $type ) { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore
	if ( (string) $helper === (string) $current ) {
		$result = " $type='$type'";
	} else {
		$result = '';
	}

	if ( $display ) {
		echo $result;
	}

	return $result;
}

Changelog

Version Description
2.8.0 Introduced.

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