Skip to content

Commit

Permalink
Use activated_plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
arunshenoy99 committed Oct 14, 2024
1 parent 10e2a25 commit f0e519a
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions includes/WPAdmin/Listeners/InstallerListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function enqueue_installer_script() {
}

/**
* Listens for premium plugin activation.
* Listens for premium plugin activation using activated_plugin hook.
*
* @return void
*/
Expand All @@ -78,17 +78,19 @@ private function listen_for_premium_plugin_activation() {
return;
}

// Loop through each plugin in the license data and hook to its activation using basename
foreach ( $license_data_store as $plugin_slug => $license_data ) {
if ( isset( $license_data['basename'] ) ) {
$basename = $license_data['basename'];
add_action(
'activate_' . $basename,
function () use ( $plugin_slug, $pls_utility ) {
// Hook into activated_plugin action to trigger license activation after plugin activation
add_action(
'activated_plugin',
function ( $plugin, $network_wide ) use ( $pls_utility, $license_data_store ) {
foreach ( $license_data_store as $plugin_slug => $license_data ) {
if ( isset( $license_data['basename'] ) && $license_data['basename'] === $plugin ) {
$pls_utility->activate_license( $plugin_slug );
break;
}
);
}
}
}
},
10,
2
);
}
}

0 comments on commit f0e519a

Please sign in to comment.