Skip to content

Instantly share code, notes, and snippets.

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

Bradley Davis Bradley-D

✌️
View GitHub Profile
@Bradley-D
Bradley-D / Generate Public Key and Convert to PEMs
Last active August 31, 2022 23:47
This will help generate a private pem and then you can extract the public key and save it
// This will generate a private PEM
openssl genrsa -out PATH-LOCATION/file_name_private.pem 1024
// Now extract public key from the private pem and save it to a file
openssl rsa -in PATH-LOCATION/file_name_private.pem -pubout > PATH-LOCATION/file_name_public.pem
@Bradley-D
Bradley-D / HTML: Menu for a hero area with animation
Last active November 2, 2018 06:23
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 06:42
WooCommerce: Gallery Slider Navigation Controls
@Bradley-D
Bradley-D / Add Security to target _blank
Last active May 21, 2018 07:08
jQuery: Target Blank Security
$('a').each(function () {
if ($(this).attr('target') == '_blank') {
if ($(this).attr('rel')) {
this.rel += ' noopener noreferrer';
} else {
$('a').attr('rel', 'noopener noreferrer');
}
};
});
// 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 September 4, 2017 12:06
Removes the "Add to cart" text/button from the shop/cat loop and replaces with a view product link
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 );
// 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);
/*
* Remove Yoast data stuff
*/
add_filter( 'wpseo_use_page_analysis', '__return_false' );
// 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 : '';
}