Skip to content

Instantly share code, notes, and snippets.

View khromov's full-sized avatar
☀️

Stanislav Khromov khromov

☀️
View GitHub Profile
<?php
/**
* Place next to wp-blog-header.php. Visit this file to find the time suck.
*/
declare(ticks=1);
register_tick_function('ds_do_profile');
$ds_profile = array();
$ds_last_time = microtime(true);
@karpstrucking
karpstrucking / gist:ec8e7de6b6f570f38ab8
Created April 25, 2015 10:21
Copy parent theme's mods to child theme on activation
<?php
add_action( 'after_switch_theme', 'gowp_copy_theme_mods' );
function gowp_copy_theme_mods() {
$mods = get_theme_mods();
if ( is_null( $mods ) || ( ( 1 == count( $mods ) ) && ! $mods[0] ) ) {
$parent = wp_get_theme()->get('Template');
$child = basename( dirname( __FILE__ ) );
update_option( "theme_mods_$child", get_option( "theme_mods_$parent" ) );
}
@Stubbs
Stubbs / main.yml
Created March 28, 2015 14:31
Ansible Playbook to install PHP7
- name: Install Packages Needed To Compile PHP 7
apt: pkg={{ item }} state=latest
with_items:
- git
- autoconf
- bison
- libxml2-dev
- libbz2-dev
- libmcrypt-dev
- libcurl4-openssl-dev
@tomazzaman
tomazzaman / functions.php
Created February 18, 2015 20:35
Clear WP_Object_Cache on WPEngine to get around ACF's updating bug.
<?php
// Register script and add necessary options to it, make sure the path is correct
function flush_redis_enqueue_scripts() {
wp_enqueue_script( 'flush-redis', plugin_dir_url( __FILE__ ) . 'js/script.js', array( 'jquery' ) );
wp_localize_script( 'flush-redis', 'FlushRedis', array(
'ajaxUrl' => admin_url( 'admin-ajax.php' ),
'flushRedisNonce' => wp_create_nonce( 'flush-redis-nonce' ),
)
);
@tomazzaman
tomazzaman / hhvm.conf
Last active September 22, 2016 08:23
Restart HHVM with Monit
# This file should be in /etc/monit/conf.d
check process hhvm with pidfile /var/run/hhvm/pid
group hhvm
# Start program calls our custom script from above
start program = "/usr/local/sbin/start_hhvm.sh"
stop program = "/usr/sbin/service hhvm stop"
if failed unixsocket /var/run/hhvm/hhvm.sock then restart
if mem > 400.0 MB for 1 cycles then restart
if 5 restarts with 5 cycles then timeout
@tomazzaman
tomazzaman / www.wp-kickstart.com.conf
Last active August 29, 2015 14:15
wp-kickstart.com Nginx vhost config
server {
include /home/webmaster/www/www.wp-kickstart.com.conf;
server_name www.wp-kickstart.com;
listen 443 ssl spdy;
server_tokens off;
client_body_buffer_size 10K;
client_header_buffer_size 1k;
@mr-prud
mr-prud / datadog-agent
Last active January 29, 2016 03:30
datadog-agent init script for my raspberry
#! /bin/sh
### BEGIN INIT INFO
# Provides: datadog-agent
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Launch datadog agent
# Description:
### END INIT INFO
@codeablehq
codeablehq / backup.sh
Last active July 3, 2017 07:07
A script that creates a backup of your WordPress site and uploads it to Dropbox
#!/bin/bash
# For this script to work, save it somewhere in the executable path, like /usr/local/sbin/backup.sh
# make it executable: chmod +x /usr/local/sbin/backup.sh
# then add it to cron: crontab -e
# and add the line below, which will run backup 3am each day, then upload to Dropbox
# 0 3 * * * /usr/local/sbin/backup.sh > /dev/null 2>&1
# You also need WP CLI installed: http://wp-cli.org/
@donut
donut / CaptainHook.coffee
Last active August 29, 2015 14:05
A simple hook system in JavaScript.
###*
* @file
* A hook system.
* @see https://gist.github.com/donut/f16040209cdc6f5e62c2
###
'use strict'
hook =
_callbacks: []
@fabrizim
fabrizim / acf-customizer-patch.php
Last active May 31, 2025 20:56
Plugin to allow for Advanced Custom Fields to be used in widgets within the Customizer
<?php
/*
Plugin Name: ACF Customizer Patch
Plugin URI: https://gist.github.com/fabrizim/9c0f36365f20705f7f73
Description: A class to allow acf widget fields to be stored with normal widget settings and allow for use in customizer.
Author: Mark Fabrizio
Version: 1.0
Author URI: http://owlwatch.com/
*/
class acf_customizer_patch