add_filter('rest_authentication_errors', function($result) {
if (!empty($result)) {
return $result;
}
if (!is_user_logged_in()) {
return new WP_Error('rest_not_logged_in', 'API is not available for anonymous users.', array('status' => 401));
}
return $result;
});
if (!is_admin()) {
// block WP enum scans
if (preg_match('/(wp-comments-post)/', $_SERVER['REQUEST_URI']) === 0 && !empty($_REQUEST['author'])) {
wp_redirect(home_url());
exit;
}
}
add_filter( 'xmlrpc_methods', function( $methods ) {
unset( $methods['pingback.ping'] );
return $methods;
});
define('DISALLOW_FILE_EDIT', true);
add_filter('xmlrpc_enabled', '__return_false');
remove_action('wp_head', 'wp_generator');