Skip to content

Instantly share code, notes, and snippets.

@Ollo
Ollo / .htaccess
Created September 8, 2012 00:56 — forked from boogah/.htaccess
Expire headers .htaccess code.
<IfModule mod_expires.c>
ExpiresActive on
# Perhaps better to whitelist expires rules? Perhaps.
ExpiresDefault "access plus 1 month"
# Data
ExpiresByType text/xml "access plus 0 seconds"
ExpiresByType application/xml "access plus 0 seconds"
ExpiresByType application/json "access plus 0 seconds"
setttings
@Ollo
Ollo / local-livereload.js
Created January 3, 2014 20:00
hacky localhost check for livereload injection
// check if running locally for livereload
var url = window.location.protocol + "//" + window.location.host + window.location.pathname;
// grab the reload script from grunt
if ( url == "http://portal.dev" ) {
var lr = document.createElement("script");
lr.type = "text/javascript";
lr.src="//localhost:35729/livereload.js";
@Ollo
Ollo / custom-taxonomy-dropdown
Created September 25, 2013 17:51
Create a dropdown list without a button to navigate custom taxonomies for custom post types
<?php
// place in functions or a plugin
function cpt_taxonomy_dropdown($taxonomy) { ?>
<form action="/" method="get">
<select name="cat" id="cat" class="postform">
<option value="-1">Choose one...</option>
<?php
$terms = get_terms($taxonomy);
foreach ($terms as $term) {
@Ollo
Ollo / force-file-download
Last active December 23, 2015 18:39
Push a file download after registration. - hides url of file to prevent unauthorized sharing - uses custom field in ACF to store download file - uses gravity forms for form management
add_action("gform_after_submission_1", "push_pdf", 10, 2);
function push_pdf($entry, $form) {
$host = $_SERVER['HTTP_HOST'];
preg_match("/[^\.\/]+\.[^\.\/]+$/", $host, $matches);
global $post;
$postID = $post->ID;
// base button styles
%btn {
padding: em(14) em(40);
color: $white;
display: inline-block;
@include border-radius(7px);
&:hover {
color: $white;
}
@mixin base_font {
font-family: Helvetica, Arial, Sans-serif;
font-size: 16px;
line-height: 24px;
}
// Avoid `console` errors in browsers that lack a console.
if (!(window.console && console.log)) {
(function() {
var noop = function() {};
var methods = ['assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error', 'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log', 'markTimeline', 'profile', 'profileEnd', 'markTimeline', 'table', 'time', 'timeEnd', 'timeStamp', 'trace', 'warn'];
var length = methods.length;
var console = window.console = {};
while (length--) {
console[methods[length]] = noop;
}
@Ollo
Ollo / latest_dl.php
Last active December 15, 2015 17:09
get latest download that isn't a release candidate
// echo latest download version for buttons
function get_latest_dl_ver() {
$args = array(
'post_type' => 'downloads',
'posts_per_page' => '1',
//'order' => 'DESC',
'orderby' => 'meta_value',
'meta_query' => array(
array(
'key' => 'rc',
@Ollo
Ollo / keyboard-nav
Created January 23, 2013 22:45
cycle 2 keyboard navigation
//gallery keyboard evetns
$(document.documentElement).keyup(function (event) {
if (event.keyCode == 37) {
$('.slider').cycle('prev');
} else if (event.keyCode == 39) {
$('.slider').cycle('next')
}
});