Changeset 5598 for trunk/bp-xprofile/bp-xprofile-admin.php
- Timestamp:
- 12/24/2011 06:01:22 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-xprofile/bp-xprofile-admin.php
r5452 r5598 313 313 } 314 314 315 /************************************************************************** 316 xprofile_admin_delete_field() 317 318 Handles the deletion of a profile field [or option]. 319 **************************************************************************/ 320 function xprofile_admin_delete_field( $field_id, $type = 'field' ) { 315 /** 316 * Handles the deletion of a profile field (or field option) 317 * 318 * @since BuddyPress (1.0) 319 * @global string $message The feedback message to show 320 * @global $type The type of feedback message to show 321 * @param int $field_id The field to delete 322 * @param string $field_type The type of field being deleted 323 * @param bool $delete_data Should the field data be deleted too? 324 */ 325 function xprofile_admin_delete_field( $field_id, $field_type = 'field', $delete_data = false ) { 321 326 global $message, $type; 322 327 323 if ( 'field' == $type ) 324 $type = __('field', 'buddypress'); 325 else 326 $type = __('option', 'buddypress'); 328 // Switch type to 'option' if type is not 'field' 329 // @todo trust this param 330 $field_type = ( 'field' == $field_type ) ? __( 'field', 'buddypress' ) : __( 'option', 'buddypress' ); 327 331 328 332 $field = new BP_XProfile_Field( $field_id ); 329 333 330 if ( !$field->delete( ) ) {331 $message = sprintf( __( 'There was an error deleting the %s. Please try again', 'buddypress' ), $type );332 $type = 'error';334 if ( !$field->delete( (bool) $delete_data ) ) { 335 $message = sprintf( __( 'There was an error deleting the %s. Please try again', 'buddypress' ), $field_type ); 336 $type = 'error'; 333 337 } else { 334 $message = sprintf( __( 'The %s was deleted successfully!', 'buddypress' ), $type );335 $type = 'success';338 $message = sprintf( __( 'The %s was deleted successfully!', 'buddypress' ), $field_type ); 339 $type = 'success'; 336 340 337 341 do_action( 'xprofile_fields_deleted_field', $field ); … … 460 464 461 465 <?php } ?> 466 467 <?php if ( $field->description ) : ?> 468 469 <p class="description"><?php echo esc_attr( $field->description ); ?></p> 470 471 <?php endif; ?> 472 462 473 <div class="actions"> 463 <?php if ( !$field->can_delete ) : ?> <?php else : ?><a class="submit-delete deletion ajax-option-delete" href="admin.php?page=bp-profile-setup&field_id=<?php echo esc_attr( $field->id ); ?>&mode=delete_field"><?php _e( 'Delete', 'buddypress' ); ?></a><?php endif; ?>464 474 <a class="button edit" href="admin.php?page=bp-profile-setup&group_id=<?php echo esc_attr( $admin_group->id ); ?>&field_id=<?php echo esc_attr( $field->id ); ?>&mode=edit_field"><?php _e( 'Edit', 'buddypress' ); ?></a> 475 476 <?php if ( $field->can_delete ) : ?> 477 478 <a class="submit-delete deletion" href="admin.php?page=bp-profile-setup&field_id=<?php echo esc_attr( $field->id ); ?>&mode=delete_field"><?php _e( 'Delete', 'buddypress' ); ?></a> 479 480 <?php endif; ?> 465 481 </div> 466 467 <?php if ( $field->description ) : ?>468 469 <p class="description"><?php echo esc_attr( $field->description ); ?></p>470 471 <?php endif; ?>472 473 482 </div> 474 483 </fieldset>
Note: See TracChangeset
for help on using the changeset viewer.