Skip to content

Instantly share code, notes, and snippets.

View JoelEadeDesign's full-sized avatar

Joel Eade JoelEadeDesign

View GitHub Profile
@jancbeck
jancbeck / wp-role-bodyclass.php
Last active January 15, 2022 19:34
WordPress: Add user role class to body tag
<?php
// Add role class to body
function add_role_to_body($classes) {
foreach (wp_get_current_user()->roles as $user_role) {
$classes[] = 'role-'. $user_role;
}
return $classes;
});
add_filter('body_class','add_role_to_body');
@karlhorky
karlhorky / grayscale-disable.css
Created August 26, 2012 12:17
Cross-Browser CSS Grayscale
img.grayscale.disabled {
filter: url("data:image/svg+xml;utf8,&lt;svg xmlns=\'http://www.w3.org/2000/svg\'&gt;&lt;filter id=\'grayscale\'&gt;&lt;feColorMatrix type=\'matrix\' values=\'1 0 0 0 0, 0 1 0 0 0, 0 0 1 0 0, 0 0 0 1 0\'/&gt;&lt;/filter&gt;&lt;/svg&gt;#grayscale");
-webkit-filter: grayscale(0%);
}
@kloon
kloon / gist:4331540
Created December 18, 2012 20:14
WooCommerce Change Bacs sort code text
add_filter( 'woocommerce_bacs_fields', 'woocommerce_bacs_custom_sort_code_text', 10, 1 );
function woocommerce_bacs_custom_sort_code_text( $fields ) {
$fields['sort_code'] = 'BSB';
return $fields;
}
@HoundstoothSTL
HoundstoothSTL / anchor-scroll-with-offset.js
Created May 3, 2013 15:43
Anchor scroll with fixed header offset
(function($) {
$('a[href*=#]:not([href=#])').click(function()
{
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
|| location.hostname == this.hostname)
{
var target = $(this.hash),
headerHeight = $(".primary-header").height() + 5; // Get fixed header height
@Laszaro
Laszaro / typography-scales.css
Created October 11, 2013 14:03
CSS - Typography Scales
/*
Source: http://typecast.com/blog/contrast-through-scale
The 16th century scale:
6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 21, 24, 26, 48, 60, 72
*/
body { font-size:100%; }
h1 { font-size: 2.25em; /* 16 x 2.25 = 36 */ }
h2 { font-size: 1.5em; /* 16 x 1.5 = 24 */ }
@webaware
webaware / gravity-forms-fields-above.php
Created May 12, 2014 03:39
Move Gravity Forms field labels from below to above fields in compound fields (e.g. Address, Name)
<?php
/*
Plugin Name: Gravity Forms Fields Above
Plugin URI: https://gist.github.com/webaware/24e1bacb47b76a6aee7f
Description: move field labels from below to above fields in compound fields (e.g. Address, Name)
Version: 1
Author: WebAware
Author URI: http://webaware.com.au/
@link http://www.gravityhelp.com/forums/topic/change-position-of-sub-labels-on-advanced-fields
@mattradford
mattradford / acf_get_directions.php
Last active July 24, 2024 18:08
ACF Get Directions map link
<?php
$location = get_field('map_location');
if ( !empty( $location ) ) :
$map_url = 'https://www.google.com/maps/dir/?api=1&destination=' . $location['lat'] . ',' . $location['lng'];
echo '<a href=". esc_url( $map_url ) . '" rel="nooopener">Get directions</a>';
endif;
?>
<p>This should produce a link like this:</p>
<a href="https://www.google.com/maps/dir/?api=1&destination=51.072159,1.088130">Get directions</a>
@cod3cow
cod3cow / svg.js
Created June 3, 2015 13:59
Replace all SVG images with inline SVG using jQuery
/*
* Replace all SVG images with inline SVG
*/
jQuery('img.svg').each(function(){
var $img = jQuery(this);
var imgID = $img.attr('id');
var imgClass = $img.attr('class');
var imgURL = $img.attr('src');
jQuery.get(imgURL, function(data) {
@generatepress
generatepress / gist:c23aef2d05807c39bb32
Last active January 14, 2019 22:35
Initiate the mobile menu at your desired width
@media (max-width: 768px) {
.main-navigation .menu-toggle,
.main-navigation .mobile-bar-items,
.sidebar-nav-mobile:not(#sticky-placeholder) {
display: block;
}
.main-navigation ul,
.gen-sidebar-nav {
display: none;
@generatepress
generatepress / gist:d8211a277d13fa095849
Created October 5, 2015 07:24
Make the mobile menu slide up and down
<script>
jQuery( document ).ready( function( $ ) {
$( '.menu-toggle' ).addClass( 'closed' );
$( document ).on( 'click', '.menu-toggle.closed', function() {
var sub = $( this ).next( '.main-nav' ).children( 'ul' );
sub.hide();
sub.slideDown();
$( this ).removeClass( 'closed' );
$( this ).addClass( 'opened' );
});