Skip to content

Commit

Permalink
Disable XML RPC endpoint by default
Browse files Browse the repository at this point in the history
  • Loading branch information
titouanmathis committed Oct 19, 2023
1 parent 7f2342f commit f5e5fcd
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/Managers/CleanupManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,24 @@
* Cleanup a WordPress project for security and performance.
*/
class CleanupManager implements ManagerInterface {
// phpcs:ignore Generic.Commenting.DocComment.MissingShort
/**
* @inheritdoc
* Wether to enable XML RPC endpoint or not.
*
* @var bool
*/
protected $xml_rpc;

/**
* Constructor.
*
* @param bool $xml_rpc Enable or disable XML RPC.
*/
public function __construct( bool $xml_rpc = false ) {
$this->xml_rpc = $xml_rpc;
}

/**
* {@inheritdoc}
*/
public function run() {
// Clean up <head>.
Expand All @@ -47,6 +62,8 @@ public function run() {

// Remove comments from the admin menu.
add_action( 'admin_menu', array( $this, 'remove_comments_from_admin_menu' ) );

add_action( 'xmlrpc_enabled', array( $this, 'xmlrpc_enabled' ) );
}

/**
Expand Down Expand Up @@ -152,4 +169,11 @@ public function remove_comments_from_admin_menu():void {
// Remove comments admin menu item.
remove_menu_page( 'edit-comments.php' );
}

/**
* Enable or disable XML RPC endpoint.
*/
public function xmlrpc_enabled(): bool {
return $this->xml_rpc;
}
}

0 comments on commit f5e5fcd

Please sign in to comment.