[wp-trac] [WordPress Trac] #16886: Adding readonly function to wp-includes/general-template.php
WordPress Trac
wp-trac at lists.automattic.com
Fri Mar 18 16:00:34 UTC 2011
#16886: Adding readonly function to wp-includes/general-template.php
-------------------------+-----------------------------
Reporter: kakidcm | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 3.1
Severity: minor | Keywords: has-patch
-------------------------+-----------------------------
A quite simple improvement, really.
Just like the ''checked'', ''selected'' and ''disabled'' function,
''readonly'' would be a shortcut to ''__checked_selected_helper''.
I was doing a theme option page and realized that disabling fields removes
the data from the data submission.
I have a bunch of fields that gets used (or not) in the theme, depending
on a on/off switch. At first, depending on the switch, I was disabling the
fields, but all the data is removed on submit if the switch is at off.
Meaning that the user would have to reenter every fields if he wants to
activate the functionality.
Putting the fields on readonly gives a nice feedback to the user that
those fields are not use, depending on the switch, AND the data is kept if
the user changes his mind.
So, here's the patch.
{{{
/**
* Outputs the html readonly attribute.
*
* Compares the first two arguments and if identical marks as readonly
*
* @since 3.1.#
*
* @param mixed $disabled 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 readonly( $readonly, $current = true, $echo = true ) {
return __checked_selected_helper( $readonly, $current, $echo,
'readonly' );
}
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/16886>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list