Skip to content

Instantly share code, notes, and snippets.

View landbryo's full-sized avatar
🤠
Always Excitied

Landon Otis landbryo

🤠
Always Excitied
View GitHub Profile
@landbryo
landbryo / woo-email
Created October 10, 2018 18:04
Add a message to the beginning of a WooCommerce order email. Change which order email by updating what is currently set to 'customer_processing_order'
<?php
add_action('woocommerce_email_before_order_table', 'custom_order_header', 20, 4);
function custom_order_header( $order, $sent_to_admin, $plain_text, $email ) {
if ($email->id == 'customer_processing_order') {
echo '<p>Once your order is processed...</p>';
}
}
@landbryo
landbryo / pdf-optimize.sh
Last active November 21, 2018 23:02
Optimize PDF for ebook (150dpi) in Linux using Ghost Script. This is perfect for preparing PDFs to be added to services such as Issuu.
// https://ghostscript.com/doc/current/Ps2pdf.htm
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
@landbryo
landbryo / log-scan.sh
Created October 1, 2018 16:57
Scan access logs for duplicate hits and list top 100
grep '1/Oct/2018' /var/www/vhosts/system/*/logs/access_log | awk '{print $1,$7}' | sort | uniq -c | sort -nr | head -100
@landbryo
landbryo / docker-compose.yml
Last active October 2, 2018 21:08
My in-progress docker-compose.yml file for local WordPress Development
version: "3.3"
services:
my-wpdb:
image: mariadb
ports:
- "8081:3306"
environment:
MYSQL_DATABASE: wordpress
MYSQL_ROOT_PASSWORD: password
volumes:
@landbryo
landbryo / name-regex.md
Last active March 15, 2019 16:31
Use these regular expressions to help split first and last names.

Keep first name - \s(.*)

Keep last name - ^\S*

Remove numbers from end of string \d(.*)

@landbryo
landbryo / gravity-forms-roles.php
Last active September 11, 2018 16:59
Grant editor role full access to Gravity Forms
/* These functions are set to run on init and can be removed after they've run once. There is no need to keep them in the functions file */
/* Credit goes to https://ryanbenhase.com/giving-editors-access-to-gravity-forms/ */
//////////////////
// GRANT ACCESS //
//////////////////
function grant_gforms_editor_access() {
$role = get_role( 'editor' );
$role->add_cap( 'gform_full_access' );
}
add_action( 'init', 'grant_gforms_editor_access' );
@landbryo
landbryo / the-pop.html
Last active September 10, 2018 18:06
Super simple code to add a popup with a cookie created on closing.
<h3>JS</h3>
<script>
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime()+(exdays*24*60*60*1000));
var expires = "expires="+d.toGMTString();
document.cookie = cname + "=" + cvalue + "; " + expires + '; path=/';
}
@landbryo
landbryo / putty-secury-copy-client
Last active September 10, 2018 18:11
Use Putty Secure Copy Client to push/pull files to/from Linux server and Windows.
pscp [email protected]:/home/username/file-to-download.zip C:\Users\Username\new-file.zip
@landbryo
landbryo / kallyas-blog-layout.md
Last active June 8, 2018 18:13
Kallyas WordPress Theme Blog Layout Tweak to Isotope

Kallyas WordPress Theme Blog Layout Tweak to Isotope

Styles to override Isotope styled applied to element

.blog-isotope-item {
	position: relative !important;
	top: auto !important;
	left: auto !important;
}
@landbryo
landbryo / mysql-select-update.sql
Created June 4, 2018 20:48
Useful MySQL select and update
/* find all matches for strings starting with 2070 in the fire_date column of the termmeta table */
SELECT * FROM `as9g6f0_termmeta` WHERE `meta_key` LIKE 'fire_date' AND `meta_value` LIKE '2070%';
/* find all matches for strings starting with 2070 in the fire_date column of the termmeta table and replace them with 1970 */
UPDATE as9g6f0_termmeta
SET meta_value = REPLACE(meta_value,'2070','1970')
WHERE `meta_key` LIKE 'fire_date' AND `meta_value` LIKE '2070%';