[Plugin: Advanced Permalinks] Workaround to allow periods in permalinks
-
I had recently been using Advanced Permalinks just to allow periods in permalinks (so I could give my permalinks names like “page-name.html” to make it backwards compatible with an old, static HTML site it replaced).
When I upgraded to 3.3.2, Advanced Permalinks stopped working and started giving me unlimited redirects. Boo.
Since I was just using it to allow periods in permalinks, I found the relevant section in the plugin, extracted it, and deactivated everything else.
Here’s the code, slightly modified. You can just place this in your functions.php file. It seems to be working and hasn’t yet created any problems for me.
global $wp_rewrite; remove_filter ('sanitize_title', 'sanitize_title_with_dashes'); add_filter ('sanitize_title', 'sanitize_title2'); function sanitize_title2 ($title) { $title = strip_tags($title); // Preserve escaped octets. $title = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '---$1---', $title); // Remove percent signs that are not part of an octet. $title = str_replace('%', '', $title); // Restore octets. $title = preg_replace('|---([a-fA-F0-9][a-fA-F0-9])---|', '%$1', $title); $title = remove_accents($title); if (seems_utf8($title)) { if (function_exists('mb_strtolower')) { $title = mb_strtolower($title, 'UTF-8'); } $title = utf8_uri_encode($title); } $title = strtolower($title); $title = preg_replace('/&.+?;/', '', $title); // kill entities $title = preg_replace('/[^%a-z0-9\. _-]/', '', $title); $title = preg_replace('/\s+/', '-', $title); $title = preg_replace('|-+|', '-', $title); $title = trim($title, '-'); return $title; }
https://www.ads-software.com/extend/plugins/advanced-permalinks/
- The topic ‘[Plugin: Advanced Permalinks] Workaround to allow periods in permalinks’ is closed to new replies.