Skip to content

Commit

Permalink
Add Logic
Browse files Browse the repository at this point in the history
  • Loading branch information
officiallygod committed Sep 24, 2024
1 parent bc7bc4f commit 3a66dc3
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions includes/Services/PluginService.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public static function initialize() {

$init_plugins = array();

$is_entitlements_plugin_installed = self::install_entitlements_plugins();

$flow = Data::current_flow();
if ( 'sitegen' === $flow && SiteGenService::is_enabled() ) {
$init_plugins = Plugins::get_init();
Expand Down Expand Up @@ -157,6 +159,41 @@ public static function activate_init_plugins() {
return true;
}

/**
* Installs the entitlements plugin.
* This function installs the required entitlements plugin if it's not already installed.
*
* @return bool True if the entitlements plugin is installed, false otherwise.
*/
public static function install_entitlements_plugins() {
// TO-DO Ensure a call is made to the endpoint and data is used.
$entitlements_plugins = array();
foreach ( $entitlements_plugins as $plugin ) {
// Checks if a plugin with the given slug and activation criteria already exists.
if ( PluginInstaller::is_plugin_installed( $plugin['basename'] ) ) {
// Add a new PluginInstallTask to the Plugin install queue.
PluginActivationTaskManager::add_to_queue(
new PluginActivationTask(
$plugin['slug']
)
);
continue;
}

PluginInstallTaskManager::add_to_queue(
new PluginInstallTask(
$plugin['slug'],
true,
0,
0,
true,
$plugin
)
);
}
return true;
}

/**
* Sets up a Transient to activate plugins and filter_active_plugins
*
Expand Down

0 comments on commit 3a66dc3

Please sign in to comment.