Skip to content

Instantly share code, notes, and snippets.

@mattjstrauss
mattjstrauss / gist:11294579
Last active July 24, 2017 17:24
JS: Animated ScrollTo
$('a[href*=\\#]:not([href=\\#])').on("click", function(e) {
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);
return false;
}
@mattjstrauss
mattjstrauss / gist:10679172
Created April 14, 2014 20:10
CSS: Visibly Hidden
.visibly-hidden {
position: absolute !important;
clip: rect(1px 1px 1px 1px);
/* IE6, IE7 */
clip: rect(1px, 1px, 1px, 1px);
padding: 0 !important;
border: 0 !important;
height: 1px !important;
width: 1px !important;
overflow: hidden;
@mattjstrauss
mattjstrauss / gist:9420358
Created March 7, 2014 21:20
FB: Cached Facebook Feed
<?php
// Create a Facebook application to obtain a ID and Secret
$appID = 'APPLICATION ID';
$appSecret = 'APPLICATION SECRET';
// Insert Profile ID below using http://findmyfacebookid.com/
$feed = 11111111111;
$maximum = 10;
$caching = 60;
@mattjstrauss
mattjstrauss / gist:9419502
Created March 7, 2014 20:35
JS: jQuery CDN
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
@mattjstrauss
mattjstrauss / gist:9107876
Created February 20, 2014 06:06
SUBL: User Settings
{
"color_scheme": "Packages/Color Scheme - Default/Tomorrow-Night-Eighties.tmTheme",
"font_size": 14.0,
"ignored_packages":
[
"Vintage"
],
"word_wrap": true
}
@mattjstrauss
mattjstrauss / gist:9099572
Created February 19, 2014 19:23
JS: Tabs
$('#tabs-nav a').bind('click', function(e){
$('#tabs-nav a.current').removeClass('current');
$('.tab-content:visible').removeClass('active-tab');
$(this.hash).addClass('active-tab');
$(this).addClass('current');
e.preventDefault();
}).filter(':first').click();
@mattjstrauss
mattjstrauss / gist:8963921
Last active August 29, 2015 13:56
ACF: Simple if Field
<?php if( get_field('field_name') ): ?>
<?php the_field('field_name'); ?>
<?php endif; ?>
@mattjstrauss
mattjstrauss / gist:8957441
Created February 12, 2014 15:21
WP: Post Slug Function
function the_slug($echo=true){
$slug = basename(get_permalink());
do_action('before_slug', $slug);
$slug = apply_filters('slug_filter', $slug);
if( $echo ) echo $slug;
do_action('after_slug', $slug);
return $slug;
}
<?php the_slug();?>
@mattjstrauss
mattjstrauss / gist:8918615
Last active August 29, 2015 13:56
WP: Simple Loop with Args
<div class="row">
<?php
$query_name = new WP_Query(array(
'post_type'=>'page',
'posts_per_page'=>'4',
'post_parent'=>'184',
'orderby' => 'menu_order',
'order' => 'ASC'
));
while ( $query_name->have_posts() ) : $query_name->the_post();
@mattjstrauss
mattjstrauss / gist:8786976
Created February 3, 2014 16:20
ACF: if Radio Value
<?php if( get_field('radio_field' ) === "yes") { ?>
<div>
<!-- Stuff -->
</div>
<?php } ?>