-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxmlrpc.php
More file actions
56 lines (46 loc) · 1.15 KB
/
xmlrpc.php
File metadata and controls
56 lines (46 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
/**
* Functionality related to XML-RPC endpoints
*
* @package PluginPizza\Uncomment
*/
namespace PluginPizza\Uncomment\XMLRPC;
if ( ! defined( 'ABSPATH' ) ) exit;
// Replace xmlrpc methods.
add_filter( 'xmlrpc_methods', __NAMESPACE__ . '\replace_xmlrpc_methods' );
/**
* Replace XML_RPC methods.
*
* @param array $methods An array of XML-RPC methods.
*
* @return array
*/
function replace_xmlrpc_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 ] = __NAMESPACE__ . '\xmlrpc_placeholder_method';
}
}
return $methods;
}
/**
* XML_RPC placeholder method.
*
* @return \IXR_Error
*/
function xmlrpc_placeholder_method() {
return new \IXR_Error(
403,
// phpcs:ignore WordPress.WP.I18n.TextDomainMismatch -- "Comments are closed" is a core WP string, we're using the 'default' domain to leverage existing translations.
__( 'Comments are closed.', 'default' )
);
}