Changeset 13101
- Timestamp:
- 09/02/2021 04:26:52 PM (3 years ago)
- Location:
- trunk/src/bp-groups
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-groups/bp-groups-functions.php
r13085 r13101 3532 3532 } 3533 3533 } 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 */ 3546 function 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 */ 3568 function 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 } 3582 add_action( 'bp_init', 'bp_init_group_extensions', 11 ); -
trunk/src/bp-groups/classes/class-bp-group-extension.php
r11773 r13101 11 11 defined( 'ABSPATH' ) || exit; 12 12 13 if ( ! class_exists( 'BP_Group_Extension', false ) ) : 13 14 /** 14 15 * API for creating group extensions without having to hardcode the content into … … 1696 1697 } 1697 1698 } 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 } 1699 endif; // End class_exists check. -
trunk/src/bp-groups/classes/class-bp-groups-component.php
r13093 r13101 94 94 */ 95 95 public $current_directory_type = ''; 96 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(); 96 106 97 107 /**
Note: See TracChangeset
for help on using the changeset viewer.