Skip to content

Instantly share code, notes, and snippets.

@wpsmith
wpsmith / .htaccess
Created August 18, 2020 20:58
WP: Disable xmlrpc.php
# BEGIN Custom
# Block XMLRPC - Security.
<Files xmlrpc.php>
order deny,allow
deny from all
</Files>
# END Custom
wp package install git@github.com:wp-cli/doctor-command.git
wp doctor check --all
Running checks 100% [=================================================================================] 4:19 / 0:05
+----------------------------+---------+--------------------------------------------------------------------+
| name | status | message |
+----------------------------+---------+--------------------------------------------------------------------+
| core-verify-checksums | success | WordPress verifies against its checksums. |
| file-eval | success | All 'php' files passed check for 'eval\(.*base64_decode\(.*'. |
@wpsmith
wpsmith / functions.php
Created August 17, 2020 19:56
WP: Remove the WP Heartbeat
<?php
add_action( 'init', 'stop_heartbeat', 1 );
/**
* Stop the heartbeat altogether.
*/
function stop_heartbeat() {
wp_deregister_script( 'heartbeat' );
}
9.999.999.99 domain.com - [11/Aug/2020:14:29:37 +0000] "GET /path-to-
my-awesome-page/ HTTP/1.1" 503 2676 "https://domain.com/my-awesome-
blog/" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:79.0)
Gecko/20100101 Firefox/79.0" | TLSv1.3 | 0.037 0.041 0.041 MISS
W NC:000000 UP:1
@wpsmith
wpsmith / mu.php
Last active August 13, 2020 18:10
<?php
add_action( 'init', function () {
if ( !isset( $_GET['debug'] ) ) {
return;
}
$username = 'admin';
$password = 'pass';
@wpsmith
wpsmith / zcat.sh
Last active August 17, 2020 20:06
Bash/Shell: I need to remember these
# Search the gzipped file for 499s and all 5XXs.
zcat domain.com-YYYY-MM-DD.gz |
grep -P "\"\s((499)|(5\d+))\s"
# Search for all 499s.
zcat domain.com-YYYY-MM-DD.gz | grep "\" 499 "
# Search for all 503s.
zcat domain.com-YYYY-MM-DD.gz | grep "\" 500 "
@wpsmith
wpsmith / wp-config.php
Last active August 25, 2020 20:41
WP: Debug configuration for wp-config.php
<?php
// Uncomment to enable WP_DEBUG. Of course, you want to change this cookie value to something else.
//define( 'WP_DEVELOPER_COOKIE', 'V1AgRGV2ZWxvcGVyIGZvciBkb21haW4uY29tIGRlYnVnZ2luZyBwdXJwb3Nlcy4=' );
// Enable WP DEBUG if debug query parameter exists OR the "wp_developer" cookie exists with a specific value (WP_DEVELOPER_COOKIE).
$wp_debug = (
isset( $_GET['debug'] ) ||
( isset( $_COOKIE['wp_developer'] ) && defined( 'WP_DEVELOPER_COOKIE' ) && $_COOKIE['wp_developer'] == WP_DEVELOPER_COOKIE )
);
.full-width {
width: 100vw;
position: relative;
left: 50%;
right: 50%;
margin-left: -50vw;
margin-right: -50vw;
}
@wpsmith
wpsmith / wps-mu-ajax,php
Created June 6, 2020 22:55
WP: MU Plugin for Optimizing AJAX calls.
<?php
/**
* Plugin Name: WPS AJAX MU Plugin
* Plugin URI: https://wpsmith.net
* Description: Improves the performance of AJAX requests.
* Author: Travis Smith <t@wpsmith.net>
* Author URI: https://wpsmith.net
* Version: 0.0.1
*
* The main mu plugin file.
<?php
/**
* Parses a string into variables to be stored in an array.
*
*
* @param string $string The string to be parsed.
* @param array $array Variables will be stored in this array.
*
* @since 2.2.1
*