Skip to content

Commit

Permalink
Rename PluginSuggestions to Suggestions for generic use
Browse files Browse the repository at this point in the history
  • Loading branch information
TorbenLundsgaard committed Oct 4, 2024
1 parent 9f96e3e commit f76f669
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
5 changes: 3 additions & 2 deletions inc/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use TLA_Media\GTM_Kit\Admin\NotificationsHandler;
use TLA_Media\GTM_Kit\Admin\PluginAvailability;
use TLA_Media\GTM_Kit\Admin\SetupWizard;
use TLA_Media\GTM_Kit\Admin\PluginSuggestions;
use TLA_Media\GTM_Kit\Admin\Suggestions;
use TLA_Media\GTM_Kit\Admin\TemplatesOptionsPage;
use TLA_Media\GTM_Kit\Common\Conditionals\ContactForm7Conditional;
use TLA_Media\GTM_Kit\Common\Conditionals\EasyDigitalDownloadsConditional;
Expand All @@ -30,6 +30,7 @@
use TLA_Media\GTM_Kit\Frontend\Stape;
use TLA_Media\GTM_Kit\Frontend\UserData;
use TLA_Media\GTM_Kit\Installation\Activation;
use TLA_Media\GTM_Kit\Installation\AutomaticUpdates;
use TLA_Media\GTM_Kit\Installation\Upgrade;
use TLA_Media\GTM_Kit\Integration\ContactForm7;
use TLA_Media\GTM_Kit\Integration\EasyDigitalDownloads;
Expand Down Expand Up @@ -177,7 +178,7 @@ function gtmkit_admin_init(): void {

$notifications_handler = NotificationsHandler::get();

PluginSuggestions::register( $notifications_handler, $plugin_availability, $util );
Suggestions::register( $notifications_handler, $plugin_availability, $options, $util );
Analytics::register( $options, $util );
MetaBox::register( $options );
SetupWizard::register( $options, $util );
Expand Down
24 changes: 17 additions & 7 deletions src/Admin/PluginSuggestions.php → src/Admin/Suggestions.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
use TLA_Media\GTM_Kit\Options;

/**
* Suggested plugins
* Suggestions
*/
final class PluginSuggestions {
final class Suggestions {

/**
* An instance of PluginAvailability.
Expand All @@ -32,6 +32,13 @@ final class PluginSuggestions {
*/
private NotificationsHandler $notifications_handler;

/**
* An instance of Options.
*
* @var Options
*/
private Options $options;

/**
* An instance of Util.
*
Expand All @@ -44,11 +51,13 @@ final class PluginSuggestions {
*
* @param NotificationsHandler $notifications_handler The notifications handler to add notifications to.
* @param PluginAvailability $plugin_availability Plugin Availability.
* @param Options $options Options.
* @param Util $util Util.
*/
public function __construct( NotificationsHandler $notifications_handler, PluginAvailability $plugin_availability, Util $util ) {
public function __construct( NotificationsHandler $notifications_handler, PluginAvailability $plugin_availability, Options $options, Util $util ) {
$this->notifications_handler = $notifications_handler;
$this->plugin_availability = $plugin_availability;
$this->options = $options;
$this->util = $util;
}

Expand All @@ -57,12 +66,13 @@ public function __construct( NotificationsHandler $notifications_handler, Plugin
*
* @param NotificationsHandler $notifications_handler The notifications handler to add notifications to.
* @param PluginAvailability $plugin_availability Plugin Availability.
* @param Options $options Options.
* @param Util $util Util.
*
* @return void
*/
public static function register( NotificationsHandler $notifications_handler, PluginAvailability $plugin_availability, Util $util ): void {
$page = new self( $notifications_handler, $plugin_availability, $util );
public static function register( NotificationsHandler $notifications_handler, PluginAvailability $plugin_availability, Options $options, Util $util ): void {
$page = new self( $notifications_handler, $plugin_availability, $options, $util );

add_action( 'admin_init', [ $page->plugin_availability, 'register' ] );
add_action( 'admin_init', [ $page, 'suggest_premium' ] );
Expand All @@ -83,7 +93,7 @@ public function suggest_premium(): void {
if ( ! (
( new WooCommerceConditional() )->is_met() &&
! ( new PremiumConditional() )->is_met() &&
! Options::init()->get( 'misc', 'gf_wishlist' ) === true )
! $this->options->get( 'misc', 'gf_wishlist' ) === true )
) {
$this->notifications_handler->remove_notification_by_id( $notification_id );
return;
Expand Down Expand Up @@ -182,7 +192,7 @@ public function suggest_grandfathered_wishlist(): void {
if ( ! (
( new WooCommerceConditional() )->is_met() &&
! ( new PremiumConditional() )->is_met() &&
Options::init()->get( 'misc', 'gf_wishlist' ) === true )
$this->options->get( 'misc', 'gf_wishlist' ) === true )
) {
$this->notifications_handler->remove_notification_by_id( $notification_id );
return;
Expand Down

0 comments on commit f76f669

Please sign in to comment.