Skip to content

Instantly share code, notes, and snippets.

@razorfrog
razorfrog / ca-prop-65-woocommerce.php
Last active February 25, 2021 20:03
California Prop 65 Conditional Text in WooCommerce
<?php
///////////////////////////////////////////////////////////////////////////////////////////////////////
// Show Prop 65 Message Upon State of California Shipping Selection During WooCommerce Checkout
// https://razorfrog.com/california-prop-65-conditional-text-in-woocommerce/
///////////////////////////////////////////////////////////////////////////////////////////////////////
// First Step
// Create Prop 65 warning message and hook it into WooCommerce After Order Review
// "display:none" we have hidden the warning message by default
@razorfrog
razorfrog / gist:a78bcb374c98ee61b92013ad37600208
Created December 18, 2022 23:05
gp doctor for all sites
for wpconfig in /var/www/*/wp-config.php; do \
echo; site=${wpconfig%\/wp-config.php}; site=${site#\/var\/www\/}; \
gp wp $site doctor check --all
echo
done
@razorfrog
razorfrog / gravityforms-to-groupsio.php
Last active April 4, 2024 16:22
Gravity Forms to Groups.IO subgroup signup
<?php
/////////////////////////////////////////////////////////////
// Gravity Forms to groups.io subgroup signup
// API details: https://groups.io/api/20190816#login
// Code details: https://razorfrog.com
/////////////////////////////////////////////////////////////
add_action( 'gform_after_submission_2', 'post_to_third_party', 10, 2 ); // Edit the "_2" to the correct form ID
function post_to_third_party( $entry, $form ) {
<?php
////////////////////////////////////////////////////////////
// deregister default punch fonts
////////////////////////////////////////////////////////////
add_action( 'wp_print_styles', 'rzf_deregister_punch', 100 );
function rzf_deregister_punch() {
wp_deregister_style( 'tp-open-sans' );
wp_deregister_style( 'tp-raleway' );
wp_deregister_style( 'tp-droid-serif' );
<?php
////////////////////////////////////////////////////////////
// additional customer info
// https://razorfrog.com/woocommerce-user-order-data-columns/
////////////////////////////////////////////////////////////
if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
function add_user_details_columns($columns) {
<?php
// Dark Mode Shortcode for Main Navigation Menu.
add_shortcode( 'dark-mode-toggle-nav', 'dark_mode_toggle_nav_shortcode' );
function dark_mode_toggle_nav_shortcode() {
return '<div class="rf-darkmode-toggle">
<button data-theme-toggle-nav class="container" aria-label="Light mode is active" title="Toggle color mode">
<img class="sun visible" src="/wp-content/themes/razorfrog/svg/dark-mode/sun-light-mode-toggle-icon.svg" />
<img class="moon" src="/wp-content/themes/razorfrog/svg/dark-mode/moon-dark-mode-toggle-icon.svg" />
// Mobile navigation menu and footer dark mode toggle button styling.
.rf-darkmode-toggle {
label {
width: 120px;
height: 45px;
position: relative;
display: block;
background-color: $color-n1;
border-radius: 200px;
<?php
// Set minimum quantity per product before checking out
add_action( 'woocommerce_check_cart_items', 'spyr_set_min_qty_per_product' );
function spyr_set_min_qty_per_product() {
// Only run in the Cart or Checkout pages
if( is_cart() || is_checkout() ) {
global $woocommerce;
<?php
// Set minimum quantity per product before checking out
function razorfrog_set_min_qty_per_product() {
// Only run in the Cart or Checkout pages
if( is_cart() || is_checkout() ) {
// Product Id and Min. Quantities per Product
$product_min_qty = array(
20 => 100,
<?php
// Change attribute rewrite rules
add_action('woocommerce_register_taxonomy', 'razorfrog_woo_register_taxonomy');
function razorfrog_woo_register_taxonomy() {
global $razorfrog_woo_attribute_labels;
$razorfrog_woo_attributes_labels = array();
if ( $attribute_taxonomies = wc_get_attribute_taxonomies() ) {
foreach ( $attribute_taxonomies as $tax ) {