Make WordPress Core

Opened 13 years ago

Closed 9 years ago

Last modified 9 years ago

#20166 closed enhancement (fixed)

Function url_shorten() enhancement

Reported by: mulvane's profile mulvane Owned by: chriscct7's profile chriscct7
Milestone: 4.4 Priority: normal
Severity: normal Version:
Component: Formatting Keywords: has-patch commit
Focuses: Cc:

Description

The function url_open is included in the wp_admin/includes/misc.php and is not usable unless loaded. This is not loaded by default so not available site wide. Also, the function is very static as of right now in its use with no defined options. Options to set length of the shortened url and the ability to turn on off the cutting of the leading "http://www" and the trailing slashes are included in this patch.

Attachments (5)

url_shorten.patch (1.9 KB) - added by mulvane 13 years ago.
20166.patch (2.9 KB) - added by chriscct7 9 years ago.
20166.2.patch (2.9 KB) - added by chriscct7 9 years ago.
typo.diff (1.3 KB) - added by swissspidy 9 years ago.
typo2.diff (1.2 KB) - added by swissspidy 9 years ago.

Download all attachments as: .zip

Change History (19)

#1 @dd32
13 years ago

  • Component changed from General to Formatting
  • Keywords has-patch added
  • Summary changed from Function url_open() enhancement to Function url_shorten() enhancement

Makes sense to move it to a more neutral location perhaps, but I'd suggest that adding anything other than the length cutoff isn't needed for core.

#2 @mulvane
13 years ago

I mostly agree but there are more than a few sites where cutting off the www or removing the trailing slash will break the link. For visual purposes, its nice to see them when they are required.

#3 @nacin
11 years ago

  • Milestone changed from Awaiting Review to Future Release

This seems like a good candidate for formatting.php, versus the generic (and early-loaded) functions.php.

mulvane, you make a good point, but I agree with dd32 that we shouldn't deal with anything in core other than the length cut-off.

#4 @chriscct7
9 years ago

  • Owner set to chriscct7
  • Status changed from new to assigned

#5 @chriscct7
9 years ago

  • Keywords commit added
  • Milestone changed from Future Release to 4.4
  • Status changed from assigned to accepted

Refreshed patch in the formatting file (as requested by nacin). Updated the function with only the one new parameter, updated the docblocs, moved the unit tests, and added a unit test to cover length

@chriscct7
9 years ago

#6 @chriscct7
9 years ago

tests/phpunit/tests/admin/includesMisc.php needs to be removed after this is commmitted

#7 follow-up: @ocean90
9 years ago

  • Keywords commit removed

The function doesn't support https URLs.

Looks to me like a candidate for deprecate.php.

#8 in reply to: ↑ 7 @chriscct7
9 years ago

Replying to ocean90:

The function doesn't support https URLs.

Looks to me like a candidate for deprecate.php.

The function didn't originally support it so I didn't add support when I moved it. It could easily add support

@chriscct7
9 years ago

#9 @chriscct7
9 years ago

New version supports HTTPs

#10 @chriscct7
9 years ago

  • Keywords commit added

#11 @wonderboymusic
9 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 35314:

Formatting: move url_shorten() from wp-admin/includes/misc.php to wp-includes/formatting.php for more global access.

Adds unit tests.

Props mulvane, chriscct7.
Fixes #20166.

@swissspidy
9 years ago

#12 @swissspidy
9 years ago

[35314] broke the function docblock (wrong alignment, typo). typo.diff aims to fix that.

@DrewAPicture Maybe you can have a look at that during contributor day?

@swissspidy
9 years ago

#13 @swissspidy
9 years ago

In 35813:

Docs: After [35314], fix the DocBlock for url_shorten().

See #20166.

#14 @ocean90
9 years ago

In 35815:

Docs: After [35314], fix the DocBlock for url_shorten().

Merge of [35813] for the 4.4 branch.

Props swissspidy.
See #20166.

Note: See TracTickets for help on using tickets.