Skip to content

Instantly share code, notes, and snippets.

View robin-scott's full-sized avatar
🏠
Working from home

Rob Scott robin-scott

🏠
Working from home
View GitHub Profile
// 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
// By Robin Scott of Silicon Dales - details here: https://silicondales.com/tutorials/wordpress/lock-out-all-traffic-except-your-ip-from-login-admin/
Order Deny,Allow
Deny from all
Allow from X.X.X.X
// Add this into your .htaccess file at the root of your WordPress installation. By Robin Scott of Silicon Dales.
// See full details here: https://silicondales.com/tutorials/wordpress/lock-out-all-traffic-except-your-ip-from-login-admin/
<Files wp-login.php>
Order Deny,Allow
Deny from all
Allow from X.X.X.X
</Files>
@robin-scott
robin-scott / funtions.php
Created September 3, 2018 10:45
Declare WooCommerce Support (With settings)
// Originally posted in official WooCommerce Github
// Re-posted by Robin Scott of Silicon Dales here https://silicondales.com/tutorials/woocommerce/declare-woocommerce-support-theme/ to aid understanding and benefit all in the Open Source community. Feel free to share are distribute as required!
function mytheme_add_woocommerce_support() {
add_theme_support( 'woocommerce', array(
'thumbnail_image_width' => 150,
'single_image_width' => 300,
'product_grid' => array(
'default_rows' => 3,
'min_rows' => 2,
@robin-scott
robin-scott / funtions.php
Created September 3, 2018 10:43
Declare WooCommerce Support in theme (simple)
// Below declares woocommerce support when added to a theme or child theme functions.php - from the official WooCommerce Github (August 2018)
// Posted by Robin Scott of Silicon Dales here https://silicondales.com/tutorials/woocommerce/declare-woocommerce-support-theme/ to benefit the Open Source community. Free to share and distribute for any purpose.
function mytheme_add_woocommerce_support() {
add_theme_support( 'woocommerce' );
}
add_action( 'after_setup_theme', 'mytheme_add_woocommerce_support' );
@robin-scott
robin-scott / functions.php
Last active July 2, 2018 20:18
Hide woocommerce related products
// place this in your child theme functions.php file to remove related products from WooCommerce
// posted by Robin Scott of Silicon Dales, here: https://silicondales.com/tutorials/woocommerce/remove-related-products-woocommerce/
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
@robin-scott
robin-scott / functions.php
Created April 18, 2018 09:55
Change review author to not show full name, WooCommerce
// Add this to child theme functions.php to change the way reviews display in WooCommerce to not show full name.
// Details here: https://silicondales.com/tutorials/woocommerce/woocommerce-change-review-author-display-name-username/
// By Robin Scott for Silicon Dales
add_filter('get_comment_author', 'my_comment_author', 10, 1);
function my_comment_author( $author = '' ) {
// Get the comment ID from WP_Query
$comment = get_comment( $comment_ID );
if (!empty($comment->comment_author) ) {
if($comment->user_id > 0){
@robin-scott
robin-scott / example-theme-file.php
Created March 14, 2018 18:25
Add a shortcode into your theme php files
// How to add a shortcode into a PHP theme file in WordPress. By Robin Scott of Silicon Dales. More here: https://silicondales.com/tutorials/wordpress-tutorials/use-shortcodes-wordpress-theme-files/
<?php echo do_shortcode("[YOURSHORTCODE]"); ?>
@robin-scott
robin-scott / functions.php
Created February 20, 2018 11:29
Remove the additional information tab from woocommerce
// Remove the additional information tab from woocommerce - posted by Robin Scott of Silicon Dales @ https://silicondales.com/tutorials/woocommerce-tutorials/remove-tab-woocommerce/
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
function woo_remove_product_tabs( $tabs ) {
unset( $tabs['additional_information'] ); // Remove the additional information tab
return $tabs;
}
@robin-scott
robin-scott / functions.php
Created February 20, 2018 11:29
Remove reviews tab woocommerce
// Remove the reviews tab from woocommerce - posted by Robin Scott of Silicon Dales @ https://silicondales.com/tutorials/woocommerce-tutorials/remove-tab-woocommerce/
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
function woo_remove_product_tabs( $tabs ) {
unset( $tabs['reviews'] ); // Remove the reviews tab
return $tabs;
}
@robin-scott
robin-scott / functions.php
Created February 20, 2018 11:24
Remove description tab woocommerce
// Remove the description tab from woocommerce - posted by Robin Scott of Silicon Dales @ https://silicondales.com/tutorials/woocommerce-tutorials/remove-tab-woocommerce/
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
function woo_remove_product_tabs( $tabs ) {
unset( $tabs['description'] ); // Remove the description tab
return $tabs;
}