Skip to:
Content

bbPress.org


Ignore:
Timestamp:
01/12/2010 10:54:40 PM (17 years ago)
Author:
mdawaffe
Message:

backport some of the profile_info_keys stuff to 0.9 so it can handle checkboxes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/0.9/bb-includes/template-functions.php

    r1889 r2389  
    14881488                        ) {
    14891489                                echo "\t<dt>{$label[1]}</dt>\n";
    1490                                 echo "\t<dd>" . make_clickable( $val ) . "</dd>\n";
     1490
     1491                                $val = make_clickable( $val );
     1492                                if (isset($label[2]) && !empty($label[2]))
     1493                                        if (preg_match("#^<a#i", $val))
     1494                                                $val = preg_replace("#^<a#i", '<a class="' . attribute_escape($label[2]) . '"', $val);
     1495                                        else
     1496                                                $val = '<span class="' . attribute_escape($label[2]) . '">' . $val . '</span>';
     1497                               
     1498                                echo "\t<dd>" . $val . "</dd>\n";
    14911499                        }
    14921500                }
     
    15311539                        $name = attribute_escape( $key );
    15321540                        $type = isset($label[2]) ? attribute_escape( $label[2] ) : 'text';
     1541                        $checked = false;
    15331542
    15341543                        if ( in_array( $key, $error_codes ) ) {
    15351544                                $class .= ' form-invalid';
    15361545                                $data = $errors->get_error_data( $key );
    1537                                 if ( isset($data['data']) )
    1538                                         $value = $data['data'];
    1539                                 else
    1540                                         $value = $_POST[$key];
     1546
     1547                                if ( 'checkbox' == $type ) {
     1548                                        if ( isset($data['data']) )
     1549                                                $checked = $data['data'];
     1550                                        else
     1551                                                $checked = $_POST[$key];
     1552                                        $value = $label[3];
     1553                                        $checked = $checked == $value;
     1554                                } else {
     1555                                        if ( isset($data['data']) )
     1556                                                $value = $data['data'];
     1557                                        else
     1558                                                $value = $_POST[$key];
     1559                                }
    15411560
    15421561                                $message = wp_specialchars( $errors->get_error_message( $key ) );
    15431562                                $message = "<p class='error'>$message</p>";
    15441563                        } else {
    1545                                 $value = $user->$key;
     1564                                if ( 'checkbox' == $type ) {
     1565                                        $checked = $user->$key == $label[3] || $label[4] == $label[3];
     1566                                        $value = $label[3];
     1567                                } else {
     1568                                        $value = isset($user->$key) ? $user->$key : '';
     1569                                }
    15461570                                $message = '';
    15471571                        }
     1572
     1573                        $checked = $checked ? ' checked="checked"' : '';
    15481574                        $value = attribute_escape( $value );
    15491575
     
    15531579        <th scope="row"><label for="<?php echo $name; ?>"><?php echo $title; ?></label></th>
    15541580        <td>
    1555                 <input name="<?php echo $name; ?>" type="<?php echo $type; ?>" id="<?php echo $name; ?>" value="<?php echo $value; ?>" />
     1581                <input name="<?php echo $name; ?>" type="<?php echo $type; ?>" id="<?php echo $name; ?>" value="<?php echo $value; ?>"<?php echo $checked; ?> />
    15561582                <?php echo $message; ?>
    15571583        </td>
Note: See TracChangeset for help on using the changeset viewer.