From 8ab7bbe3857ceb5206f9caffcbf73580adf011c3 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 25 Jul 2019 01:36:54 +0000 Subject: [PATCH] Posts, Post Types: Introduce `is_sticky` filter in `is_sticky()` to provide more flexibility for custom sticky post implementations. Props dehisok, greenshady. Fixes #37629. Built from https://develop.svn.wordpress.org/trunk@45671 git-svn-id: http://core.svn.wordpress.org/trunk@45482 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post.php | 18 ++++++++++-------- wp-includes/version.php | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index 44411baa0d..499f800d67 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -2213,15 +2213,17 @@ function is_sticky( $post_id = 0 ) { $stickies = get_option( 'sticky_posts' ); - if ( ! is_array( $stickies ) ) { - return false; - } + $is_sticky = is_array( $stickies ) && in_array( $post_id, $stickies ); - if ( in_array( $post_id, $stickies ) ) { - return true; - } - - return false; + /** + * Filters whether a post is sticky. + * + * @since 5.3.0 + * + * @param bool $is_sticky Whether a post is sticky. + * @param int $post_id Post ID. + */ + return apply_filters( 'is_sticky', $is_sticky, $post_id ); } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index 5d5dda23c2..b21930f971 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.3-alpha-45670'; +$wp_version = '5.3-alpha-45671'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.