WordPress Dhaka Meetup · 29 August 2026

Scaling
WordPress Pluginswith AI

Mohammad Emran Hasan
Co-founder & CEO, Klasio / FigLab
Agentic Engineering.

Don't use AI to only write more code.

Use it to find what will break.

ai-engineering.co02
01/Engineering

Kill query amplification


Prime once. Read many.


// BEFORE
foreach ($user_ids as $user_id) {
    $plan = get_user_meta($user_id, 'plan', true);
}

// AFTER
update_meta_cache('user', $user_ids);

foreach ($user_ids as $user_id) {
    $plan = get_user_meta($user_id, 'plan', true);
}
ai-engineering.co03
01/Ask your agent
Scan this WordPress plugin for database or metadata access inside loops. Focus on get_post_meta(), get_user_meta(), get_option(), WP_Query, and $wpdb calls. For every finding: 1. show the exact code, 2. explain how query count grows with input size, 3. propose the smallest safe fix using cache priming, batching, or a better query. Do not change code yet. Rank findings by likely production impact.
01
ai-engineering.co04
02/Engineering

Move heavy work off the request


The user should not wait for work they don't need now.


// BEFORE
add_action('save_post', function ($post_id) {
    sync_to_crm($post_id);
    send_digest($post_id);
});

// AFTER — Action Scheduler
add_action('save_post', function ($post_id) {
    as_enqueue_async_action(
        'myplugin/process_post',
        [$post_id],
        'myplugin'
    );
});
ai-engineering.co05
02/Ask your agent
Audit this plugin for work that unnecessarily blocks an HTTP request. Look for: - external API calls, - email, - file generation, - bulk processing, - expensive calculations. For each candidate, tell me: 1. why it should stay synchronous or move to background work, 2. what failure/retry behavior is required, 3. the smallest safe WordPress-compatible change. Prefer Action Scheduler when a durable job queue is justified. Do not patch anything yet.
02
ai-engineering.co06
03/Engineering

Cache expensive reads


Cache is easy. Invalidation is the design.


$key = "stats:$user_id";

$stats = wp_cache_get($key, 'myplugin');

if (false === $stats) {
    $stats = calculate_stats($user_id);

    wp_cache_set(
        $key,
        $stats,
        'myplugin',
        300
    );
}
ai-engineering.co07
03/Ask your agent
Find repeated expensive reads or calculations in this plugin that are good caching candidates. For each candidate: 1. show where the repeated work happens, 2. estimate why it is expensive, 3. recommend object cache, transient, or no cache, 4. define the cache key, 5. define every event that must invalidate it. Reject caching where stale data could break correctness. Do not implement anything until the invalidation strategy is clear.
03
ai-engineering.co08
04/Engineering

Keep hooks thin


A hook should trigger behavior — not become the application.


// BEFORE
add_action('save_post_course', function ($post_id) {
    // validate
    // business rules
    // database writes
    // email
    // analytics
});

// AFTER
add_action(
    'save_post_course',
    [$course_saved, 'handle']
);
ai-engineering.co09
04/Ask your agent
Find WordPress hooks/callbacks in this repository that have too many responsibilities. Flag callbacks that mix several of these: validation, authorization, business rules, database access, notifications, analytics, external APIs. For each finding: 1. name the responsibilities being mixed, 2. propose the minimum useful boundaries, 3. keep the WordPress hook layer thin, 4. show a small refactoring sketch. Avoid abstractions that do not reduce real coupling.
04
ai-engineering.co10
05/Engineering

Extract business rules from WordPress


Framework at the edge. Business rules in the middle.


// COUPLED
function discount_for($user_id): int {
    $roles = get_userdata($user_id)->roles;

    return in_array('vip', $roles, true) ? 20 : 0;
}

// PORTABLE
final class DiscountPolicy {
    public function for(Customer $customer): int {
        return $customer->isVip() ? 20 : 0;
    }
}
ai-engineering.co11
05/Ask your agent
Identify business rules in this plugin that are unnecessarily coupled to WordPress APIs. Focus on pricing, permissions, subscriptions, commissions, enrollment, product rules, and state transitions. For each case: 1. show the business rule, 2. show the WordPress dependency mixed into it, 3. propose the smallest extraction that makes the rule independently testable, 4. keep WordPress integration at the boundary. Do not introduce a new abstraction unless it improves testability or reduces coupling.
05
ai-engineering.co12
06/Engineering

Ask MySQL what it is doing


Indexes follow access patterns — not intuition.


EXPLAIN
SELECT id
FROM wp_myplugin_orders
WHERE customer_id = 42
  AND status = 'paid'
ORDER BY created_at DESC
LIMIT 50;

CREATE INDEX idx_customer_status_created
ON wp_myplugin_orders (
    customer_id,
    status,
    created_at
);
ai-engineering.co13
06/Ask your agent
Act as a MySQL performance reviewer. I will give you: - table schema, - existing indexes, - the slow SQL, - EXPLAIN output. Analyze them together. Tell me: 1. what MySQL is doing, 2. where the expensive step is, 3. whether current indexes fit the access pattern, 4. the exact index or query change you recommend, 5. write/storage trade-offs of that index. Do not recommend an index merely because a column appears in WHERE.
06
ai-engineering.co14

Build less blindly.Engineer with agents.

ai-engineering.co
ai-engineering.co15