Skip to content

Instantly share code, notes, and snippets.

Avatar
🤓
Busy ... Always busy

Mitchell Krog mitchellkrogza

🤓
Busy ... Always busy
View GitHub Profile
@mitchellkrogza
mitchellkrogza / woocommerce-remove-nofollow
Created Sep 14, 2021
Woocommerce remove rel="nofollow" from add to cart and select options buttons
View woocommerce-remove-nofollow
/**
* Remove "nofollow" from add to cart / Select options buttons
* What possessed Woocommerce to inplement this we shall never know ?
*/
add_filter( 'woocommerce_loop_add_to_cart_args', 'add_to_cart_args_remove_nofollow' );
function add_to_cart_args_remove_nofollow( $args ) {
unset($args['attributes']['rel']);
return $args;
@mitchellkrogza
mitchellkrogza / delete-woocommerce-product-images
Created Jun 10, 2021
Delete Woocommerce Product images when deleting a Product
View delete-woocommerce-product-images
add_action( 'before_delete_post', 'delete_product_images', 10, 1 );
function delete_product_images( $post_id )
{
$product = wc_get_product( $post_id );
if ( !$product ) {
return;
}
View inline flatsome.css (NEW with inline icons) - Flatsome 3.14 Only
add_action('wp_head', 'inject_flatsome', 5);
function inject_flatsome() {
ob_start();
include 'wp-content/themes/flatsome/assets/css/flatsome.css';
$atf_css = ob_get_clean();
if ($atf_css != "" ) {
$theme = wp_get_theme( get_template() );
$version = $theme->get( 'Version' );
$fonts_url = get_template_directory_uri() . '/assets/css/icons';
$atf_css .= '@font-face {
@mitchellkrogza
mitchellkrogza / woocommerce-hide-featured-image
Last active Sep 2, 2021
Woocommerce Hide Featured Image from Specific Category
View woocommerce-hide-featured-image
@mitchellkrogza
mitchellkrogza / woocommerce-hide-product-categories
Last active Aug 20, 2021
Woocommerce Hide Specific Product Categories from View
View woocommerce-hide-product-categories
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() || is_product_category()) {
foreach( $terms as $key => $term ) {
if ( !in_array( $term->slug, array( 'uncategorised','artist' ) ) ) { //pass the slug name here
$new_terms[] = $term;
}}
$terms = $new_terms;
@mitchellkrogza
mitchellkrogza / flatsome-customize-woocommerce-notices
Created Aug 16, 2021
Flatsome Theme - Customize Success & Error Messages / Notices (Floating) & Hide Success Messages Completely & Make Notices disappear after 15 seconds
View flatsome-customize-woocommerce-notices
CSS FOR CUSTOMIZING WOOCOMMERCE MESSAGES
/*---------------------------------------------*/
/*Make Woocommerce Messages Float Above Content*/
/*---------------------------------------------*/
.woocommerce-notices-wrapper {
position:fixed;
top:30%;
left:50%;
@mitchellkrogza
mitchellkrogza / woocommerce-hide-featured-image
Created Jul 26, 2021
Woocommerce - hide featured image on single-product page
View woocommerce-hide-featured-image
@mitchellkrogza
mitchellkrogza / disable-wp-json
Last active Jul 3, 2021
Disable wp-json User Endpoints for Wordpress
View disable-wp-json
// Set this function to only run on front end ONLY (NOT in Admin side it breaks things)
// Use Code Snippets Plugin set to Front end only
add_filter( 'rest_user_query', '__return_null' );
add_filter( 'rest_prepare_user', '__return_null' );
@mitchellkrogza
mitchellkrogza / inline-flatsome.css
Last active Jun 23, 2021
Inline flatsome.css (Flatsome Theme)
View inline-flatsome.css
// This function can be adapted and modified to inline any theme or plugin CSS you like
// Inlining any critical CSS can make big improvements on your site speed
// Dont get carried away inlining everything - Keep it to critical and essential CSS
add_action('wp_head', 'inject_flatsome', 5);
function inject_flatsome() {
ob_start();
include 'wp-content/themes/flatsome/assets/css/flatsome.css';
$atf_css = ob_get_clean();
if ($atf_css != "" ) {
echo '<style id="inline-css" type="text/css">'. $atf_css . '</style>';
@mitchellkrogza
mitchellkrogza / woo-increase-variations
Last active Jun 22, 2021
Woocommerce Increase Variations per Page (Admin)
View woo-increase-variations
// NOTE: Setting this too high (even 50) can cause freezing when saving variations
// A 400 Bad Request can be registered on wpadmin-ajax.php when too high
add_filter( 'woocommerce_admin_meta_boxes_variations_per_page', 'woo_increase_variations_per_page' );
function woo_increase_variations_per_page() {
return 50;
}