Skip to content

Instantly share code, notes, and snippets.

View cdsaenz's full-sized avatar

charly cdsaenz

View GitHub Profile
@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 / class-wc-kia-class-email.php
Created May 11, 2022 19:37 — forked from helgatheviking/class-wc-kia-class-email.php
Send a WooCommerce Customer email from the Order Admin Actions
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! class_exists( 'WC_KIA_Class_Email', false ) ) :
/**
* A custom Order WooCommerce Email class
*
* @since 0.1
* @extends \WC_Email
@cdsaenz
cdsaenz / xss_clean.php
Created August 18, 2022 00:37 — forked from mbijon/xss_clean.php
XSS filtering in PHP (cleans various UTF encodings & nested exploits)
<?php
/*
* XSS filter, recursively handles HTML tags & UTF encoding
* Optionally handles base64 encoding
*
* ***DEPRECATION RECOMMENDED*** Not updated or maintained since 2011
* A MAINTAINED & BETTER ALTERNATIVE => kses
* https://github.com/RichardVasquez/kses/
*
* This was built from numerous sources
@cdsaenz
cdsaenz / my_get_plugin_info.php
Created September 20, 2022 20:05 — forked from butlerblog/my_get_plugin_info.php
#utility to get plugin info
<?php // no need to use this line.
/**
* Utility to get information on installed plugins.
*
* Returns an array of all installed plugins and indicates which are
* plugin are active and which are not. Array is keyed by the plugin's
* folder/slug.php (which is how WP looks at them) and includes the
* name, version, and true/false whether it is active or not.
*
@cdsaenz
cdsaenz / delete_older_than.php
Created September 25, 2022 15:04 — forked from tdebatty/delete_older_than.php
A simple PHP function to delete files older than a given age. Very handy to rotate backup or log files, for example...
<?php
/**
* A simple function that uses mtime to delete files older than a given age (in seconds)
* Very handy to rotate backup or log files, for example...
*
* $dir String whhere the files are
* $max_age Int in seconds
* return String[] the list of deleted files
*/
@cdsaenz
cdsaenz / VSCode-Regex-Search-Replace-Markdown-Images
Created September 29, 2022 18:37 — forked from dixonge/VSCode-Regex-Search-Replace-Markdown-Images
Regex to find markdown images and replace with img tag in VS Code (or template engine shortcode, etc.)
Find: !\[(.*?)\]\((.*?)\)
Replace: <img alt="$1" src="$2">
@cdsaenz
cdsaenz / .htaccess
Created September 29, 2022 23:16 — forked from thehashrocket/.htaccess
.htaccess file for CodeIgniter
AddDefaultCharset utf-8
# AddHandler php5-script .php
# AddHandler php4-script .php
# AddHandler php5-cgi .php
# Use PHP5 as default
AddHandler application/x-httpd-php5 .php
@cdsaenz
cdsaenz / Woo_WC_Product_Variable.php
Created October 4, 2022 00:51 — forked from gorkamu/Woo_WC_Product_Variable.php
Extended Woocommerce Variation Class
<?php
class Woo_WC_Product_Variable extends WC_Product_Variable {
public function get_all_variations() {
$available_variations = array();
foreach($this->get_children() as $child_id){
$variation = wc_get_product($child_id);
$available_variations[] = $this->get_available_variation($variation);
}