WP Manifestindependent plugin directory
manifest / utilities / kntnt-fix-colon-in-fragments-of-relative-urls

Kntnt Fix Colon in Fragments of Relative URLs

WordPress mu-plugin that replaces colon with dash before saving content to database.

by Thomas Barregren · github.com/kntnt/kntnt-fix-colon-in-fragments-of-relative-urls · website

0stars
0forks

Install

No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:

wp plugin install https://github.com/kntnt/kntnt-fix-colon-in-fragments-of-relative-urls/archive/refs/heads/master.zip

WordPress mu-plugin that replaces colon with dash before saving content to database.

Description

Colon is allowed in the fragment part of a URI according to RFC 3986 and is allowed in id and name in both HTML4 and HTML5. Despite these facts, WordPress removes everything up to and including the colon when a colon is used in a fragment of a relative or a protocol-relative URL. An example when this cause problem is when HTML generated by Markdown Extra is used, since colon is used in fragments to both link to the footnote (e.g. #fn:1) and link back (e.g. #fnref:1). Thus the need for this "hack" which replace colon with a dash in id and name attributes, and in href attributes that are relative (i.e. not starting with http://, https://. This is done before KSES runs and the post content is saved to the database.

Installation

  1. In your wp-content directory, create a mu-plugin directory if it not already exists.
  2. Copy kntnt-fix-colon-in-fragments-of-relative-urls.php into mu-plugin. Only the file. Not this directory or the other files within it.

Changelog

1.0.0

Initial release.