Skip to content

Instantly share code, notes, and snippets.

@easaw
easaw / database.rules.json
Created September 12, 2020 01:53 — forked from codediodeio/database.rules.json
Common Database Rules for Firebase
// No Security
{
"rules": {
".read": true,
".write": true
}
}
@easaw
easaw / wp-config.php
Created August 19, 2020 15:47 — forked from MikeNGarrett/wp-config.php
All those damned wp-config constants you can never remember.
<?php
// PHP memory limit for this site
define( 'WP_MEMORY_LIMIT', '128M' );
define( 'WP_MAX_MEMORY_LIMIT', '256M' ); // Increase admin-side memory limit.
// Database
define( 'WP_ALLOW_REPAIR', true ); // Allow WordPress to automatically repair your database.
define( 'DO_NOT_UPGRADE_GLOBAL_TABLES', true ); // Don't make database upgrades on global tables (like users)
// Explicitely setting url
@easaw
easaw / wp-secure.conf
Created August 6, 2018 09:30 — forked from ethanpil/wp-secure.conf
Wordpress Security for NginX
# wp-secure.conf
#
#
# This file includes common security considerations for wordpress using nginx.
#
# The goal is to block actions which are usually dangerous to wordpress.
# Additionally, we block direct access to PHP files and folders which should not
# be accessed directly from a browser.
#
# Also have included exceptions for plugins that are known to require this access.
@easaw
easaw / woo-check-if-has-shipping-class.php
Created August 26, 2017 00:43
Check if the Woocommerce cart has product with a certain Shipping Class
/**
* From https://isabelcastillo.com/woocommerce-check-shipping-class
* Check if the cart has product with a certain Shipping Class
* @param string $slug the shipping class slug to check for
* @return bool true if a product with the Shipping Class is found in cart
*/
function cart_has_product_with_shipping_class( $slug ) {
global $woocommerce;
<?php
function email_past_due() {
global $wpdb;
$mailer = WC_Emails::instance();
$date = date( "Y-m-d H:i:s", current_time( 'timestamp' ) + 86400 * 7 );
$due_orders = $wpdb->get_col( $wpdb->prepare( "
SELECT posts.ID
FROM {$wpdb->posts} AS posts
<?php
/**
* Only allow one payment plan purchase (Subscription) at a time
*/
add_filter( 'woocommerce_add_to_cart_validation', 'woo_block_sub', 10, 2 );
function woo_block_sub( $valid, $product_id ) {
// Get the current product
$current_product = wc_get_product( $product_id );
RewriteEngine On
RewriteCond %{QUERY_STRING} !^desktop
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|googlebot-mobile|iemobile|iphone|ipod|#opera mobile|palmos|webos" [NC]
RewriteCond %{HTTP_USER_AGENT} "acs|alav|alca|amoi|audi|aste|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "dang|doco|eric|hipt|inno|ipaq|java|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|opwv" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "palm|pana|pant|pdxg|phil|play|pluc|port|prox|qtek|qwap|sage|sams|sany" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|w3cs|wap-|wapa|wapi" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "wapp|wapr|webc|winw|winw|xda|xda-" [NC,OR]