admin
1 year ago
lib
11 months ago
captcha.php
2 years ago
cloudsecure-wp.php
11 months ago
common.php
1 year ago
config.php
2 years ago
disable-access-system-file.php
1 year ago
disable-author-query.php
2 years ago
disable-login.php
1 year ago
disable-restapi.php
1 year ago
disable-xmlrpc.php
1 year ago
htaccess.php
1 year ago
login-log.php
1 year ago
login-notification.php
1 year ago
rename-login-page.php
1 year ago
restrict-admin-page.php
1 year ago
server-error-notification.php
1 year ago
two-factor-authentication.php
11 months ago
unify-messages.php
2 years ago
update-notice.php
2 years ago
waf-engine.php
1 year ago
waf.php
1 year ago
unify-messages.php
101 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | class CloudSecureWP_Unify_Messages extends CloudSecureWP_Common { |
| 8 | private const KEY_FEATURE = 'unify_messages'; |
| 9 | private const ERROR_MESSAGE = '� |
| 10 | �力に誤りがあります'; |
| 11 | |
| 12 | private $config; |
| 13 | private $disable_login; |
| 14 | |
| 15 | function __construct( array $info, CloudSecureWP_Config $config, CloudSecureWP_Disable_Login $disable_login ) { |
| 16 | parent::__construct( $info ); |
| 17 | $this->config = $config; |
| 18 | $this->disable_login = $disable_login; |
| 19 | } |
| 20 | |
| 21 | /** |
| 22 | * 機能毎のKEY取得 |
| 23 | * |
| 24 | * @return string |
| 25 | */ |
| 26 | public function get_feature_key(): string { |
| 27 | return self::KEY_FEATURE; |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * 有効無効判定 |
| 32 | * |
| 33 | * @return bool |
| 34 | */ |
| 35 | public function is_enabled(): bool { |
| 36 | return $this->config->get( $this->get_feature_key() ) === 't' ? true : false; |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * 初期設定値取得 |
| 41 | * |
| 42 | * @return array |
| 43 | */ |
| 44 | public function get_default(): array { |
| 45 | return array( self::KEY_FEATURE => $this->check_environment() ? 't' : 'f' ); |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * 設定値取得 |
| 50 | */ |
| 51 | public function get_settings(): array { |
| 52 | $settings = array(); |
| 53 | $default = $this->get_default(); |
| 54 | |
| 55 | foreach ( $default as $key => $val ) { |
| 56 | $settings[ $key ] = $this->config->get( $key ); |
| 57 | } |
| 58 | |
| 59 | return $settings; |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * 設定値保存 |
| 64 | * |
| 65 | * @param array $settings |
| 66 | * @return void |
| 67 | */ |
| 68 | public function save_settings( $settings ): void { |
| 69 | $default = $this->get_default(); |
| 70 | |
| 71 | foreach ( $default as $key => $val ) { |
| 72 | $this->config->set( $key, $settings[ $key ] ?? '' ); |
| 73 | } |
| 74 | |
| 75 | $this->config->save(); |
| 76 | } |
| 77 | |
| 78 | public function login_errors( $error ) { |
| 79 | return self::ERROR_MESSAGE; |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * 有効化 |
| 84 | * |
| 85 | * @return void |
| 86 | */ |
| 87 | public function activate(): void { |
| 88 | $this->save_settings( $this->get_default() ); |
| 89 | } |
| 90 | |
| 91 | /** |
| 92 | * 無効化 |
| 93 | * |
| 94 | * @return void |
| 95 | */ |
| 96 | public function deactivate(): void { |
| 97 | $this->config->set( $this->get_feature_key(), 'f' ); |
| 98 | $this->config->save(); |
| 99 | } |
| 100 | } |
| 101 |