Skip to content

Instantly share code, notes, and snippets.

View treetrum's full-sized avatar

Sam Davis treetrum

View GitHub Profile
@treetrum
treetrum / index.js
Last active August 19, 2021 09:33
jQuery Slideup & Slidedown replacement with GSAP - TweenLite
import { TweenLite } from 'gsap';
const DEFAULT_DURATION = 0.3;
export const hideElement = (el, speed = DEFAULT_DURATION) => {
const oldSpacing = { height: el.clientHeight };
const newSpacing = { height: 0 };
const additionalSpacingProperties = ['paddingTop', 'paddingBottom', 'marginTop', 'marginBottom'];
additionalSpacingProperties.forEach(property => {
@treetrum
treetrum / previous-next-post-looped.php
Last active August 25, 2021 10:30
Get Next or Previous Post (Looped). Will continue working once end of posts reached.
<?php
/**
* Gets the next post in the current post type, even if is last post
* Inspired from https://gist.github.com/banago/5603826
*
* @method get_next_post_looped
* @return WordPress Post Object
*/
function get_next_post_looped() {
$post_type = get_post_type();
/**
The following mixin works when @include[ed] onto a div containing three empty spans:
<div class="animated-hamburger">
<span></span>
<span></span>
<span></span>
</div>
To get the animation on click, use the following JQuery:
@banago
banago / get-fisrt-paragraph.php
Created November 6, 2012 09:18
Get first paragraph from a WordPress post.
<?php
/**
* Get first paragraph from a WordPress post. Use inside the Loop.
*
* @return string
*/
function get_first_paragraph(){
global $post;
$str = wpautop( get_the_content() );