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
disable-restapi.php
132 lines
| 1 | <?php |
| 2 | |
| 3 | class CloudSecureWP_Admin_Disable_RESTAPI extends CloudSecureWP_Admin_Common { |
| 4 | private $disable_restapi; |
| 5 | private $active_plugin_list = ''; |
| 6 | private $allowed_html; |
| 7 | |
| 8 | function __construct( array $info, CloudSecureWP_Disable_RESTAPI $disable_restapi ) { |
| 9 | parent::__construct( $info ); |
| 10 | $this->disable_restapi = $disable_restapi; |
| 11 | $this->prepare_view_data(); |
| 12 | $this->render(); |
| 13 | } |
| 14 | |
| 15 | /** |
| 16 | * 画面表示用のデータを準備 |
| 17 | */ |
| 18 | public function prepare_view_data(): void { |
| 19 | $this->datas = $this->disable_restapi->get_settings(); |
| 20 | |
| 21 | if ( ! empty( $_POST ) && check_admin_referer( $this->disable_restapi->get_feature_key() . '_csrf' ) ) { |
| 22 | |
| 23 | foreach ( $this->datas as $key => $val ) { |
| 24 | |
| 25 | switch ( $key ) { |
| 26 | case 'disable_rest_api': |
| 27 | $tmp = sanitize_text_field( $_POST[ $key ] ?? '' ); |
| 28 | if ( ! $this->is_selected( $tmp, self::TF_VALIES ) ) { |
| 29 | $this->errors[] = '有効・無効の値が不正です'; |
| 30 | } |
| 31 | |
| 32 | if ( ! $this->check_environment() ) { |
| 33 | $tmp = 'f'; |
| 34 | } |
| 35 | |
| 36 | $this->datas[ $key ] = $tmp; |
| 37 | break; |
| 38 | |
| 39 | case 'disable_rest_api_exclude': |
| 40 | $tmp = stripslashes( sanitize_textarea_field( $_POST[ $key ] ?? '' ) ); |
| 41 | $this->datas[ $key ] = $this->disable_restapi->text2array( $tmp ); |
| 42 | break; |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | if ( empty( $this->errors ) ) { |
| 47 | if ( 't' === $this->datas['disable_rest_api'] ) { |
| 48 | $this->messages[] = 'REST API無効化機能が有効になりました。'; |
| 49 | } else { |
| 50 | $this->messages[] = 'REST API無効化機能が無効になりました。'; |
| 51 | } |
| 52 | |
| 53 | $this->disable_restapi->save_settings( $this->datas ); |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | if ( is_array( $this->datas['disable_rest_api_exclude'] ) ) { |
| 58 | $this->datas['disable_rest_api_exclude'] = $this->array2text( $this->datas['disable_rest_api_exclude'] ); |
| 59 | } |
| 60 | |
| 61 | $this->datas = $this->get_checked( $this->datas, array( 'disable_rest_api' ) ); |
| 62 | $active_plugins = $this->disable_restapi->get_active_plugin_names(); |
| 63 | |
| 64 | foreach ( $active_plugins as $active_plugin ) { |
| 65 | $this->active_plugin_list .= '<li><span>' . $active_plugin . '</span> <a class="btn-exclude">[追加]</a></li>' . "\n"; |
| 66 | } |
| 67 | |
| 68 | $this->allowed_html = array( |
| 69 | 'li' => array(), |
| 70 | 'span' => array(), |
| 71 | 'a' => array( |
| 72 | 'class' => array(), |
| 73 | ), |
| 74 | ); |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * デスクリプション |
| 79 | */ |
| 80 | protected function admin_description(): void { |
| 81 | ?> |
| 82 | <div class="title-block mb-12"> |
| 83 | <h1 class="title-block-title">REST API無効化</h1> |
| 84 | <p class="title-block-small-text">この機能のマニュアルは<a class="title-block-link" target="_blank" href="https://wpplugin.cloudsecure.ne.jp/cloudsecure_wp_security/disable_restapi.php">こちら</a></p> |
| 85 | </div> |
| 86 | <div class="title-bottom-text"> |
| 87 | REST APIの悪用を防ぐため、機能自体を無効化します。<br /> |
| 88 | デフォルトでは「oEmbed」「Contact Form 7」「Akismet」を除外プラグインにしています。<br /> |
| 89 | <strong>※上記プラグインが正常に機能しない可能性があるため。</strong> |
| 90 | </div> |
| 91 | <?php |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * ページコンテンツ |
| 96 | */ |
| 97 | protected function page(): void { |
| 98 | ?> |
| 99 | <form method="post"> |
| 100 | <div class="enabled-or-disabled"> |
| 101 | <input class="enabled-or-disabled__btn" id="enabled" type="radio" name="disable_rest_api" value="t" <?php echo esc_html( $this->datas['disable_rest_api_t'] ?? '' ); ?> /><label for="enabled">有効</label> |
| 102 | <input class="enabled-or-disabled__btn" id="disabled" type="radio" name="disable_rest_api" value="f" <?php echo esc_html( $this->datas['disable_rest_api_f'] ?? '' ); ?> /><label for="disabled">無効</label> |
| 103 | </div> |
| 104 | <div class="box"> |
| 105 | <div class="box-top">除外プラグイン</div> |
| 106 | <div class="box-bottom pt-0"> |
| 107 | <div class="remove-plugin-area"> |
| 108 | <div class="remove-plugin-area-text order-1">除外するプラグインを直接� |
| 109 | �力できます。※プラグインごとに改行してください。</div> |
| 110 | <div class="remove-plugin-area-text order-3">以下の有効なプラグインの「+」ボタンをクリックすると、除外するプラグインに追加できます。</div> |
| 111 | <div class="remove-plugin-area-textarea-wrapper"> |
| 112 | <textarea class="remove-plugin-area-textarea" id="disable_rest_api_exclude" name="disable_rest_api_exclude"><?php echo esc_textarea( $this->datas['disable_rest_api_exclude'] ); ?></textarea> |
| 113 | </div> |
| 114 | <div class="remove-plugin-area-like-textarea-wrapper"> |
| 115 | <div class="remove-plugin-area-like-textarea"> |
| 116 | <ul id="active-plugins"> |
| 117 | <?php echo wp_kses( $this->active_plugin_list, $this->allowed_html ); ?> |
| 118 | </ul> |
| 119 | </div> |
| 120 | </div> |
| 121 | </div> |
| 122 | </div> |
| 123 | </div> |
| 124 | <div id="submit-btn-area"> |
| 125 | <?php $this->nonce_wp( $this->disable_restapi->get_feature_key() ); ?> |
| 126 | <?php $this->submit_button_wp(); ?> |
| 127 | </div> |
| 128 | </form> |
| 129 | <?php |
| 130 | } |
| 131 | } |
| 132 |