Title: __checked_selected_helper
Published: April 25, 2014
Last modified: August 20, 2026

---

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

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/__checked_selected_helper/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/__checked_selected_helper/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/__checked_selected_helper/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/__checked_selected_helper/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/__checked_selected_helper/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/__checked_selected_helper/?output_format=md#changelog)

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

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

## 󠀁[Description](https://developer.wordpress.org/reference/functions/__checked_selected_helper/?output_format=md#description)󠁿

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

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/__checked_selected_helper/?output_format=md#parameters)󠁿

 `$helper`mixedrequired

One of the values to compare.

`$current`mixedrequired

The other value to compare if not just true.

`$display`boolrequired

Whether to echo or just return the string.

`$type`stringrequired

The type of `checked|selected|disabled|readonly` we are doing.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/__checked_selected_helper/?output_format=md#return)󠁿

 string HTML attribute or empty string.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/__checked_selected_helper/?output_format=md#source)󠁿

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

[View all references](https://developer.wordpress.org/reference/files/wp-includes/general-template.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/general-template.php#L5569)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/general-template.php#L5569-L5581)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/__checked_selected_helper/?output_format=md#related)󠁿

| Used by | Description | 
| [wp_readonly()](https://developer.wordpress.org/reference/functions/wp_readonly/)`wp-includes/general-template.php` |

Outputs the HTML readonly attribute.

  | 
| [checked()](https://developer.wordpress.org/reference/functions/checked/)`wp-includes/general-template.php` |

Outputs the HTML checked attribute.

  | 
| [selected()](https://developer.wordpress.org/reference/functions/selected/)`wp-includes/general-template.php` |

Outputs the HTML selected attribute.

  | 
| [disabled()](https://developer.wordpress.org/reference/functions/disabled/)`wp-includes/general-template.php` |

Outputs the HTML disabled attribute.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/__checked_selected_helper/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.8.0](https://developer.wordpress.org/reference/since/2.8.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2F__checked_selected_helper%2F)
before being able to contribute a note or feedback.