文件操作 - PEL.php
返回文件管理
返回主菜单
删除本文件
文件: /home/www/public/wp-content/plugins/ionos-security/inc/Controllers/PEL.php
编辑文件内容
<?php namespace Ionos\Security\Controllers; use Ionos\Librarysecurity\Config; use Ionos\Security\Controllers\Settings\SettingsPEL; use Ionos\Security\Helper; /** * Contains the main logic of the feature and functions that are used for managing the plugin options. */ class PEL { /** * Initializes the feature. * * @since 1.0.0 */ public static function init() { // Check if the feature is enabled in the s3 config. if ( Config::get( 'features.pel.enabled' ) !== '1' ) { return; } add_action( 'admin_init', [ __CLASS__, 'init_settings_builder' ], 240 ); // Check if toggle is switched on. if ( self::get_option( 'pel_enabled' ) === 1 ) { self::enable_pel(); } } /** * Load the settings builder scripts. */ public static function init_settings_builder() { $settings = new SettingsPEL(); $settings->init(); } /** * Enables the PEL feature. * * @since 1.0.0 */ private static function enable_pel() { remove_filter( 'authenticate', 'wp_authenticate_email_password', 20 ); add_filter( 'authenticate', [ __CLASS__, 'email_auth_filter' ], 200, 2 ); } /** * Filters the authentication process to prevent login with email address. * * @param \WP_User $user The user object. * @param string $username The username. * * @since 1.0.0 */ public static function email_auth_filter( $user, $username ) { if ( false !== strpos( $username, '@' ) ) { return new \WP_Error( 'email_login_inactive', __( '<strong>Error</strong>: The login with an email address is deactivated for this website. Please use your username instead.', 'ionos-security' ) ); } return $user; } /** * Gets plugins options. * * @since 1.0.0 * * @return array Array of option values */ public static function get_options() { return get_option( 'ionos-security', [] ); } /** * Merges the options passed as parameter with the existing options and updates them in database. * * @since 1.0.0 * * @param array $options The options to update. * * @return bool */ public static function set_options( $options ) { $merged_options = array_merge( self::get_options(), $options ); return update_option( 'ionos-security', $merged_options ); } /** * Gets a specific option. * * @since 1.0.0 * * @param string $option The option key. * * @return mixed|null */ public static function get_option( $option ) { $options = self::get_options(); if ( isset( $options[ $option ] ) ) { return $options[ $option ]; } return null; } /** * Gets options managed by the xmlrpc-guard feature. * * @since 1.0.0 * * @return array Array of option values prefixed with xmlrpc_guard_. */ public static function get_feature_options() { return array_filter( self::get_options(), /** * Filters options by prefix. * * @param string $option_key The option key. * * @return bool True if the option key starts with xmlrpc_guard_, false otherwise. */ function ( $option_key ) { return strpos( $option_key, 'pel_' ) !== false; }, ARRAY_FILTER_USE_KEY ); } }
修改文件时间
将文件时间修改为当前时间的前一年
删除文件