Skip to content

Instantly share code, notes, and snippets.

@tdmrhn
tdmrhn / blc-2-preload-mini-cart-css.php
Last active February 29, 2024 13:55
Blocksy 2 Preload Mini Cart CSS file
View blc-2-preload-mini-cart-css.php
<?php
add_action('wp_enqueue_scripts', function() {
$theme = blocksy_get_wp_parent_theme();
wp_enqueue_style(
'ct-legacy-mini-cart-styles',
blocksy_cdn_url(
get_template_directory_uri() . '/static/bundle/cart-header-element-lazy.min.css'
),
[],
@tdmrhn
tdmrhn / floating-whatsapp-button.html
Last active February 27, 2024 11:56
Content Blocks Floating Whatsapp Button
View floating-whatsapp-button.html
<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 / blc-posts-shortcode-add-author-arg.php
Last active February 26, 2024 16:33
Blocksy Posts Shortcode Add Author IDs arg
View blc-posts-shortcode-add-author-arg.php
<?php
add_filter('blocksy:general:shortcodes:blocksy-posts:args', function ($query_args, $shortcode_args) {
if (isset($shortcode_args['author_ids'])) {
$author_ids = array_map('intval', explode(',', $shortcode_args['author_ids']));
$query_args['author__in'] = $author_ids;
}
return $query_args;
}, 10, 2);
@tdmrhn
tdmrhn / blc-2-exclude-out-of-stock-products-upsell.php
Created February 23, 2024 11:44
Blocksy 2 Exclude Out of Stock products from related and upsells
View blc-2-exclude-out-of-stock-products-upsell.php
<?php
add_filter( 'woocommerce_output_related_products_args', function ( $args ) {
$args['status'] = 'publish';
$args['limit'] = -1;
$args['stock_status'] = 'instock';
return $args;
}, 10, 1 );
@tdmrhn
tdmrhn / blc-2-mobile-pagination-numbers.css
Created February 23, 2024 06:12
Blocksy 2 Simplify Pagination Numbers in Mobile View
View blc-2-mobile-pagination-numbers.css
@media (max-width: 689.98px) {
[data-pagination="simple"] > div .page-numbers
{ margin: 2px; }
[data-pagination="simple"] > div .page-numbers:nth-child(3),
[data-pagination="simple"] > div .page-numbers:nth-child(4),
[data-pagination="simple"] > div .page-numbers:nth-child(8),
[data-pagination="simple"] > div .page-numbers:nth-child(9)
{ display: none; }
}
@tdmrhn
tdmrhn / blc-2-echo-content-block-if-acf-exist.php
Created February 17, 2024 12:40
Blocksy 2 Content Blocks + ACF condition
View blc-2-echo-content-block-if-acf-exist.php
<?php
add_filter('blocksy:single:top', function () {
if (get_field('my-field')) {
echo do_shortcode('[blocksy-content-block id="XXX"]');
}
});
@tdmrhn
tdmrhn / blc-2-product-brands-shortcode.php
Last active February 16, 2024 17:12
Blocksy 2 Product Brands loop Shortcode
View blc-2-product-brands-shortcode.php
<?php
add_shortcode('product_brands', function ($atts) {
ob_start();
$brands = get_terms(array(
'taxonomy' => 'product_brands',
'hide_empty' => false,
));
if (empty($brands)) {
echo 'No product brands found.';
@tdmrhn
tdmrhn / blocksy-2-masonry-grid.css
Created February 15, 2024 12:22
Blocksy 2 Blog Posts Masonry Grid
View blocksy-2-masonry-grid.css
[data-prefix="blog"] section .entries {
display: block;
--masonry-column: 3;
-webkit-column-count: var(--masonry-column);
-moz-column-count: var(--masonry-column);
column-count: var(--masonry-column);
}
[data-prefix="blog"] section .entries article {
display: inline-block;
@tdmrhn
tdmrhn / disable-woocommerce-bloat.php
Last active February 4, 2024 08:29
Disable WooCommerce Bloat
View disable-woocommerce-bloat.php
<?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 / blc-2-add-related-brand-products-with-content-bocks.php
Last active January 24, 2024 11:15
Blocksy 2 Brand based related products with Content Blocks Hook + Code Editor Block
View blc-2-add-related-brand-products-with-content-bocks.php