<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[BuddyPress][6294] trunk/bp-xprofile: XProfile:</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://buddypress.trac.wordpress.org/changeset/6294">6294</a></dd>
<dt>Author</dt> <dd>johnjamesjacoby</dd>
<dt>Date</dt> <dd>2012-09-03 02:28:05 +0000 (Mon, 03 Sep 2012)</dd>
</dl>
<h3>Log Message</h3>
<pre>XProfile:
* Allow options to be sorted.
* Escape all the things.
* Props humanshell.
* Fixes <a href="http://buddypress.trac.wordpress.org/ticket/3778">#3778</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpxprofileadmincssadmincss">trunk/bp-xprofile/admin/css/admin.css</a></li>
<li><a href="#trunkbpxprofileadminjsadminjs">trunk/bp-xprofile/admin/js/admin.js</a></li>
<li><a href="#trunkbpxprofilebpxprofileclassesphp">trunk/bp-xprofile/bp-xprofile-classes.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpxprofileadmincssadmincss"></a>
<div class="modfile"><h4>Modified: trunk/bp-xprofile/admin/css/admin.css (6293 => 6294)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-xprofile/admin/css/admin.css        2012-09-03 01:52:17 UTC (rev 6293)
+++ trunk/bp-xprofile/admin/css/admin.css        2012-09-03 02:28:05 UTC (rev 6294)
</span><span class="lines">@@ -26,7 +26,7 @@
</span><span class="cx">                         background-color: transparent;
</span><span class="cx">                         margin-right: 8px;
</span><span class="cx">                 }
</span><del>-                ul#field-group-tabs li.ui-state-hover {
</del><ins>+                ul#field-group-tabs li.ui-state-hover a {
</ins><span class="cx">                         background-color: #fafafa;
</span><span class="cx">                 }
</span><span class="cx">                 ul#field-group-tabs li.ui-state-hover a.ui-tab {
</span><span class="lines">@@ -38,7 +38,7 @@
</span><span class="cx">                         color: #8a8;
</span><span class="cx">                         background-color: #efe;
</span><span class="cx">                 }
</span><del>-                        ul#field-group-tabs li.ui-tabs-selected.ui-state-acceptable a.ui-tab {
</del><ins>+                        ul#field-group-tabs li.ui-state-active.ui-state-acceptable a.ui-tab {
</ins><span class="cx">                                 background-color: #f9f9f9;
</span><span class="cx">                         }
</span><span class="cx">                 ul#field-group-tabs li.drop-candidate a.ui-tab {
</span><span class="lines">@@ -60,7 +60,7 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 /* Selected tab */
</span><del>-                ul#field-group-tabs li.ui-tabs-selected a.ui-tab {
</del><ins>+                ul#field-group-tabs li.ui-state-active a.ui-tab {
</ins><span class="cx">                         background-color: #f9f9f9;
</span><span class="cx">                         margin-top: -1px;
</span><span class="cx">                         padding: 7px 10px 7px;
</span></span></pre></div>
<a id="trunkbpxprofileadminjsadminjs"></a>
<div class="modfile"><h4>Modified: trunk/bp-xprofile/admin/js/admin.js (6293 => 6294)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-xprofile/admin/js/admin.js        2012-09-03 01:52:17 UTC (rev 6293)
+++ trunk/bp-xprofile/admin/js/admin.js        2012-09-03 02:28:05 UTC (rev 6294)
</span><span class="lines">@@ -3,20 +3,20 @@
</span><span class="cx">         var theId = document.getElementById(forWhat + '_option_number').value;
</span><span class="cx">         var newDiv = document.createElement('p');
</span><span class="cx">         var newOption = document.createElement('input');
</span><del>-        var label = document.createElement( 'label' );
-        var txt = document.createTextNode( "Option " + theId + ": " );
</del><ins>+        var span = document.createElement( 'span' );
+        var txt = document.createTextNode( "\u00A0\u039E\u00A0" );
</ins><span class="cx">         var isDefault = document.createElement( 'input' );
</span><del>-        var label1 = document.createElement( 'label' );
</del><ins>+        var span1 = document.createElement( 'span' );
</ins><span class="cx">         var txt1 = document.createTextNode( " Default Value " );
</span><span class="cx">
</span><span class="cx">         newDiv.setAttribute('id', forWhat + '_div' + theId);
</span><ins>+        newDiv.setAttribute('class', 'sortable');
</ins><span class="cx">         
</span><span class="cx">         newOption.setAttribute( 'type', 'text' );
</span><span class="cx">         newOption.setAttribute( 'name', forWhat + '_option[' + theId + ']' );
</span><span class="cx">         newOption.setAttribute( 'id', forWhat + '_option' + theId );
</span><span class="cx">
</span><del>-        label.setAttribute( 'for', forWhat + '_option' + theId );
-        label.appendChild( txt );
</del><ins>+        span.appendChild( txt );
</ins><span class="cx">
</span><span class="cx">         if ( forWhat == 'checkbox' || forWhat == 'multiselectbox' ) {
</span><span class="cx">                 isDefault.setAttribute( 'type', 'checkbox' );
</span><span class="lines">@@ -28,8 +28,7 @@
</span><span class="cx">
</span><span class="cx">         isDefault.setAttribute( 'value', theId );
</span><span class="cx">
</span><del>-        label1.appendChild( txt1 );
-        label1.setAttribute( 'for', 'isDefault_' + forWhat + '_option[]' );
</del><ins>+        span1.appendChild( txt1 );
</ins><span class="cx">
</span><span class="cx">         var toDelete = document.createElement( 'a' );
</span><span class="cx">         var toDeleteText = document.createTextNode( '[x]' );
</span><span class="lines">@@ -38,14 +37,16 @@
</span><span class="cx">         toDelete.setAttribute( 'class', 'delete' );
</span><span class="cx">         toDelete.appendChild( toDeleteText );
</span><span class="cx">
</span><del>-        newDiv.appendChild( label );
</del><ins>+        newDiv.appendChild( span );
</ins><span class="cx">         newDiv.appendChild( newOption );
</span><span class="cx">         newDiv.appendChild( document.createTextNode( " " ) );
</span><span class="cx">         newDiv.appendChild( isDefault );
</span><del>-        newDiv.appendChild( label1 );
</del><ins>+        newDiv.appendChild( span1 );
</ins><span class="cx">         newDiv.appendChild( toDelete );
</span><span class="cx">         holder.appendChild( newDiv );
</span><span class="cx">
</span><ins>+        // re-initialize the sorable ui
+        enableSortableFieldOptions( forWhat );
</ins><span class="cx">
</span><span class="cx">         theId++;
</span><span class="cx">
</span><span class="lines">@@ -85,9 +86,27 @@
</span><span class="cx">         return ui;
</span><span class="cx"> };
</span><span class="cx">
</span><del>-// Set up deleting options ajax
</del><ins>+function enableSortableFieldOptions( forWhat ) {
+        if ( jQuery( '#' + forWhat + ' p.sortable' ).length > 1 ) {
+                jQuery( '.options-box' ).sortable( {
+                        items: 'p.sortable',
+                        tolerance: 'pointer',
+                        axis: 'y',
+                        handle: 'span'
+                });
+
+                jQuery( '.sortable span' ).css( 'cursor', 'move' );
+        }
+}
+
+function destroySortableFieldOptions() {
+        jQuery( '.options-box' ).sortable( 'destroy' );
+        jQuery( '.sortable span' ).css( 'cursor', 'default' );
+}
+
</ins><span class="cx"> jQuery( document ).ready( function() {
</span><span class="cx">
</span><ins>+        // Set up deleting options ajax
</ins><span class="cx">         jQuery( 'a.ajax-option-delete' ).click(
</span><span class="cx">                 function() {
</span><span class="cx">                         var theId = this.id.split( '-' );
</span><span class="lines">@@ -103,6 +122,15 @@
</span><span class="cx">                 }
</span><span class="cx">         );
</span><span class="cx">
</span><ins>+        //
+        jQuery( '[id^="sort_order_"]' ).change(function() {
+                if ( jQuery( this ).val() != 'custom' ) {
+                        destroySortableFieldOptions();
+                } else {
+                        enableSortableFieldOptions( jQuery('#fieldtype :selected').val() );
+                }
+        });
+
</ins><span class="cx">         // Show object if JS is enabled
</span><span class="cx">         jQuery( 'ul#field-group-tabs' ).show();
</span><span class="cx">
</span><span class="lines">@@ -150,6 +178,9 @@
</span><span class="cx">         // Change cursor to move if JS is enabled
</span><span class="cx">         .css( 'cursor', 'move' );
</span><span class="cx">
</span><ins>+        // Allow reordering of field options
+        enableSortableFieldOptions( jQuery('#fieldtype :selected').val() );
+
</ins><span class="cx">         // tabs init with a custom tab template and an "add" callback filling in the content
</span><span class="cx">         var $tab_items;
</span><span class="cx">         var $tabs = jQuery( '#tabs' ).tabs();
</span><span class="lines">@@ -206,4 +237,4 @@
</span><span class="cx">                         }
</span><span class="cx">                 });
</span><span class="cx">         }
</span><del>-});
</del><span class="cx">\ No newline at end of file
</span><ins>+});
</ins></span></pre></div>
<a id="trunkbpxprofilebpxprofileclassesphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-xprofile/bp-xprofile-classes.php (6293 => 6294)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-xprofile/bp-xprofile-classes.php        2012-09-03 01:52:17 UTC (rev 6293)
+++ trunk/bp-xprofile/bp-xprofile-classes.php        2012-09-03 02:28:05 UTC (rev 6294)
</span><span class="lines">@@ -380,7 +380,7 @@
</span><span class="cx">                         <?php endif; ?>
</span><span class="cx">
</span><span class="cx">                         <div id="poststuff">
</span><del>-                                <form action="<?php echo esc_attr( $action ); ?>" method="post">
</del><ins>+                                <form action="<?php echo esc_erl( $action ); ?>" method="post">
</ins><span class="cx">                                         <div id="titlediv">
</span><span class="cx">                                                 <h3><label for="group_name"><?php _e( "Field Group Title", 'buddypress') ?> *</label></h3>
</span><span class="cx">                                                 <div id="titlewrap">
</span><span class="lines">@@ -736,13 +736,14 @@
</span><span class="cx">
</span><span class="cx">                         ?>
</span><span class="cx">
</span><del>-                        <div id="<?php echo $type; ?>" class="options-box" style="<?php echo $class; ?> margin-left: 15px;">
</del><ins>+                        <div id="<?php echo esc_attr( $type ); ?>" class="options-box" style="<?php echo esc_attr( $class ); ?> margin-left: 15px;">
</ins><span class="cx">                                 <h4><?php _e( 'Please enter options for this Field:', 'buddypress' ); ?></h4>
</span><del>-                                <p><label for="sort_order_<?php echo $type; ?>"><?php _e( 'Order By:', 'buddypress' ); ?></label>
-                                        <select name="sort_order_<?php echo $type; ?>" id="sort_order_<?php echo $type; ?>" >
-                                                <option value="default" <?php if ( 'default' == $this->order_by ) {?> selected="selected"<?php } ?> ><?php _e( 'Order Entered', 'buddypress' ); ?></option>
-                                                <option value="asc" <?php if ( 'asc' == $this->order_by ) {?> selected="selected"<?php } ?>><?php _e( 'Name - Ascending', 'buddypress' ); ?></option>
-                                                <option value="desc" <?php if ( 'desc' == $this->order_by ) {?> selected="selected"<?php } ?>><?php _e( 'Name - Descending', 'buddypress' ); ?></option>
</del><ins>+                                <p>
+                                        <label for="sort_order_<?php echo esc_attr( $type ); ?>"><?php _e( 'Sort Order:', 'buddypress' ); ?></label>
+                                        <select name="sort_order_<?php echo esc_attr( $type ); ?>" id="sort_order_<?php echo esc_attr( $type ); ?>" >
+                                                <option value="custom" <?php selected( 'custom', $this->order_by ); ?>><?php _e( 'Custom', 'buddypress' ); ?></option>
+                                                <option value="asc" <?php selected( 'asc', $this->order_by ); ?>><?php _e( 'Ascending', 'buddypress' ); ?></option>
+                                                <option value="desc" <?php selected( 'desc', $this->order_by ); ?>><?php _e( 'Descending', 'buddypress' ); ?></option>
</ins><span class="cx">                                         </select>
</span><span class="cx">
</span><span class="cx">                                 <?php if ( !$options = $this->get_children( true ) ) {
</span><span class="lines">@@ -766,35 +767,35 @@
</span><span class="cx">                                                 if ( 'multiselectbox' == $type || 'checkbox' == $type )
</span><span class="cx">                                                         $default_name = '[' . $j . ']'; ?>
</span><span class="cx">
</span><del>-                                                <p><?php _e( 'Option', 'buddypress' ); ?> <?php echo $j; ?>:
-                                                 <input type="text" name="<?php echo $type; ?>_option[<?php echo $j; ?>]" id="<?php echo $type; ?>_option<?php echo $j; ?>" value="<?php echo stripslashes( esc_attr( $options[$i]->name ) ); ?>" />
-                                                 <input type="<?php echo $default_input; ?>" name="isDefault_<?php echo $type; ?>_option<?php echo $default_name; ?>" <?php if ( (int) $options[$i]->is_default_option ) {?> checked="checked"<?php } ?> " value="<?php echo $j; ?>" /> <?php _e( 'Default Value', 'buddypress' ); ?>
-
-                                                        <?php if ( $j != 1 && $options[$i]->id != -1 ) : ?>
-
-                                                                <a href="admin.php?page=bp-profile-setup&amp;mode=delete_option&amp;option_id=<?php echo $options[$i]->id ?>" class="ajax-option-delete" id="delete-<?php echo $options[$i]->id; ?>">[x]</a>
-
-                                                        <?php endif; ?>
-
</del><ins>+                                                <p class="sortable">
+                                                        <span>&nbsp;&Xi;&nbsp;</span>
+                                                        <input type="text" name="<?php echo esc_attr( $type ); ?>_option[<?php echo esc_attr( $j ); ?>]" id="<?php echo esc_attr( $type ); ?>_option<?php echo esc_attr( $j ); ?>" value="<?php echo stripslashes( esc_attr( $options[$i]->name ) ); ?>" />
+                                                        <input type="<?php echo $default_input; ?>" name="isDefault_<?php echo esc_attr( $type ); ?>_option<?php echo esc_attr( $default_name ); ?>" <?php checked( (int) $options[$i]->is_default_option, true ); ?> value="<?php echo esc_attr( $j ); ?>" />
+                                                        <span><?php _e( 'Default Value', 'buddypress' ); ?></span>
+                                                        <a href="<?php echo esc_url( 'admin.php?page=bp-profile-setup&amp;mode=delete_option&amp;option_id=' . $options[$i]->id ); ?>" class="ajax-option-delete" id="delete-<?php echo esc_attr( $options[$i]->id ); ?>">[x]</a>
</ins><span class="cx">                                                 </p>
</span><span class="cx">
</span><span class="cx">                                         <?php } /* end for */ ?>
</span><span class="cx">
</span><del>-                                        <input type="hidden" name="<?php echo $type; ?>_option_number" id="<?php echo $type; ?>_option_number" value="<?php echo $j + 1; ?>" />
</del><ins>+                                        <input type="hidden" name="<?php echo esc_attr( $type ); ?>_option_number" id="<?php echo esc_attr( $type ); ?>_option_number" value="<?php echo esc_attr( (int) $j + 1 ); ?>" />
</ins><span class="cx">
</span><span class="cx">                                 <?php } else {
</span><span class="cx">
</span><span class="cx">                                         if ( 'multiselectbox' == $type || 'checkbox' == $type )
</span><span class="cx">                                                 $default_name = '[1]'; ?>
</span><span class="cx">
</span><del>-                                        <p><?php _e( 'Option', 'buddypress' ); ?> 1: <input type="text" name="<?php echo $type; ?>_option[1]" id="<?php echo $type; ?>_option1" />
-                                        <input type="<?php echo $default_input; ?>" name="isDefault_<?php echo $type; ?>_option<?php echo $default_name; ?>" id="isDefault_<?php echo $type; ?>_option" value="1" /> <?php _e( 'Default Value', 'buddypress' ); ?>
-                                        <input type="hidden" name="<?php echo $type; ?>_option_number" id="<?php echo $type; ?>_option_number" value="2" />
</del><ins>+                                        <p class="sortable">
+                                                <span>&nbsp;&Xi;&nbsp;</span>
+                                                <input type="text" name="<?php echo esc_attr( $type ); ?>_option[1]" id="<?php echo esc_attr( $type ); ?>_option1" />
+                                                <input type="<?php echo esc_attr( $default_input ); ?>" name="isDefault_<?php echo esc_attr( $type ); ?>_option<?php echo esc_attr( $default_name ); ?>" id="isDefault_<?php echo esc_attr( $type ); ?>_option" value="1" />
+                                                <span><?php _e( 'Default Value', 'buddypress' ); ?></span>
+                                                <input type="hidden" name="<?php echo esc_attr( $type ); ?>_option_number" id="<?php echo esc_attr( $type ); ?>_option_number" value="2" />
+                                        </p>
</ins><span class="cx">
</span><span class="cx">                                 <?php } /* end if */ ?>
</span><span class="cx">
</span><del>-                                <div id="<?php echo $type; ?>_more"></div>
-                                <p><a href="javascript:add_option('<?php echo $type; ?>')"><?php _e('Add Another Option', 'buddypress'); ?></a></p>
</del><ins>+                                <div id="<?php echo esc_attr( $type ); ?>_more"></div>
+                                <p><a href="javascript:add_option('<?php echo esc_attr( $type ); ?>')"><?php _e( 'Add Another Option', 'buddypress' ); ?></a></p>
</ins><span class="cx">                         </div>
</span><span class="cx">
</span><span class="cx">                 <?php }
</span><span class="lines">@@ -802,11 +803,11 @@
</span><span class="cx">
</span><span class="cx">         function render_admin_form( $message = '' ) {
</span><span class="cx">                 if ( empty( $this->id ) ) {
</span><del>-                        $title                                = __( 'Add Field', 'buddypress' );
-                        $action                                = "admin.php?page=bp-profile-setup&amp;group_id=" . $this->group_id . "&amp;mode=add_field#tabs-" . $this->group_id;
</del><ins>+                        $title = __( 'Add Field', 'buddypress' );
+                        $action        = "admin.php?page=bp-profile-setup&amp;group_id=" . $this->group_id . "&amp;mode=add_field#tabs-" . $this->group_id;
</ins><span class="cx">
</span><span class="cx">                         if ( !empty( $_POST['saveField'] ) ) {
</span><del>-                                $this->name          = $_POST['title'];
</del><ins>+                                $this->name = $_POST['title'];
</ins><span class="cx">                                 $this->description = $_POST['description'];
</span><span class="cx">                                 $this->is_required = $_POST['required'];
</span><span class="cx">                                 $this->type = $_POST['fieldtype'];
</span><span class="lines">@@ -820,18 +821,18 @@
</span><span class="cx">
</span><span class="cx">                 <div class="wrap">
</span><span class="cx">                         <div id="icon-users" class="icon32"><br /></div>
</span><del>-                        <h2><?php echo $title; ?></h2>
</del><ins>+                        <h2><?php echo esc_html( $title ); ?></h2>
</ins><span class="cx">                         <p><?php _e( 'Fields marked * are required', 'buddypress' ) ?></p>
</span><span class="cx">
</span><span class="cx">                         <?php if ( !empty( $message ) ) : ?>
</span><span class="cx">
</span><span class="cx">                                 <div id="message" class="error fade">
</span><del>-                                        <p><?php echo $message; ?></p>
</del><ins>+                                        <p><?php echo esc_html( $message ); ?></p>
</ins><span class="cx">                                 </div>
</span><span class="cx">
</span><span class="cx">                         <?php endif; ?>
</span><span class="cx">
</span><del>-                        <form action="<?php echo $action; ?>" method="post">
</del><ins>+                        <form action="<?php echo esc_url( $action ); ?>" method="post">
</ins><span class="cx">                                 <div id="poststuff">
</span><span class="cx">                                         <div id="titlediv">
</span><span class="cx">                                                 <h3><label for="title"><?php _e( 'Field Title', 'buddypress' ); ?> *</label></h3>
</span><span class="lines">@@ -843,30 +844,30 @@
</span><span class="cx">                                         <div id="titlediv">
</span><span class="cx">                                                 <h3><label for="description"><?php _e("Field Description", 'buddypress'); ?></label></h3>
</span><span class="cx">                                                 <div id="titlewrap">
</span><del>-                                                        <textarea name="description" id="description" rows="8" cols="60"><?php echo htmlspecialchars( $this->description ); ?></textarea>
</del><ins>+                                                        <textarea name="description" id="description" rows="8" cols="60"><?php echo esc_textarea( $this->description ); ?></textarea>
</ins><span class="cx">                                                 </div>
</span><span class="cx">                                         </div>
</span><span class="cx">
</span><del>-                                        <?php if ( '0' != $this->can_delete ) { ?>
</del><ins>+                                        <?php if ( '0' != $this->can_delete ) : ?>
</ins><span class="cx">
</span><span class="cx">                                                 <div id="titlediv">
</span><span class="cx">                                                         <h3><label for="required"><?php _e( "Is This Field Required?", 'buddypress' ); ?> *</label></h3>
</span><span class="cx">                                                         <select name="required" id="required" style="width: 30%">
</span><del>-                                                                <option value="0"<?php if ( $this->is_required == '0' ) { ?> selected="selected"<?php } ?>><?php _e( 'Not Required', 'buddypress' ); ?></option>
-                                                                <option value="1"<?php if ( $this->is_required == '1' ) { ?> selected="selected"<?php } ?>><?php _e( 'Required', 'buddypress' ); ?></option>
</del><ins>+                                                                <option value="0"<?php selected( $this->is_required, '0' ); ?>><?php _e( 'Not Required', 'buddypress' ); ?></option>
+                                                                <option value="1"<?php selected( $this->is_required, '1' ); ?>><?php _e( 'Required', 'buddypress' ); ?></option>
</ins><span class="cx">                                                         </select>
</span><span class="cx">                                                 </div>
</span><span class="cx">
</span><span class="cx">                                                 <div id="titlediv">
</span><del>-                                                        <h3><label for="fieldtype"><?php _e("Field Type", 'buddypress'); ?> *</label></h3>
</del><ins>+                                                        <h3><label for="fieldtype"><?php _e( 'Field Type', 'buddypress'); ?> *</label></h3>
</ins><span class="cx">                                                         <select name="fieldtype" id="fieldtype" onchange="show_options(this.value)" style="width: 30%">
</span><del>-                                                                <option value="textbox"<?php if ( $this->type == 'textbox' ) {?> selected="selected"<?php } ?>><?php _e( 'Text Box', 'buddypress' ); ?></option>
-                                                                <option value="textarea"<?php if ( $this->type == 'textarea' ) {?> selected="selected"<?php } ?>><?php _e( 'Multi-line Text Box', 'buddypress' ); ?></option>
-                                                                <option value="datebox"<?php if ( $this->type == 'datebox' ) {?> selected="selected"<?php } ?>><?php _e( 'Date Selector', 'buddypress' ); ?></option>
-                                                                <option value="radio"<?php if ( $this->type == 'radio' ) {?> selected="selected"<?php } ?>><?php _e( 'Radio Buttons', 'buddypress' ); ?></option>
-                                                                <option value="selectbox"<?php if ( $this->type == 'selectbox' ) {?> selected="selected"<?php } ?>><?php _e( 'Drop Down Select Box', 'buddypress' ); ?></option>
-                                                                <option value="multiselectbox"<?php if ( $this->type == 'multiselectbox' ) {?> selected="selected"<?php } ?>><?php _e( 'Multi Select Box', 'buddypress' ); ?></option>
-                                                                <option value="checkbox"<?php if ( $this->type == 'checkbox' ) {?> selected="selected"<?php } ?>><?php _e( 'Checkboxes', 'buddypress' ); ?></option>
</del><ins>+                                                                <option value="textbox" <?php selected( $this->type, 'textbox' ); ?>><?php _e( 'Text Box', 'buddypress' ); ?></option>
+                                                                <option value="textarea" <?php selected( $this->type, 'textarea' ); ?>><?php _e( 'Multi-line Text Box', 'buddypress' ); ?></option>
+                                                                <option value="datebox" <?php selected( $this->type, 'datebox' ); ?>><?php _e( 'Date Selector', 'buddypress' ); ?></option>
+                                                                <option value="radio" <?php selected( $this->type, 'radio' ); ?>><?php _e( 'Radio Buttons', 'buddypress' ); ?></option>
+                                                                <option value="selectbox" <?php selected( $this->type, 'selectbox' ); ?>><?php _e( 'Drop Down Select Box', 'buddypress' ); ?></option>
+                                                                <option value="multiselectbox" <?php selected( $this->type, 'multiselectbox' ); ?>><?php _e( 'Multi Select Box', 'buddypress' ); ?></option>
+                                                                <option value="checkbox" <?php selected( $this->type, 'checkbox' ); ?>><?php _e( 'Checkboxes', 'buddypress' ); ?></option>
</ins><span class="cx">                                                         </select>
</span><span class="cx">                                                 </div>
</span><span class="cx">
</span><span class="lines">@@ -874,33 +875,35 @@
</span><span class="cx">
</span><span class="cx">                                                 <?php $this->render_admin_form_children(); ?>
</span><span class="cx">
</span><del>-                                        <?php } else { ?>
</del><ins>+                                        <?php else : ?>
</ins><span class="cx">
</span><del>-                                                <input type="hidden" name="required" id="required" value="1" />
</del><ins>+                                                <input type="hidden" name="required" id="required" value="1" />
</ins><span class="cx">                                                 <input type="hidden" name="fieldtype" id="fieldtype" value="textbox" />
</span><span class="cx">
</span><del>-                                        <?php } ?>
</del><ins>+                                        <?php endif;
</ins><span class="cx">
</span><del>-                                        <?php /* The fullname field cannot be hidden */ ?>
-                                        <?php if ( 1 != $this->id ) : ?>
</del><ins>+                                        /* The fullname field cannot be hidden */
+                                        if ( 1 != $this->id ) : ?>
</ins><span class="cx">
</span><span class="cx">                                                 <div id="titlediv">
</span><del>-
</del><span class="cx">                                                         <div id="titlewrap">
</span><del>-                                                                <h3><label for="default-visibility"><?php _e( "Default Visibility", 'buddypress' ); ?></label></h3>
</del><ins>+                                                                <h3><label for="default-visibility"><?php _e( 'Default Visibility', 'buddypress' ); ?></label></h3>
</ins><span class="cx">                                                                 <ul>
</span><del>-                                                                <?php foreach( bp_xprofile_get_visibility_levels() as $level ) : ?>
-                                                                        <li><input type="radio" name="default-visibility" value="<?php echo esc_attr( $level['id'] ) ?>" <?php checked( $this->default_visibility, $level['id'] ) ?>> <?php echo esc_html( $level['label'] ) ?></li>
-                                                                <?php endforeach ?>
</del><ins>+
+                                                                        <?php foreach( bp_xprofile_get_visibility_levels() as $level ) : ?>
+
+                                                                                <li><input type="radio" name="default-visibility" value="<?php echo esc_attr( $level['id'] ) ?>" <?php checked( $this->default_visibility, $level['id'] ); ?>> <?php echo esc_html( $level['label'] ) ?></li>
+
+                                                                        <?php endforeach ?>
+
</ins><span class="cx">                                                                 </ul>
</span><span class="cx">                                                         </div>
</span><span class="cx">
</span><span class="cx">                                                         <div id="titlewrap">
</span><del>-                                                                <h3><label for="allow-custom-visibility"><?php _e( "Per-Member Visibility", 'buddypress' ); ?></label></h3>
</del><ins>+                                                                <h3><label for="allow-custom-visibility"><?php _e( 'Per-Member Visibility', 'buddypress' ); ?></label></h3>
</ins><span class="cx">                                                                 <ul>
</span><del>-                                                                        <li><input type="radio" name="allow-custom-visibility" value="allowed" <?php checked( $this->allow_custom_visibility, 'allowed' ) ?>> <?php _e( "Let members change the this field's visibility", 'buddypress' ) ?></li>
-
-                                                                        <li><input type="radio" name="allow-custom-visibility" value="disabled" <?php checked( $this->allow_custom_visibility, 'disabled' ) ?>> <?php _e( 'Enforce the default visibility for all members', 'buddypress' ) ?></li>
</del><ins>+                                                                        <li><input type="radio" name="allow-custom-visibility" value="allowed" <?php checked( $this->allow_custom_visibility, 'allowed' ); ?>> <?php _e( "Let members change the this field's visibility", 'buddypress' ); ?></li>
+                                                                        <li><input type="radio" name="allow-custom-visibility" value="disabled" <?php checked( $this->allow_custom_visibility, 'disabled' ); ?>> <?php _e( 'Enforce the default visibility for all members', 'buddypress' ); ?></li>
</ins><span class="cx">                                                                 </ul>
</span><span class="cx">                                                         </div>
</span><span class="cx">                                                 </div>
</span><span class="lines">@@ -957,8 +960,9 @@
</span><span class="cx">         var $last_updated;
</span><span class="cx">
</span><span class="cx">         function __construct( $field_id = null, $user_id = null ) {
</span><del>-                if ( !empty( $field_id ) )
</del><ins>+                if ( !empty( $field_id ) ) {
</ins><span class="cx">                         $this->populate( $field_id, $user_id );
</span><ins>+                }
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         function populate( $field_id, $user_id ) {
</span><span class="lines">@@ -1070,9 +1074,9 @@
</span><span class="cx">                 $profile_data = array();
</span><span class="cx">
</span><span class="cx">                 if ( !empty( $results ) ) {
</span><del>-                        $profile_data['user_login']                = $results[0]->user_login;
-                        $profile_data['user_nicename']        = $results[0]->user_nicename;
-                        $profile_data['user_email']                = $results[0]->user_email;
</del><ins>+                        $profile_data['user_login'] = $results[0]->user_login;
+                        $profile_data['user_nicename'] = $results[0]->user_nicename;
+                        $profile_data['user_email'] = $results[0]->user_email;
</ins><span class="cx">
</span><span class="cx">                         foreach( (array) $results as $field ) {
</span><span class="cx">                                 $profile_data[$field->field_name] = array(
</span><span class="lines">@@ -1136,10 +1140,11 @@
</span><span class="cx">
</span><span class="cx">                 if ( is_array( $fields ) ) {
</span><span class="cx">                         for ( $i = 0, $count = count( $fields ); $i < $count; ++$i ) {
</span><del>-                                if ( $i == 0 )
</del><ins>+                                if ( $i == 0 ) {
</ins><span class="cx">                                         $field_sql .= $wpdb->prepare( "AND ( f.name = %s ", $fields[$i] );
</span><del>-                                else
</del><ins>+                                } else {
</ins><span class="cx">                                         $field_sql .= $wpdb->prepare( "OR f.name = %s ", $fields[$i] );
</span><ins>+                                }
</ins><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         $field_sql .= ')';
</span><span class="lines">@@ -1157,10 +1162,11 @@
</span><span class="cx">                 if ( is_array( $fields ) ) {
</span><span class="cx">                         for ( $i = 0, $count = count( $values ); $i < $count; ++$i ) {
</span><span class="cx">                                 for ( $j = 0; $j < count( $fields ); $j++ ) {
</span><del>-                                        if ( $values[$i]->name == $fields[$j] )
</del><ins>+                                        if ( $values[$i]->name == $fields[$j] ) {
</ins><span class="cx">                                                 $new_values[$fields[$j]] = $values[$i]->value;
</span><del>-                                        else if ( !array_key_exists( $fields[$j], $new_values ) )
</del><ins>+                                        } else if ( !array_key_exists( $fields[$j], $new_values ) ) {
</ins><span class="cx">                                                 $new_values[$fields[$j]] = NULL;
</span><ins>+                                        }
</ins><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                 } else {
</span><span class="lines">@@ -1208,11 +1214,8 @@
</span><span class="cx">                         $user_id = bp_displayed_user_id();
</span><span class="cx">
</span><span class="cx">                 $field_name = bp_xprofile_fullname_field_name();
</span><ins>+                $data = xprofile_get_field_data( $field_name, $user_id );
</ins><span class="cx">
</span><del>-                $data = xprofile_get_field_data( $field_name, $user_id );
-
</del><span class="cx">                 return $data[$field_name];
</span><span class="cx">         }
</span><span class="cx"> }
</span><del>-
-?>
</del></span></pre>
</div>
</div>
</body>
</html>