JavaScript Behavior
Front-end and admin JavaScript behavior included in Epiktetos.
Epiktetos enqueues JavaScript conditionally from functions.php and feature classes.
Front-end scripts
| Handle | File | Condition |
|---|---|---|
epiktetos-header | assets/js/header.js | Loaded on the front end. |
epiktetos-categories | assets/js/categories.js | Loaded on the front page except the saved route. |
epiktetos-single | assets/js/single.js | Loaded on singular posts. |
epiktetos-reader | assets/js/reader.js | Loaded on saved route, front page, single posts, archives, and search. |
epiktetos-voiceover | assets/js/voiceover.js | Loaded on singular posts when a valid Article Voiceover audio file exists. |
The header script receives localized strings for controls such as dark mode, light mode, and search.
Admin scripts
Admin classes enqueue scripts for settings screens, wizard behavior, category ordering, and admin tooling where needed. The category order screen uses jQuery UI Sortable.
Article Voiceover also enqueues assets/js/voiceover-admin.js on post editor screens. It opens the WordPress Media Library filtered to audio attachments and stores the selected attachment ID in post meta.
Article Voiceover behavior
The frontend voiceover script progressively enhances a native <audio controls> element. If JavaScript fails or is disabled, the native browser player remains visible and usable. When enhancement succeeds, the script builds a small custom control set for play/pause, current time, timeline seeking, duration, mute, and playback speed.
REST behavior
The search feature registers a public REST endpoint:
/wp-json/epiktetos/v1/search
It accepts a search query argument, requires at least two characters, and returns up to five post results with title, category, excerpt, permalink, date, and reading-time data.
Public endpoint
The search endpoint intentionally uses a public permission callback. Keep the response limited to public post data if extending it.