Use disabled() form helper. fixes #12581

git-svn-id: http://svn.automattic.com/wordpress/trunk@13661 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2010-03-11 17:12:23 +00:00
parent c8756014d2
commit 20eae9d24a
6 changed files with 17 additions and 21 deletions

View File

@ -914,17 +914,17 @@ jQuery(function($){
<table class="form-table">
<tr valign="top">
<th scope="row"><label for="hostname"><?php _e('Hostname') ?></label></th>
<td><input name="hostname" type="text" id="hostname" value="<?php echo esc_attr($hostname); if ( !empty($port) ) echo ":$port"; ?>"<?php if ( defined('FTP_HOST') ) echo ' disabled="disabled"' ?> size="40" /></td>
<td><input name="hostname" type="text" id="hostname" value="<?php echo esc_attr($hostname); if ( !empty($port) ) echo ":$port"; ?>"<?php disabled( defined('FTP_HOST') ); ?> size="40" /></td>
</tr>
<tr valign="top">
<th scope="row"><label for="username"><?php _e('Username') ?></label></th>
<td><input name="username" type="text" id="username" value="<?php echo esc_attr($username) ?>"<?php if ( defined('FTP_USER') ) echo ' disabled="disabled"' ?> size="40" /></td>
<td><input name="username" type="text" id="username" value="<?php echo esc_attr($username) ?>"<?php disabled( defined('FTP_USER') ); ?> size="40" /></td>
</tr>
<tr valign="top">
<th scope="row"><label for="password"><?php _e('Password') ?></label></th>
<td><input name="password" type="password" id="password" value="<?php if ( defined('FTP_PASS') ) echo '*****'; ?>"<?php if ( defined('FTP_PASS') ) echo ' disabled="disabled"' ?> size="40" /></td>
<td><input name="password" type="password" id="password" value="<?php if ( defined('FTP_PASS') ) echo '*****'; ?>"<?php disabled( defined('FTP_PASS') ); ?> size="40" /></td>
</tr>
<?php if ( isset($types['ssh']) ) : ?>
@ -934,7 +934,7 @@ jQuery(function($){
<label for="public_key"><?php _e('Public Key:') ?></label ><br />
<label for="private_key"><?php _e('Private Key:') ?></label>
</div></th>
<td><br /><input name="public_key" type="text" id="public_key" value="<?php echo esc_attr($public_key) ?>"<?php if ( defined('FTP_PUBKEY') ) echo ' disabled="disabled"' ?> size="40" /><br /><input name="private_key" type="text" id="private_key" value="<?php echo esc_attr($private_key) ?>"<?php if ( defined('FTP_PRIKEY') ) echo ' disabled="disabled"' ?> size="40" />
<td><br /><input name="public_key" type="text" id="public_key" value="<?php echo esc_attr($public_key) ?>"<?php disabled( defined('FTP_PUBKEY') ); ?> size="40" /><br /><input name="private_key" type="text" id="private_key" value="<?php echo esc_attr($private_key) ?>"<?php disabled( defined('FTP_PRIKEY') ); ?> size="40" />
<div><?php _e('Enter the location on the server where the keys are located. If a passphrase is needed, enter that in the password field above.') ?></div></td>
</tr>
<?php endif; ?>
@ -943,13 +943,9 @@ jQuery(function($){
<th scope="row"><?php _e('Connection Type') ?></th>
<td>
<fieldset><legend class="screen-reader-text"><span><?php _e('Connection Type') ?></span></legend>
<?php
$disabled = (defined('FTP_SSL') && FTP_SSL) || (defined('FTP_SSH') && FTP_SSH) ? ' disabled="disabled"' : '';
foreach ( $types as $name => $text ) : ?>
<?php foreach ( $types as $name => $text ) : ?>
<label for="<?php echo esc_attr($name) ?>">
<input type="radio" name="connection_type" id="<?php echo esc_attr($name) ?>" value="<?php echo esc_attr($name) ?>" <?php checked($name, $connection_type); echo $disabled; ?>/>
<input type="radio" name="connection_type" id="<?php echo esc_attr($name) ?>" value="<?php echo esc_attr($name) ?>"<?php checked($name, $connection_type); disabled( $disabled, (defined('FTP_SSL') && FTP_SSL) || (defined('FTP_SSH') && FTP_SSH) ); ?> />
<?php echo $text ?>
</label>
<?php endforeach; ?>

View File

@ -858,7 +858,7 @@ function image_size_input_fields( $post, $check = '' ) {
$checked = " checked='checked'";
}
$html = "<div class='image-size-item'><input type='radio' " . ( $enabled ? '' : "disabled='disabled' " ) . "name='attachments[$post->ID][image-size]' id='{$css_id}' value='{$size}'$checked />";
$html = "<div class='image-size-item'><input type='radio' " . disabled( $enabled, false, false ) . "name='attachments[$post->ID][image-size]' id='{$css_id}' value='{$size}'$checked />";
$html .= "<label for='{$css_id}'>$label</label>";
// only show the dimensions if that choice is available

View File

@ -206,7 +206,7 @@ class Walker_Category_Checklist extends Walker {
$name = 'tax_input['.$taxonomy.']';
$class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : '';
$output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" . '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="'.$name.'[]" id="in-'.$taxonomy.'-' . $category->term_id . '"' . (in_array( $category->term_id, $selected_cats ) ? ' checked="checked"' : "" ) . (!empty($args['disabled']) ? 'disabled="disabled"' : '') . '/> ' . esc_html( apply_filters('the_category', $category->name )) . '</label>';
$output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" . '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="'.$name.'[]" id="in-'.$taxonomy.'-' . $category->term_id . '"' . checked( in_array( $category->term_id, $selected_cats ), true, false ) . disabled( empty( $args['disabled'] ), false, false ) . ' /> ' . esc_html( apply_filters('the_category', $category->name )) . '</label>';
}
function end_el(&$output, $category, $depth, $args) {

View File

@ -165,20 +165,20 @@ switch ( $action ) {
foreach ( $options as $option ) {
if ( $option->option_name == 'default_role' )
$editblog_default_role = $option->option_value;
$disabled = '';
$disabled = false;
if ( is_serialized($option->option_value) ) {
if ( is_serialized_string($option->option_value) ) {
$option->option_value = esc_html(maybe_unserialize($option->option_value), 'single');
} else {
$option->option_value = "SERIALIZED DATA";
$disabled = ' disabled="disabled"';
$disabled = true;
}
}
if ( stristr($option->option_value, "\r") || stristr($option->option_value, "\n") || stristr($option->option_value, "\r\n") ) {
?>
<tr class="form-field">
<th scope="row"><?php echo ucwords( str_replace( "_", " ", $option->option_name ) ) ?></th>
<td><textarea rows="5" cols="40" name="option[<?php echo esc_attr($option->option_name) ?>]" id="<?php echo esc_attr($option->option_name) ?>"<?php echo $disabled ?>><?php echo esc_html( $option->option_value ) ?></textarea></td>
<td><textarea rows="5" cols="40" name="option[<?php echo esc_attr($option->option_name) ?>]" id="<?php echo esc_attr($option->option_name) ?>"<?php disabled( $disabled ) ?>><?php echo esc_html( $option->option_value ) ?></textarea></td>
</tr>
<?php
} else {
@ -188,7 +188,7 @@ switch ( $action ) {
<?php if ( $is_main_site && in_array( $option->option_name, array( 'siteurl', 'home' ) ) ) { ?>
<td><?php echo esc_attr( $option->option_value ) ?></td>
<?php } else { ?>
<td><input name="option[<?php echo esc_attr($option->option_name) ?>]" type="text" id="<?php echo esc_attr($option->option_name) ?>" value="<?php echo esc_attr( $option->option_value ) ?>" size="40" <?php echo $disabled ?> /></td>
<td><input name="option[<?php echo esc_attr($option->option_name) ?>]" type="text" id="<?php echo esc_attr($option->option_name) ?>" value="<?php echo esc_attr( $option->option_value ) ?>" size="40" <?php disabled( $disabled ) ?> /></td>
<?php } ?>
</tr>
<?php

View File

@ -75,11 +75,11 @@ include('./admin-header.php');
<?php if ( !is_multisite() ) { ?>
<tr valign="top">
<th scope="row"><label for="siteurl"><?php _e('WordPress address (URL)') ?></label></th>
<td><input name="siteurl" type="text" id="siteurl" value="<?php form_option('siteurl'); ?>" class="regular-text code<?php if ( defined( 'WP_SITEURL' ) ) : ?> disabled" disabled="disabled"<?php else: ?>"<?php endif; ?> /></td>
<td><input name="siteurl" type="text" id="siteurl" value="<?php form_option('siteurl'); ?>"<?php $disabled = disabled( defined( 'WP_SITEURL' ) ); ?> class="regular-text code<?php if ( $disabled ) echo ' disabled' ?>" /></td>
</tr>
<tr valign="top">
<th scope="row"><label for="home"><?php _e('Blog address (URL)') ?></label></th>
<td><input name="home" type="text" id="home" value="<?php form_option('home'); ?>" class="regular-text code<?php if ( defined( 'WP_HOME' ) ) : ?> disabled" disabled="disabled"<?php else: ?>"<?php endif; ?> />
<td><input name="home" type="text" id="home" value="<?php form_option('home'); ?>"<?php $disabled = disabled( defined( 'WP_HOME' ) ); ?> class="regular-text code<?php if ( $disabled ) echo ' disabled' ?>" />
<span class="description"><?php _e('Enter the address here if you want your blog homepage <a href="http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory">to be different from the directory</a> you installed WordPress.'); ?></span></td>
</tr>
<tr valign="top">

View File

@ -173,7 +173,7 @@ include('admin-header.php'); ?>
$options = $wpdb->get_results( "SELECT * FROM $wpdb->options ORDER BY option_name" );
foreach ( (array) $options as $option ) :
$disabled = '';
$disabled = false;
if ( $option->option_name == '' )
continue;
if ( is_serialized( $option->option_value ) ) {
@ -184,7 +184,7 @@ foreach ( (array) $options as $option ) :
$class = 'all-options';
} else {
$value = 'SERIALIZED DATA';
$disabled = ' disabled="disabled"';
$disabled = true;
$class = 'all-options disabled';
}
} else {
@ -200,7 +200,7 @@ foreach ( (array) $options as $option ) :
if ( strpos( $value, "\n" ) !== false )
echo "<textarea class='$class' name='$name' id='$name' cols='30' rows='5'>" . wp_htmledit_pre( $value ) . "</textarea>";
else
echo "<input class='regular-text $class' type='text' name='$name' id='$name' value='" . esc_attr( $value ) . "'$disabled />";
echo "<input class='regular-text $class' type='text' name='$name' id='$name' value='" . esc_attr( $value ) . "'" . disabled( $disabled, true, false ) . " />";
echo "</td>
</tr>";
endforeach;