<?php

namespace SovereignStack\SecuritySafe;

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

/**
 * Class AdminPagePrivacy
 *
 * @package SecuritySafe
 * @since   0.2.0
 */
class AdminPagePrivacy extends AdminPage {

	/**
	 * This populates all the metaboxes for this specific page.
	 *
	 * @since  0.2.0
	 * @return string
	 *
	 */
	function tab_settings() {

		$html = '';

		// Shutoff Switch - All Privacy Policies
		$classes = ( $this->page_settings['on'] ) ? '' : 'notice-warning';

		$rows = $this->form_select( $this->page_settings, __( 'Privacy Policies', 'security-safe' ), 'on', [
				'0' => __( 'Disabled', 'security-safe' ),
				'1' => __( 'Enabled', 'security-safe' ),
			], __( 'If you experience a problem, you may want to temporarily turn off all privacy policies at once to troubleshoot the issue.', 'security-safe' ), $classes );

		$html .= $this->form_table( $rows );

		// Source Code Versions ================
		$html .= $this->form_section( __( 'Software Privacy', 'security-safe' ), __( 'It is important to conceal what versions of software you are using.', 'security-safe' ) );

		// WordPress Version
		$classes = '';

		$rows = $this->form_checkbox( $this->page_settings, __( 'WordPress Version', 'security-safe' ), 'wp_generator', __( 'Hide WordPress Version Publicly', 'security-safe' ), __( 'WordPress leaves little public footprints about the version of your site in multiple places visible to the public. This feature removes the WordPress version from the generator tag and RSS feed.', 'security-safe' ), $classes, false );

		$classes = '';

		$rows .= $this->form_checkbox( $this->page_settings, '', 'wp_version_admin_footer', __( 'Hide WordPress Version in Admin Footer', 'security-safe' ), __( 'WordPress places the version number at the bottom of the WP-Admin screen.', 'security-safe' ), $classes, false );

		// Script Versions
		$classes = '';

		$rows .= $this->form_checkbox( $this->page_settings, __( 'Script Versions', 'security-safe' ), 'hide_script_versions', __( 'Hide Script Versions', 'security-safe' ), __( 'This replaces all script versions appended to the enqueued JS and CSS files with the current date (YYYYMMDD).', 'security-safe' ), $classes, false );

		$rows .= '<tr><td colspan="2">' . sprintf( __( '<i>NOTICE: You can also <a href="%s">deny access to files</a> that disclose software versions.</i>', 'security-safe' ), admin_url( 'admin.php?page=' . SECSAFE_SLUG . '-files#file-access' ) ) . '</td></tr>';

		$html .= $this->form_table( $rows );

		// Website Privacy ================
		$html .= $this->form_section( __( 'Website Privacy', 'security-safe' ), __( 'Do not share unnecessary information about your website.', 'security-safe' ) );

		// Website Information
		$classes = '';
		$rows = $this->form_checkbox( $this->page_settings, __( 'Website Information', 'security-safe' ), 'http_headers_useragent', __( 'Make Website Anonymous', 'security-safe' ), __( 'When checking for updates, WordPress gets access to your current version and your website URL. The default info looks like this: "WordPress/X.X; https://www.your-website.com" This feature removes your URL address from the information sent.', 'security-safe' ), $classes, false );

		$html .= $this->form_table( $rows );

		// Save Button ================
		$html .= $this->button( __( 'Save Settings', 'security-safe' ) );

		return $html;
	}

	/**
	 * This sets the variables for the page.
	 *
	 * @since  0.1.0
	 */
	protected function set_page() {

		$this->slug = SECSAFE_SLUG . '-privacy';
		$this->title = __( 'Privacy', 'security-safe' );
		$this->description = __( 'Anonymity is one of your fundamental rights. Embody it in principle.', 'security-safe' );

		$this->tabs[] = [
			'id' => 'settings',
			'label' => __( 'Settings', 'security-safe' ),
			'title' => __( 'Privacy Settings', 'security-safe' ),
			'heading' => false,
			'intro' => false,
			'content_callback' => 'tab_settings',
		];
	}
}
