From 96cf1ab03fe56963f28f6bd2371aad763ccaa6ab Mon Sep 17 00:00:00 2001 From: Titouan Mathis Date: Tue, 1 Aug 2023 10:55:05 +0200 Subject: [PATCH] Disable XML RPC endpoint by default --- src/Managers/CleanupManager.php | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/Managers/CleanupManager.php b/src/Managers/CleanupManager.php index a674f20..85dc5ce 100644 --- a/src/Managers/CleanupManager.php +++ b/src/Managers/CleanupManager.php @@ -18,9 +18,20 @@ * 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. + */ + protected bool $xml_rpc; + + /** + * Constructor. + */ + public function __construct(bool $xml_rpc = false) { + $this->xml_rpc = $xml_rpc; + } + + /** + * {@inheritdoc} */ public function run() { // Clean up . @@ -47,6 +58,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' ) ); } /** @@ -152,4 +165,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; + } }