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
@vapvarun
vapvarun / 01-realtime-stock-sync-webhooks.php
Created February 24, 2026 20:15
WooCommerce Multi-Store Management: Stock Sync & Deployment (woocustomdev.com)
<?php
/**
* Real-time stock sync between WooCommerce stores via REST API webhooks.
*
* Store A sends stock updates when product stock changes.
* Store B receives and applies the stock update.
* Requires a shared SYNC_API_KEY constant defined in wp-config.php.
*/
// Store A: Send stock update when product stock changes
@vapvarun
vapvarun / 01-group-extension-resources.php
Created February 24, 2026 20:15
Extending BuddyPress Groups: Custom Tabs, Meta & Programmatic Management (bpcustomdev.com)
<?php
/**
* BuddyPress Group Extension: Resources Tab
*
* Adds a custom "Resources" tab to BuddyPress groups using
* the BP_Group_Extension API. Group admins can add resource
* links via the settings screen; all members see the list.
*/
class My_Group_Resources extends BP_Group_Extension {
@vapvarun
vapvarun / 01-salt-keys.php
Last active February 24, 2026 20:19
WordPress Security Hardening: wp-config & Server-Level Tweaks (tweakswp.com)
<?php
/**
* WordPress Salt Keys in wp-config.php
*
* Salt keys encrypt session cookies. Get fresh keys from:
* https://api.wordpress.org/secret-key/1.1/salt/
*
* Regenerate after any suspected breach, after removing
* a compromised admin user, or quarterly for high-value sites.
*/
@vapvarun
vapvarun / 01-list-inactive-members.php
Created February 26, 2026 04:52
WordPress MCP Adapter: Code Snippets (wbcomdesigns.com)
add_action( 'wp_abilities_api_init', function() {
wp_register_ability( 'my-bp-plugin/list-inactive-members', array(
'label' => 'List Inactive Members',
'description' => 'Retrieve community members with no activity in the specified number of days.',
'input_schema' => array(
'type' => 'object',
'properties' => array(
'days_inactive' => array(
'type' => 'integer',
'description' => 'Number of days of inactivity',
@vapvarun
vapvarun / 01-n1-query-bad-example.php
Created February 26, 2026 05:31
Performance Optimization for High-Traffic BuddyPress Communities (bpcustomdev.com)
// BAD: N+1 pattern — fires a query per member
$members = bp_core_get_users( array( 'per_page' => 20 ) );
foreach ( $members['users'] as $member ) {
// Each call fires a SELECT against bp_xprofile_data
$location = xprofile_get_field_data( 'Location', $member->ID );
$job_title = xprofile_get_field_data( 'Job Title', $member->ID );
$company = xprofile_get_field_data( 'Company', $member->ID );
echo "<div class='member-card'>";
@vapvarun
vapvarun / 01-install-tools.sh
Created February 26, 2026 05:31
WordPress Image Optimization Without Plugins - CLI and Server Methods (tweakswp.com)
# Debian/Ubuntu
sudo apt install imagemagick webp libavif-bin jpegoptim optipng
# CentOS/RHEL/AlmaLinux
sudo dnf install ImageMagick libwebp-tools libavif-tools jpegoptim optipng
# macOS (Homebrew)
brew install imagemagick webp libavif jpegoptim optipng
@vapvarun
vapvarun / 01-clamp-syntax.css
Created February 26, 2026 05:32
Fluid Typography and Spacing with theme.json for Block Themes (brndle.com)
clamp(minimum, preferred, maximum)
@vapvarun
vapvarun / 01-wp-admin-url.txt
Created February 26, 2026 05:35
Getting Started with WordPress 6.9 - Your First Site in 30 Minutes (wppioneer.com)
https://yourdomain.com/wp-admin
@vapvarun
vapvarun / 01-pmpro-restriction-message.txt
Created February 26, 2026 05:35
How to Create a Members-Only Content Area with Reign Theme and BuddyPress (reigntheme.com)
This content is exclusively available to [membership_level] members.
Unlock full access to our premium tutorials, downloads, and
community features by joining today.
[pmpro_button level="2" text="Become a Premium Member"]
@vapvarun
vapvarun / 01-tiered-commission.php
Created February 26, 2026 05:35
How to Build an EDD-Powered Marketplace for Multiple Vendors (eddsellservices.com)
add_filter( 'eddc_calc_commission_amount', 'custom_tiered_commission', 10, 5 );
function custom_tiered_commission( $commission, $download_id, $price, $payment_id, $user_id ) {
// Get vendor's total sales count
$sales_count = eddc_count_vendor_sales( $user_id );
if ( $sales_count > 200 ) {
$rate = 0.80; // 80% for top vendors
} elseif ( $sales_count > 50 ) {
$rate = 0.70; // 70% for established vendors
} else {