__checked_selected_helper()WP 2.8.0

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

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

Внутренняя функция — эта функция рассчитана на использование самим ядром. Не рекомендуется использовать эту функцию в своем коде.

Хуков нет.

Возвращает

Строку. HTML attribute or empty string.

Использование

__checked_selected_helper( $helper, $current, $display, $type );
$helper(разное) (обязательный)
One of the values to compare.
$current(разное) (обязательный)
The other value to compare if not just true.
$display(true|false) (обязательный)
Whether to echo or just return the string.
$type(строка) (обязательный)
The type of checked|selected|disabled|readonly we are doing.

Список изменений

С версии 2.8.0 Введена.

Код __checked_selected_helper() WP 6.5.2

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