[ 'name' => __('Lightify', 'crownify'), 'tagline' => __('Caching, asset & media optimization and Core Web Vitals monitoring.', 'crownify'), 'constant' => 'LIGHTIFY_VERSION', ], 'generatify' => [ 'name' => __('Generatify', 'crownify'), 'tagline' => __('AI suite with chatbot, content generation, agents and automations.', 'crownify'), 'constant' => 'GENERATIFY_VERSION', ], 'progressify' => [ 'name' => __('Progressify', 'crownify'), 'tagline' => __('PWA features: install prompts, offline access and push notifications.', 'crownify'), 'constant' => 'PROGRESSIFY_VERSION', ], 'snapshotify' => [ 'name' => __('Snapshotify', 'crownify'), 'tagline' => __('Backup, restore and migration with scheduled snapshots and cloud storage.', 'crownify'), 'constant' => 'SNAPSHOTIFY_VERSION', ], ]; } public function recordInstallTime() { if (!get_option(self::INSTALL_TIME_OPTION)) { update_option(self::INSTALL_TIME_OPTION, time()); } } public function renderNotices() { if (!current_user_can('manage_options')) { return; } if (Utils::hasActivePro()) { return; } $showReview = $this->shouldShow(self::REVIEW_DISMISS_OPTION, self::REVIEW_DELAY, self::REVIEW_DISMISS_PERIOD); $showUpgrade = $this->shouldShow(self::UPGRADE_DISMISS_OPTION, self::UPGRADE_DELAY, self::UPGRADE_DISMISS_PERIOD); $stackPlugins = []; $showStack = false; if ($this->canInstallPlugins() && $this->shouldShow(self::STACK_DISMISS_OPTION, self::STACK_DELAY, self::STACK_DISMISS_PERIOD)) { $stackPlugins = $this->getStackPluginsWithStatus(); foreach ($stackPlugins as $plugin) { if ($plugin['state'] !== 'active') { $showStack = true; break; } } } if (!$showReview && !$showUpgrade && !$showStack) { return; } $this->renderStyles(); $this->renderDismissScript(); if ($showReview) { $this->renderReviewNotice(); } if ($showUpgrade) { $this->renderUpgradeNotice(); } if ($showStack) { $this->renderStackNotice($stackPlugins); } } private function canInstallPlugins() { if (Utils::hasActivePro()) { return false; } return current_user_can('install_plugins') && current_user_can('activate_plugins'); } private function getStackPluginsWithStatus() { $plugins = $this->getStackPlugins(); foreach ($plugins as $slug => $plugin) { $status = $this->getPluginStatus($slug, $plugin['constant']); $plugins[$slug]['state'] = $status['state']; $plugins[$slug]['file'] = $status['file']; } return $plugins; } /** * Detect whether a stack plugin is active, installed but inactive, or missing. * Matches both the free folder and the Freemius premium folder (slug-pro / slug-premium). */ private function getPluginStatus($slug, $constant) { if (defined($constant)) { return ['state' => 'active', 'file' => '']; } if (!function_exists('get_plugins')) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $folders = [$slug, "{$slug}-pro", "{$slug}-premium"]; foreach (get_plugins() as $file => $data) { if (!in_array(strtolower(dirname($file)), $folders, true)) { continue; } return [ 'state' => is_plugin_active($file) ? 'active' : 'inactive', 'file' => $file, ]; } return ['state' => 'missing', 'file' => '']; } private function shouldShow($dismissOption, $delay, $dismissPeriod) { $installedAt = (int) get_option(self::INSTALL_TIME_OPTION, 0); if (!$installedAt || time() - $installedAt < $delay) { return false; } $dismissedAt = (int) get_option($dismissOption, 0); if ($dismissedAt && time() - $dismissedAt < $dismissPeriod) { return false; } return true; } private function renderReviewNotice() { $nonce = wp_create_nonce('rankify_dismiss_notice'); $logoUrl = plugins_url('assets/media/icons/icon-256x256.png', RANKIFY_FILE); ?>
__('Not installed', 'crownify'), 'inactive' => __('Installed, inactive', 'crownify'), 'active' => __('Active', 'crownify'), ]; ?>