Skip to content
This repository has been archived by the owner on May 16, 2023. It is now read-only.

Disable comment related XML_RPC methods #17

Merged
merged 1 commit into from
Sep 21, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions remove-comments-absolute.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ public function __construct() {

// remove comment options in profile page
add_action( 'personal_options', array( $this, 'remove_profile_items' ) );

// replace xmlrpc methods
add_filter( 'xmlrpc_methods', array( $this, 'xmlrpc_replace_methods' ) );
}

/**
Expand Down Expand Up @@ -483,6 +486,45 @@ public function remove_theme_string( $translation, $text, $domain ) {
return $translation;
}

/**
* Replace comment related XML_RPC methods.
*
* @access public
* @since
* @return array
*/
public function xmlrpc_replace_methods( $methods ) {

$comment_methods = array(
'wp.getCommentCount',
'wp.getComment',
'wp.getComments',
'wp.deleteComment',
'wp.editComment',
'wp.newComment',
'wp.getCommentStatusList'
);

foreach( $comment_methods as $method_name ) {
if ( isset( $methods[$method_name] ) ) {
$methods[$method_name] = array( $this, 'xmlrpc_placeholder_method' );
}
}

return $methods;
}

/**
* XML_RPC placeholder method.
*
* @access public
* @since
* @return object
*/
public function xmlrpc_placeholder_method() {
return new IXR_Error( 403, __( 'Comments are disabled on this site.', 'remove_comments_absolute' ) );
}

} // end class

} // end if class exists