Skip to content

Instantly share code, notes, and snippets.

View mitchellkrogza's full-sized avatar
🤓
Busy ... Always busy

Mitchell Krog mitchellkrogza

🤓
Busy ... Always busy
View GitHub Profile
@mitchellkrogza
mitchellkrogza / flatsome-fix-gallery-thumbnail-sizes
Created September 26, 2021 08:44
Flatsome Theme - FIX Google Properly Size Images Warning for Gallery Thumbnails
<?php
// Version CSS file in a theme
wp_enqueue_style( 'theme-styles', get_stylesheet_directory_uri() . '/style.css', array(), filemtime( get_stylesheet_directory() . '/style.css' ) );
// Version JS file in a theme
wp_enqueue_script( 'theme-scripts', get_stylesheet_directory_uri() . '/js/scripts.js', array(), filemtime( get_stylesheet_directory() . '/js/scripts.js' ) );
@mitchellkrogza
mitchellkrogza / wp-rocket-deactivate-cart-fragments-cache
Created July 22, 2021 06:25
WP Rocket | Deactivate WooCommerce Refresh Cart Fragments Cache
/**
* Plugin Name: WP Rocket | Deactivate WooCommerce Refresh Cart Fragments Cache
* Description: Deactivate the WP Rocket feature that caches WooCommerce Refresh Cart Fragments.
* Plugin URI: https://github.com/wp-media/wp-rocket-helpers/tree/master/compatibility/wp-rocket-compat-wc-cart-fragments
* Author: WP Rocket Support Team
* Author URI: http://wp-rocket.me/
* License: GNU General Public License v2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*
* Copyright SAS WP MEDIA 2018
@mitchellkrogza
mitchellkrogza / delete-woocommerce-product-images
Created June 10, 2021 12:35
Delete Woocommerce Product images when deleting a Product
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;
}
@mitchellkrogza
mitchellkrogza / inline flatsome.css (NEW with inline icons) - Flatsome 3.14 Only
Created July 19, 2021 12:56
Inline flatsome.css (Flatsome Theme 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 September 2, 2021 09:43
Woocommerce Hide Featured Image from Specific Category
@mitchellkrogza
mitchellkrogza / woocommerce-hide-product-categories
Last active August 20, 2021 07:22
Woocommerce Hide Specific Product Categories from View
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 August 16, 2021 07:59
Flatsome Theme - Customize Success & Error Messages / Notices (Floating) & Hide Success Messages Completely & Make Notices disappear after 15 seconds
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 July 26, 2021 09:02
Woocommerce - hide featured image on single-product page
@mitchellkrogza
mitchellkrogza / disable-wp-json
Last active July 3, 2021 13:36
Disable wp-json User Endpoints for Wordpress
// 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' );