mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 04:40:26 +00:00
Sticky Posts, firct cut. see #7457
git-svn-id: https://develop.svn.wordpress.org/trunk@8546 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -482,6 +482,8 @@ function get_posts($args = null) {
|
||||
} elseif ( ! empty($r['exclude']) )
|
||||
$r['post__not_in'] = preg_split('/[\s,]+/',$r['exclude']);
|
||||
|
||||
$r['caller_get_posts'] = true;
|
||||
|
||||
$get_posts = new WP_Query;
|
||||
return $get_posts->query($r);
|
||||
|
||||
@@ -749,6 +751,30 @@ function get_post_custom_values( $key = '', $post_id = 0 ) {
|
||||
return $custom[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* is_sticky() - Check if post is sticky
|
||||
*
|
||||
* {@internal Missing Long Description}}
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Post
|
||||
* @since 2.7
|
||||
*
|
||||
* @param int $post_id A post ID
|
||||
* @return bool
|
||||
*/
|
||||
function is_sticky($post_id) {
|
||||
$stickies = get_option('sticky_posts');
|
||||
|
||||
if ( !is_array($stickies) )
|
||||
return false;
|
||||
|
||||
if ( in_array($post_id, $stickies) )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* sanitize_post() - Sanitize every post field
|
||||
*
|
||||
@@ -847,6 +873,58 @@ function sanitize_post_field($field, $value, $post_id, $context) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a post sticky
|
||||
*
|
||||
* Makes a post stick to the top of the front page
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Post
|
||||
* @since 2.7
|
||||
*
|
||||
* @param int $post_id A post ID
|
||||
*/
|
||||
function stick_post($post_id) {
|
||||
$stickies = get_option('sticky_posts');
|
||||
|
||||
if ( !is_array($stickies) )
|
||||
$stickies = array($post_id);
|
||||
|
||||
if ( ! in_array($post_id, $stickies) )
|
||||
$stickies[] = $post_id;
|
||||
|
||||
update_option('sticky_posts', $stickies);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unstick a post
|
||||
*
|
||||
* Unstick a post from the front page
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Post
|
||||
* @since 2.7
|
||||
*
|
||||
* @param int $post_id A post ID
|
||||
*/
|
||||
function unstick_post($post_id) {
|
||||
$stickies = get_option('sticky_posts');
|
||||
|
||||
if ( !is_array($stickies) )
|
||||
return;
|
||||
|
||||
if ( ! in_array($post_id, $stickies) )
|
||||
return;
|
||||
|
||||
$offset = array_search($post_id, $stickies);
|
||||
if ( false === $offset )
|
||||
return;
|
||||
|
||||
array_splice($stickies, $offset, 1);
|
||||
|
||||
update_option('sticky_posts', $stickies);
|
||||
}
|
||||
|
||||
/**
|
||||
* Count number of posts of a post type and is user has permissions to view.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user