<?php
/**
 * This class handles the HonePot tab.
 *
 * @author     FutrX
 * @year       2023
 * @package    NoMoreBots
 * @subpackage NoMoreBots\Admin\Pages\Settings
 */

namespace NoMoreBots\Admin\Pages\Settings;

use Carbon_Fields\Field;


class Remote {

	/**
	 * Returns the Object for the activation field
	 *
	 * @return Field\Field
	 */
	public static function getActivateField(): Field\Field {
		return Field::make( 'select', NOMOREBOTS_REMOTE_FIELD_PREFIX . '_activate', 'Activate Remote' )
					->add_options(
						array(
							'yes' => 'Yes',
							'no'  => 'No',
						)
					)
					->set_help_text(
						'By activating this option, the plugin will disable any remote requests to register new users to the site. This will prevent Bots that uses DOS attacks and other spam techniques. **HIGHLY RECOMMENDED**',
						NOMOREBOTS_PLUGINTEXTDOMAIN
					)
					->set_default_value( 'yes' );
	}


	/**
	 * Save the Remote fields directly to wp_options for faster and more performant access.
	 *
	 * @return void
	 */
	public static function saveRemoteFields() {
		// 1. Activate Option.
		$otpActivate = carbon_get_theme_option( NOMOREBOTS_REMOTE_FIELD_PREFIX . '_activate' );
		update_option( NOMOREBOTS_REMOTE_FIELD_PREFIX . '_activate', $otpActivate );
	}
}
