Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Adds back in woocommerce functionality removed from Feast themes 4.1.5+ - not tested
// Add support for WooCommerce features.
add_theme_support( 'woocommerce' );
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
add_theme_support( 'wc-product-gallery-zoom' );
if ( class_exists( 'WooCommerce', false ) ) {
require_once FEAST_DIR . 'lib/woocommerce.php'; // note: doesn't exist anymore
}
// contents of lib/woocommerce.php:
/**
* Seasoned Pro
*
* This file adds the required WooCommerce setup functions to the Seasoned Pro Theme.
*
* @package SeasonedPro
* @author StudioPress
* @license GPL-2.0+
* @link https://studiopress.com
*/
defined( 'WPINC' ) || die;
add_filter( 'woocommerce_enqueue_styles', 'seasoned_pro_wc_styles' );
/**
* Enqueue the theme's custom WooCommerce styles to the WooCommerce plugin.
*
* @since 1.1.0
*
* @return array Required values for the theme's WooCommerce stylesheet.
*/
function seasoned_pro_wc_styles( $enqueue_styles ) {
$enqueue_styles['seasoned-woocommerce-styles'] = array(
'src' => SEASONED_PRO_URI . 'css/woocommerce.css', // does not exist
'deps' => '',
'version' => CHILD_THEME_VERSION,
'media' => 'screen',
);
return $enqueue_styles;
}
add_filter( 'woocommerce_style_smallscreen_breakpoint', 'seasoned_pro_wc_breakpoint' );
/**
* Modify the WooCommerce breakpoints.
*
* @since 1.1.0
*/
function seasoned_pro_wc_breakpoint() {
$layouts = array(
'content-sidebar',
'sidebar-content',
);
if ( in_array( genesis_site_layout(), $layouts, true ) ) {
return '1200px';
}
return '800px';
}
add_filter( 'genesiswooc_default_products_per_page', 'seasoned_pro_wc_default_products_per_page' );
/**
* Set the default products per page value.
*
* @since 1.1.0
*
* @return int Number of products to show per page.
*/
function seasoned_pro_wc_default_products_per_page() {
return 8;
}
add_filter( 'woocommerce_pagination_args', 'seasoned_pro_wc_pagination' );
/**
* Update the next and previous arrows to the default Genesis style.
*
* @since 1.1.0
*
* @return string New next and previous text string.
*/
function seasoned_pro_wc_pagination( $args ) {
$args['prev_text'] = sprintf( '« %s', __( 'Previous Page', 'seasonedpro' ) );
$args['next_text'] = sprintf( '%s »', __( 'Next Page', 'seasonedpro' ) );
return $args;
}
add_action( 'after_switch_theme', 'seasoned_pro_wc_after_switch_theme', 1 );
/**
* Define WooCommerce image sizes on theme activation.
*
* @since 1.1.0
*/
function seasoned_pro_wc_after_switch_theme() {
global $pagenow;
if ( isset( $_GET['activated'] ) && 'themes.php' === $pagenow ) {
seasoned_pro_wc_update_image_dimensions();
}
}
add_action( 'activated_plugin', 'seasoned_pro_wc_woo_activated', 10, 2 );
/**
* Define the WooCommerce image sizes on WooCommerce activation.
*
* @since 1.1.0
*/
function seasoned_pro_wc_woo_activated( $plugin ) {
if ( 'woocommerce/woocommerce.php' === $plugin ) {
seasoned_pro_wc_update_image_dimensions();
}
}
/**
* Update WooCommerce image dimensions.
*
* @since 1.1.0
*/
function seasoned_pro_wc_update_image_dimensions() {
// Product category thumbs.
update_option( 'shop_catalog_image_size', array(
'width' => '530',
'height' => '530',
'crop' => 1,
) );
// Single product image.
update_option( 'shop_single_image_size', array(
'width' => '720',
'height' => '720',
'crop' => 1,
) );
// Image gallery thumbs.
update_option( 'shop_thumbnail_image_size', array(
'width' => '180',
'height' => '180',
'crop' => 1,
) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment