Skip to content

Instantly share code, notes, and snippets.

✌️
Living life one commit at a time!

Bradley Davis Bradley-D

✌️
Living life one commit at a time!
Block or report user

Report or block Bradley-D

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Bradley-D
Bradley-D / HTML: Menu for a hero area with animation
Last active Nov 2, 2018
HTML: Menu for a hero area with animation
View HTML: Menu for a hero area with animation
I needed to add a "menu" to a hero area on a page so I thought this would be a good boilerplate for another time.
@Bradley-D
Bradley-D / WooCommerce: Gallery Slider Navigation Controls
Last active May 3, 2018
WooCommerce: Gallery Slider Navigation Controls
View WooCommerce: Gallery Slider Navigation Controls
@Bradley-D
Bradley-D / Add Security to target _blank
Last active May 21, 2018
jQuery: Target Blank Security
View Add Security to target _blank
$('a').each(function () {
if ($(this).attr('target') == '_blank') {
if ($(this).attr('rel')) {
this.rel += ' noopener noreferrer';
} else {
$('a').attr('rel', 'noopener noreferrer');
}
};
});
View WooCommerce: Replace placeholder image
// Replace WooCommerce product placeholder
function _custom_woocommerce_placeholder_img_src( $src ) {
$src = trailingslashit( get_template_directory_uri() ) . 'includes/images/placeholder.jpg'; // Change to required path and name
return $src;
}
add_filter( 'woocommerce_placeholder_img_src', '_custom_woocommerce_placeholder_img_src' );
@Bradley-D
Bradley-D / WooCommerce: Remove Add To Cart from loop and replace with View Product Link
Created Sep 4, 2017
Removes the "Add to cart" text/button from the shop/cat loop and replaces with a view product link
View WooCommerce: Remove Add To Cart from loop and replace with View Product Link
View WooCommerce: Quantity input args
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 );
View WooCommerce: RRP & Sale text in front of price
// 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);
View WordPress: Remove Yoast SEO Cols
/*
* Remove Yoast data stuff
*/
add_filter( 'wpseo_use_page_analysis', '__return_false' );
View _tb: Bootstrap activate parent menu - bootstrap-wp-navwalker.php
// 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 : '';
}
View WordPress: Add menu in content with shortcode
/* ------------------------------------------------------------------------ */
/* 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' );
You can’t perform that action at this time.