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