siteguard-admin-filter.php
1 month ago
siteguard-base.php
1 month ago
siteguard-captcha.php
1 month ago
siteguard-config.php
11 months ago
siteguard-disable-author-query.php
2 weeks ago
siteguard-disable-pingback.php
1 month ago
siteguard-disable-xmlrpc.php
1 month ago
siteguard-htaccess.php
2 weeks ago
siteguard-login-alert.php
1 month ago
siteguard-login-history.php
1 month ago
siteguard-login-lock.php
1 month ago
siteguard-rename-login.php
1 week ago
siteguard-updates-notify.php
1 month ago
siteguard-waf-exclude-rule.php
1 month ago
siteguard-disable-xmlrpc.php
63 lines
| 1 | <?php |
| 2 | |
| 3 | class SiteGuard_Disable_XMLRPC extends SiteGuard_Base { |
| 4 | public static $htaccess_mark = '#==== SITEGUARD_DISABLE_XMLRPC_SETTINGS'; |
| 5 | |
| 6 | function __construct() { |
| 7 | global $siteguard_config; |
| 8 | if ( '1' === $siteguard_config->get( 'disable_xmlrpc_enable' ) ) { |
| 9 | $this->add_filters(); |
| 10 | } |
| 11 | } |
| 12 | |
| 13 | static function get_mark() { |
| 14 | return self::$htaccess_mark; |
| 15 | } |
| 16 | |
| 17 | function init() { |
| 18 | global $siteguard_config; |
| 19 | $siteguard_config->set( 'disable_xmlrpc_enable', '0' ); |
| 20 | $siteguard_config->update(); |
| 21 | } |
| 22 | |
| 23 | private function add_filters() { |
| 24 | add_filter( 'xmlrpc_enabled', '__return_false', 99 ); |
| 25 | add_filter( 'wp_headers', array( $this, 'remove_pingback_header' ), 99 ); |
| 26 | add_action( 'plugins_loaded', array( $this, 'early_block_xmlrpc' ), 0 ); |
| 27 | } |
| 28 | |
| 29 | public function remove_pingback_header( $headers ) { |
| 30 | if ( isset( $headers['X-Pingback'] ) ) { |
| 31 | unset( $headers['X-Pingback'] ); |
| 32 | } |
| 33 | return $headers; |
| 34 | } |
| 35 | |
| 36 | public function early_block_xmlrpc() { |
| 37 | global $siteguard_config; |
| 38 | if ( '1' !== $siteguard_config->get( 'disable_xmlrpc_enable' ) ) { |
| 39 | return; |
| 40 | } |
| 41 | if ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST ) { |
| 42 | status_header( 403 ); |
| 43 | nocache_headers(); |
| 44 | exit; |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | function feature_on() { |
| 49 | global $siteguard_config; |
| 50 | $siteguard_config->set( 'disable_xmlrpc_enable', '1' ); |
| 51 | $siteguard_config->update(); |
| 52 | $this->add_filters(); |
| 53 | return true; |
| 54 | } |
| 55 | |
| 56 | static function feature_off() { |
| 57 | global $siteguard_config; |
| 58 | $siteguard_config->set( 'disable_xmlrpc_enable', '0' ); |
| 59 | $siteguard_config->update(); |
| 60 | return true; |
| 61 | } |
| 62 | } |
| 63 |