<!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( &quot;Option &quot; + theId + &quot;: &quot; );
</del><ins>+        var span     = document.createElement( 'span' );
+        var txt       = document.createTextNode( &quot;\u00A0\u039E\u00A0&quot; );
</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( &quot; Default Value &quot; );
</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( &quot; &quot; ) );
</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 &gt; 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^=&quot;sort_order_&quot;]' ).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 &quot;add&quot; 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">                         &lt;?php endif; ?&gt;
</span><span class="cx"> 
</span><span class="cx">                         &lt;div id=&quot;poststuff&quot;&gt;
</span><del>-                                &lt;form action=&quot;&lt;?php echo esc_attr( $action ); ?&gt;&quot; method=&quot;post&quot;&gt;
</del><ins>+                                &lt;form action=&quot;&lt;?php echo esc_erl( $action ); ?&gt;&quot; method=&quot;post&quot;&gt;
</ins><span class="cx">                                         &lt;div id=&quot;titlediv&quot;&gt;
</span><span class="cx">                                                 &lt;h3&gt;&lt;label for=&quot;group_name&quot;&gt;&lt;?php _e( &quot;Field Group Title&quot;, 'buddypress') ?&gt; *&lt;/label&gt;&lt;/h3&gt;
</span><span class="cx">                                                 &lt;div id=&quot;titlewrap&quot;&gt;
</span><span class="lines">@@ -736,13 +736,14 @@
</span><span class="cx"> 
</span><span class="cx">                         ?&gt;
</span><span class="cx"> 
</span><del>-                        &lt;div id=&quot;&lt;?php echo $type; ?&gt;&quot; class=&quot;options-box&quot; style=&quot;&lt;?php echo $class; ?&gt; margin-left: 15px;&quot;&gt;
</del><ins>+                        &lt;div id=&quot;&lt;?php echo esc_attr( $type ); ?&gt;&quot; class=&quot;options-box&quot; style=&quot;&lt;?php echo esc_attr( $class ); ?&gt; margin-left: 15px;&quot;&gt;
</ins><span class="cx">                                 &lt;h4&gt;&lt;?php _e( 'Please enter options for this Field:', 'buddypress' ); ?&gt;&lt;/h4&gt;
</span><del>-                                &lt;p&gt;&lt;label for=&quot;sort_order_&lt;?php echo $type; ?&gt;&quot;&gt;&lt;?php _e( 'Order By:', 'buddypress' ); ?&gt;&lt;/label&gt;
-                                        &lt;select name=&quot;sort_order_&lt;?php echo $type; ?&gt;&quot; id=&quot;sort_order_&lt;?php echo $type; ?&gt;&quot; &gt;
-                                                &lt;option value=&quot;default&quot; &lt;?php if ( 'default' == $this-&gt;order_by ) {?&gt; selected=&quot;selected&quot;&lt;?php } ?&gt; &gt;&lt;?php _e( 'Order Entered', 'buddypress' ); ?&gt;&lt;/option&gt;
-                                                &lt;option value=&quot;asc&quot; &lt;?php if ( 'asc' == $this-&gt;order_by ) {?&gt; selected=&quot;selected&quot;&lt;?php } ?&gt;&gt;&lt;?php _e( 'Name - Ascending', 'buddypress' ); ?&gt;&lt;/option&gt;
-                                                &lt;option value=&quot;desc&quot; &lt;?php if ( 'desc' == $this-&gt;order_by ) {?&gt; selected=&quot;selected&quot;&lt;?php } ?&gt;&gt;&lt;?php _e( 'Name - Descending', 'buddypress' ); ?&gt;&lt;/option&gt;
</del><ins>+                                &lt;p&gt;
+                                        &lt;label for=&quot;sort_order_&lt;?php echo esc_attr( $type ); ?&gt;&quot;&gt;&lt;?php _e( 'Sort Order:', 'buddypress' ); ?&gt;&lt;/label&gt;
+                                        &lt;select name=&quot;sort_order_&lt;?php echo esc_attr( $type ); ?&gt;&quot; id=&quot;sort_order_&lt;?php echo esc_attr( $type ); ?&gt;&quot; &gt;
+                                                &lt;option value=&quot;custom&quot; &lt;?php selected( 'custom', $this-&gt;order_by ); ?&gt;&gt;&lt;?php _e( 'Custom',     'buddypress' ); ?&gt;&lt;/option&gt;
+                                                &lt;option value=&quot;asc&quot;    &lt;?php selected( 'asc',    $this-&gt;order_by ); ?&gt;&gt;&lt;?php _e( 'Ascending',  'buddypress' ); ?&gt;&lt;/option&gt;
+                                                &lt;option value=&quot;desc&quot;   &lt;?php selected( 'desc',   $this-&gt;order_by ); ?&gt;&gt;&lt;?php _e( 'Descending', 'buddypress' ); ?&gt;&lt;/option&gt;
</ins><span class="cx">                                         &lt;/select&gt;
</span><span class="cx"> 
</span><span class="cx">                                 &lt;?php if ( !$options = $this-&gt;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 . ']'; ?&gt;
</span><span class="cx"> 
</span><del>-                                                &lt;p&gt;&lt;?php _e( 'Option', 'buddypress' ); ?&gt; &lt;?php echo $j; ?&gt;:
-                                                   &lt;input type=&quot;text&quot; name=&quot;&lt;?php echo $type; ?&gt;_option[&lt;?php echo $j; ?&gt;]&quot; id=&quot;&lt;?php echo $type; ?&gt;_option&lt;?php echo $j; ?&gt;&quot; value=&quot;&lt;?php echo stripslashes( esc_attr( $options[$i]-&gt;name ) ); ?&gt;&quot; /&gt;
-                                                   &lt;input type=&quot;&lt;?php echo $default_input; ?&gt;&quot; name=&quot;isDefault_&lt;?php echo $type; ?&gt;_option&lt;?php echo $default_name; ?&gt;&quot; &lt;?php if ( (int) $options[$i]-&gt;is_default_option ) {?&gt; checked=&quot;checked&quot;&lt;?php } ?&gt; &quot; value=&quot;&lt;?php echo $j; ?&gt;&quot; /&gt; &lt;?php _e( 'Default Value', 'buddypress' ); ?&gt;
-
-                                                        &lt;?php if ( $j != 1 &amp;&amp; $options[$i]-&gt;id != -1 ) : ?&gt;
-
-                                                                &lt;a href=&quot;admin.php?page=bp-profile-setup&amp;amp;mode=delete_option&amp;amp;option_id=&lt;?php echo $options[$i]-&gt;id ?&gt;&quot; class=&quot;ajax-option-delete&quot; id=&quot;delete-&lt;?php echo $options[$i]-&gt;id; ?&gt;&quot;&gt;[x]&lt;/a&gt;
-
-                                                        &lt;?php endif; ?&gt;
-
</del><ins>+                                                &lt;p class=&quot;sortable&quot;&gt;
+                                                        &lt;span&gt;&amp;nbsp;&amp;Xi;&amp;nbsp;&lt;/span&gt;
+                                                        &lt;input type=&quot;text&quot; name=&quot;&lt;?php echo esc_attr( $type ); ?&gt;_option[&lt;?php echo esc_attr( $j ); ?&gt;]&quot; id=&quot;&lt;?php echo esc_attr( $type ); ?&gt;_option&lt;?php echo esc_attr( $j ); ?&gt;&quot; value=&quot;&lt;?php echo stripslashes( esc_attr( $options[$i]-&gt;name ) ); ?&gt;&quot; /&gt;
+                                                        &lt;input type=&quot;&lt;?php echo $default_input; ?&gt;&quot; name=&quot;isDefault_&lt;?php echo esc_attr( $type ); ?&gt;_option&lt;?php echo esc_attr( $default_name ); ?&gt;&quot; &lt;?php checked( (int) $options[$i]-&gt;is_default_option, true ); ?&gt; value=&quot;&lt;?php echo esc_attr( $j ); ?&gt;&quot; /&gt;
+                                                        &lt;span&gt;&lt;?php _e( 'Default Value', 'buddypress' ); ?&gt;&lt;/span&gt;
+                                                        &lt;a href=&quot;&lt;?php echo esc_url( 'admin.php?page=bp-profile-setup&amp;amp;mode=delete_option&amp;amp;option_id=' . $options[$i]-&gt;id ); ?&gt;&quot; class=&quot;ajax-option-delete&quot; id=&quot;delete-&lt;?php echo esc_attr( $options[$i]-&gt;id ); ?&gt;&quot;&gt;[x]&lt;/a&gt;
</ins><span class="cx">                                                 &lt;/p&gt;
</span><span class="cx"> 
</span><span class="cx">                                         &lt;?php } /* end for */ ?&gt;
</span><span class="cx"> 
</span><del>-                                        &lt;input type=&quot;hidden&quot; name=&quot;&lt;?php echo $type; ?&gt;_option_number&quot; id=&quot;&lt;?php echo $type; ?&gt;_option_number&quot; value=&quot;&lt;?php echo $j + 1; ?&gt;&quot; /&gt;
</del><ins>+                                        &lt;input type=&quot;hidden&quot; name=&quot;&lt;?php echo esc_attr( $type ); ?&gt;_option_number&quot; id=&quot;&lt;?php echo esc_attr( $type ); ?&gt;_option_number&quot; value=&quot;&lt;?php echo esc_attr( (int) $j + 1 ); ?&gt;&quot; /&gt;
</ins><span class="cx"> 
</span><span class="cx">                                 &lt;?php } else {
</span><span class="cx"> 
</span><span class="cx">                                         if ( 'multiselectbox' == $type || 'checkbox' == $type )
</span><span class="cx">                                                 $default_name = '[1]'; ?&gt;
</span><span class="cx"> 
</span><del>-                                        &lt;p&gt;&lt;?php _e( 'Option', 'buddypress' ); ?&gt; 1: &lt;input type=&quot;text&quot; name=&quot;&lt;?php echo $type; ?&gt;_option[1]&quot; id=&quot;&lt;?php echo $type; ?&gt;_option1&quot; /&gt;
-                                        &lt;input type=&quot;&lt;?php echo $default_input; ?&gt;&quot; name=&quot;isDefault_&lt;?php echo $type; ?&gt;_option&lt;?php echo $default_name; ?&gt;&quot; id=&quot;isDefault_&lt;?php echo $type; ?&gt;_option&quot; value=&quot;1&quot; /&gt; &lt;?php _e( 'Default Value', 'buddypress' ); ?&gt;
-                                        &lt;input type=&quot;hidden&quot; name=&quot;&lt;?php echo $type; ?&gt;_option_number&quot; id=&quot;&lt;?php echo $type; ?&gt;_option_number&quot; value=&quot;2&quot; /&gt;
</del><ins>+                                        &lt;p class=&quot;sortable&quot;&gt;
+                                                &lt;span&gt;&amp;nbsp;&amp;Xi;&amp;nbsp;&lt;/span&gt;
+                                                &lt;input type=&quot;text&quot; name=&quot;&lt;?php echo esc_attr( $type ); ?&gt;_option[1]&quot; id=&quot;&lt;?php echo esc_attr( $type ); ?&gt;_option1&quot; /&gt;
+                                                &lt;input type=&quot;&lt;?php echo esc_attr( $default_input ); ?&gt;&quot; name=&quot;isDefault_&lt;?php echo esc_attr( $type ); ?&gt;_option&lt;?php echo esc_attr( $default_name ); ?&gt;&quot; id=&quot;isDefault_&lt;?php echo esc_attr( $type ); ?&gt;_option&quot; value=&quot;1&quot; /&gt;
+                                                &lt;span&gt;&lt;?php _e( 'Default Value', 'buddypress' ); ?&gt;&lt;/span&gt;
+                                                &lt;input type=&quot;hidden&quot; name=&quot;&lt;?php echo esc_attr( $type ); ?&gt;_option_number&quot; id=&quot;&lt;?php echo esc_attr( $type ); ?&gt;_option_number&quot; value=&quot;2&quot; /&gt;
+                                        &lt;/p&gt;
</ins><span class="cx"> 
</span><span class="cx">                                 &lt;?php } /* end if */ ?&gt;
</span><span class="cx"> 
</span><del>-                                &lt;div id=&quot;&lt;?php echo $type; ?&gt;_more&quot;&gt;&lt;/div&gt;
-                                &lt;p&gt;&lt;a href=&quot;javascript:add_option('&lt;?php echo $type; ?&gt;')&quot;&gt;&lt;?php _e('Add Another Option', 'buddypress'); ?&gt;&lt;/a&gt;&lt;/p&gt;
</del><ins>+                                &lt;div id=&quot;&lt;?php echo esc_attr( $type ); ?&gt;_more&quot;&gt;&lt;/div&gt;
+                                &lt;p&gt;&lt;a href=&quot;javascript:add_option('&lt;?php echo esc_attr( $type ); ?&gt;')&quot;&gt;&lt;?php _e( 'Add Another Option', 'buddypress' ); ?&gt;&lt;/a&gt;&lt;/p&gt;
</ins><span class="cx">                         &lt;/div&gt;
</span><span class="cx"> 
</span><span class="cx">                 &lt;?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-&gt;id ) ) {
</span><del>-                        $title                                = __( 'Add Field', 'buddypress' );
-                        $action                                = &quot;admin.php?page=bp-profile-setup&amp;amp;group_id=&quot; . $this-&gt;group_id . &quot;&amp;amp;mode=add_field#tabs-&quot; . $this-&gt;group_id;
</del><ins>+                        $title  = __( 'Add Field', 'buddypress' );
+                        $action        = &quot;admin.php?page=bp-profile-setup&amp;amp;group_id=&quot; . $this-&gt;group_id . &quot;&amp;amp;mode=add_field#tabs-&quot; . $this-&gt;group_id;
</ins><span class="cx"> 
</span><span class="cx">                         if ( !empty( $_POST['saveField'] ) ) {
</span><del>-                                $this-&gt;name             = $_POST['title'];
</del><ins>+                                $this-&gt;name        = $_POST['title'];
</ins><span class="cx">                                 $this-&gt;description = $_POST['description'];
</span><span class="cx">                                 $this-&gt;is_required = $_POST['required'];
</span><span class="cx">                                 $this-&gt;type        = $_POST['fieldtype'];
</span><span class="lines">@@ -820,18 +821,18 @@
</span><span class="cx"> 
</span><span class="cx">                 &lt;div class=&quot;wrap&quot;&gt;
</span><span class="cx">                         &lt;div id=&quot;icon-users&quot; class=&quot;icon32&quot;&gt;&lt;br /&gt;&lt;/div&gt;
</span><del>-                        &lt;h2&gt;&lt;?php echo $title; ?&gt;&lt;/h2&gt;
</del><ins>+                        &lt;h2&gt;&lt;?php echo esc_html( $title ); ?&gt;&lt;/h2&gt;
</ins><span class="cx">                         &lt;p&gt;&lt;?php _e( 'Fields marked * are required', 'buddypress' ) ?&gt;&lt;/p&gt;
</span><span class="cx"> 
</span><span class="cx">                         &lt;?php if ( !empty( $message ) ) : ?&gt;
</span><span class="cx"> 
</span><span class="cx">                                 &lt;div id=&quot;message&quot; class=&quot;error fade&quot;&gt;
</span><del>-                                        &lt;p&gt;&lt;?php echo $message; ?&gt;&lt;/p&gt;
</del><ins>+                                        &lt;p&gt;&lt;?php echo esc_html( $message ); ?&gt;&lt;/p&gt;
</ins><span class="cx">                                 &lt;/div&gt;
</span><span class="cx"> 
</span><span class="cx">                         &lt;?php endif; ?&gt;
</span><span class="cx"> 
</span><del>-                        &lt;form action=&quot;&lt;?php echo $action; ?&gt;&quot; method=&quot;post&quot;&gt;
</del><ins>+                        &lt;form action=&quot;&lt;?php echo esc_url( $action ); ?&gt;&quot; method=&quot;post&quot;&gt;
</ins><span class="cx">                                 &lt;div id=&quot;poststuff&quot;&gt;
</span><span class="cx">                                         &lt;div id=&quot;titlediv&quot;&gt;
</span><span class="cx">                                                 &lt;h3&gt;&lt;label for=&quot;title&quot;&gt;&lt;?php _e( 'Field Title', 'buddypress' ); ?&gt; *&lt;/label&gt;&lt;/h3&gt;
</span><span class="lines">@@ -843,30 +844,30 @@
</span><span class="cx">                                         &lt;div id=&quot;titlediv&quot;&gt;
</span><span class="cx">                                                 &lt;h3&gt;&lt;label for=&quot;description&quot;&gt;&lt;?php _e(&quot;Field Description&quot;, 'buddypress'); ?&gt;&lt;/label&gt;&lt;/h3&gt;
</span><span class="cx">                                                 &lt;div id=&quot;titlewrap&quot;&gt;
</span><del>-                                                        &lt;textarea name=&quot;description&quot; id=&quot;description&quot; rows=&quot;8&quot; cols=&quot;60&quot;&gt;&lt;?php echo htmlspecialchars( $this-&gt;description ); ?&gt;&lt;/textarea&gt;
</del><ins>+                                                        &lt;textarea name=&quot;description&quot; id=&quot;description&quot; rows=&quot;8&quot; cols=&quot;60&quot;&gt;&lt;?php echo esc_textarea( $this-&gt;description ); ?&gt;&lt;/textarea&gt;
</ins><span class="cx">                                                 &lt;/div&gt;
</span><span class="cx">                                         &lt;/div&gt;
</span><span class="cx"> 
</span><del>-                                        &lt;?php if ( '0' != $this-&gt;can_delete ) { ?&gt;
</del><ins>+                                        &lt;?php if ( '0' != $this-&gt;can_delete ) : ?&gt;
</ins><span class="cx"> 
</span><span class="cx">                                                 &lt;div id=&quot;titlediv&quot;&gt;
</span><span class="cx">                                                         &lt;h3&gt;&lt;label for=&quot;required&quot;&gt;&lt;?php _e( &quot;Is This Field Required?&quot;, 'buddypress' ); ?&gt; *&lt;/label&gt;&lt;/h3&gt;
</span><span class="cx">                                                         &lt;select name=&quot;required&quot; id=&quot;required&quot; style=&quot;width: 30%&quot;&gt;
</span><del>-                                                                &lt;option value=&quot;0&quot;&lt;?php if ( $this-&gt;is_required == '0' ) { ?&gt; selected=&quot;selected&quot;&lt;?php } ?&gt;&gt;&lt;?php _e( 'Not Required', 'buddypress' ); ?&gt;&lt;/option&gt;
-                                                                &lt;option value=&quot;1&quot;&lt;?php if ( $this-&gt;is_required == '1' ) { ?&gt; selected=&quot;selected&quot;&lt;?php } ?&gt;&gt;&lt;?php _e( 'Required', 'buddypress' ); ?&gt;&lt;/option&gt;
</del><ins>+                                                                &lt;option value=&quot;0&quot;&lt;?php selected( $this-&gt;is_required, '0' ); ?&gt;&gt;&lt;?php _e( 'Not Required', 'buddypress' ); ?&gt;&lt;/option&gt;
+                                                                &lt;option value=&quot;1&quot;&lt;?php selected( $this-&gt;is_required, '1' ); ?&gt;&gt;&lt;?php _e( 'Required',     'buddypress' ); ?&gt;&lt;/option&gt;
</ins><span class="cx">                                                         &lt;/select&gt;
</span><span class="cx">                                                 &lt;/div&gt;
</span><span class="cx"> 
</span><span class="cx">                                                 &lt;div id=&quot;titlediv&quot;&gt;
</span><del>-                                                        &lt;h3&gt;&lt;label for=&quot;fieldtype&quot;&gt;&lt;?php _e(&quot;Field Type&quot;, 'buddypress'); ?&gt; *&lt;/label&gt;&lt;/h3&gt;
</del><ins>+                                                        &lt;h3&gt;&lt;label for=&quot;fieldtype&quot;&gt;&lt;?php _e( 'Field Type', 'buddypress'); ?&gt; *&lt;/label&gt;&lt;/h3&gt;
</ins><span class="cx">                                                         &lt;select name=&quot;fieldtype&quot; id=&quot;fieldtype&quot; onchange=&quot;show_options(this.value)&quot; style=&quot;width: 30%&quot;&gt;
</span><del>-                                                                &lt;option value=&quot;textbox&quot;&lt;?php if ( $this-&gt;type == 'textbox' ) {?&gt; selected=&quot;selected&quot;&lt;?php } ?&gt;&gt;&lt;?php _e( 'Text Box', 'buddypress' ); ?&gt;&lt;/option&gt;
-                                                                &lt;option value=&quot;textarea&quot;&lt;?php if ( $this-&gt;type == 'textarea' ) {?&gt; selected=&quot;selected&quot;&lt;?php } ?&gt;&gt;&lt;?php _e( 'Multi-line Text Box', 'buddypress' ); ?&gt;&lt;/option&gt;
-                                                                &lt;option value=&quot;datebox&quot;&lt;?php if ( $this-&gt;type == 'datebox' ) {?&gt; selected=&quot;selected&quot;&lt;?php } ?&gt;&gt;&lt;?php _e( 'Date Selector', 'buddypress' ); ?&gt;&lt;/option&gt;
-                                                                &lt;option value=&quot;radio&quot;&lt;?php if ( $this-&gt;type == 'radio' ) {?&gt; selected=&quot;selected&quot;&lt;?php } ?&gt;&gt;&lt;?php _e( 'Radio Buttons', 'buddypress' ); ?&gt;&lt;/option&gt;
-                                                                &lt;option value=&quot;selectbox&quot;&lt;?php if ( $this-&gt;type == 'selectbox' ) {?&gt; selected=&quot;selected&quot;&lt;?php } ?&gt;&gt;&lt;?php _e( 'Drop Down Select Box', 'buddypress' ); ?&gt;&lt;/option&gt;
-                                                                &lt;option value=&quot;multiselectbox&quot;&lt;?php if ( $this-&gt;type == 'multiselectbox' ) {?&gt; selected=&quot;selected&quot;&lt;?php } ?&gt;&gt;&lt;?php _e( 'Multi Select Box', 'buddypress' ); ?&gt;&lt;/option&gt;
-                                                                &lt;option value=&quot;checkbox&quot;&lt;?php if ( $this-&gt;type == 'checkbox' ) {?&gt; selected=&quot;selected&quot;&lt;?php } ?&gt;&gt;&lt;?php _e( 'Checkboxes', 'buddypress' ); ?&gt;&lt;/option&gt;
</del><ins>+                                                                &lt;option value=&quot;textbox&quot;        &lt;?php selected( $this-&gt;type, 'textbox'        ); ?&gt;&gt;&lt;?php _e( 'Text Box',             'buddypress' ); ?&gt;&lt;/option&gt;
+                                                                &lt;option value=&quot;textarea&quot;       &lt;?php selected( $this-&gt;type, 'textarea'       ); ?&gt;&gt;&lt;?php _e( 'Multi-line Text Box',  'buddypress' ); ?&gt;&lt;/option&gt;
+                                                                &lt;option value=&quot;datebox&quot;        &lt;?php selected( $this-&gt;type, 'datebox'        ); ?&gt;&gt;&lt;?php _e( 'Date Selector',        'buddypress' ); ?&gt;&lt;/option&gt;
+                                                                &lt;option value=&quot;radio&quot;          &lt;?php selected( $this-&gt;type, 'radio'          ); ?&gt;&gt;&lt;?php _e( 'Radio Buttons',        'buddypress' ); ?&gt;&lt;/option&gt;
+                                                                &lt;option value=&quot;selectbox&quot;      &lt;?php selected( $this-&gt;type, 'selectbox'      ); ?&gt;&gt;&lt;?php _e( 'Drop Down Select Box', 'buddypress' ); ?&gt;&lt;/option&gt;
+                                                                &lt;option value=&quot;multiselectbox&quot; &lt;?php selected( $this-&gt;type, 'multiselectbox' ); ?&gt;&gt;&lt;?php _e( 'Multi Select Box',     'buddypress' ); ?&gt;&lt;/option&gt;
+                                                                &lt;option value=&quot;checkbox&quot;       &lt;?php selected( $this-&gt;type, 'checkbox'       ); ?&gt;&gt;&lt;?php _e( 'Checkboxes',           'buddypress' ); ?&gt;&lt;/option&gt;
</ins><span class="cx">                                                         &lt;/select&gt;
</span><span class="cx">                                                 &lt;/div&gt;
</span><span class="cx"> 
</span><span class="lines">@@ -874,33 +875,35 @@
</span><span class="cx"> 
</span><span class="cx">                                                 &lt;?php $this-&gt;render_admin_form_children(); ?&gt;
</span><span class="cx"> 
</span><del>-                                        &lt;?php } else { ?&gt;
</del><ins>+                                        &lt;?php else : ?&gt;
</ins><span class="cx"> 
</span><del>-                                                &lt;input type=&quot;hidden&quot; name=&quot;required&quot; id=&quot;required&quot; value=&quot;1&quot; /&gt;
</del><ins>+                                                &lt;input type=&quot;hidden&quot; name=&quot;required&quot;  id=&quot;required&quot;  value=&quot;1&quot;       /&gt;
</ins><span class="cx">                                                 &lt;input type=&quot;hidden&quot; name=&quot;fieldtype&quot; id=&quot;fieldtype&quot; value=&quot;textbox&quot; /&gt;
</span><span class="cx"> 
</span><del>-                                        &lt;?php } ?&gt;
</del><ins>+                                        &lt;?php endif;
</ins><span class="cx"> 
</span><del>-                                        &lt;?php /* The fullname field cannot be hidden */ ?&gt;
-                                        &lt;?php if ( 1 != $this-&gt;id ) : ?&gt;
</del><ins>+                                        /* The fullname field cannot be hidden */
+                                        if ( 1 != $this-&gt;id ) : ?&gt;
</ins><span class="cx"> 
</span><span class="cx">                                                 &lt;div id=&quot;titlediv&quot;&gt;
</span><del>-
</del><span class="cx">                                                         &lt;div id=&quot;titlewrap&quot;&gt;
</span><del>-                                                                &lt;h3&gt;&lt;label for=&quot;default-visibility&quot;&gt;&lt;?php _e( &quot;Default Visibility&quot;, 'buddypress' ); ?&gt;&lt;/label&gt;&lt;/h3&gt;
</del><ins>+                                                                &lt;h3&gt;&lt;label for=&quot;default-visibility&quot;&gt;&lt;?php _e( 'Default Visibility', 'buddypress' ); ?&gt;&lt;/label&gt;&lt;/h3&gt;
</ins><span class="cx">                                                                 &lt;ul&gt;
</span><del>-                                                                &lt;?php foreach( bp_xprofile_get_visibility_levels() as $level ) : ?&gt;
-                                                                        &lt;li&gt;&lt;input type=&quot;radio&quot; name=&quot;default-visibility&quot; value=&quot;&lt;?php echo esc_attr( $level['id'] ) ?&gt;&quot; &lt;?php checked( $this-&gt;default_visibility, $level['id'] ) ?&gt;&gt; &lt;?php echo esc_html( $level['label'] ) ?&gt;&lt;/li&gt;
-                                                                &lt;?php endforeach ?&gt;
</del><ins>+
+                                                                        &lt;?php foreach( bp_xprofile_get_visibility_levels() as $level ) : ?&gt;
+
+                                                                                &lt;li&gt;&lt;input type=&quot;radio&quot; name=&quot;default-visibility&quot; value=&quot;&lt;?php echo esc_attr( $level['id'] ) ?&gt;&quot; &lt;?php checked( $this-&gt;default_visibility, $level['id'] ); ?&gt;&gt; &lt;?php echo esc_html( $level['label'] ) ?&gt;&lt;/li&gt;
+
+                                                                        &lt;?php endforeach ?&gt;
+
</ins><span class="cx">                                                                 &lt;/ul&gt;
</span><span class="cx">                                                         &lt;/div&gt;
</span><span class="cx"> 
</span><span class="cx">                                                         &lt;div id=&quot;titlewrap&quot;&gt;
</span><del>-                                                                &lt;h3&gt;&lt;label for=&quot;allow-custom-visibility&quot;&gt;&lt;?php _e( &quot;Per-Member Visibility&quot;, 'buddypress' ); ?&gt;&lt;/label&gt;&lt;/h3&gt;
</del><ins>+                                                                &lt;h3&gt;&lt;label for=&quot;allow-custom-visibility&quot;&gt;&lt;?php _e( 'Per-Member Visibility', 'buddypress' ); ?&gt;&lt;/label&gt;&lt;/h3&gt;
</ins><span class="cx">                                                                 &lt;ul&gt;
</span><del>-                                                                        &lt;li&gt;&lt;input type=&quot;radio&quot; name=&quot;allow-custom-visibility&quot; value=&quot;allowed&quot; &lt;?php checked( $this-&gt;allow_custom_visibility, 'allowed' ) ?&gt;&gt; &lt;?php _e( &quot;Let members change the this field's visibility&quot;, 'buddypress' ) ?&gt;&lt;/li&gt;
-
-                                                                        &lt;li&gt;&lt;input type=&quot;radio&quot; name=&quot;allow-custom-visibility&quot; value=&quot;disabled&quot; &lt;?php checked( $this-&gt;allow_custom_visibility, 'disabled' ) ?&gt;&gt; &lt;?php _e( 'Enforce the default visibility for all members', 'buddypress' ) ?&gt;&lt;/li&gt;
</del><ins>+                                                                        &lt;li&gt;&lt;input type=&quot;radio&quot; name=&quot;allow-custom-visibility&quot; value=&quot;allowed&quot;  &lt;?php checked( $this-&gt;allow_custom_visibility, 'allowed'  ); ?&gt;&gt; &lt;?php _e( &quot;Let members change the this field's visibility&quot;, 'buddypress' ); ?&gt;&lt;/li&gt;
+                                                                        &lt;li&gt;&lt;input type=&quot;radio&quot; name=&quot;allow-custom-visibility&quot; value=&quot;disabled&quot; &lt;?php checked( $this-&gt;allow_custom_visibility, 'disabled' ); ?&gt;&gt; &lt;?php _e( 'Enforce the default visibility for all members', 'buddypress' ); ?&gt;&lt;/li&gt;
</ins><span class="cx">                                                                 &lt;/ul&gt;
</span><span class="cx">                                                         &lt;/div&gt;
</span><span class="cx">                                                 &lt;/div&gt;
</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-&gt;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]-&gt;user_login;
-                        $profile_data['user_nicename']        = $results[0]-&gt;user_nicename;
-                        $profile_data['user_email']                = $results[0]-&gt;user_email;
</del><ins>+                        $profile_data['user_login']    = $results[0]-&gt;user_login;
+                        $profile_data['user_nicename'] = $results[0]-&gt;user_nicename;
+                        $profile_data['user_email']    = $results[0]-&gt;user_email;
</ins><span class="cx"> 
</span><span class="cx">                         foreach( (array) $results as $field ) {
</span><span class="cx">                                 $profile_data[$field-&gt;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 &lt; $count; ++$i ) {
</span><del>-                                if ( $i == 0 )
</del><ins>+                                if ( $i == 0 ) {
</ins><span class="cx">                                         $field_sql .= $wpdb-&gt;prepare( &quot;AND ( f.name = %s &quot;, $fields[$i] );
</span><del>-                                else
</del><ins>+                                } else {
</ins><span class="cx">                                         $field_sql .= $wpdb-&gt;prepare( &quot;OR f.name = %s &quot;, $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 &lt; $count; ++$i ) {
</span><span class="cx">                                 for ( $j = 0; $j &lt; count( $fields ); $j++ ) {
</span><del>-                                        if ( $values[$i]-&gt;name == $fields[$j] )
</del><ins>+                                        if ( $values[$i]-&gt;name == $fields[$j] ) {
</ins><span class="cx">                                                 $new_values[$fields[$j]] = $values[$i]-&gt;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>-
-?&gt;
</del></span></pre>
</div>
</div>

</body>
</html>