Skip to content

Instantly share code, notes, and snippets.

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

Bradley Davis Bradley-D

✌️
View GitHub Profile
/* ------------------------------------------------------------------------ */
/* 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' );
//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>';
}
// 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(
// 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 ) {
// 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 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 );
<?php
/* This snippet removes the action that inserts thumbnails to products in teh loop
* and re-adds the function customized with our wrapper in it.
* It applies to all archives with products.
*
* @original plugin: WooCommerce
* @author of snippet: Brian Krogsard
*/
remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10);
/**
** Rename name of Black Studio Tiny MCE
**/
function change_tinymce_widget_title( $translation, $text, $domain ) {
if ( $text == 'Black Studio TinyMCE' )
$translation = 'Text - Visual Editor';
return $translation;
}
add_filter( 'gettext', 'change_tinymce_widget_title', 10, 3 );
// unregister all widgets
function unregister_default_widgets() {
unregister_widget( 'WP_Widget_Pages' );
unregister_widget( 'WP_Widget_Calendar' );
unregister_widget( 'WP_Widget_Archives' );
unregister_widget( 'WP_Widget_Links' );
unregister_widget( 'WP_Widget_Meta' );
unregister_widget( 'WP_Widget_Search' );
unregister_widget( 'WP_Widget_Text' );
unregister_widget( 'WP_Widget_Categories' );
/**
* Change the add to cart text on single product pages
*/
function woo_custom_cart_button_text() {
global $woocommerce;
foreach ( $woocommerce->cart->get_cart() as $cart_item_key => $values ) {
$_product = $values['data'];