Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/10/2018 09:34:15 PM (7 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-field.php

    r11700 r11808  
    11641164     */
    11651165    public function render_admin_form( $message = '' ) {
     1166
     1167        // Users Admin URL
     1168        $users_url = bp_get_admin_url( 'users.php' );
     1169
     1170        // Add New
    11661171        if ( empty( $this->id ) ) {
    11671172            $title  = __( 'Add New Field', 'buddypress' );
    1168             $action = "users.php?page=bp-profile-setup&group_id=" . $this->group_id . "&mode=add_field#tabs-" . $this->group_id;
    1169             $button = __( 'Save', 'buddypress' );
     1173            $button = __( 'Save',          'buddypress' );
     1174            $action = add_query_arg( array(
     1175                'page'     => 'bp-profile-setup',
     1176                'mode'     => 'add_field',
     1177                'group_id' => (int) $this->group_id
     1178            ), $users_url . '#tabs-' . (int) $this->group_id );
    11701179
    11711180            if ( !empty( $_POST['saveField'] ) ) {
     
    11801189                }
    11811190            }
     1191
     1192        // Edit
    11821193        } else {
    11831194            $title  = __( 'Edit Field', 'buddypress' );
    1184             $action = "users.php?page=bp-profile-setup&mode=edit_field&group_id=" . $this->group_id . "&field_id=" . $this->id . "#tabs-" . $this->group_id;
    1185             $button = __( 'Update', 'buddypress' );
     1195            $button = __( 'Update',     'buddypress' );
     1196            $action = add_query_arg( array(
     1197                'page'     => 'bp-profile-setup',
     1198                'mode'     => 'edit_field',
     1199                'group_id' => (int) $this->group_id,
     1200                'field_id' => (int) $this->id
     1201            ), $users_url . '#tabs-' . (int) $this->group_id );
    11861202        } ?>
    11871203
     
    12871303    private function submit_metabox( $button_text = '' ) {
    12881304
     1305        // Setup the URL for deleting
     1306        $users_url  = bp_get_admin_url( 'users.php' );
     1307        $cancel_url = add_query_arg( array(
     1308            'page' => 'bp-profile-setup'
     1309        ), $users_url );
     1310
    12891311        /**
    12901312         * Fires before XProfile Field submit metabox.
     
    13241346
    13251347                        <div id="delete-action">
    1326                             <a href="users.php?page=bp-profile-setup" class="deletion"><?php esc_html_e( 'Cancel', 'buddypress' ); ?></a>
     1348                            <a href="<?php echo esc_url( $cancel_url ); ?>" class="deletion"><?php esc_html_e( 'Cancel', 'buddypress' ); ?></a>
    13271349                        </div>
    13281350
Note: See TracChangeset for help on using the changeset viewer.