Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/01/2018 10:11:35 PM (6 years ago)
Author:
r-a-y
Message:

Groups: Move some functions from bp-groups-actions.php to bp-groups-functions.php

Some of the functions from bp-groups-actions.php are not related to group
page actions, so these are being moved to the all-purpose
bp-groups-functions.php file.

The intent is to remove and split up the bp-groups-actions.php and
bp-groups-screens.php files until these functions are actually
needed.

See #7218.

File:
1 edited

Legend:

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

    r11805 r11922  
    22002200add_action( 'bp_make_spam_user', 'groups_remove_data_for_user' );
    22012201
     2202/**
     2203 * Update orphaned child groups when the parent is deleted.
     2204 *
     2205 * @since 2.7.0
     2206 *
     2207 * @param BP_Groups_Group $group Instance of the group item being deleted.
     2208 */
     2209function bp_groups_update_orphaned_groups_on_group_delete( $group ) {
     2210    // Get child groups and set the parent to the deleted parent's parent.
     2211    $grandparent_group_id = $group->parent_id;
     2212    $child_args = array(
     2213        'parent_id'         => $group->id,
     2214        'show_hidden'       => true,
     2215        'per_page'          => false,
     2216        'update_meta_cache' => false,
     2217    );
     2218    $children = groups_get_groups( $child_args );
     2219    $children = $children['groups'];
     2220
     2221    foreach ( $children as $cgroup ) {
     2222        $cgroup->parent_id = $grandparent_group_id;
     2223        $cgroup->save();
     2224    }
     2225}
     2226add_action( 'bp_groups_delete_group', 'bp_groups_update_orphaned_groups_on_group_delete', 10, 2 );
     2227
    22022228/** Group Types ***************************************************************/
     2229
     2230/**
     2231 * Fire the 'bp_groups_register_group_types' action.
     2232 *
     2233 * @since 2.6.0
     2234 */
     2235function bp_groups_register_group_types() {
     2236    /**
     2237     * Fires when it's appropriate to register group types.
     2238     *
     2239     * @since 2.6.0
     2240     */
     2241    do_action( 'bp_groups_register_group_types' );
     2242}
     2243add_action( 'bp_register_taxonomies', 'bp_groups_register_group_types' );
    22032244
    22042245/**
Note: See TracChangeset for help on using the changeset viewer.