Disable XML-RPC Pingback - Version 1.2.1

Version Description

  • Minor changes to make code 100% compliant with WordPress Coding Standards.
Download this release

Release Info

Developer samuelaguilera
Plugin Icon 128x128 Disable XML-RPC Pingback
Version 1.2.1
Comparing to
See all releases

Code changes from version 1.2 to 1.2.1

Files changed (2) hide show
  1. disable-xml-rpc-pingback.php +34 -23
  2. readme.txt +6 -2
disable-xml-rpc-pingback.php CHANGED
@@ -1,12 +1,14 @@
1
  <?php
2
- /*
3
- Plugin Name: Disable XML-RPC Pingback
4
- Description: Stops abuse of your site's Pingback method from XML-RPC by simply removing it. While you can use the rest of XML-RPC methods.
5
- Author: Samuel Aguilera
6
- Version: 1.2
7
- Author URI: http://www.samuelaguilera.com
8
- License: GPL2
9
- */
 
 
10
 
11
  /*
12
  This program is free software: you can redistribute it and/or modify
@@ -22,34 +24,43 @@ You should have received a copy of the GNU General Public License
22
  along with this program. If not, see <http://www.gnu.org/licenses/>.
23
  */
24
 
25
- global $wp_version;
26
-
27
  add_filter( 'xmlrpc_methods', 'sar_block_xmlrpc_attacks' );
28
 
 
 
 
 
 
29
  function sar_block_xmlrpc_attacks( $methods ) {
30
- unset( $methods['pingback.ping'] );
31
- unset( $methods['pingback.extensions.getPingbacks'] );
32
- return $methods;
33
  }
34
 
35
-
 
 
36
  if ( version_compare( $wp_version, '4.4' ) >= 0 ) {
37
 
38
- // Remove X-Pingback from Header for WP 4.4+
39
- add_action('wp', 'sar_remove_x_pingback_header_44', 9999);
40
 
 
 
 
41
  function sar_remove_x_pingback_header_44() {
42
- header_remove('X-Pingback');
43
  }
44
-
45
  } else {
46
 
47
- // Remove X-Pingback from Header for older WP versions
48
  add_filter( 'wp_headers', 'sar_remove_x_pingback_header' );
49
 
 
 
 
 
 
50
  function sar_remove_x_pingback_header( $headers ) {
51
- unset( $headers['X-Pingback'] );
52
- return $headers;
53
  }
54
-
55
- }
1
  <?php
2
+ /**
3
+ * Plugin Name: Disable XML-RPC Pingback
4
+ * Description: Stops abuse of your site's Pingback method from XML-RPC by simply removing it. While you can use the rest of XML-RPC methods.
5
+ * Author: Samuel Aguilera
6
+ * Version: 1.2.1
7
+ * Author URI: http://www.samuelaguilera.com
8
+ * License: GPL2
9
+ *
10
+ * @package Disable XML-RPC Pingback
11
+ */
12
 
13
  /*
14
  This program is free software: you can redistribute it and/or modify
24
  along with this program. If not, see <http://www.gnu.org/licenses/>.
25
  */
26
 
 
 
27
  add_filter( 'xmlrpc_methods', 'sar_block_xmlrpc_attacks' );
28
 
29
+ /**
30
+ * Unset XML-RPC Methods.
31
+ *
32
+ * @param array $methods Array of current XML-RPC methods.
33
+ */
34
  function sar_block_xmlrpc_attacks( $methods ) {
35
+ unset( $methods['pingback.ping'] );
36
+ unset( $methods['pingback.extensions.getPingbacks'] );
37
+ return $methods;
38
  }
39
 
40
+ /**
41
+ * Check WP version.
42
+ */
43
  if ( version_compare( $wp_version, '4.4' ) >= 0 ) {
44
 
45
+ add_action( 'wp', 'sar_remove_x_pingback_header_44', 9999 );
 
46
 
47
+ /**
48
+ * Remove X-Pingback from Header for WP 4.4+.
49
+ */
50
  function sar_remove_x_pingback_header_44() {
51
+ header_remove( 'X-Pingback' );
52
  }
 
53
  } else {
54
 
 
55
  add_filter( 'wp_headers', 'sar_remove_x_pingback_header' );
56
 
57
+ /**
58
+ * Remove X-Pingback from Header for older WP versions.
59
+ *
60
+ * @param array $headers Array with current headers.
61
+ */
62
  function sar_remove_x_pingback_header( $headers ) {
63
+ unset( $headers['X-Pingback'] );
64
+ return $headers;
65
  }
66
+ }
 
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  Contributors: samuelaguilera
3
  Tags: xml-rpc, xml, rpc, pingback, ddos, firewall
4
  Requires at least: 4.8
5
- Tested up to: 5.1.1
6
  Requires PHP: 5.6
7
- Stable tag: 1.2
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -35,6 +35,10 @@ Removes the following methods from XML-RPC interface.
35
 
36
  == Changelog ==
37
 
 
 
 
 
38
  = 1.2 =
39
 
40
  * Added support for X-Pingback header removal in recent versions of WP.
2
  Contributors: samuelaguilera
3
  Tags: xml-rpc, xml, rpc, pingback, ddos, firewall
4
  Requires at least: 4.8
5
+ Tested up to: 5.2.2
6
  Requires PHP: 5.6
7
+ Stable tag: 1.2.1
8
  License: GPLv2
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
35
 
36
  == Changelog ==
37
 
38
+ = 1.2.1 =
39
+
40
+ * Minor changes to make code 100% compliant with WordPress Coding Standards.
41
+
42
  = 1.2 =
43
 
44
  * Added support for X-Pingback header removal in recent versions of WP.