Skip to content

Instantly share code, notes, and snippets.

<?php
/*
Plugin Name: Easy Digital Downloads - Variable Pricing License Activation Limits
Plugin URL: http://easydigitaldownloads.com/extension/
Description: Limit the number of license activations permitted based on variable prices
Version: 1.0
Author: Pippin Williamson
Author URI: http://pippinsplugins.com
Contributors: mordauk
*/
@spivurno
spivurno / gform_print_entry_content.php
Created November 2, 2015 14:35
Gravity Forms // Hooks // gform_print_entry_content
<?php
// remove default GF entry content function
remove_action( 'gform_print_entry_content', 'gform_default_entry_content', 10 );
// bind our custom entry content function
add_action( 'gform_print_entry_content', 'my_print_entry_content', 10, 3 );
function my_print_entry_content( $form, $entry, $entry_ids ) {
GFEntryDetail::lead_detail_grid( $form, $entry );
}
@gmazzap
gmazzap / AutoPaginatedQuery.php
Last active April 8, 2016 21:49
`WP_Query` subclass that takes a non-paginated query and split into different paginated queries offering a transparent interface to "standard loop" usage.
<?php
namespace GM;
/**
* `WP_Query` subclass that takes a non-paginated query and split into different
* paginated queries offering a transparent interface to "standard loop" usage.
*
* The class is not 100% transparent:
* - the var `$posts` and the method `get_posts()`, that are not used directly
* in standard loop usage, here don't return array of all posts, but only posts
@mgratch
mgratch / sideload-gf-images.php
Created June 7, 2016 00:24
sideload images from gf multi-upload
<?php
add_filter( 'gform_save_field_value', 'save_field_value', 10, 4 );
function save_field_value( $value, $lead, $field, $form ) {
$output_ids = array();
global $files_to_sideload;
if(!isset($files_to_sideload) || empty($files_to_sideload)){
$files_to_sideload = array();
}
//if not the form with fields to encode, just return the unaltered value without checking the fields
/**
* Get single entry pagination links
* to use: call anagram_entry_pagintion();
*
*/
function anagram_entry_pagintion() {
global $gravityview_view;
$criteria['paging'] = array(
'offset' => 0,
<?php
function create_onetime_nonce( $action = -1 ) {
$time = time();
$nonce = wp_create_nonce( $time . $action );
set_transient( '_nonce_' . $time, 1, 60*60 ); // adjust the lifetime of the transient
return $nonce . '-' . $time;
}
function verify_onetime_nonce( $_nonce, $action = -1 ) {
@list( $nonce, $time ) = explode( '-', $_nonce );
@markjaquith
markjaquith / readme.md
Last active June 11, 2017 15:19
For WordPress, a method to re-index a multi-dimensional array by the (unique) value of a given array key

Okay, so, let's say you have some data like this:

$things = [
  0 => [ 'id' => 123, 'title' => '123 Title', 'content' => '123 Content' ],
  1 => [ 'id' => 456, 'title' => '456 Title', 'content' => '456 Content' ],
  2 => [ 'id' => 789, 'title' => '789 Title', 'content' => '789 Content' ],
];
@Rarst
Rarst / headings.less
Created July 14, 2017 16:08
Less mixin to calculate vertical rhythm styling for headings [in Bootstrap]. Don’t ask me how this works because I don’t remember and this made my brain hurt enough.
.heading-line-height( @line-height ) when ( @line-height < 1 ) {
line-height: unit(@line-height * 2, em);
}
.heading-line-height( @line-height ) when ( @line-height >= 1 ) {
line-height: unit(@line-height, em);
}
.heading-rhythm ( @font-size-base, @font-size-increase ) {
@heading-font-size: @font-size-base * @font-size-increase;
@zackkatz
zackkatz / fix-checkboxes.php
Created May 17, 2016 04:39
Use UTF-8 checkmark instead of Dashicon .dashicons-yes icon font
<?php
add_filter( 'gravityview_field_tick', 'convert_gravityview_field_tick' );
/**
* Convert <span> to ✓
* @param string $existing_tick HTML span with `dashicons dashicons-yes` class
* @return string HTML entity checkmark character (✓)
*/
function convert_gravityview_field_tick( $existing_tick ) {
@neilernst
neilernst / query_cite.rb
Created September 4, 2010 19:34
Find citation keys using Mendeley
#!/usr/bin/ruby
require 'sqlite3'
cite_part = ARGV[0]
db_name = "/Users/nernst/Library/Application\ Support/Mendeley\ Desktop/neil\@neilernst.net\@www.mendeley.com.sqlite"
db = SQLite3::Database.new( db_name )
db.results_as_hash = true
query = "select citationkey, title, year from Documents where citationkey like '%#{cite_part}%'"#MATCH '#{cite_part}'"#{}like '%#{cite_part}%'"
db.execute( query ) do |row|
print row['citationKey'] + '|'