Make WordPress Core

Changeset 45671


Ignore:
Timestamp:
07/25/2019 01:35:52 AM (7 years ago)
Author:
SergeyBiryukov
Message:

Posts, Post Types: Introduce is_sticky filter in is_sticky() to provide more flexibility for custom sticky post implementations.

Props dehisok, greenshady.
Fixes #37629.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post.php

    r45667 r45671  
    22142214        $stickies = get_option( 'sticky_posts' );
    22152215
    2216         if ( ! is_array( $stickies ) ) {
    2217                 return false;
    2218         }
    2219 
    2220         if ( in_array( $post_id, $stickies ) ) {
    2221                 return true;
    2222         }
    2223 
    2224         return false;
     2216        $is_sticky = is_array( $stickies ) && in_array( $post_id, $stickies );
     2217
     2218        /**
     2219         * Filters whether a post is sticky.
     2220         *
     2221         * @since 5.3.0
     2222         *
     2223         * @param bool $is_sticky Whether a post is sticky.
     2224         * @param int  $post_id   Post ID.
     2225         */
     2226        return apply_filters( 'is_sticky', $is_sticky, $post_id );
    22252227}
    22262228
Note: See TracChangeset for help on using the changeset viewer.