mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-14 09:34:41 +00:00
Posts: Add hooks for post sticky status changes.
This adds a new `post_stuck` action that fires when a post is made sticky and a `post_unstuck` action that fires when the sticky flag is removed again. Props ojrask. Fixes #35600. git-svn-id: https://develop.svn.wordpress.org/trunk@37857 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -2169,7 +2169,18 @@ function stick_post( $post_id ) {
|
||||
if ( ! in_array($post_id, $stickies) )
|
||||
$stickies[] = $post_id;
|
||||
|
||||
update_option('sticky_posts', $stickies);
|
||||
$updated = update_option( 'sticky_posts', $stickies );
|
||||
|
||||
if ( $updated ) {
|
||||
/**
|
||||
* Fires once a post has been added to the sticky list.
|
||||
*
|
||||
* @since 4.6.0
|
||||
*
|
||||
* @param int $post_id ID of the post that was stuck.
|
||||
*/
|
||||
do_action( 'post_stuck', $post_id );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2196,7 +2207,18 @@ function unstick_post( $post_id ) {
|
||||
|
||||
array_splice($stickies, $offset, 1);
|
||||
|
||||
update_option('sticky_posts', $stickies);
|
||||
$updated = update_option( 'sticky_posts', $stickies );
|
||||
|
||||
if ( $updated ) {
|
||||
/**
|
||||
* Fires once a post has been removed from the sticky list.
|
||||
*
|
||||
* @since 4.6.0
|
||||
*
|
||||
* @param int $post_id ID of the post that was unstuck.
|
||||
*/
|
||||
do_action( 'post_unstuck', $post_id );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user