Skip to content

Instantly share code, notes, and snippets.

View kodie's full-sized avatar
💻
#doworkson

Kodie Grantham kodie

💻
#doworkson
View GitHub Profile
@kodie
kodie / hmodal.js
Created September 12, 2023 18:23
A modal function created by a former HM developer - Simply here so we can pull it in remotely until it can be replaced
// BUG
// Sometimes a newly opened modal sets the image height to zero
// Stupid ios menu bar showing/hiding counts as a screen resize
// Can't calculate height with padding before resize to adjust top positioning
// - After resize, calculate the difference between the height of the content
// and the height of the image-holder and set the top of the content to
// scrollTop + the difference in top height
// -------------------------------------------------------------------------------
@kodie
kodie / jquery-wrap-text-plugin.js
Created July 28, 2023 15:27
A wrap text jQuery plugin - Originally created by the good people over at PSD2HTML.com - Simply here so we can pull the code in remotely
/*
* jQuery wrap text plugin
*/
;(function($) {
function WrapText(options) {
this.options = $.extend({
holder: '.wrap-text',
wrapBefore: '<span>',
wrapAfter: '</span>',
wrapTag: 'span',
@kodie
kodie / jquery-sticky-box-plugin.js
Created July 28, 2023 15:22
A sticky box jQuery plugin - Originally created by the good people over at PSD2HTML.com - Simply here so we can pull the code in remotely
/*
* jQuery sticky box plugin
*/
;(function($, $win) {
'use strict';
function StickyScrollBlock($stickyBox, options) {
this.options = options;
this.$stickyBox = $stickyBox;
this.init();
@kodie
kodie / jquery-open-close-plugin.js
Created July 28, 2023 15:18
A accordion jQuery plugin - Originally created by the good people over at PSD2HTML.com - Simply here so we can pull the code in remotely
/*
* jQuery Open/Close plugin
*/
;(function($) {
function OpenClose(options) {
this.options = $.extend({
addClassBeforeAnimation: true,
hideOnClickOutside: false,
activeClass: 'active',
opener: '.opener',
@kodie
kodie / responsive-layout-helper.js
Created July 28, 2023 15:15
A responsive layout helper jQuery plugin - Originally created by the good people over at PSD2HTML.com - Simply here so we can pull the code in remotely
/*
* Responsive Layout helper
*/
ResponsiveHelper = (function($){
// init variables
var handlers = [],
prevWinWidth,
win = $(window),
nativeMatchMedia = false;
@kodie
kodie / Tribe__Events__Filterbar__Filters__Category_Custom.php
Created November 4, 2022 20:21 — forked from elimn/Tribe__Events__Filterbar__Filters__Category_Custom.php
MT | TEC | Customized version of the Category Filter that includes CSS classes for subcategories
<?php
/**
* Customized version of the Category Filter that includes CSS classes for subcategories
* New filter available in WP-Admin > Events > Settings > Filters
*/
if ( class_exists( 'Tribe__Events__Filterbar__Filters__Category' ) ) {
class Tribe__Events__Filterbar__Filters__Category_Custom extends Tribe__Events__Filterbar__Filters__Category {
@kodie
kodie / wp_numeric_pagination.php
Created October 31, 2022 23:41
Displays numeric pagination links in WordPress
<?php
// Displays numeric pagination links
function numeric_pagination($query = null, $echo = true) {
if (!$query) {
global $wp_query;
$query = $wp_query;
}
$total_pages = $query->max_num_pages;
$big = 999999999; // need an unlikely integer
@kodie
kodie / have_flexible_layout.php
Last active October 19, 2022 22:23
A function for WordPress that returns true or false depending on if a post's $field_name ACF field contains the $layout_name(s) flexible layout
<?php
// Returns true or false depending on if a post's $field_name ACF field contains the $layout_name(s) flexible layout
function have_flexible_layout($field_name, $layout_name, $post_id = false) {
if (function_exists('have_rows') && have_rows($field_name, $post_id)) {
while (have_rows($field_name, $post_id)) {
the_row();
if (in_array(get_row_layout(), (array) $layout_name)) {
reset_rows();
return true;
@kodie
kodie / git-lowercase-file.sh
Created June 2, 2022 17:58
A bash function to lowercase file and directory names in a git repository
function git-lowercase-file {
tmp="tmp-$RANDOM-$1"
new=$(echo "$1" | tr '[:upper:]' '[:lower:]')
git mv -f $1 $tmp
git mv -f $tmp $new
}
@kodie
kodie / updateModified.js
Last active April 15, 2024 07:02
A JavaScript function for Google Sheets that updates a specific cell with the current date/time when cell(s) are updated.
function getColumnNumberByName(name, sheet) {
if (!sheet) {
sheet = SpreadsheetApp.getActiveSheet()
}
var headers = sheet.getDataRange().offset(0, 0, 1).getValues()[0]
var column = false
for (var i = 0; i < headers.length; i++) {
if (headers[i].trim() === name) {