Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Disable comment related XML_RPC methods #17

Merged
merged 1 commit into from

2 participants

@barryceelen

Replaces comment related XML_RPC methods with a placeholder function.

Unfortunately but understandably the WordPress iOS app does not check if methods exist before showing their respective UI. Rather than just removing the XML_RPC methods altogether the placeholder function returns a more friendly error message.

nicer-error-message

@barryceelen barryceelen Disable comment related XML_RPC methods
Replaces comment related XML_RPC methods with a placeholder function which returns a friendlier error message.
d0f4c8a
@bueltge bueltge merged commit a69633d into bueltge:master
@bueltge
Owner

Thanks a lot for your solution.

@barryceelen barryceelen deleted the unknown repository branch
@barryceelen

Thanks for accepting the patch :thumbsup:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 20, 2013
  1. @barryceelen

    Disable comment related XML_RPC methods

    barryceelen authored
    Replaces comment related XML_RPC methods with a placeholder function which returns a friendlier error message.
This page is out of date. Refresh to see the latest.
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
Something went wrong with that request. Please try again.