Skip to content

Instantly share code, notes, and snippets.


Rob Scott robin-scott

View GitHub Profile
robin-scott / functions.php
Last active Feb 23, 2021
Remove out of stock products from WooCommerce Related products
View functions.php
// remove OOS products from related products in WooCommerce, because they are OOS! by Robin Scott of - see more at
add_filter( 'woocommerce_related_products', 'exclude_oos_related_products', 10, 3 );
function exclude_oos_related_products( $related_posts, $product_id, $args ){
$out_of_stock_product_ids = (array) wc_get_products( array(
'status' => 'publish',
'limit' => -1,
'stock_status' => 'outofstock',
'return' => 'ids',
) );
robin-scott / google-drive-large-wget.txt
Created Jan 7, 2020
Wget command for large files collection from Google Drive
View google-drive-large-wget.txt
// Use the below to wget in large files (over 100MB) from Google Drive. Added by Robin Scott of See full instructions at
wget --load-cookies /tmp/cookies.txt "$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate '' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=FILE_ID" -O FILE_NAME && rm -rf /tmp/cookies.txt
robin-scott / wgetcomman.txt
Last active Jan 7, 2020
Google Drive small file wget command
View wgetcomman.txt
// Wget command to collect small files from Google Drive added by Robin Scott of
wget --no-check-certificate '' -O FILE_NAME
robin-scott / gist:cb297a299ebe8eb8b405e32230e3c013
Last active Oct 28, 2019
Only use product tags in WooCommerce related products
View gist:cb297a299ebe8eb8b405e32230e3c013
// Remove categories and only use tags in WooCommerce related products - By Robin Scott of Silicon Dales see
add_filter( 'woocommerce_product_related_posts_relate_by_category', '__return_false' );
robin-scott / .htaccess
Created Nov 27, 2018
Codeigniter .htaccess for mod_rewrite - see for details
View .htaccess
RewriteEngine On
# !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
# slashes.
# If your page resides at
# then use
# RewriteBase /mypage/test1/
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
View .htaccess
## EXPIRES CACHING - by Robin Scott of Silicon Dales, here
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType application/javascript "access 1 month"
ExpiresByType application/x-javascript "access 1 month"
View SQL
update [table_name] set [field_name] = replace([field_name],'[string_to_find]','[string_to_replace]');
View .htaccess
Order Deny,Allow
Deny from
robin-scott / functions.php
Last active Nov 21, 2018
WooCommerce - Add extra weight to all cart items in a specific shipping class - Find out more here ->
View functions.php
// By Robin Scott of Silicon Dales
// Add 6oz extra weight to all cart items in specific shipping class
// More information here:
add_action( 'woocommerce_before_calculate_totals', 'rscott_add_custom_weight', 10, 1);
function rscott_add_custom_weight( $cart_object ) {
if ( (is_admin() && ! defined( 'DOING_AJAX' ) ) || $cart_object->is_empty() )
if ( did_action( 'woocommerce_before_calculate_totals' ) >= 2 )
$additionalweight = 6;
robin-scott / htaccess
Created Oct 19, 2018
Deny access to wp-admin BUT allow ajax to be used in WordPress
View htaccess
// Add this to an .htaccess file at the top of the wp-admin directory to lock down this section of your site to only trusted IP addresses - BUT still allow ajax access
// By Robin Scott of Silicon Dales - details here:
<Files admin-ajax.php>
Order allow,deny
Allow from all
Satisfy any
Order Deny,Allow
Deny from all