返回介绍

get_others_unpublished_posts()

发布于 2017-09-10 23:41:02 字数 2542 浏览 1132 评论 0 收藏 0

Warning: This function has been deprecated. Use get_posts() instead.

get_others_unpublished_posts( int $user_id,  string $type = 'any' )

Retrieves editable posts from other users.


description


参数

$user_id

(int) (Required) User ID to not retrieve posts from.

$type

(string) (Optional) Post type to retrieve. Accepts 'draft', 'pending' or 'any' (all).

Default value: 'any'


返回值

(array) List of posts from others.


源代码

File: wp-admin/includes/deprecated.php

function get_others_unpublished_posts( $user_id, $type = 'any' ) {
	_deprecated_function( __FUNCTION__, '3.1.0' );

	global $wpdb;

	$editable = get_editable_user_ids( $user_id );

	if ( in_array($type, array('draft', 'pending')) )
		$type_sql = " post_status = '$type' ";
	else
		$type_sql = " ( post_status = 'draft' OR post_status = 'pending' ) ";

	$dir = ( 'pending' == $type ) ? 'ASC' : 'DESC';

	if ( !$editable ) {
		$other_unpubs = '';
	} else {
		$editable = join(',', $editable);
		$other_unpubs = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_title, post_author FROM $wpdb->posts WHERE post_type = 'post' AND $type_sql AND post_author IN ($editable) AND post_author != %d ORDER BY post_modified $dir", $user_id) );
	}

	return apply_filters('get_others_drafts', $other_unpubs);
}

更新日志

Versiondescription
3.1.0Use get_posts()
2.3.0Introduced.

相关函数

Uses

  • wp-admin/includes/deprecated.php: get_editable_user_ids()
  • wp-includes/functions.php: _deprecated_function()
  • wp-includes/plugin.php: apply_filters()
  • wp-includes/wp-db.php: wpdb::get_results()
  • wp-includes/wp-db.php: wpdb::prepare()

Used By

  • wp-admin/includes/deprecated.php: get_others_drafts()
  • wp-admin/includes/deprecated.php: get_others_pending()

User Contributed Notes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文