Skip to content

Auto-link URLs in plain text content - #314

Open
pfefferle wants to merge 2 commits into
trunkfrom
fix/303-autolink-urls-in-plain-text
Open

Auto-link URLs in plain text content#314
pfefferle wants to merge 2 commits into
trunkfrom
fix/303-autolink-urls-in-plain-text

Conversation

@pfefferle

Copy link
Copy Markdown
Member

Summary

  • Uses WordPress's make_clickable() function to automatically convert URLs in plain text content to clickable links
  • Only applies to plain text content, not HTML content which is preserved as-is
  • HTML content with existing links, code blocks, and pre blocks are not modified

Fixes #303

@pfefferle
pfefferle requested a review from Copilot January 11, 2026 22:35
@pfefferle pfefferle self-assigned this Jan 11, 2026
@pfefferle
pfefferle requested a review from dshanske January 11, 2026 22:36
@pfefferle
pfefferle force-pushed the fix/303-autolink-urls-in-plain-text branch from af535dd to da50f52 Compare January 11, 2026 22:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds automatic URL linking functionality to plain text content submitted via the Micropub endpoint. When users submit posts with plain text content containing URLs, those URLs will now be automatically converted to clickable HTML links using WordPress's make_clickable() function.

Changes:

  • Modified the content processing logic to apply make_clickable() to plain text content after HTML escaping
  • Added comprehensive test coverage for both plain text auto-linking and HTML content preservation scenarios

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
includes/rest/class-endpoint-controller.php Updated mp_to_wp() method to apply make_clickable() to plain text content while preserving HTML content as-is
tests/test_endpoint.php Added 6 new test cases covering plain text URL auto-linking, multiple URLs, and verification that HTML content remains unchanged

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread includes/rest/class-endpoint-controller.php Outdated
Comment thread tests/phpunit/tests/class-test-endpoint.php
Use WordPress's make_clickable() function to automatically convert
URLs in plain text content to clickable links. This only applies
to plain text content, not HTML content which is preserved as-is.

Fixes #303
@pfefferle
pfefferle force-pushed the fix/303-autolink-urls-in-plain-text branch from da50f52 to c02afb0 Compare July 8, 2026 10:44
Apply make_clickable() to the content value fallback as well, so plain
text is auto-linked consistently whether it arrives as a string or as
an array with a value property. Guard the html key access while at it:
a value-only content array previously triggered an undefined array key
warning on PHP 8.
@pfefferle
pfefferle requested review from a team and snarfed July 8, 2026 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Auto-link URLs in plain text content

2 participants