Skip to content

Commit f0ba76b

Browse files
authored
Merge pull request #4932 from Automattic/staging
Production release: v20231010.0
2 parents 67c0280 + 6b25ae7 commit f0ba76b

25 files changed

+803
-509
lines changed

__tests__/e2e/package-lock.json

+7-37
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

integrations/vip-governance.php

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
/**
3+
* Integration: VIP Governance.
4+
*
5+
* @package Automattic\VIP\Integrations
6+
*/
7+
8+
namespace Automattic\VIP\Integrations;
9+
10+
/**
11+
* Loads VIP Governance.
12+
*
13+
* @private
14+
*/
15+
class VipGovernanceIntegration extends Integration {
16+
17+
/**
18+
* The version of the VIP Governance plugin to load, that's set to the latest version.
19+
* This should be higher than the lowestVersion set in "vip-governance" config (https://github.com/Automattic/vip-go-mu-plugins-ext/blob/trunk/config.json)
20+
*
21+
* @var string
22+
*/
23+
protected string $version = '1.0';
24+
25+
/**
26+
* Returns `true` if `VIP Governance` is already available e.g. via customer code. We will use
27+
* this function to prevent activating of integration from platform side.
28+
*/
29+
public function is_loaded(): bool {
30+
return defined( 'VIP_GOVERNANCE_LOADED' );
31+
}
32+
33+
/**
34+
* Applies hooks to load VIP Governance plugin.
35+
*
36+
* @private
37+
*/
38+
public function load(): void {
39+
// Wait until plugins_loaded to give precedence to the plugin in the customer repo.
40+
add_action( 'plugins_loaded', function () {
41+
// Return if the integration is already loaded.
42+
//
43+
// In activate() method we do make sure to not activate the integration if its already loaded
44+
// but still adding it here as a safety measure i.e. if load() is called directly.
45+
if ( $this->is_loaded() ) {
46+
return;
47+
}
48+
49+
// Load the version of the plugin that should be set to the latest version, otherwise if it's not found deactivate the integration.
50+
$load_path = WPMU_PLUGIN_DIR . '/vip-integrations/vip-governance-' . $this->version . '/vip-governance.php';
51+
if ( file_exists( $load_path ) ) {
52+
require_once $load_path;
53+
} else {
54+
$this->is_active = false;
55+
}
56+
} );
57+
}
58+
59+
/**
60+
* Configure `VIP Governance` for VIP Platform.
61+
*/
62+
public function configure(): void {}
63+
}

0 commit comments

Comments
 (0)