Changeset 12676 for trunk/src/bp-xprofile/bp-xprofile-admin.php
- Timestamp:
- 07/02/2020 06:25:07 AM (6 years ago)
- File:
-
- 1 edited
-
trunk/src/bp-xprofile/bp-xprofile-admin.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-xprofile/bp-xprofile-admin.php
r12668 r12676 70 70 'edit_field', 71 71 'delete_field', 72 'delete_option' 72 'do_delete_field', 73 'delete_option', 74 'do_delete_option' 73 75 ); 74 76 … … 97 99 98 100 // Delete field. 99 } elseif ( ( false !== $field_id ) && ( 'delete_field' === $mode) ) {100 xprofile_admin_delete_field( $field_id, 'field' );101 } elseif ( ( false !== $field_id ) && ( in_array( $mode, array( 'delete_field', 'do_delete_field' ), true ) ) ) { 102 xprofile_admin_delete_field( $field_id, 'field' ); 101 103 102 104 // Delete option. 103 } elseif ( ! empty( $option_id ) && 'delete_option' === $mode) {105 } elseif ( ! empty( $option_id ) && in_array( $mode, array( 'delete_option', 'do_delete_option' ), true ) ) { 104 106 xprofile_admin_delete_field( $option_id, 'option' ); 105 107 … … 611 613 check_admin_referer( 'bp_xprofile_delete_field-' . $field_id, 'bp_xprofile_delete_field' ); 612 614 615 $mode = ! empty( $_GET['mode'] ) ? sanitize_key( $_GET['mode'] ) : false; 616 613 617 // Switch type to 'option' if type is not 'field'. 614 618 // @todo trust this param. 615 619 $field_type = ( 'field' == $field_type ) ? __( 'field', 'buddypress' ) : __( 'option', 'buddypress' ); 616 $field = xprofile_get_field( $field_id ); 617 618 if ( !$field->delete( (bool) $delete_data) ) {619 /* translators: %s: the field type */620 $message = sprintf( __( 'There was an error deleting the %s. Please try again.', 'buddypress' ), $field_type ); 621 $type = 'error';620 621 // Display the field/option delete confirmation screen. 622 if ( in_array( $mode, array( 'delete_field', 'delete_option' ) ) ) { 623 xprofile_admin_delete_field_screen( $field_id, $field_type ); 624 625 // Handle the deletion of field 622 626 } else { 623 /* translators: %s: the field type */ 624 $message = sprintf( __( 'The %s was deleted successfully!', 'buddypress' ), $field_type ); 625 $type = 'success'; 626 627 /** 628 * Fires at the end of the field deletion process, if successful. 629 * 630 * @since 1.0.0 631 * 632 * @param BP_XProfile_Field $field Current BP_XProfile_Field object. 633 */ 634 do_action( 'xprofile_fields_deleted_field', $field ); 635 } 636 637 xprofile_admin_screen( $message, $type ); 638 } 627 $field = xprofile_get_field( $field_id ); 628 629 if ( !$field->delete( (bool) $delete_data ) ) { 630 /* translators: %s: the field type */ 631 $message = sprintf( __( 'There was an error deleting the %s. Please try again.', 'buddypress' ), $field_type ); 632 $type = 'error'; 633 } else { 634 /* translators: %s: the field type */ 635 $message = sprintf( __( 'The %s was deleted successfully!', 'buddypress' ), $field_type ); 636 $type = 'success'; 637 638 /** 639 * Fires at the end of the field deletion process, if successful. 640 * 641 * @since 1.0.0 642 * 643 * @param BP_XProfile_Field $field Current BP_XProfile_Field object. 644 */ 645 do_action( 'xprofile_fields_deleted_field', $field ); 646 } 647 648 xprofile_admin_screen( $message, $type ); 649 } 650 } 651 652 /** 653 * Display the delete confirmation screen of xprofile field/option. 654 * 655 * @since 7.0.0 656 */ 657 function xprofile_admin_delete_field_screen( $field_id, $field_type ) { 658 if ( ! bp_current_user_can( 'bp_moderate' ) ) { 659 die( '-1' ); 660 } 661 662 $field = xprofile_get_field( $field_id ); 663 664 $base_url = remove_query_arg( array( 'mode', 'field_id', 'bp_xprofile_delete_field' ), $_SERVER['REQUEST_URI'] ); ?> 665 666 <div class="wrap"> 667 <h1><?php printf( esc_html__( 'Delete %s', 'buddypress' ), $field_type ); ?></h1> 668 <p><?php printf( esc_html__( 'You are about to delete the following %s:', 'buddypress' ), $field_type ); ?></p> 669 670 <ul class="bp-xprofile-delete-group-list"> 671 <li><?php echo esc_html( $field->name ); ?></li> 672 </ul> 673 674 <p><strong><?php esc_html_e( 'This action cannot be undone.', 'buddypress' ); ?></strong></p> 675 676 <a class="button-primary" href="<?php echo esc_url( wp_nonce_url( add_query_arg( array( 'mode' => 'do_delete_field', 'field_id' => $field_id ), $base_url ), 'bp_xprofile_delete_field-' . $field_id, 'bp_xprofile_delete_field' ) ); ?>"><?php esc_html_e( 'Delete Permanently', 'buddypress' ); ?></a> 677 <a class="button" href="<?php echo esc_attr( $base_url ); ?>"><?php esc_html_e( 'Cancel', 'buddypress' ); ?></a> 678 </div> 679 680 <?php 681 } 682 683 639 684 640 685 /**
Note: See TracChangeset
for help on using the changeset viewer.