Skip to content

Instantly share code, notes, and snippets.

View robspangler's full-sized avatar

Rob Spangler robspangler

View GitHub Profile
@robspangler
robspangler / wp-shortcode-youtube-example.txt
Last active October 31, 2018 21:34
WordPress shortcode that displays a fullscreen responsive YouTube video within your content. Only attribute needed is the video ID.
In WordPress Editor:
[youtube id='U3TC03kQ_Do']
[youtube id='U3TC03kQ_Do' align="right"]
[youtube id='U3TC03kQ_Do' align="left"]
@robspangler
robspangler / wp-rrssb-example.php
Last active August 29, 2015 14:02
WordPress function to display Ridiculously Responsive Social Sharing Buttons. This assumes you're already including the necessary CSS and JS (http://kurtnoble.com/labs/rrssb/).
<?php
//Display for current post
echo rrssb();
//Display for a specific post (by post ID)
echo rrssb(13);
?>
@robspangler
robspangler / jquery-chosen-mobile-placeholder-support.js
Created June 11, 2015 17:27
Adds placeholder support for mobile devices using a single instance of jQuery Chosen.
chosen_browser_is_supported = function() {
if (window.navigator.appName === "Microsoft Internet Explorer") {
return document.documentMode >= 8;
}
if (/iP(od|hone)/i.test(window.navigator.userAgent)) {
return false;
}
if (/Android/i.test(window.navigator.userAgent)) {
if (/Mobile/i.test(window.navigator.userAgent)) {
return false;
@robspangler
robspangler / wp-queries.sql
Last active August 29, 2015 14:22
Common WordPress Queries
// Update Image Path from Old to New Domain
UPDATE wp_posts SET post_content = REPLACE (post_content, 'src="http://OLDURL.com', 'src="http://NEWURL.com');
UPDATE wp_posts SET guid = REPLACE (guid, 'http://OLDURL.com', 'http://NEWURL.com') WHERE post_type = 'attachment';
@robspangler
robspangler / osx-terminal-commands
Last active August 1, 2016 19:09
Common OSX Terminal commands
//Edit Hosts File
sudo nano /private/etc/hosts
//Flush DNS
sudo killall -HUP mDNSResponder
.row { width: 100%; display: table; table-layout: fixed; }
.row .col { display: table-cell; padding: 0 15px; }
.row .col:first-child { padding-left: 0; }
.row .col:last-child { padding-right: 0; }
@robspangler
robspangler / gravity-forms-sample-form.html
Last active March 31, 2016 16:06
Sample Gravity Form + default Gravity Form styles (v1.9.17.14)
<div class="gf_browser_chrome gform_wrapper" id="gform_wrapper_1"><a id="gf_1" class="gform_anchor"></a>
<form method="post" enctype="multipart/form-data" target="gform_ajax_frame_1" id="gform_1" action="/sample-page/#gf_1">
<div class="gform_heading">
<h3 class="gform_title">Contact Us</h3>
<span class="gform_description">Optional form description.</span> </div>
<div class="gform_body">
<ul id="gform_fields_1" class="gform_fields top_label form_sublabel_below description_below">
<li id="field_1_1" class="gfield gfield_contains_required field_sublabel_below field_description_below">
<label class="gfield_label" for="input_1_1_3">Name<span class="gfield_required">*</span></label>
<div class="ginput_complex ginput_container no_prefix has_first_name no_middle_name has_last_name no_suffix gf_name_has_2 ginput_container_name" id="input_1_1"> <span id="input_1_1_3_container" class="name_first">
/* START: Nav functions
* Initially based on https://medium.com/@mariusc23/hide-header-on-scroll-down-show-on-scroll-up-67bbaae9a78c */
var didScroll;
var lastScrollTop = 0;
var delta = 25;
var navbarHeight = jQuery('header.main').outerHeight();
jQuery(window).scroll(function(event){
didScroll = true;
});
/* Desktop First */
.only-mobile { display: none !important; }
.only-tablet { display: none !important; }
@media only screen and (max-width: 767px) {
.only-tablet { display: block !important; }
.only-desktop { display: none !important; }
}
@media only screen and (max-width: 480px) {
.only-mobile { display: block !important; }
}
@robspangler
robspangler / enable-pointer-events-on-click.css
Created April 18, 2016 16:23
Disables mouse events on iFrames (e.g. Google Maps) until clicked on. This is especially useful for disabling the scroll wheel.
.pointer-events-on-click { cursor: pointer; }
.pointer-events-on-click iframe { pointer-events: none; }