ascii-slugs is a PHP library and a thin WordPress plugin for sites that handle titles in Devanagari, Tamil, Urdu, Cyrillic and other non-Latin scripts. It turns those titles into short, readable ASCII slugs. It is MIT licensed, and v0.1.0 was released on 14 November 2026.
When a title is not in Latin script, WordPress keeps the UTF-8 bytes of the slug and percent-encodes them. Each byte costs three characters, such as %e0, so one Devanagari code point costs nine. The slug column holds 200 bytes, and WordPress cuts the encoded slug there without a warning. In Devanagari that keeps about 22 code points, and the URL usually stops in the middle of a word. Nothing errors and nothing is logged. The broken URL is then shared, indexed and linked for good.
The README’s example: a 38 code point Hindi headline needs 286 bytes once encoded, so WordPress stores a slug cut at 200 bytes. The ascii-slugs result is 49 bytes: chandrayan-mishan-ki-saphalata-par-desh-men-jashn.
Encoded slugs have other costs. Links pasted into chat or email show as long %E0%A4 strings and some tools break them. Two titles that differ only after the 22nd code point get the same cut slug plus a -2. Logs and cache keys become hard to read.
intl extension.post-20261112-459eae08 when a slug would be unreadable.wp ascii-slugs audit and repair. Repair is a dry run unless you pass --yes.intl is available.The library lives in the namespace IndianOpinion\AsciiSlugs, has no dependencies and no WordPress code. Slugger::slug() works in five steps:
intl is present, or are dropped.[a-z0-9] joined by single hyphens, and cut at a word boundary under maxLength (default 80).{prefix}-{yyyymmdd}-{hash}.use IndianOpinion\AsciiSlugs\Slugger;
$slugger = new Slugger();
$result = $slugger->slug('ISRO का चंद्रयान-3 मिशन');
$result->slug; // "isro-ka-chandrayan-3-mishan"
$result->method; // "transliterated"
$result->coverage; // 1.0
In WordPress, the plugin hooks sanitize_title at priority 9 and acts only in the save context, and only when core would percent-encode something. A hook on wp_unique_post_slug catches slugs that arrive already encoded and finishes with core’s own uniqueness check. A hook on pre_term_slug protects existing term slugs on edit. The plugin stores nothing: no options, tables, post meta or files.
Repair builds each new slug from the stored title and saves through wp_update_post(), so core records the old slug and its old-slug redirect sends the old URL to the new one with a 301.
define('ASCII_SLUGS_DISABLED', true); or return false from ascii_slugs_enabled. Every hook then returns its input unchanged.ascii_slugs_slug is cleaned again to [a-z0-9-] and maxLength. maxLength is capped at 190, so core’s suffix always fits in 200 bytes.pre_term_slug guard returns the stored encoded slug when the decoded value matches.wp_update_post() saves the post again. Repair now lifts the kses filters for that one save and restores them.REGEXP count over every published row, which the review measured at 36 seconds on a million rows that did not fit the buffer pool. It now does a capped index-only count first and skips the encoded count above 100,000 posts.strip_tags() dropped everything after a bare <, so a title containing 3<5 lost its tail. The table review also fixed জ্ঞ to give gy and Malayalam ന്റ to give nt.कमला gives kamala. Urdu comes out mostly as a consonant skeleton with long vowels, apart from twenty common words spelled from an exception list.intl or get the hash.ascii_slugs_repaired is the hook for that.Test status: this is v0.1.0. There are 264 PHPUnit tests on PHP 8.3, the same 264 on PHP 8.1 without intl (two intl tests skipped), PHPStan level 8 and phpcs clean. The tests use stubs and mocks, not a live WordPress site, and the plugin has not run on a live site. CI has not run on GitHub yet. It was specified, built and reviewed in separate roles by language-model coding agents under the editor’s direction.
It needs PHP 8.1 or later. The plugin needs WordPress 6.4 or later and no Composer at runtime.
composer require indianopinion/ascii-slugs
The package is not on Packagist yet, so add a Composer vcs repository entry for https://github.com/IndianOpinion/ascii-slugs first.
Without Composer, require bootstrap.php for the library, or copy the ascii-slugs folder to wp-content/plugins/ and activate it.