Skip to content

Instantly share code, notes, and snippets.

View timstl's full-sized avatar

Tim Gieseking timstl

View GitHub Profile
@timstl
timstl / border-image-fallback
Last active August 29, 2015 13:59
Border-Image with Modernizr fallback for < IE11
.decbdr
{
border-bottom: 13px solid #ff6e00;
border-image:url('img/bg/decbdr.jpg') 0 0 100 0 repeat;
}
.no-borderimage .decbdr
{
border-bottom: 13px solid transparent;
position: relative;
@timstl
timstl / maybe_ssl_url
Created August 22, 2014 14:17
maybe_ssl_url (for WordPress)
function maybe_ssl_url($url)
{
if (!is_ssl()) { return $url; }
return str_ireplace('http://', 'https://', $url);
}
@timstl
timstl / debug_display
Last active August 29, 2015 14:06
Debug_Display debugging to screen function
<?php
/*
Based on debugging function found in CMS Made Simple http://www.cmsmadesimple.org/
Meant for use in WordPress (ability to only output to 'manage_options' users)
Pass in 'false' as section param to show to everyone.
*/
if (!function_exists('debug_display'))
{
function debug_display($var, $admins=true, $title="", $echo_to_screen = true, $use_html = true)
{
@timstl
timstl / tfield()
Last active August 29, 2015 14:07
ACF conditional the_field/get_field shortcut function
<?php
if (function_exists('get_field') && !function_exists('tfield'))
{
/*
Example usage:
<?php tfield('header_text', '<div class="entry">', '</div>'); ?>
*/
function tfield($field, $before='', $after='', $echo=true)
{
/* don't output if field doesn't have value. */
@timstl
timstl / gist:c2dc5541094e99c72ee4
Created March 9, 2015 15:20
jquery.vadjust.js
/*
vadjust plugin.
adjust top margin on vertically centered elements.
var $vadj = $('[data-vadjust="true"]');
if ($vadj.length > 0) { $vadj.vadjust(); }
*/
;(function($) {
$.fn.vadjust = function(options)
@timstl
timstl / jquery.simplenav.js
Last active December 16, 2015 16:29
jQuery Simple Navigation
;(function($){$.fn.cpnav=function(options)
{
var opts=$.extend({},$.fn.cpnav.defaults,options),
$navli=this.find('li');
if(opts.hasmenuchar!=''){
$('li:has(ul)',$navli).find("a:first").append(opts.hasmenuchar);
}
$navli.hover(function() {
@timstl
timstl / fancy_adjacent_post_link.php
Last active December 17, 2015 07:09
WordPress Fancy Adjacent Post Links. For use on regular posts or custom post type.
function fancy_adjacent_post_link($prev=false, $iter=1)
{
global $post;
$link = $title = '';
$a_post = get_adjacent_post( false, '', $prev );
if ($a_post && $a_post->ID > 0)
{
@timstl
timstl / is_blog_page()
Last active March 31, 2016 14:56
Determine if currently viewing a WordPress blog page (home, archive, search, single post).
<?php
function is_blog_page($single=true, $four04=true) {
if ((is_home() || is_archive() || is_search()) && !is_post_type_archive()) {
return true;
}
if ($single === true && is_singular('post')) {
return true;
}
@timstl
timstl / jquery.colequalize.js
Last active August 17, 2016 15:45
jQuery plugin to equalize height of a set of elements if you can't do so via CSS for whatever reason.
/*
Column Equalize
Example: $('.col-equalize .col').colequalize();
*/
;(function($) {
$.fn.colequalize = function(options) {
var h = 0;
@timstl
timstl / the_field_srcset.php
Last active August 24, 2016 20:53
Function to convert ACF image field into image tag with srcset.
<?php
/*
Usage: the_field_srcset('field_name');
ACF field should return Image ID.
*/
function the_field_srcset($field, $before='', $after='', $size = 'full', $echo = true) {
if (get_field($field)) {
$img = wp_get_attachment_image(get_field($field), $size);