Skip to content

Instantly share code, notes, and snippets.

View oneblackcrayon's full-sized avatar

Frederick Polk oneblackcrayon

View GitHub Profile
function debug(){
if (typeof console != "undefined"){
if (console.log){
if (arguments.length == 1){
console.log(arguments[0]);
} else {
console.log(arguments);
}
}
}
@oneblackcrayon
oneblackcrayon / jquery.disable.js
Created January 1, 2017 06:24 — forked from somebox/jquery.disable.js
jQuery snippet to make page elements unselectable (disable highlights)
/* disable user selections */
jQuery.fn.disableSelection = function(){
$(this).each(function(){
$(this).attr('unselectable', 'on')
.css('-moz-user-select', 'none')
.each(function() {
this.onselectstart = function() { return false; };
});
});
@oneblackcrayon
oneblackcrayon / README
Created January 1, 2017 06:24 — forked from somebox/README
Update WebKit nightly
To use this:
1. check out the gist somewhere
2. edit the plist to contain the path to the .rb file
3. run this:
chmod +x update-webkit.rb
launchctl load com.indirect.update-webkit.plist
@oneblackcrayon
oneblackcrayon / functions.php
Created December 10, 2016 22:36
WordPress: Add fav icons to <head>
<?php
/**
* Adds fav icons to <head>
*
* @see https://codex.wordpress.org/Plugin_API/Action_Reference/wp_head
* @package ThemeName
* @uses http://realfavicongenerator.net
*/
add_action( 'wp_head', 'child_theme_fav_icon_link' );
function child_theme_fav_icon_link() { ?>
@oneblackcrayon
oneblackcrayon / advice.php
Last active July 5, 2018 22:31 — forked from dotspencer/advice.txt
Adding logo to wordpress theme
Put Code In Function.php
<?php
function themeslug_theme_customizer( $wp_customize ) {
$wp_customize->add_section( 'themeslug_logo_section' , array(
'title' => __( 'Logo', 'themeslug' ),
'priority' => 30,
'description' => 'Upload a logo to replace the default site name and description in the header',
) );
$wp_customize->add_setting( 'themeslug_logo' );
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'themeslug_logo', array(
@oneblackcrayon
oneblackcrayon / all_fields_extra_options.php
Created November 27, 2016 23:40
The Gravity Forms {all_fields} merge tag in notifications includes all fields which had data entered, it doesn't include HTML fields, Section Break descriptions, nor does it allow you to omit fields from the notification. By adding the following code to your themes functions.php file you will gain the ability to include HTML fields, and Section …
/**
* to exclude field from notification add 'exclude[ID]' option to {all_fields} tag
* 'include[ID]' option includes HTML field / Section Break field description / Signature image in notification
* see http://www.gravityhelp.com/documentation/page/Merge_Tags for a list of standard options
* example: {all_fields:exclude[2,3]}
* example: {all_fields:include[6]}
* example: {all_fields:include[6],exclude[2,3]}
*/
add_filter( 'gform_merge_tag_filter', 'all_fields_extra_options', 11, 5 );
function all_fields_extra_options( $value, $merge_tag, $options, $field, $raw_value ) {
@oneblackcrayon
oneblackcrayon / gist:280b893ac80f81906b7ce9fa62e05ab7
Created November 7, 2016 18:34 — forked from rutger1140/gist:5576437
Clean up WordPress wp_nav_menu
<?php
//Deletes all CSS classes and id's, except for those listed in the array below
function custom_wp_nav_menu($var) {
return is_array($var) ? array_intersect($var, array(
//List of allowed menu classes
'current_page_item',
'current_page_parent',
'current_page_ancestor',
'first',
'last',
@oneblackcrayon
oneblackcrayon / anchor-scroll-with-offset.js
Created September 26, 2016 21:51 — forked from HoundstoothSTL/anchor-scroll-with-offset.js
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

Moving from jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
<?php
/**
* A class filled with functions that will never go away upon theme deactivation
*
* @package WordPress
* @subpackage GRD
* @version 0.1.0
*/
class GRD_Functions {