View wp-config.php
<?php
/**
* Add this block in wp-config.php file.
*
* Move any other `WP_HOME` or `WP_SITEURL` in else condition if present.
*/
if ( isset( $_SERVER['HTTP_X_ORIGINAL_HOST'] ) ) {
$is_ssl = isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] );
$actual_link = ( $is_ssl ? "https" : "http" ) . "://{$_SERVER[ 'HTTP_X_ORIGINAL_HOST' ]}";
define( 'WP_HOME', $actual_link );
View index.php
<?php
/**
* Send pushbullet msg on website hit.
* Author: Utkarsh Patel (github.com/patelutkarsh)
*
* Usage: push.example.com?msg=webpush&title=Awesome&secret=SecretForAuthReplaceME
*/
// If unauthorized user kick him.
if ( ! isset( $_GET['secret'] ) || 'SecretForAuthReplaceME' !== $_GET['secret'] ) {
View backup-sites.sh
#!/bin/bash
# Generate your Dropbox token: https://www.dropbox.com/developers/apps
DROPBOX_TOKEN={dropbox access token here}
# Directory that holds your WordPress sites' root folders
PREFIX=/var/www
# If you have multiple folders with WordPress sites, add/remove them from this array
directories=( "foo.com" "bar.com" )
View execute-wp-cron.sh
#!/bin/bash
WP_PATH="/path/to/wp"
# Check for WP-CLI
if ! hash wp 2>/dev/null; then
echo "WP-CLI is not available"
exit
fi
View keybase.md

Keybase proof

I hereby claim:

  • I am patelutkarsh on github.
  • I am utkarshpatel (https://keybase.io/utkarshpatel) on keybase.
  • I have a public key ASBj2OJgHP6USNvVqXiGww94HtJgp8r0cPz2lnnl5PBn_Qo

To claim this, I am signing this object:

View ee-vip-go-local.sh
#!bin/bash
#
# NOTE:This file takes param as site name for
#
# This script currenty only works with easyengine.
#
# What this does essentially is clones mu-plugin repo of vip-mu-plugins-public
# and write nginx rule to handle static files via php.
#
# WARNING: This does not match extact vip go environment like php version and stuff
View phpcs.md

Installation

Install PEAR

sudo apt-get install php-pear

Install PHP_CodeSniffer

View search_columns.sql
SELECT DISTINCT TABLE_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME LIKE '%awesome%'
AND TABLE_SCHEMA='YourDatabase';
View fast_post_meta.php
<?php
/**
* $arr all meta in associative array.
* $post_id where to insert post.
**/
function add_post_meta_all( $arr, $post_id ) {
global $wpdb;
$inserts = array();
foreach ( $arr as $key => $val ) {
if ( is_array( $val ) ) {
View migration-makeitfast.php
<?php
/**
* call this function before executing your wp-cli(maybe in constructor of wp-cli command file) or php script.
*/
function makeitfast() {
//no cache
wp_suspend_cache_addition( true );
// suspend cache invalidation
wp_suspend_cache_invalidation( true );
//don't save queries