Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
09/02/2021 04:26:52 PM (5 years ago)
Author:
imath
Message:

Improve the Group Extension API extensibility

  • Use a new global to store the registered Group extensions of the Groups component.
  • Edit the behavior of the bp_register_group_extension() function so that it only registers custom group extensions into the new global.
  • Introduce a new function bp_init_group_extensions() to init the registered Group extensions.

These improvements will make it possible for the BP Rewrites feature as a plugin to allow slug customization of the registered Group extensions.

Props boonebgorges

Fixes #8558

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/classes/class-bp-group-extension.php

    r11773 r13101  
    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
     
    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.
Note: See TracChangeset for help on using the changeset viewer.