Make WordPress Core

Ticket #7874: 7874.1.diff

File 7874.1.diff, 1.6 KB (added by ShaneF, 17 years ago)
  • query.php

     
    871871        var $is_preview = false;
    872872
    873873        /**
     874         * Set if query is a sticky post.
     875         *
     876         * @since 2.7.0
     877         * @access public
     878         * @var bool
     879         */
     880        var $is_sticky = false;
     881
     882        /**
    874883         * Set if query returns a page.
    875884         *
    876885         * @since 1.5.0
     
    10891098         */
    10901099        function init_query_flags() {
    10911100                $this->is_single = false;
     1101                $this->is_sticky = false;
    10921102                $this->is_page = false;
    10931103                $this->is_archive = false;
    10941104                $this->is_date = false;
     
    23042314                        // Loop over posts and relocate stickies to the front.
    23052315                        for ( $i = 0; $i < $num_posts; $i++ ) {
    23062316                                if ( in_array($this->posts[$i]->ID, $sticky_posts) ) {
     2317                                        // Mark it 'sticky' so is_sticky() returns true
     2318                                        $this->posts[$i]->is_sticky = true;
     2319                                        // Gather the data for the sticky post
    23072320                                        $sticky_post = $this->posts[$i];
    23082321                                        // Remove sticky from current position
    23092322                                        array_splice($this->posts, $i, 1);
     
    23822395        }
    23832396
    23842397        /**
     2398         * Return if the post is stickyed or not.
     2399         *
     2400         * Returns true if post is considered sticky, false if not.
     2401         *
     2402         * @since 2.7.0
     2403         * @access public
     2404         * @uses $post
     2405         * @uses do_action() Calls 'sticky_post'.
     2406         */
     2407        function is_sticky() {
     2408                global $post;
     2409                if ( $post->is_sticky == 1 ) {
     2410                        do_action('sticky_post');
     2411                        return true;
     2412                } else {
     2413                        return false;
     2414                }
     2415        }
     2416
     2417        /**
    23852418         * Whether there are more posts available in the loop.
    23862419         *
    23872420         * Calls action 'loop_end', when the loop is complete.