Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bp-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/**
* Plugin Name: BuddyBoss Platform
* Plugin URI: https://buddyboss.com/
* Update URI: https://buddyboss-platform
* Description: The BuddyBoss Platform adds community features to WordPress. Member Profiles, Activity Feeds, Direct Messaging, Notifications, and more!
* Author: BuddyBoss
* Author URI: https://buddyboss.com/
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
"php": ">=5.3.0",
"php-ffmpeg/php-ffmpeg": "^0.16.0",
"maennchen/zipstream-php": "^2.1",
"caseproof/ground-level-mothership": "2.2.1",
"caseproof/ground-level-in-product-notifications": "*"
"caseproof/ground-level-mothership": "7.4.0",
"caseproof/ground-level-in-product-notifications": "7.4.0"
},
"require-dev": {
"symfony/var-dumper": "^4.2",
Expand Down
156 changes: 78 additions & 78 deletions composer.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/bp-core/admin/drm/class-bb-drm-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private function get_plugin_id() {
try {
// Use a singleton instance to avoid duplicate hook registration.
$loader = \BuddyBoss\Core\Admin\Mothership\BB_Mothership_Loader::instance();
$plugin_connector = $loader->getContainer()->get( \BuddyBossPlatform\GroundLevel\Mothership\AbstractPluginConnection::class );
$plugin_connector = $loader->get_container()->get( \BuddyBossPlatform\GroundLevel\Mothership\AbstractPluginConnection::class );
return $plugin_connector->pluginId;
} catch ( \Exception $e ) {
// Fallback to PLATFORM_EDITION constant or default if container access fails.
Expand Down
21 changes: 18 additions & 3 deletions src/bp-core/admin/drm/class-bb-drm-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,29 @@ public static function get_status() {
*/
public static function has_key() {
try {
$key = Credentials::getLicenseKey();
$key = self::get_credentials()->getLicenseKey();
return ! empty( $key );
} catch ( \Exception $e ) {
return false;
}
}

/**
* Resolve the GroundLevel Credentials service from the Mothership container.
*
* GroundLevel 7.3.1 replaced the static {@see Credentials} API with an instance
* resolved from the container, so the license key is read through this service.
*
* @since BuddyBoss [BBVERSION]
*
* @return Credentials
*/
private static function get_credentials(): Credentials {
return \BuddyBoss\Core\Admin\Mothership\BB_Mothership_Loader::instance()
->get_container()
->get( Credentials::class );
}

