PluginProbe ʕ •ᴥ•ʔ
CloudSecure WP Security / 1.4.13
CloudSecure WP Security v1.4.13
1.4.14 1.4.13 1.4.12 1.4.11 1.4.10 1.4.9 trunk 0.9.0 1.0.2 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.1 1.3.10 1.3.11 1.3.12 1.3.13 1.3.14 1.3.15 1.3.16 1.3.17 1.3.18 1.3.19 1.3.2 1.3.20 1.3.21 1.3.22 1.3.23 1.3.24 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8
cloudsecure-wp-security / modules / admin / disable-restapi.php
cloudsecure-wp-security / modules / admin Last commit date
captcha.php 2 weeks ago common.php 2 years ago dashboard.php 1 month ago disable-access-system-file.php 9 months ago disable-author-query.php 2 years ago disable-login.php 2 years ago disable-restapi.php 2 weeks ago disable-xmlrpc.php 2 years ago login-log-table.php 4 months ago login-log.php 2 years ago login-notification.php 3 months ago rename-login-page.php 1 month ago restrict-admin-page.php 3 months ago server-error-notification.php 4 months ago server-error-table.php 1 year ago two-factor-authentication-registration.php 3 months ago two-factor-authentication.php 4 months ago unify-messages.php 2 years ago update-notice.php 1 month ago waf-table.php 1 year ago waf.php 1 month ago
disable-restapi.php
159 lines
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 class CloudSecureWP_Admin_Disable_RESTAPI extends CloudSecureWP_Admin_Common {
8 private $disable_restapi;
9 private $active_exclude_list = '';
10 private $allowed_html;
11
12 function __construct( array $info, CloudSecureWP_Disable_RESTAPI $disable_restapi ) {
13 parent::__construct( $info );
14 $this->disable_restapi = $disable_restapi;
15 $this->prepare_view_data();
16 $this->render();
17 }
18
19 /**
20 * 画面表示用のデータを準備
21 */
22 public function prepare_view_data(): void {
23 $this->datas = $this->disable_restapi->get_settings();
24
25 if ( ! empty( $_POST ) && check_admin_referer( $this->disable_restapi->get_feature_key() . '_csrf' ) ) {
26
27 foreach ( $this->datas as $key => $val ) {
28
29 switch ( $key ) {
30 case 'disable_rest_api':
31 $tmp = sanitize_text_field( $_POST[ $key ] ?? '' );
32 if ( ! $this->is_selected( $tmp, self::TF_VALIES ) ) {
33 $this->errors[] = '有効・無効の値が不正です';
34 }
35
36 if ( ! $this->check_environment() ) {
37 $tmp = 'f';
38 }
39
40 $this->datas[ $key ] = $tmp;
41 break;
42
43 case 'disable_rest_api_exclude':
44 $tmp = sanitize_textarea_field( wp_unslash( $_POST[ $key ] ?? '' ) );
45 $this->datas[ $key ] = $this->disable_restapi->text2array( $tmp );
46 break;
47 }
48 }
49
50 if ( empty( $this->errors ) ) {
51 if ( 't' === $this->datas['disable_rest_api'] ) {
52 $this->messages[] = 'REST API無効化機能が有効になりました。';
53 } else {
54 $this->messages[] = 'REST API無効化機能が無効になりました。';
55 }
56
57 $this->disable_restapi->save_settings( $this->datas );
58 }
59 }
60
61 if ( is_array( $this->datas['disable_rest_api_exclude'] ) ) {
62 $this->datas['disable_rest_api_exclude'] = $this->array2text( $this->datas['disable_rest_api_exclude'] );
63 }
64
65 $this->datas = $this->get_checked( $this->datas, array( 'disable_rest_api' ) );
66 $active_themes = $this->disable_restapi->get_active_theme_names();
67 $active_plugins = $this->disable_restapi->get_active_plugin_names();
68
69 // 除外に追加していない有効なテーマ・プラグインが無いグループは見出しごと表示しない
70 if ( ! empty( $active_themes ) ) {
71 $this->active_exclude_list .= '<li class="exclude-group-label" data-group="theme">-- テーマ --</li>' . "\n";
72 foreach ( $active_themes as $active_theme ) {
73 $this->active_exclude_list .= '<li data-group="theme"><span>' . esc_html( $active_theme ) . '</span>&nbsp;<a class="btn-exclude">[追加]</a></li>' . "\n";
74 }
75 }
76
77 if ( ! empty( $active_plugins ) ) {
78 $this->active_exclude_list .= '<li class="exclude-group-label" data-group="plugin">-- プラグイン --</li>' . "\n";
79 foreach ( $active_plugins as $active_plugin ) {
80 $this->active_exclude_list .= '<li data-group="plugin"><span>' . esc_html( $active_plugin ) . '</span>&nbsp;<a class="btn-exclude">[追加]</a></li>' . "\n";
81 }
82 }
83
84 $this->allowed_html = array(
85 'li' => array(
86 'class' => array(),
87 'data-group' => array(),
88 ),
89 'span' => array(),
90 'a' => array(
91 'class' => array(),
92 ),
93 );
94 }
95
96 /**
97 * デスクリプション
98 */
99 protected function admin_description(): void {
100 ?>
101 <nav>
102 <ul class="breadcrumb">
103 <li class="breadcrumb__list"><a href="?page=cloudsecurewp">ダッシュボード</a></li>
104 <li class="breadcrumb__list">REST API無効化</li>
105 </ul>
106 </nav>
107 <div class="title-block mb-12">
108 <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>
109 <h1 class="title-block-title">REST API無効化</h1>
110 </div>
111 <div class="title-bottom-text">
112 REST APIの悪用を防ぐため、機能自体を無効化します。<br />
113 デフォルトでは「oEmbed」「Contact Form 7」「Akismet」を除外リストに設定しています。<br />
114 <strong>※上記プラグインが正常に機能しない可能性があるため。</strong>
115 </div>
116 <?php
117 }
118
119 /**
120 * ページコンテンツ
121 */
122 protected function page(): void {
123 ?>
124 <form method="post">
125 <div class="enabled-or-disabled">
126 <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>
127 <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>
128 </div>
129 <div class="box">
130 <div class="box-top">除外</div>
131 <div class="box-bottom pt-0">
132 <div class="remove-plugin-area">
133 <div class="remove-plugin-area-text order-1">除外するテーマ・プラグインを直接�
134 �力できます。※テーマ・プラグインごとに改行してください。</div>
135 <div class="remove-plugin-area-text order-4">以下のテーマ・プラグインの「+」ボタンをクリックすると、除外リストに追加できます。</div>
136 <div class="remove-plugin-area-label order-2">除外リスト</div>
137 <div class="remove-plugin-area-label order-5">除外できるテーマとプラグイン</div>
138 <div class="remove-plugin-area-textarea-wrapper">
139 <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>
140 </div>
141 <div class="remove-plugin-area-like-textarea-wrapper">
142 <div class="remove-plugin-area-like-textarea">
143 <ul id="active-plugins">
144 <?php echo wp_kses( $this->active_exclude_list, $this->allowed_html ); ?>
145 </ul>
146 </div>
147 </div>
148 </div>
149 </div>
150 </div>
151 <div id="submit-btn-area">
152 <?php $this->nonce_wp( $this->disable_restapi->get_feature_key() ); ?>
153 <?php $this->submit_button_wp(); ?>
154 </div>
155 </form>
156 <?php
157 }
158 }
159