Skip to content
Epiktetos Theme1.2.0
1.2.02 min read

JavaScript Behavior

Front-end and admin JavaScript behavior included in Epiktetos.

Epiktetos enqueues JavaScript conditionally from functions.php and feature classes.

Front-end scripts

HandleFileCondition
epiktetos-headerassets/js/header.jsLoaded on the front end.
epiktetos-categoriesassets/js/categories.jsLoaded on the front page except the saved route.
epiktetos-singleassets/js/single.jsLoaded on singular posts.
epiktetos-readerassets/js/reader.jsLoaded on saved route, front page, single posts, archives, and search.
epiktetos-voiceoverassets/js/voiceover.jsLoaded 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:

Code
/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.

Related articles