Skip to content

Instantly share code, notes, and snippets.

View cdsaenz's full-sized avatar

charly cdsaenz

View GitHub Profile
@cdsaenz
cdsaenz / wc_cancelled_order_add_customer_email.php
Created March 31, 2022 15:09 — forked from jrick1229/wc_cancelled_order_add_customer_email.php
Add customer email to Cancelled Order recipient list
<?php
/*
* Add customer email to Cancelled Order recipient list
*/
function wc_cancelled_order_add_customer_email( $recipient, $order ){
return $recipient . ',' . $order->billing_email;
}
add_filter( 'woocommerce_email_recipient_cancelled_order', 'wc_cancelled_order_add_customer_email', 10, 2 );
@cdsaenz
cdsaenz / tailwind_color_variables.scss
Created April 17, 2022 15:46 — forked from bobmurdoch/tailwind_color_variables.scss
Tailwind CSS colors as Sass variables
$black: #22292f;
$grey-darkest: #3d4852;
$grey-darker: #606f7b;
$grey-dark: #8795a1;
$grey: #b8c2cc;
$grey-light: #dae1e7;
$grey-lighter: #f1f5f8;
$grey-lightest: #f8fafc;
$white: #fff;
$red-darkest : #3b0d0c;
Add to header or function file:
<?php
// URL Segments and Master ID
//
// Segment Variables: $GLOBALS['segment']['1'], $GLOBALS['segment']['2'], etc.
// Master ID Variable: $GLOBALS['master_id']
global $segment;
global $master_id;
@cdsaenz
cdsaenz / gist:bc4d179af6b738174fd9a0ee5df9815a
Created April 28, 2022 18:22 — forked from corsonr/gist:9152652
WooCommerce : add custom fields to product variations
<?php
//Display Fields
add_action( 'woocommerce_product_after_variable_attributes', 'variable_fields', 10, 3 );
//JS to add fields for new variations
add_action( 'woocommerce_product_after_variable_attributes_js', 'variable_fields_js' );
//Save variation fields
add_action( 'woocommerce_process_product_meta_variable', 'save_variable_fields', 10, 1 );
/**
<?php
/**
* Proptotype
*/
namespace DoggieRescue\Notices;
class AdminNotice {
public static function process_messages() {
$notice = self::get_admin_message();
if ( ! empty( $notice ) && is_array( $notice ) ) {
@cdsaenz
cdsaenz / sftp-ubuntu.md
Last active August 27, 2022 15:30 — forked from lymanlai/sftp-ubuntu.md
Basic tutorial for creating a SFTP-only user on Ubuntu 9.04 and greater

Adding SFTP-only user to Ubuntu Server

https://devanswers.co/configure-sftp-web-server-document-root/

To add a SFTP-only user, you'll need to make sure your SSH config settings are correct, add a new user/group and set permissions for your new user. For step-by-step directions, see below. Omit sudo if you're logged in as root.

Directions

  1. Edit /etc/ssh/sshd_config and make sure to add the following at the end of the file:
@cdsaenz
cdsaenz / backupdb.sh
Created May 7, 2022 16:24
Backup and git MySQL DB dump, rotate weekly
#!/bin/bash
# CSDev
# Inspired in https://github.com/yamingd/gist/wiki/backup-mysql-and-commit-to-git
# Requirement: Configure user & password
# mysql_config_editor set --login-path=local --host=localhost --user=$DBUSERNAME --password
# Backup mysql, weekly overwrite
NOW=$(date +"%u%a")
@cdsaenz
cdsaenz / bs5-navwalker.php
Last active April 22, 2025 18:17
Wordpress Bootstrap 5 Nav Walker With Multiple Levels
<?php
/**
* CSDev - Bootstrap 5 wp_nav_menu walker
* Supports WP MultiLevel menus
* Based on https://github.com/AlexWebLab/bootstrap-5-wordpress-navbar-walker
* Requires additional CSS fixes
* CSS at https://gist.github.com/cdsaenz/d401330ba9705cfe7c18b19634c83004
* CHANGE: removed custom display_element. Just call the menu with a $depth of 3 or more.
*/
class bs5_Walker extends Walker_Nav_menu
@cdsaenz
cdsaenz / bs5-navwalker.css
Last active February 13, 2024 16:37
CSS for bs5-navwalker.php - Wordpress Bootstrap 5 Nav Walker With Multiple Levels
/*PHP Code at https://gist.github.com/cdsaenz/d6d65294d79a0b71b95c55a4bbd47f7d*/
/*version 2: revised for responsive on mobile, dropdown menu will open on hover for now (avoids js) */
.navbar.navbar-expand-lg .dropdown .dropdown-menu .dropdown-submenu {
/* dropdown sub menu positioning */
margin: 0;
left: 100%;
}
.dropdown-menu {
padding: 0;