Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install Plugins Extended #517

Merged
merged 8 commits into from
Mar 18, 2024
Merged
Changes from 4 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
28 changes: 27 additions & 1 deletion includes/Services/PluginService.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use NewfoldLabs\WP\Module\Onboarding\WP_Admin;
use NewfoldLabs\WP\Module\Onboarding\Data\Options;
use NewfoldLabs\WP\Module\Onboarding\Data\Config;
use NewfoldLabs\WP\Module\Installer\Services\PluginInstaller;
use NewfoldLabs\WP\Module\Installer\TaskManagers\PluginActivationTaskManager;
use NewfoldLabs\WP\Module\Installer\TaskManagers\PluginInstallTaskManager;
Expand All @@ -21,6 +22,28 @@
* Class for providing plugin related services.
*/
class PluginService {

/**
* Gets the list of plugins based on different enabled Hiive Flags
*
* @return array
*/
public static function initialize_hiive_flag_plugins() {
$init_plugins_extended = array();
$hiive_flags = Plugins::get_hiive_plugin_flags();
officiallygod marked this conversation as resolved.
Show resolved Hide resolved

foreach ( $hiive_flags as $hiive_flag => $is_enabled ) {
// Check if it is an allowed flag and is enabled on the container
if ( true === $is_enabled && true === Config::get_site_capability( $hiive_flag ) ) {
// Check if there are plugins for the flag.
if ( isset( Plugins::$hiive_flag_plugin_list[ $hiive_flag ] ) ) {
officiallygod marked this conversation as resolved.
Show resolved Hide resolved
$init_plugins_extended = array_merge( $init_plugins_extended, Plugins::$hiive_flag_plugin_list[ $hiive_flag ] );
}
}
}
return $init_plugins_extended;
}

/**
* Queues the initial list of Plugin Installs for a flow.
*
Expand All @@ -41,6 +64,9 @@ public static function initialize() {
$init_plugins = array_merge( Plugins::get_init(), SiteFeatures::get_init() );
}

// Add plugins enabled by Hiive Flags
$init_plugins = array_merge( $init_plugins, self::initialize_hiive_flag_plugins() );
arunshenoy99 marked this conversation as resolved.
Show resolved Hide resolved

foreach ( $init_plugins as $init_plugin ) {
$init_plugin_type = PluginInstaller::get_plugin_type( $init_plugin['slug'] );
$init_plugin_path = PluginInstaller::get_plugin_path( $init_plugin['slug'], $init_plugin_type );
Expand All @@ -51,7 +77,7 @@ public static function initialize() {
new PluginInstallTask(
$init_plugin['slug'],
$init_plugin['activate'],
$init_plugin['priority']
isset( $init_plugin['priority'] ) ? $init_plugin['priority'] : 0
)
);
continue;
Expand Down
Loading