Skip to content

Instantly share code, notes, and snippets.

View Bradley-D's full-sized avatar
✌️

Bradley Davis Bradley-D

✌️
View GitHub Profile
// Add the div to wrap the image on the archive pages
add_action( 'woocommerce_before_shop_loop_item_title', create_function('', 'echo "<div class=\"archive-img-wrap\">";'), 5, 2);
add_action( 'woocommerce_before_shop_loop_item_title',create_function('', 'echo "</div>";'), 12, 2);
// If there is sub categories on the archive page add a wrap around their images as well
add_action( 'woocommerce_before_subcategory_title', create_function( '', 'echo "<div class=\"sub-archive-img-wrapper\">";'), 5, 2 );
add_action( 'woocommerce_before_subcategory_title', create_function( '', 'echo "</div>";' ), 12, 2 );
// Add to functions.php
/*===================================================
Created by sk from Renegade Empire with help
from these sources:
http://docs.woothemes.com/document/editing-product-data-tabs/
http://www.sean-barton.co.uk/2013/03/remove-woocommerce-20-reviews-tab/#.UYnWe7XfB6N
http://www.sean-barton.co.uk/2013/03/sb-add-woocommerce-tabs-wordpress-plugin/#.UYrYL7XfB6M
// Add new image sizes
function bd_insert_custom_image_sizes( $image_sizes ) {
// get the custom image sizes
global $_wp_additional_image_sizes;
// if there are none, just return the built-in sizes
if ( empty( $_wp_additional_image_sizes ) )
return $image_sizes;
// add all the custom sizes to the built-in sizes
foreach ( $_wp_additional_image_sizes as $id => $data ) {
// Gravity Forms Custom Addresses (Australia)
// Credit: The Web Princess - http://thewebprincess.com/
function australian_address( $address_types, $form_id ) {
$address_types['australia'] = array(
'label' => 'Australia', //labels the dropdown
'country' => 'Australia', //sets Australia as default country
'zip_label' => 'Post Code', //what it says
'state_label' => 'State', //as above
'states' => array(
//Google Maps Shortcode - [googlemap]
function bd_google_maps( $atts, $content = null ) {
extract(shortcode_atts(array(
'width' => '', //set the width
'height' => '', // set the height
'src' => '' // get the src from google map embed
), $atts));
return '<iframe width="' . $width . '" height="' . $height . '" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="' . $src . '&amp;output=embed"></iframe>';
}
/* ------------------------------------------------------------------------ */
/* Add Menu to page with shortcode - [menu name="menu-name"]
/* ------------------------------------------------------------------------ */
function bd_menu_content_shortcode( $atts, $content = null ) {
extract( shortcode_atts(array( 'name' => null, ), $atts ) );
return wp_nav_menu( array( 'menu' => $name, 'echo' => false ) );
}
add_shortcode( 'menu', 'bd_menu_content_shortcode' );
// Line 87 of
// If item has_children add atts to a.
if ( $args->has_children && $depth === 0 ) {
$atts['href'] = ! empty( $item->url ) ? $item->url : '';
$atts['class'] = 'dropdown-toggle';
//$atts['data-toggle'] = 'dropdown'; <- This line gets added in theme.js when window width is < 768
$atts['aria-haspopup'] = 'true';
} else {
$atts['href'] = ! empty( $item->url ) ? $item->url : '';
}
/*
* Remove Yoast data stuff
*/
add_filter( 'wpseo_use_page_analysis', '__return_false' );
// Add text before regular price and sale price
function bd_rrp_sale_price_html( $price, $product ) {
if ( $product->is_on_sale() ) :
$has_sale_text = array(
'<del>' => '<del>RRP: ',
'<ins>' => '<br>Sale Price: <ins>'
);
$return_string = str_replace(array_keys( $has_sale_text ), array_values( $has_sale_text ), $price);
function bd_woocommerce_quantity_input_args( $args, $product ) {
$args['input_value'] = 1; // Starting value
$args['max_value'] = 800; // Maximum value
$args['min_value'] = 1; // Minimum value
$args['step'] = 1; // Quantity steps
return $args;
}
add_filter( 'woocommerce_quantity_input_args', 'bd_woocommerce_quantity_input_args', 10, 2 );