Skip to content

Instantly share code, notes, and snippets.

View verticalgrain's full-sized avatar

Jamie Graham verticalgrain

View GitHub Profile
@verticalgrain
verticalgrain / editor-functions.php
Created March 27, 2015 19:15
Wordpress editor template functions - customize the Wordpress WYSIWYG TinyMCE editor
<?php
// Remove default buttons from the first row of editor buttons in the Wordpress WYSIWYG editor
add_filter( 'mce_buttons', 'remove_unnecessary_editor_buttons_mce');
function remove_unnecessary_editor_buttons_mce( $buttons ) {
$invalid_buttons = array(
// 'bold',
// 'italic',
'strikethrough',
@verticalgrain
verticalgrain / dashboard-widget.php
Created March 31, 2015 17:27
Wordpress dashboard widget template function
<?php
/**
* Add a widget to the dashboard.
*
* This function is hooked into the 'wp_dashboard_setup' action below.
*/
function example_add_dashboard_widgets() {
wp_add_dashboard_widget(
@verticalgrain
verticalgrain / wp-geocode-postalcode-gravityforms.php
Last active September 4, 2017 17:55
Wordpress filter - Geocode postal code custom field to latitude and longitude custom fields - Gravity forms, regular custom fields
<?php
/**
* Geocodes a postal code field from a gravity form, saves latitude and longitude to custom fields
* To use this, change $entry[26] to the id of your gravity form field that contains the postal code - i.e. $entry[2]
* To use this, change the name of the geo_latitude and geo_longitude custom fields to what you've created.
* For bonus points, name your lat and long custom fields geo_latitude and geo_longitude, to be in line with Wordpress standard Geodata: https://codex.wordpress.org/Geodata
*
*
*/
@verticalgrain
verticalgrain / gf-email-validate.php
Created May 28, 2015 18:19
Email validation in Gravity Forms - validate an email address entered in a regular text input
<?
/**
* Hooks for validating an email address in Gravity Forms
* When using a plain text input to collect an email, this will validate that the email address entered is a proper email address
* Useful for situations in which the existing gravity forms email field can't be used
*
* Change line 28 and line 37 to adapt this to your form
*
* @package d7
@verticalgrain
verticalgrain / _grid.scss
Last active August 29, 2015 14:24
Susy grids default configuration - inside gutters
$column-count: 12;
$susy: (
columns: $column-count,
global-box-sizing: border-box,
gutter-position: inside,
// debug: ( // Optional debug option to show grid on front-end
// image: show-columns,
// output: overlay,
// toggle: bottom left
@verticalgrain
verticalgrain / .gitignore
Created August 16, 2015 19:23
.gitignore boilerplate
*.DS_Store
*.swp
*._*
*.gz
*.mysql
*.sql
*.bz2
*.zip
*.tar
.sass-cache/
@verticalgrain
verticalgrain / scrollBasedInteraction.js
Created December 17, 2015 03:27
Throttle scroll based interaction trigger
function throttle(callback, limit) {
var wait = false;
return function () {
if (!wait) {
callback.call();
wait = true;
setTimeout(function () {
wait = false;
}, limit);
}
@verticalgrain
verticalgrain / skrollr-init.js
Created December 29, 2015 19:06
Skrollr initialization script with check for touch devices and old IE
app.skrollrinit = (function($){
'use strict';
if ($('html').hasClass('no-touch') && !$('html').hasClass('ie8')) {
var s = skrollr.init({
forceHeight:false,
smoothScrolling:false,
edgeStrategy:'ease',
constants: {
viewportheight: function() {
@verticalgrain
verticalgrain / nav-data-attr.php
Created March 4, 2016 17:10
WP Nav menu item title as data attribute
<?php
add_filter( 'nav_menu_link_attributes', 'nav_data_attr', 10, 3 );
function nav_data_attr( $atts, $item, $args )
{
$atts['data-title'] = $item->title;
return $atts;
}
@verticalgrain
verticalgrain / closing-braces-comment.sublime-snippet
Created March 29, 2016 18:50
Sublime Snippet for commenting closing braces in CSS or SCSS
<snippet>
<content>$1 {
$2
} // $1 $0</content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>d</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>