Skip to:
Content

BuddyPress.org

Changeset 11922


Ignore:
Timestamp:
04/01/2018 10:11:35 PM (7 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.

Location:
trunk/src/bp-groups
Files:
2 edited

Legend:

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

    r11776 r11922  
    1414// Exit if accessed directly.
    1515defined( 'ABSPATH' ) || exit;
    16 
    17 /**
    18  * Fire the 'bp_groups_register_group_types' action.
    19  *
    20  * @since 2.6.0
    21  */
    22 function bp_groups_register_group_types() {
    23     /**
    24      * Fires when it's appropriate to register group types.
    25      *
    26      * @since 2.6.0
    27      */
    28     do_action( 'bp_groups_register_group_types' );
    29 }
    30 add_action( 'bp_register_taxonomies', 'bp_groups_register_group_types' );
    3116
    3217/**
     
    593578}
    594579add_action( 'bp_actions', 'groups_action_group_feed' );
    595 
    596 /**
    597  * Update orphaned child groups when the parent is deleted.
    598  *
    599  * @since 2.7.0
    600  *
    601  * @param BP_Groups_Group $group Instance of the group item being deleted.
    602  */
    603 function bp_groups_update_orphaned_groups_on_group_delete( $group ) {
    604     // Get child groups and set the parent to the deleted parent's parent.
    605     $grandparent_group_id = $group->parent_id;
    606     $child_args = array(
    607         'parent_id'         => $group->id,
    608         'show_hidden'       => true,
    609         'per_page'          => false,
    610         'update_meta_cache' => false,
    611     );
    612     $children = groups_get_groups( $child_args );
    613     $children = $children['groups'];
    614 
    615     foreach ( $children as $cgroup ) {
    616         $cgroup->parent_id = $grandparent_group_id;
    617         $cgroup->save();
    618     }
    619 }
    620 add_action( 'bp_groups_delete_group', 'bp_groups_update_orphaned_groups_on_group_delete', 10, 2 );
  • 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.