PluginProbe ʕ •ᴥ•ʔ
CloudSecure WP Security / 1.2.6
CloudSecure WP Security v1.2.6
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 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 server-error-notification.php 2 years ago server-error-table.php 2 years ago two-factor-authentication-registration.php 2 years ago two-factor-authentication.php 2 years ago unify-messages.php 2 years ago update-notice.php 2 years ago
common.php
199 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 $error_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 * @return string
84 * @param string $view_text
85 * @return void
86 */
87 protected function submit_button_wp( string $view_text = '' ): void {
88 if ( '' === $view_text ) {
89 $view_text = '変更を保存';
90 }
91 submit_button( $view_text );
92 }
93
94 /**
95 * wp_nonceのview
96 *
97 * @param string $feature_key
98 * @return void
99 */
100 protected function nonce_wp( string $feature_key ): void {
101 wp_nonce_field( $feature_key . '_csrf', '_wpnonce' );
102 }
103
104 /**
105 * checkbox radioのchecked
106 *
107 * @param array $datas
108 * @param array $names
109 * @return array
110 */
111 protected function get_checked( array $datas, array $names ): array {
112 $checks = array();
113
114 foreach ( $names as $name ) {
115 if ( ! empty( $datas[ $name ] ) ) {
116 $checks[ $name . '_' . $datas[ $name ] ] = 'checked';
117 }
118 }
119 $datas = array_merge( $checks, $datas );
120
121 return $datas;
122 }
123
124 /**
125 * レンダリング
126 *
127 * @return void
128 */
129 protected function render(): void {
130 $this->allowed_notice_html = array(
131 'div' => array(
132 'id' => array(),
133 'class' => array(),
134 ),
135 'a' => array(
136 'href' => array(),
137 'target' => array(),
138 ),
139 'br' => array(),
140 );
141
142 wp_enqueue_script( 'cloudsecurewp', $this->info['plugin_url'] . 'assets/js/script.js' );
143
144 if ( is_multisite() ) {
145 $this->errors[] = self::MESSAGES['error_multisite'];
146 }
147
148 $conflict_plugin_name = $this->get_conflict_plugin_name();
149 if ( '' != $conflict_plugin_name ) {
150 $this->errors[] = self::MESSAGES['error_conflict_plugin'] . "{$conflict_plugin_name}";
151 }
152
153 print( '<div id="cloudsecure-wp-security" class="wrap">' . "\n" . '<div class="header">' . "\n" . '<div class="header-logo">' . "\n" . '</div>' . "\n" . '</div>' . "\n" );
154 print( '<div class="top-area ">' . "\n" . '<div class="error-success-area ">' . "\n" );
155
156 if ( ! empty( $this->messages ) ) {
157 print( wp_kses( $this->get_message_notices( $this->messages ), $this->allowed_notice_html ) );
158 }
159
160 if ( ! empty( $this->important_messages ) ) {
161 print( wp_kses( $this->get_important_message_notices( $this->important_messages ), $this->allowed_notice_html ) );
162 }
163
164 if ( ! empty( $this->errors ) ) {
165 print( wp_kses( $this->get_error_notices( $this->errors ), $this->allowed_notice_html ) );
166 }
167
168 if ( ! is_multisite() ) {
169 print( '</div>' . "\n" );
170 $this->admin_description();
171 print( '</div>' . "\n" );
172
173 $this->page();
174 }
175
176 print( '</div>' . "\n" );
177 }
178
179 /* デスクリプション */
180 protected function admin_description(): void {}
181
182 /* ページコンテンツ */
183 protected function page(): void {}
184
185 /**
186 * 選択肢の値確認
187 *
188 * @param string $selected_value
189 * @param array $values
190 * @return bool
191 */
192 protected function is_selected( string $selected_value, array $values ): bool {
193 if ( empty( $selected_value ) ) {
194 return false;
195 }
196 return in_array( $selected_value, $values );
197 }
198 }
199