Translation with gettext

18. August 2020

function this_translations( $translation, $text, $domain ) {
	if ( 'woocommerce' === $domain ) {
		switch ( $translation ) {
			case 'Includes':
				$translation = 'Inkluderet';
				break;
			case 'MVA':
				$translation = 'moms';
				break;
		}
	}

	return $translation;
}
add_filter( 'gettext', 'this_translations', 10, 3 );
Replace ‘Dismiss’ with an X in Woo store notice

2. April 2020

function twstudio_demo_store_filter($text) {

	$text = str_replace(array('<p class="woocommerce-store-notice demo_store">', '</p>', 'Dismiss'), array('<div class="woo-notice-container"><p class="woocommerce-store-notice demo_store">', '</p></div>', 'X'), $text);
	return $text;
}
add_filter('woocommerce_demo_store', 'twstudio_demo_store_filter', 10, 1);
Remove Uncategorized from widget

20. March 2020

function remove_uncategorized_category( $terms, $taxonomy, $query_vars, $term_query ) {
if ( is_admin() )
return $terms; if ( $taxonomy[0] == 'product_cat' ) {
foreach ( $terms as $k => $term ) {
if ( $term->term_id == get_option( 'default_product_cat' ) ) {
unset( $terms[$k] );
}
}
} return $terms;
}
add_filter( 'get_terms', 'remove_uncategorized_category', 10, 4 );
Simple function based on queried page

12. February 2020

<?php
$term = get_queried_object();
$type = $term->post_type;
if ( $type === 'event' ) {
	if ( has_post_thumbnail() ) {
		$size = apply_filters( 'twstudio_default_thumbnail_size', 'large' );
		the_post_thumbnail( $size, array( 'class' => 'featured-image' ) );
	}
}
?>