Skip to content

Instantly share code, notes, and snippets.

@tdmrhn
tdmrhn / floating-whatsapp-button.html
Last active February 27, 2024 11:56
Content Blocks Floating Whatsapp Button
<style>.dhn-whatsapp{position:fixed;bottom:20px;left:20px;width:64px;height:64px;border-radius:50%;animation:1.5s ease-out infinite pulse;z-index:99}@keyframes pulse{0%{box-shadow:0 0 0 0 rgba(37,211,102,.5)}80%{box-shadow:0 0 0 14px rgba(37,211,102,0)}}@media (max-width:700px){.btn-whatsapp-pulse{bottom:70px;width:40px;height:40px}}</style>
<a href="https://wa.me/NUMBER?text=Hello" class="dhn-whatsapp" target="_blank">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><circle cx="32" cy="32" r="31" fill="#30bf39"/><path fill="#fff" d="M41.4 34.8c-.4-.2-2.5-1.4-2.9-1.5-.4-.2-.7-.2-1 .2-.3.4-1.2 1.4-1.4 1.6-.3.3-.5.3-.9.1-.4-.2-1.8-.7-3.4-2.3-1.2-1.2-2.1-2.6-2.3-3.1-.2-.4 0-.7.2-.9.2-.2.4-.5.7-.7s.3-.4.5-.7c.2-.3.1-.5 0-.8s-.9-2.4-1.2-3.3c-.3-.9-.7-.7-.9-.8-.3 0-.5-.1-.8-.1-.4 0-.9.2-1.2.5-.4.4-1.6 1.4-1.6 3.5s1.4 4.3 1.6 4.5c.2.3 2.8 4.9 7.1 6.8 4.3 1.9 4.3 1.3 5.1 1.3.8 0 2.6-1 3-1.9.4-1 .4-1.9.3-2-.2 0-.5-.1-.9-.4zm-8 10.3c-2.8 0-5.4-.8-7.7-2.3l-5.4 1.7 1.8-5.2c-1.7-2.4-2.7-5.3-2.7-8.3 0-7.8 6.3
@tdmrhn
tdmrhn / rss_force_featured_image.php
Created June 13, 2021 10:58
RSS Force Featured Image
@tdmrhn
tdmrhn / blocksy-add-selected-posts.php
Created June 14, 2021 14:36
Blocksy add selected posts to Blog Archive
add_action('blocksy:hero:after', 'blocksy_featured_posts', 10);
function blocksy_featured_posts(){
if ( is_home() ) {
echo do_shortcode ("[blocksy_posts post_ids=10,25,48 limit=3 has_pagination=no]");
}
}
@tdmrhn
tdmrhn / woo-new-tab-with-hook.php
Last active August 4, 2022 11:41
Blocksy Add Product Tab with Content Block
<?php
add_filter( 'woocommerce_product_tabs', function ( $tabs ) {
$tabs['my_tab'] = array(
'title' => __( 'Blocksy Tab', 'woocommerce' ),
'priority' => 20,
'callback' => function() { echo do_shortcode( '[blocksy-content-block id="5870"]' ); }
);
return $tabs;
} );
@tdmrhn
tdmrhn / custom_recaptcha.php
Last active July 16, 2021 09:14
Custom Recaptcha v1
<?php
add_action('login_enqueue_scripts', 'login_recaptcha_script');
function login_recaptcha_script() {
wp_register_script('recaptcha_login', 'https://www.google.com/recaptcha/api.js?render=reCAPTCHA_site_key');
wp_enqueue_script('recaptcha_login');
}
add_action( 'login_form', 'display_recaptcha_on_login' );
function display_recaptcha_on_login() {
echo "<script> function onSubmit(token) { document.getElementById('loginform').submit(); } </script> <button class='g-recaptcha' data-sitekey='YOUR_PUBLIC_KEY' data-callback='onSubmit' data-size='invisible' style='display:none;'>Submit</button>";
@tdmrhn
tdmrhn / lightweight-accordion-by-andy.css
Created June 19, 2021 16:55
Lightweight Accordion Hover and Open State title color change
.lightweight-accordion details summary:hover {
background:var(--paletteColor3) !important;
color:var(--paletteColor8) !important;
}
.lightweight-accordion details[open] summary {
background:var(--paletteColor1) !important;
color:var(--paletteColor8) !important;
}
@tdmrhn
tdmrhn / add_buynow_button_after_addtocart.php
Created June 22, 2021 10:36
Blocksy Add Buy Now Button After Add to cart
<?php
function add_buynow_button_after_addtocart() {
$current_product_id = get_the_ID();
$product = wc_get_product( $current_product_id );
$checkout_url = WC()->cart->get_checkout_url();
if( $product->is_type( 'simple' ) ){
echo '<a href="'.$checkout_url.'?add-to-cart='.$current_product_id.'" class="ct-button">Buy Now</a>';
}
}
add_action( 'woocommerce_after_add_to_cart_button', 'add_buynow_button_after_addtocart', 99 );
@tdmrhn
tdmrhn / display_attribute_for_variations_size.php
Last active August 4, 2022 11:38
Display Attributes in Product Loop Card
add_action( 'blocksy:woocommerce:product-card:title:after', 'display_attribute_for_variations_size' );
function display_attribute_for_variations_size(){
global $product;
$taxonomy = 'pa_size';
if ( $product->get_type() == 'variable' ) {
$output = array();
foreach ($product->get_available_variations() as $values) {
foreach ( $values['attributes'] as $attr_variation => $term_slug ) {
if( $attr_variation === 'attribute_' . $taxonomy ){
@tdmrhn
tdmrhn / delete-wordpress-wp-admin.php
Created June 26, 2021 17:29
Deleting "- Wordpress" page title
<?php
add_filter( 'login_title', 'blc_wp_new_title' );
add_filter( 'admin_title', 'blc_wp_new_title', 10, 2);
function blc_wp_new_title( $login_title ) {
return str_replace(array( ' &lsaquo;', ' &#8212; WordPress'), array( ' &lsaquo;', ''),$login_title );
}
@tdmrhn
tdmrhn / blocksy-blog-filter-cs.php
Created June 26, 2021 22:01
Blocksy Blog or CPT live jQuery filter CS
<?php
add_filter( 'blocksy:hero:after', 'blc_jquery_filter', 10);
function blc_jquery_filter() {
if ( is_home() ) {
?>
<script>
jQuery(document).ready(function($) {
$('.ct-filter').on( 'click', function(event){
var $type = $(this).data("filter");
if($type == "all"){