| 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 | // Display the field delete confirmation screen. |
| | 621 | if ( 'delete_field' === $mode ) { |
| | 622 | xprofile_admin_delete_field_screen( $field_id, $field_type ); |
| | 623 | |
| | 624 | // Handle the deletion of field |
| 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 ); |
| | 628 | if ( !$field->delete( (bool) $delete_data ) ) { |
| | 629 | /* translators: %s: the field type */ |
| | 630 | $message = sprintf( __( 'There was an error deleting the %s. Please try again.', 'buddypress' ), $field_type ); |
| | 631 | $type = 'error'; |
| | 632 | } else { |
| | 633 | /* translators: %s: the field type */ |
| | 634 | $message = sprintf( __( 'The %s was deleted successfully!', 'buddypress' ), $field_type ); |
| | 635 | $type = 'success'; |
| | 636 | |
| | 637 | /** |
| | 638 | * Fires at the end of the field deletion process, if successful. |
| | 639 | * |
| | 640 | * @since 1.0.0 |
| | 641 | * |
| | 642 | * @param BP_XProfile_Field $field Current BP_XProfile_Field object. |
| | 643 | */ |
| | 644 | do_action( 'xprofile_fields_deleted_field', $field ); |
| | 645 | } |
| | 646 | |
| | 647 | xprofile_admin_screen( $message, $type ); |
| 637 | | xprofile_admin_screen( $message, $type ); |
| | 651 | /** |
| | 652 | * Display the delete confirmation screen of xprofile field. |
| | 653 | * |
| | 654 | * @since 7.0.0 |
| | 655 | */ |
| | 656 | function xprofile_admin_delete_field_screen( $field_id, $field_type ) { |
| | 657 | if ( ! bp_current_user_can( 'bp_moderate' ) ) { |
| | 658 | die( '-1' ); |
| | 659 | } |
| | 660 | |
| | 661 | $field = xprofile_get_field( $field_id ); |
| | 662 | |
| | 663 | $base_url = remove_query_arg( array( 'mode', 'field_id', 'bp_xprofile_delete_field' ), $_SERVER['REQUEST_URI'] ); ?> |
| | 664 | |
| | 665 | <div class="wrap"> |
| | 666 | <h1><?php esc_html_e( sprintf ( 'Delete %s', $field_type ), 'buddypress' ) ?></h1> |
| | 667 | <p><?php esc_html_e( sprintf( 'You are about to delete the following %s:', $field_type ), 'buddypress' ) ?></p> |
| | 668 | |
| | 669 | <ul class="bp-xprofile-delete-group-list"> |
| | 670 | <li><?php echo esc_html( $field->name ); ?></li> |
| | 671 | </ul> |
| | 672 | |
| | 673 | <p><strong><?php esc_html_e( 'This action cannot be undone.', 'buddypress' ) ?></strong></p> |
| | 674 | |
| | 675 | <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> |
| | 676 | <a class="button" href="<?php echo esc_attr( $base_url ); ?>"><?php esc_html_e( 'Cancel', 'buddypress' ) ?></a> |
| | 677 | </div> |
| | 678 | |
| | 679 | <?php |