Skip to:
Content

BuddyPress.org

Changeset 8797


Ignore:
Timestamp:
08/12/2014 01:38:36 AM (5 years ago)
Author:
johnjamesjacoby
Message:

Clean up basic (likely no longer used) XProfile field group functions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-xprofile/bp-xprofile-functions.php

    r8785 r8797  
    3636}
    3737
     38/**
     39 * Insert a new profile field group
     40 *
     41 * @since BuddyPress (1.0.0)
     42 *
     43 * @param type $args
     44 * @return boolean
     45 */
    3846function xprofile_insert_field_group( $args = '' ) {
    39     $defaults = array(
     47
     48    // Parse the arguments
     49    $r = bp_parse_args( $args, array(
    4050        'field_group_id' => false,
    4151        'name'           => false,
    4252        'description'    => '',
    4353        'can_delete'     => true
    44     );
    45 
    46     $r = wp_parse_args( $args, $defaults );
    47     extract( $r, EXTR_SKIP );
    48 
    49     if ( empty( $name ) )
    50         return false;
    51 
    52     $field_group              = new BP_XProfile_Group( $field_group_id );
    53     $field_group->name        = $name;
    54     $field_group->description = $description;
    55     $field_group->can_delete  = $can_delete;
     54    ), 'xprofile_insert_field_group' );
     55
     56    // Bail if no group name
     57    if ( empty( $r['name'] ) ) {
     58        return false;
     59    }
     60
     61    // Create new field group object, maybe using an existing ID
     62    $field_group              = new BP_XProfile_Group( $r['field_group_id'] );
     63    $field_group->name        = $r['name'];
     64    $field_group->description = $r['description'];
     65    $field_group->can_delete  = $r['can_delete'];
    5666
    5767    return $field_group->save();
    5868}
    5969
    60 function xprofile_get_field_group( $field_group_id ) {
     70/**
     71 * Get a specific profile field group
     72 *
     73 * @since BuddyPress (1.0.0)
     74 *
     75 * @param int $field_group_id
     76 * @return boolean|BP_XProfile_Group
     77 */
     78function xprofile_get_field_group( $field_group_id = 0 ) {
     79
     80    // Try to get a specific field group by ID
    6181    $field_group = new BP_XProfile_Group( $field_group_id );
    6282
    63     if ( empty( $field_group->id ) )
    64         return false;
    65 
     83    // Bail if group was not found
     84    if ( empty( $field_group->id ) ) {
     85        return false;
     86    }
     87
     88    // Return field group
    6689    return $field_group;
    6790}
    6891
    69 function xprofile_delete_field_group( $field_group_id ) {
    70     $field_group = new BP_XProfile_Group( $field_group_id );
     92/**
     93 * Delete a specific profile field group
     94 *
     95 * @since BuddyPress (1.0.0)
     96 *
     97 * @param int $field_group_id
     98 * @return boolean
     99 */
     100function xprofile_delete_field_group( $field_group_id = 0 ) {
     101
     102    // Try to get a specific field group by ID
     103    $field_group = xprofile_get_field_group( $field_group_id );
     104
     105    // Bail if group was not found
     106    if ( false === $field_group ) {
     107        return false;
     108    }
     109
     110    // Return the results of trying to delete the field group
    71111    return $field_group->delete();
    72112}
    73113
    74 function xprofile_update_field_group_position( $field_group_id, $position ) {
     114/**
     115 * Update the position of a specific profile field group
     116 *
     117 * @since BuddyPress (1.0.0)
     118 *
     119 * @param int $field_group_id
     120 * @param int $position
     121 * @return bool
     122 */
     123function xprofile_update_field_group_position( $field_group_id = 0, $position = 0 ) {
    75124    return BP_XProfile_Group::update_position( $field_group_id, $position );
    76125}
Note: See TracChangeset for help on using the changeset viewer.