[wp-trac] [WordPress Trac] #23570: Add functions to extract a URL from an arbitrary string, HTML, or the current $post

WordPress Trac noreply at wordpress.org
Thu Feb 21 02:02:49 UTC 2013


#23570: Add functions to extract a URL from an arbitrary string, HTML, or the
current $post
----------------------------+-------------------------
 Reporter:  wonderboymusic  |       Type:  enhancement
   Status:  new             |   Priority:  normal
Milestone:  3.6             |  Component:  General
  Version:                  |   Severity:  normal
 Keywords:  has-patch       |
----------------------------+-------------------------
 = Scenarios

 My post has a format of "link"
 - My post has format meta for URL
 - OR - My post content is a URL
 - OR - My post contains an <a> tag with an href
 - OR - My post content is a URL followed by new line(s) and commentary

 An arbitrary string might be only a URL, a URL with some commentary, or a
 blob of HTML that might contain an <a> with an href attribute

 Introduce `the_link()` and `get_the_link( $id = 0 )` which will
 arbitrarily extract a URL from a post's content.

 Introduce `get_content_link( &$content, $remove = false )` to find a URL
 in an arbitrary string meeting the above criteria and optionally remove
 the found URL if it wasn't embedded in HTML content.

 = Tested

 Theme doesn't support 'link' post format, but post has 'link' post format.
 `the_content()` is called.
 - Not in the post and has meta: only shows once
 - In the post and has meta: nothing changes, only shows once
 - URL in the post and has meta with a different URL: both links show, the
 meta url is formatted
 - In the post and has no meta: wrapped in an <a> tag with the `post_title`
 as anchor text, if present, only shows once
 - In the post as an href and has meta: nothing changes, only shows once
 - In the post as an href and has no meta: nothing changes, only shows once

 Theme doesn't support 'link' post format, but post has 'link' post format,
 and `the_link()` and `the_content()` are called in succession.
 - Not in the post and has meta: URL is output, content is output with a
 formatted link. Themer should use if / else.
 - In the post and has meta: URL is output, content is output unchanged.
 Themer should use if / else.
 - URL in the post and has meta with a different URL: meta URL is output,
 post URL remains, meta URL is formatted and added to post. Themer should
 use if / else.
 - In the post and has no meta: URL is output, content is output with a
 formatted link. Themer should use if / else.
 - In the post as an href and has meta: URL is output, content is
 unchanged. Themer should use if / else.
 - In the post as an href and has no meta: URL is output, content is
 unchanged. Themer should use if / else.

 Theme does support 'link' post format. `the_content()` is called.
 - Not in the post and has meta: Content is unchanged.
 - In the post and has meta: Content is unchanged.
 - URL in the post and has meta with a different URL: Content is unchanged.
 - In the post and has no meta: Content is unchanged.
 - In the post as an href and has meta: Content is unchanged.
 - In the post as an href and has no meta: Content is unchanged.

 Theme does support 'link' post format. `the_link()` and `the_content()`
 are called in succession.
 - Not in the post and has meta: URL is output, Content is unchanged.
 - In the post and has meta: URL is output, Content is unchanged.
 - URL in the post and has meta with a different URL: Meta URL is output,
 Content is unchanged.
 - In the post and has no meta: URL is output, Content is unchanged.
 - In the post as an href and has meta: URL is output, Content is
 unchanged.
 - In the post as an href and has no meta: URL is output, Content is
 unchanged.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/23570>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list