A Jupyter-like notebook interface and declarative DSL for WordPress.
Expression Lab is an in-browser, Jupyter-like notebook interface and diagnostics plugin for WordPress. Powered by a declarative Domain-Specific Language (DSL), it lets you inspect posts, options, database tables, caches, HTTP requests, and files-and visualize results with Vega-Lite charts-without writing raw PHP snippets or using eval().
Key capabilities include multi-cell interactive notebooks and a scratchpad mode, visual query and HTTP request builders, in-memory SQLite analytics (Database.mirror()), a filesystem inspector, and encrypted .elab notebook storage (Professional Edition).
Expression Lab is built around four core security pillars to protect your WordPress environment:
- Declarative AST Sandbox: Expressions are parsed and evaluated through an isolated Abstract Syntax Tree (AST) engine based on Symfony Expression Language, preventing arbitrary PHP code execution.
- Client-Side Cryptography: Authentication uses browser-derived ephemeral Ed25519 keys to sign every request. Master passphrases, private keys, and credentials are never stored in the WordPress database.
- Operational Boundaries: Database operations default to read-only access with in-memory SQLite mirroring, filesystem access enforces path canonicalization, and a CPU watchdog enforces execution time limits.
- Isolated UI & Auditability: The notebook interface runs inside a sandboxed
iframewith anullorigin, and actions are recorded in a built-in audit log.
Note
Expression Lab has not undergone a formal security audit by an independent third-party security firm. For details on the threat model and boundary limits, see the Security Model documentation.
/* Query the latest 5 published posts */
Posts.where('post_type', 'post')
.where('post_status', 'publish')
.order_by('post_date', 'DESC')
.limit(5)
.get()/* Inspect user details and capabilities */
Users.get('anderson')/* Inspect registered cron schedules */
Options.get('cron')Database.mirror('posts', { 'post_author': 1 }, { 'limit': 100 })
.query('
SELECT
(SELECT count(*) FROM wp_posts WHERE post_status = "publish") published,
(SELECT count(*) FROM wp_posts WHERE post_status = "draft") drafts,
(SELECT count(*) FROM wp_posts WHERE post_status = "trash") trashed
')prog[
set[
'posts',
Database.mirror('posts', { 'post_status': 'publish' }, { 'limit': 5 })
.query('SELECT ID, post_title, comment_count FROM wp_posts')
],
map[
var['posts'],
fn[
['item'],
'Post #' ~ args['item']['ID']
~ ': "' ~ args['item']['post_title']
~ '" (' ~ args['item']['comment_count'] ~ ' comments)'
]
]
]| Component | Requirement | Note |
|---|---|---|
| PHP | 8.4 – 8.5 |
Tested against PHP 8.4 and 8.5 |
| WordPress | 6.4+ |
Tested on modern WordPress releases and Core trunk |
| PHP Extensions | sodium, sqlite3 |
sodium for Ed25519 signature verification; sqlite3 for in-memory database mirroring |
| Environment | Single-site & Multisite | Automated tests run against both configurations |
| Browser | Modern Chromium, Firefox, or Safari | Requires native Web Crypto API and WebAssembly support |
Pre-built release packages compiled by the repository's CI/CD pipeline are distributed as .zip archives via GitHub Releases. These releases ship Expression Lab Professional Edition (governed by the EULA) with bundled frontend assets and scoped dependencies, installable via Plugins → Add New Plugin → Upload Plugin in WordPress.
To build the Community Edition from source:
- Clone the repository into
wp-content/plugins:cd wp-content/plugins git clone https://github.com/andersonsalas/expressionlab.git cd expressionlab
- Install PHP dependencies:
(For a build without development tooling, use
composer install
composer install --no-dev --optimize-autoloader.) - Install JavaScript dependencies and compile frontend assets:
pnpm install pnpm run build
- Navigate to Tools → Expression Lab in the WordPress administration dashboard as an administrator.
- Complete the onboarding wizard by defining a master passphrase.
- Append the generated constants to
wp-config.php:
define( 'EXPRESSION_LAB_ADMIN_USER_ID', 1 );
define( 'EXPRESSION_LAB_ADMIN_PUBLIC_KEY', 'your_hex_encoded_public_key' );
define( 'EXPRESSION_LAB_ADMIN_SALT', 'your_unique_salt' );- Reload the administration interface.
# Linting (PHPCS, ESLint, Stylelint)
pnpm run lint
# Automated Tests
pnpm run test:php # PHPUnit (Single-site)
pnpm run test:php:ms # PHPUnit (Multisite)
pnpm run test:php:all # PHPUnit (Single-site + Multisite)
pnpm run test:js # Jest (Frontend)
# Frontend Builds
pnpm run dev # Development build
pnpm run watch # Incremental watch mode
pnpm run dev-server # Webpack Encore dev server (HMR)
pnpm run build # Production minified bundleTip
Frontend Hot Reload: Because the sandboxed iframe blocks localStorage access, disable the iframe sandbox in wp-config.php during local UI development (define( 'EXPRESSION_LAB_SANDBOX_ENABLED', false );) and keep it enabled otherwise.
pnpm run docs:dev # Start local docs server (English)
pnpm run docs:dev:es # Start local docs server (Spanish)
pnpm run docs:build # Build static docs
pnpm run docs:serve # Preview built docsFull guides and API references are available at docs.expressionlab.io (Español):
- Getting Started: Installation & Configuration · Basic Syntax · Scripting
- API Reference: Database · Options · Cache · Network Sites · Users · Posts · Media · Files · HTTP · Console · IP Lookup · Graph
- Security & Environment: Security Model
- Contributing: See CONTRIBUTING.md and CODE_OF_CONDUCT.md. Working branches (
fix/*,improve/*,feature/*) targetmastervia Pull Requests and must passpnpm run lintandpnpm run test. - Security Inquiries: Do not report vulnerabilities via public issues. See SECURITY.md or submit reports via GitHub Security Advisories or
github@andersonsalas.com.
- Professional Edition: The version distributed via GitHub Releases and compiled by this repository's CI/CD pipeline is proprietary software and is governed by the End-User License Agreement (EULA).
- Community Edition: The standalone base source code hosted in this repository is licensed under the GNU General Public License v2.0 or later (GPL-2.0-or-later).