Skip to content

Instantly share code, notes, and snippets.

<h1>Canvas experiment based on tweet</h1>
<p>A simple experiment to generate graphs on the fly</p>
<p>inspired by <a href="https://twitter.com/stephdau/status/238336513170083840">https://twitter.com/stephdau/status/238336513170083840</a>
<form>
<label for="chart_values">Simply enter your values, separated by a + sign</label>
<input id="chart_values" name="chart_values" type="text">
</form>
<div id="debug"></div>
<canvas id="chart1" width="300" height="150"></canvas>
@isotrope
isotrope / wp_nav_cancel_links.js
Last active August 29, 2015 14:01
How to prevent clicks on WP nav menu items with a class of .disabled-click
(function ($) {
/**
* Copyright 2012, Digital Fusion
* Licensed under the MIT license.
* http://teamdf.com/jquery-plugins/license/
*
* @author Sam Sehnert
* @desc A small plugin that checks whether elements are within
* the user visible viewport of a web browser.
@isotrope
isotrope / transient_query.php
Created May 22, 2014 12:14
WordPress: Get the X latest posts with the added benefit of using transients to save it from actually running when not necessary.
<?php
/**
*
* Get a potentially cached version of a WP_Query
*
* @param int $how_many Optional. How many posts to return.
* @return WP_Query
*/
function get_transient_query($how_many = 10) {
@isotrope
isotrope / iso_gf_min_sum_validation.php
Last active April 28, 2021 20:44
Sum total of all fields with a class of XXXX and throw a validation error if the sum is == 0
<?php
//Don't forget to change the _1 in the hook to the ID of your form
add_filter('gform_validation_1', 'iso_min_sum_validate');
// Most code taken from http://www.gravityhelp.com/documentation/page/Using_the_Gravity_Forms_%22gform_validation%22_Hook
function iso_min_sum_validate($validation_result) {
// We'll base our loop on CSS class
@isotrope
isotrope / grab-fontawesome-classes-and-unicode.js
Last active August 29, 2015 14:04
Grabs all the .fa and tries to extract the Unicode character for the :before pseudo-class
// Grabs all the .fa and tries to extract the Unicode character for the :before pseudo-class
// Based on http://fontawesome.io/icons/
// Inspired by c.bavota https://github.com/cbavota
// window.getComputedStyle trickery thanks to http://stackoverflow.com/a/21709814/636709
// Unicode conversion via http://stackoverflow.com/a/21014576/636709
var strAll = '$font_awesome_icons = array(' + "\n";
@isotrope
isotrope / chross-menu-helper.js
Created September 11, 2014 14:07
Quickly thrown together menu management helper for Christopher Ross
/**
* Add a Delete button to menu items without needing to open them up.
*
* Untested.
*
* Use at your own risk!
*/
(function ($) {
@isotrope
isotrope / mike-dickson-export.php
Created September 23, 2014 14:39
Exporting a CPT with its Custom Taxonomies
<?php
/**
* Created by PhpStorm.
* User: Michal
* Date: 2014-09-23
* Time: 10:28 AM
*/
require( '../../../../../wp-load.php' );
@isotrope
isotrope / mike-dickson-import.php
Last active August 29, 2015 14:06
Importing a CPT with its Custom Taxonomies
<?php
/**
* User: Michal
* Date: 2014-09-23
* Time: 10:34 AM
*/
require( '../../../../wp-load.php' );
@isotrope
isotrope / add-attachments-from-url.php
Created September 23, 2014 14:55
Add files to library, pull in from outside
<?php
function iso_add_file( $post_id, $url ) {
$temp_file = download_url( $url, 500 );
if ( ! is_wp_error( $temp_file ) ) {
$file_type = wp_check_filetype( $temp_file );