Skip to content

Instantly share code, notes, and snippets.

@alexpani
Last active December 14, 2015 09:19
Show Gist options
  • Save alexpani/5064003 to your computer and use it in GitHub Desktop.
Save alexpani/5064003 to your computer and use it in GitHub Desktop.
Snippet per siti basati su Woocommerce
<?php
/**
* functions-woocommerce.php
* Snippet collection for Woocommerce powered themes
* Author: Alessandro Pani for Active Net
* Version: 1.0
* aggiungere a functions.php: require_once('includes/functions-woocommerce.php');
*
*/
/** supporto per woocommerce genesis connect */
// add_theme_support( 'genesis-connect-woocommerce' );
/* Se il sito usa Woocommerce, possiamo sfruttare i tre formati immagine che vengono creati.
* Col seguente codice, eliminiamo i formati nativi di WP e sftruttiamo quelli di
* WooCommerce anche nel resto del tema.
*/
// add_filter('image_size_names_choose', 'an_woo_image_sizes');
function an_woo_image_sizes($sizes) {
// questi update in teoria non sono neccessari, di fatto cosi' sono sicuro del risultato
update_option( 'thumbnail_size_h', 0 );
update_option( 'thumbnail_size_w', 0 );
update_option( 'medium_size_h', 0 );
update_option( 'medium_size_w', 0 );
update_option( 'large_size_h', 0 );
update_option( 'large_size_w', 0 );
unset( $sizes['thumbnail']);
unset( $sizes['medium']);
unset( $sizes['large']);
// unset( $sizes['full'] ); // removes full size if needed
$myimgsizes = array(
"shop_thumbnail" => __( "Miniatura prodotto" ),
"shop_catalog" => __( "Prodotto negli elenchi" ),
"shop_single" => __( "Prodotto in pagina prodotto" )
);
if( !empty($sizes) )
return array_merge($sizes, $myimgsizes);
else
return $myimgsizes;
}
/** Remove Genesis SEO & Layouts layouts from 'product' post_type */
// add_action( 'init', 'child_remove_post_type_support' );
function child_remove_post_type_support() {
remove_post_type_support( 'product', 'genesis-layouts' );
remove_post_type_support( 'product', 'genesis-seo' );
}
/** Rimuove i prodotti correlati da woocommerce */
// remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20);
/** Number of products per page */
add_filter('loop_shop_per_page', create_function('$cols', 'return 28;'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment