Skip to content

Instantly share code, notes, and snippets.

View danimalweb's full-sized avatar

Daniel Hewes danimalweb

  • Creative Dot
  • Vancouver, Canada
View GitHub Profile
@davidhariri
davidhariri / all-the-links.md
Last active September 15, 2015 09:20
All of my links to blogs, resources, tutorials and people I find inspiring
@cfoellmann
cfoellmann / DocBlocks-for-WP.php
Created February 26, 2014 19:52
DocBlocks collection for WP development
<?php
/**
* DocBlocks for WordPress
*
* Structural Elements:
* -- to be documented with DocBlocks --
*
* class
* function (including methods)
* variable
@Lewiscowles1986
Lewiscowles1986 / lc-svg-upload.php
Last active August 4, 2016 13:45
SVG Media Plugin for WordPress (Works since 4.1.2!)
<?php
// Please see https://github.com/Lewiscowles1986/WordPressSVGPlugin from now on
@yellow5
yellow5 / refresh_vagrant_jessie64.bash
Created November 3, 2016 14:17
Script to reload a locally managed vagrant base box with a VMware Fusion provider.
#!/bin/bash
# Save the current directory.
pushd ./
# Change to the directory that contains the VM.
cd ~/Documents/Virtual\ Machines.localized/Debian\ Jessie\ 64\ -\ Base.vmwarevm/
# Defragment and shrink the virtual disk.
/Applications/VMware\ Fusion.app/Contents/Library/vmware-vdiskmanager -d Virtual\ Disk.vmdk
<?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
@amitramani
amitramani / functions.php
Created August 22, 2016 01:05
How to send WooCommerce Checkout Error Messages to Google Analytics as Events
function load_ga_error_script() {
// Load the JS file (jquery is a dependency)
wp_enqueue_script( 'ga-send-error-event', get_stylesheet_directory_uri() . '/js/ga-send-error-event.js', array('jquery' ) );
}
add_action( 'wp_enqueue_scripts', 'load_ga_error_script' );
@kierzniak
kierzniak / functions.php
Last active May 25, 2018 15:15
Require basic authentication for all pages except home page
<?php
/**
* Require basic authentication for all pages except home page
*
* @return void
*/
function motivast_require_auth() {
define('AUTH_USER', 'admin');
@Uwingame
Uwingame / gist:8c4c25a2a883f6f5213e72d29864ade8
Created December 14, 2016 06:40 — forked from karlwestin/gist:3163157
throttling a window.scroll handler for better performance
// underscore's throttle-metod
var throttle = function(func, wait) {
var context, args, timeout, throttling, more, result;
var whenDone = _.debounce(function(){ more = throttling = false; }, wait);
return function() {
context = this; args = arguments;
var later = function() {
timeout = null;
if (more) func.apply(context, args);
@zeshanshani
zeshanshani / php-rewrite-rule-fix-for-same-slug.php
Last active March 6, 2019 17:52
Fix pagination of page with same slug as of CPT's rewrite slug. This function will fix the same slug conflict of CPT and a static page with pagination.
<?php // Don't copy this line...
/**
* This function will Kill 'blogs/editor' rewrite rules
* to fix the broken pagination issue on this page:
* '/blogs/editor/'
*
* This fix was needed because we add rewrite rules for CPT: editor
* And because '/blogs/editor/' is also a static page, the pagination
* on that page e.g., '/blogs/editor/page/4/' was broken.
@saas786
saas786 / sanitize_checkbox.php
Last active April 7, 2019 10:47
Sanitization of customizer controls
/*
* Sanitize Checkbox
*/
// Source: https://github.com/FlagshipWP/flagship-library/blob/develop/customizer/classes/customizer-base.php
/**
* Sanitize a checkbox to only allow 0 or 1
*
* @since 1.2.0
* @access public