Skip to:
Content

BuddyPress.org

Ticket #8558: 8558.2.patch

File 8558.2.patch, 3.7 KB (added by imath, 4 years ago)
  • src/bp-groups/bp-groups-functions.php

    diff --git src/bp-groups/bp-groups-functions.php src/bp-groups/bp-groups-functions.php
    index b23780ae4..f9bb87405 100644
    function bp_groups_migrate_invitations() { 
    35313531                $wpdb->query( "DELETE FROM {$bp->groups->table_name_members} WHERE ID IN ($ids_to_delete)" );
    35323532        }
    35333533}
     3534
     3535/**
     3536 * Register a new Group Extension.
     3537 *
     3538 * @since 1.1.0
     3539 * @since 10.0.0 The function was moved from the `/bp-groups/classes/class-bp-group-extension.php` file.
     3540 *               It only registers Group Extensions if their corresponding class name has not been already
     3541 *               registered.
     3542 *
     3543 * @param string $group_extension_class Name of the Extension class.
     3544 * @return bool                         Returns true on success, otherwise false.
     3545 */
     3546function bp_register_group_extension( $group_extension_class = '' ) {
     3547        if ( ! class_exists( $group_extension_class ) ) {
     3548                return false;
     3549        }
     3550
     3551        $bp = buddypress();
     3552
     3553        if ( isset( $bp->groups->group_extensions[ $group_extension_class ] ) ) {
     3554                return false;
     3555        }
     3556
     3557        // Add the new Group extension to the registered ones.
     3558        $bp->groups->group_extensions[ $group_extension_class ] = true;
     3559
     3560        return true;
     3561}
     3562
     3563/**
     3564 * Init Registered Group Extensions.
     3565 *
     3566 * @since 10.0.0
     3567 */
     3568function bp_init_group_extensions() {
     3569        $registered_group_extensions = buddypress()->groups->group_extensions;
     3570
     3571        if ( ! $registered_group_extensions ) {
     3572                return;
     3573        }
     3574
     3575        foreach ( array_keys( $registered_group_extensions ) as $group_extension_class ) {
     3576                $extension = new $group_extension_class;
     3577
     3578                add_action( 'bp_actions', array( &$extension, '_register' ), 8 );
     3579                add_action( 'admin_init', array( &$extension, '_register' ) );
     3580        }
     3581}
     3582add_action( 'bp_init', 'bp_init_group_extensions', 11 );
  • src/bp-groups/classes/class-bp-group-extension.php

    diff --git src/bp-groups/classes/class-bp-group-extension.php src/bp-groups/classes/class-bp-group-extension.php
    index 1a12ebcee..e89f3b890 100644
     
    1010// Exit if accessed directly.
    1111defined( 'ABSPATH' ) || exit;
    1212
     13if ( ! class_exists( 'BP_Group_Extension', false ) ) :
    1314/**
    1415 * API for creating group extensions without having to hardcode the content into
    1516 * the theme.
    class BP_Group_Extension { 
    16951696                }
    16961697        }
    16971698}
    1698 
    1699 /**
    1700  * Register a new Group Extension.
    1701  *
    1702  * @since 1.1.0
    1703  *
    1704  * @param string $group_extension_class Name of the Extension class.
    1705  * @return false|null Returns false on failure, otherwise null.
    1706  */
    1707 function bp_register_group_extension( $group_extension_class = '' ) {
    1708 
    1709         if ( ! class_exists( $group_extension_class ) ) {
    1710                 return false;
    1711         }
    1712 
    1713         // Register the group extension on the bp_init action so we have access
    1714         // to all plugins.
    1715         add_action( 'bp_init', function() use ( $group_extension_class ) {
    1716                 $extension = new $group_extension_class;
    1717                 add_action( 'bp_actions', array( &$extension, '_register' ), 8 );
    1718                 add_action( 'admin_init', array( &$extension, '_register' ) );
    1719         }, 11 );
    1720 }
     1699endif; // End class_exists check.
  • src/bp-groups/classes/class-bp-groups-component.php

    diff --git src/bp-groups/classes/class-bp-groups-component.php src/bp-groups/classes/class-bp-groups-component.php
    index df567e36f..c8c9b7787 100644
    class BP_Groups_Component extends BP_Component { 
    9494         */
    9595        public $current_directory_type = '';
    9696
     97        /**
     98         * List of registered Group extensions.
     99         *
     100         * @see bp_register_group_extension()
     101         *
     102         * @since 10.0.0
     103         * @var array
     104         */
     105        public $group_extensions = array();
     106
    97107        /**
    98108         * Start the groups component creation process.
    99109         *