html entities in permalink and extraneous forward slash and dash
4 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: March 18 (RSS)
By kitsguru - February 10
When someone uses smart quotes in a field used in the permalink, it is encoded into the permalink.
I have added this to the plugin.
$GLOBALS['PERMALINKS']['autopopulate_skipWords'] = array("lsquo", "rsquo","ldquo","rdquo"); // array of words to remove from permalinks
Also, these two modifications around line 215
$permalinkText = preg_replace("/\/+/", '/', $permalinkText); // collapse multiple forward slashes
$permalinkText = preg_replace("/\/-+/", '/', $permalinkText); // remove - after /
By Dave - February 22
Hi Jeff,
Thanks so much for the report and code suggestions.
There might be even more HTML entities so we decided to call html_entity_decode() so unknown chars can be filtered out and we don't to list them all in autopopulate_skipWords.
Can you try the attached plugin and let me know if resolves the issue for you? If so we'll release this update.
interactivetools.com
By kitsguru - February 22
This line is actually dash not underscore which is a good thing, but removing the underscores would also be good
$permalinkText = preg_replace("/(^-+|-+$)/", '', $permalinkText); // remove leading and trailing underscores
should be
$permalinkText = preg_replace("/(^-+|-+$)/", '', $permalinkText); // remove leading and trailing dashes
$permalinkText = preg_replace("/(^_+|_+$)/", '', $permalinkText); // remove leading and trailing undeerscores
There is some debate on whether underscores should be replaced with dash.
Replacing & with 'and' can lead to poor a permalink, i.e. good&bad gets converted to goodandbad where good-and-bad would be better.
Anyway, that's what I came up with so far.
Hi Jeff,
Thanks for the feedback! We've released permalinks v1.12 with the following changes:
- Automatically remove “smart” ‘quotes’ instead of encoding them as HTML entities (lsquo, rsquo, etc.)
- Automatically remove periods when creating permalinks
- Add spaces when replacing & so "this&that" becomes "this-and-that" instead of "thisandthat"
- Misc Code and other minor improvements
The latest version can be downloaded here: https://www.interactivetools.com/plugins/permalinks/
interactivetools.com