Skip to content

Instantly share code, notes, and snippets.

View sc0ttkclark's full-sized avatar
🍕
Working hard reviewing and deploying code

Scott Kingsley Clark sc0ttkclark

🍕
Working hard reviewing and deploying code
View GitHub Profile
@knu
knu / gist:111055
Created May 13, 2009 14:38
How to mass-rename tags and push them with Git
# Rename tags named foo-bar-#.#.# to v#.#.# and push the tag changes
git tag -l | while read t; do n="v${t##*-}"; git tag $n $t; git push --tags ; git tag -d $t; git push origin :refs/tags/$t ; done
@raybrownco
raybrownco / wp-pods-vs-ee.php
Created March 13, 2011 16:57
This file is a comparison between WordPress/Pods and ExpressionEngine. It shows the syntax required to display a list of three featured books on a site's homepage.
<!-- Featuring three books on a site's homepage -->
<!-- The Pods/WordPress way -->
<ul id="featured-books">
<?php
$book = new Pod('book');
$params = array(
'where'=>'t.show_on_homepage = 1',
@Thinkscape
Thinkscape / gist:1136563
Created August 10, 2011 11:05
Very simple performance comparison - arrays vs objects (PHP 5.3.6)
# php -v
PHP 5.3.6 (cli) (built: Mar 17 2011 20:58:15)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
# echo '<?php $s = array(); for($x=0;$x<1000;$x++){ $s[] = array("name"=>"Adam","age"=>35); }; echo memory_get_peak_usage(); ' | php
655040
# echo '<?php $s = array(); for($x=0;$x<1000;$x++){ $o = new ArrayObject; $o->name = "Adam"; $o->age = 35; $s[] = $o;} echo memory_get_peak_usage(); ' | php
887984
@mnem
mnem / git_fetch_pull_all_subfolders.sh
Created December 6, 2011 14:35
Simple bash script for fetching and pulling all repos in the executed folder to the latest of the branch they are on
#!/bin/bash
################
# Uncomment if you want the script to always use the scripts
# directory as the folder to look through
#REPOSITORIES="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
REPOSITORIES=`pwd`
IFS=$'\n'
@kloon
kloon / gist:2376300
Last active March 5, 2020 08:28
WooCommerce Automatically add product to cart on site visit
/*
* goes in theme functions.php or a custom plugin
**/
// add item to cart on visit
add_action( 'template_redirect', 'add_product_to_cart' );
function add_product_to_cart() {
if ( ! is_admin() ) {
$product_id = 64;
$found = false;
//check if product already in cart
@Viper007Bond
Viper007Bond / generate-thumbnails.php
Created May 25, 2012 02:33
WordPress: When a thumbnail image is requested of a specific width/height (rather than by name), generate it if it doesn't exist.
<?php /*
**************************************************************************
Plugin Name: Generate Thumbnails On The Fly
Description: When a thumbnail image is requested of a specific width/height (rather than by name), generate it if it doesn't exist.
Version: 1.0.0
Author: Alex Mills (Viper007Bond)
Author URI: http://www.viper007bond.com/
@nb
nb / bootstrap-sample.php
Created August 5, 2012 19:27
Sample plugin tests config files
<?php
define( 'WP_TESTS_PATH', '<Enter the path to your unit-tests checkout>' );
$GLOBALS['wp_tests_options'] = array(
'active_plugins' => array( '<plugindir/<plugin>.php' ),
);
require rtrim( WP_TESTS_PATH, DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR . 'bootstrap.php';
@wesbos
wesbos / gist:3744393
Created September 18, 2012 17:15
Use latest version of jquery in wordpress
/* pop me into your functions.php */
wp_deregister_script('jquery');
wp_register_script('jquery', ("http://code.jquery.com/jquery-git.js"), false, '1.8.2');
wp_enqueue_script('jquery');
@markjaquith
markjaquith / plugin-deploy.sh
Created November 16, 2012 05:04 — forked from scribu/plugin-deploy.sh
Plugin deploy script
#!/bin/bash
# args
MSG=${1-'deploy from git'}
BRANCH=${2-'trunk'}
# paths
SRC_DIR=$(git rev-parse --show-toplevel)
DIR_NAME=$(basename $SRC_DIR)
DEST_DIR=~/svn/wp-plugins/$DIR_NAME/$BRANCH
@benfavre
benfavre / pods2.x_gravityforms_helper.php
Last active December 10, 2015 05:58 — forked from anonymous/gravityforms.php
Pods 2.0 Gravity Forms input helper. Use a text or code field.
<?php
wp_enqueue_style( 'pods-select2' );
wp_enqueue_script( 'pods-select2' );
$attributes = array();
$attributes[ 'tabindex' ] = 2;
$pick_limit = (int) pods_var( 'pick_limit', $options, 0 );
$name .= '[]';
$attributes[ 'multiple' ] = 'multiple';
if ( !is_array( $options[ 'data' ] ) && false !== $options[ 'data' ] && 0 < strlen( $options[ 'data' ] ) )