PluginProbe ʕ •ᴥ•ʔ
CloudSecure WP Security / 1.2.1
CloudSecure WP Security v1.2.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 / disable-author-query.php
cloudsecure-wp-security / modules Last commit date
admin 2 years ago lib 2 years ago captcha.php 2 years ago cloudsecure-wp.php 2 years ago common.php 2 years ago config.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 htaccess.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 two-factor-authentication.php 2 years ago unify-messages.php 2 years ago update-notice.php 2 years ago
disable-author-query.php
105 lines
1 <?php
2 class CloudSecureWP_Disable_Author_Query extends CloudSecureWP_Common {
3 private const KEY_FEATURE = 'disable_author_query';
4 private $config;
5
6 function __construct( array $info, CloudSecureWP_Config $config ) {
7 parent::__construct( $info );
8 $this->config = $config;
9 }
10
11 /**
12 * 機能毎のKEY取得
13 *
14 * @return string
15 */
16 public function get_feature_key(): string {
17 return self::KEY_FEATURE;
18 }
19
20 /**
21 * 有効無効判定
22 *
23 * @return bool
24 */
25 public function is_enabled(): bool {
26 return $this->config->get( $this->get_feature_key() ) === 't' ? true : false;
27 }
28
29 /**
30 * 初期設定値取得
31 *
32 * @return array
33 */
34 public function get_default(): array {
35 $ret = array(
36 self::KEY_FEATURE => $this->check_environment() ? 't' : 'f',
37 );
38 return $ret;
39 }
40
41 /**
42 * 設定値取得
43 */
44 public function get_settings(): array {
45 $settings = array();
46 $default = $this->get_default();
47
48 foreach ( $default as $key => $val ) {
49 $settings[ $key ] = $this->config->get( $key );
50 }
51
52 return $settings;
53 }
54
55 /**
56 * 設定値保存
57 *
58 * @param array $settings
59 * @return void
60 */
61 public function save_settings( $settings ): void {
62 $default = $this->get_default();
63
64 foreach ( $default as $key => $val ) {
65 $this->config->set( $key, $settings[ $key ] ?? '' );
66 }
67
68 $this->config->save();
69 }
70
71 /**
72 * author_query
73 */
74 function init() {
75 $url = sanitize_url( $_SERVER['REQUEST_URI'] ?? '' );
76
77 if ( ! empty( $url ) ) {
78 if ( ! is_admin() && preg_match( '/[?&]author=\d+/i', $url ) ) {
79 wp_safe_redirect( home_url( self::PAGE_404 ) );
80 exit;
81 }
82 }
83 }
84
85 /**
86 * 有効化
87 *
88 * @return void
89 */
90 public function activate(): void {
91 $this->save_settings( $this->get_default() );
92 }
93
94 /**
95 * 無効化
96 *
97 * @return void
98 */
99 public function deactivate(): void {
100 $this->config->set( $this->get_feature_key(), 'f' );
101 $this->config->save();
102 }
103
104 }
105