Instantly share code, notes, and snippets.

View fix_multisite_tables.php
<?php
if( ! isset( $_GET['wds-replace-urls'] ) ) {
return;
}
add_action( 'init', function() {
global $wpdb;
$p = $wpdb->prefix;
View anti-emoticons.php
/* Clean up head section and improve performance by removing Emojicons */
function disable_wp_emojicons() {
// all actions related to emojis
remove_action( 'admin_print_styles', 'print_emoji_styles' );
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
View .htaccess
# Enable browser caching.
<IfModule expires_module>
ExpiresActive On
# Default directive
ExpiresDefault "access plus 1 week"
# favicon
ExpiresByType image/x-icon "access plus 1 week"
# Images
View gist:587133417eeff93867b5c974df0bbb06
0) Freeze content updates
1) Copy database to new db server (the server must support remote connections)
2) Update database connection details in current wp-config.php to point to the new db server
3) Site should be running fine still
4) Copy the docroot to the new web server
5) Repoint the DNS
6) Drink Scotch
View gist:0b284d263cb4c341f1065ae3f03bab0f
/*
* Disable emojis.
*
* There have been security issues, plus it simply provides better
* performance not to load unecessary core crap all the time.
*/
function grd_remove_emoji() {
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
View gist:3a5fd40a73fe6bea943e73e5d5f4c349
function wds_rename_media_button( $translation, $text ) {
if( is_admin() && 'Add Media' === $text ) {
return 'Add Files and all other things';
}
return $translation;
}
add_filter( 'gettext', wds_rename_media_button, 10, 2 );
View speedtestssh.sh
speedtestssh() {
# Verify we have a host to check agains
[[ -z "$1" ]] && {
echo "You must provide an ssh host" ;
return;
}
RED='\033[0;31m'
NC='\033[0m' # No Color
echo -e "\n${RED}Press CTRL-C to exit test${NC}\n";
View mysql_backup.sh
#!/bin/bash
# Database credentials
user="USERNAME"
password="PASSWORD"
host="HOST"
db_name="DATABASE"
# General config
backup_path="/WHERE/TO/PUT/BACKUP/FILE"
View sep_logs_by_date.sh
#!/bin/bash
# Location of log file is passed in as the first parameter
# Get a list of all the dates in the file
DATES="$(grep "2016" $1 | cut -d ' ' -f 1 | sort | uniq)"
for i in ${DATES}; do
# $i contains the string of the date we are looking at
# Remove the leading [ to prevent grep regex errors
View mysql_who.pl
#!/usr/bin/perl
use DBI;
use 5.010;
use Getopt::Long;
# Set defaults
my $host = 'localhost';
my $db = 'information_schema';
my $user = '';