This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This fixes the Google Pagespeed Insights warning for "Properly Size Images" | |
// First inspect your gallery thumbnails with chrome developer tools and find the size they are RENDERED at on DESKTOP | |
// In my case they render at exactly 165 x 110 | |
// This function creates the correct gallery thumbnail size for Woocommerce and does NOT affect any image sizes of Flatsome | |
// After adding this function (use Code Snippets plugin) You need to Regenerate Thumbnails | |
// Use the plugin "Renegrate thumbmnails" with the setting "Skip regenerating existing correctly sized thumbnails (faster)." | |
add_filter( 'woocommerce_get_image_size_gallery_thumbnail', function( $size ) { | |
return array( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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' ) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Useful function to hide the product featured image for all products in specific categories | |
// The main image displayed when visiting products in these categories becomes the first gallery image | |
// Written by Mitchell Krog - mitchellkrog@gmail.com | |
// Replace categoryslug2 / categoryslug1 with your category slug (add to array as needed) | |
add_filter('woocommerce_single_product_image_thumbnail_html', 'remove_featured_image', 10, 2); | |
function remove_featured_image($html, $attachment_id ) { | |
global $product; | |
if( ! has_term( array( 'categoryslug1', 'categoryslug2' ) , 'product_cat', $product->get_id() ) ){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CSS FOR CUSTOMIZING WOOCOMMERCE MESSAGES | |
/*---------------------------------------------*/ | |
/*Make Woocommerce Messages Float Above Content*/ | |
/*---------------------------------------------*/ | |
.woocommerce-notices-wrapper { | |
position:fixed; | |
top:30%; | |
left:50%; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This removes the featured image from the single product page | |
// Your First Gallery Image becomes the main image | |
add_filter('woocommerce_single_product_image_thumbnail_html', 'remove_featured_image', 10, 2); | |
function remove_featured_image($html, $attachment_id ) { | |
global $post, $product; | |
$featured_image = get_post_thumbnail_id( $post->ID ); | |
if ( $attachment_id == $featured_image ) | |
$html = ''; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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' ); |