Skip to content

Instantly share code, notes, and snippets.

@ksolomon
ksolomon / xmlrpc-brute-protection.php
Created Oct 9, 2015
Block XMLRPC Brute Force Amplification Attacks on WordPress
View xmlrpc-brute-protection.php
<?php
/*
Plugin Name: XML-RPC Brute Protection
Description: Disable XML-RPC methods used in brute-force amplification attacks
Author: Keith Solomon
Version: 1.0
License: GPL2
*/
function mmx_remove_xmlrpc_methods($methods) {
@ksolomon
ksolomon / wpfuncs.php
Last active Oct 8, 2019
Collection of WordPress helper functions I use constantly.
View wpfuncs.php
<?php
// addFirstLastClass() - Add first and last classes to list items returned from wp_list_pages.
function addFirstLastClass($pageList) {
// pattern to focus on just li's
$allLisPattern = '/<li class="page_item(.*)<\/li>/s';
preg_match($allLisPattern,$pageList,$allLis);
$liClassPattern = "/<li[^>]+class=\"([^\"]+)/i";
// first let's break out each li
$liArray = explode("\n",$allLis[0]);