diff --git a/assets/images/store-growth-logo.png b/assets/images/store-growth-logo.png new file mode 100644 index 0000000000..c55fbef117 Binary files /dev/null and b/assets/images/store-growth-logo.png differ diff --git a/includes/Admin/RecommendedPlugins.php b/includes/Admin/RecommendedPlugins.php new file mode 100644 index 0000000000..2d400bb1cc --- /dev/null +++ b/includes/Admin/RecommendedPlugins.php @@ -0,0 +1,128 @@ +plugins = [ + [ + 'type' => 'store_growth', + 'title' => __( 'StoreGrowth', 'dokan-lite' ), + 'description' => __( 'Best WooCommerce Marketing Solution!', 'dokan-lite' ), + 'img_url' => DOKAN_PLUGIN_ASSEST . '/images/store-growth-logo.png', + 'img_alt' => __( 'StoreGrowth logo', 'dokan-lite' ), + 'plugins' => [ + [ + 'name' => __( 'StoreGrowth', 'dokan-lite' ), + 'slug' => 'storegrowth-sales-booster', + 'basename' => 'storegrowth-sales-booster/storegrowth-sales-booster.php', + ], + ], + ], + [ + 'type' => 'wemail', + 'title' => __( 'weMail', 'dokan-lite' ), + 'description' => __( 'Simplified Email Marketing Solution for WordPress!', 'dokan-lite' ), + 'img_url' => DOKAN_PLUGIN_ASSEST . '/images/wemail-logo.png', + 'img_alt' => __( 'weMail logo', 'dokan-lite' ), + 'plugins' => [ + [ + 'name' => __( 'weMail', 'dokan-lite' ), + 'slug' => 'wemail', + 'basename' => 'wemail/wemail.php', + ], + ], + ], + [ + 'type' => 'wc_conversion_tracking', + 'title' => __( 'WooCommerce Conversion Tracking', 'dokan-lite' ), + 'description' => __( 'Track conversions on your WooCommerce store like a pro!', 'dokan-lite' ), + 'img_url' => DOKAN_PLUGIN_ASSEST . '/images/wc-conversion-tracking-logo.png', + 'img_alt' => __( 'WooCommerce Conversion Tracking logo', 'dokan-lite' ), + 'plugins' => [ + [ + 'name' => __( 'WooCommerce Conversion Tracking', 'dokan-lite' ), + 'slug' => 'woocommerce-conversion-tracking', + 'basename' => 'woocommerce-conversion-tracking/conversion-tracking.php', + ], + ], + ], + [ + 'type' => 'texty', + 'title' => __( 'Texty', 'dokan-lite' ), + 'description' => __( 'SMS Notification for WordPress, WooCommerce, Dokan and more!', 'dokan-lite' ), + 'img_url' => DOKAN_PLUGIN_ASSEST . '/images/texty-logo.png', + 'img_alt' => __( 'Texty logo', 'dokan-lite' ), + 'plugins' => [ + [ + 'name' => __( 'Texty', 'dokan-lite' ), + 'slug' => 'texty', + 'basename' => 'texty/texty.php', + ], + ], + ], + ]; + } + + /** + * Get All Enlisted Plugins. + * + * @since DOKAN_SINCE + * + * @return array + */ + protected function get_enlisted_plugins(): array { + return apply_filters( 'dokan_recommended_plugins_list', $this->plugins ); + } + + /** + * Is Plugin Active. + * + * @since DOKAN_SINCE + * + * @param string $basename + * + * @return bool + */ + protected function is_active( string $basename ): bool { + return apply_filters( 'dokan_recommended_plugin_is_active', is_plugin_active( $basename ), $basename ); + } + + /** + * Get List of Recommended Inactive Plugins. + * + * @since DOKAN_SINCE + * + * @return array + */ + public function get(): array { + $enlisted_plugins = $this->get_enlisted_plugins(); + + $recommended_plugins = array_filter( + $enlisted_plugins, + function ( $plugin ) { + return isset( $plugin['plugins'][0]['basename'] ) && ! $this->is_active( $plugin['plugins'][0]['basename'] ); + } + ); + + return apply_filters( 'dokan_recommended_inactive_plugins', $recommended_plugins ); + } +} diff --git a/includes/Admin/SetupWizard.php b/includes/Admin/SetupWizard.php index 1772f1bda9..2f25db0b62 100644 --- a/includes/Admin/SetupWizard.php +++ b/includes/Admin/SetupWizard.php @@ -26,6 +26,15 @@ class SetupWizard { */ private $deferred_actions = []; + /** + * Instance of RecommendedPlugins class for managing plugin recommendations. + * + * @since DOKAN_SINCE + * + * @var RecommendedPlugins Handles the retrieval and management of recommended plugins + */ + private RecommendedPlugins $recommended_plugins; + /** * Hook in tabs. */ @@ -35,6 +44,8 @@ public function __construct() { } if ( current_user_can( 'manage_woocommerce' ) ) { + $this->recommended_plugins = new RecommendedPlugins(); + add_action( 'admin_menu', [ $this, 'admin_menus' ] ); add_action( 'admin_init', [ $this, 'setup_wizard' ], 99 ); @@ -699,58 +710,8 @@ public function dokan_setup_recommended() {