Skip to content

Instantly share code, notes, and snippets.

View ThatGuySam's full-sized avatar
🍉
Discovering the wonders of JAMStack

Sam Carlton ThatGuySam

🍉
Discovering the wonders of JAMStack
View GitHub Profile
function bbloomer_add_gift_if_sku_added_cart( $passed, $product_id, $quantity ) {
global $woocommerce;
$skuswithgift = array('SMWB-M23','001-SLW');
$giftsku = 'comb';
$coupon_code = 'combfree';
@ThatGuySam
ThatGuySam / time-since.php
Last active October 24, 2017 18:11
Time since Shortcode for Wordpress
<?php
// ex:
// With [time since="1997"] years experience
// outputs: With 20 years of experience
class SCCTimeShortcode {
static $add_script;
static function init() {
@ThatGuySam
ThatGuySam / wordpress-security.php
Created October 24, 2017 14:17
Wordpress Security
<?php
// https://deliciousbrains.com/wordpress-security-fundamentals/
// Remove the WordPress version from the <head> tag
add_filter( 'the_generator', '__return_empty_string' );
// wp-config.php
@ThatGuySam
ThatGuySam / ccff-left.css
Last active February 1, 2019 01:25
Move Customer Chat for Facebook - Left Mode
.fb_dialog,
.fb_dialog.fb_dialog_advanced.fb_shrink_active,
.fb_iframe_widget iframe,
.fb_dialog_content iframe {
left: 18pt;
}
@ThatGuySam
ThatGuySam / humanDate.js
Created January 3, 2018 03:36
Human Post Date
// Requires ES6
import moment from 'moment'
makeHumanDate (jsDateObject) {
// Now (If less than 1 minute)
// 5 mins ago (If less than 1 hours)
// 19 hrs ago (If less than 24 hours)
// Yesterday (If date is yesterday)
// Sunday (If from this week)
@ThatGuySam
ThatGuySam / hide-fbccp.css
Last active January 24, 2018 18:05
Hide Facebook Customer Chat Plugin
.fb_dialog,
.fb_dialog.fb_dialog_advanced.fb_shrink_active,
.fb_iframe_widget iframe,
.fb_dialog_content iframe {
display: none;
}
@ThatGuySam
ThatGuySam / fullNameToFirstName.php
Created February 13, 2018 21:05 — forked from stilliard/fullNameToFirstName.php
PHP - Get a users first name from the full name
<?php
/**
* Get a users first name from the full name
* or return the full name if first name cannot be found
* e.g.
* James Smith -> James
* James C. Smith -> James
* Mr James Smith -> James
* Mr Smith -> Mr Smith
@ThatGuySam
ThatGuySam / crops-toward-focal-point.scss
Last active September 15, 2018 23:21
Crops toward focal point instead of center of image
// Cropping towards a focal point
/*
This controls where the image is cropped toward as
the design flows around it responsively.
This would be the same as a focal point in photography.
Original Idea: https://designshack.net/articles/mobile/focal-point-intelligent-cropping-of-responsive-images/
*/
@ThatGuySam
ThatGuySam / facebook.js
Last active December 3, 2018 20:34
Promise-based Facebook Javascript SDK for ES6 - React, Vue, etc...
/*
This a helper for adding Facebook's Javascript SDK in a modern development environment with build tools.
Runs as a promise so you can run:
await const FB = facebook()
OR
facebook().then((FB) => {
})
and then know that your facebook SDK is initialized
It also should work with fullstack frameworks like Next.js and Nuxt.js
@ThatGuySam
ThatGuySam / vc_reverse-rows.css
Last active August 6, 2018 18:36
Reverse Rows in Visual Composer
/*
* Just add vc_reverse-rows to the classes of what you want to reverse
*/
.vc_reverse-rows .col {
flex-direction: row-reverse;
}