Skip to content

Instantly share code, notes, and snippets.

View coulterpeterson's full-sized avatar
🤓
Always learning

Coulter Peterson coulterpeterson

🤓
Always learning
View GitHub Profile
@coulterpeterson
coulterpeterson / snippet.php
Created August 24, 2023 14:45
WooCommerce General Helper Functions
/**
* Determine if product ID is in cart. Returns true if so, false otherwise.
*/
function is_product_in_cart($product_id) {
$in_cart = false;
foreach( WC()->cart->get_cart() as $cart_item ) {
$product_in_cart = $cart_item['product_id'];
$variation_in_cart = 0;
if( isset( $cart_item['variation_id'] ) ) {
@coulterpeterson
coulterpeterson / snippet.php
Created August 24, 2023 14:30
WooCommerce Limit Cart to 1 Product
/**
* @snippet WooCommerce Max 1 Product @ Cart
* @how-to Get CustomizeWoo.com FREE
* @author Rodolfo Melogli
* @compatible WCooCommerce 7
* @donate $9 https://businessbloomer.com/bloomer-armada/
* Note: technically speaking, the code below will force the product added to cart to replace whatever
* is in the cart, hence will only allow one product in the cart.
* Ref: https://www.businessbloomer.com/woocommerce-allow-1-product-cart/
*/
@coulterpeterson
coulterpeterson / snippet.css
Created June 23, 2023 23:01
Gravity Wiz | File Upload Pro | Hide Error Messages
/* To hide the red error box that's related to the multi-file form field: */
ul[id^='gform_multifile_messages_'] {
display: none;
}
/* Keeping the "Max file size" text while removing the "Max files: 1" part is probably the trickiest CSS rule, however if you're okay with playing with the numbers in this rule, you could try something like this: */
span.gfield_description.gform_fileupload_rules {
max-width: 9.7em;
overflow: hidden;
max-height: 2.3em;
@coulterpeterson
coulterpeterson / snippet.sh
Created June 20, 2023 16:32
WP CLI Add Local Admin Account to Site
wp user create admin local@local.local --user_pass=admin --role=administrator --porcelain
@coulterpeterson
coulterpeterson / how-i-work-template.md
Last active June 19, 2023 23:56 — forked from spivurno/how-i-work-template.md
Template for How I Like to Work posts

How I work

This is my own interpretation of how I like to work, feedback welcome! Especially if my own view of how I think I like to work doesn't match your experience of how it seems I like to work!

When I work

  • Timezone: EST
  • Times/hours you work: ~8am-4pm EST on a regular day
  • How many hours you work in a typical day: 8
  • Weekends y/n? N
  • After hours availability? N
@coulterpeterson
coulterpeterson / snippet.ps1
Last active August 15, 2023 15:03
Install SSH Key in Windows and WSL
# Credit: https://stackoverflow.com/a/63473832/8143105
# Make sure you're running PowerShell as an Administrator
Set-Service ssh-agent -StartupType Automatic
Start-Service ssh-agent
Get-Service ssh-agent
ssh-add
# Enter password
code # Or open regularly - should now have your SSH key pre-loaded into env as expected
@coulterpeterson
coulterpeterson / snippet.css
Created June 14, 2023 15:24
Gravity Forms | Make Field Look Required Without Being Required
/* Instructions: add a "look-required" class to the field you want to look required */
.look-required label:after {
content: ' (Required)';
color: red;
}
@coulterpeterson
coulterpeterson / gw-auto-submit-on-x-characters-entered-into-field.js
Last active June 13, 2023 14:46
Gravity Forms | Automatically Submit After X Number of Characters Entered Into Field
/**
* Gravity Wiz // Gravity Forms // Automatically Submit After X Number of Characters Entered Into Field
* https://gravitywiz.com/
*
* Instructions:
*
* 1. Install this snippet with our free Custom JavaScript plugin.
* https://gravitywiz.com/gravity-forms-custom-javascript/
* 2. Replace "1" with the ID of your field, and "4" with the number of characters you want to limit it to.
*
@coulterpeterson
coulterpeterson / functions.php
Created June 13, 2023 14:07
Delete All Subscribers in WordPress Site
function delete_all_subscribers() {
require_once(dirname( ABSPATH ) . '/public_html/wp-admin/includes/user.php');
$args = array(
'role' => 'subscriber',
);
$users = get_users( $args );
foreach ( $users as $user ) {
wp_delete_user($user->id);
}
@coulterpeterson
coulterpeterson / gw-disable-field-or-subfieldy.js
Last active June 12, 2023 21:08
Gravity Forms | Disable Field or Sub-Field
/**
* Gravity Wiz // Gravity Forms // Disable Field or Subfield
* https://gravitywiz.com/
*
* Instructions:
*
* 1. Install this snippet with our free Custom JavaScript plugin.
* https://gravitywiz.com/gravity-forms-custom-javascript/
* 2. Replace "1_2" with the ID of your field and the sub-field ID (in the case of an address field, for example),
* or replace the "1_2" with your field id only, if it's a single field.