Permalink
Browse files

Merge pull request #17 from barryceelen/patch-1

Disable comment related XML_RPC methods
  • Loading branch information...
2 parents 2a4e509 + d0f4c8a commit a69633d4eda6c9b8ee530dd276bc3d6b9b4f1f24 @bueltge committed Sep 21, 2013
Showing with 42 additions and 0 deletions.
  1. +42 −0 remove-comments-absolute.php
View
42 remove-comments-absolute.php
@@ -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' ) );
}
/**
@@ -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

0 comments on commit a69633d

Please sign in to comment.