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