Skip to content

Instantly share code, notes, and snippets.

View vapvarun's full-sized avatar
👋
AI Developer & WordPress Expert. Building MCP servers & Plugins

Varun Kumar Dubey vapvarun

👋
AI Developer & WordPress Expert. Building MCP servers & Plugins
View GitHub Profile

WBCOM – Geo Restrict THCA (AU/NZ via Cloudflare)

Hide, redirect, and block checkout for a WooCommerce category when visitors are from Australia or New Zealand using Cloudflare’s CF-IPCountry.

What it does

  • Hides products in the restricted category from shop, archives, search, shortcodes, widgets, blocks.
  • Redirects AU/NZ visitors away from the category page and any single product in that category → to the Shop page.
  • Blocks add-to-cart via any method (buttons, AJAX, ?add-to-cart=ID, REST).
  • Cleans up saved carts and double-checks at checkout.
  • Adds Vary: CF-IPCountry to keep caches/CDNs from mixing countries.

Dokan Downloadable File Picker Fix

This snippet fixes a long-standing issue in Dokan Pro vendor dashboards where clicking “Choose file” for downloadable products fails on the first attempt (the media modal opens but does not populate _wc_file_urls[] and _wc_file_names[] inputs).

✅ Problem

  • Vendors go to Products → Add/Edit → Downloadable files.
  • Clicking Choose file opens the WordPress Media Library.
  • On the first attempt, the chosen file does not populate the input fields.
  • On the second attempt, it suddenly works.
@vapvarun
vapvarun / reign-custom-loader-simple.php
Created September 3, 2025 09:59
Reign Theme - Custom GIF Site Loader
<?php
/**
* Reign Theme - Custom GIF Site Loader
*
* Add this code to your child theme's functions.php file
* or create a custom plugin with this code.
*
* @version 1.0.0
* @link https://wbcomdesigns.com/
*/
@vapvarun
vapvarun / wp-stories-grouped-display.php
Last active September 4, 2025 12:10
WP Stories - Display Stories Grouped by Users on Activity Pages
<?php
/**
* WP Stories - Display Stories Grouped by Users on Activity Pages
*
* This code snippet modifies the default story display on BuddyPress and PeepSo
* activity pages to show stories grouped by users (public type) instead of
* showing all stories mixed together (single type).
*
* Add this code to your theme's functions.php file or create a custom plugin.
*
@vapvarun
vapvarun / wp-stories-smart-grouping.php
Last active September 4, 2025 12:21
WP Stories - Smart Grouping Based on Cover Images (Club stories without covers, separate stories with covers)
<?php
/**
* WP Stories - Fix PUBLIC Story Separation
*
* This ensures PUBLIC stories are NEVER combined, even from the same user
* Each PUBLIC story should appear as its own separate icon
*
* Add this code to your theme's functions.php or as a custom plugin
*
* @version 3.0.0
@vapvarun
vapvarun / wp-stories-fix-public-separation.php
Last active September 4, 2025 13:35
WP Stories - Separate PUBLIC Stories on Activity Pages (Complete Solution with Plugin Modifications)
<?php
/**
* Plugin Name: WP Stories - Separate PUBLIC Stories on Activity Pages
* Description: Display PUBLIC stories as separate circles on activity pages instead of grouping by user
* Version: 1.0.0
*
* This code ensures that PUBLIC type stories are displayed separately on BuddyPress/PeepSo activity pages,
* while SINGLE type stories remain grouped by user as normal.
*/
@vapvarun
vapvarun / README.md
Last active September 16, 2025 11:06
LearnDash - Link Course Image to First Lesson | Reign Theme Fix v1.2 | JavaScript solution for direct image output

LearnDash - Link Course Image to First Lesson (Reign Theme Fix)

Makes the course featured image clickable, linking directly to the first lesson. Specifically fixed for Reign theme's .lm-course-thumbnail implementation.

Installation

Add this code to your child theme's functions.php file or use a code snippets plugin like WPCode.

What This Fixes

@vapvarun
vapvarun / buddyx-avatar-fix.php
Created September 16, 2025 11:26
BuddyX Pro Theme - Fix for header avatar not updating with BuddyPress profile picture
<?php
/**
* BuddyX Pro Theme - Fix Header Avatar Not Updating
*
* Problem: The avatar in the top-right navigation bar doesn't update when users
* change their BuddyPress profile picture.
*
* Solution: This code snippet forces WordPress to use BuddyPress avatars when
* an email address is used to fetch avatars, ensuring the header displays
* the correct BuddyPress profile picture.
@vapvarun
vapvarun / fluentcart-bug-report.md
Created October 17, 2025 12:55
FluentCart Plugin Bug Report - ProductCardRender.php Line 45 Error

FluentCart Plugin Bug Report

Bug Description

There is a PHP syntax error in the FluentCart plugin that causes error messages and file paths to be displayed on product cards in archive/shop pages.

Affected File

File: app/Services/Renderer/ProductCardRender.php Line: 45

Current Code (WRONG)

@vapvarun
vapvarun / functions.php
Created October 30, 2025 07:28
BuddyBoss Active/Inactive Members Filter - Custom implementation for filtering and displaying member activity status
<?php
/**
* BuddyBoss Theme Child Functions
*
* @package BuddyBoss Theme Child
* @since 1.0.0
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {