use images from live site on stage


// use images from live site on stage https://johnoleksowicz.com/serve-wordpress-images-different-domain-htaccess/

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(wp-content/uploads/\d+/.*)$ https://www.livedomainurl.com/$1 [R=301,NC,L]
</IfModule>

gp featured post excerpt length

// gp blog - featured post excerpt length
add_filter( 'excerpt_length', function( $length ) {
    global $wp_query;
    if ( 0 === $wp_query->current_post && !wp_is_mobile() ) {
        // Set Length of first post on desktop
        $length = 50;
    } else {
        // Set Length of other posts and all posts on mobile
        $length = 20;
    }
	return $length;
}, 200);

woo omit categories from shop

// woo - omit categories from shop page

add_filter( 'get_terms', 'ts_get_subcategory_terms', 10, 3 );
function ts_get_subcategory_terms( $terms, $taxonomies, $args ) {
$new_terms = array();
// if it is a product category and on the shop page
if ( in_array( 'product_cat', $taxonomies ) && ! is_admin() &&is_shop() ) {
foreach( $terms as $key => $term ) {
if ( !in_array( $term->slug, array( 'uncategorized', 'sessions', 'programs' ) ) ) { //pass the slug name here
$new_terms[] = $term;
}}
$terms = $new_terms;
}
return $terms;
}

woo autocomplete virtual orders

/**
 * Auto Complete all WooCommerce virtual orders.
 * 
 * @param  int 	$order_id The order ID to check
 * @return void
 */
function custom_woocommerce_auto_complete_virtual_orders( $order_id ) {

	// if there is no order id, exit
	if ( ! $order_id ) {
		return;
	}

	// get the order and its exit
	$order = wc_get_order( $order_id );
	$items = $order->get_items();

	// if there are no items, exit
	if ( 0 >= count( $items ) ) {
		return;
	}

	// go through each item
	foreach ( $items as $item ) {

		// if it is a variation
		if ( '0' != $item['variation_id'] ) {

			// make a product based upon variation
			$product = new WC_Product( $item['variation_id'] );

		} else {

			// else make a product off of the product id
			$product = new WC_Product( $item['product_id'] );

		}

		// if the product isn't virtual, exit
		if ( ! $product->is_virtual() ) {
			return;
		}
	}

	/*
	 * If we made it this far, then all of our items are virual
	 * We set the order to completed.
	 */
	$order->update_status( 'completed' );
}
add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_virtual_orders' );

woo product title above image

// woo - product title above image
function product_change_title_position() {
	remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
	add_action( 'woocommerce_before_single_product', 'woocommerce_template_single_title', 5 );
}
add_action( 'init', 'product_change_title_position' );

woo remove tabs on product page

//Remove WooCommerce Tabs - this code removes all 3 tabs - to be more specific just remove actual unset lines 
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;

}