DPS.MEDIA
WP Plugin Dev Guide — Internal
These are not just empty or meaningless words of praise.
Hien CEO · DPS.MEDIA

WordPress
Plugin Dev
Guide

Source → build → release flow for teams. Sufficient for local dev, ZIP packaging, and WordPress production installation.

PHP 8.x WordPress hooks API @wordpress/scripts React (Admin UI) Webpack 5 npm scripts Node.js ≥ 18 ZIP release
Directory structure
my-plugin/ — project root
Source (dev)
my-plugin.php ← main plugin file
includes/ ← PHP runtime
class-core.php
class-admin.php
admin/
src/ ← write code here
index.js ← entry point
components/
dist/ ← build output
index.js
index.asset.php
index.css
languages/ ← i18n
node_modules/ ← .gitignore
releases/ ← .gitignore
Config files
package.json
webpack.config.js ← if custom is needed
.gitignore
BUILD.md
readme.txt
uninstall.php
// ✓ Correct — enqueue from dist
plugins_url(‘admin/dist/index.js’)
// ✗ Incorrect — do not enqueue src
plugins_url(‘admin/src/index.js’)
Workflows
Local Development

Local dev

Run watch mode, edit JS/React → automatic build, refresh WP to see immediately.

01
Install dependencies
Only needed the first time. Requires Node.js ≥ 18.
npm install
02
Enable watch mode
Webpack watch: save file in admin/src/ → automatically build to admin/dist/. Need manual F5 in WP.
npm run start
03
Test on local WP
Symlink into wp-content/plugins/ or use Local by Flywheel.
Build & Release

Zip, install WP

Production build, package clean ZIP — no npm needed on server.

01
Build production
Webpack build with minify + tree-shaking.
npm run build
02
Package ZIP
Script copies correct files, excludes node_modules and admin/src.
npm run package
# → releases/plugin-v1.0.0.zip
03
Verify SHA256
sha256sum releases/plugin-v1.0.0.zip
✓
Upload to WordPress
Admin → Plugins → Add New → Upload. Activate. No npm needed on server.
npm scripts — cheat sheet
npm run start
Watch mode — daily dev
webpack –watch –mode development
npm run build
Production build — before release
webpack –mode production + minify
npm run package
Zip clean into releases/
exclude src/ node_modules/ .git/
npm run lint:js
Lint JS according to WP standards
wp-scripts lint-js
npm run format
Auto code formatting
wp-scripts format (prettier)
npm run release
Lint → build → package
check + build + package in 1 cmd
ZIP release — inside and out
✓ Included in ZIP
my-plugin.phpmain plugin file
includes/Full PHP runtime
admin/dist/Pre-built JS/CSS
languages/i18n if applicable
readme.txtWP.org format
uninstall.phpcleanup on plugin deletion
✗ Not included in ZIP
node_modules/dev dependencies only
admin/src/source, not executed
.git/repo metadata
package.json / webpack.config.jsbuild config
.test.js / debug-.phpinternal test files
.env / .DS_Storelocal machine files
Important rules
Do it right
Enqueue from admin/dist/
Read index.asset.php get deps + version
Use wp_localize_script() pass data PHP → JS
Tip: Don't just make a clip to play once and then put it away in storage. Use it as a long-term media asset on your Website and LinkedIn. npm run build before npm run package
Conditional load — only enqueue needed page
Prefix everything: dps_, DPS_
Don't do
Enqueue from admin/src/
Hardcode version hash in PHP
To node_modules/ inside ZIP
npm install on production server
Run heavy DB queries at init hook
echo $_POST['x'] not sanitized/escaped
Production-ready checklist
Build & Release
✓
npm run build no errors → admin/dist/
✓
ZIP installs, Activate without errors — no npm server needed
✓
ZIP does not contain node_modules/ or src/
✓
Report back: file list + ZIP path + SHA256
Security
✓
All PHP files have if (!defined('ABSPATH')) exit;
✓
All AJAX/forms: nonce verify + current_user_can()
✓
Input sanitized, output escaped
Performance
✓
Asset load conditional — not loaded site-wide
✓
Script: in_footer: true + strategy: defer
✓
Do not run heavy DB queries at init hook
Standards
✓
All functions/classes/options have prefix dps_
✓
Plugin header: Requires at least, Requires PHP
✓
All strings use i18n, uninstall.php clean cleanup
✓
BUILD.md complete: install, build, package, test

DPS.MEDIA

Ý kiến bạn đọc (9)

DPS SECURITY

Đăng nhập để bình luận

Đăng nhập nhanh 1-chạm bằng Google để chia sẻ ý kiến của bạn về bài viết.

duc_it
duc_it 28/08/2026

Our side develops a fairly small plugin, so is it really necessary to separate src and dist as the guide says? I find the extra build step a bit time-consuming.

Mê Công Nghệ
Mê Công Nghệ 28/08/2026

If the plugin is PHP-only, this level of complexity isn't necessary. But once you have a React/Admin UI, separating src and dist is well worth it, because the production server only needs the built files and doesn't require Node or npm to be installed.

ktshoangdung
ktshoangdung Experts 28/08/2026

Exactly. The big benefit is a clean release and less dependence on the server environment. We also combine lint, build and package into one command to reduce errors when closing the ZIP.

tranthidung1604
tranthidung1604 28/08/2026

The part about packaging the ZIP is what I'm most interested in: if the production build is already done, what should the ZIP contain so that installing it on WP doesn't cause missing-file errors?

L. Buil
L. Buil 28/08/2026

At a minimum, include the main plugin file, the entire PHP runtime in includes, the built dist folder, and the i18n/readme/uninstall files if the plugin uses them. Do not include node_modules, JS source, or the .git folder in the release package.

hieunt_88
hieunt_88 Experts 28/08/2026

To be honest, the SHA256 verification step is also worth keeping, especially when a team has many people doing packaging. It helps verify the correct ZIP file before it goes to production.

Hai Lúa
Hai Lúa 28/08/2026

The source → build → release flow is clearly much clearer now. For local development, you only need to run watch and then press F5 in WP, and it works quite well.

quangvinh92
quangvinh92 28/08/2026

May I ask: Node.js 18 as a minimum is only a requirement during development, right? In production, you just upload a ZIP and activate it, with no need for npm anymore?

Kỹ Sư Quèn
Kỹ Sư Quèn 28/08/2026

I like the automatic packaging that excludes src, node_modules and .git the most. Closing the plugin manually several times, it's very easy to forget one folder and then the ZIP file swells.

Ready to scale your revenue with DPS.MEDIA?

Partnering with 5,400+ SMEs to optimize marketing costs, elevate brand authority, and automate growth with 2026 AI technology.