Skip to:
Content

BuddyPress.org

Ticket #8215: 8215.patch

File 8215.patch, 10.4 KB (added by passoniate, 4 years ago)

Patch

  • src/bp-xprofile/admin/js/admin.js

     
    5959        newDiv.appendChild( toDeleteWrap );
    6060        holder.appendChild( newDiv );
    6161
    62         // re-initialize the sortable ui
     62        // Re-initialize the sortable ui.
    6363        enableSortableFieldOptions( forWhat );
    6464
    65         // set focus on newly created element
     65        // Set focus on newly created element.
    6666        document.getElementById(forWhat + '_option' + theId).focus();
    6767
    6868        theId++;
     
    104104        }
    105105
    106106        document.getElementById( id ).style.display = 'none';
    107         // the field id is [fieldtype]option[iterator] and not [fieldtype]div[iterator]
     107        // The field id is [fieldtype]option[iterator] and not [fieldtype]div[iterator].
    108108        var field_id = id.replace( 'div', 'option' );
    109109        document.getElementById( field_id ).value = '';
    110110}
     
    190190
    191191jQuery( document ).ready( function() {
    192192
    193         // Set focus in Field Title, if we're on the right page
     193        // Set focus in Field Title, if we're on the right page.
    194194        jQuery( '#bp-xprofile-add-field #title' ).focus();
    195195
    196196        // Set up the notice that shows when no member types are selected for a field.
     
    199199                toggle_no_member_type_notice();
    200200        } );
    201201
    202         // Set up deleting options ajax
     202        // Set up deleting options ajax.
    203203        jQuery( 'a.ajax-option-delete' ).on( 'click', function() {
    204204                var theId = this.id.split( '-' );
    205205                theId = theId[1];
     
    213213                function() {} );
    214214        } );
    215215
    216         // Set up the sort order change actions
     216        // Set up the sort order change actions.
    217217        jQuery( '[id^="sort_order_"]' ).change(function() {
    218218                if ( jQuery( this ).val() !== 'custom' ) {
    219219                        destroySortableFieldOptions();
     
    222222                }
    223223        });
    224224
    225         // Show object if JS is enabled
     225        // Show object if JS is enabled.
    226226        jQuery( 'ul#field-group-tabs' ).show();
    227227
    228         // Allow reordering of field group tabs
     228        // Allow reordering of field group tabs.
    229229        jQuery( 'ul#field-group-tabs' ).sortable( {
    230230                cursor: 'move',
    231231                axis: 'x',
     
    244244                }
    245245        }).disableSelection();
    246246
    247         // Allow reordering of fields within groups
     247        // Allow reordering of fields within groups.
    248248        jQuery( 'fieldset.field-group' ).sortable({
    249249                cursor: 'move',
    250250                opacity: 0.7,
     
    263263                }
    264264        })
    265265
    266         // Disallow text selection
     266        // Disallow text selection.
    267267        .disableSelection();
    268268
    269         // Allow reordering of field options
     269        // Allow reordering of field options.
    270270        enableSortableFieldOptions( jQuery('#fieldtype :selected').val() );
    271271
    272         // Handle title placeholder text the WordPress way
     272        // Handle title placeholder text the WordPress way.
    273273        titleHint( 'title' );
    274274
    275275        // On Date fields, selecting a date_format radio button should change the Custom value.
     
    313313                } );
    314314        } );
    315315
    316         // tabs init with a custom tab template and an "add" callback filling in the content
     316        // tabs init with a custom tab template and an "add" callback filling in the content.
    317317        var $tab_items,
    318318                $tabs = jQuery( '#tabs' ).tabs();
    319319
     
    327327                        touch: 'pointer',
    328328                        tolerance: 'pointer',
    329329
    330                         // When field is dropped on tab
     330                        // When field is dropped on tab.
    331331                        drop: function( ev, ui ) {
    332332                                var $item = jQuery(this), // The tab
    333333                                        $list = jQuery( $item.find( 'a' ).attr( 'href' ) ).find( '.connectedSortable' ); // The tab body
    334334
    335                                 // Remove helper class
     335                                // Remove helper class.
    336336                                jQuery($item).removeClass( 'drop-candidate' );
    337337
    338                                 // Hide field, change selected tab, and show new placement
     338                                // Hide field, change selected tab, and show new placement.
    339339                                ui.draggable.hide( 'slow', function() {
    340340
    341                                         // Select new tab as current
     341                                        // Select new tab as current.
    342342                                        $tabs.tabs( 'option', 'active', $tab_items.index( $item ) );
    343343
    344                                         // Show new placement
     344                                        // Show new placement.
    345345                                        jQuery(this).appendTo($list).show( 'slow' ).animate( {opacity: '1'}, 500 );
    346346
    347                                         // Refresh $list variable
     347                                        // Refresh $list variable.
    348348                                        $list = jQuery( $item.find( 'a' ).attr( 'href' ) ).find( '.connectedSortable' );
    349349                                        jQuery($list).find( 'p.nofields' ).hide( 'slow' );
    350350
    351                                         // Ajax update field locations and orders
     351                                        // Ajax update field locations and orders.
    352352                                        jQuery.post( ajaxurl, {
    353353                                                action: 'xprofile_reorder_fields',
    354354                                                'cookie': encodeURIComponent(document.cookie),
  • src/bp-xprofile/bp-xprofile-admin.php

     
    4545                ? sanitize_key( $_GET['mode'] )
    4646                : false;
    4747
    48         // Group ID
     48        // Group ID.
    4949        $group_id = ! empty( $_GET['group_id'] )
    5050                ? intval( $_GET['group_id'] )
    5151                : false;
    5252
    53         // Field ID
     53        // Field ID.
    5454        $field_id = ! empty( $_GET['field_id'] )
    5555                ? intval( $_GET['field_id'] )
    5656                : false;
    5757
    58         // Option ID
     58        // Option ID.
    5959        $option_id = ! empty( $_GET['option_id'] )
    6060                ? intval( $_GET['option_id'] )
    6161                : false;
    6262
    63         // Allowed modes
     63        // Allowed modes.
    6464        $allowed_modes = array(
    6565                'add_group',
    6666                'edit_group',
     
    7171                'delete_option'
    7272        );
    7373
    74         // Is an allowed mode
     74        // Is an allowed mode.
    7575        if ( in_array( $mode, $allowed_modes, true ) ) {
    7676
    77                 // All group actions
     77                // All group actions.
    7878                if ( false !== $group_id ) {
    7979
    80                         // Add field to group
     80                        // Add field to group.
    8181                        if ( 'add_field' == $mode ) {
    8282                                xprofile_admin_manage_field( $group_id );
    8383
    84                         // Edit field of group
     84                        // Edit field of group.
    8585                        } elseif ( ! empty( $field_id ) && 'edit_field' === $mode ) {
    8686                                xprofile_admin_manage_field( $group_id, $field_id );
    8787
    88                         // Delete group
     88                        // Delete group.
    8989                        } elseif ( 'delete_group' === $mode ) {
    9090                                xprofile_admin_delete_group( $group_id );
    9191
    92                         // Edit group
     92                        // Edit group.
    9393                        } elseif ( 'edit_group' === $mode ) {
    9494                                xprofile_admin_manage_group( $group_id );
    9595                        }
    9696
    97                 // Delete field
     97                // Delete field.
    9898                } elseif ( ( false !== $field_id ) && ( 'delete_field' === $mode ) ) {
    9999                        xprofile_admin_delete_field( $field_id, 'field');
    100100
    101                 // Delete option
     101                // Delete option.
    102102                } elseif ( ! empty( $option_id ) && 'delete_option' === $mode ) {
    103103                        xprofile_admin_delete_field( $option_id, 'option' );
    104104
    105                 // Add group
     105                // Add group.
    106106                } elseif ( 'add_group' == $mode ) {
    107107                        xprofile_admin_manage_group();
    108108                }
     
    124124 */
    125125function xprofile_admin_screen( $message = '', $type = 'error' ) {
    126126
    127         // Users admin URL
     127        // Users admin URL.
    128128        $url = bp_get_admin_url( 'users.php' );
    129129
    130         // Add Group
     130        // Add Group.
    131131        $add_group_url = add_query_arg( array(
    132132                'page' => 'bp-profile-setup',
    133133                'mode' => 'add_group'
     
    200200
    201201                                <?php if ( !empty( $groups ) ) : foreach ( $groups as $group ) :
    202202
    203                                         // Add Field to Group URL
     203                                        // Add Field to Group URL.
    204204                                        $add_field_url = add_query_arg( array(
    205205                                                'page'     => 'bp-profile-setup',
    206206                                                'mode'     => 'add_field',
     
    207207                                                'group_id' => (int) $group->id
    208208                                        ), $url );
    209209
    210                                         // Edit Group URL
     210                                        // Edit Group URL.
    211211                                        $edit_group_url = add_query_arg( array(
    212212                                                'page'     => 'bp-profile-setup',
    213213                                                'mode'     => 'edit_group',
     
    214214                                                'group_id' => (int) $group->id
    215215                                        ), $url );
    216216
    217                                         // Delete Group URL
     217                                        // Delete Group URL.
    218218                                        $delete_group_url = wp_nonce_url( add_query_arg( array(
    219219                                                'page'     => 'bp-profile-setup',
    220220                                                'mode'     => 'delete_group',
     
    340340        // Updating.
    341341        if ( isset( $_POST['save_group'] ) ) {
    342342
    343                 // Check nonce
     343                // Check nonce.
    344344                check_admin_referer( 'bp_xprofile_admin_group', 'bp_xprofile_admin_group' );
    345345
    346346                // Validate $_POSTed data.
     
    366366                                $message = __( 'The group was saved successfully.', 'buddypress' );
    367367                                $type    = 'success';
    368368
    369                                 // @todo remove these old options
     369                                // @todo remove these old options.
    370370                                if ( 1 == $group_id ) {
    371371                                        bp_update_option( 'bp-xprofile-base-group-name', $group->name );
    372372                                }
     
    448448
    449449        if ( isset( $_POST['saveField'] ) ) {
    450450
    451                 // Check nonce
     451                // Check nonce.
    452452                check_admin_referer( 'bp_xprofile_admin_field', 'bp_xprofile_admin_field' );
    453453
    454454                if ( BP_XProfile_Field::admin_validate() ) {
     
    483483                                $message = __( 'The field was saved successfully.', 'buddypress' );
    484484                                $type    = 'success';
    485485
    486                                 // @todo remove these old options
     486                                // @todo remove these old options.
    487487                                if ( 1 == $field_id ) {
    488488                                        bp_update_option( 'bp-xprofile-fullname-field-name', $field->name );
    489489                                }
     
    649649
    650650        $field = $admin_field;
    651651
    652         // Users admin URL
     652        // Users admin URL.
    653653        $url = bp_get_admin_url( 'users.php' );
    654654
    655         // Edit
     655        // Edit.
    656656        $field_edit_url = add_query_arg( array(
    657657                'page'     => 'bp-profile-setup',
    658658                'mode'     => 'edit_field',
     
    660660                'field_id' => (int) $field->id
    661661        ), $url );
    662662
    663         // Delete
     663        // Delete.
    664664        if ( $field->can_delete ) {
    665665                $field_delete_url = add_query_arg( array(
    666666                        'page'     => 'bp-profile-setup',
  • src/bp-xprofile/bp-xprofile-cache.php

     
    180180 *
    181181 * @since 2.1.0
    182182 *
    183  * @param object $group_obj Groub object to clear.
     183 * @param object $group_obj Group object to clear.
    184184 */
    185185function xprofile_clear_profile_groups_object_cache( $group_obj ) {
    186186        wp_cache_delete( 'all',          'bp_xprofile_groups' );
  • src/bp-xprofile/bp-xprofile-filters.php

     
    193193 *
    194194 * @since 1.2.6
    195195 *
    196  * @param string      $field_value Field value being santized.
     196 * @param string      $field_value Field value being sanitized.
    197197 * @param int         $field_id    Field ID being sanitized.
    198198 * @param bool        $reserialize Whether to reserialize arrays before returning. Defaults to true.
    199199 * @param object|null $data_obj    The BP_XProfile_ProfileData object.
     
    408408                 *
    409409                 * Before splitting on the ";" character, decode the HTML entities, and re-encode after.
    410410                 * This prevents input like "O'Hara" rendering as "O&#039; Hara" (with each of those parts
    411                  * having a seperate HTML link).
     411                 * having a separate HTML link).
    412412                 */
    413413                $list_type   = 'semicolon';
    414414                $field_value = wp_specialchars_decode( $field_value, ENT_QUOTES );