Skip to content

Instantly share code, notes, and snippets.

@wearehyphen
wearehyphen / IntString.php
Created August 21, 2019 23:22
Integer → String
<?php
/**
Usage:
require( TEMPLATEPATH . '/includes/Int_String.php' );
$intstr = new IntString;
@wearehyphen
wearehyphen / acf-responsive-image.php
Created August 22, 2017 06:10
Output responsive image tags from ACF Image Field
<?php
/**
* Output Responsive Image Tag based on ACF Image Field
*
* @param $image (array) ACF Image Field
* @param $size (string) Image size name (ie. medium, large, my-custom-image-size )
* @param $lazyload (bool) Enable/Disable lazy loading of responsive images (requires lazysizes.js to be loaded — see https://github.com/aFarkas/lazysizes)
* @param $classes (array) Array of class names to apply to the image
* @author Eivind Borgersen for Hyphen
@wearehyphen
wearehyphen / hyphen-add-countries.php
Last active April 3, 2024 07:42
WordPress: Bulk add countries as taxonomy term, using ISO code as slug
<?
/***
*
* Goes into your themes functions.php
* TODO: Create Plugin
*
***/
function add_country_codes() {
@wearehyphen
wearehyphen / slick.revealPartialSlide.js
Last active August 8, 2019 20:39
Allowing partial reveal of X pixels of the next slide in a Slick-slideshow through the 'setPosition' event.
function revealPartialSlide(padding) { // Padding (amount of the next slide you want to reveal)
var $slides = $('.element').find('.slick-slide') // Find the slides
,slideCount = $slides.length // Grab the amount of slides
,slidesToShow = $('.element').slick('getOption','slidesToShow') // Grab the 'slidesToShow' number
,slideWidth = $slides.outerWidth() // Get the width of the slides (as calculated by Slick)
,newWidth = Math.round(slideWidth - (padding / slidesToShow)) // Calculate the new width
// If less slides than you want to show, do nothing....
if(slideCount < slidesToShow) {
return false;
@wearehyphen
wearehyphen / hyphen_gravity_forms_date_validation.php
Last active September 12, 2018 21:43
Gravity Forms: Validate Arrival & Departure Dates
/***
* Gravity Forms: Validate to ensure date fields are not the same or todays date
*
* This will validate the fields on form submission and return a validation error on the fields in question.
* In this case it validates an Arrival and Departure date against each other and today's date.
*
* Code goes in your theme's functions.php file.
***/
add_filter('gform_field_validation','validate_dates',10,4);