Skip to content

Instantly share code, notes, and snippets.

View jimfloss's full-sized avatar

Jim Floss jimfloss

View GitHub Profile
@jimfloss
jimfloss / responsive-square.html
Created October 8, 2018 17:51
Responsive Squares
<style>
.square {
position: relative;
width: 50%;
}
.square:after {
content: "";
display: block;
padding-bottom: 100%;
@jimfloss
jimfloss / js-cookies.js
Created June 14, 2018 15:40
JS Cookies
//JS Cookie CRUD
function getCookie(c_name) {
var c_value = document.cookie;
var c_start = c_value.indexOf(" " + c_name + "=");
if (c_start == -1) {
c_start = c_value.indexOf(c_name + "=");
}
if (c_start == -1) {
c_value = null;
} else {
@jimfloss
jimfloss / track-clicks.js
Created June 11, 2018 17:03
Track Clicks
//On Click
var clicks = $(this).data('clicks');
if (clicks) {
$('.opprotunity .content-bottom').slideUp(800);
} else {
$('.opprotunity .content-bottom').slideDown(800);
}
$(this).data("clicks", !clicks);
@jimfloss
jimfloss / full-screen-responsive-background-video.html
Last active June 11, 2018 14:28
Full screen responsive background youtube/Vimeo video
<div class="video-wrapper">
<div class="video-foreground">
<iframe width="560" height="315" src="https://www.youtube.com/embed/<?php echo get_field('video_id'); ?>?autoplay=1&mute=1&loop=1&rel=0&controls=0&showinfo=0&playlist=<?php echo get_field('video_id'); ?>" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
</div>
</div>
<style>
.video-wrapper {
position: absolute;
width: 100%;
AL : Alabama
AK : Alaska
AZ : Arizona
AR : Arkansas
CA : California
CO : Colorado
CT : Connecticut
DE : Delaware
DC : District of Colombia
FL : Florida
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
//Code here
}
@jimfloss
jimfloss / ES6 Includes Polyfill
Created April 6, 2018 13:27
Polyfill to make ES6 Includes work in IE 11
//Includes Polyfill
if (!String.prototype.includes) {
String.prototype.includes = function(search, start) {
'use strict';
if (typeof start !== 'number') {
start = 0;
}
if (start + search.length > this.length) {
return false;
@jimfloss
jimfloss / ConstantContact.php
Created January 30, 2018 17:58
Add Contact to Constant Contact Using cURL
<?php
//Not original code, just don't want to loose it
// fill in your Constant Contact login and API key
$ccuser = get_theme_mod( 'ccuser' );
$ccpass = get_theme_mod( 'ccpass' );
$cckey = get_theme_mod( 'key' );
// fill in these values
$firstName = "";
$lastName = "";
@jimfloss
jimfloss / NewUserEmail.php
Created January 30, 2018 17:57
Programmatically send a New User WooCommerce email
<?php
$woocommerce_customer_new_account_settings = get_option('woocommerce_customer_new_account_settings');
$user_pass = 'generated_password';
$user_login = 'user_name';
$email = 'user_email@email.com';
$blogname = 'user_name';
$password_generated = 'generated_password';
require_once( '/www/wp-content/themes/theme-name/woocommerce/emails/customer-new-account.php' );
$email_content = ob_get_clean();
@jimfloss
jimfloss / ResponsiveVideo.css
Created January 30, 2018 17:56
Responsive Video CSS
.video-wrapper {
position: relative;
width: 100%;
height: 0;
padding-bottom: 56.25%;
margin: 0px auto;
}
.video-wrapper iframe {
position: absolute;