PluginProbe ʕ •ᴥ•ʔ
CloudSecure WP Security / 1.4.14
CloudSecure WP Security v1.4.14
1.4.14 1.4.13 1.4.12 1.4.11 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 weeks ago cli 2 weeks ago lib 1 month ago captcha.php 2 weeks ago cloudsecure-wp.php 6 days ago common.php 4 months ago config.php 2 years ago disable-access-system-file.php 1 month ago disable-author-query.php 2 weeks ago disable-login.php 1 month ago disable-restapi.php 2 weeks ago disable-xmlrpc.php 1 year ago htaccess.php 4 months ago login-log.php 1 month ago login-notification.php 3 months ago protect-rest-batch.php 1 month ago rename-login-page.php 4 months ago restrict-admin-page.php 3 months ago server-error-notification.php 3 months ago two-factor-authentication.php 6 days ago unify-messages.php 2 years ago update-notice.php 9 months ago waf-engine.php 6 days ago waf.php 1 month ago
disable-author-query.php
115 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 * @param WP_Query $query
80 * @return void
81 */
82 public function pre_get_posts( $query ) {
83 if ( is_admin() || ! $query->is_main_query() ) {
84 return;
85 }
86
87 // URL クエリ(?author=)由来で、WordPress が数値 author として作�
88 アーカイブに解決したものだけを遮断する。
89 if ( $query->is_author() && isset( $_GET['author'] ) && '' !== $_GET['author'] && '' !== $query->get( 'author' ) ) {
90 wp_safe_redirect( home_url( self::PAGE_404 ) );
91 exit;
92 }
93 }
94
95 /**
96 * 有効化
97 *
98 * @return void
99 */
100 public function activate(): void {
101 $this->save_settings( $this->get_default() );
102 }
103
104 /**
105 * 無効化
106 *
107 * @return void
108 */
109 public function deactivate(): void {
110 $this->config->set( $this->get_feature_key(), 'f' );
111 $this->config->save();
112 }
113
114 }
115