Disable XML-RPC-API - Version 1.0.6

Version Description

  • Fix warnings for htaccess permission
Download this release

Release Info

Developer aminnz
Plugin Icon 128x128 Disable XML-RPC-API
Version 1.0.6
Comparing to
See all releases

Code changes from version 1.0.5 to 1.0.6

Files changed (1) hide show
  1. disable-xml-rpc-api.php +8 -9
disable-xml-rpc-api.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Disable XML-RPC-API
4
  Plugin URI: https://neatma.com/
5
  Description: Simple plugin to disable XML-RPC API and X-Pingback in WordPress 3.5+ for faster and more secure website.
6
- Version: 1.0.5
7
  Tested up to: 5.6
8
  Requires at least: 3.5
9
  Author: Amin Nazemi
@@ -12,6 +12,7 @@ License: GPLv2
12
  */
13
 
14
  define('dsxmlrpc_plugin_url', plugin_dir_path(__FILE__));
 
15
  require_once(dsxmlrpc_plugin_url . '/lib/admin-notices/persist-admin-notices-dismissal.php');
16
  require_once(dsxmlrpc_plugin_url . 'admin/admin.php');
17
 
@@ -20,7 +21,7 @@ add_action( 'admin_init', array( 'PAnD', 'init' ) );
20
 
21
  add_filter('xmlrpc_enabled', '__return_false');
22
 
23
- //
24
  // Disable X-Pingback to header
25
 
26
  add_filter( 'wp_headers', 'dsxmlrpc_x_pingback' );
@@ -43,19 +44,17 @@ $in = preg_replace('#<link rel="pingback"(.*?)>#', '', $in);
43
  // Fix htaccess permissions
44
 
45
  function dsxmlrpc_file_chmod() {
46
- $home_path = dsxmlrpc_home_path;
47
- $htaccess_file = $home_path . '.htaccess';
48
  chmod($htaccess_file, 0755);
49
  }
50
 
51
- //
52
  // Disable access to xmlrpc.php entirely with .htaccess file
53
 
54
  function dsxmlrpc_add_htaccess() {
55
 
56
- $home_path = function_exists('get_home_path') ? get_home_path() : ABSPATH;
57
  $filename = dsxmlrpc_plugin_url . '/admin/dsxmlrpc-htaccess';
58
- $htaccess_file = $home_path . '.htaccess';
59
  insert_with_markers($htaccess_file, 'DS-XML-RPC-API', extract_from_markers($filename, 'DS-XML-RPC-API')) ? : dsxmlrpc_file_chmod();
60
  }
61
  add_action('admin_init', 'dsxmlrpc_add_htaccess', 1, 2 );
@@ -63,9 +62,9 @@ insert_with_markers($htaccess_file, 'DS-XML-RPC-API', extract_from_markers($file
63
 
64
 
65
  function dsxmlrpc_remove_htaccess() {
66
- $home_path = function_exists('get_home_path') ? get_home_path() : ABSPATH;
67
  $filename = dsxmlrpc_plugin_url . '/admin/dsxmlrpc-htaccess';
68
- $htaccess_file = $home_path . '.htaccess';
69
  insert_with_markers($htaccess_file, 'DS-XML-RPC-API', '') ? : dsxmlrpc_file_chmod();
70
 
71
  }
3
  Plugin Name: Disable XML-RPC-API
4
  Plugin URI: https://neatma.com/
5
  Description: Simple plugin to disable XML-RPC API and X-Pingback in WordPress 3.5+ for faster and more secure website.
6
+ Version: 1.0.6
7
  Tested up to: 5.6
8
  Requires at least: 3.5
9
  Author: Amin Nazemi
12
  */
13
 
14
  define('dsxmlrpc_plugin_url', plugin_dir_path(__FILE__));
15
+ define('dsxmlrpc_home_path', function_exists('get_home_path') ? get_home_path() : ABSPATH);
16
  require_once(dsxmlrpc_plugin_url . '/lib/admin-notices/persist-admin-notices-dismissal.php');
17
  require_once(dsxmlrpc_plugin_url . 'admin/admin.php');
18
 
21
 
22
  add_filter('xmlrpc_enabled', '__return_false');
23
 
24
+
25
  // Disable X-Pingback to header
26
 
27
  add_filter( 'wp_headers', 'dsxmlrpc_x_pingback' );
44
  // Fix htaccess permissions
45
 
46
  function dsxmlrpc_file_chmod() {
47
+ $htaccess_file = dsxmlrpc_home_path . '.htaccess';
 
48
  chmod($htaccess_file, 0755);
49
  }
50
 
51
+
52
  // Disable access to xmlrpc.php entirely with .htaccess file
53
 
54
  function dsxmlrpc_add_htaccess() {
55
 
 
56
  $filename = dsxmlrpc_plugin_url . '/admin/dsxmlrpc-htaccess';
57
+ $htaccess_file = dsxmlrpc_home_path . '.htaccess';
58
  insert_with_markers($htaccess_file, 'DS-XML-RPC-API', extract_from_markers($filename, 'DS-XML-RPC-API')) ? : dsxmlrpc_file_chmod();
59
  }
60
  add_action('admin_init', 'dsxmlrpc_add_htaccess', 1, 2 );
62
 
63
 
64
  function dsxmlrpc_remove_htaccess() {
65
+
66
  $filename = dsxmlrpc_plugin_url . '/admin/dsxmlrpc-htaccess';
67
+ $htaccess_file = dsxmlrpc_home_path . '.htaccess';
68
  insert_with_markers($htaccess_file, 'DS-XML-RPC-API', '') ? : dsxmlrpc_file_chmod();
69
 
70
  }