<?php
namespace WPUltimateSecurity\UltimateSecurity\Modules\Monitoring\SiteHealth\Collectors;

/**
 * WordPress Information Collector
 *
 * Collects WordPress core information
 */
class WordPressCollector extends AbstractCollector
{
	/**
	 * Collect WordPress information
	 *
	 * @return array
	 */
	public function collect(): array
	{
		return [
			$this->item(__('WordPress Version', 'ultimate-security'), get_bloginfo('version')),
			$this->item(__('Site Language', 'ultimate-security'), get_bloginfo('language')),
			$this->item(__('Home URL', 'ultimate-security'), get_home_url()),
			$this->item(__('Site URL', 'ultimate-security'), get_site_url()),
			$this->item(__('Permalink Structure', 'ultimate-security'), $this->getPermalinkStructure()),
			$this->item(__('HTTPS Status', 'ultimate-security'), $this->getHttpsStatus()),
			$this->item(__('Multisite', 'ultimate-security'), is_multisite()),
			$this->item(__('User Registration', 'ultimate-security'), get_option('users_can_register')),
			$this->item(__('Default Role', 'ultimate-security'), get_option('default_role')),
			$this->item(__('Timezone', 'ultimate-security'), wp_timezone_string()),
			$this->item(__('Date Format', 'ultimate-security'), get_option('date_format')),
			$this->item(__('Time Format', 'ultimate-security'), get_option('time_format')),
		];
	}

	/**
	 * Get permalink structure
	 *
	 * @return string
	 */
	private function getPermalinkStructure(): string
	{
		$structure = get_option('permalink_structure');
		return $structure ? $structure : __('Default', 'ultimate-security');
	}

	/**
	 * Get HTTPS status
	 *
	 * @return string
	 */
	private function getHttpsStatus(): string
	{
		return is_ssl()
			? __('HTTPS is enabled', 'ultimate-security')
			: __('HTTPS is not enabled', 'ultimate-security');
	}

	/**
	 * Get collector name
	 *
	 * @return string
	 */
	public function getName(): string
	{
		return 'wordpress';
	}

	/**
	 * Get collector label
	 *
	 * @return string
	 */
	public function getLabel(): string
	{
		return __('WordPress', 'ultimate-security');
	}
}
