Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#17279 closed defect (bug) (fixed)

No need to run twentyeleven_url_grabber twice

Reported by: duck_'s profile duck_ Owned by: lancewillett's profile lancewillett
Milestone: 3.2 Priority: normal
Severity: normal Version: 3.2
Component: Themes Keywords: has-patch
Focuses: Cc:


Just run it once to get the result and if that's false then replace it with the permalink.

Related: #17267

Attachments (1)

17279.diff (1.1 KB) - added by duck_ 13 years ago.

Download all attachments as: .zip

Change History (5)

13 years ago

#1 @Otto42
13 years ago

Always best to be explicit about it. I'd suggest this style instead:

if ( false == ( $link_url = twentyeleven_url_grabber() ) ) {
  $link_url = get_permalink();

#2 @duck_
13 years ago

I initially did that but personally found it a bit harder to read, but achieves the same result.

#3 @lancewillett
13 years ago

Even better is to run it once and use get_permalink() only as a fallback. empty() catches the false and an empty string.

$link_url = twentyeleven_url_grabber();
if ( empty( $link_url ) )
   $link_url = get_permalink();

#4 @lancewillett
13 years ago

  • Owner set to lancewillett
  • Resolution set to fixed
  • Status changed from new to closed

In [17917]:

Twenty Eleven: run twentyeleven_url_grabber once in widgets.php, props duck_ -- closes #17279

Note: See TracTickets for help on using tickets.