Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/10/2018 09:34:15 PM (4 years ago)
Author:
johnjamesjacoby
Message:

XProfile: use bp_get_admin_url() where appropriate.

This change updates all inline and querystring-based URL references to users.php to instead use the built-in supplied wrapper function. This comes with a few benefits:

  • URLs will be consistent across BuddyPress installation configurations (rather than relative to the current admin dashboard area)
  • Code is cleaner and easier to understand
  • Variable IDs are now cast to integers as needed (where they were not all previously)

Bonus: also updates a few bp_get_admin_url() calls in the about page to use the second parameter of add_query_arg() rather than wrapping it entirely, to match the expected usage format of all add_query_arg() calls.

Fixes #7536. Props JohnPBloch.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-xprofile/classes/class-bp-xprofile-group.php

    r11468 r11808  
    717717        global $message;
    718718
     719        // Users Admin URL
     720        $users_url = bp_get_admin_url( 'users.php' );
     721
     722        // URL to cancel to
     723        $cancel_url = add_query_arg( array(
     724            'page' => 'bp-profile-setup'
     725        ), $users_url );
     726
    719727        // New field group.
    720728        if ( empty( $this->id ) ) {
    721729            $title  = __( 'Add New Field Group', 'buddypress' );
    722             $action = add_query_arg( array( 'page' => 'bp-profile-setup', 'mode' => 'add_group' ), 'users.php' );
    723             $button = __( 'Save', 'buddypress' );
     730            $button = __( 'Save',                'buddypress' );
     731            $action = add_query_arg( array(
     732                'page' => 'bp-profile-setup',
     733                'mode' => 'add_group'
     734            ), $users_url );
    724735
    725736        // Existing field group.
    726737        } else {
    727738            $title  = __( 'Edit Field Group', 'buddypress' );
    728             $action = add_query_arg( array( 'page' => 'bp-profile-setup', 'mode' => 'edit_group', 'group_id' => $this->id ), 'users.php' );
    729             $button = __( 'Update', 'buddypress' );
     739            $button = __( 'Update',           'buddypress' );
     740            $action = add_query_arg( array(
     741                'page'     => 'bp-profile-setup',
     742                'mode'     => 'edit_group',
     743                'group_id' => (int) $this->id
     744            ), $users_url );
    730745        } ?>
    731746
     
    814829                                            </div>
    815830                                            <div id="delete-action">
    816                                                 <a href="users.php?page=bp-profile-setup" class="deletion"><?php _e( 'Cancel', 'buddypress' ); ?></a>
     831                                                <a href="<?php echo esc_url( $cancel_url ); ?>" class="deletion"><?php _e( 'Cancel', 'buddypress' ); ?></a>
    817832                                            </div>
    818833                                            <div class="clear"></div>
Note: See TracChangeset for help on using the changeset viewer.