Skip to content

Instantly share code, notes, and snippets.

View iansvo's full-sized avatar

Ian Svoboda iansvo

View GitHub Profile
@iansvo
iansvo / foundation-offcanvas-menu-clickable-parent.scss
Created June 4, 2019 20:52
Uses with the Accordion menu in JointsWP's default offcanvas menu. Allows parent links to be clickable as long as they could potentially be clickable.
.your-menu {
&_menu {
.menu-item-has-children {
display: flex;
flex-wrap: wrap;
> span {
flex-grow: 1;
}
@iansvo
iansvo / get-youtube-id-by-url.js
Created April 9, 2019 20:21
Get the ID of a YouTube video using it's URL. Returns false if no ID can be found.
function getYouTubeIdByUrl(url) {
var regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/,
match = url.match(regExp),
result = false;
if( match && match[2].length == 11 ) {
result = match[2];
}
return result;
// Inspired by @desandro's debounce.js https://gist.github.com/desandro/8559356
// Inspired by @ChrisFerdinandi's article: https://gomakethings.com/debouncing-events-with-requestanimationframe-for-better-performance/
function debounce( fn ) {
var timeout;
return function debounced() {
var _this = this,
args = arguments;
// If there's a timer, cancel it
@iansvo
iansvo / standard-iife.js
Created October 3, 2018 17:58
Boilerplate of an IIFE (Immediately Invoked Function Expression) to provide scope and allow for $ use in jQuery noConflict mode
(function($) {
$(document).ready(function() {
// Call doc ready functions here
});
// Add additional listeners as needed
// Define functions below
@iansvo
iansvo / sibling-helpers.js
Created September 7, 2018 21:34
Various JS Sibling Helper Functions
function getSiblings($element) {
var siblings = [],
$sibling = $element.parentNode.firstElementChild;
while( $sibling ) {
// Make sure the sibling isn't the $element being referenced
if( $sibling !== $element ) {
// Add sibling to array
siblings.push($sibling);
}
@iansvo
iansvo / shortcode-defintions-metabox-content.php
Last active September 7, 2018 21:32
This WordPress PHP snippet creates a metabox for all pages/posts that contains definitions for user entered shortcodes.
<?php
// Enqueue Thickbox Assets
add_thickbox();
// Define shortcodes
// Setup array
$shortcodes = array();
// Add a shortcode to the shortcodes array
@iansvo
iansvo / hubspot-macros.css
Created July 31, 2018 21:31
HubSpot CSS Macros
{% macro transition(value) -%}
-webkit-transition: {{ value }};
-o-transition: {{ value }};
transition: {{ value }};
{%- endmacro %}
{% macro transform(value) -%}
-webkit-transform: {{ value }};
-ms-transform: {{ value }};
transform: {{ value }};
@iansvo
iansvo / disable-emoji.php
Created May 7, 2018 15:18
Fully Disable WP Emojis
<?php
function disable_wp_emoji() {
// all actions related to emojis
remove_action( 'admin_print_styles', 'print_emoji_styles' );
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
remove_filter( 'wp_mail', 'wp_staticize_emoji_for_email' );
@iansvo
iansvo / add-content-to-menu-item.php
Last active April 26, 2018 20:05
Filter menu items and replace their default output with custom WYSIWYG content
<?php
function add_content_to_sub_menu($item_output, $item, $depth, $args) {
// Checks theme location (remove to apply to any menu)
if( $args->theme_location == 'primary' ) {
// Get Content from ACF Field
$content = get_field('content', $item);
// If there is content, replace the link's regular output
if( $content ) {
$item_output = $content;
@iansvo
iansvo / content-page.php
Created April 17, 2017 17:54
Add a sub-headline to WordPress Twenty-Seventeen Theme
<?php
/**
* Template part for displaying page content in page.php
*
* @link https://codex.wordpress.org/Template_Hierarchy
*
* @package WordPress
* @subpackage Twenty_Seventeen
* @since 1.0
* @version 1.0