<?php

final class MainWP_ITSEC_Core_Server_Config_Rules_Settings_Page extends MainWP_ITSEC_Module_Settings_Page {
	public function __construct() {
		$this->id = 'server-config-rules';
		$this->title = __( 'Server Config Rules', 'l10n-mainwp-ithemes-security-extension' );
		$this->description = __( 'If you need to manually add the server config rules generated by iThemes Security to your server, you can find them here.', 'l10n-mainwp-ithemes-security-extension' );
		$this->type = 'advanced';
		$this->information_only = true;
		$this->can_save = false;
		$this->always_active = true;

		parent::__construct();
	}

	protected function render_description( $form ) {
		require_once( MainWP_ITSEC_Core::get_core_dir() . '/lib/class-itsec-lib-config-file.php' );

		global $mainwp_itheme_site_data_values;
		$config = '';				
		if (is_array($mainwp_itheme_site_data_values)) {
			$config = isset($mainwp_itheme_site_data_values['server_rules']) ? $mainwp_itheme_site_data_values['server_rules'] : '';
		} 

		if ( empty( $config ) ) {
			_e( 'There are no rules that need to be written.', 'l10n-mainwp-ithemes-security-extension' );
		} else {
			echo '<p>' . __( "The following rules need to be written to your server's config file. Please make sure to keep the comments in place." ) . '</p>';
			echo '<div class="itsec_server_config_rules"><pre>' . esc_html( $config ) . '</pre></div>';
		}
	}
}
new MainWP_ITSEC_Core_Server_Config_Rules_Settings_Page();


final class MainWP_ITSEC_Core_WPConfig_File_Settings_Page extends MainWP_ITSEC_Module_Settings_Page {
	public function __construct() {
		$this->id = 'wp-config-rules';
		$this->title = __( 'wp-config.php Rules', 'l10n-mainwp-ithemes-security-extension' );
		$this->description = __( 'If you need to manually add the <code>wp-config.php</code> rules generated by iThemes Security to your server, you can find them here.', 'l10n-mainwp-ithemes-security-extension' );
		$this->type = 'advanced';
		$this->information_only = true;
		$this->can_save = false;
		$this->always_active = true;

		parent::__construct();
	}

	protected function render_description( $form ) {		 
		require_once( MainWP_ITSEC_Core::get_core_dir() . '/lib/class-itsec-lib-config-file.php' );

		global $mainwp_itheme_site_data_values;
		$config = '';				
		if (is_array($mainwp_itheme_site_data_values)) {
			$config = isset($mainwp_itheme_site_data_values['config_rules']) ? $mainwp_itheme_site_data_values['config_rules'] : '';
		} 

		if ( empty( $config ) ) {
			_e( 'There is nothing that needs to be written to your <code>wp-config.php</code> file.', 'l10n-mainwp-ithemes-security-extension' );
		} else {
			echo '<p>' . __( "The following rules need to be written to your <code>wp-config.php</code> file. Please make sure to keep the comments in place." ) . '</p>';
			echo '<div class="itsec_rewrite_rules"><pre>' . esc_html( $config ) . '</pre></div>';
		}
	}
}
new MainWP_ITSEC_Core_WPConfig_File_Settings_Page();
