Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

__checked_selected_helper() WordPress Function

__checked_selected_helper() is a function that is used to set the checked or selected attribute of a form element in WordPress. This function is typically used within the settings API.

__checked_selected_helper( mixed $helper, mixed $current, bool $echo, string $type ) #

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


Description

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


Top ↑

Parameters

$helper

(mixed)(Required)One of the values to compare.

$current

(mixed)(Required)The other value to compare if not just true.

$echo

(bool)(Required)Whether to echo or just return the string.

$type

(string)(Required)The type of checked|selected|disabled|readonly we are doing.


Top ↑

Return

(string) HTML attribute or empty string.


Top ↑

Source

File: wp-includes/general-template.php

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

	if ( $echo ) {
		echo $result;
	}

	return $result;
}


Top ↑

Changelog

Changelog
VersionDescription
2.8.0Introduced.

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.

Show More