Skip to content

Instantly share code, notes, and snippets.

View mikeselander's full-sized avatar
:shipit:
Shipping

Mike Selander mikeselander

:shipit:
Shipping
View GitHub Profile
@mikeselander
mikeselander / PHPtoICS.php
Created July 5, 2014 03:37 — forked from jakebellacera/ICS.php
Script to create an iCal file from a php event with a UNIX timestamp
<?php
// Variables used in this script:
// $summary - text title of the event
// $datestart - the starting date (in seconds since unix epoch)
// $dateend - the ending date (in seconds since unix epoch)
// $address - the event's address
// $uri - the URL of the event (add http://)
// $description - text description of the event
// $filename - the name of this file for saving (e.g. my-event-name.ics)
//
@mikeselander
mikeselander / clean_phone_numbers.php
Created July 8, 2014 21:20
Clean up phone numbers to return as a linkable object grabbed and adapted from: http://stackoverflow.com/questions/4708248/formatting-phone-numbers-in-php
function _otm_clean_phone_number( $number ){
$phoneNumber = preg_replace('/[^0-9]/','',$number);
if(strlen($phoneNumber) > 10) {
$countryCode = substr($phoneNumber, 0, strlen($phoneNumber)-10);
$areaCode = substr($phoneNumber, -10, 3);
$nextThree = substr($phoneNumber, -7, 3);
$lastFour = substr($phoneNumber, -4, 4);
@mikeselander
mikeselander / gf-convert-to-timestamp.php
Created July 10, 2014 16:44
Gravity Forms doesn't offer a function to export a date field as a UNIX timestamp. This function will find all exported dates in a GF submission & convert it to UNIX, and then update the postmeta to the proper format - as is, it will ONLY work if you're using the Gravity Forms + Custom Post Types plugin to create or edit a post
add_action( 'gform_after_submission', '_convert_date_to_timestamp', 10, 2 ); // Extend
function _convert_date_to_timestamp( $entry, $form ) {
date_default_timezone_set ( "America/Denver" );
// Make sure that we're submitting a post before running the code
if ( $entry['post_id'] ){
foreach ( $entry as $key => $value ){
@mikeselander
mikeselander / new_gist_file_0
Last active August 29, 2015 14:04
Tax Rates Master
FORT COLLINS; FT COLLINS; FT. COLLINS - 3.85
Larimer County - 0.65
80511; 80512; 80513; 80515; 80517; 80517; 80521; 80522; 80523; 80524; 80525; 80526; 80527; 80528; 80532; 80535; 80536; 80537; 80538; 80539; 80541; 80545; 80547; 80549; 80553
CO - 2.9
@mikeselander
mikeselander / content_by_id.php
Created August 8, 2014 17:39
Get content by id
$post = get_post( $id );
$content = apply_filters( 'the_content', $post->post_content );
echo $content;
@mikeselander
mikeselander / breadcrumb.php
Created August 13, 2014 22:36
Nice, clean breadcrumb function
function otm_breadcrumb(){
global $post;
$trail = '';
$page_title = get_the_title($post->ID);
if($post->post_parent) {
$parent_id = $post->post_parent;
@mikeselander
mikeselander / new_gist_file_0
Created September 13, 2014 19:25
Sanitize Text (from Word in the first one) Word stuff from: http://www.paulund.co.uk/sanitize-special-word-characters
function sanitize_from_word( $content )
{
// Convert microsoft special characters
$replace = array(
"‘" => "'",
"’" => "'",
"”" => '"',
"“" => '"',
"–" => "-",
"—" => "-",
@mikeselander
mikeselander / triangle.less
Last active August 29, 2015 14:07
Simple Triangle CSS
&:after{
@size:32;
content:"";
position: absolute;
bottom: -@size*1px;
left: 0;
width: 0;
height: 0;
border-width:(@size / 2)*1px;
border-style:solid;
@mikeselander
mikeselander / progress-bar.css
Created September 29, 2014 17:17
Progress Bar CSS
.progress-bar {
width: 95%;
height: 14px;
padding: 3px;
background-color: #ffffff;
overflow:hidden;
border-radius:16px;
box-shadow: inset 0 1px 2px #000,
0 1px 0 #2b2b2b;
float:right;
@mikeselander
mikeselander / browsers.css
Created September 29, 2014 17:22
Common Browser Specific Selectors
// ================ IE SPECIFIC SELECTORS
background: gray; /* standard */
//background: grey \0/; /* IE8+9 */
//\0/ - i.e. padding: 0px 5px 10px 70px\0/ /* IE 8 only */
background: pink\9; /* IE 9 and below */