captcha.php
2 years ago
common.php
2 years ago
dashboard.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
login-log-table.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
unify-messages.php
2 years ago
update-notice.php
2 years ago
login-notification.php
143 lines
| 1 | <?php |
| 2 | |
| 3 | class CloudSecureWP_Admin_Login_Notification extends CloudSecureWP_Admin_Common { |
| 4 | private $login_notification; |
| 5 | |
| 6 | function __construct( array $info, CloudSecureWP_Login_Notification $login_notification ) { |
| 7 | parent::__construct( $info ); |
| 8 | $this->login_notification = $login_notification; |
| 9 | $this->prepare_view_data(); |
| 10 | $this->render(); |
| 11 | } |
| 12 | |
| 13 | /** |
| 14 | * 画面表示用のデータを準備 |
| 15 | */ |
| 16 | public function prepare_view_data(): void { |
| 17 | $this->datas = $this->login_notification->get_settings(); |
| 18 | |
| 19 | if ( ! empty( $_POST ) && check_admin_referer( $this->login_notification->get_feature_key() . '_csrf' ) ) { |
| 20 | |
| 21 | foreach ( $this->datas as $key => $val ) { |
| 22 | |
| 23 | switch ( $key ) { |
| 24 | case 'login_notification': |
| 25 | $tmp = sanitize_text_field( $_POST[ $key ] ?? '' ); |
| 26 | if ( ! $this->is_selected( $tmp, self::TF_VALIES ) ) { |
| 27 | $this->errors[] = '有効・無効の値が不正です'; |
| 28 | } |
| 29 | |
| 30 | if ( ! $this->check_environment() ) { |
| 31 | $tmp = 'f'; |
| 32 | } |
| 33 | |
| 34 | $this->datas[ $key ] = $tmp; |
| 35 | break; |
| 36 | |
| 37 | case 'login_notification_subject': |
| 38 | $tmp = stripslashes( sanitize_textarea_field( $_POST[ $key ] ?? '' ) ); |
| 39 | if ( ! $tmp ) { |
| 40 | $this->errors[] = '件名を� |
| 41 | �力してください'; |
| 42 | } |
| 43 | $this->datas[ $key ] = $tmp; |
| 44 | break; |
| 45 | |
| 46 | case 'login_notification_body': |
| 47 | $tmp = stripslashes( sanitize_textarea_field( $_POST[ $key ] ?? '' ) ); |
| 48 | if ( ! $tmp ) { |
| 49 | $this->errors[] = '本文を� |
| 50 | �力してください'; |
| 51 | } |
| 52 | $this->datas[ $key ] = $tmp; |
| 53 | break; |
| 54 | |
| 55 | case 'login_notification_admin_only': |
| 56 | $tmp = sanitize_text_field( $_POST[ $key ] ?? 'f' ); |
| 57 | if ( ! $this->is_selected( $tmp, self::TF_VALIES ) ) { |
| 58 | $this->errors[] = '管理� |
| 59 | のみ通知の値が不正です'; |
| 60 | } |
| 61 | $this->datas[ $key ] = $tmp; |
| 62 | break; |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | if ( empty( $this->errors ) ) { |
| 67 | if ( 't' === $this->datas['login_notification'] ) { |
| 68 | $this->messages[] = 'ログイン通知機能が有効になりました。'; |
| 69 | } else { |
| 70 | $this->messages[] = 'ログイン通知機能が無効になりました。'; |
| 71 | } |
| 72 | |
| 73 | $this->login_notification->save_settings( $this->datas ); |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | $this->datas = $this->get_checked( $this->datas, array( 'login_notification', 'login_notification_admin_only' ) ); |
| 78 | } |
| 79 | |
| 80 | /** |
| 81 | * デスクリプション |
| 82 | */ |
| 83 | protected function admin_description(): void { |
| 84 | ?> |
| 85 | <div class="title-block mb-12"> |
| 86 | <h1 class="title-block-title">ログイン通知</h1> |
| 87 | <p class="title-block-small-text">この機能のマニュアルは<a class="title-block-link" target="_blank" href="https://wpplugin.cloudsecure.ne.jp/cloudsecure_wp_security/login_notification.php">こちら</a></p> |
| 88 | </div> |
| 89 | <div class="title-bottom-text"> |
| 90 | ログインがあったとき、ユーザーにメールで通知します。 |
| 91 | </div> |
| 92 | <?php |
| 93 | } |
| 94 | |
| 95 | /** |
| 96 | * ページコンテンツ |
| 97 | */ |
| 98 | protected function page(): void { |
| 99 | ?> |
| 100 | <form method="post"> |
| 101 | <div class="enabled-or-disabled"> |
| 102 | <input class="enabled-or-disabled__btn" id="enabled" type="radio" name="login_notification" value="t" <?php echo esc_html( $this->datas['login_notification_t'] ?? '' ); ?> /><label for="enabled">有効</label> |
| 103 | <input class="enabled-or-disabled__btn" id="disabled" type="radio" name="login_notification" value="f" <?php echo esc_html( $this->datas['login_notification_f'] ?? '' ); ?> /><label for="disabled">無効</label> |
| 104 | </div> |
| 105 | <div class="box"> |
| 106 | <div class="box-bottom"> |
| 107 | <div class="box-row flex-start"> |
| 108 | <div class="box-row-title not-label pt-12"> |
| 109 | サブジェクト |
| 110 | </div> |
| 111 | <div class="box-row-content"> |
| 112 | <input style="width:100%;" type="text" name="login_notification_subject" value="<?php echo esc_attr( sanitize_text_field( $this->datas['login_notification_subject'] ) ); ?>" /> |
| 113 | </div> |
| 114 | </div> |
| 115 | <div class="box-row flex-start"> |
| 116 | <div class="box-row-title not-label pt-12"> |
| 117 | メール本文 |
| 118 | </div> |
| 119 | <div class="box-row-content"> |
| 120 | <textarea class="login-notification-textarea" style="width:100%; height:148px;" name="login_notification_body"><?php echo esc_textarea( $this->datas['login_notification_body'] ); ?></textarea> |
| 121 | </div> |
| 122 | </div> |
| 123 | <div class="box-row flex-start"> |
| 124 | <div class="box-row-title not-label"> |
| 125 | 受信� |
| 126 | |
| 127 | </div> |
| 128 | <div class="box-row-content "> |
| 129 | <input id="receiver-checkbox" class="checkbox" type="checkbox" name="login_notification_admin_only" value="t" <?php echo esc_html( $this->datas['login_notification_admin_only_t'] ?? '' ); ?> /><label for="receiver-checkbox">管理� |
| 130 | のみ通知</label> |
| 131 | </div> |
| 132 | </div> |
| 133 | </div> |
| 134 | </div> |
| 135 | <div id="submit-btn-area"> |
| 136 | <?php $this->nonce_wp( $this->login_notification->get_feature_key() ); ?> |
| 137 | <?php $this->submit_button_wp(); ?> |
| 138 | </div> |
| 139 | </form> |
| 140 | <?php |
| 141 | } |
| 142 | } |
| 143 |