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
@robin-scott
robin-scott / finctions.php
Created December 29, 2017 16:03
Remove unwanted fields from Gravity Forms exports
// Remove unwanted fields from Gravity Forms export - updated by Robin Scott of Silicon Dales
add_filter( 'gform_export_fields', function ( $form ) {
// array of field IDs I never want to see on the export page
$fields_to_remove = array(
'payment_amount',
'payment_date',
'payment_status',
'transaction_id',
'user_agent',
'ip',
@robin-scott
robin-scott / functions.php
Created December 29, 2017 16:09
Remove Gravity forms fields in a specific form
// Robin Scott added this here for use in SiliconDales.com, but the snippet comes from Gravity Forms docs, here: https://docs.gravityforms.com/gform_export_fields/
add_filter( 'gform_export_fields', function ( $form ) {
// only limit the fields available for export form form ID 3
if ( $form['id'] == 3 ) {
// array of field IDs I never want to see on the export page
$fields_to_remove = array(
'payment_amount',
'payment_date',
'payment_status',
'transaction_id',
@robin-scott
robin-scott / functions.php
Created January 31, 2018 09:56
Remove woocommerce description tab
// add this to functions.php, a custom plugin, or a snippets plugin to remove the description tab in woocommerce
// by Robin Scott of Silicon Dales - full info at https://silicondales.com/tutorials/woocommerce-tutorials/remove-description-tab-woocommerce/
add_filter( 'woocommerce_product_tabs', 'sd_remove_product_tabs', 98 );
function sd_remove_product_tabs( $tabs ) {
unset( $tabs['description'] );
return $tabs;
}
@robin-scott
robin-scott / functions.php
Created February 6, 2018 09:47
Automatically complete woocommerce orders when paid
// Automatically complete woocommerce orders on successful payment (skip "processing") - Robin Scott for SiliconDales.com
add_action( 'woocommerce_thankyou', 'sd_woocommerce_auto_complete_order' );
function sd_woocommerce_auto_complete_order( $order_id ) {
if ( ! $order_id ) {
return;
}
$order = wc_get_order( $order_id );
$order->update_status( 'completed' );
}
@robin-scott
robin-scott / functions.php
Created February 20, 2018 11:23
Remove tabs from WooCommerce
// Remove the tabs 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
unset( $tabs['reviews'] ); // Remove the reviews tab
unset( $tabs['additional_information'] ); // Remove the additional information 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;
}
@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: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 / 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 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){