PluginProbe ʕ •ᴥ•ʔ
CloudSecure WP Security / 1.3.10
CloudSecure WP Security v1.3.10
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 / common.php
cloudsecure-wp-security / modules / admin Last commit date
captcha.php 1 year ago common.php 1 year ago dashboard.php 1 year ago disable-access-system-file.php 1 year 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 1 year 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 1 year ago server-error-table.php 1 year ago two-factor-authentication-registration.php 2 years ago two-factor-authentication.php 1 year ago unify-messages.php 1 year ago update-notice.php 1 year ago waf-table.php 1 year ago waf.php 1 year ago
common.php
202 lines
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 class CloudSecureWP_Admin_Common extends CloudSecureWP_Common {
8 protected $datas;
9 protected $messages;
10 protected $errors;
11 protected $important_messages;
12 public const TF_VALIES = array( 't', 'f' );
13 private $allowed_notice_html;
14
15 function __construct( array $info ) {
16 parent::__construct( $info );
17 $this->datas = array();
18 $this->messages = array();
19 $this->errors = array();
20 $this->important_messages = array();
21 }
22
23 /**
24 * メッセージ行
25 *
26 * @param array $messages
27 * @return string
28 */
29 protected function get_message_view_lines( array $messages ): string {
30 $view_lines = '';
31
32 foreach ( $messages as $message ) {
33 $view_lines .= '<div>' . $message . '</div>';
34 }
35 return $view_lines;
36 }
37
38 /**
39 * メッセージ表示
40 *
41 * @param array $messages
42 * @return string
43 */
44 protected function get_message_notices( array $messages ): string {
45 if ( ! empty( $messages ) ) {
46 $view_lines = $this->get_message_view_lines( $messages );
47 return '<div id="settings_updated" class="success-box ">' . $view_lines . '</div>';
48 }
49 return '';
50 }
51
52 /**
53 * エラー表示
54 *
55 * @param array $messages
56 * @return string
57 */
58 protected function get_error_notices( array $messages ): string {
59 if ( ! empty( $messages ) ) {
60 $view_lines = $this->get_message_view_lines( $messages );
61 return '<div class="error-box">' . $view_lines . '</div>';
62 }
63 return '';
64 }
65
66 /**
67 * 重要メッセージ表示
68 *
69 * @param array $messages
70 * @return string
71 */
72 protected function get_important_message_notices( array $messages ): string {
73 if ( ! empty( $messages ) ) {
74 $view_lines = $this->get_message_view_lines( $messages );
75 return '<div id="settings_updated" class="success-box green">' . $view_lines . '</div>';
76 }
77 return '';
78 }
79
80 /**
81 * submitボタン取得
82 *
83 * @param string $view_text
84 * @return void
85 */
86 protected function submit_button_wp( string $view_text = '' ): void {
87 if ( '' === $view_text ) {
88 $view_text = '変更を保存';
89 }
90 submit_button( $view_text );
91 }
92
93 /**
94 * wp_nonceのview
95 *
96 * @param string $feature_key
97 * @return void
98 */
99 protected function nonce_wp( string $feature_key ): void {
100 wp_nonce_field( $feature_key . '_csrf', '_wpnonce' );
101 }
102
103 /**
104 * checkbox radioのchecked
105 *
106 * @param array $datas
107 * @param array $names
108 * @return array
109 */
110 protected function get_checked( array $datas, array $names ): array {
111 $checks = array();
112
113 foreach ( $names as $name ) {
114 if ( ! empty( $datas[ $name ] ) ) {
115 $checks[ $name . '_' . $datas[ $name ] ] = 'checked';
116 }
117 }
118 $datas = array_merge( $checks, $datas );
119
120 return $datas;
121 }
122
123 /**
124 * レンダリング
125 *
126 * @return void
127 */
128 protected function render(): void {
129 $this->allowed_notice_html = array(
130 'div' => array(
131 'id' => array(),
132 'class' => array(),
133 ),
134 'a' => array(
135 'href' => array(),
136 'target' => array(),
137 ),
138 'br' => array(),
139 );
140
141 wp_enqueue_script( 'cloudsecurewp', $this->info['plugin_url'] . 'assets/js/script.js', array(), $this->info['version'] );
142
143 if ( is_multisite() ) {
144 $this->errors[] = self::MESSAGES['error_multisite'];
145 }
146
147 $conflict_plugin_name = $this->get_conflict_plugin_name();
148 if ( '' !== $conflict_plugin_name ) {
149 $this->errors[] = self::MESSAGES['error_conflict_plugin'] . "{$conflict_plugin_name}";
150 }
151
152 print( '<div id="cloudsecure-wp-security" class="wrap">' . "\n" . '<div class="header">' . "\n" . '<div class="header-logo">' . "\n" . '</div>' . "\n" . '</div>' . "\n" );
153 print( '<div class="top-area ">' . "\n" . '<div class="error-success-area ">' . "\n" );
154
155 if ( ! empty( $this->messages ) ) {
156 print( wp_kses( $this->get_message_notices( $this->messages ), $this->allowed_notice_html ) );
157 }
158
159 if ( ! empty( $this->important_messages ) ) {
160 print( wp_kses( $this->get_important_message_notices( $this->important_messages ), $this->allowed_notice_html ) );
161 }
162
163 if ( ! empty( $this->errors ) ) {
164 print( wp_kses( $this->get_error_notices( $this->errors ), $this->allowed_notice_html ) );
165 }
166
167 if ( ! is_multisite() ) {
168 print( '</div>' . "\n" );
169 $this->admin_description();
170 print( '</div>' . "\n" );
171
172 $this->page();
173 }
174
175 print( '</div>' . "\n" );
176 }
177
178 /**
179 * デスクリプション
180 */
181 protected function admin_description(): void {}
182
183 /**
184 * ページコンテンツ
185 */
186 protected function page(): void {}
187
188 /**
189 * 選択肢の値確認
190 *
191 * @param string $selected_value
192 * @param array $values
193 * @return bool
194 */
195 protected function is_selected( string $selected_value, array $values ): bool {
196 if ( empty( $selected_value ) ) {
197 return false;
198 }
199 return in_array( $selected_value, $values );
200 }
201 }
202