Skip to content

Instantly share code, notes, and snippets.

@vkartk
vkartk / WooCommerce-Product-Count.php
Created January 17, 2022 07:18
WooCommerce Product Count By Category || Shortcode
// To Only Retrun the Product Count By Category
//[woocommerce_product_category_count category="rings"]
// Special thanks to CHADREX
add_shortcode( 'products-counter', 'products_counter' );
function products_counter( $atts ) {
$atts = shortcode_atts( [
'category' => '',
], $atts );
$taxonomy = 'product_cat';
@vkartk
vkartk / buddy_exclude_users_by_role.php
Created November 6, 2021 19:45
Exclude Users from BuddyPress Members List by WordPress role. ( BuddyPress / BuddyBoss )
function buddy_exclude_users_by_role( $args ) {
// do not exclude in admin.
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
return $args;
}
$excluded = isset( $args['exclude'] ) ? $args['exclude'] : array();
if ( ! is_array( $excluded ) ) {
$excluded = explode( ',', $excluded );
@vkartk
vkartk / buddy_hide_admin_activity.php
Created November 6, 2021 19:41
Hide admin activity for BuddyPress / BuddyBoss
// hide admin's activities from all activity feeds
function ( $a, $activities ) {
// ... but allow admin to see his activities!
if ( is_super_admin() )
return $activities;
foreach ( $activities->activities as $key => $activity ) {
// ID's to exclude, separated by commas. ID 1 is always the superadmin
if ( $activity->user_id == 1 ) {
@vkartk
vkartk / counter.js
Created September 4, 2021 18:30
Animated counter in Vanilla JS
<script>
const counters = document.querySelectorAll(".count");
const speed = 200;
counters.forEach((counter) => {
const updateCount = () => {
const target = parseInt(+counter.getAttribute("data-target"));
const count = parseInt(+counter.innerText);
const increment = Math.trunc(target / speed);
console.log(increment);