Skip to content

Instantly share code, notes, and snippets.

Andy Knapp andyknapp

Block or report user

Report or block andyknapp

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@andyknapp
andyknapp / init.coffee
Last active Dec 17, 2017
atom-sync-settings
View init.coffee
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
View gform-disable-conf-anchor.php
// disable gravity forms confirmation msg anchor functionality
add_filter('gform_confirmation_anchor', create_function('', 'return false;'));
@andyknapp
andyknapp / smoothscroll.js
Created Jun 13, 2014
smooth scroll for links on same page (via css-tricks)
View smoothscroll.js
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
|| location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 1000);
@andyknapp
andyknapp / remove-default-value.js
Created Jun 8, 2014
Remove default value on ::focus in gravity forms
View remove-default-value.js
jQuery(document).ready(function($) {
$('.gform_wrapper input[type=text], .gform_wrapper input[type=email], .gform_wrapper textarea, .gform_wrapper input[type=tel]').each(function() {
$.data(this, 'default', this.value);
}).focus(function() {
if ($.data(this, 'default') == this.value) {
this.value = '';
$(this).addClass('focus-value');
}
}).blur(function() {
if (this.value == '') {
@andyknapp
andyknapp / menu-toggle.js
Created Jun 8, 2014
Custom responsive menu for _s
View menu-toggle.js
jQuery(document).ready(function($) {
/* menu toggle */
$('.menu-toggle').click(function() {
$('#site-navigation, .menu-toggle').toggleClass('toggled');
})
});
@andyknapp
andyknapp / triangles.scss
Created Jun 8, 2014
Sass mixins for triangles
View triangles.scss
@mixin rt-triangle($h, $depth, $color, $top: 0, $left: 100%) {
content: '';
display: inline-block;
position: absolute;
top: $top;
left: $left;
width: 0;
height: 0;
border-top: $h/2 solid transparent;
border-left: $h*$depth solid $color;
@andyknapp
andyknapp / register-img-sizes-wp.php
Last active Aug 29, 2015
Register image sizes - WordPress
View register-img-sizes-wp.php
/* register additional image sizes */
function ak_insert_custom_image_sizes( $image_sizes ) {
// get the custom image sizes
global $_wp_additional_image_sizes;
// if there are none, just return the built-in sizes
if ( empty( $_wp_additional_image_sizes ) )
return $image_sizes;
// add all the custom sizes to the built-in sizes
foreach ( $_wp_additional_image_sizes as $id => $data ) {
@andyknapp
andyknapp / no-p-tags.php
Created Mar 31, 2014
Strip <p> tags from images within the_content in WordPress
View no-p-tags.php
function filter_ptags_on_images($content){
return preg_replace('/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU', '\1\2\3', $content);
}
add_filter('the_content', 'filter_ptags_on_images');
@andyknapp
andyknapp / nav.js
Created Dec 19, 2013
responsive menu adapted from _s to be mobile first. bare bones
View nav.js
( function() {
var container, button, menu;
container = document.getElementById( 'site-navigation' );
if ( ! container )
return;
button = container.getElementsByTagName( 'h1' )[0];
if ( 'undefined' === typeof button )
return;
@andyknapp
andyknapp / remove-submenu.php
Created Nov 14, 2013
remove WP submenu pages from dashboard for gravity forms
View remove-submenu.php
function ak_remove_submenu_pages() {
if( !current_user_can('administrator') ) {
remove_submenu_page( 'gf_edit_forms', 'gf_edit_forms' );
remove_submenu_page( 'gf_edit_forms', 'gf_new_form' );
remove_submenu_page( 'gf_edit_forms', 'gf_new_formf_help' );
// remove_submenu_page( 'gf_edit_forms', 'gf_entries' );
remove_submenu_page( 'gf_edit_forms', 'gf_settings' );
remove_submenu_page( 'gf_edit_forms', 'gf_export' );
remove_submenu_page( 'gf_edit_forms', 'gf_update' );
remove_submenu_page( 'gf_edit_forms', 'gf_addons' );
You can’t perform that action at this time.