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