captcha.php
1 year ago
common.php
1 year ago
dashboard.php
2 months ago
disable-access-system-file.php
7 months ago
disable-author-query.php
1 year ago
disable-login.php
1 year ago
disable-restapi.php
1 year ago
disable-xmlrpc.php
1 year ago
login-log-table.php
3 months 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
2 months ago
server-error-table.php
1 year ago
two-factor-authentication-registration.php
2 months ago
two-factor-authentication.php
2 months ago
unify-messages.php
1 year ago
update-notice.php
2 months ago
waf-table.php
1 year ago
waf.php
2 months ago
update-notice.php
172 lines
| 1 | <?php |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | class CloudSecureWP_Admin_Update_Notice extends CloudSecureWP_Admin_Common { |
| 8 | private $update_notice; |
| 9 | private $constant_settings; |
| 10 | |
| 11 | function __construct( array $info, CloudSecureWP_Update_Notice $update_notice ) { |
| 12 | parent::__construct( $info ); |
| 13 | $this->update_notice = $update_notice; |
| 14 | $this->constant_settings = $this->update_notice->get_constant_settings(); |
| 15 | $this->prepare_view_data(); |
| 16 | $this->render(); |
| 17 | } |
| 18 | |
| 19 | /** |
| 20 | * 画面表示用のデータを準備 |
| 21 | */ |
| 22 | public function prepare_view_data(): void { |
| 23 | $this->datas = $this->update_notice->get_settings(); |
| 24 | $flag_cron_error = false; |
| 25 | |
| 26 | if ( ! empty( $_POST ) && check_admin_referer( $this->update_notice->get_feature_key() . '_csrf' ) ) { |
| 27 | |
| 28 | foreach ( $this->datas as $key => $val ) { |
| 29 | |
| 30 | switch ( $key ) { |
| 31 | case 'update_notice': |
| 32 | $tmp = sanitize_text_field( $_POST[ $key ] ?? '' ); |
| 33 | if ( ! $this->is_selected( $tmp, self::TF_VALIES ) ) { |
| 34 | $this->errors[] = '有効・無効の値が不正です'; |
| 35 | } |
| 36 | |
| 37 | if ( ! $this->check_environment() ) { |
| 38 | $tmp = 'f'; |
| 39 | } |
| 40 | |
| 41 | if ( 't' === $tmp ) { |
| 42 | $cron_error = $this->update_notice->check_cron_error(); |
| 43 | |
| 44 | if ( '' !== $cron_error ) { |
| 45 | $this->errors[] = $cron_error; |
| 46 | $tmp = 'f'; |
| 47 | $flag_cron_error = true; |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | $this->datas[ $key ] = $tmp; |
| 52 | break; |
| 53 | |
| 54 | case 'update_notice_wp': |
| 55 | $tmp = sanitize_text_field( $_POST[ $key ] ?? '' ); |
| 56 | if ( ! $this->is_selected( $tmp, $this->constant_settings['update_notice_wp'] ) ) { |
| 57 | $this->errors[] = 'WordPressアップデートの値が不正です'; |
| 58 | } |
| 59 | $this->datas[ $key ] = $tmp; |
| 60 | break; |
| 61 | |
| 62 | case 'update_notice_plugin': |
| 63 | $tmp = sanitize_text_field( $_POST[ $key ] ?? '' ); |
| 64 | if ( ! $this->is_selected( $tmp, $this->constant_settings['update_notice_plugin'] ) ) { |
| 65 | $this->errors[] = 'プラグインアップデートの値が不正です'; |
| 66 | } |
| 67 | $this->datas[ $key ] = $tmp; |
| 68 | break; |
| 69 | |
| 70 | case 'update_notice_theme': |
| 71 | $tmp = sanitize_text_field( $_POST[ $key ] ?? '' ); |
| 72 | if ( ! $this->is_selected( $tmp, $this->constant_settings['update_notice_theme'] ) ) { |
| 73 | $this->errors[] = 'テーマアップデートの値が不正です'; |
| 74 | } |
| 75 | $this->datas[ $key ] = $tmp; |
| 76 | break; |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | if ( empty( $this->errors ) ) { |
| 81 | if ( 't' === $this->datas['update_notice'] ) { |
| 82 | $this->messages[] = 'アップデート通知機能が有効になりました。'; |
| 83 | $this->update_notice->set_cron(); |
| 84 | } else { |
| 85 | $this->messages[] = 'アップデート通知機能が無効になりました。'; |
| 86 | $this->update_notice->remove_cron(); |
| 87 | $this->datas['update_notice_last_notice'] = $this->update_notice->get_last_notice_default(); |
| 88 | } |
| 89 | |
| 90 | $this->update_notice->save_settings( $this->datas ); |
| 91 | |
| 92 | } elseif ( $flag_cron_error === true ) { |
| 93 | $this->update_notice->remove_cron(); |
| 94 | $this->update_notice->save_settings( $this->datas ); |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | $this->datas = $this->get_checked( $this->datas, array( 'update_notice', 'update_notice_wp', 'update_notice_plugin', 'update_notice_theme' ) ); |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * デスクリプション |
| 103 | */ |
| 104 | protected function admin_description(): void { |
| 105 | ?> |
| 106 | <nav> |
| 107 | <ul class="breadcrumb"> |
| 108 | <li class="breadcrumb__list"><a href="?page=cloudsecurewp">ダッシュボード</a></li> |
| 109 | <li class="breadcrumb__list">アップデート通知</li> |
| 110 | </ul> |
| 111 | </nav> |
| 112 | <div class="title-block mb-12"> |
| 113 | <p class="title-block-small-text">この機能のマニュアルは<a class="title-block-link" target="_blank" href="https://wpplugin.cloudsecure.ne.jp/cloudsecure_wp_security/update_notification.php">こちら</a></p> |
| 114 | <h1 class="title-block-title">アップデート通知</h1> |
| 115 | </div> |
| 116 | <div class="title-bottom-text"> |
| 117 | WordPress、プラグイン、テーマの更新が� |
| 118 | 要になったとき、WordPressの管理� |
| 119 | ユーザーにメールで通知します。<br /> |
| 120 | 更新の確認は24時間ごとに行われます。<br /> |
| 121 | <strong>※「/cron.php」へのhttpアクセスが発生するため、アクセスできない環境では機能を有効化できません。<br /> |
| 122 | Basic認証(ベーシック認証 / 基本認証)を設定している場合など、ご注意ください。</strong> |
| 123 | </div> |
| 124 | <?php |
| 125 | } |
| 126 | |
| 127 | /** |
| 128 | * ページコンテンツ |
| 129 | */ |
| 130 | protected function page(): void { |
| 131 | ?> |
| 132 | <form method="post"> |
| 133 | <div class="enabled-or-disabled"> |
| 134 | <input class="enabled-or-disabled__btn" id="enabled" type="radio" name="update_notice" value="t" <?php echo esc_html( $this->datas['update_notice_t'] ?? '' ); ?> /><label for="enabled">有効</label> |
| 135 | <input class="enabled-or-disabled__btn" id="disabled" type="radio" name="update_notice" value="f" <?php echo esc_html( $this->datas['update_notice_f'] ?? '' ); ?> /><label for="disabled">無効</label> |
| 136 | </div> |
| 137 | <div class="box"> |
| 138 | <div class="box-bottom"> |
| 139 | <div class="box-row flex-start"> |
| 140 | <div class="box-row-title not-label">WordPressアップデート</div> |
| 141 | <div class="box-row-content radio-btns"> |
| 142 | <input type="radio" class="circle-radio" id="update_notice_wp-off" name="update_notice_wp" value="<?php echo esc_attr( $this->constant_settings['update_notice_wp'][0] ); ?>" <?php echo esc_html( $this->datas[ 'update_notice_wp_' . $this->constant_settings['update_notice_wp'][0] ] ?? '' ); ?> /><label for="update_notice_wp-off"><?php echo esc_html( $this->constant_settings['update_notice_wp'][0] ); ?> 通知しない</label><br /> |
| 143 | <input type="radio" class="circle-radio" id="update_notice_wp-on" name="update_notice_wp" value="<?php echo esc_attr( $this->constant_settings['update_notice_wp'][1] ); ?>" <?php echo esc_html( $this->datas[ 'update_notice_wp_' . $this->constant_settings['update_notice_wp'][1] ] ?? '' ); ?> /><label for="update_notice_wp-on"><?php echo esc_html( $this->constant_settings['update_notice_wp'][1] ); ?> 通知する</label><br /> |
| 144 | </div> |
| 145 | </div> |
| 146 | <div class="box-row flex-start"> |
| 147 | <div class="box-row-title not-label">プラグインアップデート</div> |
| 148 | <div class="box-row-content radio-btns"> |
| 149 | <input type="radio" id="update_notice_plugin-off" class="circle-radio" name="update_notice_plugin" value="<?php echo esc_attr( $this->constant_settings['update_notice_plugin'][0] ); ?>" <?php echo esc_html( $this->datas[ 'update_notice_plugin_' . $this->constant_settings['update_notice_plugin'][0] ] ?? '' ); ?> /><label for="update_notice_plugin-off"><?php echo esc_html( $this->constant_settings['update_notice_plugin'][0] ); ?> 通知しない</label><br /> |
| 150 | <input type="radio" id="update_notice_plugin-all-on" class="circle-radio" name="update_notice_plugin" value="<?php echo esc_attr( $this->constant_settings['update_notice_plugin'][1] ); ?>" <?php echo esc_html( $this->datas[ 'update_notice_plugin_' . $this->constant_settings['update_notice_plugin'][1] ] ?? '' ); ?> /><label for="update_notice_plugin-all-on"><?php echo esc_html( $this->constant_settings['update_notice_plugin'][1] ); ?> すべて通知する</label><br /> |
| 151 | <input type="radio" id="update_notice_plugin-exclusive-on" class="circle-radio" name="update_notice_plugin" value="<?php echo esc_attr( $this->constant_settings['update_notice_plugin'][2] ); ?>" <?php echo esc_html( $this->datas[ 'update_notice_plugin_' . $this->constant_settings['update_notice_plugin'][2] ] ?? '' ); ?> /><label for="update_notice_plugin-exclusive-on"><?php echo esc_html( $this->constant_settings['update_notice_plugin'][2] ); ?> 有効化されたプラグインのみ通知する</label> |
| 152 | </div> |
| 153 | </div> |
| 154 | <div class="box-row flex-start"> |
| 155 | <div class="box-row-title not-label">テーマアップデート</div> |
| 156 | <div class="box-row-content radio-btns"> |
| 157 | <input type="radio" id="update_notice_theme-off" class="circle-radio" name="update_notice_theme" value="<?php echo esc_attr( $this->constant_settings['update_notice_theme'][0] ); ?>" <?php echo esc_html( $this->datas[ 'update_notice_theme_' . $this->constant_settings['update_notice_theme'][0] ] ?? '' ); ?> /><label for="update_notice_theme-off"><?php echo esc_html( $this->constant_settings['update_notice_theme'][0] ); ?> 通知しない</label><br /> |
| 158 | <input type="radio" id="update_notice_theme-all-on" class="circle-radio" name="update_notice_theme" value="<?php echo esc_attr( $this->constant_settings['update_notice_theme'][1] ); ?>" <?php echo esc_html( $this->datas[ 'update_notice_theme_' . $this->constant_settings['update_notice_theme'][1] ] ?? '' ); ?> /><label for="update_notice_theme-all-on"><?php echo esc_html( $this->constant_settings['update_notice_theme'][1] ); ?> すべて通知する</label><br /> |
| 159 | <input type="radio" id="update_notice_theme-exclusive-on" class="circle-radio" name="update_notice_theme" value="<?php echo esc_attr( $this->constant_settings['update_notice_theme'][2] ); ?>" <?php echo esc_html( $this->datas[ 'update_notice_theme_' . $this->constant_settings['update_notice_theme'][2] ] ?? '' ); ?> /><label for="update_notice_theme-exclusive-on"><?php echo esc_html( $this->constant_settings['update_notice_theme'][2] ); ?> 有効化されたテーマのみ通知する</label> |
| 160 | </div> |
| 161 | </div> |
| 162 | </div> |
| 163 | </div> |
| 164 | <div id="submit-btn-area"> |
| 165 | <?php $this->nonce_wp( $this->update_notice->get_feature_key() ); ?> |
| 166 | <?php $this->submit_button_wp(); ?> |
| 167 | </div> |
| 168 | </form> |
| 169 | <?php |
| 170 | } |
| 171 | } |
| 172 |