-
Notifications
You must be signed in to change notification settings - Fork 0
Managed JS Files
Pro feature. Managed JS Files requires an active Scriptomatic Pro licence. A 3-day free trial is available — visit Scriptomatic → Account.
Create, edit, upload, and delete standalone .js files stored in wp-content/uploads/scriptomatic/. Each file has its own Head/Footer selector, load conditions, CodeMirror editor, and activity log. Files persist across plugin updates because they live in the uploads directory, not the plugin folder.
Navigate to Scriptomatic → JS Files to see the list of all managed files. The table shows:
- Label — human-readable name
-
Filename — the
.jsfilename on disk - Location — Head or Footer
- Conditions — summary of load conditions (or "All pages")
- Edit / Delete links
An Upload a JS File card at the top lets you import a local .js file directly from your computer.
- Go to Scriptomatic → JS Files
- Click Add New JS File
- Enter a Label, optional Filename (auto-generated from label if left blank), Head / Footer location
- Write or paste JavaScript in the CodeMirror editor
- Optionally set Load Conditions to restrict when the file loads
- Click Save JS File
Click Edit next to any file in the list. The edit page shows:
- The CodeMirror editor with the current file contents
- Label, filename, Head/Footer selector, and Load Conditions
- A per-file Activity Log panel at the bottom (file saves, rollbacks, deletes)
From the list page UI:
- Click Choose File in the Upload card and select a local
.jsfile - Click Upload & Edit — you are taken to the edit page to review the code and set label, location, and conditions before the file goes live
Via REST API:
curl -X POST https://example.com/wp-json/scriptomatic/v1/files/upload \
-H "Authorization: Basic $(echo -n 'admin:xxxx xxxx xxxx xxxx xxxx xxxx' | base64)" \
-F "file=@/path/to/tracker.js" \
-F "label=My Tracker" \
-F "location=head"Via WP-CLI:
wp scriptomatic files upload --path=/path/to/tracker.js --label="My Tracker" --location=headClick Delete on the list page, or use the Delete button on the edit page. Confirm the prompt. The file is removed from disk and its metadata is removed from scriptomatic_js_files. The deletion is recorded in the Activity Log.
All upload paths (admin UI, REST API, WP-CLI) run through the same central validation:
- Extension must be
.js - MIME type is validated via
finfo_open()/mime_content_type()fallback - File size is checked against the server's
wp_max_upload_size() - Content is validated for UTF-8, control characters, PHP tags, and 100 KB inline limit
Files are stored in: wp-content/uploads/scriptomatic/
The directory is created automatically on first use. The URL is derived from wp_upload_dir(). Because files live in the uploads directory they survive plugin deactivation, reactivation, and updates.
Each file's metadata is stored in the scriptomatic_js_files WordPress option as a JSON array. Each entry:
{
"id": "my-tracker",
"label": "My Tracker",
"filename": "my-tracker.js",
"location": "head",
"conditions": { "logic": "and", "rules": [] }
}← Home