/**
* Get the license key.
*
Expand All @@ -124,7 +140,7 @@ public static function has_key() {
*/
public static function get_key() {
try {
return Credentials::getLicenseKey();
return self::get_credentials()->getLicenseKey();
} catch ( \Exception $e ) {
return '';
}
Expand Down Expand Up @@ -182,7 +198,6 @@ public static function is_valid() {
* @return bool True if development environment detected.
*/
public static function is_dev_environment() {
return false;
// Check WordPress environment type (WordPress 5.5+).
if ( function_exists( 'wp_get_environment_type' ) ) {
$env = wp_get_environment_type();
Expand Down
4 changes: 2 additions & 2 deletions src/bp-core/admin/drm/class-bb-notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function add( $notification ) {

// Get the GroundLevel container from the loader.
$loader = $this->get_mothership_loader();
$container = $loader->getContainer();
$container = $loader->get_container();

/** @var \BuddyBossPlatform\GroundLevel\InProductNotifications\Services\Store $store */
$store = $container->get( Store::class )->fetch();
Expand Down Expand Up @@ -90,7 +90,7 @@ public function add( $notification ) {
public function dismiss_events( $type ) {
// Get the GroundLevel container from the loader.
$loader = $this->get_mothership_loader();
$container = $loader->getContainer();
$container = $loader->get_container();

/**
* Get the GroundLevel notification store.
Expand Down
68 changes: 56 additions & 12 deletions src/bp-core/admin/mothership/autoload-aliases.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* PHP-Scoper was actually used or not.
*
* @package BuddyBoss\Core\Admin\Mothership
* @since 1.0.0
* @since BuddyBoss 2.14.0
*/

// Exit if accessed directly.
Expand All @@ -26,15 +26,17 @@ function buddyboss_setup_mothership_aliases() {
}

// Define the class mappings - creating BuddyBossPlatform aliases.
// Updated for GroundLevel 7.4.0: the static-container `Service` classes and the
// HasStaticContainer/StaticContainerAwareness concern+contract were removed in
// favor of the dependency-injection ServiceProvider pattern.
$class_mappings = array(
// Container classes.
'BuddyBossPlatform\GroundLevel\Container\Container' => 'GroundLevel\Container\Container',
'BuddyBossPlatform\GroundLevel\Container\Service' => 'GroundLevel\Container\Service',
'BuddyBossPlatform\GroundLevel\Container\Concerns\HasStaticContainer' => 'GroundLevel\Container\Concerns\HasStaticContainer',
'BuddyBossPlatform\GroundLevel\Container\Contracts\StaticContainerAwareness' => 'GroundLevel\Container\Contracts\StaticContainerAwareness',
'BuddyBossPlatform\GroundLevel\Container\ServiceProvider' => 'GroundLevel\Container\ServiceProvider',
'BuddyBossPlatform\GroundLevel\Container\Resolver' => 'GroundLevel\Container\Resolver',

// Mothership classes.
'BuddyBossPlatform\GroundLevel\Mothership\Service' => 'GroundLevel\Mothership\Service',
'BuddyBossPlatform\GroundLevel\Mothership\MothershipServiceProvider' => 'GroundLevel\Mothership\MothershipServiceProvider',
'BuddyBossPlatform\GroundLevel\Mothership\AbstractPluginConnection' => 'GroundLevel\Mothership\AbstractPluginConnection',
'BuddyBossPlatform\GroundLevel\Mothership\Credentials' => 'GroundLevel\Mothership\Credentials',
'BuddyBossPlatform\GroundLevel\Mothership\Api\Request' => 'GroundLevel\Mothership\Api\Request',
Expand All @@ -45,26 +47,68 @@ function buddyboss_setup_mothership_aliases() {
'BuddyBossPlatform\GroundLevel\Mothership\Manager\AddonsManager' => 'GroundLevel\Mothership\Manager\AddonsManager',
'BuddyBossPlatform\GroundLevel\Mothership\Manager\AddonInstallSkin' => 'GroundLevel\Mothership\Manager\AddonInstallSkin',
'BuddyBossPlatform\GroundLevel\Mothership\ExtensionType' => 'GroundLevel\Mothership\ExtensionType',
'BuddyBossPlatform\GroundLevel\InProductNotifications\Service' => 'GroundLevel\InProductNotifications\Service',
'BuddyBossPlatform\GroundLevel\InProductNotifications\IPNServiceProvider' => 'GroundLevel\InProductNotifications\IPNServiceProvider',
);

// Create aliases from actual namespace to BuddyBossPlatform namespace.
foreach ( $class_mappings as $alias => $original ) {
// Skip if alias already exists.
// Skip if alias already exists. Do NOT autoload the alias here — the prefixed
// name has no file in a non-scoped build, so autoloading it would be wasted.
if ( class_exists( $alias, false ) || interface_exists( $alias, false ) || trait_exists( $alias, false ) ) {
continue;
}

// Check if the original class/interface/trait exists and create alias.
if ( class_exists( $original, false ) ) {
// Resolve the original class/interface/trait WITH autoloading. This function runs at
// mothership-init include time, before anything has referenced the vendor classes, so
// without autoloading every check would return false and no aliases would be created —
// which then fatals when BB_Plugin_Connector/BB_Addons_Manager extend the prefixed
// parent names. (The reverse-alias function already autoloads for the same reason.)
if ( class_exists( $original ) ) {
class_alias( $original, $alias );
} elseif ( interface_exists( $original, false ) ) {
} elseif ( interface_exists( $original ) ) {
class_alias( $original, $alias );
} elseif ( trait_exists( $original, false ) ) {
} elseif ( trait_exists( $original ) ) {
class_alias( $original, $alias );
}
}
}

// Call the function immediately since we need these aliases available.
/**
* Create reverse aliases (prefixed -> un-prefixed) for service providers referenced by
* GroundLevel `@inject` docblock annotations.
*
* The GroundLevel 7.4.0 dependency resolver reads `@inject \GroundLevel\...::CONST`
* annotations and resolves them with PHP's `constant()`. Because the vendor packages are
* PHP-Scoper prefixed to `BuddyBossPlatform\GroundLevel\...`, but the scoper does NOT rewrite
* class names inside docblock comments, those annotations still reference the un-prefixed
* class names (e.g. `\GroundLevel\Mothership\MothershipServiceProvider::PARAM_API_BASE_URL`).
* Without these aliases the resolver throws "@inject references undefined constant" and the
* Mothership/IPN services fail to boot.
*
* @since BuddyBoss [BBVERSION]
*/
function buddyboss_setup_mothership_inject_aliases() {
$provider_mappings = array(
// Un-prefixed alias => actual prefixed class.
'GroundLevel\Mothership\MothershipServiceProvider' => 'BuddyBossPlatform\GroundLevel\Mothership\MothershipServiceProvider',
'GroundLevel\InProductNotifications\IPNServiceProvider' => 'BuddyBossPlatform\GroundLevel\InProductNotifications\IPNServiceProvider',
'GroundLevel\Component\ComponentServiceProvider' => 'BuddyBossPlatform\GroundLevel\Component\ComponentServiceProvider',
);

foreach ( $provider_mappings as $alias => $original ) {
if ( class_exists( $alias, false ) ) {
continue;
}

// Allow autoloading here ($original may not be loaded yet this early in boot);
// class_alias() then makes the un-prefixed name resolve to the real prefixed class
// so the resolver's constant() lookups on @inject annotations succeed.
if ( class_exists( $original ) ) {
class_alias( $original, $alias );
}
}
}

// Call the functions immediately since we need these aliases available.
buddyboss_setup_mothership_aliases();
buddyboss_setup_mothership_inject_aliases();
Loading
Loading