Skip to content

Instantly share code, notes, and snippets.

View joshuaiz's full-sized avatar
💭
it iz what it iz

Joshua Michaels joshuaiz

💭
it iz what it iz
View GitHub Profile
@joshuaiz
joshuaiz / plate-body-class.php
Last active April 22, 2018 01:52
Plate WordPress body class function: adds more classes to your WordPress posts + pages to help with CSS
<?php
// Body Class functions
// Adds more slugs to body class so we can style individual pages + posts.
// In your SCSS/CSS, use .page-yourslug {} to add styles for that page or post.
add_filter( 'body_class', 'plate_body_class' );
function plate_body_class( $classes ) {
global $post;
@joshuaiz
joshuaiz / wpmdb_clear_wp_super_cache.php
Created September 30, 2018 02:58
WordPress: Clear WP Super Cache after WP Migrate DB Pro migration
<?php
// Add this to your functions.php file of the active theme
add_action( 'wpmdb_migration_complete', 'wpmdb_clear_wp_super_cache', 2, 20 );
function wpmdb_clear_wp_super_cache() {
if (function_exists('wp_cache_clear_cache')) {
wp_cache_clear_cache();
}
}
@joshuaiz
joshuaiz / scss_css_liquid.sh
Created May 31, 2020 04:51
Append processed css from .scss file to .liquid file with the same name
# Script for CodeKit hook to append processed css from scss file to liquid file
# (make sure to use 'Compressed' for scss->css output so everything is on one line)
#
# To use:
# 1. create a `/styles` directory in your Shopify theme for your .scss files
# 2. name the .scss file the same name as the liquid file; e.g. sample.scss/sample.liquid
# 3. IMPORTANT: add empty `<style></style>` tags to first line of liquid file; add empty line below
# 4. add this script to your project in CodeKit in Hooks
# 5. profit
/* GC */
let gcDataArray = []
let gcCachedData = JSON.parse(localStorage.getItem('ma_pgc'))
// when customer adds physical gift card(s) to the cart
$('body').on('click', '.add-to-cart-physical', function () {
let notes = ''
console.log('atc pgc clicked')
@joshuaiz
joshuaiz / prepopulate-gf-radio.php
Created May 19, 2017 14:29
Pre-populate Gravity Forms Dropdown
<?php
add_filter( 'gform_pre_render_2', 'populate_posts' );
add_filter( 'gform_pre_validation_2', 'populate_posts' );
add_filter( 'gform_pre_submission_filter_2', 'populate_posts' );
add_filter( 'gform_admin_pre_render_2', 'populate_posts' );
function populate_posts( $form ) {
foreach ( $form['fields'] as &$field ) {
if ( strpos( $field->cssClass, 'populate-posts' ) === false ) {
@joshuaiz
joshuaiz / product-atc-options.js
Last active June 21, 2023 18:49
Shopify Add To Cart with options
const handleAddToCart = (e) => {
e.preventDefault()
if (
productOptions.embroidery === true &&
productOptions.embroiderySubmitted === false
) {
setEmbroideryError(true)
alert(
'Please select all required embroidery options and submit before adding to your cart.'