Skip to content

Instantly share code, notes, and snippets.

View shanejones's full-sized avatar

Shane Jones shanejones

View GitHub Profile
@shanejones
shanejones / .htaccess
Created May 5, 2017 13:32
301 all HTTP to HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
function throttle(f, delay){
var timer = null;
return function(){
var context = this, args = arguments;
clearTimeout(timer);
timer = window.setTimeout(function(){
f.apply(context, args);
},
delay || 500);
};
<?php
/**
* Bootstrap Alert Dialog
*
* @link http://v4-alpha.getbootstrap.com/components/alerts/
*
* @param $a array containing the options for this function. Expected array keys are below
* html - string - this is the HTML that will be outputted
* type - string - type of alert info(default), success, warning, danger
* close_button - bool- true or false to display
<?php echo $adults ?> live in a <?php echo ($bedrooms==1?$bedrooms . ' bedroom': $bedrooms . ' bedrooms') ?> <?php echo $home_type ?> in <?php echo $town ?>.
<?php if($children!=0): ?>
They live with <?php echo $children ?> children in the home.
Their
<?php if($child_1_gender != 'N/a' && $child_1_gender != 'None'): ?>
<?php echo $child_1_gender ?> was born in <?php echo $child_1_dob ?>
<?php endif; ?>
<?php if($child_2_gender != 'N/a' && $child_2_gender != 'None'): ?>
@shanejones
shanejones / und2_form_resubmit_fields.php
Last active December 21, 2018 13:43
If you're submitting a form using GForms and populating ACF you'll need ot run this script on save to push the fields into ACF correctly
/**
* Save Form Items to ACF Properly
*
*
*/
function und2_form_resubmit_fields($entry, $form){
$args = array(
'post_type' =>'CUSTOM_POST_TYPE',
'posts_per_page' => 1
);
/**
* Function to check weather or not an image sizes exists in the thumbnail library for a specific attachment id
*
* @param $attachment_id - the id of any image in the se
* @param $image_size_name - the name from add_image_size()
*
* @return bool
*/
function check_image_size( $attachment_id, $image_size_name ){
@shanejones
shanejones / lazy-link.js
Created March 22, 2019 08:54
For lazy loading favicons
@shanejones
shanejones / und2-social-sharing.php
Last active June 26, 2019 14:13
Replaces any bloated social plugins with a simpler version. Replace images with SVG or anything else.
<?php
/**
* Replaces the old social sharing shortcode with a lightweight, no dependecy version
*
* @return void
*/
function under2_social_buttons(){
$id = get_the_ID();