Skip to content

Instantly share code, notes, and snippets.

@tdmrhn
tdmrhn / blc-2-add-quantity+atc-to-product-cards.php
Created March 28, 2024 07:19
Blocksy 2 Add Quantity + Add to Card button to Product Cards via Content Blocks Element
<?php
// Add this to Content Blocks > Hook > No Condition or Location
// Call it through Customizer > Product Archives > Card Options > Enable Content Block Element > Select the Hook name in drop down
if ( is_product() || is_shop() || is_tax( 'product_cat' ) || is_tax( 'product_tag' ) ) {
global $product;
if ( ! $product->is_sold_individually() && 'variable' != $product->product_type && $product->is_purchasable() && $product->is_in_stock() ) {
echo '<div class="dhn-atc-wrap">';
woocommerce_quantity_input( array( 'min_value' => 1, 'max_value' => $product->backorders_allowed() ? '' : $product->get_stock_quantity() ) );
echo '<a href="' . esc_url( $product->add_to_cart_url() ) . '" data-quantity="1" class="button product_type_simple add_to_cart_button ajax_add_to_cart" data-product_id="' . esc_attr( $product->get_id() ) . '" aria-label="' . esc_attr( sprintf( __( 'Add to cart: %s', 'woocommerce' ), $product->get_name() ) ) . '" aria-describedby="" rel="nofollow">' . esc_html( $p
@tdmrhn
tdmrhn / disable-woocommerce-bloat.php
Last active April 22, 2024 04:33
Disable WooCommerce Bloat
<?php
add_filter( 'woocommerce_admin_disabled', '__return_true' );
add_filter( 'jetpack_just_in_time_msgs', '__return_false', 20 );
add_filter( 'jetpack_show_promotions', '__return_false', 20 );
add_filter( 'woocommerce_allow_marketplace_suggestions', '__return_false', 999 );
add_filter( 'woocommerce_helper_suppress_admin_notices', '__return_true' );
add_filter( 'woocommerce_marketing_menu_items', '__return_empty_array' );
add_filter( 'woocommerce_background_image_regeneration', '__return_false' );
add_filter( 'wp_lazy_loading_enabled', '__return_false' );
add_filter( 'woocommerce_menu_order_count', 'false' );
@tdmrhn
tdmrhn / remove-author-meta-link.php
Created April 18, 2024 09:29
Wordpress Remove Author Meta Link
@tdmrhn
tdmrhn / blc-2-woo-quantity-type-2-remove-button-spaces.css
Created April 17, 2024 09:54
Blocksy 2 Woo Quantity Type 2 Remove Button Spaces
.quantity[data-type="type-2"] .ct-increase {
inset-inline-end: 0;
}
.quantity[data-type="type-2"] .ct-decrease {
inset-inline-start: 0;
}
.quantity[data-type="type-2"] .ct-increase, .quantity[data-type="type-2"] .ct-decrease {
top: 0;
width: calc(var(--quantity-height, 55px)/1.3);
height: 100%;
@tdmrhn
tdmrhn / blc-2-single-posts-custom-tag-design.css
Created April 7, 2024 07:20
Blocksy 2 Single Posts Custom Tag Design
.entry-tags > a {
--price-tag-height: 25px;
--price-border-radius: 4px;
position: relative;
display: inline-flex;
height: var(--price-tag-height);
margin-left: calc(var(--price-tag-height) / 2);
padding: 0 calc(var(--price-tag-height) / 2);
color: #fff;
@tdmrhn
tdmrhn / blc-2-disable-cart-checkout-buttons.css
Created April 5, 2024 08:09
Blocksy 2 Disable cart and checkout buttons on opposite pages
body.woocommerce-cart .woocommerce-mini-cart__buttons .wc-forward:not(.checkout),
body.woocommerce-checkout .woocommerce-mini-cart__buttons .checkout
{ display: none; }
body.woocommerce-cart .woocommerce-mini-cart__buttons,
body.woocommerce-checkout .woocommerce-mini-cart__buttons
{ grid-template-columns: 1fr; }
@tdmrhn
tdmrhn / blc-open-account-popup-on-pageload.php
Last active April 1, 2024 06:53
Blocksy open account popup on selected page load
<?php
add_action( 'wp_footer', function () {
if ( is_page( array( 'contact', 'my-other-page' ) ) && ! is_user_logged_in() ) {// Add any condition you want like is_shop, is_category etc.
?>
<script>
document.addEventListener('DOMContentLoaded', function() {
document.querySelector('.ct-header-account [href="#account-modal"]').click();
});
</script>
<?php
@tdmrhn
tdmrhn / dhn-remove-extra-image-sizes.php
Created December 27, 2022 17:13
Wordpress remove extra image sizes
<?php
add_filter( 'intermediate_image_sizes', function ( $sizes ) {
// keep only 'thumbnail', 'medium', 'large'
$targets = ['medium_large', '1536x1536', '2048x2048','shop_thumbnail', 'shop_single', 'shop_catalog', 'woocommerce_thumbnail', 'woocommerce_single', 'woocommerce_gallery_thumbnail'];
foreach($sizes as $size_index=>$size) {
if(in_array($size, $targets)) {
unset($sizes[$size_index]);
}
}
@tdmrhn
tdmrhn / blc-2-cpt-card-hover-background-transition-effect.css
Created March 25, 2024 22:27
Blocksy Card Hover background transition from left
.entry-card.type-project {overflow: hidden; position: relative }
.entry-card.type-project::after { position: absolute; content: ""; top:0; left:-100%; width: 100%; height: 100%; background-color:var(--theme-palette-color-1); z-index: 1; transition: all 1s ease; }
.entry-card.type-project:hover::after { left: 0; }
@tdmrhn
tdmrhn / blocksy_add_menu.php
Last active March 18, 2024 12:40
Blocksy Add Menu Shortcode
<?php
add_shortcode('listmenu', function ($atts, $content = null) {
extract(shortcode_atts(array( 'name' => null, 'class' => null ), $atts));
return wp_nav_menu( array( 'menu' => $name, 'menu_class' => 'mymenu', 'echo' => false ) );
} );
// Usage [listmenu name="Menu Name"]