Skip to content

Instantly share code, notes, and snippets.

View mehh's full-sized avatar
🎯
Focusing

Kris Chase mehh

🎯
Focusing
View GitHub Profile
@mehh
mehh / functions.php
Created March 4, 2019 16:52
Remove Inline Styles from WordPress the_content();
add_filter('the_content', function( $content ){
//--Remove all inline styles--
$content = preg_replace('/ style=("|\')(.*?)("|\')/','',$content);
return $content;
}, 20);
@mehh
mehh / magento_cart_price_rule.sql
Created January 28, 2019 23:37
Magento1 Cart Price Rule SQL
// https://magento.stackexchange.com/questions/40649/magento-direct-sql-query-for-coupon-based-orders
SELECT coupon_rule_name AS 'Promotion Used'
, coupon_code AS 'Code Used'
, COUNT(coupon_code) AS 'Times Used / Number of Orders'
, SUM(subtotal) AS 'Cumulative Price'
, SUM(total_paid) AS 'Cumulative Paid with Coupon'
, AVG(total_paid) AS 'Average Order Total (W/ Coupon)'
, AVG(subtotal) AS 'Average Order Total (W/O Coupon)'
@mehh
mehh / gravity_forms_clamav.php
Created October 13, 2017 18:13
Scan Gravity Forms uploads with ClamAV - WordPress Raw
/**
* Scan Gravity Forms uploads with ClamAV
* Based on 'Custom Scan AV function by Kris Chase'
* https://krischase.com/detect-and-prevent-malware-in-gravity-forms-file-upload-with-php-clamav/
* Requires clamav and php-clamav installed and enabled
*/
function myfunc_uploads_clamav( $validation_result ) {
if ( $_FILES ) {
$form = $validation_result['form'];
@mehh
mehh / couponUsage.sql
Created June 2, 2016 15:38
Export list of transaction IDs, Customer IDs and coupon codes used for Magento Orders
SELECT sfo.customer_id AS customer, ce.email, GROUP_CONCAT(cev.value SEPARATOR ' ') as name,
sfo.entity_id, sfo.increment_id,scu.times_used,sc.coupon_id,sc.rule_id,sc.code FROM sales_flat_order sfo
LEFT JOIN salesrule_coupon_usage scu ON sfo.customer_id = scu.customer_id LEFT JOIN salesrule_coupon sc
ON sc.coupon_id = scu.coupon_id LEFT JOIN customer_entity ce ON ce.entity_id = sfo.customer_id
LEFT JOIN customer_entity_varchar cev ON cev.entity_id = sfo.customer_id WHERE (cev.attribute_id IN (5,7)
OR cev.attribute_id IS NULL) GROUP BY sfo.increment_id ORDER BY sfo.increment_id;
@mehh
mehh / wpcron-post-status.sh
Created May 14, 2016 05:46
Unpublish page or post automatically at given time using wpcli and cron
59 23 * * * /usr/local/bin/wp post update 1310 --post_status=draft --path="/home/username/public_html/"
#! /bin/bash
#----------------------------------------------------------------------------------------------#
# addMonitorToUptimeRobot.sh v1.0 (#0 2016-05-05) #
# #
# This script will loop through all users on WHM server, #
# retreive associated domains and add them to Uptime Robot #
############################## Modification Log ############################## #
# Date Who Version Description #
# 20160505 KChase 1.0 Initial Release #
#!/bin/bash
# Script by Kris Chase
# http://krischase.com
#
# robotsDeploy.sh is a script which will take a templated robots.txt file
# and deploy it to all users accounts on the current system
# Meant for systems running WHM
#Initialize variables counters.
v_cpanel_accounts=0