Skip to content

WP 5.8 Backport: Introduce function wp_readonly() (Trac 53858) #1590

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/wp-includes/general-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -4824,6 +4824,22 @@ function readonly( $readonly, $current = true, $echo = true ) {
return __checked_selected_helper( $readonly, $current, $echo, 'readonly' );
}

/**
* Outputs the HTML readonly attribute.
*
* Compares the first two arguments and if identical marks as readonly
*
* @since 5.9.0 with backports in 5.8.x, 5.7.x, 5.6.x, 5.5.x
*
* @param mixed $readonly One of the values to compare
* @param mixed $current (true) The other value to compare if not just true
* @param bool $echo Whether to echo or just return the string
* @return string HTML attribute or empty string
*/
function wp_readonly( $readonly, $current = true, $echo = true ) {
return __checked_selected_helper( $readonly, $current, $echo, 'readonly' );
}

/**
* Private helper function for checked, selected, disabled and readonly.
*
Expand Down