Skip to content

Instantly share code, notes, and snippets.

@richardW8k
richardW8k / RW_Delete_Entry.php
Last active Nov 10, 2016
When placed in the theme functions.php file this will add a checkbox to the 'Form Options' part of the Form Settings page which when checked will cause entries to be automatically deleted at the end of the submission process.
View RW_Delete_Entry.php
<?php
class RW_Delete_Entry {
function __construct() {
if( ! property_exists( 'GFCommon', 'version' ) || ! version_compare( GFCommon::$version, '1.8.5.8', '>=' ) )
return;
add_filter( 'gform_tooltips', array( $this, 'add_delete_tooltip') );
add_filter( 'gform_form_settings', array( $this, 'add_delete_setting' ), 10, 2 );
add_action( 'gform_pre_form_settings_save', array( $this, 'save_delete_setting' ), 10 );
add_action( 'gform_after_submission', array( $this, 'maybe_delete_form_entry' ), 15, 2 );
@benmay
benmay / wp-cli.sh
Created Jul 9, 2013
Bash script used on dev server to create new WordPress sites.
View wp-cli.sh
#!/bin/sh
# Set DB Constants
DBHOST="localhost"
DBUSER="root"
DBPASS="123"
DBNAME="wp_$1"
# Set WP Constants
ADMIN_NAME="my_admin_account"
@westonruter
westonruter / gist:5475349
Last active Feb 6, 2017 — forked from markjaquith/gist:2653957
WordPress Fragment Caching convenience wrapper
View gist:5475349
<?php
/*
Usage:
cache_fragment_output( 'unique-key', 3600, function () {
functions_that_do_stuff_live();
these_should_echo();
});
*/
function cache_fragment_output( $key, $ttl, $function ) {
anonymous
anonymous / gist:2523336
Created Apr 29, 2012
Changing author info
View gist:2523336
#!/bin/sh
git filter-branch --env-filter '
an="$GIT_AUTHOR_NAME"
am="$GIT_AUTHOR_EMAIL"
cn="$GIT_COMMITTER_NAME"
cm="$GIT_COMMITTER_EMAIL"
if [ "$GIT_COMMITTER_EMAIL" = "your@email.to.match" ]
@lu1s
lu1s / get-random-flickr-user-pic-jquery.js
Created Mar 17, 2012
Get random flickr picture from given user id and append to given div id (needs jquery and flickr api key)
View get-random-flickr-user-pic-jquery.js
function getPicture(the_user_id, your_div_id){
var apiKey = "YOUR-API-KEY"; // replace this with your API key
var url_to_a_photo_head = "http://api.flickr.com/services/rest/?method=flickr.photos.getSizes&api_key="+apiKey+"&photo_id=";
var url_to_a_photo_tail = "&format=json&jsoncallback=?";
// get an array of random photos
$.getJSON(
"http://api.flickr.com/services/rest/",
@Rarst
Rarst / r-debug.php
Last active Feb 9, 2021
R Debug (set of dump helpers for debug)
View r-debug.php
<?php
/*
Plugin Name: R Debug
Description: Set of dump helpers for debug.
Author: Andrey "Rarst" Savchenko
Author URI: https://www.rarst.net/
License: MIT
*/
@ocean90
ocean90 / gist:1544377
Created Dec 31, 2011
Compiling Compass.app on Mac OS X
View gist:1544377
Tutorial for compiling the Compass.app (http://compass.handlino.com/)
=====================================================================
Java installed?
java -version
Load jRuby (for example JRuby 1.6.5.1 Binary .zip)
http://jruby.org/download
Unzip jRuby to `/usr/local/`
View wordpress_post_expirator.php
<?php
/*
This function assumes a custom field named 'expiration' with a human friendly date/time.
*/
function is_post_expired($post_ID = null){
if(!$post_ID) global $post;
@wesbos
wesbos / is_blog.php
Created Sep 2, 2011
WordPress is_blog()
View is_blog.php
function is_blog () {
global $post;
$posttype = get_post_type($post );
return ( ((is_archive()) || (is_author()) || (is_category()) || (is_home()) || (is_single()) || (is_tag())) && ( $posttype == 'post') ) ? true : false ;
}
Usage:
<?php if (is_blog()) { echo 'You are on a blog page'; } ?>
@markjaquith
markjaquith / disable-plugins-when-doing-local-dev.php
Created Jun 24, 2011
Disables specified WordPress plugins when doing local development
View disable-plugins-when-doing-local-dev.php
<?php
/*
Plugin Name: Disable plugins when doing local dev
Description: If the WP_LOCAL_DEV constant is true, disables plugins that you specify
Version: 0.1
License: GPL version 2 or any later version
Author: Mark Jaquith
Author URI: http://coveredwebservices.com/
*/