Make WordPress Core

Opened 16 years ago

Closed 15 years ago

#7874 closed enhancement (wontfix)

the_sticky() to "the loop"

Reported by: shanef's profile ShaneF Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.7
Component: Template Keywords: needs-patch reporter-feedback
Focuses: Cc:

Description

Adds a new loop function 'is_sticky'.

Attachments (1)

7874.1.diff (1.6 KB) - added by ShaneF 16 years ago.

Download all attachments as: .zip

Change History (12)

@ShaneF
16 years ago

#1 @westi
16 years ago

  • Keywords reporter-feedback added; has-patch commit removed

What is wrong with the existing is_sticky() function that we already have?

#2 @ShaneF
16 years ago

  • Milestone 2.7 deleted
  • Resolution set to worksforme
  • Status changed from new to closed

Wait? There is one? :o

#3 @ShaneF
16 years ago

  • Keywords reporter-feedback removed

#4 @ShaneF
16 years ago

  • Milestone set to 2.7
  • Resolution worksforme deleted
  • Status changed from closed to reopened
/**
 * Output 'Sticky', if the post is sticky.
 *
 * Used from within 'The Loop' to allow string output of what ever you want,
 * if the current post is a sticky post.
 *
 * @since 2.7.0
 *
 * @param str $sticky What are we outputing? default: Sticky
 * @param str $before Pre-prend our text
 * @param str $after What are we going to place afterwords
 * @param bool $echo Default to true. False for return.
 */
function the_sticky($sticky = '', $before = '', $after = '', $echo = true) {
	global $id;
	
	if (!is_sticky(absint($id)))
		return;
	
	if ( strlen($sticky) == 0 )
		$sticky = __('Sticky');

	$sticky = $before . $sticky . $after;

	if ( $echo )
		echo apply_filters( 'the_sticky', $sticky );
	else
		return apply_filters( 'the_sticky', $sticky );
		
}

This is what I was trying to do. For inside wp-includes/post.php

#5 @ShaneF
16 years ago

  • Summary changed from is_sticky() to "the loop" to the_sticky() to "the loop"

#6 @ShaneF
16 years ago

function the_sticky($sticky = '', $before = '', $after = '', $echo = true) {
	global $id;
	
	if (!is_sticky(absint($id)))
		return;
	
	if ( strlen($sticky) == 0 ) {
		if (!is_sticky(absint($id)))
			return false;
		else
			return true;
	}

	$sticky = $before . $sticky . $after;

	if ( $echo )
		echo apply_filters( 'the_sticky', $sticky );
	else
		return apply_filters( 'the_sticky', $sticky );
		
}

This is a better version... :)

#7 @ryan
16 years ago

  • Milestone changed from 2.7 to 2.8

Moving enhancements to 2.8.

#8 @ShaneF
15 years ago

  • Keywords has-patch added

#9 @Denis-de-Bernardy
15 years ago

  • Keywords needs-patch reporter-feedback added; has-patch removed
  • Milestone changed from 2.8 to Future Release

Please expand on what you're trying to do a little, too. I personally fail to see how this the_sticky() function is useful.

Also, that the patch is for an is_sticky() function, which makes the ticket a bit confusing.

#10 @Denis-de-Bernardy
15 years ago

  • Component changed from General to Template

#11 @Denis-de-Bernardy
15 years ago

  • Milestone Future Release deleted
  • Resolution set to wontfix
  • Status changed from reopened to closed

no apparent interest, and can be done with a plugin

Note: See TracTickets for help on using tickets.