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-wp-config-db-constants.php
Created April 10, 2026 11:48
How to Migrate WordPress Site Without Downtime — Code Snippets (wppioneer.com)
<?php
// Update these four constants in wp-config.php on your new server
// Replace with the credentials from your new host's MySQL database setup
define( 'DB_NAME', 'new_database_name' );
define( 'DB_USER', 'new_database_user' );
define( 'DB_PASSWORD', 'new_database_password' );
define( 'DB_HOST', 'localhost' ); // Usually 'localhost' — check with your new host
@vapvarun
vapvarun / 01-php-ini-memory-limit.ini
Created April 10, 2026 11:37
WordPress Memory Limit: WP_MEMORY_LIMIT vs PHP memory_limit Explained (tweakswp.com)
; php.ini — PHP process memory ceiling
; This is the absolute maximum PHP will allocate for any script.
; WordPress and all plugins combined cannot exceed this value.
memory_limit = 256M
; For memory-intensive operations (large imports, WooCommerce batch processing):
; memory_limit = 512M
; For shared hosting where you cannot edit php.ini directly,
; use .htaccess (Apache only):
@vapvarun
vapvarun / 01-register-custom-report.php
Created April 10, 2026 11:32
How to Build Custom Reports and Analytics Dashboards in Easy Digital Downloads (eddsellservices.com)
<?php
/**
* Register a custom EDD report using the Reports API.
*
* Hook into 'edd_reports_init' to add your own report endpoint,
* define its date filters, and register the data tile(s) it contains.
*
* @package EDD_Custom_Reports
*/
@vapvarun
vapvarun / 01-check-autoload-options.sql
Created April 10, 2026 11:31
WordPress Database Optimization: wp_options Cleanup Guide (wppioneer.com)
-- Find autoloaded options bloating your wp_options table
-- Run in phpMyAdmin, TablePlus, or via WP-CLI: wp db query < 01-check-autoload-options.sql
-- 1. Total size of autoloaded data (in MB)
SELECT
ROUND(SUM(LENGTH(option_value)) / 1024 / 1024, 2) AS autoload_size_mb,
COUNT(*) AS autoload_row_count
FROM wp_options
WHERE autoload = 'yes';
@vapvarun
vapvarun / 01-nginx-page-cache-cart-exclusions.conf
Created April 10, 2026 11:31
WooCommerce Caching Strategies That Work with Dynamic Cart Data (woocustomdev.com)
## nginx.conf — Page cache with WooCommerce cart/session exclusions
## Place inside your server {} block (or FastCGI Cache config)
fastcgi_cache_path /tmp/nginx-cache levels=1:2 keys_zone=WORDPRESS:100m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
server {
# ... your existing server config ...
set $skip_cache 0;
@vapvarun
vapvarun / 01-register-point-rule.php
Created April 10, 2026 08:53
Add Points, Badges and Leaderboards to BuddyPress with WP Gamification (bpcustomdev.com)
<?php
/**
* Register a custom point rule with WP Gamification.
*
* Hook: wp_gamification_register_rules
* Fires on 'init' after the plugin has loaded its core rule engine.
*/
add_action( 'wp_gamification_register_rules', function( $rule_registry ) {
$rule_registry->register( 'bp_profile_complete', [
@vapvarun
vapvarun / 01-scaffold.sh
Created April 10, 2026 08:29
Building Custom Gutenberg Blocks with React: Step-by-Step Tutorial (wppioneer.com)
#!/bin/bash
# Step 1: Create the plugin directory inside WordPress
cd wp-content/plugins
mkdir highlight-card-block
cd highlight-card-block
# Step 2: Initialise npm project
npm init -y
# Step 3: Install @wordpress/scripts as a dev dependency
@vapvarun
vapvarun / 01-wp-schedule-event.php
Created April 9, 2026 19:29
WordPress Cron Jobs Explained: Schedule Tasks Without Server Access (wppioneer.com)
<?php
/**
* Schedule a custom cron event on plugin activation.
*
* Hooks into 'wp_schedule_event' to register a task that runs
* once every hour starting from the current time.
*/
function myplugin_activate() {
if ( ! wp_next_scheduled( 'myplugin_hourly_event' ) ) {
wp_schedule_event( time(), 'hourly', 'myplugin_hourly_event' );
@vapvarun
vapvarun / 01-nav-cta-button.css
Created April 9, 2026 19:29
How to Customize WordPress Menus with Dropdowns, Icons, and Mega Menus (wppioneer.com)
/* Target the <li> that has the custom class you added in the menu editor */
.nav-cta a {
background-color: #0073aa;
color: #ffffff !important;
padding: 8px 20px;
border-radius: 4px;
font-weight: 600;
transition: background-color 0.2s ease;
display: inline-block;
}
@vapvarun
vapvarun / 01-hpos-enable.php
Created April 9, 2026 18:45
WooCommerce Database Optimization for Scale (woocustomdev.com)
<?php
/**
* Enable HPOS (High-Performance Order Storage) programmatically.
* Place in a site-specific mu-plugin or functions.php.
* Run AFTER the HPOS migration is complete.
*
* @see https://github.com/woocommerce/woocommerce/wiki/High-Performance-Order-Storage-Upgrade-Recipe-Book
*/
add_action( 'before_woocommerce_init', function () {
if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {