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 Aug 1, 2023
1 parent 7f2342f commit 96cf1ab
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/Managers/CleanupManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <head>.
Expand All @@ -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' ) );

Check warning on line 62 in src/Managers/CleanupManager.php

View check run for this annotation

Codecov / codecov/patch

src/Managers/CleanupManager.php#L62

Added line #L62 was not covered by tests
}

/**
Expand Down Expand Up @@ -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;

Check warning on line 173 in src/Managers/CleanupManager.php

View check run for this annotation

Codecov / codecov/patch

src/Managers/CleanupManager.php#L172-L173

Added lines #L172 - L173 were not covered by tests
}
}

0 comments on commit 96cf1ab

Please sign in to comment.