Checkboxes over radio buttons for site info tab. Values outside of 0/1 won't be changed, see #12832 for previous discussion. see #15174.

git-svn-id: http://svn.automattic.com/wordpress/trunk@15906 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2010-10-21 20:23:54 +00:00
parent 57fe65fd6d
commit 1e640c7b0a
1 changed files with 19 additions and 13 deletions

View File

@ -47,6 +47,14 @@ if ( isset($_REQUEST['action']) && 'update-site' == $_REQUEST['action'] ) {
// update blogs table // update blogs table
$blog_data = stripslashes_deep( $_POST['blog'] ); $blog_data = stripslashes_deep( $_POST['blog'] );
$existing_details = get_blog_details( $id, false );
$blog_data_checkboxes = array( 'public', 'archived', 'spam', 'mature', 'deleted' );
foreach ( $blog_data_checkboxes as $c ) {
if ( ! in_array( $existing_details->$c, array( 0, 1 ) ) )
$blog_data[ $c ] = $existing_details->$c;
else
$blog_data[ $c ] = isset( $_POST['blog'][ $c ] ) ? 1 : 0;
}
update_blog_details( $id, $blog_data ); update_blog_details( $id, $blog_data );
do_action( 'wpmu_update_blog_options' ); do_action( 'wpmu_update_blog_options' );
@ -114,29 +122,27 @@ if ( ! empty( $messages ) ) {
<td><input name="blog[registered]" type="text" id="blog_registered" value="<?php echo esc_attr( $details->registered ) ?>" size="40" /></td> <td><input name="blog[registered]" type="text" id="blog_registered" value="<?php echo esc_attr( $details->registered ) ?>" size="40" /></td>
</tr> </tr>
<tr class="form-field"> <tr class="form-field">
<th scope="row"><?php _e('Last Updated') ?></th> <th scope="row"><?php _e( 'Last Updated' ); ?></th>
<td><input name="blog[last_updated]" type="text" id="blog_last_updated" value="<?php echo esc_attr( $details->last_updated ) ?>" size="40" /></td> <td><input name="blog[last_updated]" type="text" id="blog_last_updated" value="<?php echo esc_attr( $details->last_updated ) ?>" size="40" /></td>
</tr> </tr>
<?php <?php
$radio_fields = array( 'public' => __( 'Public' ) ); $attribute_fields = array( 'public' => __( 'Public' ) );
if ( ! $is_main_site ) { if ( ! $is_main_site ) {
$radio_fields['archived'] = __( 'Archived' ); $attribute_fields['archived'] = __( 'Archived' );
$radio_fields['spam'] = _x( 'Spam', 'site' ); $attribute_fields['spam'] = _x( 'Spam', 'site' );
$radio_fields['deleted'] = __( 'Deleted' ); $attribute_fields['deleted'] = __( 'Deleted' );
} }
$radio_fields['mature'] = __( 'Mature' ); $attribute_fields['mature'] = __( 'Mature' );
foreach ( $radio_fields as $field_key => $field_label ) {
?> ?>
<tr> <tr>
<th scope="row"><?php echo $field_label; ?></th> <th scope="row"><?php _e( 'Attributes' ); ?></th>
<td> <td>
<input type="radio" name="blog[<?php echo $field_key; ?>]" id="blog_<?php echo $field_key; ?>_1" value="1"<?php checked( $details->$field_key, 1 ); ?> /> <?php foreach ( $attribute_fields as $field_key => $field_label ) : ?>
<label for="blog_<?php echo $field_key; ?>_1"><?php _e('Yes'); ?></label> <label><input type="checkbox" name="blog[<?php echo $field_key; ?>]" value="1" <?php checked( (bool) $details->$field_key, true ); disabled( ! in_array( $details->$field_key, array( 0, 1 ) ) ); ?> />
<input type="radio" name="blog[<?php echo $field_key; ?>]" id="blog_<?php echo $field_key; ?>_0" value="0"<?php checked( $details->$field_key, 0 ); ?> /> <?php echo $field_label; ?></label><br/>
<label for="blog_<?php echo $field_key; ?>_0"><?php _e('No'); ?></label> <?php endforeach; ?>
</td> </td>
</tr> </tr>
<?php } ?>
</table> </table>
<?php submit_button(); ?> <?php submit_button(); ?>
</form> </form>