Apply a coupon depending on a number of products in the cart

add_action( 'woocommerce_before_cart', 'shipjar_apply_coupon_number_of_products' );

function shipjar_apply_coupon_number_of_products() {
	$coupon_code = 'snipdeal';
	// if there are more than 5 different products in the cart
	if( 5 < count( WC()->cart->get_cart() ) ) {
		if( ! WC()->cart->has_discount( $coupon_code ) ) {
			WC()->cart->apply_coupon( $coupon_code );
		}
	} else {
		WC()->cart->remove_coupon( $coupon_code );
		WC()->cart->calculate_totals();
	}
}

Apply a coupon if there is a specific product in cart 

When a customer purchases a specific product you may want to provide a specific discount to all the products in the cart automatically.

add_action( 'woocommerce_before_cart', 'snipjar_apply_coupon_specific_product' );

function snipjar_apply_coupon_specific_product() {
	$coupon_code = 'snipdeal';
	$product_id = 678;
	// if product in the cart
	if( in_array( $product_id, array_column( WC()->cart->get_cart(), 'product_id' ) ) ) {
		if( ! WC()->cart->has_discount( $coupon_code ) ) {
			WC()->cart->apply_coupon( $coupon_code );
		}
	} else { // if product removed from cart we remove the coupon
		WC()->cart->remove_coupon( $coupon_code );
		WC()->cart->calculate_totals();
	}
}

Move admin bar to the bottom

body {margin-top: -28px;padding-bottom: 28px;}
body.admin-bar #wphead {padding-top: 0;}
body.admin-bar #footer {padding-bottom: 28px;}
#wpadminbar { top: auto !important;bottom: 0;}
#wpadminbar .menupop .ab-sub-wrapper { bottom: 32px; }

Change excerpt length

add_filter(
	'excerpt_length',
	function ( $length ) {
		// Number of words to display in the excerpt.
		return 40;
	},
	500
);

Open all external links in new tab

<script type="text/javascript">
//<![CDATA[
jQuery(document).ready(function($) {
$('a').each(function() {
var a = new RegExp('/' + window.location.host + '/');
if(!a.test(this.href)) {
$(this).click(function(event) {
event.preventDefault();
event.stopPropagation();
window.open(this.href, '_blank');
});
}
});
});
//]]>
</script>