Skip to content

Instantly share code, notes, and snippets.

View iansvo's full-sized avatar

Ian Svoboda iansvo

View GitHub Profile
@iansvo
iansvo / codekit-trigger-file-process-hook.scpt
Created September 7, 2022 12:14
A simple AppleScript for CodeKit that triggers the processing of a specific file when the hook runs.
tell application "CodeKit"
set projectRoot to get path of active project
process file at path projectRoot & "/src/css/style.css"
end tell
@iansvo
iansvo / wordpress-cache-bust-enqueues.php
Created February 11, 2022 12:46
This is a simple pattern that uses a helper function to pass a dynamic version value to a style/script enqueue. This ensures WordPress updates the asset URL (e.g. the thing the browser downloads from) so it looks like its a new URL, and downloads the most recent version. This is all triggered when the file is modified on disk so its a simple way…
<?php
// This is used as a fallback if the file isn't found for some reason
global $wp_version;
/*
Note:
This function assumes you're only asking for files in your own theme
and that theme isn't a child theme. If you're using a child theme,
replace get_template_directory() with get_stylesheet_directory().
@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' );