Skip to content

Instantly share code, notes, and snippets.

View topdown's full-sized avatar
🎯
Focusing

Jeff Behnke topdown

🎯
Focusing
View GitHub Profile
@topdown
topdown / Gruntfile.js
Last active April 10, 2016 20:21
Network wide WordPress theme development
// http://mattbanks.me/grunt-wordpress-development-deployments/
// https://github.com/mattbanks/WordPress-Starter-Theme/blob/master/Gruntfile.js
'use strict';
module.exports = function (grunt) {
// load all grunt tasks matching the `grunt-*` pattern
require('load-grunt-tasks')(grunt);
var $proxy = 'vvv_domain.dev';
@topdown
topdown / custom-post_status.php
Last active January 31, 2016 18:06
Custom post status workaround
<?php
/**
* Register Custom Status
*
*/
function custom_archived_post_status() {
$args = array(
@topdown
topdown / gist:8d895976b40b888942ba
Created January 19, 2016 02:59
Brew Update issues untracked working tree
cd $(brew --repository)
sudo chown -R $USER .
git reset --hard origin/master
brew update
@topdown
topdown / provision.sh
Created December 3, 2015 05:08 — forked from FrankM1/provision.sh
Faster provisioning for vvv - Removed provisioning for Wordpress Core development. That took a long time to complete
#!/bin/bash
#
# provision.sh
#
# This file is specified in Vagrantfile and is loaded by Vagrant as the primary
# provisioning script whenever the commands `vagrant up`, `vagrant provision`,
# or `vagrant reload` are used. It provides all of the default packages and
# configurations included with Varying Vagrant Vagrants.
# By storing the date now, we can calculate the duration of provisioning at the
@topdown
topdown / wp-get-results.php
Created May 28, 2015 21:56
WP $wpdb->get_results() Gotcha
// Breaks ORDER BY silently
$sql = $this->wpdb->prepare( "SELECT * FROM $this->table ORDER BY 'id' ASC LIMIT %d OFFSET %d", $limit, $start );
// Works correctly
$sql = $this->wpdb->prepare( "SELECT * FROM $this->table ORDER BY id ASC LIMIT %d OFFSET %d", $limit, $start );
$rows = $this->wpdb->get_results( $sql );
return $rows;
@topdown
topdown / vw_block_open_sans.php
Last active August 29, 2015 14:02
WordPress - Blocks Admin Panel from loading Google Fonts - Open Sans, mainly for work offline. I hate the lag when there is no internet.
<?php
/**
* Blocks Admin Panel from loading Google Fonts - Open Sans, mainly for work offline. I hate the lag when there is no internet.
*
* Created 6/21/14, 12:57 PM
*
* @category WordPress Plugin
* @package Block External Scripts - block_external_scripts.php
* @author Jeff Behnke <code@validwebs.com>
@topdown
topdown / BrightCove Analytics JS API
Created June 11, 2014 17:42
BrightCove Analytics JS API required player params
FIND
<param name="dynamicStreaming" value="true" />
AFTER ADD
<param name="includeAPI" value="true" />
<param name="templateLoadHandler" value="BCL.onTemplateLoaded" />
<param name="templateReadyHandler" value="BCL.onTemplateReady" />
Which should be before
<param name="@videoPlayer" value="some_video_id" / >
<?php
/**
* Abstract class which has helper functions to get data from the database
*/
abstract class Base_Custom_Data
{
/**
* The current table name
*
* @var boolean
@topdown
topdown / Regex_find_words_in_string.php
Last active December 15, 2015 01:19
Regex find words in string This regex is capable of finding specific words in string and ignoring words in HTML attributes so when replacing with HTML it does not break the code.
<?php
// Updated, the other expression misses stuff like nulla.jpg which broke images
// (?<!-)\b(ipsum|nulla|Nulla)\b(?!\/|\"|\.[a-zA-Z0-9])
//----------------------------
// Example string
//----------------------------
?>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc feugiat laoreet augue, non congue lectus mattis nec. Etiam augue risus, consequat et sodales at, scelerisque id orci. Sed posuere egestas tristique. Aenean fermentum volutpat nisi, nulla vitae convallis risus mollis vel. <a title="nulla" href="http://nulla/nulla">Nulla</a> Nulla convallis venenatis tortor, nec congue augue hendrerit quis. Fusce augue metus, venenatis posuere ornare quis, scelerisque sed quam. <img alt="ipsum" src="ipsum.png" title="ipsum">Nunc nec adipiscing justo. Morbi eget ultrices diam. Proin nisl nisl, aliquet quis aliquet non, sollicitudin ultricies lectus. Etiam malesuada mauris quis sem varius hendrerit. Etiam eu tempor magna. Donec quam metus, elementum eget sollicitudin adipiscing, porttitor di